Proper scope around goto labels

This commit is contained in:
Thomas Krijnen
2018-05-13 15:30:20 +02:00
parent 1ef813bf51
commit f23ffa856c
+31 -28
View File
@@ -156,7 +156,6 @@ namespace {
gp_Pnt p2 = BRep_Tool::Pnt(w21); gp_Pnt p2 = BRep_Tool::Pnt(w21);
double dist = p1.Distance(p2); double dist = p1.Distance(p2);
TopTools_IndexedDataMapOfShapeListOfShape wmap1, wmap2;
// Distance is within 2p, this is fine // Distance is within 2p, this is fine
if (dist < 2. * p_) { if (dist < 2. * p_) {
@@ -172,40 +171,44 @@ namespace {
goto check; goto check;
} }
// Find edges connected to end- and begin vertex {
TopExp::MapShapesAndAncestors(w1, TopAbs_VERTEX, TopAbs_EDGE, wmap1); TopTools_IndexedDataMapOfShapeListOfShape wmap1, wmap2;
TopExp::MapShapesAndAncestors(w2, TopAbs_VERTEX, TopAbs_EDGE, wmap2);
const TopTools_ListOfShape& last_edges = wmap1.FindFromKey(w12); // Find edges connected to end- and begin vertex
const TopTools_ListOfShape& first_edges = wmap2.FindFromKey(w21); TopExp::MapShapesAndAncestors(w1, TopAbs_VERTEX, TopAbs_EDGE, wmap1);
TopExp::MapShapesAndAncestors(w2, TopAbs_VERTEX, TopAbs_EDGE, wmap2);
double _, __; const TopTools_ListOfShape& last_edges = wmap1.FindFromKey(w12);
if (last_edges.Extent() == 1 && first_edges.Extent() == 1) { const TopTools_ListOfShape& first_edges = wmap2.FindFromKey(w21);
Handle(Geom_Curve) c1 = BRep_Tool::Curve(TopoDS::Edge(last_edges.First()), _, __);
Handle(Geom_Curve) c2 = BRep_Tool::Curve(TopoDS::Edge(first_edges.First()), _, __);
const bool is_line1 = c1->DynamicType() == STANDARD_TYPE(Geom_Line); double _, __;
const bool is_line2 = c2->DynamicType() == STANDARD_TYPE(Geom_Line); if (last_edges.Extent() == 1 && first_edges.Extent() == 1) {
Handle(Geom_Curve) c1 = BRep_Tool::Curve(TopoDS::Edge(last_edges.First()), _, __);
Handle(Geom_Curve) c2 = BRep_Tool::Curve(TopoDS::Edge(first_edges.First()), _, __);
// Adjust the segment that is linear const bool is_line1 = c1->DynamicType() == STANDARD_TYPE(Geom_Line);
if (is_line1) { const bool is_line2 = c2->DynamicType() == STANDARD_TYPE(Geom_Line);
mw_.Add(adjust(w1, TopoDS::Edge(last_edges.First()), w12, p2));
Logger::Message(Logger::LOG_ERROR, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_->entity); // Adjust the segment that is linear
} else if (is_line2 && !last) { if (is_line1) {
// tfk: not ideal, begin point of first edge cannot be adjusted now for cyclic wires mw_.Add(adjust(w1, TopoDS::Edge(last_edges.First()), w12, p2));
mw_.Add(w1); Logger::Message(Logger::LOG_ERROR, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_->entity);
mw_.Add(adjust(w1, TopoDS::Edge(last_edges.First()), w12, p2)); } else if (is_line2 && !last) {
skip_next_ = true; // tfk: not ideal, begin point of first edge cannot be adjusted now for cyclic wires
Logger::Message(Logger::LOG_ERROR, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_->entity); mw_.Add(w1);
mw_.Add(adjust(w1, TopoDS::Edge(last_edges.First()), w12, p2));
skip_next_ = true;
Logger::Message(Logger::LOG_ERROR, "Adjusted edge end-point with distance " + boost::lexical_cast<std::string>(dist) + " on:", inst_->entity);
} else {
// If both aren't linear an edge is added
mw_.Add(w1);
mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2));
Logger::Message(Logger::LOG_ERROR, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_->entity);
}
} else { } else {
// If both aren't linear an edge is added Logger::Error("Internal error, inconsistent wire segments", inst_->entity);
mw_.Add(w1); mw_.Add(w1);
mw_.Add(BRepBuilderAPI_MakeEdge(p1, p2));
Logger::Message(Logger::LOG_ERROR, "Added additional segment to close gap with length " + boost::lexical_cast<std::string>(dist) + " to:", inst_->entity);
} }
} else {
Logger::Error("Internal error, inconsistent wire segments", inst_->entity);
mw_.Add(w1);
} }
check: check: