You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using this function from CGAL to remesh. The preview result looks the same. However, when I tag the face indices on them I can tell the faces are in different orders. And the coordinates of the vertices have very minor differences.
The inputs are the same.
Could anyone tell me if there is anything wrong with my code or if there is a way to get a fixed result?
Thank you very much!
voidCGAL_Remesh(double* vert_xyz_array, size_t vert_count, double criteria_a, double criteria_b, int iteration_number, double*& newVertices, int*& vCount, int*& newFaces, int*& fCount)
{ CDT cdt; // insert Vertex_handle
vector<Vertex_handle> cdt_Vh_Boundary;
for (int i = 0; i < vert_count; ++i)
{
Vertex_handle vh = cdt.insert(Point(vert_xyz_array[3 * i + 0], vert_xyz_array[3 * i + 1]));
cdt_Vh_Boundary.push_back(vh);
}
// insert Constrainfor (int i = 0; i < cdt_Vh_Boundary.size() - 1; ++i)
{
cdt.insert_constraint(cdt_Vh_Boundary[i], cdt_Vh_Boundary[i + 1]);
}
cdt.insert_constraint(cdt_Vh_Boundary[cdt_Vh_Boundary.size() - 1], cdt_Vh_Boundary[0]);
// refine and optimize mesh
Mesher mesher(cdt);
mesher.set_criteria(Criteria(criteria_a, criteria_b));
mesher.refine_mesh();
CGAL::lloyd_optimize_mesh_2(cdt, CGAL::parameters::max_iteration_number = iteration_number);
// make index pair
vector<CDT::Vertex_handle> visitedVertices; // collect visited vertices
map<CDT::Vertex_handle, int> indexList; // create a map to note the indexint i = 0;
for (CDT::Vertex_iterator v_it = cdt.vertices_begin(); v_it != cdt.vertices_end(); ++v_it)
{
CDT::Vertex_handle vh = v_it->handle();
indexList[vh] = i;
visitedVertices.push_back(vh);
i++;
}
// Convert data into double arrayint vNum = cdt.number_of_vertices();
newVertices = newdouble[vNum * 3];
i = 0;
for (CDT::Vertex_iterator vi = cdt.vertices_begin(); vi != cdt.vertices_end(); ++vi)
{
newVertices[i] = vi->point()[0];
i += 1;
newVertices[i] = vi->point()[1];
i += 1;
newVertices[i] = 0;
i += 1;
}
int vertexCount = vNum;
vCount = &vertexCount;
int num_face_in_domain = 0;
for (CDT::Face_iterator f_it = cdt.faces_begin(); f_it != cdt.faces_end(); ++f_it)
{
CDT::Face_handle face = f_it;
if (face->is_in_domain())
{
num_face_in_domain++;
}
}
newFaces = newint[num_face_in_domain * 3];
i = 0;
for (CDT::Face_iterator f_it = cdt.faces_begin(); f_it != cdt.faces_end(); ++f_it)
{
CDT::Face_handle face = f_it;
if (face->is_in_domain())
{
newFaces[i] = int(indexList.find(face->vertex(0)->handle())->second);
i += 1;
newFaces[i] = int(indexList.find(face->vertex(1)->handle())->second);
i += 1;
newFaces[i] = int(indexList.find(face->vertex(2)->handle())->second);
i += 1;
}
}
int faceCount = num_face_in_domain;
fCount = &faceCount;
}
The text was updated successfully, but these errors were encountered:
Please put a self contained example on gist.github.com
Hi, thank you for your reply. I have put a self contained example below. It will create 100 txt files. And you can tell the face orders are not always the same.
I am using this function from CGAL to remesh. The preview result looks the same. However, when I tag the face indices on them I can tell the faces are in different orders. And the coordinates of the vertices have very minor differences.
The inputs are the same.
Could anyone tell me if there is anything wrong with my code or if there is a way to get a fixed result?
Thank you very much!
The text was updated successfully, but these errors were encountered: