mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
SVG: IfcAnnotation objectype handling
This commit is contained in:
@@ -788,21 +788,30 @@ void SvgSerializer::write(const geometry_data& data) {
|
|||||||
auto ot_arg = data.product->get("ObjectType");
|
auto ot_arg = data.product->get("ObjectType");
|
||||||
if (!ot_arg->isNull()) {
|
if (!ot_arg->isNull()) {
|
||||||
object_type = (std::string) *ot_arg;
|
object_type = (std::string) *ot_arg;
|
||||||
|
object_type.erase(std::remove_if(object_type.begin(), object_type.end(), [](char c) { return !std::isalnum(c); }), object_type.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.product->declaration().is("IfcAnnotation") && // is an Annotation
|
if (data.product->declaration().is("IfcAnnotation") && // is an Annotation
|
||||||
object_type == "Dimension" && // with ObjectType='Dimension'
|
|
||||||
(proj.Magnitude() > 1.e-5) && // when projected onto the view has a length
|
(proj.Magnitude() > 1.e-5) && // when projected onto the view has a length
|
||||||
zmin >= range.first && zmin <= range.second) // the Z-coords are within the range of the building storey
|
zmin >= range.first && zmin <= range.second) // the Z-coords are within the range of the building storey
|
||||||
{
|
{
|
||||||
|
auto svg_name = data.svg_name;
|
||||||
|
|
||||||
|
if (object_type.size()) {
|
||||||
|
// postfix the object_type for CSS matching
|
||||||
|
boost::replace_all(svg_name, "class=\"IfcAnnotation\"", "class=\"IfcAnnotation " + object_type + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
if (po == nullptr) {
|
if (po == nullptr) {
|
||||||
if (storey) {
|
if (storey) {
|
||||||
po = &start_path(pln, storey, data.svg_name);
|
po = &start_path(pln, storey, svg_name);
|
||||||
} else {
|
} else {
|
||||||
po = &start_path(pln, drawing_name, data.svg_name);
|
po = &start_path(pln, drawing_name, svg_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (object_type == "Dimension") {
|
||||||
|
|
||||||
TopExp_Explorer exp(subshape, TopAbs_EDGE, TopAbs_FACE);
|
TopExp_Explorer exp(subshape, TopAbs_EDGE, TopAbs_FACE);
|
||||||
for (; exp.More(); exp.Next()) {
|
for (; exp.More(); exp.Next()) {
|
||||||
const auto& e = TopoDS::Edge(exp.Current());
|
const auto& e = TopoDS::Edge(exp.Current());
|
||||||
@@ -810,16 +819,14 @@ void SvgSerializer::write(const geometry_data& data) {
|
|||||||
TopExp::Vertices(e, v0, v1);
|
TopExp::Vertices(e, v0, v1);
|
||||||
gp_Pnt p0 = BRep_Tool::Pnt(v0);
|
gp_Pnt p0 = BRep_Tool::Pnt(v0);
|
||||||
gp_Pnt p1 = BRep_Tool::Pnt(v1);
|
gp_Pnt p1 = BRep_Tool::Pnt(v1);
|
||||||
// @todo should we take the average parameter value instead?
|
|
||||||
gp_XYZ center = (p0.XYZ() + p1.XYZ()) / 2.;
|
|
||||||
BRep_Builder B;
|
BRep_Builder B;
|
||||||
TopoDS_Wire W;
|
TopoDS_Wire W;
|
||||||
B.MakeWire(W);
|
B.MakeWire(W);
|
||||||
B.Add(W, e);
|
B.Add(W, e);
|
||||||
write(*po, W);
|
write(*po, W);
|
||||||
|
|
||||||
|
// @todo should we take the average parameter value instead?
|
||||||
|
gp_XYZ center = (p0.XYZ() + p1.XYZ()) / 2.;
|
||||||
|
|
||||||
util::string_buffer path;
|
util::string_buffer path;
|
||||||
// dominant-baseline="central" is not well supported in IE.
|
// dominant-baseline="central" is not well supported in IE.
|
||||||
@@ -855,6 +862,18 @@ void SvgSerializer::write(const geometry_data& data) {
|
|||||||
path.add("</text>");
|
path.add("</text>");
|
||||||
po->second.push_back(path);
|
po->second.push_back(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (object_type == "Symbol") {
|
||||||
|
|
||||||
|
TopExp_Explorer exp(subshape, TopAbs_WIRE, TopAbs_FACE);
|
||||||
|
for (; exp.More(); exp.Next()) {
|
||||||
|
const auto& W = TopoDS::Wire(exp.Current());
|
||||||
|
write(*po, W);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// We're finished processing IfcAnnotation instances
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1396,7 +1415,7 @@ void SvgSerializer::writeHeader() {
|
|||||||
" .IfcSpace path {\n"
|
" .IfcSpace path {\n"
|
||||||
" fill-opacity: .2;\n"
|
" fill-opacity: .2;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" .IfcAnnotation path {\n"
|
" .dimension path {\n"
|
||||||
" marker-end: url(#arrowend);\n"
|
" marker-end: url(#arrowend);\n"
|
||||||
" marker-start: url(#arrowstart);\n"
|
" marker-start: url(#arrowstart);\n"
|
||||||
" }\n";
|
" }\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user