process IfcIndexedPolyCurve without segments #549

This commit is contained in:
hlg
2019-02-14 03:05:38 +08:00
committed by Thomas Krijnen
parent 5db91e52da
commit acde878946
+41 -33
View File
@@ -873,44 +873,52 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcIndexedPolyCurve* l, TopoDS_Wi
BRepBuilderAPI_MakeWire w; BRepBuilderAPI_MakeWire w;
IfcEntityList::ptr segments = l->Segments(); if(l->hasSegments()) {
for (IfcEntityList::it it = segments->begin(); it != segments->end(); ++it) { IfcEntityList::ptr segments = l->Segments();
IfcUtil::IfcBaseClass* segment = *it; for (IfcEntityList::it it = segments->begin(); it != segments->end(); ++it) {
if (segment->is(IfcSchema::Type::IfcLineIndex)) { IfcUtil::IfcBaseClass* segment = *it;
IfcSchema::IfcLineIndex* line = (IfcSchema::IfcLineIndex*) segment; if (segment->is(IfcSchema::Type::IfcLineIndex)) {
std::vector<int> indices = *line; IfcSchema::IfcLineIndex* line = (IfcSchema::IfcLineIndex*) segment;
gp_Pnt previous; std::vector<int> indices = *line;
for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) { gp_Pnt previous;
if (*jt < 1 || *jt > max_index) { for (std::vector<int>::const_iterator jt = indices.begin(); jt != indices.end(); ++jt) {
throw IfcParse::IfcException("IfcIndexedPolyCurve index out of bounds for index " + boost::lexical_cast<std::string>(*jt)); if (*jt < 1 || *jt > max_index) {
throw IfcParse::IfcException("IfcIndexedPolyCurve index out of bounds for index " + boost::lexical_cast<std::string>(*jt));
}
const gp_Pnt& current = points[*jt - 1];
if (jt != indices.begin()) {
w.Add(BRepBuilderAPI_MakeEdge(previous, current));
}
previous = current;
} }
const gp_Pnt& current = points[*jt - 1]; } else if (segment->is(IfcSchema::Type::IfcArcIndex)) {
if (jt != indices.begin()) { IfcSchema::IfcArcIndex* arc = (IfcSchema::IfcArcIndex*) segment;
w.Add(BRepBuilderAPI_MakeEdge(previous, current)); std::vector<int> indices = *arc;
if (indices.size() != 3) {
throw IfcParse::IfcException("Invalid IfcArcIndex encountered");
} }
previous = current; for (int i = 0; i < 3; ++i) {
} const int& idx = indices[i];
} else if (segment->is(IfcSchema::Type::IfcArcIndex)) { if (idx < 1 || idx > max_index) {
IfcSchema::IfcArcIndex* arc = (IfcSchema::IfcArcIndex*) segment; throw IfcParse::IfcException("IfcIndexedPolyCurve index out of bounds for index " + boost::lexical_cast<std::string>(idx));
std::vector<int> indices = *arc; }
if (indices.size() != 3) {
throw IfcParse::IfcException("Invalid IfcArcIndex encountered");
}
for (int i = 0; i < 3; ++i) {
const int& idx = indices[i];
if (idx < 1 || idx > max_index) {
throw IfcParse::IfcException("IfcIndexedPolyCurve index out of bounds for index " + boost::lexical_cast<std::string>(idx));
} }
const gp_Pnt& a = points[indices[0] - 1];
const gp_Pnt& b = points[indices[1] - 1];
const gp_Pnt& c = points[indices[2] - 1];
Handle(Geom_Circle) circ = GC_MakeCircle(a, b, c).Value();
w.Add(BRepBuilderAPI_MakeEdge(circ, a, c));
} else {
throw IfcParse::IfcException("Unexpected IfcIndexedPolyCurve segment of type " + IfcSchema::Type::ToString(segment->type()));
} }
const gp_Pnt& a = points[indices[0] - 1];
const gp_Pnt& b = points[indices[1] - 1];
const gp_Pnt& c = points[indices[2] - 1];
Handle(Geom_Circle) circ = GC_MakeCircle(a, b, c).Value();
w.Add(BRepBuilderAPI_MakeEdge(circ, a, c));
} else {
throw IfcParse::IfcException("Unexpected IfcIndexedPolyCurve segment of type " + IfcSchema::Type::ToString(segment->type()));
} }
} } else {
std::vector<gp_Pnt>::const_iterator previous = points.begin();
for (std::vector<gp_Pnt>::const_iterator current = previous+1; current < points.end(); ++current){
w.Add(BRepBuilderAPI_MakeEdge(*previous, *current));
previous = current;
}
}
result = w.Wire(); result = w.Wire();
return true; return true;