OpenHeartDevelopers / CemrgApp

An Interactive Medical Imaging Platform with Image Processing and Computer Vision Toolkits for Cardiovascular Research.
http://www.cemrgapp.com
BSD 3-Clause "New" or "Revised" License
18 stars 8 forks source link

[WathCa] The app quits unexpectedly after clipping PVs #18

Closed alonsoJASL closed 4 years ago

alonsoJASL commented 4 years ago

This issue was originally reported in #17 and reported by @dariadg

After doing a couple of cases, the App would quit.

OrodRazeghi commented 4 years ago

As the tested, the issue is most likely due to failure of generating centrelines or clipper planes. A number of safeguards are now added to alert the user, if the process fails. It may still be necessary to reevaluate the meshing tool used at the moment for clipping the veins.

OrodRazeghi commented 4 years ago

So, it seems that the crash can occur when the user clicks on clipper planes button in the PV clipper view. Debugging the code shows that segmentation fault is caused by the vtkvmtkPolyDataCenterlineSections filter:

vtkSmartPointer ctrLineSects; ctrLineSects->SetInputData(surface->GetVtkPolyData()); ctrLineSects->SetCenterlines(line); ctrLineSects->SetCenterlineSectionAreaArrayName("CentrelineSectionAreaArrayName"); ctrLineSects->SetCenterlineSectionMinSizeArrayName("CenterlineSectionMinSizeArrayName"); ctrLineSects->SetCenterlineSectionMaxSizeArrayName("CenterlineSectionMaxSizeArrayName"); ctrLineSects->SetCenterlineSectionShapeArrayName("CenterlineSectionShapeArrayName"); ctrLineSects->SetCenterlineSectionClosedArrayName("CenterlineSectionClosedArrayName"); ctrLineSects->Update(); //update causes the crash

And the filter fails most likely due to degenerate triangles of the decimated mesh. We need to find a way to clean the mesh after decimation or remove the decimation code all together and find a better meshing tool with control over meshing resolution.

OrodRazeghi commented 4 years ago

I added polydata cleaning and recalculating normals filters to the code after the decimation step. It seems it has stopped the crashes in cases sent to us that had issues in the past. @alonsoJASL can you please run some tests on the new clipping code? If it works, I think we can close this issue.

OrodRazeghi commented 4 years ago

By using vtkPolyDataConnectivityFilter and vtkWindowedSincPolyDataFilter after the decimation step, the problem seems to be fixed.