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

Function toVTK

cadquery/occ_impl/assembly.py:673–715  ·  view source on GitHub ↗
(
    assy: AssemblyProtocol,
    color: Tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0),
    tolerance: float = 1e-3,
    angularTolerance: float = 0.1,
)

Source from the content-addressed store, hash-verified

671
672
673def toVTK(
674 assy: AssemblyProtocol,
675 color: Tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0),
676 tolerance: float = 1e-3,
677 angularTolerance: float = 0.1,
678) -> vtkRenderer:
679
680 renderer = vtkRenderer()
681
682 for shape, _, loc, col_ in assy:
683
684 col = col_.toTuple() if col_ else color
685
686 trans, rot = _loc2vtk(loc)
687
688 # convert to vtkPolyData and split into edges/faces
689 data = shape.toVtkPolyData(tolerance, angularTolerance)
690 data_edges, data_faces = extractEdgesFaces(data)
691
692 # add both to the renderer
693 mapper = vtkMapper()
694 mapper.AddInputDataObject(data_faces)
695
696 actor = vtkActor()
697 actor.SetMapper(mapper)
698 actor.SetPosition(*trans)
699 actor.SetOrientation(*rot)
700 actor.GetProperty().SetColor(*col[:3])
701 actor.GetProperty().SetOpacity(col[3])
702
703 renderer.AddActor(actor)
704
705 mapper = vtkMapper()
706 mapper.AddInputDataObject(data_edges)
707
708 actor = vtkActor()
709 actor.SetMapper(mapper)
710 actor.SetPosition(*trans)
711 actor.SetOrientation(*rot)
712
713 renderer.AddActor(actor)
714
715 return renderer
716
717
718def toJSON(

Callers 2

test_toVTKFunction · 0.90
_vtkRenderWindowFunction · 0.85

Calls 5

_loc2vtkFunction · 0.85
extractEdgesFacesFunction · 0.85
toVtkPolyDataMethod · 0.80
SetPositionMethod · 0.80
toTupleMethod · 0.45

Tested by 1

test_toVTKFunction · 0.72