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

Function toVTKAssy

cadquery/occ_impl/assembly.py:623–670  ·  view source on GitHub ↗
(
    assy: AssemblyProtocol,
    color: Tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0),
    edgecolor: Tuple[float, float, float, float] = (0.0, 0.0, 0.0, 0.0),
    edges: bool = True,
    linewidth: float = 2,
    tolerance: float = 1e-3,
    angularTolerance: float = 0.1,
)

Source from the content-addressed store, hash-verified

621
622
623def toVTKAssy(
624 assy: AssemblyProtocol,
625 color: Tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0),
626 edgecolor: Tuple[float, float, float, float] = (0.0, 0.0, 0.0, 0.0),
627 edges: bool = True,
628 linewidth: float = 2,
629 tolerance: float = 1e-3,
630 angularTolerance: float = 0.1,
631) -> List[vtkProp3D]:
632
633 rv: List[vtkProp3D] = []
634
635 for shape, _, loc, col_ in assy:
636
637 col = col_.toTuple() if col_ else color
638
639 trans, rot = _loc2vtk(loc)
640
641 data = shape.toVtkPolyData(tolerance, angularTolerance)
642 data_edges, data_faces = extractEdgesFaces(data)
643
644 # add both to the vtkAssy
645 mapper = vtkMapper()
646 mapper.AddInputDataObject(data_faces)
647
648 actor = vtkActor()
649 actor.SetMapper(mapper)
650 actor.SetPosition(*trans)
651 actor.SetOrientation(*rot)
652 actor.GetProperty().SetColor(*col[:3])
653 actor.GetProperty().SetOpacity(col[3])
654
655 rv.append(actor)
656
657 mapper = vtkMapper()
658 mapper.AddInputDataObject(data_edges)
659
660 actor = vtkActor()
661 actor.SetMapper(mapper)
662 actor.SetPosition(*trans)
663 actor.SetOrientation(*rot)
664 actor.GetProperty().SetLineWidth(linewidth)
665 actor.SetVisibility(edges)
666 actor.GetProperty().SetColor(*edgecolor[:3])
667
668 rv.append(actor)
669
670 return rv
671
672
673def toVTK(

Callers 2

_to_vtk_shapesFunction · 0.85
showFunction · 0.85

Calls 6

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

Tested by

no test coverage detected