ShapeWorks icon indicating copy to clipboard operation
ShapeWorks copied to clipboard

shapeworks::Mesh::smooth() gives poor quality results

Open medakk opened this issue 3 years ago • 23 comments

Initial mesh: image

result of shapeworks::Mesh::smooth() with 100 iterations (I tried playing with "relaxation" but couldn't get better results): image

MeshLab's laplacian smooth with 3 iterations: image image

Is there some option that is not being exposed? Or is the VTK Laplacian Smooth doing something different?

Meshes attached meshsmooth.zip

medakk avatar May 09 '21 07:05 medakk

@archanasri is this using VTK smoothing or FEMesh smoothing?

@medakk PreviewCmd (or mesh-fix) had a Laplacian smoothing with a number of iterations and lambda parameter that controls the smoothing operation.

sheryjoe avatar May 09 '21 15:05 sheryjoe

PreviewCmd (or mesh-fix) had a Laplacian smoothing with a number of iterations and lambda parameter that controls the smoothing operation.

Is the usage documented? I don't see any binaries related to PreviewCmd or mesh-fix in build:

$ make -j8
$ ls bin/
boundary_loop_extractor
ComputeMeanNormals
ComputeMeshGeodesics
create_isosurface
GroomTests
ImageTests
libgeometry-central.so
MeshFromDT
MeshTests
OptimizeTests
ParticlesTests
PythonTests
ReconstructMeanSurface
ReconstructSamplesAlongPCAModes
ReconstructSurface
RemoveFidsDTLeakage
shapeworks
shapeworks.cpython-37m-x86_64-linux-gnu.so
ShapeWorksStudio
shapeworksTests
shared_boundary_extractor

medakk avatar May 09 '21 15:05 medakk

PreviewCmd was probably removed after its consolidation. @archanasri I recall the command name was mesh-fix. Is there a new command for PreviewCmd?

@medakk you can find the filter here https://github.com/SCIInstitute/ShapeWorks/blob/master/Libs/Mesh/PreviewMeshQC/FEMeshSmoothingModifier.h

sheryjoe avatar May 09 '21 15:05 sheryjoe

Its hard for me to tell what it's doing by looking at the code. There is a note there however:

//! \todo This implementation will only work with closed surfaces. 

The shared boundary surfaces will always be open meshes

medakk avatar May 10 '21 03:05 medakk

The smoothing in there right now is VTK's Laplacian. They also have windowed sinc that I will add.

akenmorris avatar May 10 '21 17:05 akenmorris

Does the vtk filter support open meshes?

sheryjoe avatar May 10 '21 17:05 sheryjoe

We are seeing the output of the vtkSmoothPolyData filter in the images above. I'm not sure about windowed sinc on open meshes.

akenmorris avatar May 10 '21 20:05 akenmorris

Fwiw I've been playing with "relaxation" some more. Results improve a bit but are still off

image

medakk avatar May 11 '21 15:05 medakk

FYI, the Mesh::fix call that uses the FEMesh stuff crashes on all three of these inputs:

$ shapeworks read-mesh --name meshlab_smooth.ply fix-mesh
zsh: segmentation fault  shapeworks read-mesh --name meshlab_smooth.ply fix-mesh
$ shapeworks read-mesh --name source_mesh.ply  fix-mesh
zsh: segmentation fault  shapeworks read-mesh --name source_mesh.ply fix-mesh
$ shapeworks read-mesh --name sw_smooth.ply   fix-mesh
zsh: segmentation fault  shapeworks read-mesh --name sw_smooth.ply fix-mesh
FECoreMesh::IsType(int) FECoreMesh.cpp:19
FEMeshSmoothingModifier::Apply(FEMesh*) FEMeshSmoothingModifier.cpp:27
shapeworks::Mesh::fix(bool, bool, double, int, bool, double) Mesh.cpp:553

akenmorris avatar May 11 '21 16:05 akenmorris

VTK's laplacian and windowed sinc seem to work fine on open meshes in general, but Karthik's meshes with the jagged edges don't seem to work out.

akenmorris avatar May 11 '21 16:05 akenmorris

The difference is probably that Meshlab has:

        parlst.addParam(RichBool ("Boundary",true,"1D Boundary Smoothing", "Smooth boundary edges only by themselves (e.g. the polyline forming the boundary of the mesh is independently smoothed). This can reduce the shrinking on the border but can have strange effects on very small boundaries."));

akenmorris avatar May 11 '21 16:05 akenmorris

The current implementation of shapeworks::Mesh::smooth() already has boundary smoothing enabled:

  if (relaxation)
  {
    smoother->SetRelaxationFactor(relaxation);
    smoother->FeatureEdgeSmoothingOff();
    smoother->BoundarySmoothingOn();
  }

So it appears the results I've been obtaining are despite that

medakk avatar May 12 '21 03:05 medakk

Is there someone more appropriate to whom this issue should be assigned? We only ported the executable to the Mesh class, so it's the same as it was before.

cchriste avatar May 19 '21 19:05 cchriste

adding @riddhishb

sheryjoe avatar May 19 '21 19:05 sheryjoe

@riddhishb can you check this out for 6.1?

sheryjoe avatar May 25 '21 15:05 sheryjoe

Can we move this to 6.3?

akenmorris avatar Sep 24 '21 23:09 akenmorris

Yes we can.

sheryjoe avatar Sep 27 '21 13:09 sheryjoe

  • Look into VTK loop sub-division to improve mesh quality and other smoothing options
  • Check ACVD again, does it work on open meshes?

iyerkrithika21 avatar May 10 '22 19:05 iyerkrithika21

@akenmorris, @sheryjoe: Looks like windowed sinc smoothening(with added arguments) is a better option than Laplacian smoothening.

Windowed Sinc with updated options: mesh.smoothSinc(10,0.5) Iteration: 10, passband: 0.5

smoother->SetNumberOfIterations(iterations);
  smoother->BoundarySmoothingOn();
  smoother->FeatureEdgeSmoothingOn();
  smoother->SetFeatureAngle(180.0);
  smoother->SetPassBand(passband);
  smoother->SetEdgeAngle(180);
  smoother->NonManifoldSmoothingOn();
  smoother->Update();

image

Laplacian Smooth: mesh.smooth(10,0.5) Iterations:10, relaxation: 0.5

smoother->SetRelaxationFactor(relaxation);
smoother->FeatureEdgeSmoothingOn();
smoother->BoundarySmoothingOn();

image

iyerkrithika21 avatar Jun 17 '22 17:06 iyerkrithika21

are these options exposed in Studio?

sheryjoe avatar Jun 21 '22 17:06 sheryjoe

Edge angle will have to be added to Studio. Iterations and relaxation are exposed currently for Laplacian, and iteration and passband are exposed for window sinc.

iyerkrithika21 avatar Jun 21 '22 22:06 iyerkrithika21

Which ones do we want to expose and which ones do we want to hard-code?

akenmorris avatar Jun 22 '22 13:06 akenmorris

  • Using the edge smoothing option can curl the edges inwards
  • Remeshing can cause non-manifold edges at the boundary faces that have an opposite ordering giving an inverted normal
  • vtkPolyDataNormals can only fix the orientation for closed surfaces.
  • Either other mesh smoothing options need to be investigated, or the shared boundary extraction has to be modified to produce smoother meshes.

iyerkrithika21 avatar Jul 19 '22 15:07 iyerkrithika21