From 964d47b2a021bff9947c8c2dc28b9e09cd5026e5 Mon Sep 17 00:00:00 2001 From: Viktor UZLOV Date: Wed, 27 Jan 2021 18:34:57 +0300 Subject: [PATCH] correct SMDS_MeshInfo, SMDS_Mesh --- src/SMDS/SMDS_Mesh.cxx | 30 ++++----- src/SMDS/SMDS_MeshInfo.hxx | 123 +++++++++++++++++++------------------ 2 files changed, 77 insertions(+), 76 deletions(-) diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 3763fb4fd..5c8b7b5fa 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -815,9 +815,9 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, SMDS_MeshFace* SMDS_Mesh::AddPolygonalFaceWithID (const std::vector & nodes_ids, const smIdType ID) { - int nbNodes = nodes_ids.size(); + smIdType nbNodes = nodes_ids.size(); std::vector nodes (nbNodes); - for (int i = 0; i < nbNodes; i++) { + for (smIdType i = 0; i < nbNodes; i++) { nodes[i] = myNodeFactory->FindNode( nodes_ids[i] ); if (!nodes[i]) return NULL; } @@ -911,9 +911,9 @@ SMDS_MeshVolume * SMDS_Mesh::AddPolyhedralVolumeWithID (const std::vector & quantities, const smIdType ID) { - int nbNodes = nodes_ids.size(); + smIdType nbNodes = nodes_ids.size(); std::vector nodes (nbNodes); - for (int i = 0; i < nbNodes; i++) { + for (smIdType i = 0; i < nbNodes; i++) { nodes[i] = myNodeFactory->FindNode(nodes_ids[i]); if (!nodes[i]) return NULL; } @@ -1589,7 +1589,7 @@ SMDS_NodeIteratorPtr SMDS_Mesh::nodesIterator() const SMDS_ElemIteratorPtr SMDS_Mesh::elementGeomIterator(SMDSAbs_GeometryType type) const { - int nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbElements( type ); + smIdType nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbElements( type ); return myCellFactory->GetIterator< SMDS_ElemIterator >( new SMDS_MeshElement::GeomFilter( type ), nbElems); } @@ -1600,7 +1600,7 @@ SMDS_ElemIteratorPtr SMDS_Mesh::elementEntityIterator(SMDSAbs_EntityType type) c { return myNodeFactory->GetIterator< SMDS_ElemIterator >( new SMDS_MeshElement::NonNullFilter ); } - int nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbElements( type ); + smIdType nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbElements( type ); return myCellFactory->GetIterator( new SMDS_MeshElement::EntityFilter( type ), nbElems); } @@ -1620,7 +1620,7 @@ SMDS_ElemIteratorPtr SMDS_Mesh::elementsIterator(SMDSAbs_ElementType type) const return myNodeFactory->GetIterator< TIterator >( new SMDS_MeshElement::NonNullFilter ); default: - int nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbElements( type ); + smIdType nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbElements( type ); return myCellFactory->GetIterator< TIterator >( new SMDS_MeshElement::TypeFilter( type ), nbElems); } @@ -1634,7 +1634,7 @@ SMDS_ElemIteratorPtr SMDS_Mesh::elementsIterator(SMDSAbs_ElementType type) const SMDS_EdgeIteratorPtr SMDS_Mesh::edgesIterator() const { typedef SMDS_EdgeIterator TIterator; - int nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbEdges(); + smIdType nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbEdges(); return myCellFactory->GetIterator< TIterator >( new SMDS_MeshElement::TypeFilter( SMDSAbs_Edge ), nbElems); } @@ -1646,7 +1646,7 @@ SMDS_EdgeIteratorPtr SMDS_Mesh::edgesIterator() const SMDS_FaceIteratorPtr SMDS_Mesh::facesIterator() const { typedef SMDS_FaceIterator TIterator; - int nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbFaces(); + smIdType nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbFaces(); return myCellFactory->GetIterator< TIterator >( new SMDS_MeshElement::TypeFilter( SMDSAbs_Face ), nbElems); } @@ -1658,7 +1658,7 @@ SMDS_FaceIteratorPtr SMDS_Mesh::facesIterator() const SMDS_VolumeIteratorPtr SMDS_Mesh::volumesIterator() const { typedef SMDS_VolumeIterator TIterator; - int nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbVolumes(); + smIdType nbElems = myCellFactory->CompactChangePointers() ? -1 : myInfo.NbVolumes(); return myCellFactory->GetIterator< TIterator >( new SMDS_MeshElement::TypeFilter( SMDSAbs_Volume ), nbElems ); @@ -1705,7 +1705,7 @@ intersectionOfSets( std::set vs[], int numberOfSets ) /////////////////////////////////////////////////////////////////////////////// static std::set * getFinitElements(const SMDS_MeshElement * element) { - int numberOfSets=element->NbNodes(); + smIdType numberOfSets=element->NbNodes(); std::set *initSet = new std::set[numberOfSets]; SMDS_NodeIteratorPtr itNodes = element->nodeIterator(); @@ -2973,16 +2973,16 @@ void SMDS_Mesh::CompactMesh() for ( ; holder != myElemHolders.end(); ++holder ) (*holder)->beforeCompacting(); } - int oldCellSize = myCellFactory->GetMaxID(); + smIdType oldCellSize = myCellFactory->GetMaxID(); // remove "holes" in SMDS numeration - std::vector idNodesOldToNew, idCellsNewToOld, idCellsOldToNew; + std::vector idNodesOldToNew, idCellsNewToOld, idCellsOldToNew; myNodeFactory->Compact( idNodesOldToNew ); myCellFactory->Compact( idCellsNewToOld ); // make VTK IDs correspond to SMDS IDs - int newNodeSize = myNodeFactory->NbUsedElements(); - int newCellSize = myCellFactory->NbUsedElements(); + smIdType newNodeSize = myNodeFactory->NbUsedElements(); + smIdType newCellSize = myCellFactory->NbUsedElements(); myGrid->compactGrid( idNodesOldToNew, newNodeSize, idCellsNewToOld, newCellSize ); if ( idsChange && !myElemHolders.empty() ) diff --git a/src/SMDS/SMDS_MeshInfo.hxx b/src/SMDS/SMDS_MeshInfo.hxx index b9cfb61f2..b37232ae1 100644 --- a/src/SMDS/SMDS_MeshInfo.hxx +++ b/src/SMDS/SMDS_MeshInfo.hxx @@ -30,6 +30,7 @@ #include "SMDS_MeshElement.hxx" #include +#include class SMDS_EXPORT SMDS_MeshInfo { @@ -39,39 +40,39 @@ public: inline SMDS_MeshInfo& operator=(const SMDS_MeshInfo& other); inline void Clear(); - inline int NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const; - inline int NbElements(SMDSAbs_EntityType type) const { return NbEntities(type); } - inline int NbElements(SMDSAbs_GeometryType type) const { return NbElementsOfGeom(type); } - - inline int NbEntities(SMDSAbs_EntityType type) const; - inline int NbElementsOfGeom(SMDSAbs_GeometryType geom) const; - - int NbNodes() const { return myNbNodes; } - int Nb0DElements() const { return myNb0DElements; } - int NbBalls() const { return myNbBalls; } - 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; - inline int NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) const; - int NbBiQuadTriangles() const { return myNbBiQuadTriangles; } - int NbBiQuadQuadrangles() const { return myNbBiQuadQuadrangles; } - inline int NbPolygons(SMDSAbs_ElementOrder order = ORDER_ANY) const; - - inline int NbVolumes (SMDSAbs_ElementOrder order = ORDER_ANY) const; - inline int NbTetras (SMDSAbs_ElementOrder order = ORDER_ANY) const; - inline int NbHexas (SMDSAbs_ElementOrder order = ORDER_ANY) const; - inline int NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) const; - inline int NbPrisms (SMDSAbs_ElementOrder order = ORDER_ANY) const; - inline int NbHexPrisms(SMDSAbs_ElementOrder order = ORDER_ANY) const; - int NbTriQuadHexas() const { return myNbTriQuadHexas; } - int NbQuadPrisms() const { return myNbQuadPrisms; } - int NbBiQuadPrisms() const { return myNbBiQuadPrisms; } - int NbPolyhedrons() const { return myNbPolyhedrons; } + inline smIdType NbElements(SMDSAbs_ElementType type=SMDSAbs_All) const; + inline smIdType NbElements(SMDSAbs_EntityType type) const { return NbEntities(type); } + inline smIdType NbElements(SMDSAbs_GeometryType type) const { return NbElementsOfGeom(type); } + + inline smIdType NbEntities(SMDSAbs_EntityType type) const; + inline smIdType NbElementsOfGeom(SMDSAbs_GeometryType geom) const; + + smIdType NbNodes() const { return myNbNodes; } + smIdType Nb0DElements() const { return myNb0DElements; } + smIdType NbBalls() const { return myNbBalls; } + inline smIdType NbEdges (SMDSAbs_ElementOrder order = ORDER_ANY) const; + + inline smIdType NbFaces (SMDSAbs_ElementOrder order = ORDER_ANY) const; + inline smIdType NbTriangles (SMDSAbs_ElementOrder order = ORDER_ANY) const; + inline smIdType NbQuadrangles(SMDSAbs_ElementOrder order = ORDER_ANY) const; + smIdType NbBiQuadTriangles() const { return myNbBiQuadTriangles; } + smIdType NbBiQuadQuadrangles() const { return myNbBiQuadQuadrangles; } + inline smIdType NbPolygons(SMDSAbs_ElementOrder order = ORDER_ANY) const; + + inline smIdType NbVolumes (SMDSAbs_ElementOrder order = ORDER_ANY) const; + inline smIdType NbTetras (SMDSAbs_ElementOrder order = ORDER_ANY) const; + inline smIdType NbHexas (SMDSAbs_ElementOrder order = ORDER_ANY) const; + inline smIdType NbPyramids(SMDSAbs_ElementOrder order = ORDER_ANY) const; + inline smIdType NbPrisms (SMDSAbs_ElementOrder order = ORDER_ANY) const; + inline smIdType NbHexPrisms(SMDSAbs_ElementOrder order = ORDER_ANY) const; + smIdType NbTriQuadHexas() const { return myNbTriQuadHexas; } + smIdType NbQuadPrisms() const { return myNbQuadPrisms; } + smIdType NbBiQuadPrisms() const { return myNbBiQuadPrisms; } + smIdType NbPolyhedrons() const { return myNbPolyhedrons; } protected: inline void addWithPoly(const SMDS_MeshElement* el); - inline void setNb(const SMDSAbs_EntityType geomType, const int nb); + inline void setNb(const SMDSAbs_EntityType geomType, const smIdType nb); private: friend class SMDS_Mesh; @@ -79,27 +80,27 @@ private: // 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) const; + inline smIdType index(SMDSAbs_ElementType type, smIdType nbNodes) const; // methods to remove elements of ANY kind inline void RemoveEdge(const SMDS_MeshElement* el); inline void RemoveFace(const SMDS_MeshElement* el); inline void RemoveVolume(const SMDS_MeshElement* el); - int myNbNodes; + smIdType myNbNodes; - int myNb0DElements; - int myNbBalls; - int myNbEdges , myNbQuadEdges ; - int myNbTriangles , myNbQuadTriangles, myNbBiQuadTriangles ; - int myNbQuadrangles, myNbQuadQuadrangles, myNbBiQuadQuadrangles; - int myNbPolygons , myNbQuadPolygons; + smIdType myNb0DElements; + smIdType myNbBalls; + smIdType myNbEdges , myNbQuadEdges ; + smIdType myNbTriangles , myNbQuadTriangles, myNbBiQuadTriangles ; + smIdType myNbQuadrangles, myNbQuadQuadrangles, myNbBiQuadQuadrangles; + smIdType myNbPolygons , myNbQuadPolygons; - int myNbTetras , myNbQuadTetras ; - int myNbHexas , myNbQuadHexas, myNbTriQuadHexas; - int myNbPyramids, myNbQuadPyramids; - int myNbPrisms , myNbQuadPrisms, myNbBiQuadPrisms; - int myNbHexPrism; - int myNbPolyhedrons; + smIdType myNbTetras , myNbQuadTetras ; + smIdType myNbHexas , myNbQuadHexas, myNbTriQuadHexas; + smIdType myNbPyramids, myNbQuadPyramids; + smIdType myNbPrisms , myNbQuadPrisms, myNbBiQuadPrisms; + smIdType myNbHexPrism; + smIdType myNbPolyhedrons; std::vector myNb; // pointers to myNb... fields std::vector myShift; // shift to get an index in myNb by elem->NbNodes() @@ -212,8 +213,8 @@ SMDS_MeshInfo::Clear() myNbPolygons=myNbQuadPolygons=myNbPolyhedrons=0; } -inline int // index -SMDS_MeshInfo::index(SMDSAbs_ElementType type, int nbNodes) const +inline smIdType // index +SMDS_MeshInfo::index(SMDSAbs_ElementType type, smIdType nbNodes) const { return nbNodes + myShift[ type ]; } inline void // remove @@ -250,54 +251,54 @@ inline void // RemoveVolume SMDS_MeshInfo::RemoveVolume(const SMDS_MeshElement* el) { if ( el->IsPoly() ) --myNbPolyhedrons; else remove( el ); } -inline int // NbEdges +inline smIdType // NbEdges SMDS_MeshInfo::NbEdges (SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbEdges+myNbQuadEdges : order == ORDER_LINEAR ? myNbEdges : myNbQuadEdges; } -inline int // NbFaces +inline smIdType // NbFaces SMDS_MeshInfo::NbFaces (SMDSAbs_ElementOrder order) const { return NbTriangles(order)+NbQuadrangles(order)+(order == ORDER_ANY ? myNbPolygons+myNbQuadPolygons : order == ORDER_LINEAR ? myNbPolygons : myNbQuadPolygons ); } -inline int // NbTriangles +inline smIdType // NbTriangles SMDS_MeshInfo::NbTriangles (SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbTriangles+myNbQuadTriangles+myNbBiQuadTriangles : order == ORDER_LINEAR ? myNbTriangles : myNbQuadTriangles+myNbBiQuadTriangles; } -inline int // NbQuadrangles +inline smIdType // NbQuadrangles SMDS_MeshInfo::NbQuadrangles(SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbQuadrangles+myNbQuadQuadrangles+myNbBiQuadQuadrangles : order == ORDER_LINEAR ? myNbQuadrangles : myNbQuadQuadrangles+myNbBiQuadQuadrangles; } -inline int // NbPolygons +inline smIdType // NbPolygons SMDS_MeshInfo::NbPolygons(SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbPolygons+myNbQuadPolygons : order == ORDER_LINEAR ? myNbPolygons : myNbQuadPolygons; } -inline int // NbVolumes +inline smIdType // NbVolumes SMDS_MeshInfo::NbVolumes (SMDSAbs_ElementOrder order) const { return NbTetras(order) + NbHexas(order) + NbPyramids(order) + NbPrisms(order) + NbHexPrisms(order) + (order == ORDER_QUADRATIC ? 0 : myNbPolyhedrons); } -inline int // NbTetras +inline smIdType // NbTetras SMDS_MeshInfo::NbTetras (SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbTetras+myNbQuadTetras : order == ORDER_LINEAR ? myNbTetras : myNbQuadTetras; } -inline int // NbHexas +inline smIdType // NbHexas SMDS_MeshInfo::NbHexas (SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbHexas+myNbQuadHexas+myNbTriQuadHexas : order == ORDER_LINEAR ? myNbHexas : myNbQuadHexas+myNbTriQuadHexas; } -inline int // NbPyramids +inline smIdType // NbPyramids SMDS_MeshInfo::NbPyramids(SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbPyramids+myNbQuadPyramids : order == ORDER_LINEAR ? myNbPyramids : myNbQuadPyramids; } -inline int // NbPrisms +inline smIdType // NbPrisms SMDS_MeshInfo::NbPrisms (SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbPrisms+myNbQuadPrisms+myNbBiQuadPrisms: order == ORDER_LINEAR ? myNbPrisms : myNbQuadPrisms+myNbBiQuadPrisms; } -inline int // NbHexPrisms +inline smIdType // NbHexPrisms SMDS_MeshInfo::NbHexPrisms (SMDSAbs_ElementOrder order) const { return order == ORDER_ANY ? myNbHexPrism : order == ORDER_LINEAR ? myNbHexPrism : 0; } -inline int // NbElements +inline smIdType // NbElements SMDS_MeshInfo::NbElements(SMDSAbs_ElementType type) const { - int nb = 0; + smIdType nb = 0; switch (type) { case SMDSAbs_All: for ( size_t i=1+index( SMDSAbs_Node,1 ); i