From c964559b91336d1d1afd1773af293223e72940a2 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 27 Mar 2023 14:02:53 +0200 Subject: [PATCH] taxonomy string formatting --- src/ifcgeom/taxonomy.cpp | 10 ++++++++++ src/ifcgeom/taxonomy.h | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/ifcgeom/taxonomy.cpp b/src/ifcgeom/taxonomy.cpp index dbbb74b452..f939483a9d 100644 --- a/src/ifcgeom/taxonomy.cpp +++ b/src/ifcgeom/taxonomy.cpp @@ -397,4 +397,14 @@ ifcopenshell::geometry::taxonomy::collection * ifcopenshell::geometry::flatten(c flat->children.push_back(i); }); return flat; +} + +const std::string& ifcopenshell::geometry::taxonomy::kind_to_string(kinds k) { + using namespace std::string_literals; + + static std::string values[] = { + "matrix4"s, "point3"s, "direction3"s, "line"s, "circle"s, "ellipse"s, "bspline_curve"s, "offset_curve"s, "plane"s, "cylinder"s, "bspline_surface"s, "edge"s, "loop"s, "face"s, "shell"s, "solid"s, "loft"s, "extrusion"s, "revolve"s, "surface_curve_sweep"s, "node"s, "collection"s, "boolean_result"s + }; + + return values[k]; } \ No newline at end of file diff --git a/src/ifcgeom/taxonomy.h b/src/ifcgeom/taxonomy.h index 2a01ddc8e4..f20313296d 100644 --- a/src/ifcgeom/taxonomy.h +++ b/src/ifcgeom/taxonomy.h @@ -29,6 +29,8 @@ public: enum kinds { MATRIX4, POINT3, DIRECTION3, LINE, CIRCLE, ELLIPSE, BSPLINE_CURVE, OFFSET_CURVE, PLANE, CYLINDER, BSPLINE_SURFACE, EDGE, LOOP, FACE, SHELL, SOLID, LOFT, EXTRUSION, REVOLVE, SURFACE_CURVE_SWEEP, NODE, COLLECTION, BOOLEAN_RESULT, COLOUR, STYLE }; +const std::string& kind_to_string(kinds k); + struct item { const IfcUtil::IfcBaseInterface* instance; @@ -453,7 +455,7 @@ struct collection : public geom_item { } void print(std::ostream& o, int indent = 0) const { - o << std::string(indent, ' ') << "collection" << std::endl; + o << std::string(indent, ' ') << kind_to_string(kind()) << std::endl; if (!matrix.is_identity()) { matrix.print(o, indent + 4); } @@ -620,6 +622,12 @@ struct boolean_result : public collection { virtual item* clone() const { return new boolean_result(*this); } virtual kinds kind() const { return BOOLEAN_RESULT; } operation_t operation; + + static const std::string& operation_str(operation_t op) { + using namespace std::string_literals; + static std::string s[] = { "union"s, "subtraction"s, "intersection"s }; + return s[(size_t)op]; + } }; namespace impl {