From ede5377866d46b8b8ff1d8048d67689c702581ab Mon Sep 17 00:00:00 2001 From: Jan Brouwer Date: Sat, 19 Nov 2022 15:58:30 +0100 Subject: [PATCH] Fix: issue #39 moved layer to instance geometry --- .../lib/lib_ifc/representation_manager.rb | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/bt_ifcmanager/lib/lib_ifc/representation_manager.rb b/src/bt_ifcmanager/lib/lib_ifc/representation_manager.rb index 8b10d86..55f082e 100644 --- a/src/bt_ifcmanager/lib/lib_ifc/representation_manager.rb +++ b/src/bt_ifcmanager/lib/lib_ifc/representation_manager.rb @@ -67,13 +67,12 @@ def initialize(ifc_model, definition) # @param [Sketchup::Transformation] transformation # @param [Sketchup::Material] su_material # @return [BimTools::IFC2X3::IfcFacetedBrep] - def get_representation(faces, transformation, material = nil, layer = nil) + def get_representation(faces, transformation, material = nil) material_name = material ? material.name : '' - layer_name = layer ? layer.name : '' - representation_string = "#{transformation.to_a}_#{material_name}_#{layer_name}" + representation_string = "#{transformation.to_a}_#{material_name}" unless @representations.key?(representation_string) @representations[representation_string] = - IfcManager::ShapeRepresentation.new(@ifc_model, faces, transformation, material, layer) + IfcManager::ShapeRepresentation.new(@ifc_model, faces, transformation, material) end @representations[representation_string] end @@ -86,7 +85,7 @@ def get_representation(faces, transformation, material = nil, layer = nil) def create_representation(faces, transformation, su_material, su_layer) # Check if Mapped representation should be used if @ifc_model.options[:mapped_items] - definition_representation = get_representation(faces, transformation, su_material, su_layer) + definition_representation = get_representation(faces, transformation, su_material) target = @ifc::IfcCartesianTransformationOperator3D.new(@ifc_model) target.localorigin = @ifc_model.default_location @@ -110,6 +109,18 @@ def create_representation(faces, transformation, su_material, su_layer) add_styling(@ifc_model, brep, su_material) end + # set layer + if @ifc_model.options[:layers] + + # check if IfcPresentationLayerAssignment exists + unless @ifc_model.layers[su_layer.name] + @ifc_model.layers[su_layer.name] = @ifc::IfcPresentationLayerAssignment.new(@ifc_model, su_layer) + end + + # add self to IfcPresentationLayerAssignment + @ifc_model.layers[su_layer.name].assigneditems.add(shape_representation) + end + representation = IfcProductDefinitionShapeBuilder.build(@ifc_model) do |builder| builder.add_representation(shape_representation) end @@ -128,7 +139,7 @@ def add_styling(ifc_model, brep, su_material) class ShapeRepresentation attr_reader :brep, :shaperepresentation, :representationmap - def initialize(ifc_model, faces, transformation, su_material, su_layer) + def initialize(ifc_model, faces, transformation, su_material) @ifc = Settings.ifc_module @brep = @ifc::IfcFacetedBrep.new(ifc_model, faces, transformation) @@ -143,18 +154,6 @@ def initialize(ifc_model, faces, transformation, su_material, su_layer) @representationmap.mappedrepresentation = @shaperepresentation add_styling(ifc_model, brep, su_material) - - # set layer - if ifc_model.options[:layers] - - # check if IfcPresentationLayerAssignment exists - unless ifc_model.layers[su_layer.name] - ifc_model.layers[su_layer.name] = @ifc::IfcPresentationLayerAssignment.new(ifc_model, su_layer) - end - - # add self to IfcPresentationLayerAssignment - ifc_model.layers[su_layer.name].assigneditems.add(@shaperepresentation) - end end def add_styling(ifc_model, brep, su_material)