MCPcopy
hub / github.com/CadQuery/cadquery / cast

Method cast

cadquery/occ_impl/shapes.py:460–482  ·  view source on GitHub ↗

Returns the right type of wrapper, given a OCCT object

(cls, obj: TopoDS_Shape, forConstruction: bool = False)

Source from the content-addressed store, hash-verified

458
459 @classmethod
460 def cast(cls, obj: TopoDS_Shape, forConstruction: bool = False) -> Shape:
461 "Returns the right type of wrapper, given a OCCT object"
462
463 tr = None
464
465 # define the shape lookup table for casting
466 constructor_LUT = {
467 ta.TopAbs_VERTEX: Vertex,
468 ta.TopAbs_EDGE: Edge,
469 ta.TopAbs_WIRE: Wire,
470 ta.TopAbs_FACE: Face,
471 ta.TopAbs_SHELL: Shell,
472 ta.TopAbs_SOLID: Solid,
473 ta.TopAbs_COMPSOLID: CompSolid,
474 ta.TopAbs_COMPOUND: Compound,
475 }
476
477 t = shapetype(obj)
478 # NB downcast is needed to handle TopoDS_Shape types
479 tr = constructor_LUT[t](downcast(obj))
480 tr.forConstruction = forConstruction
481
482 return tr
483
484 def exportStl(
485 self,

Callers 15

reverseMethod · 0.95
importBrepMethod · 0.80
importBinMethod · 0.80
_entitiesFromMethod · 0.80
transformShapeMethod · 0.80
transformGeometryMethod · 0.80
_bool_opMethod · 0.80
__iter__Method · 0.80
ancestorsMethod · 0.80
_siblingsMethod · 0.80
makeRuledSurfaceMethod · 0.80
sweepMethod · 0.80

Calls 2

shapetypeFunction · 0.85
downcastFunction · 0.85

Tested by 4

_make_circleMethod · 0.64
_make_ellipseMethod · 0.64
testVerticesMethod · 0.64
testCompSolidMethod · 0.64