diff --git a/src/ifcconvert/IfcConvert.cpp b/src/ifcconvert/IfcConvert.cpp index cd6fd679f6..6b4cc7fca4 100644 --- a/src/ifcconvert/IfcConvert.cpp +++ b/src/ifcconvert/IfcConvert.cpp @@ -363,7 +363,9 @@ int main(int argc, char** argv) { "Applicable for OBJ and DAE output. For DAE output, value >= 15 means that up to 16 decimals are used, " " and any other value means that 6 or 7 decimals are used.") ("print-space-names", "Prints IfcSpace LongName and Name in the geometry output. Applicable for SVG output") - ("print-space-areas", "Prints calculated IfcSpace areas in square meters. Applicable for SVG output"); + ("print-space-areas", "Prints calculated IfcSpace areas in square meters. Applicable for SVG output") + ("edge-arrows", "Adds arrow heads to edge segments to signify edge direction") + ; po::options_description cmdline_options; cmdline_options.add(generic_options).add(fileio_options).add(geom_options).add(ifc_options).add(serializer_options); @@ -425,6 +427,7 @@ int main(int argc, char** argv) { const bool building_local_placement = vmap.count("building-local-placement") != 0; const bool generate_uvs = vmap.count("generate-uvs") != 0; const bool validate = vmap.count("validate") != 0; + const bool edge_arrows = vmap.count("edge-arrows") != 0; if (!quiet || vmap.count("version")) { print_version(); @@ -654,6 +657,7 @@ int main(int argc, char** argv) { settings.set(IfcGeom::IteratorSettings::LAYERSET_FIRST, layerset_first); settings.set(IfcGeom::IteratorSettings::NO_NORMALS, no_normals); settings.set(IfcGeom::IteratorSettings::GENERATE_UVS, generate_uvs); + settings.set(IfcGeom::IteratorSettings::EDGE_ARROWS, edge_arrows); settings.set(IfcGeom::IteratorSettings::SEARCH_FLOOR, use_element_hierarchy || output_extension == SVG); settings.set(IfcGeom::IteratorSettings::SITE_LOCAL_PLACEMENT, site_local_placement); settings.set(IfcGeom::IteratorSettings::BUILDING_LOCAL_PLACEMENT, building_local_placement); diff --git a/src/ifcgeom/IfcGeomIteratorSettings.h b/src/ifcgeom/IfcGeomIteratorSettings.h index 68258bf474..02b624d05f 100644 --- a/src/ifcgeom/IfcGeomIteratorSettings.h +++ b/src/ifcgeom/IfcGeomIteratorSettings.h @@ -90,8 +90,10 @@ namespace IfcGeom VALIDATE_QUANTITIES = 1 << 17, /// Assigns the first layer material to the entire product LAYERSET_FIRST = 1 << 18, + /// Adds arrow heads to edge segments to signify edge direction + EDGE_ARROWS = 1 << 19, /// Number of different setting flags. - NUM_SETTINGS = 18 + NUM_SETTINGS = 19 }; /// Used to store logical OR combination of setting flags. typedef unsigned SettingField; diff --git a/src/ifcgeom/IfcGeomRepresentation.h b/src/ifcgeom/IfcGeomRepresentation.h index c68e4debfc..d56d66f0c1 100644 --- a/src/ifcgeom/IfcGeomRepresentation.h +++ b/src/ifcgeom/IfcGeomRepresentation.h @@ -290,57 +290,52 @@ namespace IfcGeom { for (int i = 1; i <= n; ++i) { gp_XYZ p = tessellater.Value(i).XYZ(); - /* - // In case you want direction arrows on your edges - double u = tessellater.Parameter(i); - gp_XYZ p2, p3; - gp_Pnt tmp; - gp_Vec tmp2; - crv.D1(u, tmp, tmp2); - gp_Dir d1, d2, d3, d4; - d1 = tmp2; - if (texp.Current().Orientation() == TopAbs_REVERSED) { - d1 = -d1; - } - if (fabs(d1.Z()) < 0.5) { - d2 = d1.Crossed(gp::DZ()); - } else { - d2 = d1.Crossed(gp::DY()); - } - d3 = d1.XYZ() + d2.XYZ(); - d4 = d1.XYZ() - d2.XYZ(); - p2 = p - d3.XYZ() / 10.; - p3 = p - d4.XYZ() / 10.; - trsf.Transforms(p2); - trsf.Transforms(p3); - _material_ids.push_back(surface_style_id); - _material_ids.push_back(surface_style_id); - _verts.push_back(static_cast

(p2.X())); - _verts.push_back(static_cast

(p2.Y())); - _verts.push_back(static_cast

(p2.Z())); - _verts.push_back(static_cast

(p3.X())); - _verts.push_back(static_cast

(p3.Y())); - _verts.push_back(static_cast

(p3.Z())); - */ - - trsf.Transforms(p); - int current = addVertex(surface_style_id, p); + std::vector> segments; if (i > 1) { - _edges.push_back(previous); - _edges.push_back(current); + segments.push_back(std::make_pair(previous, current)); + } + + if (settings().get(IfcGeom::IteratorSettings::EDGE_ARROWS)) { + // In case you want direction arrows on your edges + double u = tessellater.Parameter(i); + gp_XYZ p2, p3; + gp_Pnt tmp; + gp_Vec tmp2; + crv.D1(u, tmp, tmp2); + gp_Dir d1, d2, d3, d4; + d1 = tmp2; + if (texp.Current().Orientation() == TopAbs_REVERSED) { + d1 = -d1; + } + if (fabs(d1.Z()) < 0.5) { + d2 = d1.Crossed(gp::DZ()); + } else { + d2 = d1.Crossed(gp::DY()); + } + d3 = d1.XYZ() + d2.XYZ(); + d4 = d1.XYZ() - d2.XYZ(); + p2 = p - d3.XYZ() / 10.; + p3 = p - d4.XYZ() / 10.; + trsf.Transforms(p2); + trsf.Transforms(p3); + trsf.Transforms(p); + + int left = addVertex(surface_style_id, p2); + int right = addVertex(surface_style_id, p3); + + segments.push_back(std::make_pair(left, current)); + segments.push_back(std::make_pair(right, current)); + } + + for (auto& s : segments) { + _edges.push_back(s.first); + _edges.push_back(s.second); _material_ids.push_back(surface_style_id); - // _edges.push_back(start + 3 * (i - 2) + 2); - // _edges.push_back(start + 3 * (i - 1) + 2); } previous = current; - - // _edges.push_back(start + 3 * (i - 1) + 0); - // _edges.push_back(start + 3 * (i - 1) + 2); - // _edges.push_back(start + 3 * (i - 1) + 1); - // _edges.push_back(start + 3 * (i - 1) + 2); } } }