From 9ef234b8424f0ca33f2252a56cfd9c5f2e06b4ac Mon Sep 17 00:00:00 2001 From: Leo Terziman Date: Fri, 17 Mar 2017 11:58:50 +0100 Subject: [PATCH] Added parameter to control cylindrical shapes tessellation + renamed smoothing angle parameter for better user understanding --- code/IFCLoader.cpp | 5 +++-- code/IFCLoader.h | 2 ++ code/IFCProfile.cpp | 4 ++-- include/assimp/config.h.in | 33 +++++++++++++++++++++++++-------- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/code/IFCLoader.cpp b/code/IFCLoader.cpp index ff4eb4b1f..dc31f4c59 100644 --- a/code/IFCLoader.cpp +++ b/code/IFCLoader.cpp @@ -154,8 +154,9 @@ void IFCImporter::SetupProperties(const Importer* pImp) { settings.skipSpaceRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS,true); settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true); - settings.conicSamplingAngle = pImp->GetPropertyFloat(AI_CONFIG_IMPORT_IFC_CONIC_SAMPLING_ANGLE, AI_IMPORT_IFC_DEFAULT_CONIC_SAMPLING_ANGLE); - settings.skipAnnotations = true; + settings.conicSamplingAngle = std::min(std::max(pImp->GetPropertyFloat(AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE, AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE), 5.0f), 120.0f); + settings.cylindricalTessellation = std::min(std::max(pImp->GetPropertyInteger(AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION, AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION), 3), 180); + settings.skipAnnotations = true; } diff --git a/code/IFCLoader.h b/code/IFCLoader.h index 70a7b1685..9fa6cba38 100644 --- a/code/IFCLoader.h +++ b/code/IFCLoader.h @@ -110,6 +110,7 @@ public: , useCustomTriangulation() , skipAnnotations() , conicSamplingAngle(10.f) + , cylindricalTessellation(32) {} @@ -117,6 +118,7 @@ public: bool useCustomTriangulation; bool skipAnnotations; float conicSamplingAngle; + int cylindricalTessellation; }; diff --git a/code/IFCProfile.cpp b/code/IFCProfile.cpp index a84f98f58..866b874c9 100644 --- a/code/IFCProfile.cpp +++ b/code/IFCProfile.cpp @@ -101,7 +101,7 @@ void ProcessOpenProfile(const IfcArbitraryOpenProfileDef& def, TempMesh& meshout } // ------------------------------------------------------------------------------------------------ -void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh& meshout, ConversionData& /*conv*/) +void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh& meshout, ConversionData& conv) { if(const IfcRectangleProfileDef* const cprofile = def.ToPtr()) { const IfcFloat x = cprofile->XDim*0.5f, y = cprofile->YDim*0.5f; @@ -117,7 +117,7 @@ void ProcessParametrizedProfile(const IfcParameterizedProfileDef& def, TempMesh& if(def.ToPtr()) { // TODO } - const size_t segments = 32; + const size_t segments = conv.settings.cylindricalTessellation; const IfcFloat delta = AI_MATH_TWO_PI_F/segments, radius = circle->Radius; meshout.verts.reserve(segments); diff --git a/include/assimp/config.h.in b/include/assimp/config.h.in index b8962520e..9f0e70704 100644 --- a/include/assimp/config.h.in +++ b/include/assimp/config.h.in @@ -877,18 +877,35 @@ enum aiComponent #define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION" // --------------------------------------------------------------------------- -/** @brief Set the tessellation conic angle for IFC curves. +/** @brief Set the tessellation conic angle for IFC smoothing curves. * * This is used by the IFC importer to determine the tessellation parameter - * for curves. - * @note The default value is AI_IMPORT_IFC_DEFAULT_CONIC_SAMPLING_ANGLE - * Property type: float. + * for smoothing curves. + * @note The default value is AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE and the + * accepted values are in range [5.0, 120.0]. + * Property type: Float. */ -#define AI_CONFIG_IMPORT_IFC_CONIC_SAMPLING_ANGLE "IMPORT_IFC_CONIC_SAMPLING_ANGLE" +#define AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE "IMPORT_IFC_SMOOTHING_ANGLE" -// default value for AI_CONFIG_IMPORT_IFC_CONIC_SAMPLING_ANGLE -#if (!defined AI_IMPORT_IFC_DEFAULT_CONIC_SAMPLING_ANGLE) -# define AI_IMPORT_IFC_DEFAULT_CONIC_SAMPLING_ANGLE 10.0f +// default value for AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE +#if (!defined AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE) +# define AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE 10.0f +#endif + +// --------------------------------------------------------------------------- +/** @brief Set the tessellation for IFC cylindrical shapes. + * + * This is used by the IFC importer to determine the tessellation parameter + * for cylindrical shapes, i.e. the number of segments used to aproximate a circle. + * @note The default value is AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION and the + * accepted values are in range [3, 180]. + * Property type: Integer. + */ +#define AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION "IMPORT_IFC_CYLINDRICAL_TESSELLATION" + +// default value for AI_CONFIG_IMPORT_IFC_CYLINDRICAL_TESSELLATION +#if (!defined AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION) +# define AI_IMPORT_IFC_DEFAULT_CYLINDRICAL_TESSELLATION 32 #endif // ---------------------------------------------------------------------------