diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml
index f9d0d6c05..2c5ca438b 100644
--- a/.github/workflows/ccpp.yml
+++ b/.github/workflows/ccpp.yml
@@ -46,7 +46,7 @@ jobs:
toolchain: ninja-vs-win64-cxx17
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
with:
submodules: true
@@ -69,17 +69,11 @@ jobs:
- name: Checkout Hunter toolchains
if: endsWith(matrix.name, 'hunter')
- uses: actions/checkout@v3
+ uses: actions/checkout@v4
with:
repository: cpp-pm/polly
path: cmake/polly
- - name: Remove contrib directory for Hunter builds
- if: contains(matrix.name, 'hunter')
- uses: JesseTG/rm@v1.0.3
- with:
- path: contrib
-
- name: Cache DX SDK
id: dxcache
if: contains(matrix.name, 'windows')
diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml
index 483ee8fc1..6a8e2336f 100644
--- a/.github/workflows/sanitizer.yml
+++ b/.github/workflows/sanitizer.yml
@@ -14,7 +14,7 @@ jobs:
name: adress-sanitizer
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
- uses: lukka/set-shell-env@v1
with:
@@ -38,7 +38,7 @@ jobs:
name: undefined-behavior-sanitizer
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- uses: lukka/get-cmake@latest
- uses: lukka/set-shell-env@v1
with:
@@ -62,7 +62,7 @@ jobs:
name: printf-sanitizer
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - uses: actions/checkout@v4
- name: run scan_printf script
run: ./scripts/scan_printf.sh
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dfaa2b791..88f69174a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,14 +49,13 @@ option(ASSIMP_HUNTER_ENABLED "Enable Hunter package manager support" OFF)
IF(ASSIMP_HUNTER_ENABLED)
include("cmake-modules/HunterGate.cmake")
HunterGate(
- URL "https://github.com/cpp-pm/hunter/archive/v0.24.17.tar.gz"
- SHA1 "e6396699e414120e32557fe92db097b7655b760b"
+ URL "https://github.com/cpp-pm/hunter/archive/v0.24.18.tar.gz"
+ SHA1 "1292e4d661e1770d6d6ca08c12c07cf34a0bf718"
)
-
add_definitions(-DASSIMP_USE_HUNTER)
ENDIF()
-PROJECT(Assimp VERSION 5.2.5)
+PROJECT(Assimp VERSION 5.3.0)
# All supported options ###############################################
@@ -201,12 +200,9 @@ SET (ASSIMP_VERSION ${ASSIMP_VERSION_MAJOR}.${ASSIMP_VERSION_MINOR}.${ASSIMP_VER
SET (ASSIMP_SOVERSION 5)
SET( ASSIMP_PACKAGE_VERSION "0" CACHE STRING "the package-specific version used for uploading the sources" )
-if(NOT ASSIMP_HUNTER_ENABLED)
- # Enable C++17 support globally
- set(CMAKE_CXX_STANDARD 17)
- set(CMAKE_CXX_STANDARD_REQUIRED ON)
- set(CMAKE_C_STANDARD 99)
-endif()
+set(CMAKE_CXX_STANDARD 17)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_C_STANDARD 99)
IF(NOT ASSIMP_IGNORE_GIT_HASH)
# Get the current working branch
@@ -254,8 +250,7 @@ IF( UNIX )
# Use GNUInstallDirs for Unix predefined directories
INCLUDE(GNUInstallDirs)
# Ensure that we do not run into issues like http://www.tcm.phy.cam.ac.uk/sw/inodes64.html on 32 bit linux
- IF( ${OPERATING_SYSTEM} MATCHES "Android")
- ELSE()
+ IF(NOT ${OPERATING_SYSTEM} MATCHES "Android")
IF ( CMAKE_SIZEOF_VOID_P EQUAL 4) # only necessary for 32-bit linux
ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 )
ENDIF()
@@ -263,9 +258,8 @@ IF( UNIX )
ENDIF()
# Grouped compiler settings ########################################
-IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW)
+IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW AND NOT HAIKU)
IF(NOT ASSIMP_HUNTER_ENABLED)
- SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
ENDIF()
@@ -302,7 +296,6 @@ ELSEIF(MSVC)
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG:FULL /PDBALTPATH:%_PDB% /OPT:REF /OPT:ICF")
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
IF(NOT ASSIMP_HUNTER_ENABLED)
- SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
ENDIF()
SET(CMAKE_CXX_FLAGS "-fvisibility=hidden -fno-strict-aliasing -Wall -Wno-long-long ${CMAKE_CXX_FLAGS}" )
@@ -327,17 +320,17 @@ ENDIF()
IF ( IOS AND NOT ASSIMP_HUNTER_ENABLED)
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -Og")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -Og")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -Og")
ELSE()
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -O3")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fembed-bitcode -O3")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fembed-bitcode -O3")
- # Experimental for pdb generation
ENDIF()
ENDIF()
IF (ASSIMP_COVERALLS)
MESSAGE(STATUS "Coveralls enabled")
+
INCLUDE(Coveralls)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
@@ -345,14 +338,16 @@ ENDIF()
IF (ASSIMP_ASAN)
MESSAGE(STATUS "AddressSanitizer enabled")
+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
ENDIF()
IF (ASSIMP_UBSAN)
MESSAGE(STATUS "Undefined Behavior sanitizer enabled")
+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin -fno-sanitize-recover=all")
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin -fno-sanitize-recover=all")
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined,shift,shift-exponent,integer-divide-by-zero,unreachable,vla-bound,null,return,signed-integer-overflow,bounds,float-divide-by-zero,float-cast-overflow,nonnull-attribute,returns-nonnull-attribute,bool,enum,vptr,pointer-overflow,builtin -fno-sanitize-recover=all")
ENDIF()
INCLUDE (FindPkgMacros)
@@ -673,13 +668,13 @@ ELSE()
set_target_properties(draco_encoder draco_decoder PROPERTIES
EXCLUDE_FROM_ALL TRUE
EXCLUDE_FROM_DEFAULT_BUILD TRUE
- )
+ )
# Do build the draco shared library
set_target_properties(${draco_LIBRARIES} PROPERTIES
EXCLUDE_FROM_ALL FALSE
EXCLUDE_FROM_DEFAULT_BUILD FALSE
- )
+ )
TARGET_USE_COMMON_OUTPUT_DIRECTORY(${draco_LIBRARIES})
TARGET_USE_COMMON_OUTPUT_DIRECTORY(draco_encoder)
@@ -696,8 +691,7 @@ ELSE()
FRAMEWORK DESTINATION ${ASSIMP_LIB_INSTALL_DIR}
COMPONENT ${LIBASSIMP_COMPONENT}
INCLUDES DESTINATION include
- )
-
+ )
ENDIF()
ENDIF()
ENDIF()
@@ -783,7 +777,7 @@ IF ( ASSIMP_INSTALL )
SET(CPACK_DEBIAN_PACKAGE_SECTION "libs" )
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_COMPONENTS_ALL}")
SET(CPACK_DEBIAN_PACKAGE_SUGGESTS)
- SET(cPACK_DEBIAN_PACKAGE_NAME "assimp")
+ SET(CPACK_DEBIAN_PACKAGE_NAME "assimp")
SET(CPACK_DEBIAN_PACKAGE_REMOVE_SOURCE_FILES contrib/gtest contrib/zlib workspaces test doc obj samples packaging)
SET(CPACK_DEBIAN_PACKAGE_SOURCE_COPY svn export --force)
SET(CPACK_DEBIAN_CHANGELOG)
diff --git a/Readme.md b/Readme.md
index 9a8ac7c33..a740be772 100644
--- a/Readme.md
+++ b/Readme.md
@@ -6,20 +6,14 @@ Open Asset Import Library is a library to load various 3d file formats into a sh
### Current project status ###
[![Financial Contributors on Open Collective](https://opencollective.com/assimp/all/badge.svg?label=financial+contributors)](https://opencollective.com/assimp)
![C/C++ CI](https://github.com/assimp/assimp/workflows/C/C++%20CI/badge.svg)
-
-
-
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9973693b7bdd4543b07084d5d9cf4745)](https://www.codacy.com/gh/assimp/assimp/dashboard?utm_source=github.com&utm_medium=referral&utm_content=assimp/assimp&utm_campaign=Badge_Grade)
-
-[![Coverage Status](https://coveralls.io/repos/github/assimp/assimp/badge.svg?branch=master)](https://coveralls.io/github/assimp/assimp?branch=master)
[![Join the chat at https://gitter.im/assimp/assimp](https://badges.gitter.im/assimp/assimp.svg)](https://gitter.im/assimp/assimp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/assimp/assimp.svg)](http://isitmaintained.com/project/assimp/assimp "Percentage of issues still open")
APIs are provided for C and C++. There are various bindings to other languages (C#, Java, Python, Delphi, D). Assimp also runs on Android and iOS.
-Additionally, assimp features various __mesh post processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more.
+Additionally, assimp features various __mesh post-processing tools__: normals and tangent space generation, triangulation, vertex cache locality optimization, removal of degenerate primitives and duplicate vertices, sorting by primitive type, merging of redundant materials and many more.
### Latest Doc's ###
Please check the latest documents at [Asset-Importer-Lib-Doc](https://assimp-docs.readthedocs.io/en/latest/).
@@ -58,20 +52,21 @@ Take a look into the https://github.com/assimp/assimp/blob/master/Build.md file.
### Other tools ###
[open3mod](https://github.com/acgessler/open3mod) is a powerful 3D model viewer based on Assimp's import and export abilities.
+[Assimp-Viewer(]https://github.com/assimp/assimp_view) is an experimental implementation for an Asset-Viewer based on ImGUI and Assimp (experimental).
#### Repository structure ####
-Open Asset Import Library is implemented in C++. The directory structure looks like:
+Open Asset Import Library is implemented in C++. The directory structure looks like this:
/code Source code
/contrib Third-party libraries
/doc Documentation (doxysource and pre-compiled docs)
- /fuzz Contains the test-code for the Google-Fuzzer project
+ /fuzz Contains the test code for the Google Fuzzer project
/include Public header C and C++ header files
- /scripts Scripts used to generate the loading code for some formats
+ /scripts Scripts are used to generate the loading code for some formats
/port Ports to other languages and scripts to maintain those.
/test Unit- and regression tests, test suite of models
/tools Tools (old assimp viewer, command line `assimp`)
- /samples A small number of samples to illustrate possible use-cases for Assimp
+ /samples A small number of samples to illustrate possible use cases for Assimp
The source code is organized in the following way:
@@ -79,9 +74,9 @@ The source code is organized in the following way:
code/CApi Special implementations which are only used for the C-API
code/Geometry A collection of geometry tools
code/Material The material system
- code/PBR An exporter for physical based models
+ code/PBR An exporter for physical-based models
code/PostProcessing The post-processing steps
- code/AssetLib/ Implementation for import and export for the format
+ code/AssetLib/ Implementation for import and export of the format
### Contributing ###
Contributions to assimp are highly appreciated. The easiest way to get involved is to submit
@@ -118,4 +113,4 @@ and don't sue us if our code doesn't work. Note that, unlike LGPLed code, you ma
For the legal details, see the `LICENSE` file.
### Why this name ###
-Sorry, we're germans :-), no english native speakers ...
+Sorry, we're germans :-), no English native speakers ...
diff --git a/code/AssetLib/Blender/BlenderScene.cpp b/code/AssetLib/Blender/BlenderScene.cpp
index ac10d7302..a2e4c30f2 100644
--- a/code/AssetLib/Blender/BlenderScene.cpp
+++ b/code/AssetLib/Blender/BlenderScene.cpp
@@ -102,10 +102,6 @@ void Structure::Convert(
ReadFieldPtr(dest.next, "*next", db);
{
- //std::shared_ptr prev;
- //ReadFieldPtr(prev, "*prev", db);
- //dest.prev = prev.get();
-
std::shared_ptr ob;
ReadFieldPtr(ob, "*ob", db);
dest.ob = ob.get();
diff --git a/code/AssetLib/Blender/BlenderTessellator.cpp b/code/AssetLib/Blender/BlenderTessellator.cpp
index 73fd56b98..84bc2ea1a 100644
--- a/code/AssetLib/Blender/BlenderTessellator.cpp
+++ b/code/AssetLib/Blender/BlenderTessellator.cpp
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2022, assimp team
-
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -40,10 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file BlenderTessellator.cpp
- * @brief A simple tessellation wrapper
- */
-
+/// @file BlenderTessellator.cpp
+/// @brief A simple tessellation wrapper
#ifndef ASSIMP_BUILD_NO_BLEND_IMPORTER
diff --git a/code/AssetLib/Blender/BlenderTessellator.h b/code/AssetLib/Blender/BlenderTessellator.h
index 87703f99d..21a4f4701 100644
--- a/code/AssetLib/Blender/BlenderTessellator.h
+++ b/code/AssetLib/Blender/BlenderTessellator.h
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2022, assimp team
-
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -144,11 +143,7 @@ namespace Assimp
#if ASSIMP_BLEND_WITH_POLY_2_TRI
-#ifdef ASSIMP_USE_HUNTER
-# include
-#else
-# include "../contrib/poly2tri/poly2tri/poly2tri.h"
-#endif
+#include "contrib/poly2tri/poly2tri/poly2tri.h"
namespace Assimp
{
diff --git a/code/AssetLib/DXF/DXFLoader.cpp b/code/AssetLib/DXF/DXFLoader.cpp
index 6b820d046..dae665388 100644
--- a/code/AssetLib/DXF/DXFLoader.cpp
+++ b/code/AssetLib/DXF/DXFLoader.cpp
@@ -731,7 +731,7 @@ void DXFImporter::ParsePolyLineVertex(DXF::LineReader& reader, DXF::PolyLine& li
if (index >= 0) {
indices[cnti++] = static_cast(index);
} else {
- ASSIMP_LOG_WARN("DXF: Skip invisible face.");
+ indices[cnti++] = static_cast(-index);
}
}
break;
diff --git a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
index 8d79e2339..55424a6a8 100644
--- a/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
+++ b/code/AssetLib/FBX/FBXBinaryTokenizer.cpp
@@ -51,6 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "FBXUtil.h"
#include
#include
+#include
#include
#include
#include
diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp
index 498da43ca..3538e84a8 100644
--- a/code/AssetLib/FBX/FBXConverter.cpp
+++ b/code/AssetLib/FBX/FBXConverter.cpp
@@ -577,16 +577,17 @@ void FBXConverter::GetRotationMatrix(Model::RotOrder mode, const aiVector3D &rot
bool is_id[3] = { true, true, true };
aiMatrix4x4 temp[3];
- if (std::fabs(rotation.z) > angle_epsilon) {
- aiMatrix4x4::RotationZ(AI_DEG_TO_RAD(rotation.z), temp[2]);
+ const auto rot = AI_DEG_TO_RAD(rotation);
+ if (std::fabs(rot.z) > angle_epsilon) {
+ aiMatrix4x4::RotationZ(rot.z, temp[2]);
is_id[2] = false;
}
- if (std::fabs(rotation.y) > angle_epsilon) {
- aiMatrix4x4::RotationY(AI_DEG_TO_RAD(rotation.y), temp[1]);
+ if (std::fabs(rot.y) > angle_epsilon) {
+ aiMatrix4x4::RotationY(rot.y, temp[1]);
is_id[1] = false;
}
- if (std::fabs(rotation.x) > angle_epsilon) {
- aiMatrix4x4::RotationX(AI_DEG_TO_RAD(rotation.x), temp[0]);
+ if (std::fabs(rot.x) > angle_epsilon) {
+ aiMatrix4x4::RotationX(rot.x, temp[0]);
is_id[0] = false;
}
@@ -3225,7 +3226,6 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
aiVector3D defTranslate = PropertyGet(props, "Lcl Translation", aiVector3D(0.f, 0.f, 0.f));
aiVector3D defRotation = PropertyGet(props, "Lcl Rotation", aiVector3D(0.f, 0.f, 0.f));
aiVector3D defScale = PropertyGet(props, "Lcl Scaling", aiVector3D(1.f, 1.f, 1.f));
- aiQuaternion defQuat = EulerToQuaternion(defRotation, rotOrder);
aiVectorKey* outTranslations = new aiVectorKey[keyCount];
aiQuatKey* outRotations = new aiQuatKey[keyCount];
@@ -3241,8 +3241,9 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
}
if (keyframeLists[TransformationComp_Rotation].size() > 0) {
- InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder);
+ InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], AI_DEG_TO_RAD(defRotation), maxTime, minTime, rotOrder);
} else {
+ aiQuaternion defQuat = EulerToQuaternion(AI_DEG_TO_RAD(defRotation), rotOrder);
for (size_t i = 0; i < keyCount; ++i) {
outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps;
outRotations[i].mValue = defQuat;
@@ -3264,7 +3265,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
const aiVector3D& preRotation = PropertyGet(props, "PreRotation", ok);
if (ok && preRotation.SquareLength() > zero_epsilon) {
- const aiQuaternion preQuat = EulerToQuaternion(preRotation, Model::RotOrder_EulerXYZ);
+ const aiQuaternion preQuat = EulerToQuaternion(AI_DEG_TO_RAD(preRotation), Model::RotOrder_EulerXYZ);
for (size_t i = 0; i < keyCount; ++i) {
outRotations[i].mValue = preQuat * outRotations[i].mValue;
}
@@ -3272,7 +3273,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name,
const aiVector3D& postRotation = PropertyGet(props, "PostRotation", ok);
if (ok && postRotation.SquareLength() > zero_epsilon) {
- const aiQuaternion postQuat = EulerToQuaternion(postRotation, Model::RotOrder_EulerXYZ);
+ const aiQuaternion postQuat = EulerToQuaternion(AI_DEG_TO_RAD(postRotation), Model::RotOrder_EulerXYZ);
for (size_t i = 0; i < keyCount; ++i) {
outRotations[i].mValue = outRotations[i].mValue * postQuat;
}
diff --git a/code/AssetLib/FBX/FBXExporter.cpp b/code/AssetLib/FBX/FBXExporter.cpp
index 31bea76b5..2ea505618 100644
--- a/code/AssetLib/FBX/FBXExporter.cpp
+++ b/code/AssetLib/FBX/FBXExporter.cpp
@@ -74,8 +74,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// https://code.blender.org/2013/08/fbx-binary-file-format-specification/
// https://wiki.blender.org/index.php/User:Mont29/Foundation/FBX_File_Structure
-const ai_real DEG = ai_real( 57.29577951308232087679815481 ); // degrees per radian
-
using namespace Assimp;
using namespace Assimp::FBX;
@@ -1391,7 +1389,7 @@ void FBXExporter::WriteObjects ()
aiMaterial* m = mScene->mMaterials[i];
// these are used to receive material data
- float f; aiColor3D c;
+ ai_real f; aiColor3D c;
// start the node record
FBX::Node n("Material");
@@ -2434,7 +2432,7 @@ void FBXExporter::WriteObjects ()
aiMatrix4x4 m(k.mValue.GetMatrix());
aiVector3D qs, qr, qt;
m.Decompose(qs, qr, qt);
- qr *= DEG;
+ qr = AI_RAD_TO_DEG(qr);
xval.push_back(qr.x);
yval.push_back(qr.y);
zval.push_back(qr.z);
@@ -2515,9 +2513,10 @@ void FBXExporter::WriteModelNode(
);
}
if (r != zero) {
+ r = AI_RAD_TO_DEG(r);
p.AddP70(
"Lcl Rotation", "Lcl Rotation", "", "A",
- double(DEG*r.x), double(DEG*r.y), double(DEG*r.z)
+ double(r.x), double(r.y), double(r.z)
);
}
if (s != one) {
@@ -2601,8 +2600,7 @@ void FBXExporter::WriteModelNodes(
transform_chain.emplace_back(elem->first, t);
break;
case 'r': // rotation
- r *= float(DEG);
- transform_chain.emplace_back(elem->first, r);
+ transform_chain.emplace_back(elem->first, AI_RAD_TO_DEG(r));
break;
case 's': // scale
transform_chain.emplace_back(elem->first, s);
diff --git a/code/AssetLib/IFC/IFCBoolean.cpp b/code/AssetLib/IFC/IFCBoolean.cpp
index 6baaf0687..f4d53990e 100644
--- a/code/AssetLib/IFC/IFCBoolean.cpp
+++ b/code/AssetLib/IFC/IFCBoolean.cpp
@@ -38,9 +38,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file IFCBoolean.cpp
- * @brief Implements a subset of Ifc boolean operations
- */
+/// @file IFCBoolean.cpp
+/// @brief Implements a subset of Ifc boolean operations
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
@@ -48,7 +47,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "Common/PolyTools.h"
#include "PostProcessing/ProcessHelper.h"
-
#include
#include
#include
@@ -67,8 +65,9 @@ bool IntersectSegmentPlane(const IfcVector3 &p, const IfcVector3 &n, const IfcVe
// if segment ends on plane, do not report a hit. We stay on that side until a following segment starting at this
// point leaves the plane through the other side
- if (std::abs(dotOne + dotTwo) < ai_epsilon)
+ if (std::abs(dotOne + dotTwo) < ai_epsilon) {
return false;
+ }
// if segment starts on the plane, report a hit only if the end lies on the *other* side
if (std::abs(dotTwo) < ai_epsilon) {
@@ -82,13 +81,15 @@ bool IntersectSegmentPlane(const IfcVector3 &p, const IfcVector3 &n, const IfcVe
// ignore if segment is parallel to plane and far away from it on either side
// Warning: if there's a few thousand of such segments which slowly accumulate beyond the epsilon, no hit would be registered
- if (std::abs(dotOne) < ai_epsilon)
+ if (std::abs(dotOne) < ai_epsilon) {
return false;
+ }
// t must be in [0..1] if the intersection point is within the given segment
const IfcFloat t = dotTwo / dotOne;
- if (t > 1.0 || t < 0.0)
+ if (t > 1.0 || t < 0.0) {
return false;
+ }
out = e0 + t * seg;
return true;
@@ -110,11 +111,13 @@ void FilterPolygon(std::vector &resultpoly) {
FuzzyVectorCompare fz(epsilon);
std::vector::iterator e = std::unique(resultpoly.begin(), resultpoly.end(), fz);
- if (e != resultpoly.end())
+ if (e != resultpoly.end()) {
resultpoly.erase(e, resultpoly.end());
+ }
- if (!resultpoly.empty() && fz(resultpoly.front(), resultpoly.back()))
+ if (!resultpoly.empty() && fz(resultpoly.front(), resultpoly.back())) {
resultpoly.pop_back();
+ }
}
// ------------------------------------------------------------------------------------------------
@@ -291,8 +294,9 @@ bool IntersectsBoundaryProfile(const IfcVector3 &e0, const IfcVector3 &e1, const
}
// Line segment ends at boundary -> ignore any hit, it will be handled by possibly following segments
- if (endsAtSegment && !halfOpen)
+ if (endsAtSegment && !halfOpen) {
continue;
+ }
// Line segment starts at boundary -> generate a hit only if following that line would change the INSIDE/OUTSIDE
// state. This should catch the case where a connected set of segments has a point directly on the boundary,
@@ -301,15 +305,17 @@ bool IntersectsBoundaryProfile(const IfcVector3 &e0, const IfcVector3 &e1, const
if (startsAtSegment) {
IfcVector3 inside_dir = IfcVector3(b.y, -b.x, 0.0) * windingOrder;
bool isGoingInside = (inside_dir * e) > 0.0;
- if (isGoingInside == isStartAssumedInside)
+ if (isGoingInside == isStartAssumedInside) {
continue;
+ }
// only insert the point into the list if it is sufficiently far away from the previous intersection point.
// This way, we avoid duplicate detection if the intersection is directly on the vertex between two segments.
if (!intersect_results.empty() && intersect_results.back().first == i - 1) {
const IfcVector3 diff = intersect_results.back().second - e0;
- if (IfcVector2(diff.x, diff.y).SquareLength() < 1e-10)
+ if (IfcVector2(diff.x, diff.y).SquareLength() < 1e-10) {
continue;
+ }
}
intersect_results.emplace_back(i, e0);
continue;
@@ -322,8 +328,9 @@ bool IntersectsBoundaryProfile(const IfcVector3 &e0, const IfcVector3 &e1, const
// This way, we avoid duplicate detection if the intersection is directly on the vertex between two segments.
if (!intersect_results.empty() && intersect_results.back().first == i - 1) {
const IfcVector3 diff = intersect_results.back().second - p;
- if (IfcVector2(diff.x, diff.y).SquareLength() < 1e-10)
+ if (IfcVector2(diff.x, diff.y).SquareLength() < 1e-10) {
continue;
+ }
}
intersect_results.emplace_back(i, p);
}
@@ -662,7 +669,8 @@ void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const Schema_2x3::IfcPoly
}
// ------------------------------------------------------------------------------------------------
-void ProcessBooleanExtrudedAreaSolidDifference(const Schema_2x3::IfcExtrudedAreaSolid *as, TempMesh &result,
+void ProcessBooleanExtrudedAreaSolidDifference(const Schema_2x3::IfcExtrudedAreaSolid *as,
+ TempMesh &result,
const TempMesh &first_operand,
ConversionData &conv) {
ai_assert(as != nullptr);
@@ -763,4 +771,4 @@ void ProcessBoolean(const Schema_2x3::IfcBooleanResult &boolean, TempMesh &resul
} // namespace IFC
} // namespace Assimp
-#endif
+#endif // ASSIMP_BUILD_NO_IFC_IMPORTER
diff --git a/code/AssetLib/IFC/IFCCurve.cpp b/code/AssetLib/IFC/IFCCurve.cpp
index 59774eb11..44165befc 100644
--- a/code/AssetLib/IFC/IFCCurve.cpp
+++ b/code/AssetLib/IFC/IFCCurve.cpp
@@ -39,15 +39,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file IFCProfile.cpp
- * @brief Read profile and curves entities from IFC files
- */
+/// @file IFCProfile.cpp
+/// @brief Read profile and curves entities from IFC files
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
#include "IFCUtil.h"
namespace Assimp {
namespace IFC {
+
namespace {
// --------------------------------------------------------------------------------
@@ -56,8 +56,7 @@ namespace {
class Conic : public Curve {
public:
// --------------------------------------------------
- Conic(const Schema_2x3::IfcConic& entity, ConversionData& conv)
- : Curve(entity,conv) {
+ Conic(const Schema_2x3::IfcConic& entity, ConversionData& conv) : Curve(entity,conv) {
IfcMatrix4 trafo;
ConvertAxisPlacement(trafo,*entity.Position,conv);
@@ -69,12 +68,12 @@ public:
}
// --------------------------------------------------
- bool IsClosed() const {
+ bool IsClosed() const override {
return true;
}
// --------------------------------------------------
- size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
+ size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const override {
ai_assert( InRange( a ) );
ai_assert( InRange( b ) );
@@ -88,7 +87,7 @@ public:
}
// --------------------------------------------------
- ParamRange GetParametricRange() const {
+ ParamRange GetParametricRange() const override {
return std::make_pair(static_cast( 0. ), static_cast( AI_MATH_TWO_PI / conv.angle_scale ));
}
@@ -102,14 +101,13 @@ protected:
class Circle : public Conic {
public:
// --------------------------------------------------
- Circle(const Schema_2x3::IfcCircle& entity, ConversionData& conv)
- : Conic(entity,conv)
- , entity(entity)
- {
- }
-
+ Circle(const Schema_2x3::IfcCircle& entity, ConversionData& conv) : Conic(entity,conv) , entity(entity) {}
+
// --------------------------------------------------
- IfcVector3 Eval(IfcFloat u) const {
+ ~Circle() override = default;
+
+ // --------------------------------------------------
+ IfcVector3 Eval(IfcFloat u) const override {
u = -conv.angle_scale * u;
return location + static_cast(entity.Radius)*(static_cast(std::cos(u))*p[0] +
static_cast(std::sin(u))*p[1]);
@@ -132,7 +130,7 @@ public:
}
// --------------------------------------------------
- IfcVector3 Eval(IfcFloat u) const {
+ IfcVector3 Eval(IfcFloat u) const override {
u = -conv.angle_scale * u;
return location + static_cast(entity.SemiAxis1)*static_cast(std::cos(u))*p[0] +
static_cast(entity.SemiAxis2)*static_cast(std::sin(u))*p[1];
@@ -155,17 +153,17 @@ public:
}
// --------------------------------------------------
- bool IsClosed() const {
+ bool IsClosed() const override {
return false;
}
// --------------------------------------------------
- IfcVector3 Eval(IfcFloat u) const {
+ IfcVector3 Eval(IfcFloat u) const override {
return p + u*v;
}
// --------------------------------------------------
- size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
+ size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const override {
ai_assert( InRange( a ) );
ai_assert( InRange( b ) );
// two points are always sufficient for a line segment
@@ -174,7 +172,7 @@ public:
// --------------------------------------------------
- void SampleDiscrete(TempMesh& out,IfcFloat a, IfcFloat b) const {
+ void SampleDiscrete(TempMesh& out,IfcFloat a, IfcFloat b) const override {
ai_assert( InRange( a ) );
ai_assert( InRange( b ) );
@@ -188,7 +186,7 @@ public:
}
// --------------------------------------------------
- ParamRange GetParametricRange() const {
+ ParamRange GetParametricRange() const override {
const IfcFloat inf = std::numeric_limits::infinity();
return std::make_pair(-inf,+inf);
@@ -234,7 +232,7 @@ public:
}
// --------------------------------------------------
- IfcVector3 Eval(IfcFloat u) const {
+ IfcVector3 Eval(IfcFloat u) const override {
if (curves.empty()) {
return IfcVector3();
}
@@ -254,7 +252,7 @@ public:
}
// --------------------------------------------------
- size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
+ size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const override {
ai_assert( InRange( a ) );
ai_assert( InRange( b ) );
size_t cnt = 0;
@@ -275,7 +273,7 @@ public:
}
// --------------------------------------------------
- void SampleDiscrete(TempMesh& out,IfcFloat a, IfcFloat b) const {
+ void SampleDiscrete(TempMesh& out,IfcFloat a, IfcFloat b) const override {
ai_assert( InRange( a ) );
ai_assert( InRange( b ) );
@@ -293,7 +291,7 @@ public:
}
// --------------------------------------------------
- ParamRange GetParametricRange() const {
+ ParamRange GetParametricRange() const override {
return std::make_pair(static_cast( 0. ),total);
}
@@ -373,27 +371,27 @@ public:
}
// --------------------------------------------------
- IfcVector3 Eval(IfcFloat p) const {
+ IfcVector3 Eval(IfcFloat p) const override {
ai_assert(InRange(p));
return base->Eval( TrimParam(p) );
}
// --------------------------------------------------
- size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
+ size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const override {
ai_assert( InRange( a ) );
ai_assert( InRange( b ) );
return base->EstimateSampleCount(TrimParam(a),TrimParam(b));
}
// --------------------------------------------------
- void SampleDiscrete(TempMesh& out,IfcFloat a,IfcFloat b) const {
+ void SampleDiscrete(TempMesh& out,IfcFloat a,IfcFloat b) const override {
ai_assert(InRange(a));
ai_assert(InRange(b));
return base->SampleDiscrete(out,TrimParam(a),TrimParam(b));
}
// --------------------------------------------------
- ParamRange GetParametricRange() const {
+ ParamRange GetParametricRange() const override {
return std::make_pair(static_cast( 0. ),maxval);
}
@@ -431,7 +429,7 @@ public:
}
// --------------------------------------------------
- IfcVector3 Eval(IfcFloat p) const {
+ IfcVector3 Eval(IfcFloat p) const override {
ai_assert(InRange(p));
const size_t b = static_cast(std::floor(p));
@@ -444,14 +442,14 @@ public:
}
// --------------------------------------------------
- size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const {
+ size_t EstimateSampleCount(IfcFloat a, IfcFloat b) const override {
ai_assert(InRange(a));
ai_assert(InRange(b));
return static_cast( std::ceil(b) - std::floor(a) );
}
// --------------------------------------------------
- ParamRange GetParametricRange() const {
+ ParamRange GetParametricRange() const override {
return std::make_pair(static_cast( 0. ),static_cast(points.size()-1));
}
@@ -516,7 +514,7 @@ size_t Curve::EstimateSampleCount(IfcFloat a, IfcFloat b) const {
ai_assert( InRange( a ) );
ai_assert( InRange( b ) );
- // arbitrary default value, deriving classes should supply better suited values
+ // arbitrary default value, deriving classes should supply better-suited values
return 16;
}
diff --git a/code/AssetLib/IFC/IFCGeometry.cpp b/code/AssetLib/IFC/IFCGeometry.cpp
index 798b0a123..83afd2b59 100644
--- a/code/AssetLib/IFC/IFCGeometry.cpp
+++ b/code/AssetLib/IFC/IFCGeometry.cpp
@@ -38,24 +38,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file IFCGeometry.cpp
- * @brief Geometry conversion and synthesis for IFC
- */
-
-
+/// @file IFCGeometry.cpp
+/// @brief Geometry conversion and synthesis for IFC
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
#include "IFCUtil.h"
#include "Common/PolyTools.h"
#include "PostProcessing/ProcessHelper.h"
-
-#ifdef ASSIMP_USE_HUNTER
-# include
-# include
-#else
-# include "../contrib/poly2tri/poly2tri/poly2tri.h"
-# include "../contrib/clipper/clipper.hpp"
-#endif
+#include "contrib/poly2tri/poly2tri/poly2tri.h"
+#include "contrib/clipper/clipper.hpp"
#include
#include
@@ -65,8 +56,7 @@ namespace Assimp {
namespace IFC {
// ------------------------------------------------------------------------------------------------
-bool ProcessPolyloop(const Schema_2x3::IfcPolyLoop& loop, TempMesh& meshout, ConversionData& /*conv*/)
-{
+bool ProcessPolyloop(const Schema_2x3::IfcPolyLoop& loop, TempMesh& meshout, ConversionData& /*conv*/) {
size_t cnt = 0;
for(const Schema_2x3::IfcCartesianPoint& c : loop.Polygon) {
IfcVector3 tmp;
@@ -91,8 +81,7 @@ bool ProcessPolyloop(const Schema_2x3::IfcPolyLoop& loop, TempMesh& meshout, Con
}
// ------------------------------------------------------------------------------------------------
-void ProcessPolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t master_bounds = (size_t)-1)
-{
+void ProcessPolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t master_bounds = (size_t)-1) {
// handle all trivial cases
if(inmesh.mVertcnt.empty()) {
return;
@@ -127,8 +116,7 @@ void ProcessPolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t m
if (master_bounds != (size_t)-1) {
ai_assert(master_bounds < inmesh.mVertcnt.size());
outer_polygon_it = begin + master_bounds;
- }
- else {
+ } else {
for(iit = begin; iit != end; ++iit) {
// find the polygon with the largest area and take it as the outer bound.
IfcVector3& n = normals[std::distance(begin,iit)];
@@ -139,7 +127,8 @@ void ProcessPolygonBoundaries(TempMesh& result, const TempMesh& inmesh, size_t m
}
}
}
- if (outer_polygon_it == end) {
+
+ if (outer_polygon_it == end) {
return;
}
@@ -205,40 +194,20 @@ void ProcessConnectedFaceSet(const Schema_2x3::IfcConnectedFaceSet& fset, TempMe
if(const Schema_2x3::IfcPolyLoop* const polyloop = bound.Bound->ToPtr()) {
if(ProcessPolyloop(*polyloop, meshout,conv)) {
-
// The outer boundary is better determined by checking which
// polygon covers the largest area.
-
- //if(bound.ToPtr()) {
- // ob = cnt;
- //}
- //++cnt;
-
}
- }
- else {
+ } else {
IFCImporter::LogWarn("skipping unknown IfcFaceBound entity, type is ", bound.Bound->GetClassName());
continue;
}
-
- // And this, even though it is sometimes TRUE and sometimes FALSE,
- // does not really improve results.
-
- /*if(!IsTrue(bound.Orientation)) {
- size_t c = 0;
- for(unsigned int& c : meshout.vertcnt) {
- std::reverse(result.verts.begin() + cnt,result.verts.begin() + cnt + c);
- cnt += c;
- }
- }*/
}
ProcessPolygonBoundaries(result, meshout);
}
}
// ------------------------------------------------------------------------------------------------
-void ProcessRevolvedAreaSolid(const Schema_2x3::IfcRevolvedAreaSolid& solid, TempMesh& result, ConversionData& conv)
-{
+void ProcessRevolvedAreaSolid(const Schema_2x3::IfcRevolvedAreaSolid& solid, TempMesh& result, ConversionData& conv) {
TempMesh meshout;
// first read the profile description
@@ -265,7 +234,8 @@ void ProcessRevolvedAreaSolid(const Schema_2x3::IfcRevolvedAreaSolid& solid, Tem
return;
}
- const unsigned int cnt_segments = std::max(2u,static_cast(conv.settings.cylindricalTessellation * 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;
@@ -324,8 +294,9 @@ void ProcessRevolvedAreaSolid(const Schema_2x3::IfcRevolvedAreaSolid& solid, Tem
}
// ------------------------------------------------------------------------------------------------
-void ProcessSweptDiskSolid(const Schema_2x3::IfcSweptDiskSolid &solid, TempMesh& result, ConversionData& conv)
-{
+void ProcessSweptDiskSolid(const Schema_2x3::IfcSweptDiskSolid &solid,
+ TempMesh& result,
+ ConversionData& conv) {
const Curve* const curve = Curve::Convert(*solid.Directrix, conv);
if(!curve) {
IFCImporter::LogError("failed to convert Directrix curve (IfcSweptDiskSolid)");
@@ -460,8 +431,7 @@ void ProcessSweptDiskSolid(const Schema_2x3::IfcSweptDiskSolid &solid, TempMesh&
}
// ------------------------------------------------------------------------------------------------
-IfcMatrix3 DerivePlaneCoordinateSpace(const TempMesh& curmesh, bool& ok, IfcVector3& norOut)
-{
+IfcMatrix3 DerivePlaneCoordinateSpace(const TempMesh& curmesh, bool& ok, IfcVector3& norOut) {
const std::vector& out = curmesh.mVerts;
IfcMatrix3 m;
@@ -504,10 +474,6 @@ IfcMatrix3 DerivePlaneCoordinateSpace(const TempMesh& curmesh, bool& ok, IfcVect
IfcVector3 r = (out[idx]-any_point);
r.Normalize();
- //if(d) {
- // *d = -any_point * nor;
- //}
-
// Reconstruct orthonormal basis
// XXX use Gram Schmidt for increased robustness
IfcVector3 u = r ^ nor;
@@ -531,8 +497,7 @@ IfcMatrix3 DerivePlaneCoordinateSpace(const TempMesh& curmesh, bool& ok, IfcVect
const auto closeDistance = ai_epsilon;
bool areClose(Schema_2x3::IfcCartesianPoint pt1,Schema_2x3::IfcCartesianPoint pt2) {
- if(pt1.Coordinates.size() != pt2.Coordinates.size())
- {
+ if(pt1.Coordinates.size() != pt2.Coordinates.size()) {
IFCImporter::LogWarn("unable to compare differently-dimensioned points");
return false;
}
@@ -540,10 +505,10 @@ bool areClose(Schema_2x3::IfcCartesianPoint pt1,Schema_2x3::IfcCartesianPoint pt
auto coord2 = pt2.Coordinates.begin();
// we're just testing each dimension separately rather than doing euclidean distance, as we're
// looking for very close coordinates
- for(; coord1 != pt1.Coordinates.end(); coord1++,coord2++)
- {
- if(std::fabs(*coord1 - *coord2) > closeDistance)
+ for(; coord1 != pt1.Coordinates.end(); coord1++,coord2++) {
+ if(std::fabs(*coord1 - *coord2) > closeDistance) {
return false;
+ }
}
return true;
}
@@ -553,6 +518,7 @@ bool areClose(IfcVector3 pt1,IfcVector3 pt2) {
std::fabs(pt1.y - pt2.y) < closeDistance &&
std::fabs(pt1.z - pt2.z) < closeDistance);
}
+
// Extrudes the given polygon along the direction, converts it into an opening or applies all openings as necessary.
void ProcessExtrudedArea(const Schema_2x3::IfcExtrudedAreaSolid& solid, const TempMesh& curve,
const IfcVector3& extrusionDir, TempMesh& result, ConversionData &conv, bool collect_openings)
@@ -590,8 +556,9 @@ void ProcessExtrudedArea(const Schema_2x3::IfcExtrudedAreaSolid& solid, const Te
// reverse profile polygon if it's winded in the wrong direction in relation to the extrusion direction
IfcVector3 profileNormal = TempMesh::ComputePolygonNormal(in.data(), in.size());
- if( profileNormal * dir < 0.0 )
+ if( profileNormal * dir < 0.0 ) {
std::reverse(in.begin(), in.end());
+ }
std::vector nors;
const bool openings = !!conv.apply_openings && conv.apply_openings->size();
@@ -678,8 +645,7 @@ void ProcessExtrudedArea(const Schema_2x3::IfcExtrudedAreaSolid& solid, const Te
if(n > 0) {
for(size_t i = 0; i < in.size(); ++i)
out.push_back(in[i] + dir);
- }
- else {
+ } else {
for(size_t i = in.size(); i--; )
out.push_back(in[i]);
}
@@ -721,9 +687,10 @@ void ProcessExtrudedArea(const Schema_2x3::IfcExtrudedAreaSolid& solid, const Te
}
// ------------------------------------------------------------------------------------------------
-void ProcessExtrudedAreaSolid(const Schema_2x3::IfcExtrudedAreaSolid& solid, TempMesh& result,
- ConversionData& conv, bool collect_openings)
-{
+void ProcessExtrudedAreaSolid(const Schema_2x3::IfcExtrudedAreaSolid& solid,
+ TempMesh& result,
+ ConversionData& conv,
+ bool collect_openings) {
TempMesh meshout;
// First read the profile description.
@@ -761,24 +728,23 @@ void ProcessExtrudedAreaSolid(const Schema_2x3::IfcExtrudedAreaSolid& solid, Tem
}
// ------------------------------------------------------------------------------------------------
-void ProcessSweptAreaSolid(const Schema_2x3::IfcSweptAreaSolid& swept, TempMesh& meshout,
- ConversionData& conv)
-{
+void ProcessSweptAreaSolid(const Schema_2x3::IfcSweptAreaSolid& swept,
+ TempMesh& meshout,
+ ConversionData& conv) {
if(const Schema_2x3::IfcExtrudedAreaSolid* const solid = swept.ToPtr()) {
ProcessExtrudedAreaSolid(*solid,meshout,conv, !!conv.collect_openings);
- }
- else if(const Schema_2x3::IfcRevolvedAreaSolid* const rev = swept.ToPtr()) {
+ } else if(const Schema_2x3::IfcRevolvedAreaSolid* const rev = swept.ToPtr()) {
ProcessRevolvedAreaSolid(*rev,meshout,conv);
- }
- else {
+ } else {
IFCImporter::LogWarn("skipping unknown IfcSweptAreaSolid entity, type is ", swept.GetClassName());
}
}
// ------------------------------------------------------------------------------------------------
-bool ProcessGeometricItem(const Schema_2x3::IfcRepresentationItem& geo, unsigned int matid, std::set& mesh_indices,
- ConversionData& conv)
-{
+bool ProcessGeometricItem(const Schema_2x3::IfcRepresentationItem& geo,
+ unsigned int matid,
+ std::set& mesh_indices,
+ ConversionData& conv) {
bool fix_orientation = false;
std::shared_ptr< TempMesh > meshtmp = std::make_shared();
if(const Schema_2x3::IfcShellBasedSurfaceModel* shellmod = geo.ToPtr()) {
@@ -788,41 +754,32 @@ bool ProcessGeometricItem(const Schema_2x3::IfcRepresentationItem& geo, unsigned
const Schema_2x3::IfcConnectedFaceSet& fs = conv.db.MustGetObject(e).To();
ProcessConnectedFaceSet(fs, *meshtmp, conv);
- }
- catch(std::bad_cast&) {
+ } catch(std::bad_cast&) {
IFCImporter::LogWarn("unexpected type error, IfcShell ought to inherit from IfcConnectedFaceSet");
}
}
fix_orientation = true;
- }
- else if(const Schema_2x3::IfcConnectedFaceSet* fset = geo.ToPtr()) {
+ } else if(const Schema_2x3::IfcConnectedFaceSet* fset = geo.ToPtr()) {
ProcessConnectedFaceSet(*fset, *meshtmp, conv);
fix_orientation = true;
- }
- else if(const Schema_2x3::IfcSweptAreaSolid* swept = geo.ToPtr()) {
+ } else if(const Schema_2x3::IfcSweptAreaSolid* swept = geo.ToPtr()) {
ProcessSweptAreaSolid(*swept, *meshtmp, conv);
- }
- else if(const Schema_2x3::IfcSweptDiskSolid* disk = geo.ToPtr()) {
+ } else if(const Schema_2x3::IfcSweptDiskSolid* disk = geo.ToPtr()) {
ProcessSweptDiskSolid(*disk, *meshtmp, conv);
- }
- else if(const Schema_2x3::IfcManifoldSolidBrep* brep = geo.ToPtr()) {
+ } else if(const Schema_2x3::IfcManifoldSolidBrep* brep = geo.ToPtr()) {
ProcessConnectedFaceSet(brep->Outer, *meshtmp, conv);
fix_orientation = true;
- }
- else if(const Schema_2x3::IfcFaceBasedSurfaceModel* surf = geo.ToPtr()) {
+ } else if(const Schema_2x3::IfcFaceBasedSurfaceModel* surf = geo.ToPtr()) {
for(const Schema_2x3::IfcConnectedFaceSet& fc : surf->FbsmFaces) {
ProcessConnectedFaceSet(fc, *meshtmp, conv);
}
fix_orientation = true;
- }
- else if(const Schema_2x3::IfcBooleanResult* boolean = geo.ToPtr()) {
+ } else if(const Schema_2x3::IfcBooleanResult* boolean = geo.ToPtr()) {
ProcessBoolean(*boolean, *meshtmp, conv);
- }
- else if(geo.ToPtr()) {
+ } else if(geo.ToPtr()) {
// silently skip over bounding boxes
return false;
- }
- else {
+ } else {
std::stringstream toLog;
toLog << "skipping unknown IfcGeometricRepresentationItem entity, type is " << geo.GetClassName() << " id is " << geo.GetID();
IFCImporter::LogWarn(toLog.str().c_str());
@@ -868,9 +825,7 @@ bool ProcessGeometricItem(const Schema_2x3::IfcRepresentationItem& geo, unsigned
}
// ------------------------------------------------------------------------------------------------
-void AssignAddedMeshes(std::set& mesh_indices,aiNode* nd,
- ConversionData& /*conv*/)
-{
+void AssignAddedMeshes(std::set& mesh_indices,aiNode* nd, ConversionData& /*conv*/) {
if (!mesh_indices.empty()) {
std::set::const_iterator it = mesh_indices.cbegin();
std::set::const_iterator end = mesh_indices.cend();
@@ -886,9 +841,9 @@ void AssignAddedMeshes(std::set& mesh_indices,aiNode* nd,
// ------------------------------------------------------------------------------------------------
bool TryQueryMeshCache(const Schema_2x3::IfcRepresentationItem& item,
- std::set& mesh_indices, unsigned int mat_index,
- ConversionData& conv)
-{
+ std::set& mesh_indices,
+ unsigned int mat_index,
+ ConversionData& conv) {
ConversionData::MeshCacheIndex idx(&item, mat_index);
ConversionData::MeshCache::const_iterator it = conv.cached_meshes.find(idx);
if (it != conv.cached_meshes.end()) {
@@ -900,18 +855,18 @@ bool TryQueryMeshCache(const Schema_2x3::IfcRepresentationItem& item,
// ------------------------------------------------------------------------------------------------
void PopulateMeshCache(const Schema_2x3::IfcRepresentationItem& item,
- const std::set& mesh_indices, unsigned int mat_index,
- ConversionData& conv)
-{
+ const std::set& mesh_indices,
+ unsigned int mat_index,
+ ConversionData& conv) {
ConversionData::MeshCacheIndex idx(&item, mat_index);
conv.cached_meshes[idx] = mesh_indices;
}
// ------------------------------------------------------------------------------------------------
-bool ProcessRepresentationItem(const Schema_2x3::IfcRepresentationItem& item, unsigned int matid,
- std::set& mesh_indices,
- ConversionData& conv)
-{
+bool ProcessRepresentationItem(const Schema_2x3::IfcRepresentationItem& item,
+ unsigned int matid,
+ std::set& mesh_indices,
+ ConversionData& conv) {
// determine material
unsigned int localmatid = ProcessMaterials(item.GetID(), matid, conv, true);
@@ -920,8 +875,9 @@ bool ProcessRepresentationItem(const Schema_2x3::IfcRepresentationItem& item, un
if(mesh_indices.size()) {
PopulateMeshCache(item,mesh_indices,localmatid,conv);
}
+ } else {
+ return false;
}
- else return false;
}
return true;
}
@@ -930,4 +886,4 @@ bool ProcessRepresentationItem(const Schema_2x3::IfcRepresentationItem& item, un
} // ! IFC
} // ! Assimp
-#endif
+#endif // ASSIMP_BUILD_NO_IFC_IMPORTER
diff --git a/code/AssetLib/IFC/IFCLoader.cpp b/code/AssetLib/IFC/IFCLoader.cpp
index ee718681e..990986b62 100644
--- a/code/AssetLib/IFC/IFCLoader.cpp
+++ b/code/AssetLib/IFC/IFCLoader.cpp
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2022, assimp team
-
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -40,9 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file IFCLoad.cpp
- * @brief Implementation of the Industry Foundation Classes loader.
- */
+/// @file IFCLoad.cpp
+/// @brief Implementation of the Industry Foundation Classes loader.
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
@@ -92,7 +90,6 @@ using namespace Assimp::IFC;
IfcUnitAssignment
IfcClosedShell
IfcDoor
-
*/
namespace {
@@ -119,14 +116,6 @@ static const aiImporterDesc desc = {
"ifc ifczip step stp"
};
-// ------------------------------------------------------------------------------------------------
-// Constructor to be privately used by Importer
-IFCImporter::IFCImporter() = default;
-
-// ------------------------------------------------------------------------------------------------
-// Destructor, private as well
-IFCImporter::~IFCImporter() = default;
-
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool IFCImporter::CanRead(const std::string &pFile, IOSystem *pIOHandler, bool /*checkSig*/) const {
@@ -196,7 +185,7 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
size_t total = 0;
int read = 0;
do {
- int bufferSize = fileInfo.uncompressed_size < INT16_MAX ? fileInfo.uncompressed_size : INT16_MAX;
+ unsigned bufferSize = fileInfo.uncompressed_size < INT16_MAX ? static_cast(fileInfo.uncompressed_size) : INT16_MAX;
void *buffer = malloc(bufferSize);
read = unzReadCurrentFile(zip, buffer, bufferSize);
if (read > 0) {
@@ -256,7 +245,12 @@ void IFCImporter::InternReadFile(const std::string &pFile, aiScene *pScene, IOSy
// tell the reader for which types we need to simulate STEPs reverse indices
static const char *const inverse_indices_to_track[] = {
- "ifcrelcontainedinspatialstructure", "ifcrelaggregates", "ifcrelvoidselement", "ifcreldefinesbyproperties", "ifcpropertyset", "ifcstyleditem"
+ "ifcrelcontainedinspatialstructure",
+ "ifcrelaggregates",
+ "ifcrelvoidselement",
+ "ifcreldefinesbyproperties",
+ "ifcpropertyset",
+ "ifcstyleditem"
};
// feed the IFC schema into the reader and pre-parse all lines
@@ -928,4 +922,4 @@ void MakeTreeRelative(ConversionData &conv) {
} // namespace
-#endif
+#endif // ASSIMP_BUILD_NO_IFC_IMPORTER
diff --git a/code/AssetLib/IFC/IFCLoader.h b/code/AssetLib/IFC/IFCLoader.h
index 7b2c3aae6..9651b633a 100644
--- a/code/AssetLib/IFC/IFCLoader.h
+++ b/code/AssetLib/IFC/IFCLoader.h
@@ -87,8 +87,8 @@ public:
int cylindricalTessellation;
};
- IFCImporter();
- ~IFCImporter() override;
+ IFCImporter() = default;
+ ~IFCImporter() override = default;
// --------------------
bool CanRead(const std::string &pFile,
diff --git a/code/AssetLib/IFC/IFCMaterial.cpp b/code/AssetLib/IFC/IFCMaterial.cpp
index 6cd0e5910..0b7b83e7c 100644
--- a/code/AssetLib/IFC/IFCMaterial.cpp
+++ b/code/AssetLib/IFC/IFCMaterial.cpp
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2022, assimp team
-
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -40,9 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file IFCMaterial.cpp
- * @brief Implementation of conversion routines to convert IFC materials to aiMaterial
- */
+/// @file IFCMaterial.cpp
+/// @brief Implementation of conversion routines to convert IFC materials to aiMaterial
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
@@ -174,7 +172,6 @@ unsigned int ProcessMaterials(uint64_t id, unsigned int prevMatId, ConversionDat
aiString name;
name.Set("");
- // ConvertColorToString( color, name);
// look if there's already a default material with this base color
for( size_t a = 0; a < conv.materials.size(); ++a ) {
diff --git a/code/AssetLib/IFC/IFCOpenings.cpp b/code/AssetLib/IFC/IFCOpenings.cpp
index 312a49b78..c47446dda 100644
--- a/code/AssetLib/IFC/IFCOpenings.cpp
+++ b/code/AssetLib/IFC/IFCOpenings.cpp
@@ -38,24 +38,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file IFCOpenings.cpp
- * @brief Implements a subset of Ifc CSG operations for pouring
- * holes for windows and doors into walls.
- */
-
+/// @file IFCOpenings.cpp
+/// @brief Implements a subset of Ifc CSG operations for pouring
+/// holes for windows and doors into walls.
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
+
#include "IFCUtil.h"
#include "Common/PolyTools.h"
#include "PostProcessing/ProcessHelper.h"
-
-#ifdef ASSIMP_USE_HUNTER
-# include
-# include
-#else
-# include "../contrib/poly2tri/poly2tri/poly2tri.h"
-# include "../contrib/clipper/clipper.hpp"
-#endif
+#include "contrib/poly2tri/poly2tri/poly2tri.h"
+#include "contrib/clipper/clipper.hpp"
#include
#include
@@ -63,32 +56,40 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include
namespace Assimp {
- namespace IFC {
+namespace IFC {
- using ClipperLib::ulong64;
- // XXX use full -+ range ...
- const ClipperLib::long64 max_ulong64 = 1518500249; // clipper.cpp / hiRange var
+using ClipperLib::ulong64;
- //#define to_int64(p) (static_cast( std::max( 0., std::min( static_cast((p)), 1.) ) * max_ulong64 ))
-#define to_int64(p) (static_cast(static_cast((p) ) * max_ulong64 ))
-#define from_int64(p) (static_cast((p)) / max_ulong64)
-#define one_vec (IfcVector2(static_cast(1.0),static_cast(1.0)))
+// XXX use full -+ range ...
+const ClipperLib::long64 max_ulong64 = 1518500249; // clipper.cpp / hiRange var
+AI_FORCE_INLINE ulong64 to_int64(IfcFloat p) {
+ return (static_cast(static_cast((p) ) * max_ulong64 ));
+}
- // fallback method to generate wall openings
- bool TryAddOpenings_Poly2Tri(const std::vector& openings,
- TempMesh& curmesh);
+AI_FORCE_INLINE IfcFloat from_int64(ulong64 p) {
+ return (static_cast((p)) / max_ulong64);
+}
+AI_FORCE_INLINE void fillRectangle(const IfcVector2& pmin, const IfcVector2& pmax, std::vector& out) {
+ out.emplace_back(pmin.x, pmin.y);
+ out.emplace_back(pmin.x, pmax.y);
+ out.emplace_back(pmax.x, pmax.y);
+ out.emplace_back(pmax.x, pmin.y);
+}
-typedef std::pair< IfcVector2, IfcVector2 > BoundingBox;
-typedef std::map XYSortedField;
+const IfcVector2 one_vec(IfcVector2(static_cast(1.0),static_cast(1.0)));
+// fallback method to generate wall openings
+bool TryAddOpenings_Poly2Tri(const std::vector& openings, TempMesh& curmesh);
+
+using BoundingBox = std::pair< IfcVector2, IfcVector2 >;
+using XYSortedField = std::map;
// ------------------------------------------------------------------------------------------------
void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField& field,
- const std::vector< BoundingBox >& bbs,
- std::vector& out)
-{
+ const std::vector< BoundingBox >& bbs,
+ std::vector& out) {
if (!(pmin.x-pmax.x) || !(pmin.y-pmax.y)) {
return;
}
@@ -114,10 +115,7 @@ void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField&
if (!found) {
// the rectangle [pmin,pend] is opaque, fill it
- out.push_back(pmin);
- out.emplace_back(pmin.x,pmax.y);
- out.push_back(pmax);
- out.emplace_back(pmax.x,pmin.y);
+ fillRectangle(pmin, pmax, out);
return;
}
@@ -142,19 +140,12 @@ void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField&
}
if (bb.second.y > ylast) {
-
found = true;
const IfcFloat ys = std::max(bb.first.y,pmin.y), ye = std::min(bb.second.y,pmax.y);
if (ys - ylast > 0.0f) {
QuadrifyPart( IfcVector2(xs,ylast), IfcVector2(xe,ys) ,field,bbs,out);
}
- // the following are the window vertices
-
- /*wnd.push_back(IfcVector2(xs,ys));
- wnd.push_back(IfcVector2(xs,ye));
- wnd.push_back(IfcVector2(xe,ye));
- wnd.push_back(IfcVector2(xe,ys));*/
ylast = ye;
}
}
@@ -176,23 +167,19 @@ void QuadrifyPart(const IfcVector2& pmin, const IfcVector2& pmax, XYSortedField&
}
}
-typedef std::vector Contour;
-typedef std::vector SkipList; // should probably use int for performance reasons
+using Contour = std::vector;
+using SkipList = std::vector; // should probably use int for performance reasons
-struct ProjectedWindowContour
-{
+struct ProjectedWindowContour {
Contour contour;
BoundingBox bb;
SkipList skiplist;
bool is_rectangular;
+ ProjectedWindowContour(const Contour& contour, const BoundingBox& bb, bool is_rectangular)
+ : contour(contour), bb(bb) , is_rectangular(is_rectangular) {}
- ProjectedWindowContour(const Contour& contour, const BoundingBox& bb, bool is_rectangular)
- : contour(contour)
- , bb(bb)
- , is_rectangular(is_rectangular)
- {}
-
+ ~ProjectedWindowContour() = default;
bool IsInvalid() const {
return contour.empty();
@@ -207,19 +194,17 @@ struct ProjectedWindowContour
}
};
-typedef std::vector< ProjectedWindowContour > ContourVector;
+using ContourVector = std::vector;
// ------------------------------------------------------------------------------------------------
-bool BoundingBoxesOverlapping( const BoundingBox &ibb, const BoundingBox &bb )
-{
+static bool BoundingBoxesOverlapping( const BoundingBox &ibb, const BoundingBox &bb ) {
// count the '=' case as non-overlapping but as adjacent to each other
return ibb.first.x < bb.second.x && ibb.second.x > bb.first.x &&
ibb.first.y < bb.second.y && ibb.second.y > bb.first.y;
}
// ------------------------------------------------------------------------------------------------
-bool IsDuplicateVertex(const IfcVector2& vv, const std::vector& temp_contour)
-{
+static bool IsDuplicateVertex(const IfcVector2& vv, const std::vector& temp_contour) {
// sanity check for duplicate vertices
for(const IfcVector2& cp : temp_contour) {
if ((cp-vv).SquareLength() < 1e-5f) {
@@ -230,14 +215,13 @@ bool IsDuplicateVertex(const IfcVector2& vv, const std::vector& temp
}
// ------------------------------------------------------------------------------------------------
-void ExtractVerticesFromClipper(const ClipperLib::Polygon& poly, std::vector& temp_contour,
- bool filter_duplicates = false)
-{
+void ExtractVerticesFromClipper(const ClipperLib::Path& poly, std::vector& temp_contour,
+ bool filter_duplicates = false) {
temp_contour.clear();
for(const ClipperLib::IntPoint& point : poly) {
IfcVector2 vv = IfcVector2( from_int64(point.X), from_int64(point.Y));
- vv = std::max(vv,IfcVector2());
- vv = std::min(vv,one_vec);
+ vv = std::max(vv, IfcVector2());
+ vv = std::min(vv, one_vec);
if (!filter_duplicates || !IsDuplicateVertex(vv, temp_contour)) {
temp_contour.push_back(vv);
@@ -246,13 +230,12 @@ void ExtractVerticesFromClipper(const ClipperLib::Polygon& poly, std::vector()(newbb_min, newbb_max);
- for(const ClipperLib::IntPoint& point : poly) {
- IfcVector2 vv = IfcVector2( from_int64(point.X), from_int64(point.Y));
+ for (const ClipperLib::IntPoint& point : poly) {
+ IfcVector2 vv = IfcVector2(from_int64(point.X), from_int64(point.Y));
// sanity rounding
vv = std::max(vv,IfcVector2());
@@ -265,12 +248,9 @@ BoundingBox GetBoundingBox(const ClipperLib::Polygon& poly)
}
// ------------------------------------------------------------------------------------------------
-void InsertWindowContours(const ContourVector& contours,
- const std::vector& /*openings*/,
- TempMesh& curmesh)
-{
+void InsertWindowContours(const ContourVector& contours, const std::vector& /*openings*/, TempMesh& curmesh) {
// fix windows - we need to insert the real, polygonal shapes into the quadratic holes that we have now
- for(size_t i = 0; i < contours.size();++i) {
+ for (size_t i = 0; i < contours.size(); ++i) {
const BoundingBox& bb = contours[i].bb;
const std::vector& contour = contours[i].contour;
if(contour.empty()) {
@@ -287,8 +267,7 @@ void InsertWindowContours(const ContourVector& contours,
const std::set::const_iterator end = verts.end();
if (verts.find(bb.first)!=end && verts.find(bb.second)!=end
&& verts.find(IfcVector2(bb.first.x,bb.second.y))!=end
- && verts.find(IfcVector2(bb.second.x,bb.first.y))!=end
- ) {
+ && verts.find(IfcVector2(bb.second.x,bb.first.y))!=end ) {
continue;
}
}
@@ -313,8 +292,7 @@ void InsertWindowContours(const ContourVector& contours,
if (std::fabs(v.x-bb.first.x)& a,
- const std::vector& b,
- ClipperLib::ExPolygons& out)
-{
+void MergeWindowContours (const std::vector& a, const std::vector& b,
+ ClipperLib::Paths& out) {
out.clear();
ClipperLib::Clipper clipper;
- ClipperLib::Polygon clip;
+ ClipperLib::Path clip;
for(const IfcVector2& pip : a) {
clip.emplace_back(to_int64(pip.x), to_int64(pip.y));
@@ -407,7 +377,7 @@ void MergeWindowContours (const std::vector& a,
std::reverse(clip.begin(), clip.end());
}
- clipper.AddPolygon(clip, ClipperLib::ptSubject);
+ clipper.AddPath(clip, ClipperLib::ptSubject, true);
clip.clear();
for(const IfcVector2& pip : b) {
@@ -418,21 +388,19 @@ void MergeWindowContours (const std::vector& a,
std::reverse(clip.begin(), clip.end());
}
- clipper.AddPolygon(clip, ClipperLib::ptSubject);
+ clipper.AddPath(clip, ClipperLib::ptSubject, true);
clipper.Execute(ClipperLib::ctUnion, out,ClipperLib::pftNonZero,ClipperLib::pftNonZero);
}
// ------------------------------------------------------------------------------------------------
// Subtract a from b
void MakeDisjunctWindowContours (const std::vector& a,
- const std::vector& b,
- ClipperLib::ExPolygons& out)
-{
+ const std::vector& b,
+ ClipperLib::Paths& out) {
out.clear();
ClipperLib::Clipper clipper;
- ClipperLib::Polygon clip;
-
+ ClipperLib::Path clip;
for(const IfcVector2& pip : a) {
clip.emplace_back(to_int64(pip.x), to_int64(pip.y));
}
@@ -441,7 +409,7 @@ void MakeDisjunctWindowContours (const std::vector& a,
std::reverse(clip.begin(), clip.end());
}
- clipper.AddPolygon(clip, ClipperLib::ptClip);
+ clipper.AddPath(clip, ClipperLib::ptClip, true);
clip.clear();
for(const IfcVector2& pip : b) {
@@ -452,30 +420,28 @@ void MakeDisjunctWindowContours (const std::vector& a,
std::reverse(clip.begin(), clip.end());
}
- clipper.AddPolygon(clip, ClipperLib::ptSubject);
+ clipper.AddPath(clip, ClipperLib::ptSubject, true);
clipper.Execute(ClipperLib::ctDifference, out,ClipperLib::pftNonZero,ClipperLib::pftNonZero);
}
// ------------------------------------------------------------------------------------------------
-void CleanupWindowContour(ProjectedWindowContour& window)
-{
+void CleanupWindowContour(ProjectedWindowContour& window) {
std::vector scratch;
std::vector& contour = window.contour;
- ClipperLib::Polygon subject;
+ ClipperLib::Path subject;
ClipperLib::Clipper clipper;
- ClipperLib::ExPolygons clipped;
+ ClipperLib::Paths clipped;
for(const IfcVector2& pip : contour) {
subject.emplace_back(to_int64(pip.x), to_int64(pip.y));
}
- clipper.AddPolygon(subject,ClipperLib::ptSubject);
+ clipper.AddPath(subject,ClipperLib::ptSubject, true);
clipper.Execute(ClipperLib::ctUnion,clipped,ClipperLib::pftNonZero,ClipperLib::pftNonZero);
// This should yield only one polygon or something went wrong
if (clipped.size() != 1) {
-
// Empty polygon? drop the contour altogether
if(clipped.empty()) {
IFCImporter::LogError("error during polygon clipping, window contour is degenerate");
@@ -487,28 +453,25 @@ void CleanupWindowContour(ProjectedWindowContour& window)
IFCImporter::LogError("error during polygon clipping, window contour is not convex");
}
- ExtractVerticesFromClipper(clipped[0].outer, scratch);
// Assume the bounding box doesn't change during this operation
+ ExtractVerticesFromClipper(clipped[0], scratch);
}
// ------------------------------------------------------------------------------------------------
-void CleanupWindowContours(ContourVector& contours)
-{
+void CleanupWindowContours(ContourVector& contours) {
// Use PolyClipper to clean up window contours
try {
for(ProjectedWindowContour& window : contours) {
CleanupWindowContour(window);
}
- }
- catch (const char* sx) {
+ } catch (const char* sx) {
IFCImporter::LogError("error during polygon clipping, window shape may be wrong: (Clipper: "
+ std::string(sx) + ")");
}
}
// ------------------------------------------------------------------------------------------------
-void CleanupOuterContour(const std::vector& contour_flat, TempMesh& curmesh)
-{
+void CleanupOuterContour(const std::vector& contour_flat, TempMesh& curmesh) {
std::vector vold;
std::vector iold;
@@ -517,12 +480,11 @@ void CleanupOuterContour(const std::vector& contour_flat, TempMesh&
// Fix the outer contour using polyclipper
try {
-
- ClipperLib::Polygon subject;
+ ClipperLib::Path subject;
ClipperLib::Clipper clipper;
- ClipperLib::ExPolygons clipped;
+ ClipperLib::Paths clipped;
- ClipperLib::Polygon clip;
+ ClipperLib::Path clip;
clip.reserve(contour_flat.size());
for(const IfcVector2& pip : contour_flat) {
clip.emplace_back(to_int64(pip.x), to_int64(pip.y));
@@ -551,18 +513,15 @@ void CleanupOuterContour(const std::vector& contour_flat, TempMesh&
std::reverse(subject.begin(), subject.end());
}
- clipper.AddPolygon(subject,ClipperLib::ptSubject);
- clipper.AddPolygon(clip,ClipperLib::ptClip);
+ clipper.AddPath(subject,ClipperLib::ptSubject, true);
+ clipper.AddPath(clip,ClipperLib::ptClip, true);
clipper.Execute(ClipperLib::ctIntersection,clipped,ClipperLib::pftNonZero,ClipperLib::pftNonZero);
- for(const ClipperLib::ExPolygon& ex : clipped) {
- iold.push_back(static_cast(ex.outer.size()));
- for(const ClipperLib::IntPoint& point : ex.outer) {
- vold.emplace_back(
- from_int64(point.X),
- from_int64(point.Y),
- 0.0f);
+ for(const ClipperLib::Path& ex : clipped) {
+ iold.push_back(static_cast(ex.size()));
+ for(const ClipperLib::IntPoint& point : ex) {
+ vold.emplace_back(from_int64(point.X), from_int64(point.Y), 0.0f);
}
}
@@ -571,8 +530,7 @@ void CleanupOuterContour(const std::vector& contour_flat, TempMesh&
clipper.Clear();
}
}
- }
- catch (const char* sx) {
+ } catch (const char* sx) {
IFCImporter::LogError("Ifc: error during polygon clipping, wall contour line may be wrong: (Clipper: "
+ std::string(sx) + ")");
@@ -584,17 +542,14 @@ void CleanupOuterContour(const std::vector& contour_flat, TempMesh&
std::swap(iold,curmesh.mVertcnt);
}
-typedef std::vector OpeningRefs;
-typedef std::vector OpeningRefVector;
-
-typedef std::vector ;
+using OpeningRefVector = std::vector;
+using ContourRefVector = std::vector
-> ContourRefVector;
+ Contour::const_iterator> >;
// ------------------------------------------------------------------------------------------------
-bool BoundingBoxesAdjacent(const BoundingBox& bb, const BoundingBox& ibb)
-{
+bool BoundingBoxesAdjacent(const BoundingBox& bb, const BoundingBox& ibb) {
// TODO: I'm pretty sure there is a much more compact way to check this
const IfcFloat epsilon = Math::getEpsilon();
return (std::fabs(bb.second.x - ibb.first.x) < epsilon && bb.first.y <= ibb.second.y && bb.second.y >= ibb.first.y) ||
@@ -607,9 +562,8 @@ bool BoundingBoxesAdjacent(const BoundingBox& bb, const BoundingBox& ibb)
// Check if m0,m1 intersects n0,n1 assuming same ordering of the points in the line segments
// output the intersection points on n0,n1
bool IntersectingLineSegments(const IfcVector2& n0, const IfcVector2& n1,
- const IfcVector2& m0, const IfcVector2& m1,
- IfcVector2& out0, IfcVector2& out1)
-{
+ const IfcVector2& m0, const IfcVector2& m1,
+ IfcVector2& out0, IfcVector2& out1) {
const IfcVector2 n0_to_n1 = n1 - n0;
const IfcVector2 n0_to_m0 = m0 - n0;
@@ -648,8 +602,7 @@ bool IntersectingLineSegments(const IfcVector2& n0, const IfcVector2& n1,
if (std::fabs(s1) == inf && std::fabs(n0_to_m1.x) < smalle) {
s1 = 0.;
}
- }
- else {
+ } else {
s0 = n0_to_m0.y / n0_to_n1.y;
s1 = n0_to_m1.y / n0_to_n1.y;
@@ -682,8 +635,7 @@ bool IntersectingLineSegments(const IfcVector2& n0, const IfcVector2& n1,
}
// ------------------------------------------------------------------------------------------------
-void FindAdjacentContours(ContourVector::iterator current, const ContourVector& contours)
-{
+void FindAdjacentContours(ContourVector::iterator current, const ContourVector& contours) {
const IfcFloat sqlen_epsilon = static_cast(Math::getEpsilon());
const BoundingBox& bb = (*current).bb;
@@ -698,13 +650,6 @@ void FindAdjacentContours(ContourVector::iterator current, const ContourVector&
continue;
}
- // this left here to make clear we also run on the current contour
- // to check for overlapping contour segments (which can happen due
- // to projection artifacts).
- //if(it == current) {
- // continue;
- //}
-
const bool is_me = it == current;
const BoundingBox& ibb = (*it).bb;
@@ -740,8 +685,7 @@ void FindAdjacentContours(ContourVector::iterator current, const ContourVector&
ncontour.insert(ncontour.begin() + n, isect0);
skiplist.insert(skiplist.begin() + n, true);
- }
- else {
+ } else {
skiplist[n] = true;
}
@@ -759,15 +703,13 @@ void FindAdjacentContours(ContourVector::iterator current, const ContourVector&
}
// ------------------------------------------------------------------------------------------------
-AI_FORCE_INLINE bool LikelyBorder(const IfcVector2& vdelta)
-{
+AI_FORCE_INLINE bool LikelyBorder(const IfcVector2& vdelta) {
const IfcFloat dot_point_epsilon = static_cast(Math::getEpsilon());
return std::fabs(vdelta.x * vdelta.y) < dot_point_epsilon;
}
// ------------------------------------------------------------------------------------------------
-void FindBorderContours(ContourVector::iterator current)
-{
+void FindBorderContours(ContourVector::iterator current) {
const IfcFloat border_epsilon_upper = static_cast(1-1e-4);
const IfcFloat border_epsilon_lower = static_cast(1e-4);
@@ -787,20 +729,17 @@ void FindBorderContours(ContourVector::iterator current)
// not have any geometry to close them (think of door openings).
if (proj_point.x <= border_epsilon_lower || proj_point.x >= border_epsilon_upper ||
proj_point.y <= border_epsilon_lower || proj_point.y >= border_epsilon_upper) {
-
if (outer_border) {
ai_assert(cit != cbegin);
if (LikelyBorder(proj_point - last_proj_point)) {
skiplist[std::distance(cbegin, cit) - 1] = true;
}
- }
- else if (cit == cbegin) {
+ } else if (cit == cbegin) {
start_on_outer_border = true;
}
outer_border = true;
- }
- else {
+ } else {
outer_border = false;
}
@@ -817,16 +756,14 @@ void FindBorderContours(ContourVector::iterator current)
}
// ------------------------------------------------------------------------------------------------
-AI_FORCE_INLINE bool LikelyDiagonal(IfcVector2 vdelta)
-{
+AI_FORCE_INLINE bool LikelyDiagonal(IfcVector2 vdelta) {
vdelta.x = std::fabs(vdelta.x);
vdelta.y = std::fabs(vdelta.y);
return (std::fabs(vdelta.x-vdelta.y) < 0.8 * std::max(vdelta.x, vdelta.y));
}
// ------------------------------------------------------------------------------------------------
-void FindLikelyCrossingLines(ContourVector::iterator current)
-{
+void FindLikelyCrossingLines(ContourVector::iterator current) {
SkipList& skiplist = (*current).skiplist;
IfcVector2 last_proj_point;
@@ -852,10 +789,9 @@ void FindLikelyCrossingLines(ContourVector::iterator current)
// ------------------------------------------------------------------------------------------------
size_t CloseWindows(ContourVector& contours,
- const IfcMatrix4& minv,
- OpeningRefVector& contours_to_openings,
- TempMesh& curmesh)
-{
+ const IfcMatrix4& minv,
+ OpeningRefVector& contours_to_openings,
+ TempMesh& curmesh) {
size_t closed = 0;
// For all contour points, check if one of the assigned openings does
// already have points assigned to it. In this case, assume this is
@@ -964,8 +900,7 @@ size_t CloseWindows(ContourVector& contours,
if (drop_this_edge) {
curmesh.mVerts.pop_back();
curmesh.mVerts.pop_back();
- }
- else {
+ } else {
curmesh.mVerts.push_back(((cit == cbegin) != reverseCountourFaces) ? world_point : bestv);
curmesh.mVerts.push_back(((cit == cbegin) != reverseCountourFaces) ? bestv : world_point);
@@ -992,16 +927,13 @@ size_t CloseWindows(ContourVector& contours,
curmesh.mVertcnt.pop_back();
curmesh.mVerts.pop_back();
curmesh.mVerts.pop_back();
- }
- else {
+ } else {
curmesh.mVerts.push_back(reverseCountourFaces ? start0 : start1);
curmesh.mVerts.push_back(reverseCountourFaces ? start1 : start0);
}
}
}
- }
- else {
-
+ } else {
const Contour::const_iterator cbegin = (*it).contour.begin(), cend = (*it).contour.end();
for(TempOpening* opening : refs) {
ai_assert(opening->wallPoints.empty());
@@ -1018,8 +950,7 @@ size_t CloseWindows(ContourVector& contours,
}
// ------------------------------------------------------------------------------------------------
-void Quadrify(const std::vector< BoundingBox >& bbs, TempMesh& curmesh)
-{
+void Quadrify(const std::vector< BoundingBox >& bbs, TempMesh& curmesh) {
ai_assert(curmesh.IsEmpty());
std::vector quads;
@@ -1045,8 +976,7 @@ void Quadrify(const std::vector< BoundingBox >& bbs, TempMesh& curmesh)
}
// ------------------------------------------------------------------------------------------------
-void Quadrify(const ContourVector& contours, TempMesh& curmesh)
-{
+void Quadrify(const ContourVector& contours, TempMesh& curmesh) {
std::vector bbs;
bbs.reserve(contours.size());
@@ -1058,12 +988,17 @@ void Quadrify(const ContourVector& contours, TempMesh& curmesh)
}
// ------------------------------------------------------------------------------------------------
-IfcMatrix4 ProjectOntoPlane(std::vector& out_contour, const TempMesh& in_mesh,
- bool &ok, IfcVector3& nor_out)
-{
+IfcMatrix4 ProjectOntoPlane(std::vector& out_contour,
+ const TempMesh& in_mesh,
+ bool &ok,
+ IfcVector3& nor_out) {
const std::vector& in_verts = in_mesh.mVerts;
+ if (in_verts.empty()){
+ ok = false;
+ return IfcMatrix4();
+ }
+
ok = true;
-
IfcMatrix4 m = IfcMatrix4(DerivePlaneCoordinateSpace(in_mesh, ok, nor_out));
if(!ok) {
return IfcMatrix4();
@@ -1076,7 +1011,6 @@ IfcMatrix4 ProjectOntoPlane(std::vector& out_contour, const TempMesh
IfcFloat zcoord = 0;
out_contour.reserve(in_verts.size());
-
IfcVector3 vmin, vmax;
MinMaxChooser()(vmin, vmax);
@@ -1087,11 +1021,6 @@ IfcMatrix4 ProjectOntoPlane(std::vector& out_contour, const TempMesh
// (which are present, of course), this should be the same value for
// all polygon vertices (assuming the polygon is planar).
- // XXX this should be guarded, but we somehow need to pick a suitable
- // epsilon
- // if(coord != -1.0f) {
- // assert(std::fabs(coord - vv.z) < 1e-3f);
- // }
zcoord += vv.z;
vmin = std::min(vv, vmin);
vmax = std::max(vv, vmax);
@@ -1143,11 +1072,10 @@ IfcMatrix4 ProjectOntoPlane(std::vector& out_contour, const TempMesh
// ------------------------------------------------------------------------------------------------
bool GenerateOpenings(std::vector& openings,
- TempMesh& curmesh,
- bool check_intersection,
- bool generate_connection_geometry,
- const IfcVector3& wall_extrusion_axis)
-{
+ TempMesh& curmesh,
+ bool check_intersection,
+ bool generate_connection_geometry,
+ const IfcVector3& wall_extrusion_axis) {
OpeningRefVector contours_to_openings;
// Try to derive a solid base plane within the current surface for use as
@@ -1183,8 +1111,7 @@ bool GenerateOpenings(std::vector& openings,
IfcVector3 norm_extrusion_dir = opening.extrusionDir;
if (norm_extrusion_dir.SquareLength() > 1e-10) {
norm_extrusion_dir.Normalize();
- }
- else {
+ } else {
norm_extrusion_dir = IfcVector3();
}
@@ -1249,10 +1176,8 @@ bool GenerateOpenings(std::vector& openings,
const IfcVector3 v = m * x;
IfcVector2 vv(v.x, v.y);
- //if(check_intersection) {
- dmin = std::min(dmin, v.z);
- dmax = std::max(dmax, v.z);
- //}
+ dmin = std::min(dmin, v.z);
+ dmax = std::max(dmax, v.z);
// sanity rounding
vv = std::max(vv,IfcVector2());
@@ -1261,8 +1186,7 @@ bool GenerateOpenings(std::vector& openings,
if(side_flag) {
vpmin = std::min(vpmin,vv);
vpmax = std::max(vpmax,vv);
- }
- else {
+ } else {
vpmin2 = std::min(vpmin2,vv);
vpmax2 = std::max(vpmax2,vv);
}
@@ -1310,28 +1234,25 @@ bool GenerateOpenings(std::vector& openings,
// See if this BB intersects or is in close adjacency to any other BB we have so far.
for (ContourVector::iterator it = contours.begin(); it != contours.end(); ) {
const BoundingBox& ibb = (*it).bb;
-
if (BoundingBoxesOverlapping(ibb, bb)) {
-
if (!(*it).is_rectangular) {
is_rectangle = false;
}
const std::vector& other = (*it).contour;
- ClipperLib::ExPolygons poly;
+ ClipperLib::Paths poly;
// First check whether subtracting the old contour (to which ibb belongs)
// from the new contour (to which bb belongs) yields an updated bb which
// no longer overlaps ibb
MakeDisjunctWindowContours(other, temp_contour, poly);
if(poly.size() == 1) {
-
- const BoundingBox newbb = GetBoundingBox(poly[0].outer);
+ const BoundingBox newbb = GetBoundingBox(poly[0]);
if (!BoundingBoxesOverlapping(ibb, newbb )) {
// Good guy bounding box
bb = newbb ;
- ExtractVerticesFromClipper(poly[0].outer, temp_contour, false);
+ ExtractVerticesFromClipper(poly[0], temp_contour, false);
continue;
}
}
@@ -1343,15 +1264,13 @@ bool GenerateOpenings(std::vector& openings,
if (poly.size() > 1) {
return TryAddOpenings_Poly2Tri(openings, curmesh);
- }
- else if (poly.size() == 0) {
+ } else if (poly.empty()) {
IFCImporter::LogWarn("ignoring duplicate opening");
temp_contour.clear();
break;
- }
- else {
+ } else {
IFCImporter::LogVerboseDebug("merging overlapping openings");
- ExtractVerticesFromClipper(poly[0].outer, temp_contour, false);
+ ExtractVerticesFromClipper(poly[0], temp_contour, false);
// Generate the union of the bounding boxes
bb.first = std::min(bb.first, ibb.first);
@@ -1429,9 +1348,14 @@ bool GenerateOpenings(std::vector& openings,
return true;
}
-std::vector GetContourInPlane2D(const std::shared_ptr& mesh,IfcMatrix3 planeSpace,
- IfcVector3 planeNor,IfcFloat planeOffset,
- IfcVector3 extrusionDir,IfcVector3& wall_extrusion,bool& first,bool& ok) {
+std::vector GetContourInPlane2D(const std::shared_ptr& mesh,
+ IfcMatrix3 planeSpace,
+ IfcVector3 planeNor,
+ IfcFloat planeOffset,
+ IfcVector3 extrusionDir,
+ IfcVector3& wall_extrusion,
+ bool& first,
+ bool& ok) {
std::vector contour;
const auto outernor = ((mesh->mVerts[2] - mesh->mVerts[0]) ^ (mesh->mVerts[1] - mesh->mVerts[0])).Normalize();
@@ -1448,7 +1372,7 @@ std::vector GetContourInPlane2D(const std::shared_ptr& mes
const std::vector& va = mesh->mVerts;
if(va.size() <= 2) {
std::stringstream msg;
- msg << "Skipping: Only " << va.size() << " verticies in opening mesh.";
+ msg << "Skipping: Only " << va.size() << " vertices in opening mesh.";
IFCImporter::LogDebug(msg.str().c_str());
ok = false;
return contour;
@@ -1494,7 +1418,6 @@ static void logSegment(std::pair segment) {
std::vector> GetContoursInPlane3D(const std::shared_ptr& mesh,IfcMatrix3 planeSpace,
IfcFloat planeOffset) {
-
{
std::stringstream msg;
msg << "GetContoursInPlane3D: planeSpace is \n";
@@ -1521,8 +1444,8 @@ std::vector> GetContoursInPlane3D(const std::shared_ptr<
IFCImporter::LogInfo(msg.str().c_str());
}
- if(nVertices <= 2) // not a plane, a point or line
- {
+ // not a plane, a point or line
+ if(nVertices <= 2) {
std::stringstream msg;
msg << "GetContoursInPlane3D: found point or line when expecting plane (only " << nVertices << " vertices)";
IFCImporter::LogWarn(msg.str().c_str());
@@ -1552,15 +1475,12 @@ std::vector> GetContoursInPlane3D(const std::shared_ptr<
if(std::fabs(vn.z - planeOffset) < close) {
// on the plane
intersection = vn;
- }
- else if((vn.z > planeOffset) != (vp.z > planeOffset))
- {
+ } else if((vn.z > planeOffset) != (vp.z > planeOffset)) {
// passes through the plane
auto vdir = vn - vp;
auto scale = (planeOffset - vp.z) / vdir.z;
intersection = vp + scale * vdir;
- }
- else {
+ } else {
// nowhere near - move on
continue;
}
@@ -1575,15 +1495,13 @@ std::vector> GetContoursInPlane3D(const std::shared_ptr<
logSegment(s);
lineSegments.push_back(s);
// next firstpoint should be this one
- }
- else {
+ } else {
// store the first intersection point
firstPoint.x = intersection.x;
firstPoint.y = intersection.y;
gotFirstPoint = true;
}
- }
- else {
+ } else {
// now got the second point, so store the pair
IfcVector2 secondPoint(intersection.x,intersection.y);
auto s = std::pair(firstPoint,secondPoint);
@@ -1691,29 +1609,28 @@ std::vector> GetContoursInPlane3D(const std::shared_ptr<
return contours;
}
-std::vector> GetContoursInPlane(const std::shared_ptr& mesh,IfcMatrix3 planeSpace,
- IfcVector3 planeNor,IfcFloat planeOffset,
- IfcVector3 extrusionDir,IfcVector3& wall_extrusion,bool& first) {
-
- if(mesh->mVertcnt.size() == 1)
- {
+std::vector> GetContoursInPlane(const std::shared_ptr& mesh,
+ IfcMatrix3 planeSpace,
+ IfcVector3 planeNor,
+ IfcFloat planeOffset,
+ IfcVector3 extrusionDir,
+ IfcVector3& wall_extrusion,
+ bool& first) {
+ if(mesh->mVertcnt.size() == 1) {
bool ok;
auto contour = GetContourInPlane2D(mesh,planeSpace,planeNor,planeOffset,extrusionDir,wall_extrusion,first,ok);
if(ok)
return std::vector> {std::move(contour)};
else
return std::vector> {};
- }
- else
- {
+ } else {
return GetContoursInPlane3D(mesh,planeSpace,planeOffset);
}
}
// ------------------------------------------------------------------------------------------------
bool TryAddOpenings_Poly2Tri(const std::vector& openings,
- TempMesh& curmesh)
-{
+ TempMesh& curmesh) {
IFCImporter::LogWarn("forced to use poly2tri fallback method to generate wall openings");
std::vector& out = curmesh.mVerts;
@@ -1746,14 +1663,6 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
// keep Z offset in the plane coordinate system. Ignoring precision issues
// (which are present, of course), this should be the same value for
// all polygon vertices (assuming the polygon is planar).
-
-
- // XXX this should be guarded, but we somehow need to pick a suitable
- // epsilon
- // if(coord != -1.0f) {
- // assert(std::fabs(coord - vv.z) < 1e-3f);
- // }
-
coord = vv.z;
vmin = std::min(IfcVector2(vv.x, vv.y), vmin);
@@ -1771,15 +1680,13 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
// If this happens then the projection must have been wrong.
ai_assert(vmax.Length());
- ClipperLib::ExPolygons clipped;
- ClipperLib::Polygons holes_union;
-
+ ClipperLib::Paths clipped;
+ ClipperLib::Paths holes_union;
IfcVector3 wall_extrusion;
bool first = true;
try {
-
ClipperLib::Clipper clipper_holes;
for(const TempOpening& t : openings) {
@@ -1787,7 +1694,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
for(auto& contour : contours) {
// scale to clipping space
- ClipperLib::Polygon hole;
+ ClipperLib::Path hole;
for(IfcVector2& pip : contour) {
pip.x = (pip.x - vmin.x) / vmax.x;
pip.y = (pip.y - vmin.y) / vmax.y;
@@ -1797,16 +1704,9 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
if(!ClipperLib::Orientation(hole)) {
std::reverse(hole.begin(),hole.end());
- // assert(ClipperLib::Orientation(hole));
}
- /*ClipperLib::Polygons pol_temp(1), pol_temp2(1);
- pol_temp[0] = hole;
-
- ClipperLib::OffsetPolygons(pol_temp,pol_temp2,5.0);
- hole = pol_temp2[0];*/
-
- clipper_holes.AddPolygon(hole,ClipperLib::ptSubject);
+ clipper_holes.AddPath(hole,ClipperLib::ptSubject, true);
{
std::stringstream msg;
msg << "- added polygon ";
@@ -1829,7 +1729,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
// Now that we have the big union of all holes, subtract it from the outer contour
// to obtain the final polygon to feed into the triangulator.
{
- ClipperLib::Polygon poly;
+ ClipperLib::Path poly;
for(IfcVector2& pip : contour_flat) {
pip.x = (pip.x - vmin.x) / vmax.x;
pip.y = (pip.y - vmin.y) / vmax.y;
@@ -1841,16 +1741,14 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
std::reverse(poly.begin(), poly.end());
}
clipper_holes.Clear();
- clipper_holes.AddPolygon(poly,ClipperLib::ptSubject);
+ clipper_holes.AddPath(poly,ClipperLib::ptSubject, true);
- clipper_holes.AddPolygons(holes_union,ClipperLib::ptClip);
+ clipper_holes.AddPaths(holes_union,ClipperLib::ptClip, true);
clipper_holes.Execute(ClipperLib::ctDifference,clipped,
ClipperLib::pftNonZero,
ClipperLib::pftNonZero);
}
-
- }
- catch (const char* sx) {
+ } catch (const char* sx) {
IFCImporter::LogError("Ifc: error during polygon clipping, skipping openings for this face: (Clipper: "
+ std::string(sx) + ")");
@@ -1864,13 +1762,13 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
old_vertcnt.swap(curmesh.mVertcnt);
std::vector< std::vector > contours;
- for(ClipperLib::ExPolygon& clip : clipped) {
+ for(ClipperLib::Path &clip : clipped) {
contours.clear();
// Build the outer polygon contour line for feeding into poly2tri
std::vector contour_points;
- for(ClipperLib::IntPoint& point : clip.outer) {
+ for(ClipperLib::IntPoint& point : clip) {
contour_points.push_back( new p2t::Point(from_int64(point.X), from_int64(point.Y)) );
}
@@ -1881,16 +1779,14 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
// happen in production use if the input data is broken. An assertion would be
// inappropriate.
cdt = new p2t::CDT(contour_points);
- }
- catch(const std::exception& e) {
+ } catch(const std::exception& e) {
IFCImporter::LogError("Ifc: error during polygon triangulation, skipping some openings: (poly2tri: "
+ std::string(e.what()) + ")");
continue;
}
-
// Build the poly2tri inner contours for all holes we got from ClipperLib
- for(ClipperLib::Polygon& opening : clip.holes) {
+ for(ClipperLib::Path& opening : holes_union) {
contours.emplace_back();
std::vector& contour = contours.back();
@@ -1905,8 +1801,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
try {
// Note: See above
cdt->Triangulate();
- }
- catch(const std::exception& e) {
+ } catch(const std::exception& e) {
IFCImporter::LogError("Ifc: error during polygon triangulation, skipping some openings: (poly2tri: "
+ std::string(e.what()) + ")");
continue;
@@ -1945,12 +1840,11 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,
return result;
}
-
- } // ! IFC
+} // ! IFC
} // ! Assimp
#undef to_int64
#undef from_int64
#undef one_vec
-#endif
+#endif // ASSIMP_BUILD_NO_IFC_IMPORTER
diff --git a/code/AssetLib/IFC/IFCProfile.cpp b/code/AssetLib/IFC/IFCProfile.cpp
index cee36c022..0e4670560 100644
--- a/code/AssetLib/IFC/IFCProfile.cpp
+++ b/code/AssetLib/IFC/IFCProfile.cpp
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2022, assimp team
-
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -40,9 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file IFCProfile.cpp
- * @brief Read profile and curves entities from IFC files
- */
+/// @file IFCProfile.cpp
+/// @brief Read profile and curves entities from IFC files
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
@@ -52,8 +50,9 @@ namespace Assimp {
namespace IFC {
// ------------------------------------------------------------------------------------------------
-void ProcessPolyLine(const Schema_2x3::IfcPolyline& def, TempMesh& meshout, ConversionData& /*conv*/)
-{
+void ProcessPolyLine(const Schema_2x3::IfcPolyline& def,
+ TempMesh& meshout,
+ ConversionData& /*conv*/) {
// this won't produce a valid mesh, it just spits out a list of vertices
IfcVector3 t;
for(const Schema_2x3::IfcCartesianPoint& cp : def.Points) {
@@ -64,8 +63,9 @@ void ProcessPolyLine(const Schema_2x3::IfcPolyline& def, TempMesh& meshout, Conv
}
// ------------------------------------------------------------------------------------------------
-bool ProcessCurve(const Schema_2x3::IfcCurve& curve, TempMesh& meshout, ConversionData& conv)
-{
+bool ProcessCurve(const Schema_2x3::IfcCurve& curve,
+ TempMesh& meshout,
+ ConversionData& conv) {
std::unique_ptr cv(Curve::Convert(curve,conv));
if (!cv) {
IFCImporter::LogWarn("skipping unknown IfcCurve entity, type is ", curve.GetClassName());
@@ -90,20 +90,23 @@ bool ProcessCurve(const Schema_2x3::IfcCurve& curve, TempMesh& meshout, Convers
}
// ------------------------------------------------------------------------------------------------
-void ProcessClosedProfile(const Schema_2x3::IfcArbitraryClosedProfileDef& def, TempMesh& meshout, ConversionData& conv)
-{
+void ProcessClosedProfile(const Schema_2x3::IfcArbitraryClosedProfileDef& def,
+ TempMesh& meshout,
+ ConversionData& conv) {
ProcessCurve(def.OuterCurve,meshout,conv);
}
// ------------------------------------------------------------------------------------------------
-void ProcessOpenProfile(const Schema_2x3::IfcArbitraryOpenProfileDef& def, TempMesh& meshout, ConversionData& conv)
-{
+void ProcessOpenProfile(const Schema_2x3::IfcArbitraryOpenProfileDef& def,
+ TempMesh& meshout,
+ ConversionData& conv) {
ProcessCurve(def.Curve,meshout,conv);
}
// ------------------------------------------------------------------------------------------------
-void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& def, TempMesh& meshout, ConversionData& conv)
-{
+void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& def,
+ TempMesh& meshout,
+ ConversionData& conv) {
if(const Schema_2x3::IfcRectangleProfileDef* const cprofile = def.ToPtr()) {
const IfcFloat x = cprofile->XDim*0.5f, y = cprofile->YDim*0.5f;
@@ -113,8 +116,7 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
meshout.mVerts.emplace_back(-x,-y, 0.f );
meshout.mVerts.emplace_back( x,-y, 0.f );
meshout.mVertcnt.push_back(4);
- }
- else if( const Schema_2x3::IfcCircleProfileDef* const circle = def.ToPtr()) {
+ } else if( const Schema_2x3::IfcCircleProfileDef* const circle = def.ToPtr()) {
if(def.ToPtr()) {
// TODO
}
@@ -129,8 +131,7 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
}
meshout.mVertcnt.push_back(static_cast(segments));
- }
- else if( const Schema_2x3::IfcIShapeProfileDef* const ishape = def.ToPtr()) {
+ } else if( const Schema_2x3::IfcIShapeProfileDef* const ishape = def.ToPtr()) {
// construct simplified IBeam shape
const IfcFloat offset = (ishape->OverallWidth - ishape->WebThickness) / 2;
const IfcFloat inner_height = ishape->OverallDepth - ishape->FlangeThickness * 2;
@@ -150,8 +151,7 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
meshout.mVerts.emplace_back(ishape->OverallWidth,0,0);
meshout.mVertcnt.push_back(12);
- }
- else {
+ } else {
IFCImporter::LogWarn("skipping unknown IfcParameterizedProfileDef entity, type is ", def.GetClassName());
return;
}
@@ -162,18 +162,14 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
}
// ------------------------------------------------------------------------------------------------
-bool ProcessProfile(const Schema_2x3::IfcProfileDef& prof, TempMesh& meshout, ConversionData& conv)
-{
+bool ProcessProfile(const Schema_2x3::IfcProfileDef& prof, TempMesh& meshout, ConversionData& conv) {
if(const Schema_2x3::IfcArbitraryClosedProfileDef* const cprofile = prof.ToPtr()) {
ProcessClosedProfile(*cprofile,meshout,conv);
- }
- else if(const Schema_2x3::IfcArbitraryOpenProfileDef* const copen = prof.ToPtr()) {
+ } else if(const Schema_2x3::IfcArbitraryOpenProfileDef* const copen = prof.ToPtr()) {
ProcessOpenProfile(*copen,meshout,conv);
- }
- else if(const Schema_2x3::IfcParameterizedProfileDef* const cparam = prof.ToPtr()) {
+ } else if(const Schema_2x3::IfcParameterizedProfileDef* const cparam = prof.ToPtr()) {
ProcessParametrizedProfile(*cparam,meshout,conv);
- }
- else {
+ } else {
IFCImporter::LogWarn("skipping unknown IfcProfileDef entity, type is ", prof.GetClassName());
return false;
}
diff --git a/code/AssetLib/IFC/IFCUtil.cpp b/code/AssetLib/IFC/IFCUtil.cpp
index eb636d735..27f3141c8 100644
--- a/code/AssetLib/IFC/IFCUtil.cpp
+++ b/code/AssetLib/IFC/IFCUtil.cpp
@@ -4,7 +4,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2022, assimp team
-
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -40,9 +39,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------
*/
-/** @file IFCUtil.cpp
- * @brief Implementation of conversion routines for some common Ifc helper entities.
- */
+/// @file IFCUtil.cpp
+/// @brief Implementation of conversion routines for some common Ifc helper entities.
#ifndef ASSIMP_BUILD_NO_IFC_IMPORTER
@@ -66,8 +64,7 @@ void TempOpening::Transform(const IfcMatrix4& mat) {
}
// ------------------------------------------------------------------------------------------------
-aiMesh* TempMesh::ToMesh()
-{
+aiMesh* TempMesh::ToMesh() {
ai_assert(mVerts.size() == std::accumulate(mVertcnt.begin(),mVertcnt.end(),size_t(0)));
if (mVerts.empty()) {
@@ -105,36 +102,31 @@ aiMesh* TempMesh::ToMesh()
}
// ------------------------------------------------------------------------------------------------
-void TempMesh::Clear()
-{
+void TempMesh::Clear() {
mVerts.clear();
mVertcnt.clear();
}
// ------------------------------------------------------------------------------------------------
-void TempMesh::Transform(const IfcMatrix4& mat)
-{
+void TempMesh::Transform(const IfcMatrix4& mat) {
for(IfcVector3& v : mVerts) {
v *= mat;
}
}
// ------------------------------------------------------------------------------
-IfcVector3 TempMesh::Center() const
-{
- return (mVerts.size() == 0) ? IfcVector3(0.0f, 0.0f, 0.0f) : (std::accumulate(mVerts.begin(),mVerts.end(),IfcVector3()) / static_cast(mVerts.size()));
+IfcVector3 TempMesh::Center() const {
+ return mVerts.empty() ? IfcVector3(0.0f, 0.0f, 0.0f) : (std::accumulate(mVerts.begin(),mVerts.end(),IfcVector3()) / static_cast(mVerts.size()));
}
// ------------------------------------------------------------------------------------------------
-void TempMesh::Append(const TempMesh& other)
-{
+void TempMesh::Append(const TempMesh& other) {
mVerts.insert(mVerts.end(),other.mVerts.begin(),other.mVerts.end());
mVertcnt.insert(mVertcnt.end(),other.mVertcnt.begin(),other.mVertcnt.end());
}
// ------------------------------------------------------------------------------------------------
-void TempMesh::RemoveDegenerates()
-{
+void TempMesh::RemoveDegenerates() {
// The strategy is simple: walk the mesh and compute normals using
// Newell's algorithm. The length of the normals gives the area
// of the polygons, which is close to zero for lines.
@@ -167,11 +159,9 @@ void TempMesh::RemoveDegenerates()
}
// ------------------------------------------------------------------------------------------------
-IfcVector3 TempMesh::ComputePolygonNormal(const IfcVector3* vtcs, size_t cnt, bool normalize)
-{
+IfcVector3 TempMesh::ComputePolygonNormal(const IfcVector3* vtcs, size_t cnt, bool normalize) {
std::vector temp((cnt+2)*3);
- for( size_t vofs = 0, i = 0; vofs < cnt; ++vofs )
- {
+ for( size_t vofs = 0, i = 0; vofs < cnt; ++vofs ) {
const IfcVector3& v = vtcs[vofs];
temp[i++] = v.x;
temp[i++] = v.y;
@@ -185,9 +175,8 @@ IfcVector3 TempMesh::ComputePolygonNormal(const IfcVector3* vtcs, size_t cnt, bo
// ------------------------------------------------------------------------------------------------
void TempMesh::ComputePolygonNormals(std::vector& normals,
- bool normalize,
- size_t ofs) const
-{
+ bool normalize,
+ size_t ofs) const {
size_t max_vcount = 0;
std::vector::const_iterator begin = mVertcnt.begin()+ofs, end = mVertcnt.end(), iit;
for(iit = begin; iit != end; ++iit) {
@@ -250,29 +239,27 @@ struct FindVector {
};
// ------------------------------------------------------------------------------------------------
-void TempMesh::FixupFaceOrientation()
-{
+void TempMesh::FixupFaceOrientation() {
const IfcVector3 vavg = Center();
// create a list of start indices for all faces to allow random access to faces
std::vector faceStartIndices(mVertcnt.size());
- for( size_t i = 0, a = 0; a < mVertcnt.size(); i += mVertcnt[a], ++a )
+ for( size_t i = 0, a = 0; a < mVertcnt.size(); i += mVertcnt[a], ++a ) {
faceStartIndices[a] = i;
+ }
// list all faces on a vertex
std::map, CompareVector> facesByVertex;
- for( size_t a = 0; a < mVertcnt.size(); ++a )
- {
- for( size_t b = 0; b < mVertcnt[a]; ++b )
+ for( size_t a = 0; a < mVertcnt.size(); ++a ) {
+ for( size_t b = 0; b < mVertcnt[a]; ++b ) {
facesByVertex[mVerts[faceStartIndices[a] + b]].push_back(a);
+ }
}
// determine neighbourhood for all polys
std::vector neighbour(mVerts.size(), SIZE_MAX);
std::vector tempIntersect(10);
- for( size_t a = 0; a < mVertcnt.size(); ++a )
- {
- for( size_t b = 0; b < mVertcnt[a]; ++b )
- {
+ for( size_t a = 0; a < mVertcnt.size(); ++a ) {
+ for( size_t b = 0; b < mVertcnt[a]; ++b ) {
size_t ib = faceStartIndices[a] + b, nib = faceStartIndices[a] + (b + 1) % mVertcnt[a];
const std::vector& facesOnB = facesByVertex[mVerts[ib]];
const std::vector& facesOnNB = facesByVertex[mVerts[nib]];
@@ -281,10 +268,12 @@ void TempMesh::FixupFaceOrientation()
std::vector::iterator sectend = std::set_intersection(
facesOnB.begin(), facesOnB.end(), facesOnNB.begin(), facesOnNB.end(), sectstart);
- if( std::distance(sectstart, sectend) != 2 )
+ if( std::distance(sectstart, sectend) != 2 ) {
continue;
- if( *sectstart == a )
+ }
+ if( *sectstart == a ) {
++sectstart;
+ }
neighbour[ib] = *sectstart;
}
}
@@ -293,15 +282,14 @@ void TempMesh::FixupFaceOrientation()
// facing outwards. So we reverse this face to point outwards in relation to the center. Then we adapt neighbouring
// faces to have the same winding until all faces have been tested.
std::vector faceDone(mVertcnt.size(), false);
- while( std::count(faceDone.begin(), faceDone.end(), false) != 0 )
- {
+ while( std::count(faceDone.begin(), faceDone.end(), false) != 0 ) {
// find the farthest of the remaining faces
size_t farthestIndex = SIZE_MAX;
IfcFloat farthestDistance = -1.0;
- for( size_t a = 0; a < mVertcnt.size(); ++a )
- {
- if( faceDone[a] )
+ for( size_t a = 0; a < mVertcnt.size(); ++a ) {
+ if( faceDone[a] ) {
continue;
+ }
IfcVector3 faceCenter = std::accumulate(mVerts.begin() + faceStartIndices[a],
mVerts.begin() + faceStartIndices[a] + mVertcnt[a], IfcVector3(0.0)) / IfcFloat(mVertcnt[a]);
IfcFloat dst = (faceCenter - vavg).SquareLength();
@@ -315,8 +303,7 @@ void TempMesh::FixupFaceOrientation()
/ IfcFloat(mVertcnt[farthestIndex]);
// We accept a bit of negative orientation without reversing. In case of doubt, prefer the orientation given in
// the file.
- if( (farthestNormal * (farthestCenter - vavg).Normalize()) < -0.4 )
- {
+ if( (farthestNormal * (farthestCenter - vavg).Normalize()) < -0.4 ) {
size_t fsi = faceStartIndices[farthestIndex], fvc = mVertcnt[farthestIndex];
std::reverse(mVerts.begin() + fsi, mVerts.begin() + fsi + fvc);
std::reverse(neighbour.begin() + fsi, neighbour.begin() + fsi + fvc);
@@ -333,19 +320,18 @@ void TempMesh::FixupFaceOrientation()
todo.push_back(farthestIndex);
// go over its neighbour faces recursively and adapt their winding order to match the farthest face
- while( !todo.empty() )
- {
+ while( !todo.empty() ) {
size_t tdf = todo.back();
size_t vsi = faceStartIndices[tdf], vc = mVertcnt[tdf];
todo.pop_back();
// check its neighbours
- for( size_t a = 0; a < vc; ++a )
- {
+ for( size_t a = 0; a < vc; ++a ) {
// ignore neighbours if we already checked them
size_t nbi = neighbour[vsi + a];
- if( nbi == SIZE_MAX || faceDone[nbi] )
+ if( nbi == SIZE_MAX || faceDone[nbi] ) {
continue;
+ }
const IfcVector3& vp = mVerts[vsi + a];
size_t nbvsi = faceStartIndices[nbi], nbvc = mVertcnt[nbi];
@@ -388,32 +374,8 @@ void TempMesh::RemoveAdjacentDuplicates() {
IfcVector3 vmin,vmax;
ArrayBounds(&*base, cnt ,vmin,vmax);
-
const IfcFloat epsilon = (vmax-vmin).SquareLength() / static_cast(1e9);
- //const IfcFloat dotepsilon = 1e-9;
-
- //// look for vertices that lie directly on the line between their predecessor and their
- //// successor and replace them with either of them.
-
- //for(size_t i = 0; i < cnt; ++i) {
- // IfcVector3& v1 = *(base+i), &v0 = *(base+(i?i-1:cnt-1)), &v2 = *(base+(i+1)%cnt);
- // const IfcVector3& d0 = (v1-v0), &d1 = (v2-v1);
- // const IfcFloat l0 = d0.SquareLength(), l1 = d1.SquareLength();
- // if (!l0 || !l1) {
- // continue;
- // }
-
- // const IfcFloat d = (d0/std::sqrt(l0))*(d1/std::sqrt(l1));
-
- // if ( d >= 1.f-dotepsilon ) {
- // v1 = v0;
- // }
- // else if ( d < -1.f+dotepsilon ) {
- // v2 = v1;
- // continue;
- // }
- //}
-
+
// drop any identical, adjacent vertices. this pass will collect the dropouts
// of the previous pass as a side-effect.
FuzzyVectorCompare fz(epsilon);
@@ -440,78 +402,58 @@ void TempMesh::RemoveAdjacentDuplicates() {
}
// ------------------------------------------------------------------------------------------------
-void TempMesh::Swap(TempMesh& other)
-{
+void TempMesh::Swap(TempMesh& other) {
mVertcnt.swap(other.mVertcnt);
mVerts.swap(other.mVerts);
}
// ------------------------------------------------------------------------------------------------
-bool IsTrue(const ::Assimp::STEP::EXPRESS::BOOLEAN& in)
-{
+bool IsTrue(const ::Assimp::STEP::EXPRESS::BOOLEAN& in) {
return (std::string)in == "TRUE" || (std::string)in == "T";
}
// ------------------------------------------------------------------------------------------------
-IfcFloat ConvertSIPrefix(const std::string& prefix)
-{
+IfcFloat ConvertSIPrefix(const std::string& prefix) {
if (prefix == "EXA") {
return 1e18f;
- }
- else if (prefix == "PETA") {
+ } else if (prefix == "PETA") {
return 1e15f;
- }
- else if (prefix == "TERA") {
+ } else if (prefix == "TERA") {
return 1e12f;
- }
- else if (prefix == "GIGA") {
+ } else if (prefix == "GIGA") {
return 1e9f;
- }
- else if (prefix == "MEGA") {
+ } else if (prefix == "MEGA") {
return 1e6f;
- }
- else if (prefix == "KILO") {
+ } else if (prefix == "KILO") {
return 1e3f;
- }
- else if (prefix == "HECTO") {
+ } else if (prefix == "HECTO") {
return 1e2f;
- }
- else if (prefix == "DECA") {
+ } else if (prefix == "DECA") {
return 1e-0f;
- }
- else if (prefix == "DECI") {
+ } else if (prefix == "DECI") {
return 1e-1f;
- }
- else if (prefix == "CENTI") {
+ } else if (prefix == "CENTI") {
return 1e-2f;
- }
- else if (prefix == "MILLI") {
+ } else if (prefix == "MILLI") {
return 1e-3f;
- }
- else if (prefix == "MICRO") {
+ } else if (prefix == "MICRO") {
return 1e-6f;
- }
- else if (prefix == "NANO") {
+ } else if (prefix == "NANO") {
return 1e-9f;
- }
- else if (prefix == "PICO") {
+ } else if (prefix == "PICO") {
return 1e-12f;
- }
- else if (prefix == "FEMTO") {
+ } else if (prefix == "FEMTO") {
return 1e-15f;
- }
- else if (prefix == "ATTO") {
+ } else if (prefix == "ATTO") {
return 1e-18f;
- }
- else {
+ } else {
IFCImporter::LogError("Unrecognized SI prefix: ", prefix);
return 1;
}
}
// ------------------------------------------------------------------------------------------------
-void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourRgb& in)
-{
+void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourRgb& in) {
out.r = static_cast( in.Red );
out.g = static_cast( in.Green );
out.b = static_cast( in.Blue );
@@ -519,8 +461,10 @@ void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourRgb& in)
}
// ------------------------------------------------------------------------------------------------
-void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourOrFactor& in,ConversionData& conv,const aiColor4D* base)
-{
+void ConvertColor(aiColor4D& out,
+ const Schema_2x3::IfcColourOrFactor& in,
+ ConversionData& conv,
+ const aiColor4D* base) {
if (const ::Assimp::STEP::EXPRESS::REAL* const r = in.ToPtr<::Assimp::STEP::EXPRESS::REAL>()) {
out.r = out.g = out.b = static_cast(*r);
if(base) {
@@ -528,20 +472,18 @@ void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourOrFactor& in,Conver
out.g *= static_cast( base->g );
out.b *= static_cast( base->b );
out.a = static_cast( base->a );
+ } else {
+ out.a = 1.0;
}
- else out.a = 1.0;
- }
- else if (const Schema_2x3::IfcColourRgb* const rgb = in.ResolveSelectPtr(conv.db)) {
+ } else if (const Schema_2x3::IfcColourRgb* const rgb = in.ResolveSelectPtr(conv.db)) {
ConvertColor(out,*rgb);
- }
- else {
+ } else {
IFCImporter::LogWarn("skipping unknown IfcColourOrFactor entity");
}
}
// ------------------------------------------------------------------------------------------------
-void ConvertCartesianPoint(IfcVector3& out, const Schema_2x3::IfcCartesianPoint& in)
-{
+void ConvertCartesianPoint(IfcVector3& out, const Schema_2x3::IfcCartesianPoint& in) {
out = IfcVector3();
for(size_t i = 0; i < in.Coordinates.size(); ++i) {
out[static_cast(i)] = in.Coordinates[i];
@@ -549,15 +491,13 @@ void ConvertCartesianPoint(IfcVector3& out, const Schema_2x3::IfcCartesianPoint&
}
// ------------------------------------------------------------------------------------------------
-void ConvertVector(IfcVector3& out, const Schema_2x3::IfcVector& in)
-{
+void ConvertVector(IfcVector3& out, const Schema_2x3::IfcVector& in) {
ConvertDirection(out,in.Orientation);
out *= in.Magnitude;
}
// ------------------------------------------------------------------------------------------------
-void ConvertDirection(IfcVector3& out, const Schema_2x3::IfcDirection& in)
-{
+void ConvertDirection(IfcVector3& out, const Schema_2x3::IfcDirection& in) {
out = IfcVector3();
for(size_t i = 0; i < in.DirectionRatios.size(); ++i) {
out[static_cast(i)] = in.DirectionRatios[i];
@@ -571,8 +511,7 @@ void ConvertDirection(IfcVector3& out, const Schema_2x3::IfcDirection& in)
}
// ------------------------------------------------------------------------------------------------
-void AssignMatrixAxes(IfcMatrix4& out, const IfcVector3& x, const IfcVector3& y, const IfcVector3& z)
-{
+void AssignMatrixAxes(IfcMatrix4& out, const IfcVector3& x, const IfcVector3& y, const IfcVector3& z) {
out.a1 = x.x;
out.b1 = x.y;
out.c1 = x.z;
@@ -587,8 +526,7 @@ void AssignMatrixAxes(IfcMatrix4& out, const IfcVector3& x, const IfcVector3& y,
}
// ------------------------------------------------------------------------------------------------
-void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement3D& in)
-{
+void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement3D& in) {
IfcVector3 loc;
ConvertCartesianPoint(loc,in.Location);
@@ -612,8 +550,7 @@ void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement3D
}
// ------------------------------------------------------------------------------------------------
-void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement2D& in)
-{
+void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement2D& in) {
IfcVector3 loc;
ConvertCartesianPoint(loc,in.Location);
@@ -629,34 +566,28 @@ void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement2D
}
// ------------------------------------------------------------------------------------------------
-void ConvertAxisPlacement(IfcVector3& axis, IfcVector3& pos, const Schema_2x3::IfcAxis1Placement& in)
-{
+void ConvertAxisPlacement(IfcVector3& axis, IfcVector3& pos, const Schema_2x3::IfcAxis1Placement& in) {
ConvertCartesianPoint(pos,in.Location);
if (in.Axis) {
ConvertDirection(axis,in.Axis.Get());
- }
- else {
+ } else {
axis = IfcVector3(0.f,0.f,1.f);
}
}
// ------------------------------------------------------------------------------------------------
-void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement& in, ConversionData& conv)
-{
+void ConvertAxisPlacement(IfcMatrix4& out, const Schema_2x3::IfcAxis2Placement& in, ConversionData& conv) {
if(const Schema_2x3::IfcAxis2Placement3D* pl3 = in.ResolveSelectPtr(conv.db)) {
ConvertAxisPlacement(out,*pl3);
- }
- else if(const Schema_2x3::IfcAxis2Placement2D* pl2 = in.ResolveSelectPtr(conv.db)) {
+ } else if(const Schema_2x3::IfcAxis2Placement2D* pl2 = in.ResolveSelectPtr(conv.db)) {
ConvertAxisPlacement(out,*pl2);
- }
- else {
+ } else {
IFCImporter::LogWarn("skipping unknown IfcAxis2Placement entity");
}
}
// ------------------------------------------------------------------------------------------------
-void ConvertTransformOperator(IfcMatrix4& out, const Schema_2x3::IfcCartesianTransformationOperator& op)
-{
+void ConvertTransformOperator(IfcMatrix4& out, const Schema_2x3::IfcCartesianTransformationOperator& op) {
IfcVector3 loc;
ConvertCartesianPoint(loc,op.LocalOrigin);
@@ -677,14 +608,12 @@ void ConvertTransformOperator(IfcMatrix4& out, const Schema_2x3::IfcCartesianTra
IfcMatrix4::Translation(loc,locm);
AssignMatrixAxes(out,x,y,z);
-
IfcVector3 vscale;
if (const Schema_2x3::IfcCartesianTransformationOperator3DnonUniform* nuni = op.ToPtr