nmwsharp / nmwsharp/polyscope

Volume Grid Isosurface mesh issue

Ouverte
#285 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
C++
Étoiles
2.2k
Forks
242
Merge moyen
11 min
PR mergées (30 j)
1

Description

Hi,

I've run into an issue with the isosurface generation for volume grid scalar quantities. The problem appears to be that the change made to fix the frame transformation for #253 wasn't propagated into the grid dimensions passed to the MarchingCube library, resulting in the grid cells being interpreted in the wrong order.

The following shows a volume grid of the Stanford Bunny and its isosurface visualization with the 2.2.1 release:
Polyscope_Isosurface_Issue

By swizzling the grid dimensions passed into MarchingCube we get the following (correct) result instead:
Polyscope_Isosurface_Fix

The patch for the above fix is:

diff --git a/src/volume_grid_scalar_quantity.cpp b/src/volume_grid_scalar_quantity.cpp                                 
index cde441a..603841f 100644                                                                                          
--- a/src/volume_grid_scalar_quantity.cpp                                                                              
+++ b/src/volume_grid_scalar_quantity.cpp                                                                              
@@ -165,8 +165,8 @@ void VolumeGridNodeScalarQuantity::createIsosurfaceProgram() {                                     
                                                                                                                       
   // Extract the isosurface from the level set of the scalar field                                                    
   MC::mcMesh isosurfaceMesh;                                                                                          
-  MC::marching_cube(&values.data.front(), isosurfaceLevel.get(), parent.getGridNodeDim().x, parent.getGridNodeDim().y,
-                    parent.getGridNodeDim().z, isosurfaceMesh);                                                       
+  MC::marching_cube(&values.data.front(), isosurfaceLevel.get(), parent.getGridNodeDim().z, parent.getGridNodeDim().y,
+                    parent.getGridNodeDim().x, isosurfaceMesh);                                                       
                                                                                                                       
   // Transform the result to be aligned with our volume's spatial layout                                              
   glm::vec3 scale = parent.gridSpacing();                                                                             
@@ -215,8 +215,8 @@ SurfaceMesh* VolumeGridNodeScalarQuantity::registerIsosurfaceAsMesh(std::string                    
                                                                                                                       
   // extract the mesh                                                                                                 
   MC::mcMesh isosurfaceMesh;                                                                                          
-  MC::marching_cube(&values.data.front(), isosurfaceLevel.get(), parent.getGridNodeDim().x, parent.getGridNodeDim().y,
-                    parent.getGridNodeDim().z, isosurfaceMesh);                                                       
+  MC::marching_cube(&values.data.front(), isosurfaceLevel.get(), parent.getGridNodeDim().z, parent.getGridNodeDim().y,
+                    parent.getGridNodeDim().x, isosurfaceMesh);                                                       
   glm::vec3 scale = parent.gridSpacing();                                                                             
   for (auto& p : isosurfaceMesh.vertices) {                                                                           
     // swizzle to account for change of coordinate/buffer ordering in the MC lib                                      

I'm not sure how you prefer to manage the repo, but if you'd like me to open a PR for the fix I'm happy to. Thanks!

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez dans src/volume_grid_scalar_quantity.cpp en examinant createIsosurfaceProgram() et registerIsosurfaceAsMesh(), où sont présentés les appels à MarchingCube et la transformation des coordonnées. Comparez l’ordre des dimensions de la grille dans les deux chemins avec la disposition du tampon de volume. Le travail est terminé lorsque les isosurfaces de volume-grid sont rendues avec l’orientation et l’ordre des cellules corrects dans les deux utilisations.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
cpp
Domaine
computer-graphics
Type d'issue
Bug
Difficulté
2/5
Temps estimé
1-3 heures
Activité
À l'abandon
Clarté
Clairement spécifiée
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.