From 3440dd4bf71078b77405f504412178eb6aee2631 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 14 Sep 2020 14:03:35 +0200 Subject: [PATCH] #766 --- src/ifcconvert/IfcConvert.cpp | 7 +++++-- src/ifcgeom/IfcGeomIteratorSettings.h | 8 +++++++- src/ifcgeom/IfcGeomRepresentation.h | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index 72bccb00fe..357c2a652d 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -197,7 +197,7 @@ int main(int argc, char** argv) { typedef char char_t; #endif - double deflection_tolerance; + double deflection_tolerance, angular_tolerance; inclusion_filter include_filter; inclusion_traverse_filter include_traverse_filter; exclusion_filter exclude_filter; @@ -326,6 +326,8 @@ int main(int argc, char** argv) { "model in other modelling application in any case.") ("deflection-tolerance", po::value(&deflection_tolerance)->default_value(1e-3), "Sets the deflection tolerance of the mesher, 1e-3 by default if not specified.") + ("angular-tolerance", po::value(&angular_tolerance)->default_value(0.5), + "Sets the angular tolerance of the mesher in radians 0.5 by default if not specified.") ("generate-uvs", "Generates UVs (texture coordinates) by using simple box projection. Requires normals. " "Not guaranteed to work properly if used with --weld-vertices.") @@ -708,7 +710,8 @@ int main(int argc, char** argv) { settings.set(SerializerSettings::USE_ELEMENT_TYPES, use_element_types); settings.set(SerializerSettings::USE_ELEMENT_HIERARCHY, use_element_hierarchy); settings.set_deflection_tolerance(deflection_tolerance); - settings.precision = precision; + settings.set_angular_tolerance(angular_tolerance); + settings.precision = precision; boost::shared_ptr serializer; /**< @todo use std::unique_ptr when possible */ if (output_extension == OBJ) { diff --git a/src/ifcgeom/IfcGeomIteratorSettings.h b/src/ifcgeom/IfcGeomIteratorSettings.h index 02b624d05f..f6d0a8f5dc 100644 --- a/src/ifcgeom/IfcGeomIteratorSettings.h +++ b/src/ifcgeom/IfcGeomIteratorSettings.h @@ -101,11 +101,13 @@ namespace IfcGeom IteratorSettings() : settings_(WELD_VERTICES) // OR options that default to true here , deflection_tolerance_(1.e-3) + , angular_tolerance_(0.5) { } /// Note that this is independent of the IFC length unit, one millimeter by default. double deflection_tolerance() const { return deflection_tolerance_; } + double angular_tolerance() const { return angular_tolerance_; } void set_deflection_tolerance(double value) { @@ -118,6 +120,10 @@ namespace IfcGeom } } + void set_angular_tolerance(double value) { + angular_tolerance_ = value; + } + /// Get boolean value for a single settings or for a combination of settings. bool get(SettingField setting) const { @@ -143,7 +149,7 @@ namespace IfcGeom protected: SettingField settings_; - double deflection_tolerance_; + double deflection_tolerance_, angular_tolerance_; }; class IFC_GEOM_API ElementSettings : public IteratorSettings diff --git a/src/ifcgeom/IfcGeomRepresentation.h b/src/ifcgeom/IfcGeomRepresentation.h index d56d66f0c1..63d99c1eb8 100644 --- a/src/ifcgeom/IfcGeomRepresentation.h +++ b/src/ifcgeom/IfcGeomRepresentation.h @@ -163,7 +163,7 @@ namespace IfcGeom { // Triangulate the shape try { - BRepMesh_IncrementalMesh(s, settings().deflection_tolerance()); + BRepMesh_IncrementalMesh(s, settings().deflection_tolerance(), false, settings().angular_tolerance()); } catch(...) { Logger::Message(Logger::LOG_ERROR, "Failed to triangulate shape"); continue;