@@ -61,27 +61,64 @@ class BRep:
6161
6262 Attributes
6363 ----------
64- shape : ``TopoDS_Shape``
65- The underlying OCC shape of the BRep.
66- type : ``TopAbs_ShapeEnum``, read-only
67- The type of BRep shape.
68- vertices : list[:class:`compas_occ.brep.BRepVertex`], read-only
64+ vertices : list[:class:`~compas_occ.brep.BRepVertex`], read-only
6965 The vertices of the BRep.
70- edges : list[:class:`compas_occ.brep.BRepEdge`], read-only
66+ edges : list[:class:`~ compas_occ.brep.BRepEdge`], read-only
7167 The edges of the BRep.
72- loops : list[:class:`compas_occ.brep.BRepLoop`], read-only
68+ loops : list[:class:`~ compas_occ.brep.BRepLoop`], read-only
7369 The loops of the BRep.
74- faces : list[:class:`compas_occ.brep.BRepFace`], read-only
70+ faces : list[:class:`~ compas_occ.brep.BRepFace`], read-only
7571 The faces of the BRep.
76- orientation : TopAbs_Orientation, read-only
77- Orientation of the shape.
78- frame : :class:`compas.geometry.Frame`, read-only
72+ frame : :class:`~compas.geometry.Frame`, read-only
7973 The local coordinate system of the BRep.
8074 area : float, read-only
8175 The surface area of the BRep.
8276 volume : float, read-only
8377 The volume of the regions contained by the BRep.
8478
79+ Other Attributes
80+ ----------------
81+ shape : ``TopoDS_Shape``
82+ The underlying OCC shape of the BRep.
83+ type : ``TopAbs_ShapeEnum``, read-only
84+ The type of BRep shape.
85+ orientation : ``TopAbs_Orientation``, read-only
86+ Orientation of the shape.
87+
88+ Examples
89+ --------
90+ Constructors
91+
92+ >>> brep = BRep.from_corners([0, 0, 0], [1, 0, 0], [1, 1, 1], [1, 1, 0])
93+
94+ >>> from compas.geometry import Box
95+ >>> box = Box.from_width_height_depth(1, 1, 1)
96+ >>> vertices, faces = box.to_vertices_and_faces()
97+ >>> polygons = [[vertices[index] for index in face] for face in faces]
98+ >>> brep = BRep.from_polygons(polygons)
99+
100+ >>> from compas.geometry import Box
101+ >>> box = Box.from_width_height_depth(1, 1, 1)
102+ >>> brep = BRep.from_box(box)
103+
104+ >>> from compas.geometry import Box, Sphere
105+ >>> box = Box.from_width_height_depth(1, 1, 1)
106+ >>> sphere = Sphere([1, 1, 1], 0.5)
107+ >>> A = BRep.from_box(box)
108+ >>> B = BRep.from_sphere(sphere)
109+ >>> brep = BRep.from_boolean_union(A, B)
110+
111+ Booleans
112+
113+ >>> from compas.geometry import Box, Sphere
114+ >>> box = Box.from_width_height_depth(1, 1, 1)
115+ >>> sphere = Sphere([1, 1, 1], 0.5)
116+ >>> A = BRep.from_box(box)
117+ >>> B = BRep.from_sphere(sphere)
118+ >>> C = A + B
119+ >>> D = A - B
120+ >>> E = A & B
121+
85122 """
86123
87124 def __init__ (self ) -> None :
@@ -91,8 +128,53 @@ def __init__(self) -> None:
91128 # Customization
92129 # ==============================================================================
93130
94- # def __eq__(self, other):
95- # pass
131+ def __add__ (self , other ):
132+ """Compute the boolean union using the "+" operator of this BRep and another.
133+
134+ Parameters
135+ ----------
136+ other : :class:`compas_occ.brep.BRep`
137+ The BRep to add.
138+
139+ Returns
140+ -------
141+ :class:`compas_occ.brep.BRep`
142+ The resulting BRep.
143+
144+ """
145+ return BRep .from_boolean_union (self , other )
146+
147+ def __sub__ (self , other ):
148+ """Compute the boolean difference using the "-" operator of this shape and another.
149+
150+ Parameters
151+ ----------
152+ other : :class:`compas_occ.brep.BRep`
153+ The BRep to subtract.
154+
155+ Returns
156+ -------
157+ :class:`compas_occ.brep.BRep`
158+ The resulting BRep.
159+
160+ """
161+ return BRep .from_boolean_difference (self , other )
162+
163+ def __and__ (self , other ):
164+ """Compute the boolean intersection using the "&" operator of this shape and another.
165+
166+ Parameters
167+ ----------
168+ other : :class:`compas_occ.brep.BRep`
169+ The BRep to intersect with.
170+
171+ Returns
172+ -------
173+ :class:`compas_occ.brep.BRep`
174+ The resulting BRep.
175+
176+ """
177+ return BRep .from_boolean_intersection (self , other )
96178
97179 # ==============================================================================
98180 # Properties
@@ -192,14 +274,14 @@ def from_corners(cls,
192274
193275 Parameters
194276 ----------
195- p1 : :class:`compas.geometry.Point`
196- p2 : :class:`compas.geometry.Point`
197- p3 : :class:`compas.geometry.Point`
198- p4 : :class:`compas.geometry.Point`, optional
277+ p1 : :class:`~ compas.geometry.Point`
278+ p2 : :class:`~ compas.geometry.Point`
279+ p3 : :class:`~ compas.geometry.Point`
280+ p4 : :class:`~ compas.geometry.Point`, optional
199281
200282 Returns
201283 -------
202- :class:`compas_occ.brep.BRep`
284+ :class:`~ compas_occ.brep.BRep`
203285
204286 """
205287 if not p4 :
@@ -216,11 +298,11 @@ def from_polygons(cls, polygons: List[compas.geometry.Polygon]) -> 'BRep':
216298
217299 Parameters
218300 ----------
219- polygons : list[:class:`compas.geometry.Polygon`]
301+ polygons : list[:class:`~ compas.geometry.Polygon`]
220302
221303 Returns
222304 -------
223- :class:`compas_occ.brep.BRep`
305+ :class:`~ compas_occ.brep.BRep`
224306
225307 """
226308 shell = TopoDS_Shell ()
@@ -243,11 +325,11 @@ def from_curves(cls, curves: List[compas.geometry.NurbsCurve]) -> 'BRep':
243325
244326 Parameters
245327 ----------
246- curves : list[:class:`compas.geometry.NurbsCurve`]
328+ curves : list[:class:`~ compas.geometry.NurbsCurve`]
247329
248330 Returns
249331 -------
250- :class:`compas_occ.brep.BRep`
332+ :class:`~ compas_occ.brep.BRep`
251333
252334 """
253335 raise NotImplementedError
@@ -258,11 +340,11 @@ def from_box(cls, box: compas.geometry.Box) -> 'BRep':
258340
259341 Parameters
260342 ----------
261- box : :class:`compas.geometry.Box`
343+ box : :class:`~ compas.geometry.Box`
262344
263345 Returns
264346 -------
265- :class:`compas_occ.brep.BRep`
347+ :class:`~ compas_occ.brep.BRep`
266348
267349 """
268350 xaxis = box .frame .xaxis .scaled (- 0.5 * box .xsize )
@@ -280,11 +362,11 @@ def from_sphere(cls, sphere: compas.geometry.Sphere) -> 'BRep':
280362
281363 Parameters
282364 ----------
283- sphere : :class:`compas.geometry.Sphere`
365+ sphere : :class:`~ compas.geometry.Sphere`
284366
285367 Returns
286368 -------
287- :class:`compas_occ.brep.BRep`
369+ :class:`~ compas_occ.brep.BRep`
288370
289371 """
290372 brep = BRep ()
@@ -297,11 +379,11 @@ def from_cylinder(cls, cylinder: compas.geometry.Cylinder) -> 'BRep':
297379
298380 Parameters
299381 ----------
300- cylinder : :class:`compas.geometry.Cylinder`
382+ cylinder : :class:`~ compas.geometry.Cylinder`
301383
302384 Returns
303385 -------
304- :class:`compas_occ.brep.BRep`
386+ :class:`~ compas_occ.brep.BRep`
305387
306388 """
307389 plane = cylinder .circle .plane
@@ -320,11 +402,11 @@ def from_cone(cls, cone: compas.geometry.Cone) -> 'BRep':
320402
321403 Parameters
322404 ----------
323- cone : :class:`compas.geometry.Cone`
405+ cone : :class:`~ compas.geometry.Cone`
324406
325407 Returns
326408 -------
327- :class:`compas_occ.brep.BRep`
409+ :class:`~ compas_occ.brep.BRep`
328410
329411 """
330412 raise NotImplementedError
@@ -335,11 +417,11 @@ def from_torus(cls, torus: compas.geometry.Torus) -> 'BRep':
335417
336418 Parameters
337419 ----------
338- torus : :class:`compas.geometry.Torus`
420+ torus : :class:`~ compas.geometry.Torus`
339421
340422 Returns
341423 -------
342- :class:`compas_occ.brep.BRep`
424+ :class:`~ compas_occ.brep.BRep`
343425
344426 """
345427 raise NotImplementedError
@@ -350,12 +432,12 @@ def from_boolean_difference(cls, A: 'BRep', B: 'BRep') -> 'BRep':
350432
351433 Parameters
352434 ----------
353- A : :class:`compas_occ.brep.BRep`
354- B : :class:`compas_occ.brep.BRep`
435+ A : :class:`~ compas_occ.brep.BRep`
436+ B : :class:`~ compas_occ.brep.BRep`
355437
356438 Returns
357439 -------
358- :class:`compas_occ.brep.BRep`
440+ :class:`~ compas_occ.brep.BRep`
359441
360442 """
361443 cut = BRepAlgoAPI_Cut (A .shape , B .shape )
@@ -371,12 +453,12 @@ def from_boolean_intersection(cls, A: 'BRep', B: 'BRep') -> 'BRep':
371453
372454 Parameters
373455 ----------
374- A : :class:`compas_occ.brep.BRep`
375- B : :class:`compas_occ.brep.BRep`
456+ A : :class:`~ compas_occ.brep.BRep`
457+ B : :class:`~ compas_occ.brep.BRep`
376458
377459 Returns
378460 -------
379- :class:`compas_occ.brep.BRep`
461+ :class:`~ compas_occ.brep.BRep`
380462
381463 """
382464 common = BRepAlgoAPI_Common (A .shape , B .shape )
@@ -392,12 +474,12 @@ def from_boolean_union(cls, A, B) -> 'BRep':
392474
393475 Parameters
394476 ----------
395- A : :class:`compas_occ.brep.BRep`
396- B : :class:`compas_occ.brep.BRep`
477+ A : :class:`~ compas_occ.brep.BRep`
478+ B : :class:`~ compas_occ.brep.BRep`
397479
398480 Returns
399481 -------
400- :class:`compas_occ.brep.BRep`
482+ :class:`~ compas_occ.brep.BRep`
401483
402484 """
403485 fuse = BRepAlgoAPI_Fuse (A .shape , B .shape )
@@ -413,11 +495,11 @@ def from_mesh(cls, mesh: compas.datastructures.Mesh) -> 'BRep':
413495
414496 Parameters
415497 ----------
416- mesh : :class:`compas.datastructures.Mesh`
498+ mesh : :class:`~ compas.datastructures.Mesh`
417499
418500 Returns
419501 -------
420- :class:`compas_occ.brep.BRep`
502+ :class:`~ compas_occ.brep.BRep`
421503
422504 """
423505 shell = TopoDS_Shell ()
@@ -488,7 +570,7 @@ def to_tesselation(self) -> Mesh:
488570
489571 Returns
490572 -------
491- :class:`compas.datastructures.Mesh`
573+ :class:`~ compas.datastructures.Mesh`
492574
493575 """
494576 tesselation = ShapeTesselator (self .shape )
@@ -509,7 +591,7 @@ def to_meshes(self, u=16, v=16):
509591
510592 Returns
511593 -------
512- list[:class:`compas.datastructures.Mesh`]
594+ list[:class:`~ compas.datastructures.Mesh`]
513595
514596 """
515597 converter = BRepBuilderAPI_NurbsConvert (self .shape , False )
@@ -676,12 +758,12 @@ def contours(self,
676758
677759 Parameters
678760 ----------
679- planes : list[:class:`compas.geometry.Plane`]
761+ planes : list[:class:`~ compas.geometry.Plane`]
680762 The slicing planes.
681763
682764 Returns
683765 -------
684- list[list[:class:`compas.geometry.Polyline`]]
766+ list[list[:class:`~ compas.geometry.Polyline`]]
685767 A list of polylines per plane.
686768
687769 """
0 commit comments