mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 11:24:19 +00:00
Merge remote-tracking branch 'origin/v0.6.0' into v0.7.0
# Conflicts: # src/ifcgeom/IfcGeomTree.h # src/ifcgeom_schema_agnostic/IfcGeomIterator.h # src/ifcgeom_schema_agnostic/IteratorImplementation.cpp # src/ifcgeom_schema_agnostic/IteratorImplementation.h # src/ifcparse/Ifc4x3_rc3.cpp # src/ifcparse/Ifc4x3_rc3.h # src/serializers/SvgSerializer.cpp
This commit is contained in:
@@ -543,7 +543,12 @@ void SvgSerializer::write(const IfcGeom::BRepElement* brep_obj) {
|
||||
const gp_Trsf& trsf = brep_obj->transformation().data();
|
||||
|
||||
const bool is_section = (section_ref_ && object_type && *section_ref_ == *object_type);
|
||||
const bool is_elevation = (elevation_ref_ && object_type && *elevation_ref_ == *object_type);
|
||||
bool is_elevation = false;
|
||||
if (elevation_ref_ && object_type) {
|
||||
is_elevation = *elevation_ref_ == *object_type;
|
||||
} else if (elevation_ref_guid_) {
|
||||
is_elevation = *elevation_ref_guid_ == brep_obj->guid();
|
||||
}
|
||||
|
||||
if (is_section || is_elevation) {
|
||||
BRepBuilderAPI_Transform make_transform_global(compound_local, trsf, true);
|
||||
@@ -663,7 +668,7 @@ void SvgSerializer::write(const IfcGeom::BRepElement* brep_obj) {
|
||||
// @todo is it correct to call nameElement() here with a single storey (what if this element spans multiple?)
|
||||
geometry_data data{ compound_local, dash_arrays, trsf, brep_obj->product(), storey, elev, brep_obj->name(), nameElement(storey, brep_obj) };
|
||||
|
||||
if (auto_section_ || auto_elevation_ || section_ref_ || elevation_ref_) {
|
||||
if (auto_section_ || auto_elevation_ || section_ref_ || elevation_ref_ || elevation_ref_guid_) {
|
||||
element_buffer_.push_back(data);
|
||||
}
|
||||
|
||||
@@ -1196,11 +1201,17 @@ void SvgSerializer::write(const geometry_data& data) {
|
||||
|
||||
emitted = true;
|
||||
|
||||
auto svg_name = data.svg_name;
|
||||
if (object_type.size()) {
|
||||
// prefix class to indicate this is a cut element
|
||||
boost::replace_all(svg_name, "class=\"", "class=\"cut ");
|
||||
}
|
||||
|
||||
if (po == nullptr) {
|
||||
if (storey) {
|
||||
po = &start_path(pln, storey, data.svg_name);
|
||||
po = &start_path(pln, storey, svg_name);
|
||||
} else {
|
||||
po = &start_path(pln, drawing_name, data.svg_name);
|
||||
po = &start_path(pln, drawing_name, svg_name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1960,13 +1971,19 @@ void SvgSerializer::finalize() {
|
||||
svg_file.stream << " <g " << namespace_prefix_ << "name=\"" << n << "\" class=\"section\" " << writeMetadata(drawing_metadata[it->first]) << ">\n";
|
||||
}
|
||||
}
|
||||
|
||||
previous = it->first;
|
||||
|
||||
if (it->second.second.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
svg_file.stream << " <g " << it->second.first << ">\n";
|
||||
std::vector<util::string_buffer>::const_iterator jt;
|
||||
for (jt = it->second.second.begin(); jt != it->second.second.end(); ++jt) {
|
||||
svg_file.stream << jt->str();
|
||||
}
|
||||
svg_file.stream << " </g>\n";
|
||||
previous = it->first;
|
||||
}
|
||||
|
||||
if (previous) {
|
||||
@@ -2000,45 +2017,49 @@ void SvgSerializer::doWriteHeader() {
|
||||
" <marker id=\"arrowstart\" markerWidth=\"10\" markerHeight=\"7\" refX=\"0\" refY=\"3.5\" orient=\"auto\">\n"
|
||||
" <polygon points=\"10 0, 0 3.5, 10 7\" />\n"
|
||||
" </marker>\n"
|
||||
" </defs>\n"
|
||||
" <style type=\"text/css\" >\n"
|
||||
" <![CDATA[\n"
|
||||
" path {\n"
|
||||
" stroke: #222222;\n"
|
||||
" fill: #444444;\n"
|
||||
" }\n"
|
||||
" .IfcDoor path,\n"
|
||||
" .Symbol path {\n"
|
||||
" fill: none;\n"
|
||||
" }\n"
|
||||
" .Symbol path {\n"
|
||||
" stroke-width: 0.5px;\n"
|
||||
" }\n"
|
||||
" .IfcSpace path {\n"
|
||||
" fill-opacity: .2;\n"
|
||||
" }\n"
|
||||
" .Dimension path {\n"
|
||||
" marker-end: url(#arrowend);\n"
|
||||
" marker-start: url(#arrowstart);\n"
|
||||
" }\n";
|
||||
|
||||
if (scale_) {
|
||||
// previously:
|
||||
// (pt) (px) (in) (mm)
|
||||
// approx 12 / 0.75 / 96 * 25.4
|
||||
" </defs>\n";
|
||||
|
||||
if (!no_css_) {
|
||||
svg_file.stream <<
|
||||
" <style type=\"text/css\" >\n"
|
||||
" <![CDATA[\n"
|
||||
" path {\n"
|
||||
" stroke: #222222;\n"
|
||||
" fill: #444444;\n"
|
||||
" }\n"
|
||||
" .IfcDoor path,\n"
|
||||
" .Symbol path {\n"
|
||||
" fill: none;\n"
|
||||
" }\n"
|
||||
" .Symbol path {\n"
|
||||
" stroke-width: 0.5px;\n"
|
||||
" }\n"
|
||||
" .IfcSpace path {\n"
|
||||
" fill-opacity: .2;\n"
|
||||
" }\n"
|
||||
" .Dimension path {\n"
|
||||
" marker-end: url(#arrowend);\n"
|
||||
" marker-start: url(#arrowstart);\n"
|
||||
" }\n";
|
||||
|
||||
if (scale_) {
|
||||
// previously:
|
||||
// (pt) (px) (in) (mm)
|
||||
// approx 12 / 0.75 / 96 * 25.4
|
||||
|
||||
svg_file.stream <<
|
||||
" text {\n"
|
||||
" font-size: 2;\n" // (reduced to two).
|
||||
" }\n"
|
||||
" path {\n"
|
||||
" stroke-width: 0.3;\n"
|
||||
" }\n";
|
||||
}
|
||||
|
||||
svg_file.stream <<
|
||||
" text {\n"
|
||||
" font-size: 2;\n" // (reduced to two).
|
||||
" }\n"
|
||||
" path {\n"
|
||||
" stroke-width: 0.3;\n"
|
||||
" }\n";
|
||||
" ]]>\n"
|
||||
" </style>\n";
|
||||
}
|
||||
|
||||
svg_file.stream <<
|
||||
" ]]>\n"
|
||||
" </style>\n";
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -157,6 +157,7 @@ protected:
|
||||
bool auto_section_, auto_elevation_;
|
||||
bool use_namespace_, use_hlr_poly_, always_project_, polygonal_;
|
||||
bool emit_building_storeys_;
|
||||
bool no_css_;
|
||||
|
||||
IfcParse::IfcFile* file;
|
||||
IfcUtil::IfcBaseEntity* storey_;
|
||||
@@ -167,7 +168,7 @@ protected:
|
||||
float_item_list xcoords, ycoords, radii;
|
||||
size_t xcoords_begin, ycoords_begin, radii_begin;
|
||||
|
||||
boost::optional<std::string> section_ref_, elevation_ref_;
|
||||
boost::optional<std::string> section_ref_, elevation_ref_, elevation_ref_guid_;
|
||||
|
||||
std::list<geometry_data> element_buffer_;
|
||||
|
||||
@@ -201,6 +202,7 @@ public:
|
||||
, always_project_(false)
|
||||
, polygonal_(false)
|
||||
, emit_building_storeys_(true)
|
||||
, no_css_(false)
|
||||
, file(0)
|
||||
, storey_(0)
|
||||
, xcoords_begin(0)
|
||||
@@ -242,8 +244,15 @@ public:
|
||||
void setSectionRef(const boost::optional<std::string>& s) {
|
||||
section_ref_ = s;
|
||||
}
|
||||
|
||||
void setElevationRef(const boost::optional<std::string>& s) {
|
||||
elevation_ref_ = s;
|
||||
elevation_ref_guid_ = boost::none;
|
||||
}
|
||||
|
||||
void setElevationRefGuid(const boost::optional<std::string>& s) {
|
||||
elevation_ref_ = boost::none;
|
||||
elevation_ref_guid_ = s;
|
||||
}
|
||||
|
||||
void setAutoSection(bool b) {
|
||||
@@ -275,6 +284,10 @@ public:
|
||||
emit_building_storeys_ = !b;
|
||||
}
|
||||
|
||||
void setNoCSS(bool b) {
|
||||
no_css_ = b;
|
||||
}
|
||||
|
||||
void setScale(double s) { scale_ = s; }
|
||||
void setDrawingCenter(double x, double y) {
|
||||
center_x_ = x; center_y_ = y;
|
||||
|
||||
Reference in New Issue
Block a user