Hemesh Neighbors Mystery
in
Contributed Library Questions
•
1 year ago
Hey everyone,
I'm experimenting with the awesome Hemesh library. I am using the getNeighborFaces() function in the HE_Face class. However it seems this function is not returning the most recent state of affairs. Even when there are no other faces left in the mesh, this method still returns faces. How can I solve this so I get the actual neighbor faces (which in this example - after removing all the other faces - I expected to be none)?
Run this code and the mystery will be printed to your console.
Code Example
I'm experimenting with the awesome Hemesh library. I am using the getNeighborFaces() function in the HE_Face class. However it seems this function is not returning the most recent state of affairs. Even when there are no other faces left in the mesh, this method still returns faces. How can I solve this so I get the actual neighbor faces (which in this example - after removing all the other faces - I expected to be none)?
Run this code and the mystery will be printed to your console.
Code Example
- import wblut.hemesh.core.*;
- import wblut.hemesh.creators.*;
- void setup() {
- HE_Mesh mesh = new HE_Mesh(new HEC_Cube().setEdge(100));
- // put all the faces of the mesh in an arraylist
- ArrayList <HE_Face> faces = mesh.getFacesAsArrayList();
- println("The mesh has " + faces.size() + " faces.");
- // get a single face (the first one)
- HE_Face face = faces.get(0);
- // put all it's neighbor faces in an arraylist
- ArrayList <HE_Face> neighbors = face.getNeighborFaces();
- println("The selected face has " + neighbors.size() + " neighbors.");
- // remove all the faces except the first from the mesh
- for (int i=faces.size()-1; i>0; i--) {
- HE_Face f = faces.get(i);
- mesh.remove(f);
- }
- // put all the (remaining) faces of the mesh in an arraylist
- faces = mesh.getFacesAsArrayList();
- println("The mesh has " + faces.size() + " face.");
- // get a single face (the first -and now only!- one)
- face = faces.get(0);
- // put all it's neighbor faces in an arraylist
- neighbors = face.getNeighborFaces();
- println("The selected face still has " + neighbors.size() + " neighbors!");
- println("How is this possible? Where are these neighbors coming from?");
- exit();
- }
2