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

Method toVtkPolyData

cadquery/occ_impl/shapes.py:1675–1721  ·  view source on GitHub ↗

Convert shape to vtkPolyData

(
        self,
        tolerance: float | None = None,
        angularTolerance: float | None = None,
        normals: bool = False,
    )

Source from the content-addressed store, hash-verified

1673 return self.__class__(bldr.Shape())
1674
1675 def toVtkPolyData(
1676 self,
1677 tolerance: float | None = None,
1678 angularTolerance: float | None = None,
1679 normals: bool = False,
1680 ) -> vtkPolyData:
1681 """
1682 Convert shape to vtkPolyData
1683 """
1684
1685 vtk_shape = IVtkOCC_Shape(self.wrapped)
1686 shape_data = IVtkVTK_ShapeData()
1687 shape_mesher = IVtkOCC_ShapeMesher()
1688
1689 drawer = vtk_shape.Attributes()
1690 drawer.SetUIsoAspect(Prs3d_IsoAspect(Quantity_Color(), Aspect_TOL_SOLID, 1, 0))
1691 drawer.SetVIsoAspect(Prs3d_IsoAspect(Quantity_Color(), Aspect_TOL_SOLID, 1, 0))
1692
1693 if tolerance:
1694 drawer.SetDeviationCoefficient(tolerance)
1695
1696 if angularTolerance:
1697 drawer.SetDeviationAngle(angularTolerance)
1698
1699 shape_mesher.Build(vtk_shape, shape_data)
1700
1701 rv = shape_data.getVtkPolyData()
1702
1703 # convert to triangles and split edges
1704 t_filter = vtkTriangleFilter()
1705 t_filter.SetInputData(rv)
1706 t_filter.Update()
1707
1708 rv = t_filter.GetOutput()
1709
1710 # compute normals
1711 if normals:
1712 n_filter = vtkPolyDataNormals()
1713 n_filter.SetComputePointNormals(True)
1714 n_filter.SetComputeCellNormals(True)
1715 n_filter.SetFeatureAngle(360)
1716 n_filter.SetInputData(rv)
1717 n_filter.Update()
1718
1719 rv = n_filter.GetOutput()
1720
1721 return rv
1722
1723 def _repr_javascript_(self) -> str:
1724 """

Callers 5

toVTKAssyFunction · 0.80
toVTKFunction · 0.80
exportVTPFunction · 0.80
toStringFunction · 0.80
test_toVtkMethod · 0.80

Calls 1

UpdateMethod · 0.80

Tested by 1

test_toVtkMethod · 0.64