Added parameter to control cylindrical shapes tessellation

+ renamed smoothing angle parameter for better user understanding
pull/1208/head
Leo Terziman 2017-03-17 11:58:50 +01:00
parent fff0e886a1
commit 9ef234b842
4 changed files with 32 additions and 12 deletions

View File

@ -154,8 +154,9 @@ void IFCImporter::SetupProperties(const Importer* pImp)
{ {
settings.skipSpaceRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS,true); settings.skipSpaceRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS,true);
settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,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.conicSamplingAngle = std::min(std::max(pImp->GetPropertyFloat(AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE, AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE), 5.0f), 120.0f);
settings.skipAnnotations = true; 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;
} }

View File

@ -110,6 +110,7 @@ public:
, useCustomTriangulation() , useCustomTriangulation()
, skipAnnotations() , skipAnnotations()
, conicSamplingAngle(10.f) , conicSamplingAngle(10.f)
, cylindricalTessellation(32)
{} {}
@ -117,6 +118,7 @@ public:
bool useCustomTriangulation; bool useCustomTriangulation;
bool skipAnnotations; bool skipAnnotations;
float conicSamplingAngle; float conicSamplingAngle;
int cylindricalTessellation;
}; };

View File

@ -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<IfcRectangleProfileDef>()) { if(const IfcRectangleProfileDef* const cprofile = def.ToPtr<IfcRectangleProfileDef>()) {
const IfcFloat x = cprofile->XDim*0.5f, y = cprofile->YDim*0.5f; 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<IfcCircleHollowProfileDef>()) { if(def.ToPtr<IfcCircleHollowProfileDef>()) {
// TODO // 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; const IfcFloat delta = AI_MATH_TWO_PI_F/segments, radius = circle->Radius;
meshout.verts.reserve(segments); meshout.verts.reserve(segments);

View File

@ -877,18 +877,35 @@ enum aiComponent
#define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION" #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 * This is used by the IFC importer to determine the tessellation parameter
* for curves. * for smoothing curves.
* @note The default value is AI_IMPORT_IFC_DEFAULT_CONIC_SAMPLING_ANGLE * @note The default value is AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE and the
* Property type: float. * 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 // default value for AI_CONFIG_IMPORT_IFC_SMOOTHING_ANGLE
#if (!defined AI_IMPORT_IFC_DEFAULT_CONIC_SAMPLING_ANGLE) #if (!defined AI_IMPORT_IFC_DEFAULT_SMOOTHING_ANGLE)
# define AI_IMPORT_IFC_DEFAULT_CONIC_SAMPLING_ANGLE 10.0f # 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 #endif
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------