1- from typing import List , Tuple , Union , Optional
1+ from typing import List
2+ from typing import Optional
3+ from typing import Tuple
4+ from typing import Union
25
3- import compas .geometry
46import compas .datastructures
5-
6- from compas .geometry import Vector
7+ import compas .geometry
8+ from compas .datastructures import Mesh
9+ from compas .geometry import Brep
710from compas .geometry import Frame
8- from compas .geometry import Translation
11+ from compas .geometry import Plane
912from compas .geometry import Point
10- from compas .geometry import Polyline
1113from compas .geometry import Polygon
12- from compas .geometry import Plane
13- from compas .datastructures import Mesh
14- from compas .geometry import Brep
15-
14+ from compas .geometry import Polyline
15+ from compas .geometry import Translation
16+ from compas .geometry import Vector
1617from OCC .Core import BOPAlgo
17- from OCC .Core import BRepAlgoAPI
1818from OCC .Core import BRep
19+ from OCC .Core import BRepAlgoAPI
1920from OCC .Core import BRepBuilderAPI
2021from OCC .Core import BRepCheck
2122from OCC .Core import BRepExtrema
2223from OCC .Core import BRepFilletAPI
2324from OCC .Core import BRepGProp
2425from OCC .Core import BRepMesh
2526from OCC .Core import BRepPrimAPI
26- from OCC .Core import gp
2727from OCC .Core import GProp
2828from OCC .Core import IFSelect
2929from OCC .Core import IGESControl
3636from OCC .Core import TopLoc
3737from OCC .Core import TopoDS
3838from OCC .Core import TopTools
39-
39+ from OCC . Core import gp
4040from OCC .Extend import DataExchange
4141
42- from compas_occ .conversions import triangle_to_face
43- from compas_occ .conversions import quad_to_face
44- from compas_occ .conversions import ngon_to_face
4542from compas_occ .conversions import compas_transformation_to_trsf
43+ from compas_occ .conversions import frame_to_occ_ax2
44+ from compas_occ .conversions import location_to_compas
45+ from compas_occ .conversions import ngon_to_face
4646from compas_occ .conversions import point_to_compas
47+ from compas_occ .conversions import quad_to_face
48+ from compas_occ .conversions import triangle_to_face
4749from compas_occ .conversions import vector_to_occ
48- from compas_occ .conversions import location_to_compas
49- from compas_occ .conversions import frame_to_occ_ax2
5050from compas_occ .geometry import OCCNurbsSurface
5151
52- from .errors import BrepFilletError
53-
54- from .brepvertex import OCCBrepVertex
5552from .brepedge import OCCBrepEdge
56- from .breploop import OCCBrepLoop
5753from .brepface import OCCBrepFace
54+ from .breploop import OCCBrepLoop
55+ from .brepvertex import OCCBrepVertex
56+ from .errors import BrepFilletError
5857
5958
6059class OCCBrep (Brep ):
@@ -563,9 +562,7 @@ def from_box(cls, box: compas.geometry.Box) -> "OCCBrep":
563562 zaxis = box .frame .zaxis .scaled (- 0.5 * box .zsize )
564563 frame = box .frame .transformed (Translation .from_vector (xaxis + yaxis + zaxis ))
565564 ax2 = frame_to_occ_ax2 (frame ) # type: ignore
566- shape = BRepPrimAPI .BRepPrimAPI_MakeBox (
567- ax2 , box .xsize , box .ysize , box .zsize
568- ).Shape ()
565+ shape = BRepPrimAPI .BRepPrimAPI_MakeBox (ax2 , box .xsize , box .ysize , box .zsize ).Shape ()
569566 return cls .from_native (shape )
570567
571568 @classmethod
@@ -582,9 +579,7 @@ def from_sphere(cls, sphere: compas.geometry.Sphere) -> "OCCBrep":
582579 :class:`~compas_occ.brep.OCCBrep`
583580
584581 """
585- shape = BRepPrimAPI .BRepPrimAPI_MakeSphere (
586- gp .gp_Pnt (* sphere .frame .point ), sphere .radius
587- ).Shape ()
582+ shape = BRepPrimAPI .BRepPrimAPI_MakeSphere (gp .gp_Pnt (* sphere .frame .point ), sphere .radius ).Shape ()
588583 return cls .from_native (shape )
589584
590585 @classmethod
@@ -642,9 +637,7 @@ def from_torus(cls, torus: compas.geometry.Torus) -> "OCCBrep":
642637 raise NotImplementedError
643638
644639 @classmethod
645- def from_mesh (
646- cls , mesh : compas .datastructures .Mesh , solid : bool = True
647- ) -> "OCCBrep" :
640+ def from_mesh (cls , mesh : compas .datastructures .Mesh , solid : bool = True ) -> "OCCBrep" :
648641 """
649642 Construct a BRep from a COMPAS mesh.
650643
@@ -909,9 +902,7 @@ def from_boolean_union(cls, A: "OCCBrep", B: "OCCBrep") -> "OCCBrep":
909902 # Converters
910903 # ==============================================================================
911904
912- def to_tesselation (
913- self , linear_deflection : float = 1
914- ) -> Tuple [Mesh , List [Polyline ]]:
905+ def to_tesselation (self , linear_deflection : float = 1 ) -> Tuple [Mesh , List [Polyline ]]:
915906 """
916907 Create a tesselation of the shape for visualisation.
917908
@@ -955,9 +946,7 @@ def to_tesselation(
955946 if any (edge .is_same (e ) for e in seen ):
956947 continue
957948 seen .append (edge )
958- pot = bt .PolygonOnTriangulation (
959- edge .occ_edge , triangulation , location
960- )
949+ pot = bt .PolygonOnTriangulation (edge .occ_edge , triangulation , location )
961950 if pot is None :
962951 continue
963952 points = []
@@ -971,9 +960,7 @@ def to_tesselation(
971960 if any (edge .is_same (e ) for e in seen ):
972961 continue
973962 if edge .is_line :
974- lines .append (
975- Polyline ([edge .vertices [0 ].point , edge .vertices [- 1 ].point ])
976- )
963+ lines .append (Polyline ([edge .vertices [0 ].point , edge .vertices [- 1 ].point ]))
977964 elif edge .is_circle :
978965 lines .append (edge .curve .to_polyline ())
979966 elif edge .is_ellipse :
@@ -1042,9 +1029,7 @@ def vertex_neighbors(self, vertex: OCCBrepVertex) -> List[OCCBrepVertex]:
10421029
10431030 """
10441031 map = TopTools .TopTools_IndexedDataMapOfShapeListOfShape ()
1045- TopExp .topexp_MapShapesAndUniqueAncestors (
1046- self .occ_shape , TopAbs .TopAbs_VERTEX , TopAbs .TopAbs_EDGE , map
1047- )
1032+ TopExp .topexp_MapShapesAndUniqueAncestors (self .occ_shape , TopAbs .TopAbs_VERTEX , TopAbs .TopAbs_EDGE , map )
10481033 results = map .FindFromKey (vertex .occ_vertex )
10491034 iterator = TopTools .TopTools_ListIteratorOfListOfShape (results ) # type: ignore
10501035 vertices = []
@@ -1072,9 +1057,7 @@ def vertex_edges(self, vertex: OCCBrepVertex) -> List[OCCBrepEdge]:
10721057
10731058 """
10741059 map = TopTools .TopTools_IndexedDataMapOfShapeListOfShape ()
1075- TopExp .topexp_MapShapesAndUniqueAncestors (
1076- self .occ_shape , TopAbs .TopAbs_VERTEX , TopAbs .TopAbs_EDGE , map
1077- )
1060+ TopExp .topexp_MapShapesAndUniqueAncestors (self .occ_shape , TopAbs .TopAbs_VERTEX , TopAbs .TopAbs_EDGE , map )
10781061 results = map .FindFromKey (vertex .occ_vertex )
10791062 iterator = TopTools .TopTools_ListIteratorOfListOfShape (results ) # type: ignore
10801063 edges = []
@@ -1098,9 +1081,7 @@ def vertex_faces(self, vertex: OCCBrepVertex) -> List[OCCBrepFace]:
10981081
10991082 """
11001083 map = TopTools .TopTools_IndexedDataMapOfShapeListOfShape ()
1101- TopExp .topexp_MapShapesAndUniqueAncestors (
1102- self .occ_shape , TopAbs .TopAbs_VERTEX , TopAbs .TopAbs_FACE , map
1103- )
1084+ TopExp .topexp_MapShapesAndUniqueAncestors (self .occ_shape , TopAbs .TopAbs_VERTEX , TopAbs .TopAbs_FACE , map )
11041085 results = map .FindFromKey (vertex .occ_vertex )
11051086 iterator = TopTools .TopTools_ListIteratorOfListOfShape (results ) # type: ignore
11061087 faces = []
@@ -1124,9 +1105,7 @@ def edge_faces(self, edge: OCCBrepEdge) -> List[OCCBrepFace]:
11241105
11251106 """
11261107 map = TopTools .TopTools_IndexedDataMapOfShapeListOfShape ()
1127- TopExp .topexp_MapShapesAndUniqueAncestors (
1128- self .occ_shape , TopAbs .TopAbs_EDGE , TopAbs .TopAbs_FACE , map
1129- )
1108+ TopExp .topexp_MapShapesAndUniqueAncestors (self .occ_shape , TopAbs .TopAbs_EDGE , TopAbs .TopAbs_FACE , map )
11301109 results = map .FindFromKey (edge .occ_edge )
11311110 iterator = TopTools .TopTools_ListIteratorOfListOfShape (results ) # type: ignore
11321111 faces = []
@@ -1152,9 +1131,7 @@ def edge_loops(self, edge: OCCBrepEdge) -> List[OCCBrepLoop]:
11521131 """
11531132
11541133 map = TopTools .TopTools_IndexedDataMapOfShapeListOfShape ()
1155- TopExp .topexp_MapShapesAndUniqueAncestors (
1156- self .occ_shape , TopAbs .TopAbs_EDGE , TopAbs .TopAbs_WIRE , map
1157- )
1134+ TopExp .topexp_MapShapesAndUniqueAncestors (self .occ_shape , TopAbs .TopAbs_EDGE , TopAbs .TopAbs_WIRE , map )
11581135 results = map .FindFromKey (edge .occ_edge )
11591136 iterator = TopTools .TopTools_ListIteratorOfListOfShape (results ) # type: ignore
11601137 loops = []
@@ -1332,9 +1309,7 @@ def transformed(self, matrix: compas.geometry.Transformation) -> "OCCBrep":
13321309 shape = builder .ModifiedShape (self .occ_shape )
13331310 return OCCBrep .from_shape (shape )
13341311
1335- def contours (
1336- self , planes : List [compas .geometry .Plane ]
1337- ) -> List [List [compas .geometry .Polyline ]]:
1312+ def contours (self , planes : List [compas .geometry .Plane ]) -> List [List [compas .geometry .Polyline ]]:
13381313 """
13391314 Generate contour lines by slicing the BRep shape with a series of planes.
13401315
@@ -1438,10 +1413,11 @@ def trim(self, plane: compas.geometry.Plane) -> None:
14381413 None
14391414
14401415 """
1441- from compas_occ .occ import split_shapes
1442- from compas_occ .occ import compute_shape_centreofmass
14431416 from compas .geometry import is_point_behind_plane
14441417
1418+ from compas_occ .occ import compute_shape_centreofmass
1419+ from compas_occ .occ import split_shapes
1420+
14451421 if isinstance (plane , Frame ):
14461422 plane = Plane .from_frame (plane )
14471423
@@ -1540,9 +1516,7 @@ def fillet(
15401516 else :
15411517 raise BrepFilletError ("Fillet operation could not be completed." )
15421518
1543- def filleted (
1544- self , radius : float , exclude : Optional [List [OCCBrepEdge ]] = None
1545- ) -> "OCCBrep" :
1519+ def filleted (self , radius : float , exclude : Optional [List [OCCBrepEdge ]] = None ) -> "OCCBrep" :
15461520 """Construct a copy of a Brep with filleted edges.
15471521
15481522 Parameters
0 commit comments