dave3d / dicom2stl

Python script to extract a STL surface from a DICOM image series.
196 stars 68 forks source link

Program stuck at decimation step #22

Open Shaokun-X opened 3 years ago

Shaokun-X commented 3 years ago

The program stuck at line 174 in vtkutils.py:

def reduceMesh(mymesh, reductionFactor):
    """Reduce the number of triangles in a mesh using VTK's QuadricDecimation
    filter."""
    try:
        t = time.perf_counter()
        deci = vtk.vtkQuadricDecimation()
        deci.SetTargetReduction(reductionFactor)
        if vtk.vtkVersion.GetVTKMajorVersion() >= 6:
            deci.SetInputData(mymesh)
        else:
            deci.SetInput(mymesh)
        deci.Update()
        # ......

I checked the official documentation, in the given example it uses vtk.vtkDecimatePro() instead of vtk.vtkQuadricDecimation(), and this fixes the problem.

My environment:

OS: Windows 10
CPU: AMD
VTK: 9.0.2 installed via pip
Python: 3.8.3
dave3d commented 3 years ago

Interesting. I never had any problem with the quadric decimation filter. It probably depends on the particular data set. I could make it an option, which algorithm to use.

I always preferred the quadric decimation because I though it was a cool algorithm, and my friend wrote the VTK class.