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

Fix problem with old extrude after new one; remove superfluous code for Vertex_Bound;

parent b475f0e8
No related branches found
No related tags found
No related merge requests found
// $Id: 3D_Extrude.cpp,v 1.51 2001-12-03 15:30:03 geuzaine Exp $ // $Id: 3D_Extrude.cpp,v 1.52 2001-12-04 09:30:12 geuzaine Exp $
#include "Gmsh.h" #include "Gmsh.h"
#include "Numeric.h" #include "Numeric.h"
...@@ -12,14 +12,12 @@ extern Context_T CTX ; ...@@ -12,14 +12,12 @@ extern Context_T CTX ;
extern Mesh *THEM; extern Mesh *THEM;
static int DIM, NUM; // current dimension of parent entity static int DIM, NUM; // current dimension of parent entity
static Tree_T *Tree_Ares = NULL, *Tree_Swaps = NULL;
static int TEST_IS_ALL_OK; static int TEST_IS_ALL_OK;
static Tree_T *Tree_Ares = NULL, *Tree_Swaps = NULL, *Vertex_Bound = NULL;
static Curve *THEC=NULL; static Curve *THEC=NULL;
static Surface *THES=NULL; static Surface *THES=NULL;
static Volume *THEV=NULL; static Volume *THEV=NULL;
static ExtrudeParams *ep; static ExtrudeParams *ep;
static Tree_T *Vertex_Bound = NULL;
// Vertex_Bound contains the vertices on the boundary (on the curves // Vertex_Bound contains the vertices on the boundary (on the curves
// for extrude_mesh(surface) and on the surfaces for // for extrude_mesh(surface) and on the surfaces for
...@@ -142,30 +140,31 @@ static int compnxn (const void *a, const void *b){ ...@@ -142,30 +140,31 @@ static int compnxn (const void *a, const void *b){
return 0; return 0;
} }
void ReplaceInVertexBound(void *a, void *b){
//Warning! We must do a 'replace', and not an 'add'/'insert'!
//Otherwise, we get 'Points' mixed up with 'Vertices'. The old
//extrusion (applied to a 2D extruded mesh) would then crash since
//only the Vertices are extruded and correctly handled (e.g. for
//beg/end curves).
Tree_Replace(Vertex_Bound, a);
}
void InitExtrude (){ void InitExtrude (){
if (!Tree_Ares) if(!Tree_Ares) Tree_Ares = Tree_Create (sizeof (nxn), compnxn);
Tree_Ares = Tree_Create (sizeof (nxn), compnxn); if(!Tree_Swaps) Tree_Swaps = Tree_Create (sizeof (nxn), compnxn);
if (!Tree_Swaps)
Tree_Swaps = Tree_Create (sizeof (nxn), compnxn);
if(Vertex_Bound)
Tree_Delete(Vertex_Bound);
Vertex_Bound = Tree_Create (sizeof (Vertex *), comparePosition);
List_T *l1 = Tree2List (THEM->Points);
List_T *l2 = Tree2List (THEM->Vertices);
for(int i=0;i<List_Nbr(l1);i++)Tree_Insert(Vertex_Bound,List_Pointer(l1,i)); if(Vertex_Bound) Tree_Delete(Vertex_Bound);
for(int i=0;i<List_Nbr(l2);i++)Tree_Insert(Vertex_Bound,List_Pointer(l2,i)); Vertex_Bound = Tree_Create (sizeof (Vertex *), comparePosition);
List_Delete(l1); Tree_Action(THEM->Points, ReplaceInVertexBound);
List_Delete(l2); Tree_Action(THEM->Vertices, ReplaceInVertexBound);
} }
void ExitExtrude (){ void ExitExtrude (){
if(Tree_Ares) Tree_Delete(Tree_Ares); if(Tree_Ares) Tree_Delete(Tree_Ares);
if(Tree_Swaps) Tree_Delete(Tree_Swaps); if(Tree_Swaps) Tree_Delete(Tree_Swaps);
if(Vertex_Bound) Tree_Delete (Vertex_Bound); if(Vertex_Bound) Tree_Delete (Vertex_Bound);
Tree_Ares = Tree_Swaps = NULL; Tree_Ares = Tree_Swaps = Vertex_Bound = NULL;
Vertex_Bound = NULL;
} }
int are_exist (Vertex * v1, Vertex * v2, Tree_T * t){ int are_exist (Vertex * v1, Vertex * v2, Tree_T * t){
...@@ -536,13 +535,11 @@ void Extrude_Simplex_Phase2 (void *data, void *dum){ ...@@ -536,13 +535,11 @@ void Extrude_Simplex_Phase2 (void *data, void *dum){
void Extrude_Vertex (void *data, void *dum){ void Extrude_Vertex (void *data, void *dum){
Vertex **pV, *v, *newv; Vertex **pV, *v, *newv;
int i, j; int i, j;
nxl NXL; nxl NXL;
pV = (Vertex **) data; v = *((Vertex**)data);
v = *pV;
if(!v->Extruded_Points) if(!v->Extruded_Points)
v->Extruded_Points = List_Create (1, 1, sizeof (nxl)); v->Extruded_Points = List_Create (1, 1, sizeof (nxl));
...@@ -588,7 +585,6 @@ void Extrude_Surface2 (Surface * s){ ...@@ -588,7 +585,6 @@ void Extrude_Surface2 (Surface * s){
Tree_Action (s->Simplexes, Extrude_Simplex_Phase2); Tree_Action (s->Simplexes, Extrude_Simplex_Phase2);
} }
void Extrude_Surface3 (Surface * s){ void Extrude_Surface3 (Surface * s){
THES = s; THES = s;
Tree_Action (s->Simplexes, Extrude_Simplex_Phase3); Tree_Action (s->Simplexes, Extrude_Simplex_Phase3);
...@@ -675,7 +671,7 @@ void Extrude_Curve (void *data, void *dum){ ...@@ -675,7 +671,7 @@ void Extrude_Curve (void *data, void *dum){
void copy_mesh (Curve * from, Curve * to, int direction){ void copy_mesh (Curve * from, Curve * to, int direction){
List_T *list = from->Vertices; List_T *list = from->Vertices;
Vertex *vi, *v, **vv, **vexist; Vertex *vi, *v, **vexist;
int nb = List_Nbr(to->Vertices); int nb = List_Nbr(to->Vertices);
if(nb){ if(nb){
...@@ -687,17 +683,14 @@ void copy_mesh (Curve * from, Curve * to, int direction){ ...@@ -687,17 +683,14 @@ void copy_mesh (Curve * from, Curve * to, int direction){
to->Vertices = List_Create (List_Nbr(from->Vertices), 2, sizeof (Vertex *)); to->Vertices = List_Create (List_Nbr(from->Vertices), 2, sizeof (Vertex *));
vv = &to->beg; v = to->beg;
if ((vexist = (Vertex **) Tree_PQuery (THEM->Vertices, vv))){ if ((vexist = (Vertex **) Tree_PQuery (THEM->Vertices, &v))){
(*vexist)->u = to->ubeg; (*vexist)->u = to->ubeg;
//Tree_Insert (THEM->Vertices, vexist); if ((*vexist)->ListCurves) List_Add ((*vexist)->ListCurves, &to);
if ((*vexist)->ListCurves)
List_Add ((*vexist)->ListCurves, &to);
List_Add (to->Vertices, vexist); List_Add (to->Vertices, vexist);
} }
else{ else{
vi = Create_Vertex ((*vv)->Num, (*vv)->Pos.X, (*vv)->Pos.Y, (*vv)->Pos.Z, vi = Create_Vertex(v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc, to->ubeg);
(*vv)->lc, to->ubeg);
Tree_Insert(THEM->Vertices, &vi); Tree_Insert(THEM->Vertices, &vi);
vi->ListCurves = List_Create (1, 1, sizeof (Curve *)); vi->ListCurves = List_Create (1, 1, sizeof (Curve *));
List_Add(vi->ListCurves, &to); List_Add(vi->ListCurves, &to);
...@@ -718,23 +711,19 @@ void copy_mesh (Curve * from, Curve * to, int direction){ ...@@ -718,23 +711,19 @@ void copy_mesh (Curve * from, Curve * to, int direction){
vi = v; vi = v;
} }
Tree_Insert (THEM->Vertices, &vi); Tree_Insert (THEM->Vertices, &vi);
if(!vi->ListCurves) if(!vi->ListCurves) vi->ListCurves = List_Create (1, 1, sizeof (Curve *));
vi->ListCurves = List_Create (1, 1, sizeof (Curve *));
List_Add(vi->ListCurves, &to); List_Add(vi->ListCurves, &to);
List_Add(to->Vertices, &vi); List_Add(to->Vertices, &vi);
} }
vv = &to->end; v = to->end;
if ((vexist = (Vertex **) Tree_PQuery (THEM->Vertices, vv))){ if ((vexist = (Vertex **) Tree_PQuery (THEM->Vertices, &v))){
(*vexist)->u = to->uend; (*vexist)->u = to->uend;
//Tree_Insert (THEM->Vertices, vexist); if ((*vexist)->ListCurves) List_Add ((*vexist)->ListCurves, &to);
if ((*vexist)->ListCurves)
List_Add ((*vexist)->ListCurves, &to);
List_Add (to->Vertices, vexist); List_Add (to->Vertices, vexist);
} }
else{ else{
vi = Create_Vertex ((*vv)->Num, (*vv)->Pos.X, (*vv)->Pos.Y, (*vv)->Pos.Z, vi = Create_Vertex (v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc, to->uend);
(*vv)->lc, to->uend);
Tree_Insert (THEM->Vertices, &vi); Tree_Insert (THEM->Vertices, &vi);
vi->ListCurves = List_Create (1, 1, sizeof (Curve *)); vi->ListCurves = List_Create (1, 1, sizeof (Curve *));
List_Add (vi->ListCurves, &to); List_Add (vi->ListCurves, &to);
...@@ -745,7 +734,7 @@ void copy_mesh (Curve * from, Curve * to, int direction){ ...@@ -745,7 +734,7 @@ void copy_mesh (Curve * from, Curve * to, int direction){
int Extrude_Mesh (Curve * c){ int Extrude_Mesh (Curve * c){
int i; int i;
Vertex **v, *pV, **vexist, *v1; Vertex *v, *pV, **vexist;
List_T *L; List_T *L;
if (!c->Extrude || !c->Extrude->mesh.ExtrudeMesh) return false; if (!c->Extrude || !c->Extrude->mesh.ExtrudeMesh) return false;
...@@ -759,18 +748,16 @@ int Extrude_Mesh (Curve * c){ ...@@ -759,18 +748,16 @@ int Extrude_Mesh (Curve * c){
if (ep->geo.Mode == EXTRUDED_ENTITY){ if (ep->geo.Mode == EXTRUDED_ENTITY){
Extrude_Vertex (&c->beg, NULL); Extrude_Vertex (&c->beg, NULL);
L = getnxl(c->beg,DIM); L = getnxl(c->beg,DIM);
c->Vertices = List_Create (List_Nbr(L), 2, sizeof (Vertex *)); c->Vertices = List_Create (List_Nbr(L), 2, sizeof (Vertex *));
v = &c->beg;
if ((vexist = (Vertex **) Tree_PQuery (THEM->Vertices, v))){ v = c->beg;
if ((vexist = (Vertex **) Tree_PQuery (THEM->Vertices, &v))){
(*vexist)->u = c->ubeg; (*vexist)->u = c->ubeg;
Tree_Insert (THEM->Vertices, vexist); if ((*vexist)->ListCurves) List_Add ((*vexist)->ListCurves, &c);
if ((*vexist)->ListCurves)
List_Add ((*vexist)->ListCurves, &c);
List_Add (c->Vertices, vexist); List_Add (c->Vertices, vexist);
} }
else{ else{
pV = Create_Vertex ((*v)->Num, (*v)->Pos.X, (*v)->Pos.Y, (*v)->Pos.Z, (*v)->lc, 0.0); pV = Create_Vertex (v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc, 0.0);
pV->ListCurves = List_Create (1, 1, sizeof (Curve *)); pV->ListCurves = List_Create (1, 1, sizeof (Curve *));
List_Add (pV->ListCurves, &c); List_Add (pV->ListCurves, &c);
Tree_Insert(THEM->Vertices, &pV); Tree_Insert(THEM->Vertices, &pV);
...@@ -778,24 +765,22 @@ int Extrude_Mesh (Curve * c){ ...@@ -778,24 +765,22 @@ int Extrude_Mesh (Curve * c){
} }
for (i = 1; i < List_Nbr(L)-1; i++){ for (i = 1; i < List_Nbr(L)-1; i++){
List_Read (L, i, &v1); List_Read (L, i, &v);
if (!v1->ListCurves) v1->ListCurves = List_Create (1, 1, sizeof (Curve *)); if (!v->ListCurves) v->ListCurves = List_Create(1, 1, sizeof (Curve *));
List_Add(v1->ListCurves, &c); List_Add(v->ListCurves, &c);
Tree_Insert (THEM->Vertices, &v1); Tree_Insert(THEM->Vertices, &v);
v1->u = (double) i / (double) List_Nbr(L); v->u = (double)i / (double)List_Nbr(L);
List_Add (c->Vertices, &v1); List_Add (c->Vertices, &v);
} }
v = &c->end; v = c->end;
if ((vexist = (Vertex **) Tree_PQuery (THEM->Vertices, v))){ if ((vexist = (Vertex **) Tree_PQuery (THEM->Vertices, &v))){
(*vexist)->u = c->uend; (*vexist)->u = c->uend;
Tree_Insert (THEM->Vertices, vexist); if ((*vexist)->ListCurves) List_Add ((*vexist)->ListCurves, &c);
if ((*vexist)->ListCurves)
List_Add ((*vexist)->ListCurves, &c);
List_Add (c->Vertices, vexist); List_Add (c->Vertices, vexist);
} }
else{ else{
pV = Create_Vertex ((*v)->Num, (*v)->Pos.X, (*v)->Pos.Y, (*v)->Pos.Z, (*v)->lc, 0.0); pV = Create_Vertex (v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z, v->lc, 0.0);
pV->ListCurves = List_Create (1, 1, sizeof (Curve *)); pV->ListCurves = List_Create (1, 1, sizeof (Curve *));
List_Add (pV->ListCurves, &c); List_Add (pV->ListCurves, &c);
Tree_Insert(THEM->Vertices, &pV); Tree_Insert(THEM->Vertices, &pV);
...@@ -866,7 +851,7 @@ void AddVertsInSurf(void *a, void *b){ ...@@ -866,7 +851,7 @@ void AddVertsInSurf(void *a, void *b){
} }
int Extrude_Mesh (Surface * s){ int Extrude_Mesh (Surface * s){
int i, j; int i;
Vertex *v1; Vertex *v1;
Curve *c; Curve *c;
extern int FACE_DIMENSION; extern int FACE_DIMENSION;
...@@ -878,16 +863,8 @@ int Extrude_Mesh (Surface * s){ ...@@ -878,16 +863,8 @@ int Extrude_Mesh (Surface * s){
DIM = 2; DIM = 2;
NUM = s->Num; NUM = s->Num;
ep = s->Extrude; ep = s->Extrude;
FACE_DIMENSION = 2; FACE_DIMENSION = 2;
for (i = 0; i < List_Nbr (s->Generatrices); i++){
List_Read (s->Generatrices, i, &c);
for (j = 0; j < List_Nbr (c->Vertices); j++){
List_Read (c->Vertices, j, &v1);
Tree_Insert (Vertex_Bound, &v1);
}
}
if (ep->geo.Mode == EXTRUDED_ENTITY){ if (ep->geo.Mode == EXTRUDED_ENTITY){
c = FindCurve (abs(ep->geo.Source), THEM); c = FindCurve (abs(ep->geo.Source), THEM);
if (!c) return false; if (!c) return false;
...@@ -932,7 +909,6 @@ int Extrude_Mesh (Volume * v){ ...@@ -932,7 +909,6 @@ int Extrude_Mesh (Volume * v){
int Extrude_Mesh (Tree_T * Volumes){ int Extrude_Mesh (Tree_T * Volumes){
int i, j, extrude=0; int i, j, extrude=0;
Surface *s; Surface *s;
Vertex *v1;
List_T *list; List_T *list;
InitExtrude (); InitExtrude ();
...@@ -943,18 +919,7 @@ int Extrude_Mesh (Tree_T * Volumes){ ...@@ -943,18 +919,7 @@ int Extrude_Mesh (Tree_T * Volumes){
for (int ivol = 0; ivol < List_Nbr(vol); ivol++){ for (int ivol = 0; ivol < List_Nbr(vol); ivol++){
List_Read(vol, ivol, &THEV); List_Read(vol, ivol, &THEV);
ep = THEV->Extrude; ep = THEV->Extrude;
if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY){ if(ep && ep->mesh.ExtrudeMesh && ep->geo.Mode == EXTRUDED_ENTITY) extrude = 1;
extrude = 1;
for (i = 0; i < List_Nbr (THEV->Surfaces); i++){
List_Read (THEV->Surfaces, i, &s);
list = Tree2List (s->Vertices);
for (int j = 0; j < List_Nbr (list); j++){
List_Read (list, j, &v1);
Tree_Insert (Vertex_Bound, &v1);
}
List_Delete (list);
}
}
} }
if(!extrude) return false; if(!extrude) return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment