Foreword: This blog post mainly records the problems that occur when vtkPolyPlane is used as a cutting tool in vtkClipPolyData, for your reference and avoid stepping on the pit!
Table of contents
Introduction and function of vtkPolyPlane
Requirements: Cut a cube consisting of eight points and 12 triangular patches (vtkPolyPlane is a polyline of the XY plane)
The ideal result is as follows:
The actual result is as follows:
Introduction and function of vtkPolyPlane
For an introduction to vtkPolyPlane, please refer to VTK Clipping [2] - Introduction to vtkImplicitFunction and its subclasses_setnumberoftuples_Xueyi's Blog-CSDN Blog
Principle of vtkClipPolyData
For an introduction to the working principle of vtkClipPolyData, and the difference between vtkClipPolyData and vtkClipClosedSurface, please see the summary of Clip/Trim in VTK - Xueyi Blog - CSDN Blog
Implementation process:
1. vtkPolyPlane is the surface formed by stretching the PolyLine (polyline) of the XY plane along the Z axis.
2. Calculate the value of each point to vtkPolyPlane, if projected to the XY plane for observation, it is
3. Segment the lines and polygons that need to be segmented.
For the line: if the values of the two points are both >0, keep it; if the value of the two points is <0, discard it; if one is >0 and the other is <0, divide according to the value and create an interpolation point.
For triangular patches: split them into lines for point interpolation.
problem lies in:
For the triangular patch composed of three points with value (26, 45, 48), there is no need to subdivide according to the above logic, so there will be problems.