| 20 | #include "IfcGeomRepresentation.h" |
| 21 | |
| 22 | IfcGeom::Representation::Serialization::Serialization(const BRep& brep) |
| 23 | : Representation(brep.settings(), brep.entity(), brep.id()) |
| 24 | { |
| 25 | for (auto it = brep.begin(); it != brep.end(); ++it) { |
| 26 | int sid = -1; |
| 27 | |
| 28 | if (it->hasStyle()) { |
| 29 | const auto& clr = it->Style().get_color().ccomponents(); |
| 30 | surface_styles_.push_back(clr(0)); |
| 31 | surface_styles_.push_back(clr(1)); |
| 32 | surface_styles_.push_back(clr(2)); |
| 33 | |
| 34 | sid = it->Style().instance ? it->Style().instance->as<IfcUtil::IfcBaseEntity>()->id() : -1; |
| 35 | } else { |
| 36 | surface_styles_.push_back(-1.); |
| 37 | surface_styles_.push_back(-1.); |
| 38 | surface_styles_.push_back(-1.); |
| 39 | } |
| 40 | |
| 41 | if (it->hasStyle() && it->Style().has_transparency()) { |
| 42 | surface_styles_.push_back(1. - it->Style().transparency); |
| 43 | } else { |
| 44 | surface_styles_.push_back(1.); |
| 45 | } |
| 46 | |
| 47 | surface_style_ids_.push_back(sid); |
| 48 | } |
| 49 | |
| 50 | ifcopenshell::geometry::taxonomy::matrix4 identity; |
| 51 | auto* comp = brep.as_compound(); |
| 52 | comp->Serialize(identity, brep_data_); |
| 53 | delete comp; |
| 54 | } |
| 55 | |
| 56 | IfcGeom::ConversionResultShape* IfcGeom::Representation::BRep::as_compound(bool force_meters) const { |
| 57 | ConversionResultShape* accum = nullptr; |