Skip to content

Commit b23e036

Browse files
committed
Added the ability for the user to adjust the tolerance and angular tolerance of VRML tessellation
1 parent 12acb29 commit b23e036

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

cadquery/occ_impl/assembly.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def toVTK(
179179
loc: Location = Location(),
180180
color: Tuple[float, float, float, float] = (1.0, 1.0, 1.0, 1.0),
181181
tolerance: float = 1e-3,
182+
angularTolerance: float = 0.1
182183
) -> vtkRenderer:
183184

184185
loc = loc * assy.loc
@@ -188,7 +189,7 @@ def toVTK(
188189
color = assy.color.toTuple()
189190

190191
if assy.shapes:
191-
data = Compound.makeCompound(assy.shapes).toVtkPolyData(tolerance)
192+
data = Compound.makeCompound(assy.shapes).toVtkPolyData(tolerance, angularTolerance)
192193

193194
mapper = vtkMapper()
194195
mapper.SetInputData(data)

cadquery/occ_impl/exporters/assembly.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,15 @@ def exportCAF(assy: AssemblyProtocol, path: str) -> bool:
7979
return status == PCDM_StoreStatus.PCDM_SS_OK
8080

8181

82-
def _vtkRenderWindow(assy: AssemblyProtocol) -> vtkRenderWindow:
82+
def _vtkRenderWindow(assy: AssemblyProtocol, tolerance: float, angularTolerance: float) -> vtkRenderWindow:
8383
"""
8484
Convert an assembly to a vtkRenderWindow. Used by vtk based exporters.
8585
"""
8686

8787
renderer = vtkRenderer()
8888
renderWindow = vtkRenderWindow()
8989
renderWindow.AddRenderer(renderer)
90-
toVTK(assy, renderer)
90+
toVTK(assy, renderer, tolerance=tolerance, angularTolerance=angularTolerance)
9191

9292
renderer.ResetCamera()
9393
renderer.SetBackground(1, 1, 1)
@@ -111,14 +111,14 @@ def exportVTKJS(assy: AssemblyProtocol, path: str):
111111
make_archive(path, "zip", tmpdir)
112112

113113

114-
def exportVRML(assy: AssemblyProtocol, path: str):
114+
def exportVRML(assy: AssemblyProtocol, path: str, tolerance: float, angularTolerance: float):
115115
"""
116116
Export an assembly to a vrml file using vtk.
117117
"""
118118

119119
exporter = vtkVRMLExporter()
120120
exporter.SetFileName(path)
121-
exporter.SetRenderWindow(_vtkRenderWindow(assy))
121+
exporter.SetRenderWindow(_vtkRenderWindow(assy, tolerance, angularTolerance))
122122
exporter.Write()
123123

124124

0 commit comments

Comments
 (0)