Pārlūkot izejas kodu

Mosfet80 clipper update (#5220)

* remove deprecated sprinf

* Update clipper
Updated Clipper to V6.4.2

* Fix the build

* Fix the build

* Disable hunter build

* Fix: Fix hided var.

* Fix invalid use of hunter enabled macro.

* Fix misconfig for hunter

* Disable removing contrib folder

* Update BlenderTessellator.h

* Remove Hunter-based includes

* Refactorings

* Remove final

* Update IFCCurve.cpp

* Update IFCCurve.cpp

---------

Co-authored-by: andrea <[email protected]>
Co-authored-by: Kim Kulling <[email protected]>
Kim Kulling 1 gadu atpakaļ
vecāks
revīzija
aa1996e143

+ 0 - 6
.github/workflows/ccpp.yml

@@ -74,12 +74,6 @@ jobs:
         repository: cpp-pm/polly
         path: cmake/polly
 
-    - name: Remove contrib directory for Hunter builds
-      if: contains(matrix.name, 'hunter')
-      uses: JesseTG/[email protected]
-      with:
-        path: contrib
-
     - name: Cache DX SDK
       id: dxcache
       if: contains(matrix.name, 'windows')

+ 14 - 20
CMakeLists.txt

@@ -52,7 +52,6 @@ IF(ASSIMP_HUNTER_ENABLED)
     URL "https://github.com/cpp-pm/hunter/archive/v0.24.17.tar.gz"
     SHA1 "e6396699e414120e32557fe92db097b7655b760b"
   )
-
   add_definitions(-DASSIMP_USE_HUNTER)
 ENDIF()
 
@@ -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()
@@ -265,7 +260,6 @@ ENDIF()
 # Grouped compiler settings ########################################
 IF ((CMAKE_C_COMPILER_ID MATCHES "GNU") AND NOT MINGW)
   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()

+ 0 - 4
code/AssetLib/Blender/BlenderScene.cpp

@@ -102,10 +102,6 @@ void Structure::Convert<CollectionObject>(
 
     ReadFieldPtr<ErrorPolicy_Fail>(dest.next, "*next", db);
     {
-        //std::shared_ptr<CollectionObject> prev;
-        //ReadFieldPtr<ErrorPolicy_Fail>(prev, "*prev", db);
-        //dest.prev = prev.get();
-
         std::shared_ptr<Object> ob;
         ReadFieldPtr<ErrorPolicy_Igno>(ob, "*ob", db);
         dest.ob = ob.get();

+ 2 - 5
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
 

+ 1 - 6
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 <poly2tri/poly2tri.h>
-#else
-#  include "../contrib/poly2tri/poly2tri/poly2tri.h"
-#endif
+#include "contrib/poly2tri/poly2tri/poly2tri.h"
 
 namespace Assimp
 {

+ 23 - 15
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 <iterator>
 #include <tuple>
 #include <utility>
@@ -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<IfcVector3> &resultpoly) {
     FuzzyVectorCompare fz(epsilon);
     std::vector<IfcVector3>::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

+ 31 - 33
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<IfcFloat>( 0. ), static_cast<IfcFloat>( 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) {}
+    
+    // --------------------------------------------------
+    ~Circle() override = default;
+    
     // --------------------------------------------------
-    IfcVector3 Eval(IfcFloat u) const {
+    IfcVector3 Eval(IfcFloat u) const override {
         u = -conv.angle_scale * u;
         return location + static_cast<IfcFloat>(entity.Radius)*(static_cast<IfcFloat>(std::cos(u))*p[0] +
             static_cast<IfcFloat>(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<IfcFloat>(entity.SemiAxis1)*static_cast<IfcFloat>(std::cos(u))*p[0] +
             static_cast<IfcFloat>(entity.SemiAxis2)*static_cast<IfcFloat>(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<IfcFloat>::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<IfcFloat>( 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<IfcFloat>( 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<size_t>(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<size_t>( std::ceil(b) - std::floor(a) );
     }
 
     // --------------------------------------------------
-    ParamRange GetParametricRange() const {
+    ParamRange GetParametricRange() const override {
         return std::make_pair(static_cast<IfcFloat>( 0. ),static_cast<IfcFloat>(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;
 }
 

+ 61 - 105
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 <poly2tri/poly2tri.h>
-#  include <polyclipping/clipper.hpp>
-#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 <iterator>
 #include <memory>
@@ -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<Schema_2x3::IfcPolyLoop>()) {
                 if(ProcessPolyloop(*polyloop, meshout,conv)) {
-
                     // The outer boundary is better determined by checking which
                     // polygon covers the largest area.
-
-                    //if(bound.ToPtr<IfcFaceOuterBound>()) {
-                    //  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<unsigned int>(conv.settings.cylindricalTessellation * std::fabs(max_angle)/AI_MATH_HALF_PI_F));
+    const unsigned int cnt_segments = 
+        std::max(2u,static_cast<unsigned int>(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<IfcVector3>& 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<IfcVector3> 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<Schema_2x3::IfcExtrudedAreaSolid>()) {
         ProcessExtrudedAreaSolid(*solid,meshout,conv, !!conv.collect_openings);
-    }
-    else if(const Schema_2x3::IfcRevolvedAreaSolid* const rev = swept.ToPtr<Schema_2x3::IfcRevolvedAreaSolid>()) {
+    } else if(const Schema_2x3::IfcRevolvedAreaSolid* const rev = swept.ToPtr<Schema_2x3::IfcRevolvedAreaSolid>()) {
         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<unsigned int>& mesh_indices,
-    ConversionData& conv)
-{
+bool ProcessGeometricItem(const Schema_2x3::IfcRepresentationItem& geo, 
+        unsigned int matid, 
+        std::set<unsigned int>& mesh_indices,
+        ConversionData& conv) {
     bool fix_orientation = false;
     std::shared_ptr< TempMesh > meshtmp = std::make_shared<TempMesh>();
     if(const Schema_2x3::IfcShellBasedSurfaceModel* shellmod = geo.ToPtr<Schema_2x3::IfcShellBasedSurfaceModel>()) {
@@ -788,41 +754,32 @@ bool ProcessGeometricItem(const Schema_2x3::IfcRepresentationItem& geo, unsigned
                 const Schema_2x3::IfcConnectedFaceSet& fs = conv.db.MustGetObject(e).To<Schema_2x3::IfcConnectedFaceSet>();
 
                 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<Schema_2x3::IfcConnectedFaceSet>()) {
+    } else  if(const Schema_2x3::IfcConnectedFaceSet* fset = geo.ToPtr<Schema_2x3::IfcConnectedFaceSet>()) {
         ProcessConnectedFaceSet(*fset, *meshtmp, conv);
         fix_orientation = true;
-    }
-    else  if(const Schema_2x3::IfcSweptAreaSolid* swept = geo.ToPtr<Schema_2x3::IfcSweptAreaSolid>()) {
+    } else  if(const Schema_2x3::IfcSweptAreaSolid* swept = geo.ToPtr<Schema_2x3::IfcSweptAreaSolid>()) {
         ProcessSweptAreaSolid(*swept, *meshtmp, conv);
-    }
-    else  if(const Schema_2x3::IfcSweptDiskSolid* disk = geo.ToPtr<Schema_2x3::IfcSweptDiskSolid>()) {
+    } else  if(const Schema_2x3::IfcSweptDiskSolid* disk = geo.ToPtr<Schema_2x3::IfcSweptDiskSolid>()) {
         ProcessSweptDiskSolid(*disk, *meshtmp, conv);
-    }
-    else if(const Schema_2x3::IfcManifoldSolidBrep* brep = geo.ToPtr<Schema_2x3::IfcManifoldSolidBrep>()) {
+    } else if(const Schema_2x3::IfcManifoldSolidBrep* brep = geo.ToPtr<Schema_2x3::IfcManifoldSolidBrep>()) {
         ProcessConnectedFaceSet(brep->Outer, *meshtmp, conv);
         fix_orientation = true;
-    }
-    else if(const Schema_2x3::IfcFaceBasedSurfaceModel* surf = geo.ToPtr<Schema_2x3::IfcFaceBasedSurfaceModel>()) {
+    } else if(const Schema_2x3::IfcFaceBasedSurfaceModel* surf = geo.ToPtr<Schema_2x3::IfcFaceBasedSurfaceModel>()) {
         for(const Schema_2x3::IfcConnectedFaceSet& fc : surf->FbsmFaces) {
             ProcessConnectedFaceSet(fc, *meshtmp, conv);
         }
         fix_orientation = true;
-    }
-    else  if(const Schema_2x3::IfcBooleanResult* boolean = geo.ToPtr<Schema_2x3::IfcBooleanResult>()) {
+    } else  if(const Schema_2x3::IfcBooleanResult* boolean = geo.ToPtr<Schema_2x3::IfcBooleanResult>()) {
         ProcessBoolean(*boolean, *meshtmp, conv);
-    }
-    else if(geo.ToPtr<Schema_2x3::IfcBoundingBox>()) {
+    } else if(geo.ToPtr<Schema_2x3::IfcBoundingBox>()) {
         // 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<unsigned int>& mesh_indices,aiNode* nd,
-    ConversionData& /*conv*/)
-{
+void AssignAddedMeshes(std::set<unsigned int>& mesh_indices,aiNode* nd, ConversionData& /*conv*/) {
     if (!mesh_indices.empty()) {
 		std::set<unsigned int>::const_iterator it = mesh_indices.cbegin();
 		std::set<unsigned int>::const_iterator end = mesh_indices.cend();
@@ -886,9 +841,9 @@ void AssignAddedMeshes(std::set<unsigned int>& mesh_indices,aiNode* nd,
 
 // ------------------------------------------------------------------------------------------------
 bool TryQueryMeshCache(const Schema_2x3::IfcRepresentationItem& item,
-    std::set<unsigned int>& mesh_indices, unsigned int mat_index,
-    ConversionData& conv)
-{
+        std::set<unsigned int>& 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<unsigned int>& mesh_indices, unsigned int mat_index,
-    ConversionData& conv)
-{
+        const std::set<unsigned int>& 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<unsigned int>& mesh_indices,
-    ConversionData& conv)
-{
+bool ProcessRepresentationItem(const Schema_2x3::IfcRepresentationItem& item, 
+        unsigned int matid,
+        std::set<unsigned int>& 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

+ 9 - 15
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 {
@@ -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

+ 2 - 2
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,

+ 2 - 5
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("<IFCDefault>");
-    //  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 ) {

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 160 - 260
code/AssetLib/IFC/IFCOpenings.cpp


+ 24 - 28
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<const Curve> 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<Schema_2x3::IfcRectangleProfileDef>()) {
         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<Schema_2x3::IfcCircleProfileDef>()) {
+    } else if( const Schema_2x3::IfcCircleProfileDef* const circle = def.ToPtr<Schema_2x3::IfcCircleProfileDef>()) {
         if(def.ToPtr<Schema_2x3::IfcCircleHollowProfileDef>()) {
             // TODO
         }
@@ -129,8 +131,7 @@ void ProcessParametrizedProfile(const Schema_2x3::IfcParameterizedProfileDef& de
         }
 
         meshout.mVertcnt.push_back(static_cast<unsigned int>(segments));
-    }
-    else if( const Schema_2x3::IfcIShapeProfileDef* const ishape = def.ToPtr<Schema_2x3::IfcIShapeProfileDef>()) {
+    } else if( const Schema_2x3::IfcIShapeProfileDef* const ishape = def.ToPtr<Schema_2x3::IfcIShapeProfileDef>()) {
         // 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<Schema_2x3::IfcArbitraryClosedProfileDef>()) {
         ProcessClosedProfile(*cprofile,meshout,conv);
-    }
-    else if(const Schema_2x3::IfcArbitraryOpenProfileDef* const copen = prof.ToPtr<Schema_2x3::IfcArbitraryOpenProfileDef>()) {
+    } else if(const Schema_2x3::IfcArbitraryOpenProfileDef* const copen = prof.ToPtr<Schema_2x3::IfcArbitraryOpenProfileDef>()) {
         ProcessOpenProfile(*copen,meshout,conv);
-    }
-    else if(const Schema_2x3::IfcParameterizedProfileDef* const cparam = prof.ToPtr<Schema_2x3::IfcParameterizedProfileDef>()) {
+    } else if(const Schema_2x3::IfcParameterizedProfileDef* const cparam = prof.ToPtr<Schema_2x3::IfcParameterizedProfileDef>()) {
         ProcessParametrizedProfile(*cparam,meshout,conv);
-    }
-    else {
+    } else {
         IFCImporter::LogWarn("skipping unknown IfcProfileDef entity, type is ", prof.GetClassName());
         return false;
     }

+ 77 - 149
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<IfcFloat>(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<IfcFloat>(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<IfcFloat> 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<IfcVector3>& normals,
-    bool normalize,
-    size_t ofs) const
-{
+        bool normalize,
+        size_t ofs) const {
     size_t max_vcount = 0;
     std::vector<unsigned int>::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<size_t> 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<IfcVector3, std::vector<size_t>, 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<size_t> neighbour(mVerts.size(), SIZE_MAX);
     std::vector<size_t> 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<size_t>& facesOnB = facesByVertex[mVerts[ib]];
             const std::vector<size_t>& facesOnNB = facesByVertex[mVerts[nib]];
@@ -281,10 +268,12 @@ void TempMesh::FixupFaceOrientation()
             std::vector<size_t>::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<bool> 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<IfcFloat>(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<float>( in.Red );
     out.g = static_cast<float>( in.Green );
     out.b = static_cast<float>( 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<float>(*r);
         if(base) {
@@ -528,20 +472,18 @@ void ConvertColor(aiColor4D& out, const Schema_2x3::IfcColourOrFactor& in,Conver
             out.g *= static_cast<float>( base->g );
             out.b *= static_cast<float>( base->b );
             out.a = static_cast<float>( base->a );
+        } else {
+            out.a = 1.0;
         }
-        else out.a = 1.0;
-    }
-    else if (const Schema_2x3::IfcColourRgb* const rgb = in.ResolveSelectPtr<Schema_2x3::IfcColourRgb>(conv.db)) {
+    } else if (const Schema_2x3::IfcColourRgb* const rgb = in.ResolveSelectPtr<Schema_2x3::IfcColourRgb>(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<unsigned int>(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<unsigned int>(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<Schema_2x3::IfcAxis2Placement3D>(conv.db)) {
         ConvertAxisPlacement(out,*pl3);
-    }
-    else if(const Schema_2x3::IfcAxis2Placement2D* pl2 = in.ResolveSelectPtr<Schema_2x3::IfcAxis2Placement2D>(conv.db)) {
+    } else if(const Schema_2x3::IfcAxis2Placement2D* pl2 = in.ResolveSelectPtr<Schema_2x3::IfcAxis2Placement2D>(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<Schema_2x3::IfcCartesianTransformationOperator3DnonUniform>()) {
         vscale.x = nuni->Scale?op.Scale.Get():1.f;
         vscale.y = nuni->Scale2?nuni->Scale2.Get():1.f;
         vscale.z = nuni->Scale3?nuni->Scale3.Get():1.f;
-    }
-    else {
+    } else {
         const IfcFloat sc = op.Scale?op.Scale.Get():1.f;
         vscale = IfcVector3(sc,sc,sc);
     }
@@ -695,8 +624,7 @@ void ConvertTransformOperator(IfcMatrix4& out, const Schema_2x3::IfcCartesianTra
     out = locm * out * s;
 }
 
-
 } // ! IFC
 } // ! Assimp
 
-#endif
+#endif // ASSIMP_BUILD_NO_IFC_IMPORTER

+ 12 - 12
code/CMakeLists.txt

@@ -927,22 +927,22 @@ ELSE()
 ENDIF()
 
 # polyclipping
-IF(ASSIMP_HUNTER_ENABLED)
-  hunter_add_package(polyclipping)
-  find_package(polyclipping CONFIG REQUIRED)
-ELSE()
+#IF(ASSIMP_HUNTER_ENABLED)
+#  hunter_add_package(polyclipping)
+#  find_package(polyclipping CONFIG REQUIRED)
+#ELSE()
   SET( Clipper_SRCS
     ../contrib/clipper/clipper.hpp
     ../contrib/clipper/clipper.cpp
   )
   SOURCE_GROUP( Contrib\\Clipper FILES ${Clipper_SRCS})
-ENDIF()
+#ENDIF()
 
 # poly2tri
-IF(ASSIMP_HUNTER_ENABLED)
-  hunter_add_package(poly2tri)
-  find_package(poly2tri CONFIG REQUIRED)
-ELSE()
+#IF(ASSIMP_HUNTER_ENABLED)
+#  hunter_add_package(poly2tri)
+#  find_package(poly2tri CONFIG REQUIRED)
+#ELSE()
   SET( Poly2Tri_SRCS
     ../contrib/poly2tri/poly2tri/common/shapes.cc
     ../contrib/poly2tri/poly2tri/common/shapes.h
@@ -957,7 +957,7 @@ ELSE()
     ../contrib/poly2tri/poly2tri/sweep/sweep_context.h
   )
   SOURCE_GROUP( Contrib\\Poly2Tri FILES ${Poly2Tri_SRCS})
-ENDIF()
+#ENDIF()
 
 # minizip/unzip
 IF(ASSIMP_HUNTER_ENABLED)
@@ -1267,9 +1267,9 @@ TARGET_INCLUDE_DIRECTORIES ( assimp PUBLIC
 IF(ASSIMP_HUNTER_ENABLED)
   TARGET_LINK_LIBRARIES(assimp
       PUBLIC
-      polyclipping::polyclipping
+      #polyclipping::polyclipping
       openddlparser::openddl_parser
-      poly2tri::poly2tri
+      #poly2tri::poly2tri
       minizip::minizip
       ZLIB::zlib
       RapidJSON::rapidjson

+ 1 - 6
contrib/clipper/License.txt

@@ -1,7 +1,3 @@
-The Clipper code library, the "Software" (that includes Delphi, C++ & C# 
-source code, accompanying samples and documentation), has been released 
-under the following license, terms and conditions:
-
 Boost Software License - Version 1.0 - August 17th, 2003
 http://www.boost.org/LICENSE_1_0.txt
 
@@ -25,5 +21,4 @@ FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-
+DEALINGS IN THE SOFTWARE.

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 487 - 435
contrib/clipper/clipper.cpp


+ 274 - 174
contrib/clipper/clipper.hpp

@@ -1,10 +1,10 @@
 /*******************************************************************************
 *                                                                              *
 * Author    :  Angus Johnson                                                   *
-* Version   :  4.8.8                                                           *
-* Date      :  30 August 2012                                                  *
+* Version   :  6.4.2                                                           *
+* Date      :  27 February 2017                                                *
 * Website   :  http://www.angusj.com                                           *
-* Copyright :  Angus Johnson 2010-2012                                         *
+* Copyright :  Angus Johnson 2010-2017                                         *
 *                                                                              *
 * License:                                                                     *
 * Use, modification & distribution is subject to Boost Software License Ver 1. *
@@ -34,11 +34,30 @@
 #ifndef clipper_hpp
 #define clipper_hpp
 
+#define CLIPPER_VERSION "6.4.2"
+
+//use_int32: When enabled 32bit ints are used instead of 64bit ints. This
+//improve performance but coordinate values are limited to the range +/- 46340
+//#define use_int32
+
+//use_xyz: adds a Z member to IntPoint. Adds a minor cost to perfomance.
+//#define use_xyz
+
+//use_lines: Enables line clipping. Adds a very minor cost to performance.
+#define use_lines
+  
+//use_deprecated: Enables temporary support for the obsolete functions
+//#define use_deprecated  
+
 #include <vector>
+#include <list>
+#include <set>
 #include <stdexcept>
 #include <cstring>
 #include <cstdlib>
 #include <ostream>
+#include <functional>
+#include <queue>
 
 namespace ClipperLib {
 
@@ -50,129 +69,150 @@ enum PolyType { ptSubject, ptClip };
 //see http://glprogramming.com/red/chapter11.html
 enum PolyFillType { pftEvenOdd, pftNonZero, pftPositive, pftNegative };
 
-typedef signed long long long64;
-typedef unsigned long long ulong64;
+#ifdef use_int32
+  typedef int cInt;
+  static cInt const loRange = 0x7FFF;
+  static cInt const hiRange = 0x7FFF;
+#else
+  typedef signed long long cInt;
+  static cInt const loRange = 0x3FFFFFFF;
+  static cInt const hiRange = 0x3FFFFFFFFFFFFFFFLL;
+  typedef signed long long long64;     //used by Int128 class
+  typedef unsigned long long ulong64;
+
+#endif
 
 struct IntPoint {
-public:
-  long64 X;
-  long64 Y;
-  IntPoint(long64 x = 0, long64 y = 0): X(x), Y(y) {};
-  friend std::ostream& operator <<(std::ostream &s, IntPoint &p);
+  cInt X;
+  cInt Y;
+#ifdef use_xyz
+  cInt Z;
+  IntPoint(cInt x = 0, cInt y = 0, cInt z = 0): X(x), Y(y), Z(z) {};
+#else
+  IntPoint(cInt x = 0, cInt y = 0): X(x), Y(y) {};
+#endif
+
+  friend inline bool operator== (const IntPoint& a, const IntPoint& b)
+  {
+    return a.X == b.X && a.Y == b.Y;
+  }
+  friend inline bool operator!= (const IntPoint& a, const IntPoint& b)
+  {
+    return a.X != b.X  || a.Y != b.Y; 
+  }
 };
+//------------------------------------------------------------------------------
 
-typedef std::vector< IntPoint > Polygon;
-typedef std::vector< Polygon > Polygons;
+typedef std::vector< IntPoint > Path;
+typedef std::vector< Path > Paths;
 
-std::ostream& operator <<(std::ostream &s, Polygon &p);
-std::ostream& operator <<(std::ostream &s, Polygons &p);
+inline Path& operator <<(Path& poly, const IntPoint& p) {poly.push_back(p); return poly;}
+inline Paths& operator <<(Paths& polys, const Path& p) {polys.push_back(p); return polys;}
 
-struct ExPolygon {
-  Polygon  outer;
-  Polygons holes;
-};
-typedef std::vector< ExPolygon > ExPolygons;
-
-enum JoinType { jtSquare, jtRound, jtMiter };
-
-bool Orientation(const Polygon &poly);
-double Area(const Polygon &poly);
-void OffsetPolygons(const Polygons &in_polys, Polygons &out_polys,
-  double delta, JoinType jointype = jtSquare, double MiterLimit = 2);
-void SimplifyPolygon(const Polygon &in_poly, Polygons &out_polys, PolyFillType fillType = pftEvenOdd);
-void SimplifyPolygons(const Polygons &in_polys, Polygons &out_polys, PolyFillType fillType = pftEvenOdd);
-void SimplifyPolygons(Polygons &polys, PolyFillType fillType = pftEvenOdd);
-
-void ReversePolygon(Polygon& p);
-void ReversePolygons(Polygons& p);
-
-//used internally ...
-enum EdgeSide { esNeither = 0, esLeft = 1, esRight = 2, esBoth = 3 };
-enum IntersectProtects { ipNone = 0, ipLeft = 1, ipRight = 2, ipBoth = 3 };
-
-struct TEdge {
-  long64 xbot;
-  long64 ybot;
-  long64 xcurr;
-  long64 ycurr;
-  long64 xtop;
-  long64 ytop;
-  double dx;
-  long64 tmpX;
-  PolyType polyType;
-  EdgeSide side;
-  int windDelta; //1 or -1 depending on winding direction
-  int windCnt;
-  int windCnt2; //winding count of the opposite polytype
-  int outIdx;
-  TEdge *next;
-  TEdge *prev;
-  TEdge *nextInLML;
-  TEdge *nextInAEL;
-  TEdge *prevInAEL;
-  TEdge *nextInSEL;
-  TEdge *prevInSEL;
-};
+std::ostream& operator <<(std::ostream &s, const IntPoint &p);
+std::ostream& operator <<(std::ostream &s, const Path &p);
+std::ostream& operator <<(std::ostream &s, const Paths &p);
 
-struct IntersectNode {
-  TEdge          *edge1;
-  TEdge          *edge2;
-  IntPoint        pt;
-  IntersectNode  *next;
+struct DoublePoint
+{
+  double X;
+  double Y;
+  DoublePoint(double x = 0, double y = 0) : X(x), Y(y) {}
+  DoublePoint(IntPoint ip) : X((double)ip.X), Y((double)ip.Y) {}
 };
+//------------------------------------------------------------------------------
 
-struct LocalMinima {
-  long64        Y;
-  TEdge        *leftBound;
-  TEdge        *rightBound;
-  LocalMinima  *next;
-};
+#ifdef use_xyz
+typedef void (*ZFillCallback)(IntPoint& e1bot, IntPoint& e1top, IntPoint& e2bot, IntPoint& e2top, IntPoint& pt);
+#endif
 
-struct Scanbeam {
-  long64    Y;
-  Scanbeam *next;
-};
+enum InitOptions {ioReverseSolution = 1, ioStrictlySimple = 2, ioPreserveCollinear = 4};
+enum JoinType {jtSquare, jtRound, jtMiter};
+enum EndType {etClosedPolygon, etClosedLine, etOpenButt, etOpenSquare, etOpenRound};
 
-struct OutPt; //forward declaration
-
-struct OutRec {
-  int     idx;
-  bool    isHole;
-  OutRec *FirstLeft;
-  OutRec *AppendLink;
-  OutPt  *pts;
-  OutPt  *bottomPt;
-  OutPt  *bottomFlag;
-  EdgeSide sides;
-};
+class PolyNode;
+typedef std::vector< PolyNode* > PolyNodes;
 
-struct OutPt {
-  int     idx;
-  IntPoint pt;
-  OutPt   *next;
-  OutPt   *prev;
+class PolyNode 
+{ 
+public:
+    PolyNode();
+    virtual ~PolyNode(){};
+    Path Contour;
+    PolyNodes Childs;
+    PolyNode* Parent;
+    PolyNode* GetNext() const;
+    bool IsHole() const;
+    bool IsOpen() const;
+    int ChildCount() const;
+private:
+    //PolyNode& operator =(PolyNode& other); 
+    unsigned Index; //node index in Parent.Childs
+    bool m_IsOpen;
+    JoinType m_jointype;
+    EndType m_endtype;
+    PolyNode* GetNextSiblingUp() const;
+    void AddChild(PolyNode& child);
+    friend class Clipper; //to access Index
+    friend class ClipperOffset; 
 };
 
-struct JoinRec {
-  IntPoint  pt1a;
-  IntPoint  pt1b;
-  int       poly1Idx;
-  IntPoint  pt2a;
-  IntPoint  pt2b;
-  int       poly2Idx;
+class PolyTree: public PolyNode
+{ 
+public:
+    ~PolyTree(){ Clear(); };
+    PolyNode* GetFirst() const;
+    void Clear();
+    int Total() const;
+private:
+  //PolyTree& operator =(PolyTree& other);
+  PolyNodes AllNodes;
+    friend class Clipper; //to access AllNodes
 };
 
-struct HorzJoinRec {
-  TEdge    *edge;
-  int       savedIdx;
-};
+bool Orientation(const Path &poly);
+double Area(const Path &poly);
+int PointInPolygon(const IntPoint &pt, const Path &path);
+
+void SimplifyPolygon(const Path &in_poly, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
+void SimplifyPolygons(const Paths &in_polys, Paths &out_polys, PolyFillType fillType = pftEvenOdd);
+void SimplifyPolygons(Paths &polys, PolyFillType fillType = pftEvenOdd);
+
+void CleanPolygon(const Path& in_poly, Path& out_poly, double distance = 1.415);
+void CleanPolygon(Path& poly, double distance = 1.415);
+void CleanPolygons(const Paths& in_polys, Paths& out_polys, double distance = 1.415);
+void CleanPolygons(Paths& polys, double distance = 1.415);
 
-struct IntRect { long64 left; long64 top; long64 right; long64 bottom; };
+void MinkowskiSum(const Path& pattern, const Path& path, Paths& solution, bool pathIsClosed);
+void MinkowskiSum(const Path& pattern, const Paths& paths, Paths& solution, bool pathIsClosed);
+void MinkowskiDiff(const Path& poly1, const Path& poly2, Paths& solution);
+
+void PolyTreeToPaths(const PolyTree& polytree, Paths& paths);
+void ClosedPathsFromPolyTree(const PolyTree& polytree, Paths& paths);
+void OpenPathsFromPolyTree(PolyTree& polytree, Paths& paths);
+
+void ReversePath(Path& p);
+void ReversePaths(Paths& p);
+
+struct IntRect { cInt left; cInt top; cInt right; cInt bottom; };
+
+//enums that are used internally ...
+enum EdgeSide { esLeft = 1, esRight = 2};
+
+//forward declarations (for stuff used internally) ...
+struct TEdge;
+struct IntersectNode;
+struct LocalMinimum;
+struct OutPt;
+struct OutRec;
+struct Join;
 
 typedef std::vector < OutRec* > PolyOutList;
 typedef std::vector < TEdge* > EdgeList;
-typedef std::vector < JoinRec* > JoinList;
-typedef std::vector < HorzJoinRec* > HorzJoinList;
+typedef std::vector < Join* > JoinList;
+typedef std::vector < IntersectNode* > IntersectList;
+
+//------------------------------------------------------------------------------
 
 //ClipperBase is the ancestor to the Clipper class. It should not be
 //instantiated directly. This class simply abstracts the conversion of sets of
@@ -182,110 +222,170 @@ class ClipperBase
 public:
   ClipperBase();
   virtual ~ClipperBase();
-  bool AddPolygon(const Polygon &pg, PolyType polyType);
-  bool AddPolygons( const Polygons &ppg, PolyType polyType);
+  virtual bool AddPath(const Path &pg, PolyType PolyTyp, bool Closed);
+  bool AddPaths(const Paths &ppg, PolyType PolyTyp, bool Closed);
   virtual void Clear();
   IntRect GetBounds();
+  bool PreserveCollinear() {return m_PreserveCollinear;};
+  void PreserveCollinear(bool value) {m_PreserveCollinear = value;};
 protected:
   void DisposeLocalMinimaList();
-  TEdge* AddBoundsToLML(TEdge *e);
-  void PopLocalMinima();
+  TEdge* AddBoundsToLML(TEdge *e, bool IsClosed);
   virtual void Reset();
-  void InsertLocalMinima(LocalMinima *newLm);
-  LocalMinima      *m_CurrentLM;
-  LocalMinima      *m_MinimaList;
+  TEdge* ProcessBound(TEdge* E, bool IsClockwise);
+  void InsertScanbeam(const cInt Y);
+  bool PopScanbeam(cInt &Y);
+  bool LocalMinimaPending();
+  bool PopLocalMinima(cInt Y, const LocalMinimum *&locMin);
+  OutRec* CreateOutRec();
+  void DisposeAllOutRecs();
+  void DisposeOutRec(PolyOutList::size_type index);
+  void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
+  void DeleteFromAEL(TEdge *e);
+  void UpdateEdgeIntoAEL(TEdge *&e);
+
+  typedef std::vector<LocalMinimum> MinimaList;
+  MinimaList::iterator m_CurrentLM;
+  MinimaList           m_MinimaList;
+
   bool              m_UseFullRange;
   EdgeList          m_edges;
+  bool              m_PreserveCollinear;
+  bool              m_HasOpenPaths;
+  PolyOutList       m_PolyOuts;
+  TEdge           *m_ActiveEdges;
+
+  typedef std::priority_queue<cInt> ScanbeamList;
+  ScanbeamList     m_Scanbeam;
 };
+//------------------------------------------------------------------------------
 
 class Clipper : public virtual ClipperBase
 {
 public:
-  Clipper();
-  ~Clipper();
+  Clipper(int initOptions = 0);
   bool Execute(ClipType clipType,
-  Polygons &solution,
-  PolyFillType subjFillType = pftEvenOdd,
-  PolyFillType clipFillType = pftEvenOdd);
+      Paths &solution,
+      PolyFillType fillType = pftEvenOdd);
   bool Execute(ClipType clipType,
-  ExPolygons &solution,
-  PolyFillType subjFillType = pftEvenOdd,
-  PolyFillType clipFillType = pftEvenOdd);
-  void Clear();
-  bool ReverseSolution() {return m_ReverseOutput;};
+      Paths &solution,
+      PolyFillType subjFillType,
+      PolyFillType clipFillType);
+  bool Execute(ClipType clipType,
+      PolyTree &polytree,
+      PolyFillType fillType = pftEvenOdd);
+  bool Execute(ClipType clipType,
+      PolyTree &polytree,
+      PolyFillType subjFillType,
+      PolyFillType clipFillType);
+  bool ReverseSolution() { return m_ReverseOutput; };
   void ReverseSolution(bool value) {m_ReverseOutput = value;};
+  bool StrictlySimple() {return m_StrictSimple;};
+  void StrictlySimple(bool value) {m_StrictSimple = value;};
+  //set the callback function for z value filling on intersections (otherwise Z is 0)
+#ifdef use_xyz
+  void ZFillFunction(ZFillCallback zFillFunc);
+#endif
 protected:
-  void Reset();
-  virtual bool ExecuteInternal(bool fixHoleLinkages);
+  virtual bool ExecuteInternal();
 private:
-  PolyOutList       m_PolyOuts;
-  JoinList          m_Joins;
-  HorzJoinList      m_HorizJoins;
-  ClipType          m_ClipType;
-  Scanbeam         *m_Scanbeam;
-  TEdge           *m_ActiveEdges;
+  JoinList         m_Joins;
+  JoinList         m_GhostJoins;
+  IntersectList    m_IntersectList;
+  ClipType         m_ClipType;
+  typedef std::list<cInt> MaximaList;
+  MaximaList       m_Maxima;
   TEdge           *m_SortedEdges;
-  IntersectNode    *m_IntersectNodes;
-  bool              m_ExecuteLocked;
-  PolyFillType      m_ClipFillType;
-  PolyFillType      m_SubjFillType;
-  bool              m_ReverseOutput;
-  void DisposeScanbeamList();
+  bool             m_ExecuteLocked;
+  PolyFillType     m_ClipFillType;
+  PolyFillType     m_SubjFillType;
+  bool             m_ReverseOutput;
+  bool             m_UsingPolyTree; 
+  bool             m_StrictSimple;
+#ifdef use_xyz
+  ZFillCallback   m_ZFill; //custom callback 
+#endif
   void SetWindingCount(TEdge& edge);
   bool IsEvenOddFillType(const TEdge& edge) const;
   bool IsEvenOddAltFillType(const TEdge& edge) const;
-  void InsertScanbeam(const long64 Y);
-  long64 PopScanbeam();
-  void InsertLocalMinimaIntoAEL(const long64 botY);
-  void InsertEdgeIntoAEL(TEdge *edge);
+  void InsertLocalMinimaIntoAEL(const cInt botY);
+  void InsertEdgeIntoAEL(TEdge *edge, TEdge* startEdge);
   void AddEdgeToSEL(TEdge *edge);
+  bool PopEdgeFromSEL(TEdge *&edge);
   void CopyAELToSEL();
   void DeleteFromSEL(TEdge *e);
-  void DeleteFromAEL(TEdge *e);
-  void UpdateEdgeIntoAEL(TEdge *&e);
   void SwapPositionsInSEL(TEdge *edge1, TEdge *edge2);
   bool IsContributing(const TEdge& edge) const;
-  bool IsTopHorz(const long64 XPos);
-  void SwapPositionsInAEL(TEdge *edge1, TEdge *edge2);
-  void DoMaxima(TEdge *e, long64 topY);
+  bool IsTopHorz(const cInt XPos);
+  void DoMaxima(TEdge *e);
   void ProcessHorizontals();
   void ProcessHorizontal(TEdge *horzEdge);
   void AddLocalMaxPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
-  void AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
+  OutPt* AddLocalMinPoly(TEdge *e1, TEdge *e2, const IntPoint &pt);
+  OutRec* GetOutRec(int idx);
   void AppendPolygon(TEdge *e1, TEdge *e2);
-  void DoEdge1(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
-  void DoEdge2(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
-  void DoBothEdges(TEdge *edge1, TEdge *edge2, const IntPoint &pt);
-  void IntersectEdges(TEdge *e1, TEdge *e2,
-    const IntPoint &pt, IntersectProtects protects);
-  OutRec* CreateOutRec();
-  void AddOutPt(TEdge *e, const IntPoint &pt);
-  void DisposeBottomPt(OutRec &outRec);
-  void DisposeAllPolyPts();
-  void DisposeOutRec(PolyOutList::size_type index);
-  bool ProcessIntersections(const long64 botY, const long64 topY);
-  void AddIntersectNode(TEdge *e1, TEdge *e2, const IntPoint &pt);
-  void BuildIntersectList(const long64 botY, const long64 topY);
+  void IntersectEdges(TEdge *e1, TEdge *e2, IntPoint &pt);
+  OutPt* AddOutPt(TEdge *e, const IntPoint &pt);
+  OutPt* GetLastOutPt(TEdge *e);
+  bool ProcessIntersections(const cInt topY);
+  void BuildIntersectList(const cInt topY);
   void ProcessIntersectList();
-  void ProcessEdgesAtTopOfScanbeam(const long64 topY);
-  void BuildResult(Polygons& polys);
-  void BuildResultEx(ExPolygons& polys);
-  void SetHoleState(TEdge *e, OutRec *OutRec);
+  void ProcessEdgesAtTopOfScanbeam(const cInt topY);
+  void BuildResult(Paths& polys);
+  void BuildResult2(PolyTree& polytree);
+  void SetHoleState(TEdge *e, OutRec *outrec);
   void DisposeIntersectNodes();
-  bool FixupIntersections();
-  void FixupOutPolygon(OutRec &outRec);
+  bool FixupIntersectionOrder();
+  void FixupOutPolygon(OutRec &outrec);
+  void FixupOutPolyline(OutRec &outrec);
   bool IsHole(TEdge *e);
-  void FixHoleLinkage(OutRec *outRec);
-  void CheckHoleLinkages1(OutRec *outRec1, OutRec *outRec2);
-  void CheckHoleLinkages2(OutRec *outRec1, OutRec *outRec2);
-  void AddJoin(TEdge *e1, TEdge *e2, int e1OutIdx = -1, int e2OutIdx = -1);
+  bool FindOwnerFromSplitRecs(OutRec &outRec, OutRec *&currOrfl);
+  void FixHoleLinkage(OutRec &outrec);
+  void AddJoin(OutPt *op1, OutPt *op2, const IntPoint offPt);
   void ClearJoins();
-  void AddHorzJoin(TEdge *e, int idx);
-  void ClearHorzJoins();
-  void JoinCommonEdges(bool fixHoleLinkages);
+  void ClearGhostJoins();
+  void AddGhostJoin(OutPt *op, const IntPoint offPt);
+  bool JoinPoints(Join *j, OutRec* outRec1, OutRec* outRec2);
+  void JoinCommonEdges();
+  void DoSimplePolygons();
+  void FixupFirstLefts1(OutRec* OldOutRec, OutRec* NewOutRec);
+  void FixupFirstLefts2(OutRec* InnerOutRec, OutRec* OuterOutRec);
+  void FixupFirstLefts3(OutRec* OldOutRec, OutRec* NewOutRec);
+#ifdef use_xyz
+  void SetZ(IntPoint& pt, TEdge& e1, TEdge& e2);
+#endif
 };
-
 //------------------------------------------------------------------------------
+
+class ClipperOffset 
+{
+public:
+  ClipperOffset(double miterLimit = 2.0, double roundPrecision = 0.25);
+  ~ClipperOffset();
+  void AddPath(const Path& path, JoinType joinType, EndType endType);
+  void AddPaths(const Paths& paths, JoinType joinType, EndType endType);
+  void Execute(Paths& solution, double delta);
+  void Execute(PolyTree& solution, double delta);
+  void Clear();
+  double MiterLimit;
+  double ArcTolerance;
+private:
+  Paths m_destPolys;
+  Path m_srcPoly;
+  Path m_destPoly;
+  std::vector<DoublePoint> m_normals;
+  double m_delta, m_sinA, m_sin, m_cos;
+  double m_miterLim, m_StepsPerRad;
+  IntPoint m_lowest;
+  PolyNode m_polyNodes;
+
+  void FixOrientations();
+  void DoOffset(double delta);
+  void OffsetPoint(int j, int& k, JoinType jointype);
+  void DoSquare(int j, int k);
+  void DoMiter(int j, int k, double r);
+  void DoRound(int j, int k);
+};
 //------------------------------------------------------------------------------
 
 class clipperException : public std::exception

+ 74 - 0
contrib/unzip/MiniZip64_info.txt

@@ -0,0 +1,74 @@
+MiniZip - Copyright (c) 1998-2010 - by Gilles Vollant - version 1.1 64 bits from Mathias Svensson
+
+Introduction
+---------------------
+MiniZip 1.1 is built from MiniZip 1.0 by Gilles Vollant ( http://www.winimage.com/zLibDll/minizip.html )
+
+When adding ZIP64 support into minizip it would result into risk of breaking compatibility with minizip 1.0.
+All possible work was done for compatibility.
+
+
+Background
+---------------------
+When adding ZIP64 support Mathias Svensson found that Even Rouault have added ZIP64 
+support for unzip.c into minizip for a open source project called gdal ( http://www.gdal.org/ )
+
+That was used as a starting point. And after that ZIP64 support was added to zip.c
+some refactoring and code cleanup was also done.
+
+
+Changed from MiniZip 1.0 to MiniZip 1.1
+---------------------------------------
+* Added ZIP64 support for unzip ( by Even Rouault )
+* Added ZIP64 support for zip ( by Mathias Svensson )
+* Reverted some changed that Even Rouault did.
+* Bunch of patches received from Gulles Vollant that he received for MiniZip from various users.
+* Added unzip patch for BZIP Compression method (patch create by Daniel Borca)
+* Added BZIP Compress method for zip
+* Did some refactoring and code cleanup
+
+
+Credits
+
+ Gilles Vollant    - Original MiniZip author
+ Even Rouault      - ZIP64 unzip Support
+ Daniel Borca      - BZip Compression method support in unzip
+ Mathias Svensson  - ZIP64 zip support
+ Mathias Svensson  - BZip Compression method support in zip
+
+ Resources
+
+ ZipLayout   http://result42.com/projects/ZipFileLayout
+             Command line tool for Windows that shows the layout and information of the headers in a zip archive.
+             Used when debugging and validating the creation of zip files using MiniZip64
+
+
+ ZIP App Note  http://www.pkware.com/documents/casestudies/APPNOTE.TXT
+               Zip File specification
+
+
+Notes.
+ * To be able to use BZip compression method in zip64.c or unzip64.c the BZIP2 lib is needed and HAVE_BZIP2 need to be defined.
+
+License
+----------------------------------------------------------
+   Condition of use and distribution are the same than zlib :
+
+  This software is provided 'as-is', without any express or implied
+  warranty.  In no event will the authors be held liable for any damages
+  arising from the use of this software.
+
+  Permission is granted to anyone to use this software for any purpose,
+  including commercial applications, and to alter it and redistribute it
+  freely, subject to the following restrictions:
+
+  1. The origin of this software must not be misrepresented; you must not
+     claim that you wrote the original software. If you use this software
+     in a product, an acknowledgment in the product documentation would be
+     appreciated but is not required.
+  2. Altered source versions must be plainly marked as such, and must not be
+     misrepresented as being the original software.
+  3. This notice may not be removed or altered from any source distribution.
+
+----------------------------------------------------------
+

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels