X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMDS%2FSMDS_MeshInfo.hxx;h=87a096f038ab90d75f7f472b8a0aef57c856fb4d;hb=1d668d5560d6e4fab6467d10fbbc9cda8e049a82;hp=8dbccac83965f144b2a56a836d24eef3f5dbab3b;hpb=79b1ac2b6df9117f16f11d444b1f165d477a1813;p=modules%2Fsmesh.git diff --git a/src/SMDS/SMDS_MeshInfo.hxx b/src/SMDS/SMDS_MeshInfo.hxx index 8dbccac83..87a096f03 100644 --- a/src/SMDS/SMDS_MeshInfo.hxx +++ b/src/SMDS/SMDS_MeshInfo.hxx @@ -1,12 +1,31 @@ +// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + // File : SMDS_MeshInfo.hxx // Created : Mon Sep 24 18:32:41 2007 // Author : Edward AGAPOV (eap) - -using namespace std; - +// #ifndef SMDS_MeshInfo_HeaderFile #define SMDS_MeshInfo_HeaderFile +using namespace std; + #include "SMESH_SMDS.hxx" #include "SMDS_MeshElement.hxx" @@ -16,9 +35,14 @@ class SMDS_EXPORT SMDS_MeshInfo public: inline SMDS_MeshInfo(); + inline SMDS_MeshInfo& operator=(const SMDS_MeshInfo& other); + inline void Clear(); int NbNodes() const { return myNbNodes; } + inline int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const; + inline int NbEntities(SMDSAbs_EntityType type) const; + int Nb0DElements() const { return myNb0DElements; } inline int NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const; inline int NbFaces (SMDSAbs_ElementOrder order = ORDER_ANY) const; inline int NbTriangles (SMDSAbs_ElementOrder order = ORDER_ANY) const; @@ -32,13 +56,16 @@ public: inline int NbPrisms (SMDSAbs_ElementOrder order = ORDER_ANY) const; int NbPolyhedrons() const { return myNbPolyhedrons; } +protected: + inline void addWithPoly(const SMDS_MeshElement* el); + private: friend class SMDS_Mesh; // methods to count NOT POLY elements inline void remove(const SMDS_MeshElement* el); inline void add (const SMDS_MeshElement* el); - inline int index(SMDSAbs_ElementType type, int nbNodes); + inline int index(SMDSAbs_ElementType type, int nbNodes) const; // methods to remove elements of ANY kind inline void RemoveEdge(const SMDS_MeshElement* el); inline void RemoveFace(const SMDS_MeshElement* el); @@ -46,6 +73,7 @@ private: int myNbNodes; + int myNb0DElements; int myNbEdges , myNbQuadEdges ; int myNbTriangles , myNbQuadTriangles ; int myNbQuadrangles, myNbQuadQuadrangles; @@ -57,12 +85,13 @@ private: int myNbPrisms , myNbQuadPrisms ; int myNbPolyhedrons; - vector myNb; // pointers to myNb... fields - vector myShift; // shift to get an index in myNb by elem->NbNodes() + std::vector myNb; // pointers to myNb... fields + std::vector myShift; // shift to get an index in myNb by elem->NbNodes() }; inline SMDS_MeshInfo::SMDS_MeshInfo(): myNbNodes(0), + myNb0DElements(0), myNbEdges (0), myNbQuadEdges (0), myNbTriangles (0), myNbQuadTriangles (0), myNbQuadrangles(0), myNbQuadQuadrangles(0), @@ -73,41 +102,48 @@ inline SMDS_MeshInfo::SMDS_MeshInfo(): myNbPrisms (0), myNbQuadPrisms (0), myNbPolyhedrons(0) { - // Number of nodes in standard element types - // n v f e - // o o a d - // d l c g - // e e e - // ----------- - // 1 - // 2 * - // 3 * - // 4 * * * - // 5 * - // 6 * * - // 7 - // 8 * * - // 9 - // 10 * - // 11 - // 12 - // 13 * - // 14 - // 15 * - // 16 - // 17 - // 18 - // 19 + // Number of nodes in standard element types (. - actual nb, * - after the shift) + // n v f e 0 n + // o o a d d o + // d l c g d + // e e e e + // s + // ----------------- + // 0 - DON't USE 0!!! + // 1 . * + // 2 . + // 3 . * + // 4 * . . + // 5 * + // 6 * . + // 7 * + // 8 * . + // 9 * + // 10 * + // 11 * + // 12 * + // 13 * + // 14 * + // 15 * + // 16 * + // 17 + // 18 + // 19 // 20 * // // So to have a unique index for each type basing on nb of nodes, we use a shift: - myShift.resize(SMDSAbs_Volume + 1, 0); - myShift[ SMDSAbs_Face ] = +8; // 3->11, 4->12, 6->14, 8->16 - myShift[ SMDSAbs_Edge ] = -2; // 2->0, 4->2 + myShift.resize(SMDSAbs_NbElementTypes, 0); + + myShift[ SMDSAbs_Face ] = +8; // 3->11, 4->12, 6->14, 8->16 + myShift[ SMDSAbs_Edge ] = +5; // 2->7, 4->9 + myShift[ SMDSAbs_0DElement ] = +2; // 1->3 myNb.resize( index( SMDSAbs_Volume,20 ) + 1, NULL); + myNb[ index( SMDSAbs_Node,1 )] = & myNbNodes; + myNb[ index( SMDSAbs_0DElement,1 )] = & myNb0DElements; + myNb[ index( SMDSAbs_Edge,2 )] = & myNbEdges; myNb[ index( SMDSAbs_Edge,4 )] = & myNbQuadEdges; @@ -126,8 +162,22 @@ inline SMDS_MeshInfo::SMDS_MeshInfo(): myNb[ index( SMDSAbs_Volume, 20)] = & myNbQuadHexas; } +inline SMDS_MeshInfo& // operator= +SMDS_MeshInfo::operator=(const SMDS_MeshInfo& other) +{ for ( int i=0; iGetType(), el->NbNodes()) ]); } +inline void // addWithPoly +SMDS_MeshInfo::addWithPoly(const SMDS_MeshElement* el) +{ + if ( el->IsPoly() ) + ++( el->GetType()==SMDSAbs_Face ? myNbPolygons : myNbPolyhedrons ); + else + add(el); +} inline void // RemoveEdge SMDS_MeshInfo::RemoveEdge(const SMDS_MeshElement* el) { if ( el->IsQuadratic() ) --myNbQuadEdges; else --myNbEdges; } @@ -186,4 +244,100 @@ inline int // NbPrisms SMDS_MeshInfo::NbPrisms (SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbPrisms+myNbQuadPrisms : order == ORDER_LINEAR ? myNbPrisms : myNbQuadPrisms; } +inline int // NbElements +SMDS_MeshInfo::NbElements(SMDSAbs_ElementType type) const +{ + int nb = 0; + switch (type) { + case SMDSAbs_All: + for ( int i=1+index( SMDSAbs_Node,1 ); i