diff --git a/src/ifcconvert/SvgSerializer.cpp b/src/ifcconvert/SvgSerializer.cpp index 80b61062b0..8319393ff8 100644 --- a/src/ifcconvert/SvgSerializer.cpp +++ b/src/ifcconvert/SvgSerializer.cpp @@ -90,16 +90,10 @@ void SvgSerializer::write(path_object& p, const TopoDS_Wire& wire) { path.add(","); addYCoordinate(path.add(p1.Y())); - if (p1.X() < xmin) xmin = p1.X(); - if (p1.X() > xmax) xmax = p1.X(); - if (p1.Y() < ymin) ymin = p1.Y(); - if (p1.Y() > ymax) ymax = p1.Y(); + growBoundingBox(p1.X(), p1.Y()); } - if (p2.X() < xmin) xmin = p2.X(); - if (p2.X() > xmax) xmax = p2.X(); - if (p2.Y() < ymin) ymin = p2.Y(); - if (p2.Y() > ymax) ymax = p2.Y(); + growBoundingBox(p2.X(), p2.Y()); Handle(Standard_Type) ty = curve->DynamicType(); @@ -218,7 +212,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement* o) { if (!storey) return; - path_object& p = start_path(storey, o->unique_id()); + path_object& p = start_path(storey, nameElement(o)); for (IfcGeom::IfcRepresentationShapeItems::const_iterator it = o->geometry().begin(); it != o->geometry().end(); ++ it) { gp_GTrsf gtrsf = it->Placement(); @@ -334,9 +328,9 @@ void SvgSerializer::finalize() { svg_file << " \n"; } std::ostringstream oss; - svg_file << " first->GlobalId()).formatted() << "\">\n"; + svg_file << " first) << ">\n"; } - svg_file << " second.first << "\">\n"; + svg_file << " second.first << ">\n"; std::vector::const_iterator jt; for (jt = it->second.second.begin(); jt != it->second.second.end(); ++jt) { svg_file << jt->str(); @@ -353,3 +347,17 @@ void SvgSerializer::finalize() { void SvgSerializer::writeHeader() { svg_file << "\n"; } + +std::string SvgSerializer::nameElement(const IfcGeom::Element* elem) { + std::ostringstream oss; + const std::string type = "product"; + oss << "id=\"" << type << "-" << elem->unique_id() << "\""; + return oss.str(); +} + +std::string SvgSerializer::nameElement(const IfcSchema::IfcProduct* elem) { + std::ostringstream oss; + const std::string type = elem->is(IfcSchema::Type::IfcBuildingStorey) ? "storey" : "product"; + oss << "id=\"product-" << IfcParse::IfcGlobalId(elem->GlobalId()).formatted() << "\""; + return oss.str(); +} \ No newline at end of file diff --git a/src/ifcconvert/SvgSerializer.h b/src/ifcconvert/SvgSerializer.h index 04dbb34188..2efb632b6d 100644 --- a/src/ifcconvert/SvgSerializer.h +++ b/src/ifcconvert/SvgSerializer.h @@ -59,6 +59,7 @@ public: virtual void addXCoordinate(const SHARED_PTR& fi) { xcoords.push_back(fi); } virtual void addYCoordinate(const SHARED_PTR& fi) { ycoords.push_back(fi); } virtual void addSizeComponent(const SHARED_PTR& fi) { radii.push_back(fi); } + virtual void growBoundingBox(double x, double y) { if (x < xmin) xmin = x; if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; } virtual ~SvgSerializer() {} virtual void writeHeader(); virtual void writeMaterial(const IfcGeom::SurfaceStyle& style) {} @@ -73,6 +74,8 @@ public: virtual void setFile(IfcParse::IfcFile* f) { file = f; } virtual void setBoundingRectangle(double width, double height); virtual void setSectionHeight(double h) { section_height = h; } + virtual std::string nameElement(const IfcGeom::Element* elem); + virtual std::string nameElement(const IfcSchema::IfcProduct* elem); }; #endif