From daa83a3d2512e36eaf5e7450956cc287c8dfbaa7 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 22 Feb 2008 20:28:07 +0000 Subject: [PATCH] * revert last commit from laurent * new getNumElements() et getElement() functions in GEdge/Face/Region to simplify access to mesh --- Geo/GEdge.cpp | 22 ++++++++++++--------- Geo/GEdge.h | 11 ++++++----- Geo/GEntity.cpp | 18 +---------------- Geo/GEntity.h | 4 ---- Geo/GFace.cpp | 32 +++++++++++++++---------------- Geo/GFace.h | 9 +++++---- Geo/GModel.cpp | 49 +---------------------------------------------- Geo/GModel.h | 6 ------ Geo/GRegion.cpp | 45 ++++++++++++++++++------------------------- Geo/GRegion.h | 8 ++++---- Graphics/Post.cpp | 4 ++-- 11 files changed, 66 insertions(+), 142 deletions(-) diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp index 4fcb2ccb48..7ed1aaedd8 100644 --- a/Geo/GEdge.cpp +++ b/Geo/GEdge.cpp @@ -1,4 +1,4 @@ -// $Id: GEdge.cpp,v 1.41 2008-02-22 17:58:12 miegroet Exp $ +// $Id: GEdge.cpp,v 1.42 2008-02-22 20:28:06 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -53,6 +53,18 @@ GEdge::~GEdge() delete lines[i]; } +int GEdge::getNumElements() +{ + return lines.size(); +} + +MElement *GEdge::getElement(int index) +{ + if(index < lines.size()) + return lines[index]; + return 0; +} + void GEdge::resetMeshAttributes() { meshAttributes.Method = LIBRE; @@ -191,11 +203,3 @@ double GEdge::length(const double &u0, const double &u1, const int nbQuadPoints) #endif } -void GEdge::getTypeOfElements(std::vector<int> &groups) -{ - for(unsigned int j = 0; j < lines.size(); j++) - { - int type = lines[j]->getTypeForMSH(); - this->addThisTypeOfElement(type,groups); - } -} \ No newline at end of file diff --git a/Geo/GEdge.h b/Geo/GEdge.h index 799322d997..481deb1245 100644 --- a/Geo/GEdge.h +++ b/Geo/GEdge.h @@ -107,14 +107,15 @@ class GEdge : public GEntity { // one can impose the mesh size at an edge virtual double prescribedMeshSizeAtVertex() const { return meshAttributes.meshSize; } - // Resets the mesh attributes to default values - virtual void resetMeshAttributes(); - // True if start == end and no more than 2 segments bool isMeshDegenerated() const{ return (v0 == v1 && mesh_vertices.size() < 2); } -// Returns each type of element in the gentity - void getTypeOfElements(std::vector<int> &groups); + // Get number of elements in the mesh and get element by index + int getNumElements(); + MElement *getElement(int index); + + // Resets the mesh attributes to default values + virtual void resetMeshAttributes(); struct { char Method; diff --git a/Geo/GEntity.cpp b/Geo/GEntity.cpp index 89288341dc..80f7441293 100644 --- a/Geo/GEntity.cpp +++ b/Geo/GEntity.cpp @@ -1,4 +1,4 @@ -// $Id: GEntity.cpp,v 1.19 2008-02-22 17:58:12 miegroet Exp $ +// $Id: GEntity.cpp,v 1.20 2008-02-22 20:28:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -90,19 +90,3 @@ std::string GEntity::getInfoString() return out; } - - -inline -void GEntity::addThisTypeOfElement(int type,std::vector<int> &groups) -{ - unsigned int size=groups.size(); - if(size==0) - groups.push_back(type); - for(unsigned int i=0;i<size;i++) - { - if(type==groups[i]) - break; - else - groups.push_back(type); - } -} diff --git a/Geo/GEntity.h b/Geo/GEntity.h index bb5c43dc5c..541d6850de 100644 --- a/Geo/GEntity.h +++ b/Geo/GEntity.h @@ -244,10 +244,6 @@ class GEntity { // Vertex arrays to draw the mesh efficiently VertexArray *va_lines, *va_triangles; - - // Returns all type of element in the GEntity - virtual void getTypeOfElements(std::vector<int> &)const { throw; } - virtual void addThisTypeOfElement(int type,std::vector<int> &groups); }; class GEntityLessThan { diff --git a/Geo/GFace.cpp b/Geo/GFace.cpp index 6ce8a0b2d8..4b848c33dc 100644 --- a/Geo/GFace.cpp +++ b/Geo/GFace.cpp @@ -1,4 +1,4 @@ -// $Id: GFace.cpp,v 1.54 2008-02-22 17:58:12 miegroet Exp $ +// $Id: GFace.cpp,v 1.55 2008-02-22 20:28:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -73,6 +73,20 @@ GFace::~GFace() delete va_geom_triangles; } +int GFace::getNumElements() +{ + return triangles.size() + quadrangles.size(); +} + +MElement *GFace::getElement(int index) +{ + if(index < triangles.size()) + return triangles[i]; + else if(index < triangles.size() + quadrangles.size()) + return quadrangles[index - triangles.size()]; + return 0; +} + void GFace::resetMeshAttributes() { meshAttributes.recombine = 0; @@ -718,19 +732,3 @@ double GFace::length(const SPoint2 &pt1, const SPoint2 &pt2, int nbQuadPoints) return L; #endif } - -void GFace::getTypeOfElements(std::vector<int> &groups) -{ - for(unsigned int j = 0; j < triangles.size(); j++) - { - int type = triangles[j]->getTypeForMSH(); - addThisTypeOfElement(type,groups); - } - for(unsigned int j = 0; j < quadrangles.size(); j++) - { - int type = quadrangles[j]->getTypeForMSH(); - addThisTypeOfElement(type,groups); - } -} - - diff --git a/Geo/GFace.h b/Geo/GFace.h index f4e1bef707..3e8a1ddd3e 100644 --- a/Geo/GFace.h +++ b/Geo/GFace.h @@ -162,6 +162,10 @@ class GFace : public GEntity double &x, double &y, double &z) const; void getMeanPlaneData(double plan[3][3]) const; + // Get number of elements in the mesh and get element by index + int getNumElements(); + MElement *getElement(int index); + // Resets the mesh attributes to default values virtual void resetMeshAttributes(); @@ -184,7 +188,7 @@ class GFace : public GEntity // edge loops } meshAttributes ; - typedef enum {PENDING,DONE,FAILED} meshGenerationStatus; + typedef enum {PENDING, DONE, FAILED} meshGenerationStatus; struct { meshGenerationStatus status; double worst_element_shape, best_element_shape, average_element_shape; @@ -206,9 +210,6 @@ class GFace : public GEntity std::vector<MTriangle*> triangles; std::vector<MQuadrangle*> quadrangles; - - // Returns each type of element in the gentity - void getTypeOfElements(std::vector<int> &groups); }; #endif diff --git a/Geo/GModel.cpp b/Geo/GModel.cpp index b42671dc07..14035ab3cc 100644 --- a/Geo/GModel.cpp +++ b/Geo/GModel.cpp @@ -1,4 +1,4 @@ -// $Id: GModel.cpp,v 1.63 2008-02-22 17:58:12 miegroet Exp $ +// $Id: GModel.cpp,v 1.64 2008-02-22 20:28:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -721,50 +721,3 @@ void GModel::checkMeshCoherence() } } -//maybe UseLess as we can get each vector directly through the GEntities -void GModel::getTypeOfElements(std::map<GEntity*, std::vector<int> > groups[3]) -{ - //for(viter it = firstVertex(); it != lastVertex(); ++it) - // (*it)->getTypeOfElements(groups[0][(*it)]); - - for(eiter it = firstEdge(); it != lastEdge(); ++it) - (*it)->getTypeOfElements(groups[0][(*it)]); - - - for(fiter it = firstFace(); it != lastFace(); ++it) - (*it)->getTypeOfElements(groups[1][(*it)]); - - for(riter it = firstRegion(); it != lastRegion(); ++it) - (*it)->getTypeOfElements(groups[2][(*it)]); - -} - -void GModel::getTypeOfElements(std::map<int, std::vector<int> > groups[3]) -{ - //for(unsigned int i=0;i<(*it)->physicals.size();i++) - // (*it)->getTypeOfElements(groups[0][i]); - - for(eiter it = firstEdge(); it != lastEdge(); ++it){ - if((*it)->physicals.size()){ - (*it)->getTypeOfElements(groups[0][(*it)->physicals[0]]); - for(unsigned int i=1;i<(*it)->physicals.size();i++) - groups[0][(*it)->physicals[i]]=groups[0][(*it)->physicals[i-1]]; - } - } - - for(fiter it = firstFace(); it != lastFace(); ++it){ - if((*it)->physicals.size()){ - (*it)->getTypeOfElements(groups[1][(*it)->physicals[0]]); - for(unsigned int i=1;i<(*it)->physicals.size();i++) - groups[1][(*it)->physicals[i]]=groups[1][(*it)->physicals[i-1]]; - } - } - for(riter it = firstRegion(); it != lastRegion(); ++it){ - if((*it)->physicals.size()){ - (*it)->getTypeOfElements(groups[2][(*it)->physicals[0]]); - for(unsigned int i=1;i<(*it)->physicals.size();i++) - groups[2][(*it)->physicals[i]]=groups[2][(*it)->physicals[i-1]]; - } - } - -} diff --git a/Geo/GModel.h b/Geo/GModel.h index 8154579d5c..3c20afcf26 100644 --- a/Geo/GModel.h +++ b/Geo/GModel.h @@ -121,12 +121,6 @@ class GModel // Returns all physical groups (one map per dimension: 0-D to 3-D) void getPhysicalGroups(std::map<int, std::vector<GEntity*> > groups[4]); - // Returns all type of element in each GEntity (one map per dimension: 1-D to 3-D) - void getTypeOfElements(std::map<GEntity*, std::vector<int> > groups[3]); - - // Returns all type of element in each physical group (one map per dimension: 1-D to 3-D) - void getTypeOfElements(std::map<int, std::vector<int> > groups[3]); - // Deletes physical groups in the model void deletePhysicalGroups(); void deletePhysicalGroup(int dim, int num); diff --git a/Geo/GRegion.cpp b/Geo/GRegion.cpp index b4a63c2c5e..3776095b14 100644 --- a/Geo/GRegion.cpp +++ b/Geo/GRegion.cpp @@ -1,4 +1,4 @@ -// $Id: GRegion.cpp,v 1.23 2008-02-22 17:58:12 miegroet Exp $ +// $Id: GRegion.cpp,v 1.24 2008-02-22 20:28:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -59,6 +59,24 @@ GRegion::~GRegion() delete pyramids[i]; } +int GRegion::getNumElements() +{ + return tetrahedra.size() + hexahedra.size() + prisms.size() + pyramids.size(); +} + +MElement *GRegion::getElement(int index) +{ + if(index < tetrahedra.size()) + return tetrahedra[index]; + else if(index < tetrahedra.size() + hexahedra.size()) + return hexahedra[index - tetrahedra.size()]; + else if(index < tetrahedra.size() + hexahedra.size() + prisms.size()) + return prisms[index - tetrahedra.size() - hexahedra.size()]; + else if(index < tetrahedra.size() + hexahedra.size() + prisms.size() + pyramids.size()) + return pyramids[index - tetrahedra.size() - hexahedra.size() - prisms.size()]; + return 0; +} + void GRegion::resetMeshAttributes() { meshAttributes.Method = LIBRE; @@ -177,28 +195,3 @@ bool GRegion::edgeConnected(GRegion *r) const } return false; } - - - -void GRegion::getTypeOfElements(std::vector<int> &groups) -{ - for(unsigned int i = 0; i < tetrahedra.size(); i++){ - int type = tetrahedra[i]->getTypeForMSH(); - addThisTypeOfElement(type,groups); - } - - for(unsigned int i = 0; i < hexahedra.size(); i++){ - int type = hexahedra[i]->getTypeForMSH(); - addThisTypeOfElement(type,groups); - } - - for(unsigned int i = 0; i < prisms.size(); i++){ - int type = prisms[i]->getTypeForMSH(); - addThisTypeOfElement(type,groups); - } - - for(unsigned int i = 0; i < pyramids.size(); i++) { - int type = pyramids[i]->getTypeForMSH(); - addThisTypeOfElement(type,groups); - } -} \ No newline at end of file diff --git a/Geo/GRegion.h b/Geo/GRegion.h index c9a3d86207..eebcc75864 100644 --- a/Geo/GRegion.h +++ b/Geo/GRegion.h @@ -59,6 +59,10 @@ class GRegion : public GEntity { // Returns a type-specific additional information string virtual std::string getAdditionalInfoString(); + // Get number of elements in the mesh and get element by index + int getNumElements(); + MElement *getElement(int index); + // Resets the mesh attributes to default values virtual void resetMeshAttributes(); @@ -74,10 +78,6 @@ class GRegion : public GEntity { // indices std::vector<std::vector<std::vector<MVertex*> > > transfinite_vertices; -// Returns each type of element in the gentity - void getTypeOfElements(std::vector<int> &groups); - - std::vector<MTetrahedron*> tetrahedra; std::vector<MHexahedron*> hexahedra; std::vector<MPrism*> prisms; diff --git a/Graphics/Post.cpp b/Graphics/Post.cpp index 6e67a98151..e564c42652 100644 --- a/Graphics/Post.cpp +++ b/Graphics/Post.cpp @@ -1,4 +1,4 @@ -// $Id: Post.cpp,v 1.149 2008-02-22 15:14:03 remacle Exp $ +// $Id: Post.cpp,v 1.150 2008-02-22 20:28:07 geuzaine Exp $ // // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // @@ -1015,7 +1015,7 @@ void drawVectorArray(PView *p, VertexArray *va) double scale = opt->ArrowSize / max; double px = v[0] * scale, py = v[1] * scale, pz = v[2] * scale; // only draw vectors larger than 1 pixel on screen - if(1 || fabs(px) > 1. || fabs(py) > 1. || fabs(pz) > 1.){ + if(fabs(px) > 1. || fabs(py) > 1. || fabs(pz) > 1.){ double d = CTX.pixel_equiv_x / CTX.s[0]; double dx = px * d, dy = py * d, dz = pz * d; double x = s[0], y = s[1], z = s[2]; -- GitLab