This commit is contained in:
Andrej730
2025-03-14 10:43:47 +05:00
parent 10ecac33b8
commit 0e8810c1f5
118 changed files with 869 additions and 1203 deletions
@@ -17,7 +17,6 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
from typing import Any
def map_representation(
@@ -25,15 +24,14 @@ def map_representation(
) -> ifcopenshell.entity_instance:
usecase = Usecase()
usecase.file = file
usecase.settings = {"representation": representation}
return usecase.execute()
return usecase.execute(representation)
class Usecase:
file: ifcopenshell.file
settings: dict[str, Any]
def execute(self) -> ifcopenshell.entity_instance:
def execute(self, representation: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
self.representation = representation
mapping_source = self.get_mapping_source()
zero = self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
@@ -46,15 +44,15 @@ class Usecase:
return self.file.create_entity(
"IfcShapeRepresentation",
**{
"ContextOfItems": self.settings["representation"].ContextOfItems,
"RepresentationIdentifier": self.settings["representation"].RepresentationIdentifier,
"ContextOfItems": representation.ContextOfItems,
"RepresentationIdentifier": representation.RepresentationIdentifier,
"RepresentationType": "MappedRepresentation",
"Items": [mapped_item],
}
)
def get_mapping_source(self) -> ifcopenshell.entity_instance:
for inverse in self.file.get_inverse(self.settings["representation"]):
for inverse in self.file.get_inverse(self.representation):
if inverse.is_a("IfcRepresentationMap"):
return inverse
zero = self.file.createIfcCartesianPoint((0.0, 0.0, 0.0))
@@ -62,5 +60,5 @@ class Usecase:
z_axis = self.file.createIfcDirection((0.0, 0.0, 1.0))
mapping_origin = self.file.createIfcAxis2Placement3D(zero, z_axis, x_axis)
return self.file.createIfcRepresentationMap(
MappingOrigin=mapping_origin, MappedRepresentation=self.settings["representation"]
MappingOrigin=mapping_origin, MappedRepresentation=self.representation
)