From 3731c957284c2bac8face0be198c1365ea847917 Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Mon, 16 Sep 2019 17:40:55 +0200 Subject: [PATCH] Mapped item --- src/ifcgeom/schema/mapping.cpp | 20 ++++++++++++++++++++ src/ifcgeom/schema/mapping.i | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ifcgeom/schema/mapping.cpp b/src/ifcgeom/schema/mapping.cpp index ae2645c4bc..9b4ce1ccef 100644 --- a/src/ifcgeom/schema/mapping.cpp +++ b/src/ifcgeom/schema/mapping.cpp @@ -1170,3 +1170,23 @@ taxonomy::item* mapping::map_impl(const IfcSchema::IfcPolyline* inst) { return polygon_from_points(polygon); } + +taxonomy::item* mapping::map_impl(const IfcSchema::IfcMappedItem* inst) { + IfcSchema::IfcCartesianTransformationOperator* transform = inst->MappingTarget(); + taxonomy::matrix4 gtrsf = as(map(transform)); + IfcSchema::IfcRepresentationMap* rmap = inst->MappingSource(); + IfcSchema::IfcAxis2Placement* placement = rmap->MappingOrigin(); + taxonomy::matrix4 trsf2 = as(map(placement)); + gtrsf.components = gtrsf.components * trsf2.components; + + // @todo immutable for caching? + // @todo allow for multiple levels of matrix? + auto shapes = map(rmap->MappedRepresentation()); + for (auto& c : ((taxonomy::collection*)shapes)->children) { + auto item = ((taxonomy::geom_item*)c); + item->matrix.components = gtrsf.components * item->matrix.components; + // @todo previously style was also copied. + } + + return shapes; +} diff --git a/src/ifcgeom/schema/mapping.i b/src/ifcgeom/schema/mapping.i index cada9d4ef1..d023250b61 100644 --- a/src/ifcgeom/schema/mapping.i +++ b/src/ifcgeom/schema/mapping.i @@ -29,7 +29,7 @@ BIND(IfcProduct); // BIND(IfcShellBasedSurfaceModel); BIND(IfcFaceBasedSurfaceModel); BIND(IfcRepresentation); -// BIND(IfcMappedItem); +BIND(IfcMappedItem); // IfcFacetedBrep included // IfcAdvancedBrep included // IfcFacetedBrepWithVoids included