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

indent + cleanup messages (somewhat)
parent fde80622
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -31,14 +31,13 @@ ...@@ -31,14 +31,13 @@
#include <vector> #include <vector>
#include <list> #include <list>
#include <math.h> #include <math.h>
//#include <algorithm>
class BDS_Tet; class BDS_Tet;
class BDS_Edge; class BDS_Edge;
class BDS_Triangle; class BDS_Triangle;
class BDS_Mesh; class BDS_Mesh;
class BDS_Point; class BDS_Point;
class BDS_Vector;
void vector_triangle(BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, double c[3]); void vector_triangle(BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, double c[3]);
void normal_triangle(BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, double c[3]); void normal_triangle(BDS_Point *p1, BDS_Point *p2, BDS_Point *p3, double c[3]);
...@@ -59,7 +58,6 @@ class BDS_Metric ...@@ -59,7 +58,6 @@ class BDS_Metric
if(_target >= _max && old_target_length > _max) return _max; if(_target >= _max && old_target_length > _max) return _max;
if(old_target_length > _target)return _target ; if(old_target_length > _target)return _target ;
return old_target_length; return old_target_length;
} }
inline double target_length(double x, double y, double z) const inline double target_length(double x, double y, double z) const
{ {
...@@ -67,7 +65,6 @@ class BDS_Metric ...@@ -67,7 +65,6 @@ class BDS_Metric
} }
}; };
class BDS_Surface class BDS_Surface
{ {
public : public :
...@@ -75,7 +72,7 @@ public : ...@@ -75,7 +72,7 @@ public :
virtual void projection(double xa, double ya, double za, virtual void projection(double xa, double ya, double za,
double &x, double &y, double &z) const =0; double &x, double &y, double &z) const =0;
virtual std::string nameOf() const = 0; virtual std::string nameOf() const = 0;
// virtual BDS_Vector Gradient ( double x, double y, double z ) const = 0; virtual BDS_Vector Gradient(double x, double y, double z) const = 0;
virtual double normalCurv(double x, double y, double z) const = 0; virtual double normalCurv(double x, double y, double z) const = 0;
}; };
...@@ -122,18 +119,15 @@ public: ...@@ -122,18 +119,15 @@ public:
~BDS_GeomEntity() ~BDS_GeomEntity()
{ {
#ifdef HAVE_ANN_ #ifdef HAVE_ANN_
if (kdTree) if(kdTree){
{
delete [] nnIdx; // clean things up delete [] nnIdx; // clean things up
delete [] dists; delete [] dists;
delete kdTree; delete kdTree;
} }
#endif #endif
} }
}; };
void print_face(BDS_Triangle *t); void print_face(BDS_Triangle *t);
class BDS_Vector class BDS_Vector
...@@ -218,7 +212,6 @@ public: ...@@ -218,7 +212,6 @@ public:
static double t; static double t;
}; };
class BDS_Pos class BDS_Pos
{ {
public: public:
...@@ -247,10 +240,8 @@ public: ...@@ -247,10 +240,8 @@ public:
{ {
std::list<BDS_Edge*>::iterator it = edges.begin(); std::list<BDS_Edge*>::iterator it = edges.begin();
std::list<BDS_Edge*>::iterator ite = edges.end(); std::list<BDS_Edge*>::iterator ite = edges.end();
while(it!=ite) while(it!=ite){
{ if(*it == e){
if (*it == e)
{
edges.erase(it); edges.erase(it);
break; break;
} }
...@@ -258,9 +249,7 @@ public: ...@@ -258,9 +249,7 @@ public:
} }
} }
void getTriangles(std::list<BDS_Triangle *> &t) const; void getTriangles(std::list<BDS_Triangle *> &t) const;
void compute_curvature(); void compute_curvature();
BDS_Point(int id, double x=0, double y=0, double z=0) BDS_Point(int id, double x=0, double y=0, double z=0)
: BDS_Pos(x,y,z),iD(id),radius_of_curvature(1.e22),g(0) : BDS_Pos(x,y,z),iD(id),radius_of_curvature(1.e22),g(0)
{ {
...@@ -281,7 +270,6 @@ public: ...@@ -281,7 +270,6 @@ public:
{ {
return _faces [i]; return _faces [i];
} }
inline double length() const inline double length() const
{ {
return sqrt((p1->X-p2->X)*(p1->X-p2->X)+(p1->Y-p2->Y)*(p1->Y-p2->Y)+(p1->Z-p2->Z)*(p1->Z-p2->Z)); return sqrt((p1->X-p2->X)*(p1->X-p2->X)+(p1->Y-p2->Y)*(p1->Y-p2->Y)+(p1->Z-p2->Z)*(p1->Z-p2->Z));
...@@ -296,14 +284,12 @@ public: ...@@ -296,14 +284,12 @@ public:
if(p2 == other->p1 || p2 == other->p2) return p2; if(p2 == other->p1 || p2 == other->p2) return p2;
return 0; return 0;
} }
inline BDS_Point * othervertex(const BDS_Point *p) const inline BDS_Point * othervertex(const BDS_Point *p) const
{ {
if(p1 == p) return p2; if(p1 == p) return p2;
if(p2 == p) return p1; if(p2 == p) return p1;
return 0; return 0;
} }
inline void addface(BDS_Triangle *f) inline void addface(BDS_Triangle *f)
{ {
_faces.push_back(f); _faces.push_back(f);
...@@ -333,13 +319,11 @@ public: ...@@ -333,13 +319,11 @@ public:
BDS_Edge(BDS_Point *A, BDS_Point *B) BDS_Edge(BDS_Point *A, BDS_Point *B)
: deleted(false), status(0),partition(0),target_length(1.0),g(0) : deleted(false), status(0),partition(0),target_length(1.0),g(0)
{ {
if (*A < *B) if(*A < *B){
{
p1=A; p1=A;
p2=B; p2=B;
} }
else else{
{
p1=B; p1=B;
p2=A; p2=A;
} }
...@@ -428,13 +412,11 @@ public: ...@@ -428,13 +412,11 @@ public:
inline void del(BDS_Tet *t) inline void del(BDS_Tet *t)
{ {
if (t == t1) if(t == t1){
{
t1 = t2; t1 = t2;
t2 = 0; t2 = 0;
} }
else if (t == t2) else if(t == t2){
{
t2 = 0; t2 = 0;
} }
else else
...@@ -562,7 +544,6 @@ public : ...@@ -562,7 +544,6 @@ public :
virtual std::string nameOf() const {return std::string("Quadric");} virtual std::string nameOf() const {return std::string("Quadric");}
}; };
class GeomLessThan class GeomLessThan
{ {
public: public:
...@@ -571,6 +552,7 @@ class GeomLessThan ...@@ -571,6 +552,7 @@ class GeomLessThan
return *ent1 < *ent2; return *ent1 < *ent2;
} }
}; };
class PointLessThan class PointLessThan
{ {
public: public:
...@@ -579,6 +561,7 @@ class PointLessThan ...@@ -579,6 +561,7 @@ class PointLessThan
return *ent1 < *ent2; return *ent1 < *ent2;
} }
}; };
class PointLessThanLexicographic class PointLessThanLexicographic
{ {
public: public:
...@@ -593,6 +576,7 @@ class PointLessThanLexicographic ...@@ -593,6 +576,7 @@ class PointLessThanLexicographic
return false; return false;
} }
}; };
class EdgeLessThan class EdgeLessThan
{ {
public: public:
...@@ -655,5 +639,6 @@ class BDS_Mesh ...@@ -655,5 +639,6 @@ class BDS_Mesh
bool read_vrml(const char *filename); bool read_vrml(const char *filename);
void save_gmsh_format(const char *filename); void save_gmsh_format(const char *filename);
}; };
bool project_point_on_a_list_of_triangles(BDS_Point *p , const std::list<BDS_Triangle*> &t, bool project_point_on_a_list_of_triangles(BDS_Point *p , const std::list<BDS_Triangle*> &t,
double &X, double &Y, double &Z); double &X, double &Y, double &Z);
// $Id: DiscreteSurface.cpp,v 1.31 2005-11-01 16:37:12 remacle Exp $ // $Id: DiscreteSurface.cpp,v 1.32 2005-11-03 03:55:15 geuzaine Exp $
// //
// Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2005 C. Geuzaine, J.-F. Remacle
// //
...@@ -35,35 +35,44 @@ extern Context_T CTX; ...@@ -35,35 +35,44 @@ extern Context_T CTX;
void Mesh_To_BDS(Mesh * m) void Mesh_To_BDS(Mesh * m)
{ {
Msg(STATUS2, "Moving mesh into new structure");
Msg(STATUS2, "Moving the mesh in the new gmsh structure\n");
Move_SimplexBaseToSimplex(m, 3); Move_SimplexBaseToSimplex(m, 3);
// create the structure // create the structure
if (m->bds)delete m->bds; if(m->bds)
delete m->bds;
m->bds = new BDS_Mesh; m->bds = new BDS_Mesh;
PhysicalGroup *p; PhysicalGroup *p;
m->bds->Min[0] = m->bds->Min[1] = m->bds->Min[2] = 1.e12; m->bds->Min[0] = m->bds->Min[1] = m->bds->Min[2] = 1.e12;
m->bds->Max[0] = m->bds->Max[1] = m->bds->Max[2] = -1.e12; m->bds->Max[0] = m->bds->Max[1] = m->bds->Max[2] = -1.e12;
Msg(STATUS2, "Moving the nodes\n"); Msg(STATUS2, "Moving nodes");
// copy the nodes // copy the nodes
List_T *vertices = Tree2List(m->Vertices); List_T *vertices = Tree2List(m->Vertices);
for (int i=0;i<List_Nbr ( vertices ) ;++i) for(int i = 0; i < List_Nbr(vertices); ++i) {
{
Vertex *v; Vertex *v;
List_Read(vertices, i, &v); List_Read(vertices, i, &v);
if ( v->Pos.X < m->bds->Min [0]) m->bds->Min[0] = v->Pos.X; if(v->Pos.X < m->bds->Min[0])
if ( v->Pos.Y < m->bds->Min [1]) m->bds->Min[1] = v->Pos.Y; m->bds->Min[0] = v->Pos.X;
if ( v->Pos.Z < m->bds->Min [2]) m->bds->Min[2] = v->Pos.Z; if(v->Pos.Y < m->bds->Min[1])
if ( v->Pos.X > m->bds->Max [0]) m->bds->Max[0] = v->Pos.X; m->bds->Min[1] = v->Pos.Y;
if ( v->Pos.Y > m->bds->Max [1]) m->bds->Max[1] = v->Pos.Y; if(v->Pos.Z < m->bds->Min[2])
if ( v->Pos.Z > m->bds->Max [2]) m->bds->Max[2] = v->Pos.Z; m->bds->Min[2] = v->Pos.Z;
if(v->Pos.X > m->bds->Max[0])
m->bds->Max[0] = v->Pos.X;
if(v->Pos.Y > m->bds->Max[1])
m->bds->Max[1] = v->Pos.Y;
if(v->Pos.Z > m->bds->Max[2])
m->bds->Max[2] = v->Pos.Z;
m->bds->add_point(v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z); m->bds->add_point(v->Num, v->Pos.X, v->Pos.Y, v->Pos.Z);
} }
m->bds->LC = sqrt ((m->bds->Min[0]-m->bds->Max[0])*(m->bds->Min[0]-m->bds->Max[0])+ m->bds->LC =
(m->bds->Min[1]-m->bds->Max[1])*(m->bds->Min[1]-m->bds->Max[1])+ sqrt((m->bds->Min[0] - m->bds->Max[0]) * (m->bds->Min[0] -
(m->bds->Min[2]-m->bds->Max[2])*(m->bds->Min[2]-m->bds->Max[2])); m->bds->Max[0]) +
(m->bds->Min[1] - m->bds->Max[1]) * (m->bds->Min[1] -
m->bds->Max[1]) +
(m->bds->Min[2] - m->bds->Max[2]) * (m->bds->Min[2] -
m->bds->Max[2]));
List_Delete(vertices); List_Delete(vertices);
for(int i = 0; i < List_Nbr(m->PhysicalGroups); i++) { for(int i = 0; i < List_Nbr(m->PhysicalGroups); i++) {
...@@ -81,93 +90,115 @@ void Mesh_To_BDS(Mesh *m) ...@@ -81,93 +90,115 @@ void Mesh_To_BDS(Mesh *m)
} }
} }
Msg(STATUS2, "Moving the curves\n"); Msg(STATUS2, "Moving curves");
List_T *curves = Tree2List(m->Curves); List_T *curves = Tree2List(m->Curves);
for (int i=0;i<List_Nbr ( curves ) ;++i) for(int i = 0; i < List_Nbr(curves); ++i) {
{
Curve *c; Curve *c;
List_Read(curves, i, &c); List_Read(curves, i, &c);
m->bds->add_geom(c->Num, 1); m->bds->add_geom(c->Num, 1);
BDS_GeomEntity *g = m->bds->get_geom(c->Num, 1); BDS_GeomEntity *g = m->bds->get_geom(c->Num, 1);
List_T *simplices = Tree2List(c->Simplexes); List_T *simplices = Tree2List(c->Simplexes);
Simplex *simp; Simplex *simp;
for (int j=0;j<List_Nbr ( simplices) ;++j) for(int j = 0; j < List_Nbr(simplices); ++j) {
{
List_Read(simplices, j, &simp); List_Read(simplices, j, &simp);
BDS_Edge *edge = m->bds->add_edge(simp->V[0]->Num, simp->V[1]->Num); BDS_Edge *edge = m->bds->add_edge(simp->V[0]->Num, simp->V[1]->Num);
edge->g = g; edge->g = g;
if (!edge->p1->g)edge->p1->g = g; if(!edge->p1->g)
if (!edge->p2->g)edge->p2->g = g; edge->p1->g = g;
if(!edge->p2->g)
edge->p2->g = g;
} }
List_Delete(simplices); List_Delete(simplices);
} }
List_Delete(curves); List_Delete(curves);
Msg(STATUS2, "Moving the surfaces\n");
Msg(STATUS2, "Moving surfaces");
List_T *surfaces = Tree2List(m->Surfaces); List_T *surfaces = Tree2List(m->Surfaces);
for (int i=0;i<List_Nbr ( surfaces ) ;++i) for(int i = 0; i < List_Nbr(surfaces); ++i) {
{
Surface *s; Surface *s;
List_Read(surfaces, i, &s); List_Read(surfaces, i, &s);
m->bds->add_geom(s->Num, 2); m->bds->add_geom(s->Num, 2);
BDS_GeomEntity *g = m->bds->get_geom(s->Num, 2); BDS_GeomEntity *g = m->bds->get_geom(s->Num, 2);
printf("a new surface %d %d is created\n",g->classif_tag,g->classif_degree); Msg(INFO, "Created new surface %d %d", g->classif_tag, g->classif_degree);
List_T *simplices = Tree2List(s->Simplexes); List_T *simplices = Tree2List(s->Simplexes);
Simplex *simp; Simplex *simp;
for (int j=0;j<List_Nbr ( simplices) ;++j) for(int j = 0; j < List_Nbr(simplices); ++j) {
{
List_Read(simplices, j, &simp); List_Read(simplices, j, &simp);
BDS_Triangle *t = m->bds->add_triangle (simp->V[0]->Num,simp->V[1]->Num,simp->V[2]->Num); BDS_Triangle *t =
m->bds->add_triangle(simp->V[0]->Num, simp->V[1]->Num,
simp->V[2]->Num);
t->g = g; t->g = g;
BDS_Point *n[3]; BDS_Point *n[3];
t->getNodes(n); t->getNodes(n);
for(int K = 0; K < 3; K++) for(int K = 0; K < 3; K++)
if (!n[K]->g) n[K]->g = g; if(!n[K]->g)
if (!t->e1->g)t->e1->g = g; n[K]->g = g;
if (!t->e2->g)t->e2->g = g; if(!t->e1->g)
if (!t->e3->g)t->e3->g = g; t->e1->g = g;
if(!t->e2->g)
t->e2->g = g;
if(!t->e3->g)
t->e3->g = g;
} }
List_Delete(simplices); List_Delete(simplices);
} }
List_Delete(surfaces); List_Delete(surfaces);
Msg(STATUS2, "Moving the %d volumes\n",Tree_Nbr(m->Volumes)); Msg(STATUS2, "Moving %d volumes", Tree_Nbr(m->Volumes));
List_T *volumes = Tree2List(m->Volumes); List_T *volumes = Tree2List(m->Volumes);
for (int i=0;i<List_Nbr ( volumes ) ;++i) for(int i = 0; i < List_Nbr(volumes); ++i) {
{
Volume *v; Volume *v;
List_Read(volumes, i, &v); List_Read(volumes, i, &v);
m->bds->add_geom(v->Num, 3); m->bds->add_geom(v->Num, 3);
BDS_GeomEntity *g = m->bds->get_geom(v->Num, 3); BDS_GeomEntity *g = m->bds->get_geom(v->Num, 3);
List_T *simplices = Tree2List(v->Simplexes); List_T *simplices = Tree2List(v->Simplexes);
Simplex *simp; Simplex *simp;
printf("%d tets\n",List_Nbr ( simplices));
for (int j=0;j<List_Nbr ( simplices) ;++j) for(int j = 0; j < List_Nbr(simplices); ++j) {
{
List_Read(simplices, j, &simp); List_Read(simplices, j, &simp);
BDS_Tet *t = m->bds->add_tet (simp->V[0]->Num,simp->V[1]->Num,simp->V[2]->Num,simp->V[3]->Num); BDS_Tet *t =
m->bds->add_tet(simp->V[0]->Num, simp->V[1]->Num, simp->V[2]->Num,
simp->V[3]->Num);
t->g = g; t->g = g;
BDS_Point *n[4]; BDS_Point *n[4];
t->getNodes(n); t->getNodes(n);
for(int K = 0; K < 4; K++) for(int K = 0; K < 4; K++)
if (!n[K]->g) n[K]->g = g; if(!n[K]->g)
if (!t->f1->g) t->f1->g = g; n[K]->g = g;
if (!t->f2->g) t->f2->g = g; if(!t->f1->g)
if (!t->f3->g) t->f3->g = g; t->f1->g = g;
if (!t->f4->g) t->f4->g = g; if(!t->f2->g)
if (!t->f1->e1->g) t->f1->e1->g = g; t->f2->g = g;
if (!t->f2->e1->g) t->f2->e1->g = g; if(!t->f3->g)
if (!t->f3->e1->g) t->f3->e1->g = g; t->f3->g = g;
if (!t->f4->e1->g) t->f4->e1->g = g; if(!t->f4->g)
if (!t->f1->e2->g) t->f1->e2->g = g; t->f4->g = g;
if (!t->f2->e2->g) t->f2->e2->g = g; if(!t->f1->e1->g)
if (!t->f3->e2->g) t->f3->e2->g = g; t->f1->e1->g = g;
if (!t->f4->e2->g) t->f4->e2->g = g; if(!t->f2->e1->g)
if (!t->f1->e3->g) t->f1->e3->g = g; t->f2->e1->g = g;
if (!t->f2->e3->g) t->f2->e3->g = g; if(!t->f3->e1->g)
if (!t->f3->e3->g) t->f3->e3->g = g; t->f3->e1->g = g;
if (!t->f4->e3->g) t->f4->e3->g = g; if(!t->f4->e1->g)
t->f4->e1->g = g;
if(!t->f1->e2->g)
t->f1->e2->g = g;
if(!t->f2->e2->g)
t->f2->e2->g = g;
if(!t->f3->e2->g)
t->f3->e2->g = g;
if(!t->f4->e2->g)
t->f4->e2->g = g;
if(!t->f1->e3->g)
t->f1->e3->g = g;
if(!t->f2->e3->g)
t->f2->e3->g = g;
if(!t->f3->e3->g)
t->f3->e3->g = g;
if(!t->f4->e3->g)
t->f4->e3->g = g;
} }
List_Delete(simplices); List_Delete(simplices);
...@@ -175,41 +206,36 @@ void Mesh_To_BDS(Mesh *m) ...@@ -175,41 +206,36 @@ void Mesh_To_BDS(Mesh *m)
List_Delete(volumes); List_Delete(volumes);
} }
extern int addMeshPartition(int Num, Mesh * M); extern int addMeshPartition(int Num, Mesh * M);
void BDS_To_Mesh_2(Mesh * m) void BDS_To_Mesh_2(Mesh * m)
{ {
Msg(STATUS2, "Moving the surface mesh in the old gmsh structure\n"); Msg(STATUS2, "Moving surface mesh into old structure");
printf("coiucouce\n");
Tree_Action(m->Vertices, Free_Vertex); Tree_Action(m->Vertices, Free_Vertex);
Tree_Delete(m->Vertices); Tree_Delete(m->Vertices);
m->Vertices = Tree_Create(sizeof(Vertex *), compareVertex); m->Vertices = Tree_Create(sizeof(Vertex *), compareVertex);
{ {
std::set<BDS_Point*, PointLessThan>::iterator it = m->bds_mesh->points.begin(); std::set < BDS_Point *, PointLessThan >::iterator it =
std::set<BDS_Point*, PointLessThan>::iterator ite = m->bds_mesh->points.end(); m->bds_mesh->points.begin();
while (it != ite) std::set < BDS_Point *, PointLessThan >::iterator ite =
{ m->bds_mesh->points.end();
Vertex *vert = Create_Vertex((*it)->iD, (*it)->X,(*it)->Y,(*it)->Z, 1.0, 0.0); while(it != ite) {
Vertex *vert =
Create_Vertex((*it)->iD, (*it)->X, (*it)->Y, (*it)->Z, 1.0, 0.0);
Tree_Add(m->Vertices, &vert); Tree_Add(m->Vertices, &vert);
++it; ++it;
} }
} }
printf("coiucouce\n");
{ {
std::list < BDS_Edge * >::iterator it = m->bds_mesh->edges.begin(); std::list < BDS_Edge * >::iterator it = m->bds_mesh->edges.begin();
std::list < BDS_Edge * >::iterator ite = m->bds_mesh->edges.end(); std::list < BDS_Edge * >::iterator ite = m->bds_mesh->edges.end();
while(it!=ite) while(it != ite) {
{
BDS_GeomEntity *g = (*it)->g; BDS_GeomEntity *g = (*it)->g;
if (g && g->classif_degree == 1) if(g && g->classif_degree == 1) {
{
Vertex *v1 = FindVertex((*it)->p1->iD, m); Vertex *v1 = FindVertex((*it)->p1->iD, m);
Vertex *v2 = FindVertex((*it)->p2->iD, m); Vertex *v2 = FindVertex((*it)->p2->iD, m);
Simplex *simp = Create_Simplex(v1, v2, NULL, NULL); Simplex *simp = Create_Simplex(v1, v2, NULL, NULL);
...@@ -221,14 +247,14 @@ void BDS_To_Mesh_2(Mesh *m) ...@@ -221,14 +247,14 @@ void BDS_To_Mesh_2(Mesh *m)
++it; ++it;
} }
} }
printf("coiucouce\n");
{ {
std::list<BDS_Triangle*>::iterator it = m->bds_mesh->triangles.begin(); std::list < BDS_Triangle * >::iterator it =
m->bds_mesh->triangles.begin();
std::list < BDS_Triangle * >::iterator ite = m->bds_mesh->triangles.end(); std::list < BDS_Triangle * >::iterator ite = m->bds_mesh->triangles.end();
while(it != ite) { while(it != ite) {
BDS_GeomEntity *g = (*it)->g; BDS_GeomEntity *g = (*it)->g;
if (g && g->classif_degree == 2) if(g && g->classif_degree == 2) {
{
BDS_Point *nod[3]; BDS_Point *nod[3];
(*it)->getNodes(nod); (*it)->getNodes(nod);
Vertex *v1 = FindVertex(nod[0]->iD, m); Vertex *v1 = FindVertex(nod[0]->iD, m);
...@@ -237,19 +263,18 @@ void BDS_To_Mesh_2(Mesh *m) ...@@ -237,19 +263,18 @@ void BDS_To_Mesh_2(Mesh *m)
Simplex *simp = Create_Simplex(v1, v2, v3, NULL); Simplex *simp = Create_Simplex(v1, v2, v3, NULL);
BDS_GeomEntity *g = (*it)->g; BDS_GeomEntity *g = (*it)->g;
Surface *s = FindSurface(g->classif_tag, m); Surface *s = FindSurface(g->classif_tag, m);
if(s) if(s) {
{
simp->iEnt = g->classif_tag; simp->iEnt = g->classif_tag;
simp->iPart = addMeshPartition((*it)->partition, m); simp->iPart = addMeshPartition((*it)->partition, m);
} }
else else
printf("impossible to find surface %d\n",g->classif_tag); Msg(GERROR, "Impossible to find surface %d", g->classif_tag);
Tree_Add(s->Simplexes, &simp); Tree_Add(s->Simplexes, &simp);
} }
++it; ++it;
} }
} }
printf("coiucoucessss\n");
{ {
std::list < BDS_Tet * >::iterator it = m->bds_mesh->tets.begin(); std::list < BDS_Tet * >::iterator it = m->bds_mesh->tets.begin();
std::list < BDS_Tet * >::iterator ite = m->bds_mesh->tets.end(); std::list < BDS_Tet * >::iterator ite = m->bds_mesh->tets.end();
...@@ -263,18 +288,18 @@ void BDS_To_Mesh_2(Mesh *m) ...@@ -263,18 +288,18 @@ void BDS_To_Mesh_2(Mesh *m)
Simplex *simp = Create_Simplex(v1, v2, v3, v4); Simplex *simp = Create_Simplex(v1, v2, v3, v4);
BDS_GeomEntity *g = (*it)->g; BDS_GeomEntity *g = (*it)->g;
Volume *v = FindVolume(g->classif_tag, m); Volume *v = FindVolume(g->classif_tag, m);
if(v) if(v) {
{
simp->iEnt = g->classif_tag; simp->iEnt = g->classif_tag;
simp->iPart = addMeshPartition((*it)->partition, m); simp->iPart = addMeshPartition((*it)->partition, m);
} }
else else
printf("argh\n"); Msg(GERROR, "Error in BDS");
Tree_Add(v->Simplexes, &simp); Tree_Add(v->Simplexes, &simp);
++it; ++it;
} }
} }
Msg(STATUS2, "Ready");
Msg(STATUS3N, "Ready");
} }
void BDS_To_Mesh(Mesh * m) void BDS_To_Mesh(Mesh * m)
...@@ -292,22 +317,20 @@ void BDS_To_Mesh(Mesh *m) ...@@ -292,22 +317,20 @@ void BDS_To_Mesh(Mesh *m)
m->Surfaces = Tree_Create(sizeof(Surface *), compareSurface); m->Surfaces = Tree_Create(sizeof(Surface *), compareSurface);
m->Volumes = Tree_Create(sizeof(Volume *), compareVolume); m->Volumes = Tree_Create(sizeof(Volume *), compareVolume);
std::set < BDS_GeomEntity *, GeomLessThan >::iterator it =
m->bds->geom.begin();
std::set < BDS_GeomEntity *, GeomLessThan >::iterator ite =
m->bds->geom.end();
std::set<BDS_GeomEntity*,GeomLessThan>::iterator it = m->bds->geom.begin(); while(it != ite) {
std::set<BDS_GeomEntity*,GeomLessThan>::iterator ite = m->bds->geom.end(); if((*it)->classif_degree == 3) {
while (it != ite)
{
if ((*it)->classif_degree ==3 )
{
Volume *_Vol = 0; Volume *_Vol = 0;
_Vol = FindVolume((*it)->classif_tag, m); _Vol = FindVolume((*it)->classif_tag, m);
if(!_Vol) if(!_Vol)
_Vol = Create_Volume((*it)->classif_tag, MSH_VOLUME_DISCRETE); _Vol = Create_Volume((*it)->classif_tag, MSH_VOLUME_DISCRETE);
Tree_Add(m->Volumes, &_Vol); Tree_Add(m->Volumes, &_Vol);
} }
else if ((*it)->classif_degree ==2 ) else if((*it)->classif_degree == 2) {
{
Surface *_Surf = 0; Surface *_Surf = 0;
_Surf = FindSurface((*it)->classif_tag, m); _Surf = FindSurface((*it)->classif_tag, m);
if(!_Surf) if(!_Surf)
...@@ -316,21 +339,20 @@ void BDS_To_Mesh(Mesh *m) ...@@ -316,21 +339,20 @@ void BDS_To_Mesh(Mesh *m)
End_Surface(_Surf); End_Surface(_Surf);
Tree_Add(m->Surfaces, &_Surf); Tree_Add(m->Surfaces, &_Surf);
} }
else if ((*it)->classif_degree ==1 ) else if((*it)->classif_degree == 1) {
{
Curve *_c = 0; Curve *_c = 0;
_c = FindCurve((*it)->classif_tag, m); _c = FindCurve((*it)->classif_tag, m);
if(!_c) if(!_c)
_c = Create_Curve((*it)->classif_tag, MSH_SEGM_DISCRETE, 1, NULL, NULL, -1, -1, 0., 1.); _c =
Create_Curve((*it)->classif_tag, MSH_SEGM_DISCRETE, 1, NULL, NULL,
-1, -1, 0., 1.);
// _c->bds = m->bds; // _c->bds = m->bds;
End_Curve(_c); End_Curve(_c);
Tree_Add(m->Curves, &_c); Tree_Add(m->Curves, &_c);
} }
else if ((*it)->classif_degree == 0 ) else if((*it)->classif_degree == 0) {
{
BDS_Point *p = (*it)->p; BDS_Point *p = (*it)->p;
if (p) if(p) {
{
Vertex *_v = Create_Vertex(p->iD, p->X, p->Y, p->Z, 1, 0); Vertex *_v = Create_Vertex(p->iD, p->X, p->Y, p->Z, 1, 0);
Tree_Add(m->Points, &_v); Tree_Add(m->Points, &_v);
} }
...@@ -339,17 +361,14 @@ void BDS_To_Mesh(Mesh *m) ...@@ -339,17 +361,14 @@ void BDS_To_Mesh(Mesh *m)
} }
CTX.mesh.changed = 1; CTX.mesh.changed = 1;
} }
int ReMesh(Mesh * M) int ReMesh(Mesh * M)
{ {
printf("status %d\n",M->status); if(M->status != 2)
if(M->status != 2) return 0; return 0;
if (!M->bds) if(!M->bds) {
{
Mesh_To_BDS(M); Mesh_To_BDS(M);
M->bds->classify(CTX.mesh.dihedral_angle_tol * M_PI / 180); M->bds->classify(CTX.mesh.dihedral_angle_tol * M_PI / 180);
BDS_To_Mesh(M); BDS_To_Mesh(M);
...@@ -357,8 +376,7 @@ int ReMesh(Mesh *M) ...@@ -357,8 +376,7 @@ int ReMesh(Mesh *M)
DeleteMesh(M); DeleteMesh(M);
if (M->bds_mesh) if(M->bds_mesh) {
{
delete M->bds_mesh; delete M->bds_mesh;
M->bds_mesh = 0; M->bds_mesh = 0;
} }
...@@ -378,19 +396,24 @@ int MeshDiscreteSurface(Surface *s) ...@@ -378,19 +396,24 @@ int MeshDiscreteSurface(Surface *s)
BDS_Metric metric(THEM->bds->LC / CTX.mesh.target_elem_size_fact, BDS_Metric metric(THEM->bds->LC / CTX.mesh.target_elem_size_fact,
THEM->bds->LC / CTX.mesh.min_elem_size_fact, THEM->bds->LC / CTX.mesh.min_elem_size_fact,
THEM->bds->LC, THEM->bds->LC,
CTX.mesh.beta_smooth_metric, CTX.mesh.beta_smooth_metric, CTX.mesh.nb_elem_per_rc);
CTX.mesh.nb_elem_per_rc);
Msg(STATUS2, "Discrete Surface Mesh Generator...");
if(!THEM->bds_mesh) { if(!THEM->bds_mesh) {
Msg(STATUS2, "Remesh 2D...");
double t1 = Cpu();
THEM->bds_mesh = new BDS_Mesh(*(THEM->bds)); THEM->bds_mesh = new BDS_Mesh(*(THEM->bds));
int iter = 0; int iter = 0;
while(iter < NITER && THEM->bds_mesh->adapt_mesh(metric, true, THEM->bds)) { while(iter < NITER && THEM->bds_mesh->adapt_mesh(metric, true, THEM->bds)) {
Msg(STATUS2, "Iteration %2d/%d done (%d triangles)\n",iter, NITER,THEM->bds_mesh->triangles.size()); Msg(STATUS3, "Iter=%d/%d Tri=%d", iter, NITER, THEM->bds_mesh->triangles.size());
iter++; iter++;
} }
BDS_To_Mesh_2(THEM); BDS_To_Mesh_2(THEM);
Msg(STATUS2, "Mesh has %d vertices (%d)\n",Tree_Nbr(THEM->Vertices),THEM->bds->points.size()); Msg(INFO, "Mesh has %d vertices (%d)", Tree_Nbr(THEM->Vertices),
THEM->bds->points.size());
// THEM->bds_mesh->save_gmsh_format("3.msh"); // THEM->bds_mesh->save_gmsh_format("3.msh");
double t2 = Cpu();
Msg(STATUS2, "Remesh 2D complete (%g s)", t2 - t1);
return 1; return 1;
} }
return 2; return 2;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment