From ea938759a80b81e82c3512fbb94b7b99fcdc3efa Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 14 May 2010 21:47:37 +0000 Subject: [PATCH] don't mesh GVertices in the constructor: this has nasty side effects when loading geos+mesh+new post-processing datasets -> Mesh0D in Generator Please test: this change could have unexpected consequences... :-) --- Geo/ACISVertex.cpp | 3 --- Geo/GModel.cpp | 7 +++++-- Geo/GVertex.h | 2 ++ Geo/OCCVertex.cpp | 2 -- Geo/fourierVertex.h | 5 +---- Geo/gmshVertex.cpp | 2 -- Mesh/Generator.cpp | 13 +++++++++++++ 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Geo/ACISVertex.cpp b/Geo/ACISVertex.cpp index 1c77922e3b..8699be4be3 100644 --- a/Geo/ACISVertex.cpp +++ b/Geo/ACISVertex.cpp @@ -17,9 +17,6 @@ ACISVertex::ACISVertex(GModel *m, int num, VERTEX *v) _x = pos.coordinate(0); _y = pos.coordinate(1); _z = pos.coordinate(2); - - mesh_vertices.push_back(new MVertex(x(), y(), z(), this)); - points.push_back(new MPoint(mesh_vertices.back())); } void ACISVertex::setPosition(GPoint &p) diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index 2b873a0a60..30f13816ba 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -474,8 +474,11 @@ SBoundingBox3d GModel::bounds() // using the mesh vertices for now; should use entities[i]->bounds() instead SBoundingBox3d bb; for(unsigned int i = 0; i < entities.size(); i++) - for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++) - bb += entities[i]->mesh_vertices[j]->point(); + if(entities[i]->dim() == 0) + bb += static_cast<GVertex*>(entities[i])->xyz(); + else + for(unsigned int j = 0; j < entities[i]->mesh_vertices.size(); j++) + bb += entities[i]->mesh_vertices[j]->point(); return bb; } diff --git a/Geo/GVertex.h b/Geo/GVertex.h index 3b6800dd20..d179e6fac7 100644 --- a/Geo/GVertex.h +++ b/Geo/GVertex.h @@ -13,6 +13,7 @@ #include "GEntity.h" #include "GPoint.h" #include "SPoint2.h" +#include "SPoint3.h" #define MAX_LC 1.e22 @@ -37,6 +38,7 @@ class GVertex : public GEntity virtual double x() const = 0; virtual double y() const = 0; virtual double z() const = 0; + virtual SPoint3 xyz() const { return SPoint3(x(), y(), z()); } virtual void setPosition(GPoint &p); // add/delete an edge bounded by this vertex diff --git a/Geo/OCCVertex.cpp b/Geo/OCCVertex.cpp index 3174f0c497..8c85e9e5f2 100644 --- a/Geo/OCCVertex.cpp +++ b/Geo/OCCVertex.cpp @@ -21,8 +21,6 @@ OCCVertex::OCCVertex(GModel *m, int num, TopoDS_Vertex _v) _x = pnt.X(); _y = pnt.Y(); _z = pnt.Z(); - mesh_vertices.push_back(new MVertex(x(), y(), z(), this)); - points.push_back(new MPoint(mesh_vertices.back())); } void OCCVertex::setPosition(GPoint &p) diff --git a/Geo/fourierVertex.h b/Geo/fourierVertex.h index 6eb87c7a88..567ea964c3 100644 --- a/Geo/fourierVertex.h +++ b/Geo/fourierVertex.h @@ -19,10 +19,7 @@ class fourierVertex : public GVertex { protected: FM::TopoVertex *v; public: - fourierVertex(GModel *m, int num, FM::TopoVertex* _v) : GVertex(m, num), v(_v) - { - mesh_vertices.push_back(new MVertex(x(), y(), z(), this)); - } + fourierVertex(GModel *m, int num, FM::TopoVertex* _v) : GVertex(m, num), v(_v){} virtual ~fourierVertex() {} virtual GPoint point() const { return GPoint(x(),y(),z()); } virtual double x() const { return v->GetX(); } diff --git a/Geo/gmshVertex.cpp b/Geo/gmshVertex.cpp index 713992cc78..4d724ef422 100644 --- a/Geo/gmshVertex.cpp +++ b/Geo/gmshVertex.cpp @@ -15,8 +15,6 @@ gmshVertex::gmshVertex(GModel *m, Vertex *_v) : GVertex(m, _v->Num, _v->lc), v(_v) { - mesh_vertices.push_back(new MVertex(x(), y(), z(), this)); - points.push_back(new MPoint(mesh_vertices.back())); } void gmshVertex::setPosition(GPoint &p) diff --git a/Mesh/Generator.cpp b/Mesh/Generator.cpp index 930fb3ec9a..da4b10461f 100644 --- a/Mesh/Generator.cpp +++ b/Mesh/Generator.cpp @@ -10,6 +10,7 @@ #include "Context.h" #include "OS.h" #include "GModel.h" +#include "MPoint.h" #include "MLine.h" #include "MTriangle.h" #include "MQuadrangle.h" @@ -333,6 +334,17 @@ static bool CancelDelaunayHybrid(GModel *m) return false; } +static void Mesh0D(GModel *m) +{ + for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); ++it){ + GVertex *gv = *it; + if(gv->mesh_vertices.empty()) + gv->mesh_vertices.push_back(new MVertex(gv->x(), gv->y(), gv->z(), gv)); + if(gv->points.empty()) + gv->points.push_back(new MPoint(gv->mesh_vertices.back())); + } +} + static void Mesh1D(GModel *m) { if(TooManyElements(m, 1)) return; @@ -593,6 +605,7 @@ void GenerateMesh(GModel *m, int ask) if(ask == 1 || (ask > 1 && old < 1)) { std::for_each(m->firstRegion(), m->lastRegion(), deMeshGRegion()); std::for_each(m->firstFace(), m->lastFace(), deMeshGFace()); + Mesh0D(m); Mesh1D(m); } -- GitLab