Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Licini committed May 14, 2024
1 parent 98f0edc commit 8d5f893
Show file tree
Hide file tree
Showing 17 changed files with 55 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/compas_ifc/brep/tessellatedbrep.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
from compas.geometry import Geometry
from compas.geometry import transform_points_numpy
import numpy as np


class TessellatedBrep(Geometry):
Expand Down
7 changes: 4 additions & 3 deletions src/compas_ifc/brep/tessellatedbrepobject.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import numpy as np
from compas.colors import Color
from compas.datastructures import Mesh
from compas_viewer.scene import ViewerSceneObject

from .tessellatedbrep import TessellatedBrep
from compas.datastructures import Mesh
from compas.colors import Color
import numpy as np


class TessellatedBrepObject(ViewerSceneObject):
Expand Down
7 changes: 4 additions & 3 deletions src/compas_ifc/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
.. code-block:: python
for association in entity.HasAssociations:
if association.is_a('IfcRelAssociatesClassification'):
if association.is_a("IfcRelAssociatesClassification"):
...
Material Associations
Expand All @@ -66,14 +66,15 @@
.. code-block:: python
for association in entity.HasAssociations:
if association.is_a('IfcRelAssociatesMaterial'):
if association.is_a("IfcRelAssociatesMaterial"):
...
Object Composition
==================
Objects may be composed into parts to indicate levels of detail, such as a building having multiple storeys, a framed wall having studs, or a task having subtasks.
Composition may form a hierarchy of multiple levels, where an object must have single parent, or if a top-level object then declared within the single project or a project library.
Composition may form a hierarchy of multiple levels, where an object must have single parent,
or if a top-level object then declared within the single project or a project library.
Element Composition
-------------------
Expand Down
4 changes: 1 addition & 3 deletions src/compas_ifc/entities/buildingelements.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ def composite_body_with_opening(self):
from compas_ifc.representation import entity_body_with_opening_geometry

if not self._composite_body_with_opening:
self._composite_body_with_opening = entity_body_with_opening_geometry(
entity=self, bodies=self.composite_body, voids=self.composite_opening
)
self._composite_body_with_opening = entity_body_with_opening_geometry(entity=self, bodies=self.composite_body, voids=self.composite_opening)
return self._composite_body_with_opening

@composite_body_with_opening.setter
Expand Down
1 change: 0 additions & 1 deletion src/compas_ifc/entities/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from typing import Union

# from typing import Optional

import ifcopenshell
import ifcopenshell.util.element
import ifcopenshell.util.pset
Expand Down
4 changes: 1 addition & 3 deletions src/compas_ifc/entities/objectdefinition.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ def is_decomposed_by(self):

@property
def children(self):
children = [
entity for entity in self.model.get_entities_by_type("IfcObjectDefinition") if entity.parent == self
]
children = [entity for entity in self.model.get_entities_by_type("IfcObjectDefinition") if entity.parent == self]
for entity in self.model._new_entities:
if entity.parent == self and entity not in children:
children.append(entity)
Expand Down
1 change: 1 addition & 0 deletions src/compas_ifc/entities/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from compas.geometry import Frame
from compas.geometry import Vector

from compas_ifc.entities.objectdefinition import ObjectDefinition
from compas_ifc.entities.site import Building
from compas_ifc.entities.site import Site
Expand Down
15 changes: 7 additions & 8 deletions src/compas_ifc/model.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
from typing import List

from compas_ifc.entities.element import Element
from compas_ifc.entities.product import Product
import ifcopenshell

from compas_ifc.entities.building import Building
from compas_ifc.entities.buildingelements import BuildingElement
from compas_ifc.entities.geographicelement import GeographicElement
from compas_ifc.entities.buildingelements import BuildingElementProxy
from compas_ifc.entities.buildingstorey import BuildingStorey
from compas_ifc.entities.objectdefinition import ObjectDefinition
from compas_ifc.entities.element import Element
from compas_ifc.entities.entity import Entity
from compas_ifc.entities.geographicelement import GeographicElement
from compas_ifc.entities.objectdefinition import ObjectDefinition
from compas_ifc.entities.product import Product
from compas_ifc.entities.project import Project
from compas_ifc.entities.site import Site

from .reader import IFCReader
from .writer import IFCWriter
import ifcopenshell


class Model:
Expand Down Expand Up @@ -60,9 +61,7 @@ class Model:
"""

def __init__(
self, filepath: str = None, entity_types: dict = None, use_occ=False, schema=None, load_geometries=True
) -> None:
def __init__(self, filepath: str = None, entity_types: dict = None, use_occ=False, schema=None, load_geometries=True) -> None:
self.reader = IFCReader(model=self, entity_types=entity_types, use_occ=use_occ)
self.writer = IFCWriter(model=self)
self._new_entities = set()
Expand Down
10 changes: 4 additions & 6 deletions src/compas_ifc/reader.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import multiprocessing
import os
import time
from typing import List

import ifcopenshell
import os
import multiprocessing
import numpy as np
from compas.geometry import Transformation
import time

from compas_ifc.entities.entity import Entity

Expand Down Expand Up @@ -148,9 +148,7 @@ def load_geometries(self, include=None, exclude=None):
if self.use_occ:
settings.set(settings.USE_PYTHON_OPENCASCADE, True)

iterator = ifcopenshell.geom.iterator(
settings, self._file, multiprocessing.cpu_count(), include=include, exclude=exclude
)
iterator = ifcopenshell.geom.iterator(settings, self._file, multiprocessing.cpu_count(), include=include, exclude=exclude)
start = time.time()
if iterator.initialize():
while True:
Expand Down
11 changes: 5 additions & 6 deletions src/compas_ifc/representation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@
from operator import mul
from typing import List

from compas.geometry import Box
from compas.geometry import Scale
from compas.geometry import Transformation
from compas_occ.brep import OCCBrep
from OCC.Core.BRep import BRep_Builder
from OCC.Core.TopoDS import TopoDS_Compound

from compas.geometry import Box
from compas.geometry import Scale
from compas.geometry import Transformation
from compas_ifc.entities.entity import Entity
from compas_ifc.brep import TessellatedBrep
from compas_ifc.entities.entity import Entity
from compas_ifc.resources import IfcAxis2Placement3D_to_frame
from compas_ifc.resources import IfcBoundingBox_to_box
from compas_ifc.resources import IfcCartesianTransformationOperator3D_to_frame
from compas_ifc.resources import IfcIndexedPolyCurve_to_lines
from compas_ifc.resources import IfcLocalPlacement_to_transformation
from compas_ifc.resources import IfcLocalPlacement_to_frame
from compas_ifc.resources import IfcLocalPlacement_to_transformation
from compas_ifc.resources import IfcShape_to_brep
from compas_ifc.resources import IfcShape_to_tessellatedbrep

Expand Down Expand Up @@ -87,7 +87,6 @@ def entity_transformation(entity: Entity):


def _entity_transformation(_entity, scale=1.0):

if _entity.ObjectPlacement:
scaled_placement = IfcLocalPlacement_to_transformation(_entity.ObjectPlacement, scale=scale)
else:
Expand Down
33 changes: 10 additions & 23 deletions src/compas_ifc/resources/brep.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from typing import List

import ifcopenshell
import numpy as np

from typing import List
from compas.tolerance import TOL

from .primities import point_to_ifc_cartesian_point
from .primities import occ_plane_to_frame
from .primities import frame_to_ifc_plane

from .primities import occ_plane_to_frame
from .primities import point_to_ifc_cartesian_point
from .shapes import occ_cylinder_to_ifc_cylindrical_surface


Expand Down Expand Up @@ -149,9 +148,7 @@ def get_ifc_curve(edge):
if not IfcEdgeCurve:
raise ValueError("Edge not found")

ifc_oriented_edge = file.create_entity(
"IFCORIENTEDEDGE", EdgeElement=IfcEdgeCurve, Orientation=oriented
)
ifc_oriented_edge = file.create_entity("IFCORIENTEDEDGE", EdgeElement=IfcEdgeCurve, Orientation=oriented)
ifc_oriented_edges.append(ifc_oriented_edge)

edge_loop = file.create_entity("IfcEdgeLoop", ifc_oriented_edges)
Expand All @@ -167,26 +164,18 @@ def get_ifc_curve(edge):
occ_plane = face.occ_adaptor.Plane()
frame = occ_plane_to_frame(occ_plane)
ifc_plane = frame_to_ifc_plane(file, frame)
IfcAdvancedFace = file.create_entity(
"IfcAdvancedFace", face_bounds, ifc_plane, SameSense=same_sense
)
IfcAdvancedFace = file.create_entity("IfcAdvancedFace", face_bounds, ifc_plane, SameSense=same_sense)
elif face.is_cylinder:
cylinder = face.occ_adaptor.Cylinder()
IfcCylindricalSurface = occ_cylinder_to_ifc_cylindrical_surface(file, cylinder)
IfcAdvancedFace = file.create_entity(
"IfcAdvancedFace", face_bounds, IfcCylindricalSurface, SameSense=same_sense
)
IfcAdvancedFace = file.create_entity("IfcAdvancedFace", face_bounds, IfcCylindricalSurface, SameSense=same_sense)
else:
control_points = np.array(face.nurbssurface.points.points, dtype=float)
control_points = control_points.swapaxes(0, 1)
ifc_control_points = []

u_knots, u_mults = calculate_knots_and_multiplicities(
list(face.nurbssurface.occ_surface.UKnotSequence())
)
v_knots, v_mults = calculate_knots_and_multiplicities(
list(face.nurbssurface.occ_surface.VKnotSequence())
)
u_knots, u_mults = calculate_knots_and_multiplicities(list(face.nurbssurface.occ_surface.UKnotSequence()))
v_knots, v_mults = calculate_knots_and_multiplicities(list(face.nurbssurface.occ_surface.VKnotSequence()))

for row in control_points:
ifc_row = []
Expand Down Expand Up @@ -237,9 +226,7 @@ def get_ifc_curve(edge):
WeightsData=ifc_weights,
)

IfcAdvancedFace = file.create_entity(
"IfcAdvancedFace", face_bounds, IfcBSplineSurfaceWithKnots, SameSense=same_sense
)
IfcAdvancedFace = file.create_entity("IfcAdvancedFace", face_bounds, IfcBSplineSurfaceWithKnots, SameSense=same_sense)

ifc_faces.append(IfcAdvancedFace)

Expand Down
5 changes: 3 additions & 2 deletions src/compas_ifc/resources/geometricmodel.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
from typing import List

import ifcopenshell

# from compas.geometry import Polyline
from compas.geometry import Box
from compas.geometry import Line
from compas.geometry import Point
from compas.geometry import Transformation

from compas_ifc.resources.geometry import IfcAxis2Placement3D_to_frame
from compas_ifc.resources.geometry import IfcDirection_to_vector
from compas_ifc.resources.geometry import IfcProfileDef_to_curve

import ifcopenshell


def IfcAdvancedBrep_to_brep(advanced_brep):
"""
Expand Down
1 change: 0 additions & 1 deletion src/compas_ifc/resources/mesh.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ifcopenshell

from compas.datastructures import Mesh


Expand Down
2 changes: 1 addition & 1 deletion src/compas_ifc/resources/primities.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ifcopenshell

from compas.geometry import Frame
from compas.geometry import Point

from .shapes import create_IfcAxis2Placement3D


Expand Down
3 changes: 1 addition & 2 deletions src/compas_ifc/resources/representation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from ifcopenshell.api import run

from compas.datastructures import Mesh
from compas.geometry import Box
from compas.geometry import Cone
from compas.geometry import Cylinder
from compas.geometry import Sphere
from ifcopenshell.api import run

from .brep import brep_to_ifc_advanced_brep
from .mesh import mesh_to_IfcPolygonalFaceSet
Expand Down
5 changes: 1 addition & 4 deletions src/compas_ifc/resources/shapes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ifcopenshell

from compas.geometry import Box
from compas.geometry import Cone
from compas.geometry import Cylinder
Expand All @@ -21,9 +20,7 @@ def create_IfcAxis2Placement3D(file, point=None, dir1=None, dir2=None):
return axis2placement


def create_IfcShapeRepresentation(
file: ifcopenshell.file, item: ifcopenshell.entity_instance, context: ifcopenshell.entity_instance
) -> ifcopenshell.entity_instance:
def create_IfcShapeRepresentation(file: ifcopenshell.file, item: ifcopenshell.entity_instance, context: ifcopenshell.entity_instance) -> ifcopenshell.entity_instance:
"""
Create an IFC Shape Representation from an IFC item and a context.
"""
Expand Down
Loading

0 comments on commit 8d5f893

Please sign in to comment.