mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
Improve composite curve error message
This commit is contained in:
@@ -164,20 +164,29 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire
|
|||||||
|
|
||||||
return use_radians || use_degrees;
|
return use_radians || use_degrees;
|
||||||
}
|
}
|
||||||
IfcSchema::IfcCompositeCurveSegment::list::ptr segments = l->Segments();
|
|
||||||
BRepBuilderAPI_MakeWire w;
|
BRepBuilderAPI_MakeWire w;
|
||||||
//TopoDS_Vertex last_vertex;
|
TopoDS_Vertex v1, v2, last;
|
||||||
|
IfcSchema::IfcCompositeCurveSegment::list::ptr segments = l->Segments();
|
||||||
|
|
||||||
for( IfcSchema::IfcCompositeCurveSegment::list::it it = segments->begin(); it != segments->end(); ++ it ) {
|
for( IfcSchema::IfcCompositeCurveSegment::list::it it = segments->begin(); it != segments->end(); ++ it ) {
|
||||||
|
|
||||||
IfcSchema::IfcCurve* curve = (*it)->ParentCurve();
|
IfcSchema::IfcCurve* curve = (*it)->ParentCurve();
|
||||||
TopoDS_Wire wire2;
|
TopoDS_Wire wire2;
|
||||||
if ( !convert_wire(curve,wire2) ) {
|
|
||||||
Logger::Message(Logger::LOG_ERROR,"Failed to convert curve:",curve->entity);
|
if ( !convert_wire(curve, wire2) ) {
|
||||||
|
Logger::Message(Logger::LOG_ERROR, "Failed to convert curve:", curve->entity);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! (*it)->SameSense() ) wire2.Reverse();
|
if ( ! (*it)->SameSense() ) wire2.Reverse();
|
||||||
|
|
||||||
ShapeFix_ShapeTolerance FTol;
|
ShapeFix_ShapeTolerance FTol;
|
||||||
FTol.SetTolerance(wire2, getValue(GV_WIRE_CREATION_TOLERANCE), TopAbs_WIRE);
|
FTol.SetTolerance(wire2, getValue(GV_PRECISION), TopAbs_WIRE);
|
||||||
/*if ( it != segments->begin() ) {
|
|
||||||
|
/*
|
||||||
|
// Create a line segment between distant vertices?
|
||||||
|
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());
|
||||||
gp_Pnt first = BRep_Tool::Pnt(first_vertex);
|
gp_Pnt first = BRep_Tool::Pnt(first_vertex);
|
||||||
@@ -186,32 +195,58 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeCurve* l, TopoDS_Wire
|
|||||||
if ( distance > ALMOST_ZERO ) {
|
if ( distance > ALMOST_ZERO ) {
|
||||||
w.Add( BRepBuilderAPI_MakeEdge( last_vertex, first_vertex ) );
|
w.Add( BRepBuilderAPI_MakeEdge( last_vertex, first_vertex ) );
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
TopExp::Vertices(wire2, v1, v2);
|
||||||
|
|
||||||
w.Add(wire2);
|
w.Add(wire2);
|
||||||
//last_vertex = w.Vertex();
|
|
||||||
if ( w.Error() != BRepBuilderAPI_WireDone ) {
|
if ( w.Error() != BRepBuilderAPI_WireDone ) {
|
||||||
Logger::Message(Logger::LOG_ERROR,"Failed to join curve segments:",l->entity);
|
if (w.Error() == BRepBuilderAPI_NonManifoldWire) {
|
||||||
|
|
||||||
TopoDS_Vertex v1, v2, last;
|
Logger::Message(Logger::LOG_ERROR, "Non-manifold curve segments:", l->entity);
|
||||||
last = w.Vertex();
|
|
||||||
|
} else if (w.Error() == BRepBuilderAPI_DisconnectedWire) {
|
||||||
|
|
||||||
|
Logger::Message(Logger::LOG_ERROR, "Failed to join curve segments:", l->entity);
|
||||||
|
|
||||||
|
gp_Pnt p1, p2;
|
||||||
|
int precision = 4;
|
||||||
|
double d = 0.;
|
||||||
|
|
||||||
if (!last.IsNull()) {
|
if (!last.IsNull()) {
|
||||||
std::stringstream ss;
|
p1 = BRep_Tool::Pnt(last);
|
||||||
gp_Pnt p = BRep_Tool::Pnt(last);
|
}
|
||||||
ss << std::setprecision(4) << "Last vertex at (" << p.X() << " " << p.Y() << " " << p.Z() << ")";
|
if (!v1.IsNull()) {
|
||||||
Logger::Message(Logger::LOG_NOTICE, ss.str());
|
p2 = BRep_Tool::Pnt(v1);
|
||||||
}
|
}
|
||||||
|
if (!last.IsNull() && !v1.IsNull()) {
|
||||||
|
d = p1.Distance(p2);
|
||||||
|
precision = ceil(-log10(d)) + 3;
|
||||||
|
}
|
||||||
|
|
||||||
TopExp::Vertices(wire2, v1, v2);
|
if (!last.IsNull()) {
|
||||||
if (!v1.IsNull()) {
|
std::stringstream ss;
|
||||||
std::stringstream ss;
|
ss << std::setprecision(precision) << "Last vertex at (" << p1.X() << " " << p1.Y() << " " << p1.Z() << ")";
|
||||||
gp_Pnt p = BRep_Tool::Pnt(v1);
|
Logger::Message(Logger::LOG_NOTICE, ss.str());
|
||||||
ss << std::setprecision(4) << "Segment starts at (" << p.X() << " " << p.Y() << " " << p.Z() << ") for:";
|
}
|
||||||
Logger::Message(Logger::LOG_NOTICE, ss.str(), (*it)->entity);
|
|
||||||
|
if (!v1.IsNull()) {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << std::setprecision(precision) << "Segment starts at (" << p2.X() << " " << p2.Y() << " " << p2.Z() << ")";
|
||||||
|
if (d > 0.) {
|
||||||
|
ss << ", distance " << d << " > precision " << std::fixed << getValue(GV_PRECISION) / 10.;
|
||||||
|
}
|
||||||
|
ss << " for:";
|
||||||
|
Logger::Message(Logger::LOG_NOTICE, ss.str(), (*it)->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last = v2;
|
||||||
}
|
}
|
||||||
wire = w.Wire();
|
wire = w.Wire();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user