From 6db06f117ae362041cb3b6ae484a8bd887484fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Terziman?= Date: Tue, 23 Aug 2016 11:59:49 +0200 Subject: [PATCH 1/7] In metadata: added method to append new metadata to structure --- include/assimp/metadata.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/assimp/metadata.h b/include/assimp/metadata.h index 814d89272..0cc27a802 100644 --- a/include/assimp/metadata.h +++ b/include/assimp/metadata.h @@ -192,7 +192,28 @@ struct aiMetadata } } + template + inline void Add( const std::string& key, const T& value ) + { + aiString* new_keys = new aiString[mNumProperties + 1]; + aiMetadataEntry* new_values = new aiMetadataEntry[mNumProperties + 1]; + for(unsigned int i = 0; i < mNumProperties; ++i) + { + new_keys[i] = mKeys[i]; + new_values[i] = mValues[i]; + } + + delete mKeys; + delete mValues; + + mKeys = new_keys; + mValues = new_values; + + mNumProperties++; + + Set(mNumProperties - 1, key, value); + } template inline void Set( unsigned index, const std::string& key, const T& value ) From 2a6f722a7dbd2894c091fc1a05dc0ef8530dd043 Mon Sep 17 00:00:00 2001 From: Leo Terziman Date: Thu, 12 Jan 2017 10:19:25 +0100 Subject: [PATCH 2/7] Fixed matching ENDIF condition in CMake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8f3d2488..8aaaf36de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -335,7 +335,7 @@ IF ( ASSIMP_BUILD_ASSIMP_TOOLS ) IF ( ASSIMP_BUILD_ASSIMP_VIEW ) ADD_SUBDIRECTORY( tools/assimp_view/ ) ENDIF ( ASSIMP_BUILD_ASSIMP_VIEW ) - ENDIF ( WIN32 ) + ENDIF ( WIN32 AND DirectX_D3DX9_LIBRARY ) ADD_SUBDIRECTORY( tools/assimp_cmd/ ) From 8bc183182c971a3989f14f9a4340c634ed3505a7 Mon Sep 17 00:00:00 2001 From: Leo Terziman Date: Fri, 10 Mar 2017 14:42:17 +0100 Subject: [PATCH 3/7] Added new option to IFC importer to control tessellation angle + removed unused IFC option --- code/IFCLoader.cpp | 4 +--- code/IFCLoader.h | 2 -- include/assimp/config.h.in | 35 +++++++++++++++++++---------------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/code/IFCLoader.cpp b/code/IFCLoader.cpp index 1cc18fc3f..ff4eb4b1f 100644 --- a/code/IFCLoader.cpp +++ b/code/IFCLoader.cpp @@ -153,10 +153,8 @@ const aiImporterDesc* IFCImporter::GetInfo () const void IFCImporter::SetupProperties(const Importer* pImp) { settings.skipSpaceRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS,true); - settings.skipCurveRepresentations = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS,true); settings.useCustomTriangulation = pImp->GetPropertyBool(AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION,true); - - settings.conicSamplingAngle = 10.f; + settings.conicSamplingAngle = pImp->GetPropertyFloat(AI_CONFIG_IMPORT_IFC_CONIC_SAMPLING_ANGLE, AI_IMPORT_IFC_DEFAULT_CONIC_SAMPLING_ANGLE); settings.skipAnnotations = true; } diff --git a/code/IFCLoader.h b/code/IFCLoader.h index e301a329d..70a7b1685 100644 --- a/code/IFCLoader.h +++ b/code/IFCLoader.h @@ -107,7 +107,6 @@ public: { Settings() : skipSpaceRepresentations() - , skipCurveRepresentations() , useCustomTriangulation() , skipAnnotations() , conicSamplingAngle(10.f) @@ -115,7 +114,6 @@ public: bool skipSpaceRepresentations; - bool skipCurveRepresentations; bool useCustomTriangulation; bool skipAnnotations; float conicSamplingAngle; diff --git a/include/assimp/config.h.in b/include/assimp/config.h.in index 148a68868..e1af72bbb 100644 --- a/include/assimp/config.h.in +++ b/include/assimp/config.h.in @@ -844,14 +844,6 @@ enum aiComponent #define AI_CONFIG_IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME \ "IMPORT_OGRE_TEXTURETYPE_FROM_FILENAME" -/** @brief Specifies whether the IFC loader skips over IfcSpace elements. - * - * IfcSpace elements (and their geometric representations) are used to - * represent, well, free space in a building storey.
- * Property type: Bool. Default value: true. - */ -#define AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS "IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS" - /** @brief Specifies whether the Android JNI asset extraction is supported. * * Turn on this option if you want to manage assets in native @@ -860,17 +852,13 @@ enum aiComponent */ #define AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT "AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT" - -// --------------------------------------------------------------------------- -/** @brief Specifies whether the IFC loader skips over - * shape representations of type 'Curve2D'. +/** @brief Specifies whether the IFC loader skips over IfcSpace elements. * - * A lot of files contain both a faceted mesh representation and a outline - * with a presentation type of 'Curve2D'. Currently Assimp doesn't convert those, - * so turning this option off just clutters the log with errors.
+ * IfcSpace elements (and their geometric representations) are used to + * represent, well, free space in a building storey.
* Property type: Bool. Default value: true. */ -#define AI_CONFIG_IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS "IMPORT_IFC_SKIP_CURVE_REPRESENTATIONS" +#define AI_CONFIG_IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS "IMPORT_IFC_SKIP_SPACE_REPRESENTATIONS" // --------------------------------------------------------------------------- /** @brief Specifies whether the IFC loader will use its own, custom triangulation @@ -887,6 +875,21 @@ enum aiComponent */ #define AI_CONFIG_IMPORT_IFC_CUSTOM_TRIANGULATION "IMPORT_IFC_CUSTOM_TRIANGULATION" +// --------------------------------------------------------------------------- + /** @brief Set the tessellation conic angle for IFC 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. + */ +#define AI_CONFIG_IMPORT_IFC_CONIC_SAMPLING_ANGLE "IMPORT_IFC_CONIC_SAMPLING_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 +#endif + // --------------------------------------------------------------------------- /** @brief Specifies whether the Collada loader will ignore the provided up direction. * From bd33bcaa0d2d96673bd6aae71aa653e968ba8ebb Mon Sep 17 00:00:00 2001 From: Leo Terziman Date: Fri, 10 Mar 2017 14:46:28 +0100 Subject: [PATCH 4/7] Fixed some formatting --- include/assimp/config.h.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/assimp/config.h.in b/include/assimp/config.h.in index e1af72bbb..b8962520e 100644 --- a/include/assimp/config.h.in +++ b/include/assimp/config.h.in @@ -852,6 +852,7 @@ enum aiComponent */ #define AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT "AI_CONFIG_ANDROID_JNI_ASSIMP_MANAGER_SUPPORT" +// --------------------------------------------------------------------------- /** @brief Specifies whether the IFC loader skips over IfcSpace elements. * * IfcSpace elements (and their geometric representations) are used to @@ -876,7 +877,7 @@ 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 curves. * * This is used by the IFC importer to determine the tessellation parameter * for curves. From fff0e886a13a94cc84bec6b081c1692a5690ab2a Mon Sep 17 00:00:00 2001 From: Leo Terziman Date: Fri, 17 Mar 2017 11:53:36 +0100 Subject: [PATCH 5/7] Fixed bug in IFC openings when curmesh.vertcnt is empty --- code/IFCOpenings.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/code/IFCOpenings.cpp b/code/IFCOpenings.cpp index c2a7439ee..f40b49fe4 100644 --- a/code/IFCOpenings.cpp +++ b/code/IFCOpenings.cpp @@ -901,13 +901,21 @@ size_t CloseWindows(ContourVector& contours, curmesh.verts.reserve(curmesh.verts.size() + (*it).contour.size() * 4); curmesh.vertcnt.reserve(curmesh.vertcnt.size() + (*it).contour.size()); + bool reverseCountourFaces = false; + // compare base poly normal and contour normal to detect if we need to reverse the face winding - IfcVector3 basePolyNormal = TempMesh::ComputePolygonNormal( curmesh.verts.data(), curmesh.vertcnt.front()); - std::vector worldSpaceContourVtx( it->contour.size()); - for( size_t a = 0; a < it->contour.size(); ++a ) - worldSpaceContourVtx[a] = minv * IfcVector3( it->contour[a].x, it->contour[a].y, 0.0); - IfcVector3 contourNormal = TempMesh::ComputePolygonNormal( worldSpaceContourVtx.data(), worldSpaceContourVtx.size()); - bool reverseCountourFaces = (contourNormal * basePolyNormal) > 0.0; + if(curmesh.vertcnt.size() > 0) { + IfcVector3 basePolyNormal = TempMesh::ComputePolygonNormal(curmesh.verts.data(), curmesh.vertcnt.front()); + + std::vector worldSpaceContourVtx(it->contour.size()); + + for(size_t a = 0; a < it->contour.size(); ++a) + worldSpaceContourVtx[a] = minv * IfcVector3(it->contour[a].x, it->contour[a].y, 0.0); + + IfcVector3 contourNormal = TempMesh::ComputePolygonNormal(worldSpaceContourVtx.data(), worldSpaceContourVtx.size()); + + reverseCountourFaces = (contourNormal * basePolyNormal) > 0.0; + } // XXX this algorithm is really a bit inefficient - both in terms // of constant factor and of asymptotic runtime. From 9ef234b8424f0ca33f2252a56cfd9c5f2e06b4ac Mon Sep 17 00:00:00 2001 From: Leo Terziman Date: Fri, 17 Mar 2017 11:58:50 +0100 Subject: [PATCH 6/7] 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 // --------------------------------------------------------------------------- From bf2e2f75374db266e322db38a484ffe5a9675196 Mon Sep 17 00:00:00 2001 From: Leo Terziman Date: Fri, 17 Mar 2017 14:55:18 +0100 Subject: [PATCH 7/7] Extended support for tessellation parameter to more IFC shapes --- code/IFCGeometry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/IFCGeometry.cpp b/code/IFCGeometry.cpp index f80fadff9..908f5e065 100644 --- a/code/IFCGeometry.cpp +++ b/code/IFCGeometry.cpp @@ -258,7 +258,7 @@ void ProcessRevolvedAreaSolid(const IfcRevolvedAreaSolid& solid, TempMesh& resul return; } - const unsigned int cnt_segments = std::max(2u,static_cast(16 * std::fabs(max_angle)/AI_MATH_HALF_PI_F)); + const unsigned int cnt_segments = std::max(2u,static_cast(conv.settings.cylindricalTessellation * std::fabs(max_angle)/AI_MATH_HALF_PI_F)); const IfcFloat delta = max_angle/cnt_segments; has_area = has_area && std::fabs(max_angle) < AI_MATH_TWO_PI_F*0.99; @@ -327,7 +327,7 @@ void ProcessSweptDiskSolid(const IfcSweptDiskSolid solid, TempMesh& result, Conv return; } - const unsigned int cnt_segments = 16; + const unsigned int cnt_segments = conv.settings.cylindricalTessellation; const IfcFloat deltaAngle = AI_MATH_TWO_PI/cnt_segments; const size_t samples = curve->EstimateSampleCount(solid.StartParam,solid.EndParam);