Skip to content
Snippets Groups Projects
Commit 2680957e authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

check for duplicate elements

parent c081b9d9
No related branches found
No related tags found
No related merge requests found
// $Id: Read_Mesh.cpp,v 1.22 2001-08-02 19:11:40 geuzaine Exp $
// $Id: Read_Mesh.cpp,v 1.23 2001-08-09 20:48:31 geuzaine Exp $
#include "Gmsh.h"
#include "Geo.h"
......@@ -51,7 +51,7 @@ void Read_Mesh_MSH (Mesh *M, FILE *File_GEO){
Curve C , *c , **cc;
Surface S , *s , **ss;
Volume V , *v , **vv;
Tree_T *Duplis ;
Tree_T *Duplicates ;
while (1) {
do {
......@@ -83,16 +83,21 @@ void Read_Mesh_MSH (Mesh *M, FILE *File_GEO){
Msg(INFO, "%d Nodes", Nbr_Nodes);
if(CTX.mesh.check_duplicates)
Duplis = Tree_Create (sizeof (Vertex *), comparePosition);
Duplicates = Tree_Create (sizeof (Vertex *), comparePosition);
for (i_Node = 0 ; i_Node < Nbr_Nodes ; i_Node++) {
fscanf(File_GEO, "%d %lf %lf %lf", &Num, &x, &y, &z) ;
vert = Create_Vertex (Num, x, y, z, 1.0 ,0.0);
Tree_Replace(M->Vertices, &vert);
if(CTX.mesh.check_duplicates)
if(Tree_Replace(Duplis, &vert)) Msg(WARNING, "Node %g %g %g already exists");
if(CTX.mesh.check_duplicates){
if((vertspp = (Vertex**)Tree_PQuery(Duplicates, &vert)))
Msg(WARNING, "Nodes %d and %d have identical coordinates (%g, %g, %g)",
Num, (*vertspp)->Num, x, y, z);
else
Tree_Add(Duplicates, &vert);
}
}
if(CTX.mesh.check_duplicates)
Tree_Delete(Duplis);
Tree_Delete(Duplicates);
}
/* ELEMENTS */
......@@ -102,6 +107,9 @@ void Read_Mesh_MSH (Mesh *M, FILE *File_GEO){
fscanf(File_GEO, "%d", &Nbr_Elements) ;
Msg(INFO, "%d Elements", Nbr_Elements);
if(CTX.mesh.check_duplicates)
Duplicates = Tree_Create (sizeof (Vertex *), comparePosition);
for (i_Element = 0 ; i_Element < Nbr_Elements ; i_Element++) {
// HACK FROM JF
......@@ -113,8 +121,8 @@ void Read_Mesh_MSH (Mesh *M, FILE *File_GEO){
for (j = 0 ; j < Nbr_Nodes ; j++)
fscanf(File_GEO, "%d", &verts[j].Num) ;
if(Elementary >= 0)
{
if(Elementary >= 0){
switch(Type){
case LGN1: case LGN2:
c = &C; c->Num = Elementary;
......@@ -159,6 +167,23 @@ void Read_Mesh_MSH (Mesh *M, FILE *File_GEO){
vertsp[i] = *vertspp;
}
if(CTX.mesh.check_duplicates){
vert = Create_Vertex (Num, 0., 0., 0., 1.0 ,0.0);
for(i=0 ; i<Nbr_Nodes ; i++){
vert->Pos.X += vertsp[i]->Pos.X ;
vert->Pos.Y += vertsp[i]->Pos.Y ;
vert->Pos.Z += vertsp[i]->Pos.Z ;
}
vert->Pos.X /= (double) Nbr_Nodes;
vert->Pos.Y /= (double) Nbr_Nodes;
vert->Pos.Z /= (double) Nbr_Nodes;
if((vertspp = (Vertex**)Tree_PQuery(Duplicates, &vert)))
Msg(WARNING, "Elements %d and %d have identical barycenters",
Num, (*vertspp)->Num);
else
Tree_Add(Duplicates, &vert);
}
switch(Type){
case LGN1:
//simp = Create_Simplex(vertsp[0], vertsp[1], NULL , NULL);
......@@ -216,6 +241,11 @@ void Read_Mesh_MSH (Mesh *M, FILE *File_GEO){
}
}
if(CTX.mesh.check_duplicates){
Tree_Action(Duplicates, Free_Vertex);
Tree_Delete(Duplicates);
}
}
do {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment