|
@@ -66,12 +66,12 @@ 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) < 1e-6)
|
|
|
+ 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) < 1e-6) {
|
|
|
- if ((assumeStartOnWhiteSide && dotOne + dotTwo < 1e-6) || (!assumeStartOnWhiteSide && dotOne + dotTwo > -1e-6)) {
|
|
|
+ if (std::abs(dotTwo) < ai_epsilon) {
|
|
|
+ if ((assumeStartOnWhiteSide && dotOne + dotTwo < ai_epsilon) || (!assumeStartOnWhiteSide && dotOne + dotTwo > -ai_epsilon)) {
|
|
|
out = e0;
|
|
|
return true;
|
|
|
} else {
|
|
@@ -81,7 +81,7 @@ 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) < 1e-6)
|
|
|
+ if (std::abs(dotOne) < ai_epsilon)
|
|
|
return false;
|
|
|
|
|
|
// t must be in [0..1] if the intersection point is within the given segment
|
|
@@ -163,7 +163,7 @@ void ProcessBooleanHalfSpaceDifference(const Schema_2x3::IfcHalfSpaceSolid *hs,
|
|
|
for (iit = begin; iit != end; vidx += *iit++) {
|
|
|
|
|
|
unsigned int newcount = 0;
|
|
|
- bool isAtWhiteSide = (in[vidx] - p) * n > -1e-6;
|
|
|
+ bool isAtWhiteSide = (in[vidx] - p) * n > -ai_epsilon;
|
|
|
for (unsigned int i = 0; i < *iit; ++i) {
|
|
|
const IfcVector3 &e0 = in[vidx + i], e1 = in[vidx + (i + 1) % *iit];
|
|
|
|
|
@@ -259,7 +259,7 @@ bool IntersectsBoundaryProfile(const IfcVector3 &e0, const IfcVector3 &e1, const
|
|
|
// segment-segment intersection
|
|
|
// solve b0 + b*s = e0 + e*t for (s,t)
|
|
|
const IfcFloat det = (-b.x * e.y + e.x * b.y);
|
|
|
- if (std::abs(det) < 1e-6) {
|
|
|
+ if (std::abs(det) < ai_epsilon) {
|
|
|
// no solutions (parallel lines)
|
|
|
continue;
|
|
|
}
|
|
@@ -316,7 +316,7 @@ bool IntersectsBoundaryProfile(const IfcVector3 &e0, const IfcVector3 &e1, const
|
|
|
|
|
|
// for a valid intersection, s and t should be in range [0,1]. Including a bit of epsilon on s, potential double
|
|
|
// hits on two consecutive boundary segments are filtered
|
|
|
- if (s >= -1e-6 * b_sqlen_inv && s <= 1.0 + 1e-6 * b_sqlen_inv && t >= 0.0 && (t <= 1.0 || halfOpen)) {
|
|
|
+ if (s >= -ai_epsilon * b_sqlen_inv && s <= 1.0 + ai_epsilon * b_sqlen_inv && t >= 0.0 && (t <= 1.0 || halfOpen)) {
|
|
|
// 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) {
|
|
@@ -431,14 +431,14 @@ void ProcessPolygonalBoundedBooleanHalfSpaceDifference(const Schema_2x3::IfcPoly
|
|
|
|
|
|
// if the poly is parallel to the plane, put it completely on the black or white side
|
|
|
if (std::abs(polyNormal * n) > 0.9999) {
|
|
|
- bool isOnWhiteSide = (srcVertices[0] - p) * n > -1e-6;
|
|
|
+ bool isOnWhiteSide = (srcVertices[0] - p) * n > -ai_epsilon;
|
|
|
std::vector<IfcVector3> &targetSide = isOnWhiteSide ? whiteside : blackside;
|
|
|
targetSide.insert(targetSide.end(), srcVertices, srcVertices + srcVtxCount);
|
|
|
} else {
|
|
|
// otherwise start building one polygon for each side. Whenever the current line segment intersects the plane
|
|
|
// we put a point there as an end of the current segment. Then we switch to the other side, put a point there, too,
|
|
|
// as a beginning of the current segment, and simply continue accumulating vertices.
|
|
|
- bool isCurrentlyOnWhiteSide = ((srcVertices[0]) - p) * n > -1e-6;
|
|
|
+ bool isCurrentlyOnWhiteSide = ((srcVertices[0]) - p) * n > -ai_epsilon;
|
|
|
for (size_t a = 0; a < srcVtxCount; ++a) {
|
|
|
IfcVector3 e0 = srcVertices[a];
|
|
|
IfcVector3 e1 = srcVertices[(a + 1) % srcVtxCount];
|