Skip to content

Commit

Permalink
Fix: issue #39 moved layer to instance geometry
Browse files Browse the repository at this point in the history
  • Loading branch information
janbrouwer committed Nov 19, 2022
1 parent 3520897 commit ede5377
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions src/bt_ifcmanager/lib/lib_ifc/representation_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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)

Expand All @@ -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)
Expand Down

0 comments on commit ede5377

Please sign in to comment.