Skip to content

Commit

Permalink
Fix: Issue #43, catch unsupported IFC entities
Browse files Browse the repository at this point in the history
  • Loading branch information
janbrouwer committed Nov 19, 2022
1 parent ede5377 commit 9f6c46d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 32 deletions.
72 changes: 41 additions & 31 deletions src/bt_ifcmanager/lib/lib_ifc/ObjectCreator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def create_ifc_entity(ent_type_name, su_instance, placement_parent = nil, su_mat
faces = create_nested_objects(ifc_entity, su_instance, su_material, su_layer)
create_geometry(su_instance.definition, ifc_entity, placement_parent, su_material, su_layer, faces)
else

# (!)(?) check against list of valid IFC entities? IfcGroup, IfcProduct

ifc_entity = entity_type.new(@ifc_model, su_instance)
ifc_entity.globalid = @guid if entity_type < @ifc::IfcRoot

Expand Down Expand Up @@ -311,42 +314,49 @@ def create_geometry(definition, ifc_entity, placement_parent = nil, su_material,
su_layer)
end
else
entity = @ifc::IfcBuildingElementProxy.new(@ifc_model, nil)
entity.name = Types::IfcLabel.new(@ifc_model, definition.name)
definition_manager = @ifc_model.representation_manager.get_definition_manager(definition)
entity.representation = definition_manager.create_representation(faces,
brep_transformation,
su_material,
su_layer)
entity.objectplacement = @ifc::IfcLocalPlacement.new(@ifc_model, Geom::Transformation.new)

# IFC 4
entity.predefinedtype = :notdefined if entity.respond_to?(:predefinedtype=)

# IFC 2x3
entity.compositiontype = :element if entity.respond_to?(:compositiontype=)

# Add to spatial hierarchy
@entity_path.add(entity)
@entity_path.set_parent(entity)

# create materialassociation
unless @ifc_model.materials.include?(su_material)
@ifc_model.materials[su_material] = MaterialAndStyling.new(@ifc_model, su_material)
end

# add product to materialassociation
@ifc_model.materials[su_material].add_to_material(entity)
create_fallback_entity(definition_manager, faces, brep_transformation, su_material, su_layer)
end
else
definition_manager = @ifc_model.representation_manager.get_definition_manager(definition)
ifc_entity.representation = definition_manager.create_representation(faces,
brep_transformation,
su_material,
su_layer)
if ifc_entity.respond_to?(:representation)
definition_manager = @ifc_model.representation_manager.get_definition_manager(definition)
ifc_entity.representation = definition_manager.create_representation(faces,
brep_transformation,
su_material,
su_layer)
else
create_fallback_entity(definition_manager, faces, brep_transformation, su_material, su_layer)
end
end
end
end
def create_fallback_entity(definition_manager, faces, brep_transformation, su_material, su_layer)
entity = @ifc::IfcBuildingElementProxy.new(@ifc_model, nil)
entity.name = Types::IfcLabel.new(@ifc_model, definition_manager.name)
entity.representation = definition_manager.create_representation(faces,
brep_transformation,
su_material,
su_layer)
entity.objectplacement = @ifc::IfcLocalPlacement.new(@ifc_model, Geom::Transformation.new)

# IFC 4
entity.predefinedtype = :notdefined if entity.respond_to?(:predefinedtype=)

# IFC 2x3
entity.compositiontype = :element if entity.respond_to?(:compositiontype=)

# Add to spatial hierarchy
@entity_path.add(entity)
@entity_path.set_parent(entity)

# create materialassociation
unless @ifc_model.materials.include?(su_material)
@ifc_model.materials[su_material] = MaterialAndStyling.new(@ifc_model, su_material)
end

# add product to materialassociation
@ifc_model.materials[su_material].add_to_material(entity)

end
end
end
end
3 changes: 2 additions & 1 deletion src/bt_ifcmanager/lib/lib_ifc/representation_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ def get_definition_manager(definition)
# Class that keeps track of all different shaperepresentations for
# a sketchup component definition
class DefinitionManager
attr_reader :definition
attr_reader :definition, :name

def initialize(ifc_model, definition)
@ifc = Settings.ifc_module
@ifc_model = ifc_model
@definition = definition
@name = definition.name
@representations = {}
end

Expand Down

0 comments on commit 9f6c46d

Please sign in to comment.