Skip to content

Commit

Permalink
ISSUE #632 Updated how LOD is exposed and added support for LOD setti…
Browse files Browse the repository at this point in the history
…ngs to FileProcessorRvt
  • Loading branch information
sebjf committed Sep 14, 2023
1 parent 0c179c5 commit abf2e0d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,32 @@ const bool USE_NEW_TESSELLATION = true;
const double TRIANGULATION_EDGE_LENGTH = 1;
const double ROUNDING_ACCURACY = 0.000001;

// The following sets up the level of detail parameters for the FileProcessorRvt.
// The exact meaning of the LOD parameter provided in the config will depend on
// each processor's tessellation method. For Revit, these correspond to different
// tolerances in the BRep triangulator.

struct LevelOfDetailParams
{
int normalTolerance;
double surfaceTolerance;

LevelOfDetailParams(int normalTolerance, double surfaceTolerance) {
this->normalTolerance = normalTolerance;
this->surfaceTolerance = surfaceTolerance;
}
};

const std::vector<LevelOfDetailParams> LOD_PARAMETERS ({
LevelOfDetailParams(15, 0), // Default matches the wrTriangulationParams default constructor when bNewTess is true
LevelOfDetailParams(360, 10000),
LevelOfDetailParams(40, 10000),
LevelOfDetailParams(360, 0.1),
LevelOfDetailParams(360, 0.01),
LevelOfDetailParams(360, 0.005),
LevelOfDetailParams(360, 0.0005),
});

class StubDeviceModuleRvt : public OdGsBaseModule
{
private:
Expand Down Expand Up @@ -186,10 +212,10 @@ uint8_t FileProcessorRvt::readFile()
{
//.. change tessellation params here
wrTriangulationParams triParams(USE_NEW_TESSELLATION);
if (!importConfig.shouldUseAutoTriangulation()) {
if (importConfig.getLevelOfDetail()) {
triParams.bRecalculateSurfaceTolerance = false;
triParams.surfaceTolerance = importConfig.getSurfaceTolerance();
triParams.normalTolerance = importConfig.getNormalTolerance();
triParams.surfaceTolerance = LOD_PARAMETERS[importConfig.getLevelOfDetail()].surfaceTolerance;
triParams.normalTolerance = LOD_PARAMETERS[importConfig.getLevelOfDetail()].normalTolerance;
}
setTessellationParams(triParams);
OdBmDatabasePtr pDb = svcs.readFile(OdString(file.c_str()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ namespace repo {
bool applyReductions;
bool rotateModel;
bool importAnimations;
double surfaceTolerance;
double normalTolerance;
int lod;
std::string timeZone;
ModelUnits targetUnits;
public:
Expand All @@ -51,15 +50,13 @@ namespace repo {
const bool importAnimations = true,
const ModelUnits targetUnits = ModelUnits::UNKNOWN,
const std::string timeZone = "",
const double surfaceTolerance = 0,
const double normalTolerance = 0) :
const int lod = 0) :
applyReductions(applyReductions),
rotateModel(rotateModel),
importAnimations(importAnimations),
targetUnits(targetUnits),
timeZone(timeZone),
surfaceTolerance(surfaceTolerance),
normalTolerance(normalTolerance) {}
lod(lod) {}

~ModelImportConfig() {}

Expand All @@ -68,9 +65,7 @@ namespace repo {
bool shouldImportAnimations() const { return importAnimations; }
std::string getTimeZone() const { return timeZone; }
ModelUnits getTargetUnits() const { return targetUnits; }
bool shouldUseAutoTriangulation() const { return surfaceTolerance == 0 && normalTolerance == 0; }
double getSurfaceTolerance() const { return surfaceTolerance; }
double getNormalTolerance() const { return normalTolerance; }
int getLevelOfDetail() const { return lod; }
};
}//namespace modelconvertor
}//namespace manipulator
Expand Down
10 changes: 4 additions & 6 deletions client/src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,7 @@ int32_t importFileAndCommit(
std::string project;
std::string owner, tag, desc, units;
repo::lib::RepoUUID revId = repo::lib::RepoUUID::createUUID();
double triangulationSurfaceTolerance = 0;
double triangulationNormalTolerance = 0;
int lod = 0;

bool success = true;
bool rotate = false;
Expand All @@ -428,8 +427,7 @@ int32_t importFileAndCommit(
desc = jsonTree.get<std::string>("desc", "");
timeZone = jsonTree.get<std::string>("timezone", "");
units = jsonTree.get<std::string>("units", "");
triangulationSurfaceTolerance = jsonTree.get<double>("surfaceTolerance", 0.0);
triangulationNormalTolerance = jsonTree.get<int>("normalTolerance", 0.0);
lod = jsonTree.get<int>("lod", 0);
rotate = jsonTree.get<bool>("dxrotate", rotate);
importAnimations = jsonTree.get<bool>("importAnimations", importAnimations);
fileLoc = jsonTree.get<std::string>("file", "");
Expand Down Expand Up @@ -496,10 +494,10 @@ int32_t importFileAndCommit(
repoLog("File: " + fileLoc + " database: " + database
+ " project: " + project + " target units: " + (units.empty() ? "none" : units) + " rotate: "
+ (rotate ? "true" : "false") + " owner :" + owner + " importAnimations: " + (importAnimations ? "true" : "false")
+ " surfaceTolerance: " + std::to_string(triangulationSurfaceTolerance) + " normalTolerance: " + std::to_string(triangulationNormalTolerance)
+ " lod: " + std::to_string(lod)
);

repo::manipulator::modelconvertor::ModelImportConfig config(true, rotate, importAnimations, targetUnits, timeZone, triangulationSurfaceTolerance, triangulationNormalTolerance);
repo::manipulator::modelconvertor::ModelImportConfig config(true, rotate, importAnimations, targetUnits, timeZone, lod);
uint8_t err;
repo::core::model::RepoScene *graph = controller->loadSceneFromFile(fileLoc, err, config);
if (graph)
Expand Down

0 comments on commit abf2e0d

Please sign in to comment.