MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / Element

Class Element

src/ifcgeom/IfcGeomElement.h:53–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51 };
52
53 class Element {
54 private:
55 int _id;
56 int _parent_id;
57 std::string _name;
58 std::string _type;
59 std::string _guid;
60 std::string _context;
61 std::string _unique_id;
62 Transformation _transformation;
63 const IfcUtil::IfcBaseEntity* product_;
64 std::vector<const IfcGeom::Element*> _parents;
65 public:
66
67 friend bool operator == (const Element& element1, const Element& element2) {
68 return element1.id() == element2.id();
69 }
70
71 // Use the id to compare, or the elevation is the elements are IfcBuildingStoreys and the elevation is set
72 friend bool operator < (const Element& element1, const Element& element2) {
73 if (element1.type() == "IfcBuildingStorey" && element2.type() == "IfcBuildingStorey") {
74 size_t attr_index = element1.product()->declaration().as_entity()->attribute_index("Elevation");
75 auto elev_attr1 = element1.product()->get_attribute_value(attr_index);
76 auto elev_attr2 = element2.product()->get_attribute_value(attr_index);
77
78 if (!elev_attr1.isNull() && !elev_attr2.isNull()) {
79 double elev1 = elev_attr1;
80 double elev2 = elev_attr2;
81
82 return elev1 < elev2;
83 }
84 }
85
86 return element1.id() < element2.id();
87 }
88
89 int id() const { return _id; }
90 int parent_id() const { return _parent_id; }
91 const std::string& name() const { return _name; }
92 const std::string& type() const { return _type; }
93 const std::string& guid() const { return _guid; }
94 // Return the representation's identifier (e.g. "Body") if present, or it's context type (e.g. "Model").
95 const std::string& context() const { return _context; }
96 const std::string& unique_id() const { return _unique_id; }
97 const Transformation& transformation() const { return _transformation; }
98 const IfcUtil::IfcBaseEntity* product() const { return product_; }
99 const std::vector<const IfcGeom::Element*>& parents() const { return _parents; }
100 void SetParents(std::vector<const IfcGeom::Element*>& newparents) { _parents = newparents; }
101
102 Element(const ifcopenshell::geometry::Settings& settings, int id, int parent_id, const std::string& name, const std::string& type,
103 const std::string& guid, const std::string& context, const ifcopenshell::geometry::taxonomy::matrix4::ptr& trsf, const IfcUtil::IfcBaseEntity* product)
104 : _id(id), _parent_id(parent_id), _name(name), _type(type), _guid(guid), _context(context), _transformation(settings, trsf)
105 , product_(product)
106 {
107 std::ostringstream oss;
108
109 if (type == "IfcProject") {
110 oss << "project";

Callers 2

readMethod · 0.50
svg_splitFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected