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

Remove duplicate vertices on boundaries

parent e938bbb2
No related branches found
No related tags found
No related merge requests found
// $Id: 2D_Mesh_Shewchuk.cpp,v 1.1 2001-08-20 07:38:30 geuzaine Exp $ // $Id: 2D_Mesh_Shewchuk.cpp,v 1.2 2001-08-21 06:21:47 geuzaine Exp $
#include "Gmsh.h" #include "Gmsh.h"
#include "Mesh.h" #include "Mesh.h"
...@@ -17,36 +17,42 @@ extern "C" { ...@@ -17,36 +17,42 @@ extern "C" {
extern int CurrentNodeNumber; extern int CurrentNodeNumber;
extern Context_T CTX; extern Context_T CTX;
void AddInMesh(Surface *sur, struct triangulateio *io){ void AddInMesh(Surface *sur, Vertex **vertexbound,
struct triangulateio *in,
struct triangulateio *out){
int i; int i;
Vertex **vtable; Vertex **vtable;
Simplex *s; Simplex *s;
Msg(INFO, "Converting..."); Msg(INFO, "Converting...");
vtable = (Vertex**) Malloc(io->numberofpoints*sizeof(Vertex*)); vtable = (Vertex**) Malloc(out->numberofpoints*sizeof(Vertex*));
for (i = 0; i < io->numberofpoints; i++) { for (i = 0; i < in->numberofpoints; i++) vtable[i] = vertexbound[i];
Free(vertexbound);
for (i = in->numberofpoints; i < out->numberofpoints; i++) {
vtable[i] = Create_Vertex (++CurrentNodeNumber, vtable[i] = Create_Vertex (++CurrentNodeNumber,
io->pointlist[i * 2], io->pointlist[i * 2 + 1], 0.0, out->pointlist[i * 2], out->pointlist[i * 2 + 1], 0.0,
io->pointattributelist[i], 0.0); out->pointattributelist[i], 0.0);
Tree_Add (sur->Vertices, &vtable[i]); Tree_Add (sur->Vertices, &vtable[i]);
} }
Free(io->pointlist); Free(out->pointlist);
Free(io->pointattributelist); Free(out->pointattributelist);
for (i = 0; i < io->numberoftriangles; i++) { for (i = 0; i < out->numberoftriangles; i++) {
s = Create_Simplex(vtable[io->trianglelist[i * io->numberofcorners + 0]], s = Create_Simplex(vtable[out->trianglelist[i * out->numberofcorners + 0]],
vtable[io->trianglelist[i * io->numberofcorners + 1]], vtable[out->trianglelist[i * out->numberofcorners + 1]],
vtable[io->trianglelist[i * io->numberofcorners + 2]], vtable[out->trianglelist[i * out->numberofcorners + 2]],
NULL); NULL);
s->iEnt = sur->Num;
Tree_Add (sur->Simplexes, &s); Tree_Add (sur->Simplexes, &s);
} }
Free(vtable); Free(vtable);
Free(io->trianglelist); Free(out->trianglelist);
Free(io->triangleattributelist); Free(out->triangleattributelist);
Msg(INFO, "...Done"); Msg(INFO, "...Done");
} }
...@@ -74,7 +80,7 @@ int Mesh_Shewchuk(Surface *s){ ...@@ -74,7 +80,7 @@ int Mesh_Shewchuk(Surface *s){
int i, j, k, l, NbPts=0, first; int i, j, k, l, NbPts=0, first;
double val; double val;
List_T *list; List_T *list;
Vertex *v; Vertex *v, **vtable;
struct triangulateio in, mid, out; struct triangulateio in, mid, out;
for (i = 0; i < List_Nbr (s->Contours); i++){ for (i = 0; i < List_Nbr (s->Contours); i++){
...@@ -84,6 +90,7 @@ int Mesh_Shewchuk(Surface *s){ ...@@ -84,6 +90,7 @@ int Mesh_Shewchuk(Surface *s){
in.numberofpoints = NbPts; in.numberofpoints = NbPts;
in.pointlist = (REAL *) Malloc(in.numberofpoints * 2 * sizeof(REAL)); in.pointlist = (REAL *) Malloc(in.numberofpoints * 2 * sizeof(REAL));
vtable = (Vertex**) Malloc(in.numberofpoints*sizeof(Vertex*));
in.numberofpointattributes = 1; in.numberofpointattributes = 1;
in.pointattributelist = (REAL *) Malloc(in.numberofpoints * in.pointattributelist = (REAL *) Malloc(in.numberofpoints *
in.numberofpointattributes * in.numberofpointattributes *
...@@ -104,6 +111,7 @@ int Mesh_Shewchuk(Surface *s){ ...@@ -104,6 +111,7 @@ int Mesh_Shewchuk(Surface *s){
in.pointlist[k] = v->Pos.X; in.pointlist[k] = v->Pos.X;
in.pointlist[k+1] = v->Pos.Y; in.pointlist[k+1] = v->Pos.Y;
in.pointattributelist[l] = v->lc; in.pointattributelist[l] = v->lc;
vtable[l] = v;
in.segmentlist[k] = l; in.segmentlist[k] = l;
in.segmentlist[k+1] = (j==List_Nbr(list)-1)? (first) : (l+1); in.segmentlist[k+1] = (j==List_Nbr(list)-1)? (first) : (l+1);
in.segmentmarkerlist[l] = i; in.segmentmarkerlist[l] = i;
...@@ -140,14 +148,6 @@ int Mesh_Shewchuk(Surface *s){ ...@@ -140,14 +148,6 @@ int Mesh_Shewchuk(Surface *s){
triangulate("pqzY" OPT, &in, &mid, NULL); triangulate("pqzY" OPT, &in, &mid, NULL);
Free(in.pointlist);
Free(in.pointattributelist);
Free(in.pointmarkerlist);
Free(in.regionlist);
Free(in.segmentlist);
Free(in.segmentmarkerlist);
Free(in.holelist);
//AddInMesh(s, &mid); return 0; //AddInMesh(s, &mid); return 0;
#ifndef BGMESH #ifndef BGMESH
...@@ -189,7 +189,16 @@ int Mesh_Shewchuk(Surface *s){ ...@@ -189,7 +189,16 @@ int Mesh_Shewchuk(Surface *s){
Free(mid.trianglearealist); Free(mid.trianglearealist);
Free(mid.segmentlist); Free(mid.segmentlist);
Free(mid.segmentmarkerlist); Free(mid.segmentmarkerlist);
AddInMesh(s, &out);
AddInMesh(s, vtable, &in, &out);
Free(in.pointlist);
Free(in.pointattributelist);
Free(in.pointmarkerlist);
Free(in.regionlist);
Free(in.segmentlist);
Free(in.segmentmarkerlist);
Free(in.holelist);
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment