@@ -323,13 +323,14 @@ namespace webifc::geometry
323323 flipWinding = true ;
324324 }
325325
326- double d = EXTRUSION_DISTANCE_HALFSPACE_M / _geometryLoader. GetLinearScalingFactor () ;
326+ double d = 1 ;
327327
328328 IfcProfile profile;
329329 profile.isConvex = false ;
330330 profile.curve = GetRectangleCurve (d, d, glm::dmat3 (1 ));
331331
332332 auto geom = Extrude (profile, extrusionNormal, d, _errorHandler);
333+ geom.halfSpace = true ;
333334
334335 // @Refactor: duplicate of extrudedareasolid
335336 if (flipWinding)
@@ -785,17 +786,15 @@ namespace webifc::geometry
785786 glm::dvec4 (1 , 0 , 0 , 0 ),
786787 glm::dvec4 (0 , 1 , 0 , 0 ),
787788 glm::dvec4 (0 , 0 , 1 , 0 ),
788- glm::dvec4 (0 , 0 , 0 , 1 )
789- );
789+ glm::dvec4 (0 , 0 , 0 , 1 ));
790790 if (profilePlacementID)
791791 {
792792 auto trans2d = _geometryLoader.GetAxis2Placement2D (profilePlacementID);
793793 profileTransform = glm::dmat4 (
794794 glm::dvec4 (trans2d[0 ][0 ], trans2d[0 ][1 ], 0 , 0 ),
795795 glm::dvec4 (trans2d[1 ][0 ], trans2d[1 ][1 ], 0 , 0 ),
796796 glm::dvec4 (0 , 0 , 1 , 0 ),
797- glm::dvec4 (trans2d[2 ][0 ], trans2d[2 ][1 ], 0 , 1 )
798- );
797+ glm::dvec4 (trans2d[2 ][0 ], trans2d[2 ][1 ], 0 , 1 ));
799798 }
800799
801800 glm::dvec3 dir = _geometryLoader.GetCartesianPoint3D (directionID);
@@ -807,13 +806,13 @@ namespace webifc::geometry
807806 glm::dvec4 (dx * radius, 0 ),
808807 glm::dvec4 (dy * radius, 0 ),
809808 glm::dvec4 (0 , 0 , 1 , 0 ),
810- glm::dvec4 (0 , 0 , 0 , 1 ));
811-
809+ glm::dvec4 (0 , 0 , 0 , 1 ));
810+
812811 glm::dmat4 extrusionScale = glm::dmat4 (
813812 glm::dvec4 (1 , 0 , 0 , 0 ),
814813 glm::dvec4 (0 , 1 , 0 , 0 ),
815814 glm::dvec4 (dz * depth, 0 ),
816- glm::dvec4 (0 , 0 , 0 , 1 ));
815+ glm::dvec4 (0 , 0 , 0 , 1 ));
817816
818817 profileTransform *= profileScale;
819818 extrusionScale *= profileTransform;
@@ -842,17 +841,15 @@ namespace webifc::geometry
842841 glm::dvec4 (1 , 0 , 0 , 0 ),
843842 glm::dvec4 (0 , 1 , 0 , 0 ),
844843 glm::dvec4 (0 , 0 , 1 , 0 ),
845- glm::dvec4 (0 , 0 , 0 , 1 )
846- );
844+ glm::dvec4 (0 , 0 , 0 , 1 ));
847845 if (profilePlacementID)
848846 {
849847 auto trans2d = _geometryLoader.GetAxis2Placement2D (profilePlacementID);
850848 profileTransform = glm::dmat4 (
851849 glm::dvec4 (trans2d[0 ][0 ], trans2d[0 ][1 ], 0 , 0 ),
852850 glm::dvec4 (trans2d[1 ][0 ], trans2d[1 ][1 ], 0 , 0 ),
853851 glm::dvec4 (0 , 0 , 1 , 0 ),
854- glm::dvec4 (trans2d[2 ][0 ], trans2d[2 ][1 ], 0 , 1 )
855- );
852+ glm::dvec4 (trans2d[2 ][0 ], trans2d[2 ][1 ], 0 , 1 ));
856853 }
857854
858855 glm::dvec3 dir = _geometryLoader.GetCartesianPoint3D (directionID);
@@ -867,13 +864,13 @@ namespace webifc::geometry
867864 glm::dvec4 (dx * dimx, 0 ),
868865 glm::dvec4 (dy * dimy, 0 ),
869866 glm::dvec4 (0 , 0 , 1 , 0 ),
870- glm::dvec4 (0 , 0 , 0 , 1 ));
871-
867+ glm::dvec4 (0 , 0 , 0 , 1 ));
868+
872869 glm::dmat4 extrusionScale = glm::dmat4 (
873870 glm::dvec4 (1 , 0 , 0 , 0 ),
874871 glm::dvec4 (0 , 1 , 0 , 0 ),
875872 glm::dvec4 (dz * depth, 0 ),
876- glm::dvec4 (0 , 0 , 0 , 1 ));
873+ glm::dvec4 (0 , 0 , 0 , 1 ));
877874
878875 profileTransform *= profileScale;
879876 extrusionScale *= profileTransform;
@@ -915,10 +912,10 @@ namespace webifc::geometry
915912 double dirDot = glm::dot (dir, glm::dvec3 (0 , 0 , 1 ));
916913 bool flipWinding = dirDot < 0 ; // can't be perp according to spec
917914
918- // TODO: correct dump in case of compositeProfile
919- #ifdef CSG_DEBUG_OUTPUT
920- io::DumpSVGCurve (profile.curve .points , " IFCEXTRUDEDAREASOLID_curve.html" );
921- #endif
915+ // TODO: correct dump in case of compositeProfile
916+ #ifdef CSG_DEBUG_OUTPUT
917+ io::DumpSVGCurve (profile.curve .points , " IFCEXTRUDEDAREASOLID_curve.html" );
918+ #endif
922919
923920 IfcGeometry geom;
924921
@@ -955,10 +952,10 @@ namespace webifc::geometry
955952 }
956953 }
957954
958- // TODO: correct dump in case of compositeProfile
959- #ifdef CSG_DEBUG_OUTPUT
960- io::DumpIfcGeometry (geom, " IFCEXTRUDEDAREASOLID_geom.obj" );
961- #endif
955+ // TODO: correct dump in case of compositeProfile
956+ #ifdef CSG_DEBUG_OUTPUT
957+ io::DumpIfcGeometry (geom, " IFCEXTRUDEDAREASOLID_geom.obj" );
958+ #endif
962959
963960 _expressIDToGeometry[line.expressID ] = geom;
964961 mesh.expressID = line.expressID ;
@@ -1540,7 +1537,44 @@ namespace webifc::geometry
15401537
15411538 if (doit)
15421539 {
1543- result = fuzzybools::Subtract (result, secondGeom);
1540+ if (secondGeom.halfSpace )
1541+ {
1542+ glm::dvec3 origin = secondGeom.halfSpaceOrigin ;
1543+ glm::dvec3 x = secondGeom.halfSpaceX - origin;
1544+ glm::dvec3 y = secondGeom.halfSpaceY - origin;
1545+ glm::dvec3 z = secondGeom.halfSpaceZ - origin;
1546+ glm::dmat4 trans = glm::dmat4 (
1547+ glm::dvec4 (x, 0 ),
1548+ glm::dvec4 (y, 0 ),
1549+ glm::dvec4 (z, 0 ),
1550+ glm::dvec4 (0 , 0 , 0 , 1 )
1551+ );
1552+ IfcGeometry newSecond;
1553+
1554+ double scaleX = 1 ;
1555+ double scaleY = 1 ;
1556+ double scaleZ = 1 ;
1557+
1558+ for (uint32_t i = 0 ; i < result.numPoints ; i++)
1559+ {
1560+ glm::dvec3 p = result.GetPoint (i);
1561+ glm::dvec3 vec = (p - origin);
1562+ double dx = glm::dot (vec, x);
1563+ double dy = glm::dot (vec, y);
1564+ double dz = glm::dot (vec, z);
1565+ if (glm::abs (dx) > scaleX) {scaleX = glm::abs (dx); }
1566+ if (glm::abs (dy) > scaleY) {scaleY = glm::abs (dy); }
1567+ if (glm::abs (dz) > scaleZ) {scaleZ = glm::abs (dz); }
1568+ }
1569+ newSecond.AddGeometry (secondGeom, trans, scaleX * 2 , scaleY * 2 , scaleZ * 2 , secondGeom.halfSpaceOrigin );
1570+ IfcGeometry newFirst;
1571+ newFirst.AddGeometry (result);
1572+ result = fuzzybools::Subtract (result, newSecond);
1573+ }
1574+ else
1575+ {
1576+ result = fuzzybools::Subtract (result, secondGeom);
1577+ }
15441578 }
15451579 }
15461580 finalResult.AddGeometry (result);
0 commit comments