diff --git a/Geo/GEdge.cpp b/Geo/GEdge.cpp index 4fcb2ccb487d6666d1833c844690307791ba2f02..7ed1aaedd8bc3107acc75e2be30aa0c3607daf54 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 799322d9971ebac778ec6ed28509e07c091955c8..481deb124513af4a4de61c92a56c30d379ed6327 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 89288341dc4a8ca14217801121e7d84e8141c63b..80f744129363354f913eaa99b19a64b6ab1b537a 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 bb5c43dc5c6e7cd7a8e95083de179e5dc65cb48d..541d6850de780c4c58aff2c4a95425ff971e9420 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 6ce8a0b2d8750f10979b1fe06d57862bbf0a36ac..4b848c33dc774d9f5f7632f889d4ca9a88b2b6e4 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 f4e1bef707d8ca27dc060ab04ee9357e1706e7b9..3e8a1ddd3e539b5bc2837d53c89d9f92f0396574 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 b42671dc07fa09397564083a60438fc4f80277ce..14035ab3ccd325c28a9b422abf44de71155c3ba4 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 8154579d5c900cf7e34cc46dd55060f929c2cc22..3c20afcf2669f877d1d0d64363d631b3de324834 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 b4a63c2c5e037dc92464c07d09ee9f036543836f..3776095b148cf43dff399a509de293c3da8edaa6 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 c9a3d86207a1ce1576c2aebf658917c602ba08db..eebcc758640a0aff35ca6a0c88476f8db24e1788 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 6e67a98151c9bc82eb8d0a0bce37b66f26a6e472..e564c42652c4d0074ce6e51aec1c34331f0c1d92 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];