mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-31 00:46:36 +00:00
- Fix a regression due to too high tolerance in Polyline -Loop creation.
- Make tolerances slightly more explicit, ideally these should obviously be configurable at runtime.
This commit is contained in:
@@ -42,6 +42,14 @@
|
|||||||
|
|
||||||
#include "../ifcgeom/IfcShapeList.h"
|
#include "../ifcgeom/IfcShapeList.h"
|
||||||
|
|
||||||
|
// Tolerances for various geometrical operations:
|
||||||
|
// Specifies the deflection of the mesher
|
||||||
|
#define DEFLECTION_TOLERANCE 0.001
|
||||||
|
// Specifies the tolerance of the wire builder, most notably for trimmed curves
|
||||||
|
#define WIRE_CREATION_TOLERANCE 0.0001
|
||||||
|
// Specifies the treshold distance under which cartesian points are deemed equal
|
||||||
|
#define POINT_EQUALITY_TOLERANCE 0.000001
|
||||||
|
|
||||||
#define FACESET_AS_COMPOUND 1
|
#define FACESET_AS_COMPOUND 1
|
||||||
|
|
||||||
namespace IfcGeom {
|
namespace IfcGeom {
|
||||||
|
|||||||
@@ -278,8 +278,8 @@ bool IfcGeom::is_convex(const TopoDS_Wire& wire) {
|
|||||||
edge_points.push_back(P2);
|
edge_points.push_back(P2);
|
||||||
}
|
}
|
||||||
if ( edge_points.size() != 2 ) continue;
|
if ( edge_points.size() != 2 ) continue;
|
||||||
if ( edge_points[0].IsEqual(P1,0.0001)) neighbors.push_back(edge_points[1]);
|
if ( edge_points[0].IsEqual(P1,POINT_EQUALITY_TOLERANCE)) neighbors.push_back(edge_points[1]);
|
||||||
else if ( edge_points[1].IsEqual(P1,0.0001)) neighbors.push_back(edge_points[0]);
|
else if ( edge_points[1].IsEqual(P1,POINT_EQUALITY_TOLERANCE)) neighbors.push_back(edge_points[0]);
|
||||||
}
|
}
|
||||||
// There should be two of these
|
// There should be two of these
|
||||||
if ( neighbors.size() != 2 ) return false;
|
if ( neighbors.size() != 2 ) return false;
|
||||||
@@ -288,10 +288,10 @@ bool IfcGeom::is_convex(const TopoDS_Wire& wire) {
|
|||||||
for ( TopExp_Explorer exp2(wire,TopAbs_VERTEX); exp2.More(); exp2.Next() ) {
|
for ( TopExp_Explorer exp2(wire,TopAbs_VERTEX); exp2.More(); exp2.Next() ) {
|
||||||
TopoDS_Vertex V2 = TopoDS::Vertex(exp2.Current());
|
TopoDS_Vertex V2 = TopoDS::Vertex(exp2.Current());
|
||||||
gp_Pnt P2 = BRep_Tool::Pnt(V2);
|
gp_Pnt P2 = BRep_Tool::Pnt(V2);
|
||||||
if ( P1.IsEqual(P2,0.0001) ) continue;
|
if ( P1.IsEqual(P2,POINT_EQUALITY_TOLERANCE) ) continue;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for( std::vector<gp_Pnt>::const_iterator it = neighbors.begin(); it != neighbors.end(); ++ it ) {
|
for( std::vector<gp_Pnt>::const_iterator it = neighbors.begin(); it != neighbors.end(); ++ it ) {
|
||||||
if ( (*it).IsEqual(P2,0.0001) ) { found = true; break; }
|
if ( (*it).IsEqual(P2,POINT_EQUALITY_TOLERANCE) ) { found = true; break; }
|
||||||
}
|
}
|
||||||
if ( ! found ) non_neighbors.push_back(P2);
|
if ( ! found ) non_neighbors.push_back(P2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ IfcGeomObjects::IfcMesh::IfcMesh(int i, const IfcGeom::ShapeList& shapes) {
|
|||||||
// Triangulate the shape
|
// Triangulate the shape
|
||||||
try {
|
try {
|
||||||
//BRepTools::Clean(s);
|
//BRepTools::Clean(s);
|
||||||
BRepMesh::Mesh(s,0.001f);
|
BRepMesh::Mesh(s,DEFLECTION_TOLERANCE);
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
Ifc::LogMessage("Error","Failed to triangulate mesh:",Ifc::EntityById(i)->entity);
|
Ifc::LogMessage("Error","Failed to triangulate mesh:",Ifc::EntityById(i)->entity);
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ bool IfcGeom::convert(const Ifc2x3::IfcCompositeCurve::ptr l, TopoDS_Wire& wire)
|
|||||||
}
|
}
|
||||||
if ( ! (*it)->SameSense() ) wire2.Reverse();
|
if ( ! (*it)->SameSense() ) wire2.Reverse();
|
||||||
ShapeFix_ShapeTolerance FTol;
|
ShapeFix_ShapeTolerance FTol;
|
||||||
FTol.SetTolerance(wire2, 0.0001, TopAbs_WIRE);
|
FTol.SetTolerance(wire2, WIRE_CREATION_TOLERANCE, TopAbs_WIRE);
|
||||||
/*if ( it != segments->begin() ) {
|
/*if ( it != segments->begin() ) {
|
||||||
TopExp_Explorer exp (wire2,TopAbs_VERTEX);
|
TopExp_Explorer exp (wire2,TopAbs_VERTEX);
|
||||||
const TopoDS_Vertex& first_vertex = TopoDS::Vertex(exp.Current());
|
const TopoDS_Vertex& first_vertex = TopoDS::Vertex(exp.Current());
|
||||||
@@ -201,7 +201,7 @@ bool IfcGeom::convert(const Ifc2x3::IfcPolyline::ptr l, TopoDS_Wire& result) {
|
|||||||
gp_Pnt P1;gp_Pnt P2;
|
gp_Pnt P1;gp_Pnt P2;
|
||||||
for( Ifc2x3::IfcCartesianPoint::it it = points->begin(); it != points->end(); ++ it ) {
|
for( Ifc2x3::IfcCartesianPoint::it it = points->begin(); it != points->end(); ++ it ) {
|
||||||
IfcGeom::convert(*it,P2);
|
IfcGeom::convert(*it,P2);
|
||||||
if ( it != points->begin() && ( !P1.IsEqual(P2,0.0001) ) )
|
if ( it != points->begin() && ( !P1.IsEqual(P2,POINT_EQUALITY_TOLERANCE) ) )
|
||||||
w.Add(BRepBuilderAPI_MakeEdge(P1,P2));
|
w.Add(BRepBuilderAPI_MakeEdge(P1,P2));
|
||||||
P1 = P2;
|
P1 = P2;
|
||||||
}
|
}
|
||||||
@@ -217,13 +217,13 @@ bool IfcGeom::convert(const Ifc2x3::IfcPolyLoop::ptr l, TopoDS_Wire& result) {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for( Ifc2x3::IfcCartesianPoint::it it = points->begin(); it != points->end(); ++ it ) {
|
for( Ifc2x3::IfcCartesianPoint::it it = points->begin(); it != points->end(); ++ it ) {
|
||||||
IfcGeom::convert(*it,P2);
|
IfcGeom::convert(*it,P2);
|
||||||
if ( it != points->begin() && ( !P1.IsEqual(P2,0.0001) ) ) {
|
if ( it != points->begin() && ( !P1.IsEqual(P2,POINT_EQUALITY_TOLERANCE) ) ) {
|
||||||
w.Add(BRepBuilderAPI_MakeEdge(P1,P2));
|
w.Add(BRepBuilderAPI_MakeEdge(P1,P2));
|
||||||
count ++;
|
count ++;
|
||||||
} else if ( ! count ) F = P2;
|
} else if ( ! count ) F = P2;
|
||||||
P1 = P2;
|
P1 = P2;
|
||||||
}
|
}
|
||||||
if ( !P1.IsEqual(F,0.0001) ) {
|
if ( !P1.IsEqual(F,POINT_EQUALITY_TOLERANCE) ) {
|
||||||
w.Add(BRepBuilderAPI_MakeEdge(P1,F));
|
w.Add(BRepBuilderAPI_MakeEdge(P1,F));
|
||||||
count ++;
|
count ++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user