From 178d2ef645d103ce49228cde6ed35488144ed446 Mon Sep 17 00:00:00 2001 From: prascle Date: Tue, 5 Jan 2010 19:11:30 +0000 Subject: [PATCH] ObjectPool and SMDS_Position --- src/SMDS/Notes | 99 +++++++++++++++-- src/SMDS/ObjectPool.hxx | 105 ++++++++++++++++++ src/SMDS/SMDS_Mesh.cxx | 103 ++++++++++++++--- src/SMDS/SMDS_Mesh.hxx | 21 ++-- src/SMDS/SMDS_MeshElement.cxx | 14 ++- src/SMDS/SMDS_MeshElement.hxx | 14 ++- src/SMDS/SMDS_MeshElementIDFactory.cxx | 66 ++++------- src/SMDS/SMDS_MeshElementIDFactory.hxx | 7 +- src/SMDS/SMDS_MeshNode.cxx | 21 ++++ src/SMDS/SMDS_MeshNode.hxx | 6 +- src/SMDS/SMDS_Position.hxx | 3 +- src/SMDS/SMDS_SpacePosition.cxx | 25 ++--- src/SMDS/SMDS_SpacePosition.hxx | 15 ++- src/SMDS/SMDS_VolumeOfNodes.cxx | 18 ++- src/SMDS/SMDS_VolumeOfNodes.hxx | 8 +- src/SMESH/SMESH_Algo.cxx | 6 +- src/SMESH/SMESH_Gen.cxx | 2 + src/SMESH/SMESH_MeshEditor.cxx | 20 ++-- src/SMESH/SMESH_MesherHelper.cxx | 10 +- src/SMESH/SMESH_Pattern.cxx | 6 +- src/SMESHDS/SMESHDS_SubMesh.cxx | 8 +- src/SMESH_I/Makefile.am | 1 + src/SMESH_I/SMESH_Gen_i.cxx | 8 +- src/SMESH_I/SMESH_Mesh_i.cxx | 6 +- src/StdMeshers/StdMeshers_FaceSide.cxx | 4 +- src/StdMeshers/StdMeshers_Hexa_3D.cxx | 9 +- src/StdMeshers/StdMeshers_MEFISTO_2D.cxx | 2 +- src/StdMeshers/StdMeshers_Penta_3D.cxx | 6 +- src/StdMeshers/StdMeshers_ProjectionUtils.cxx | 2 +- src/StdMeshers/StdMeshers_Projection_2D.cxx | 4 +- 30 files changed, 458 insertions(+), 161 deletions(-) create mode 100644 src/SMDS/ObjectPool.hxx diff --git a/src/SMDS/Notes b/src/SMDS/Notes index 3107b51f3..a0e3eef8c 100644 --- a/src/SMDS/Notes +++ b/src/SMDS/Notes @@ -58,17 +58,92 @@ enlever vtkId de SMDS_MeshCell, utiliser SMDS_MeshElementIDFactory. ajouter ID dans SMDS_Mesh::createTriangle verifier ID dans SMDS_Mesh::Find*OrCreate -======================== +=================================================== occupation memoire cube 100*100*100 sans affichage -Ubuntu 9.10 64 bits 15/12/2009 -/home/prascle/projets/SALOME/SMESH/BR_SMDS_MEMIMP/SMESH_SRC/src/SMESH/SMESH_Gen.cxx:143 -in use bytes = 32843200 -/home/prascle/projets/SALOME/SMESH/BR_SMDS_MEMIMP/SMESH_SRC/src/SMESH/SMESH_Gen.cxx [294] : VSR - SMESH_Gen::Compute() finished, OK = 1 -in use bytes = 498773760 -delta = 460 Mo (45 Mo de plus que sur Sarge 64 bits ?) - -Debian Sarge 64 bits -in use bytes = 17076352 -in use bytes = 431600032 -delta = 415 Mo +Reference : V513 Debian Sarge 64 bits: --> 463 - 33 = 430 Mo +------------------------------------- +Total (incl. mmap): +system bytes = 43757568 +in use bytes = 32909584 = 33M +max mmap regions = 41 +max mmap bytes = 16371712 +---- +Total (incl. mmap): +system bytes = 464670720 +in use bytes = 463105120 = 463M +max mmap regions = 47 +max mmap bytes = 28188672 + +Debian Sarge 64 bits, vtkUnstructuredGrid nodes et hexa, 4 janvier 2010 --> 512 - 41 = 471M +----------------------------------- + +Total (incl. mmap): +system bytes = 52133888 +in use bytes = 41340320 : 41M +max mmap regions = 72 +max mmap bytes = 24625152 +---- +Total (incl. mmap): +system bytes = 520560640 +in use bytes = 518735584 : 512M +max mmap regions = 88 +max mmap bytes = 198385664 + +idem avec pool SMDS_MeshNodes --> 483 -33 = 450M +----------------------------- +Total (incl. mmap): +system bytes = 43696128 +in use bytes = 32915184 : 33M +max mmap regions = 41 +max mmap bytes = 16371712 +---- +Total (incl. mmap): +system bytes = 484806656 +in use bytes = 482980992 : 483M +max mmap regions = 58 +max mmap bytes = 184557568 + +idem ci-dessus + pool SMDS_VolumeVtkNodes --> 475 -33 = 442M (git: add ObjectPool.hxx) +----------------------------------------- + +Total (incl. mmap): +system bytes = 43200512 +in use bytes = 32908576 : 33M +max mmap regions = 41 +max mmap bytes = 16371712 +---- +Total (incl. mmap): +system bytes = 478068736 +in use bytes = 475144400 : 475M +max mmap regions = 59 +max mmap bytes = 184692736 + +remplacement SMDS_PositionPtr: (boost::shared_ptr --> SMDS_Position*) --> 436 - 35 = 401M (git SMDS_Position) +------------------------------------------------------------------------------------ +Total (incl. mmap): +system bytes = 45408256 +in use bytes = 35097680 : 35M +max mmap regions = 47 +max mmap bytes = 18116608 +---- +Total (incl. mmap): +system bytes = 438935552 +in use bytes = 436116560 : 436M +max mmap regions = 65 +max mmap bytes = 186437632 + +simplification SMDS_SpacePosition (pas de double[3]) --> 418 -33 = 385M (git SMDS_SpacePosition) +---------------------------------------------------- +Total (incl. mmap): +system bytes = 42582016 +in use bytes = 32883552 : 33M +max mmap regions = 41 +max mmap bytes = 16371712 +---- +Total (incl. mmap): +system bytes = 421728256 +in use bytes = 418378000 : 418M +max mmap regions = 58 +max mmap bytes = 183640064 + diff --git a/src/SMDS/ObjectPool.hxx b/src/SMDS/ObjectPool.hxx new file mode 100644 index 000000000..a4111b181 --- /dev/null +++ b/src/SMDS/ObjectPool.hxx @@ -0,0 +1,105 @@ + +#ifndef _OBJECTPOOL_HXX_ +#define _OBJECTPOOL_HXX_ + +#include +#include +#include + +template class ObjectPool +{ + +private: + std::vector _chunkList; + std::vector _freeList; + int _nextFree; + int _maxAvail; + int _chunkSize; + + int getNextFree() + { + for (int i=_nextFree; i< _maxAvail; i++) + if (_freeList[i] == true) + { + return i; + break; + } + return _maxAvail; + } + + void checkDelete(int chunkId) + { + int i0 = _chunkSize*chunkId; + int i1 =_chunkSize*(chunkId+1); + for (int i=i0; i < i1; i++) + if (_freeList[i] == false) + return; + std::cerr << "a chunk to delete" << std::endl; + // compactage des vecteurs un peu lourd, pas necessaire + //X* chunk = _chunkList[chunkId]; + //delete [] chunk; + } + +public: + ObjectPool(int nblk) + { + _chunkSize = nblk; + _nextFree = 0; + _maxAvail = 0; + _chunkList.clear(); + _freeList.clear(); + } + + virtual ~ObjectPool() + { + for (int i=0; i<_chunkList.size(); i++) + delete [] _chunkList[i]; + } + + X* getNew() + { + X *obj = 0; + _nextFree = getNextFree(); + if (_nextFree == _maxAvail) + { + X* newChunk = new X[_chunkSize]; + _chunkList.push_back(newChunk); + _freeList.insert(_freeList.end(), _chunkSize, true); + _maxAvail += _chunkSize; + _freeList[_nextFree] = false; + obj = newChunk; // &newChunk[0]; + } + else + { + int chunkId = _nextFree/_chunkSize; + int rank = _nextFree - chunkId*_chunkSize; + _freeList[_nextFree] = false; + obj = _chunkList[chunkId] + rank; // &_chunkList[chunkId][rank]; + } + //obj->init(); + return obj; + } + + void destroy(X* obj) + { + long adrobj = (long)(obj); + for (int i=0; i< _chunkList.size(); i++) + { + X* chunk = _chunkList[i]; + long adrmin = (long)(chunk); + if (adrobj < adrmin) continue; + long adrmax = (long)(chunk + _chunkSize); + if (adrobj >= adrmax) continue; + int rank = (adrobj -adrmin)/sizeof(X); + int toFree = i*_chunkSize + rank; + _freeList[toFree] = true; + if (toFree < _nextFree) _nextFree = toFree; + //obj->clean(); + //checkDelete(i); compactage non fait + break; + } + } + +}; + +#endif diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 693fd38fd..cd0196c3c 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -51,7 +51,8 @@ using namespace std; #define CHECKMEMORY_INTERVAL 1000 vector SMDS_Mesh::_meshList = vector(); -int SMDS_Mesh::chunkSize = 1000; +int SMDS_Mesh::chunkSize = 1024; + //================================================================================ /*! @@ -113,15 +114,21 @@ SMDS_Mesh::SMDS_Mesh() myElementIDFactory(new SMDS_MeshElementIDFactory()), myHasConstructionEdges(false), myHasConstructionFaces(false), myHasInverseElements(true), - myNodeMin(0), myNodeMax(0), myCellLinksSize(0) + myNodeMin(0), myNodeMax(0), myCellLinksSize(0), + myNodePool(0), myVolumePool(0) { myMeshId = _meshList.size(); // --- index of the mesh to push back in the vector MESSAGE("myMeshId=" << myMeshId); myNodeIDFactory->SetMesh(this); myElementIDFactory->SetMesh(this); _meshList.push_back(this); + myNodePool = new ObjectPool(SMDS_Mesh::chunkSize); + myVolumePool = new ObjectPool(SMDS_Mesh::chunkSize); + myNodes.clear(); myCells.clear(); + myIDElements.clear(); + myVtkIndex.clear(); myGrid = vtkUnstructuredGrid::New(); myGrid->Initialize(); myGrid->Allocate(); @@ -139,9 +146,11 @@ SMDS_Mesh::SMDS_Mesh() /////////////////////////////////////////////////////////////////////////////// SMDS_Mesh::SMDS_Mesh(SMDS_Mesh * parent) :myParent(parent), myNodeIDFactory(parent->myNodeIDFactory), - myElementIDFactory(parent->myElementIDFactory), - myHasConstructionEdges(false), myHasConstructionFaces(false), - myHasInverseElements(true) + myElementIDFactory(parent->myElementIDFactory), + myHasConstructionEdges(false), myHasConstructionFaces(false), + myHasInverseElements(true), + myNodePool(parent->myNodePool), + myVolumePool(parent->myVolumePool) { } @@ -178,7 +187,9 @@ SMDS_MeshNode * SMDS_Mesh::AddNodeWithID(double x, double y, double z, int ID) const SMDS_MeshElement *node = myNodeIDFactory->MeshElement(ID); if(!node){ //if ( myNodes.Extent() % CHECKMEMORY_INTERVAL == 0 ) CheckMemory(); - SMDS_MeshNode * node=new SMDS_MeshNode(ID, myMeshId, -1, x, y, z); + //SMDS_MeshNode * node=new SMDS_MeshNode(ID, myMeshId, -1, x, y, z); + SMDS_MeshNode * node = myNodePool->getNew(); + node->init(ID, myMeshId, -1, x, y, z); if (ID >= myNodes.size()) { myNodes.resize(ID+SMDS_Mesh::chunkSize, 0); @@ -842,13 +853,27 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, return NULL; } else { -// volume=new SMDS_HexahedronOfNodes(n1,n2,n3,n4,n5,n6,n7,n8); - volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5,n6,n7,n8); + // --- retreive nodes ID + vector nodeIds; + nodeIds.clear(); + nodeIds.push_back(n1->getId()); + nodeIds.push_back(n2->getId()); + nodeIds.push_back(n3->getId()); + nodeIds.push_back(n4->getId()); + nodeIds.push_back(n5->getId()); + nodeIds.push_back(n6->getId()); + nodeIds.push_back(n7->getId()); + nodeIds.push_back(n8->getId()); + + //volume = new SMDS_VolumeVtkNodes(nodeIds, this); + SMDS_VolumeVtkNodes *volvtk = myVolumePool->getNew(); + volvtk->init(nodeIds, this); + volume = volvtk; adjustmyCellsCapacity(ID); myCells[ID] = volume; myInfo.myNbHexas++; } - + if (!registerElement(ID, volume)) { RemoveElement(volume, false); volume = NULL; @@ -1130,14 +1155,42 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume /////////////////////////////////////////////////////////////////////////////// /// Registers element with the given ID, maintains inverse connections /////////////////////////////////////////////////////////////////////////////// -bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement * element) +bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element) { - //MESSAGE("registerElement " << ID) - if (myElementIDFactory->BindID(ID, element)) { - return true; + //MESSAGE("registerElement " << ID) + if ((ID < myIDElements.size()) && myIDElements[ID] >= 0) // --- already bound + { + MESSAGE(" --------------------------------- already bound "<< ID << " " << myIDElements[ID]); + return false; } - MESSAGE("BindID " << ID << " false!---------------"); - return false; + + element->myID = ID; + element->myMeshId = myMeshId; + + SMDS_MeshCell *cell = dynamic_cast(element); + assert(cell); + int vtkId = cell->getVtkId(); + if (vtkId == -1) + vtkId = myElementIDFactory->SetInVtkGrid(element); + + if (ID >= myIDElements.size()) // --- resize local vector + { + MESSAGE(" ------------------- resize myIDElements " << ID << " --> " << ID + SMDS_Mesh::chunkSize); + myIDElements.resize(ID + SMDS_Mesh::chunkSize, -1); // fill new elements with -1 + } + + myIDElements[ID] = vtkId; + //MESSAGE("smds:" << ID << " vtk:" << cellId ); + + if (vtkId >= myVtkIndex.size()) // --- resize local vector + { + MESSAGE(" --------------------- resize myVtkIndex " << vtkId << " --> " << vtkId + SMDS_Mesh::chunkSize); + myVtkIndex.resize(vtkId + SMDS_Mesh::chunkSize, -1); + } + myVtkIndex[vtkId] = ID; + + myElementIDFactory->updateMinMax(ID); + return true; } /////////////////////////////////////////////////////////////////////////////// @@ -3405,3 +3458,23 @@ void SMDS_Mesh::updateNodeMinMax() while (!myNodes[myNodeMax] && (myNodeMin>=0)) myNodeMin--; } + +void SMDS_Mesh::incrementNodesCapacity(int nbNodes) +{ + int val = myIDElements.size(); + MESSAGE(" ------------------- resize myIDElements " << val << " --> " << val + nbNodes); + myIDElements.resize(val + nbNodes, -1); // fill new elements with -1 + val = myNodes.size(); + MESSAGE(" ------------------- resize myNodes " << val << " --> " << val + nbNodes); + myNodes.resize(val +nbNodes, 0); +} + +void SMDS_Mesh::incrementCellsCapacity(int nbCells) +{ + int val = myVtkIndex.size(); + MESSAGE(" ------------------- resize myVtkIndex " << val << " --> " << val + nbCells); + myVtkIndex.resize(val + nbCells, -1); // fill new elements with -1 + val = myCells.size(); + MESSAGE(" ------------------- resize myCells " << val << " --> " << val + nbCells); + myNodes.resize(val +nbCells, 0); +} diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index db64ab782..203ec83f3 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -37,6 +37,8 @@ #include "SMDS_MeshElementIDFactory.hxx" #include "SMDS_MeshInfo.hxx" #include "SMDS_ElemIterator.hxx" +#include "SMDS_VolumeOfNodes.hxx" +#include "ObjectPool.hxx" #include #include @@ -48,7 +50,9 @@ class vtkUnstructuredGrid; class SMDS_EXPORT SMDS_Mesh:public SMDS_MeshObject{ public: - + friend class SMDS_MeshElementIDFactory; + friend class SMDS_MeshVolumeVtkNodes; + static std::vector _meshList; // --- to find the SMDS_mesh from its elements SMDS_Mesh(); @@ -549,8 +553,11 @@ public: typedef std::vector SetOfCells; void updateNodeMinMax(); - int fromVtkToSmds(int vtkid) { return myElementIDFactory->fromVtkToSmds(vtkid); }; + int fromVtkToSmds(int vtkid) { return myVtkIndex[vtkid]; }; + void incrementNodesCapacity(int nbNodes); + void incrementCellsCapacity(int nbCells); + int myCellLinksSize; static int chunkSize; @@ -595,14 +602,12 @@ private: int myMeshId; // --- index for this mesh in the vector vtkUnstructuredGrid* myGrid; - + ObjectPool* myNodePool; + ObjectPool* myVolumePool; SetOfNodes myNodes; SetOfCells myCells; - -// SetOf0DElements my0DElements; -// SetOfEdges myEdges; -// SetOfFaces myFaces; -// SetOfVolumes myVolumes; + std::vector myIDElements; // index = ID client, value = ID vtk + std::vector myVtkIndex; // index = ID vtk, value = ID client SMDS_Mesh * myParent; std::list myChildren; diff --git a/src/SMDS/SMDS_MeshElement.cxx b/src/SMDS/SMDS_MeshElement.cxx index 5f1669885..fdbeffd86 100644 --- a/src/SMDS/SMDS_MeshElement.cxx +++ b/src/SMDS/SMDS_MeshElement.cxx @@ -34,7 +34,9 @@ using namespace std; -SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID) +int SMDS_MeshCell::nbCells = 0; + +SMDS_MeshElement::SMDS_MeshElement(int ID):myID(ID), myMeshId(-1), myShapeId(-1) { } @@ -246,5 +248,11 @@ int SMDS_MeshElement::GetNodeIndex( const SMDS_MeshNode* node ) const SMDS_MeshCell::SMDS_MeshCell() { - myVtkID = -1; -}; \ No newline at end of file + nbCells++; + myVtkID = -1; +}; + +SMDS_MeshCell::~SMDS_MeshCell() +{ + nbCells--; +} \ No newline at end of file diff --git a/src/SMDS/SMDS_MeshElement.hxx b/src/SMDS/SMDS_MeshElement.hxx index eb0179ccc..94e922239 100644 --- a/src/SMDS/SMDS_MeshElement.hxx +++ b/src/SMDS/SMDS_MeshElement.hxx @@ -41,7 +41,8 @@ typedef short ShortType; class SMDS_MeshNode; class SMDS_MeshEdge; -class SMDS_MeshFace; +class SMDS_MeshFace; +class SMDS_Mesh; // ============================================================ /*! @@ -73,7 +74,8 @@ public: virtual bool IsMediumNode(const SMDS_MeshNode* node) const; friend SMDS_EXPORT std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *); - friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem); + friend SMDS_EXPORT bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement* elem); + friend class SMDS_Mesh; // =========================== // Access to nodes by index @@ -119,7 +121,7 @@ public: */ int GetNodeIndex( const SMDS_MeshNode* node ) const; - inline int getId() {return myID; }; + inline int getId() const {return myID; }; inline UShortType getMeshId() {return myMeshId; }; inline ShortType getshapeId() {return myShapeId; }; inline void setShapeId(UShortType shapeId) {myShapeId = shapeId; }; @@ -130,7 +132,7 @@ protected: virtual void Print(std::ostream & OS) const; int myID; // --- element index - UShortType myMeshId; + ShortType myMeshId; ShortType myShapeId; }; @@ -144,8 +146,10 @@ class SMDS_EXPORT SMDS_MeshCell:public SMDS_MeshElement { public: SMDS_MeshCell(); - inline void setVtkId(int vtkId) { myVtkID = vtkId; }; + virtual ~SMDS_MeshCell(); + inline void setVtkId(int vtkId) { myVtkID = vtkId; }; inline int getVtkId() const {return myVtkID; }; + static int nbCells; protected: int myVtkID; }; diff --git a/src/SMDS/SMDS_MeshElementIDFactory.cxx b/src/SMDS/SMDS_MeshElementIDFactory.cxx index 58658c5b2..f5f3c37c7 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.cxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.cxx @@ -46,8 +46,8 @@ using namespace std; SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory(): SMDS_MeshNodeIDFactory() { - myIDElements.clear(); - myVtkIndex.clear(); +// myIDElements.clear(); +// myVtkIndex.clear(); myVtkCellTypes.clear(); myVtkCellTypes.reserve(SMDSEntity_Last); myVtkCellTypes[SMDSEntity_Node] = VTK_VERTEX; @@ -72,25 +72,9 @@ SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory(): myVtkCellTypes[SMDSEntity_Quad_Polyhedra] = VTK_CONVEX_POINT_SET; } -//======================================================================= -//function : BindID -//purpose : -//======================================================================= -bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem) +int SMDS_MeshElementIDFactory::SetInVtkGrid(SMDS_MeshElement * elem) { - if ((ID < myIDElements.size()) && myIDElements[ID] >= 0) // --- already bound - { - MESSAGE(" --------------------------------- already bound "<< ID << " " << myIDElements[ID]); - return false; - } - - if (ID >= myIDElements.size()) // --- resize local vector - { - //MESSAGE(" ------------------- resize myIDElements " << ID << " --> " << ID+SMDS_Mesh::chunkSize); - myIDElements.resize(ID+SMDS_Mesh::chunkSize,-1); // fill new elements with -1 - } - - // --- retreive nodes ID + // --- retreive nodes ID vector nodeIds; SMDS_ElemIteratorPtr it = elem->nodesIterator(); @@ -106,25 +90,23 @@ bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem) vtkUnstructuredGrid * grid = myMesh->getGrid(); int typ = GetVtkCellType(elem->GetType()); int cellId = grid->InsertNextLinkedCell(typ, nodeIds.size(), &nodeIds[0]); - - // --- fill local vector - - myIDElements[ID] = cellId; - //MESSAGE("smds:" << ID << " vtk:" << cellId ); - - if (cellId >= myVtkIndex.size()) // --- resize local vector - { - //MESSAGE(" --------------------- resize myVtkIndex " << cellId << " --> " << cellId+SMDS_Mesh::chunkSize); - myVtkIndex.resize(cellId+SMDS_Mesh::chunkSize, -1); - } - myVtkIndex[cellId] = ID; - - elem->myID=ID; SMDS_MeshCell *cell = dynamic_cast(elem); assert(cell); - cell->setVtkId(cellId); - updateMinMax (ID); - return true; + cell->setVtkId(cellId); + //MESSAGE("SMDS_MeshElementIDFactory::SetInVtkGrid " << cellId); + return cellId; +} + +//======================================================================= +//function : BindID +//purpose : +//======================================================================= + +bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem) +{ + MESSAGE("SMDS_MeshElementIDFactory::BindID " << ID); + SetInVtkGrid(elem); + return myMesh->registerElement(ID, elem); } //======================================================================= @@ -133,7 +115,7 @@ bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem) //======================================================================= SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID) { - if ((ID<0) || (ID>myMax) || (myIDElements[ID]<0)) + if ((ID<0) || (ID>myMax) || (myMesh->myIDElements[ID]<0)) return NULL; const SMDS_MeshElement* elem = GetMesh()->FindElement(ID); return (SMDS_MeshElement*)(elem); @@ -145,7 +127,7 @@ SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID) //======================================================================= void SMDS_MeshElementIDFactory::ReleaseID(const int ID) { - myIDElements[ID] = -1; + myMesh->myIDElements[ID] = -1; SMDS_MeshIDFactory::ReleaseID(ID); if (ID == myMax) myMax = 0; @@ -162,8 +144,8 @@ void SMDS_MeshElementIDFactory::updateMinMax() const { myMin = IntegerLast(); myMax = 0; - for (int i=0; i=0) + for (int i=0; imyIDElements.size(); i++) + if (int id=myMesh->myIDElements[i] >=0) { if (id > myMax) myMax = id; if (id < myMin) myMin = id; @@ -184,7 +166,7 @@ SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const void SMDS_MeshElementIDFactory::Clear() { - myIDElements.clear(); + myMesh->myIDElements.clear(); myMin = myMax = 0; SMDS_MeshIDFactory::Clear(); } diff --git a/src/SMDS/SMDS_MeshElementIDFactory.hxx b/src/SMDS/SMDS_MeshElementIDFactory.hxx index bebac0973..e55da180f 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.hxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.hxx @@ -33,18 +33,21 @@ #include class SMDS_MeshElement; +class SMDS_Mesh; class SMDS_EXPORT SMDS_MeshElementIDFactory:public SMDS_MeshNodeIDFactory { public: + friend class SMDS_Mesh; + SMDS_MeshElementIDFactory(); bool BindID(int ID, SMDS_MeshElement * elem); + int SetInVtkGrid(SMDS_MeshElement * elem); SMDS_MeshElement * MeshElement(int ID); virtual void ReleaseID(int ID); SMDS_ElemIteratorPtr elementsIterator() const; virtual void Clear(); int GetVtkCellType(int SMDSType); - int fromVtkToSmds(int vtkid) { return myVtkIndex[vtkid]; }; protected: void updateMinMax() const; @@ -54,8 +57,6 @@ protected: if (id < myMin) myMin = id; } - std::vector myIDElements; // index = ID client, value = ID vtk - std::vector myVtkIndex; // index = ID vtk, value = ID client std::vector myVtkCellTypes; }; diff --git a/src/SMDS/SMDS_MeshNode.cxx b/src/SMDS/SMDS_MeshNode.cxx index 5b6f517fd..55a90c5cc 100644 --- a/src/SMDS/SMDS_MeshNode.cxx +++ b/src/SMDS/SMDS_MeshNode.cxx @@ -39,15 +39,31 @@ using namespace std; +int SMDS_MeshNode::nbNodes =0; + //======================================================================= //function : SMDS_MeshNode //purpose : //======================================================================= +SMDS_MeshNode::SMDS_MeshNode() : + SMDS_MeshElement(-1, -1, -1), + myPosition(SMDS_SpacePosition::originSpacePosition()) +{ +} SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y, double z): SMDS_MeshElement(id, meshId, shapeId), myPosition(SMDS_SpacePosition::originSpacePosition()) { + init(id, meshId, shapeId, x, y ,z); +} + +void SMDS_MeshNode::init(int id, int meshId, int shapeId, double x, double y, double z) +{ + nbNodes++; + myID = id; + myMeshId = meshId; + myShapeId = shapeId; //MESSAGE("Node " << myID << " (" << x << ", " << y << ", " << z << ")"); SMDS_Mesh* mesh = SMDS_Mesh::_meshList[myMeshId]; vtkUnstructuredGrid * grid = mesh->getGrid(); @@ -90,6 +106,11 @@ SMDS_MeshNode::SMDS_MeshNode(int id, int meshId, int shapeId, double x, double y //setXYZ(x, y, z); } +SMDS_MeshNode::~SMDS_MeshNode() +{ + nbNodes--; +} + //======================================================================= //function : RemoveInverseElement //purpose : diff --git a/src/SMDS/SMDS_MeshNode.hxx b/src/SMDS/SMDS_MeshNode.hxx index 64ecc0847..ffe1c499e 100644 --- a/src/SMDS/SMDS_MeshNode.hxx +++ b/src/SMDS/SMDS_MeshNode.hxx @@ -36,8 +36,12 @@ class SMDS_EXPORT SMDS_MeshNode:public SMDS_MeshElement { public: + SMDS_MeshNode(); SMDS_MeshNode(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0); + virtual ~SMDS_MeshNode(); + void init(int id, int meshId, int shapeId = -1, double x=0, double y=0, double z=0); + double* getCoord() const; void Print(std::ostream & OS) const; @@ -64,7 +68,7 @@ public: * \retval const SMDS_MeshNode* - the node */ virtual const SMDS_MeshNode* GetNode(const int) const { return this; } - + static int nbNodes; protected: SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; diff --git a/src/SMDS/SMDS_Position.hxx b/src/SMDS/SMDS_Position.hxx index 687bc098e..a92f4648f 100644 --- a/src/SMDS/SMDS_Position.hxx +++ b/src/SMDS/SMDS_Position.hxx @@ -32,7 +32,8 @@ #include class SMDS_Position; -typedef boost::shared_ptr SMDS_PositionPtr; +//typedef boost::shared_ptr SMDS_PositionPtr; +typedef SMDS_Position* SMDS_PositionPtr; class SMDS_EXPORT SMDS_Position { diff --git a/src/SMDS/SMDS_SpacePosition.cxx b/src/SMDS/SMDS_SpacePosition.cxx index 09532f347..5647c1e95 100644 --- a/src/SMDS/SMDS_SpacePosition.cxx +++ b/src/SMDS/SMDS_SpacePosition.cxx @@ -24,35 +24,28 @@ // Author : Jean-Michel BOULCOURT // Module : SMESH // + #include "SMDS_SpacePosition.hxx" -//======================================================================= -//function : SMDS_SpacePosition -//purpose : -//======================================================================= +SMDS_SpacePosition* SMDS_SpacePosition::_originPosition = new SMDS_SpacePosition(); SMDS_SpacePosition::SMDS_SpacePosition(double x, double y, double z): - SMDS_Position(0) + SMDS_Position(0) { - myCoords[0]=x; - myCoords[1]=y; - myCoords[2]=z; } -/** -*/ -SMDS_TypeOfPosition SMDS_SpacePosition::GetTypeOfPosition() const +const double* SMDS_SpacePosition::Coords() const { - return SMDS_TOP_3DSPACE; + static double origin[]={0,0,0}; + return origin; } -const double * SMDS_SpacePosition::Coords() const +SMDS_TypeOfPosition SMDS_SpacePosition::GetTypeOfPosition() const { - return myCoords; + return SMDS_TOP_3DSPACE; } SMDS_PositionPtr SMDS_SpacePosition::originSpacePosition() { - static SMDS_PositionPtr staticpos (new SMDS_SpacePosition()); - return staticpos; + return _originPosition; } diff --git a/src/SMDS/SMDS_SpacePosition.hxx b/src/SMDS/SMDS_SpacePosition.hxx index f80f3210a..e8cde06a5 100644 --- a/src/SMDS/SMDS_SpacePosition.hxx +++ b/src/SMDS/SMDS_SpacePosition.hxx @@ -33,14 +33,13 @@ class SMDS_EXPORT SMDS_SpacePosition:public SMDS_Position { - public: - SMDS_SpacePosition(double x=0, double y=0, double z=0); - const virtual double * Coords() const; - virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const; - inline void SetCoords(const double x, const double y, const double z); - static SMDS_PositionPtr originSpacePosition(); - private: - double myCoords[3]; +public: + SMDS_SpacePosition(double x=0, double y=0, double z=0); + const virtual double * Coords() const; + virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const; + static SMDS_PositionPtr originSpacePosition(); +private: + static SMDS_SpacePosition* _originPosition; }; #endif diff --git a/src/SMDS/SMDS_VolumeOfNodes.cxx b/src/SMDS/SMDS_VolumeOfNodes.cxx index b44bae07c..449212df2 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.cxx +++ b/src/SMDS/SMDS_VolumeOfNodes.cxx @@ -29,8 +29,11 @@ #include "SMDS_MeshNode.hxx" #include "SMDS_SetIterator.hxx" #include "SMDS_VolumeTool.hxx" +#include "SMDS_Mesh.hxx" #include "utilities.h" +#include + #include using namespace std; @@ -258,6 +261,17 @@ SMDS_VolumeVtkNodes::SMDS_VolumeVtkNodes() { } +SMDS_VolumeVtkNodes::SMDS_VolumeVtkNodes(std::vector nodeIds, SMDS_Mesh* mesh) +{ + init(nodeIds, mesh); +} + +void SMDS_VolumeVtkNodes::init(std::vector nodeIds, SMDS_Mesh* mesh) +{ + vtkUnstructuredGrid* grid = mesh->getGrid(); + myVtkID = grid->InsertNextLinkedCell(GetType(), nodeIds.size(), &nodeIds[0]); +} + bool SMDS_VolumeVtkNodes::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) { @@ -289,7 +303,9 @@ int SMDS_VolumeVtkNodes::NbFaces() const int SMDS_VolumeVtkNodes::NbNodes() const { - return 0; + vtkUnstructuredGrid* grid =SMDS_Mesh::_meshList[myMeshId]->getGrid(); + int nbPoints = grid->GetCell(myVtkID)->GetNumberOfPoints(); + return nbPoints; } int SMDS_VolumeVtkNodes::NbEdges() const diff --git a/src/SMDS/SMDS_VolumeOfNodes.hxx b/src/SMDS/SMDS_VolumeOfNodes.hxx index 9c2aa7129..2aabf9fc3 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.hxx +++ b/src/SMDS/SMDS_VolumeOfNodes.hxx @@ -29,6 +29,8 @@ #include "SMESH_SMDS.hxx" #include "SMDS_MeshVolume.hxx" +#include +#include class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume { @@ -90,10 +92,12 @@ class SMDS_EXPORT SMDS_VolumeOfNodes:public SMDS_MeshVolume class SMDS_EXPORT SMDS_VolumeVtkNodes:public SMDS_MeshVolume { public: - SMDS_VolumeVtkNodes(); + SMDS_VolumeVtkNodes(); + SMDS_VolumeVtkNodes(std::vector nodeIds, SMDS_Mesh* mesh); + ~SMDS_VolumeVtkNodes(); + void init(std::vector nodeIds, SMDS_Mesh* mesh); bool ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes); - ~SMDS_VolumeVtkNodes(); void Print(std::ostream & OS) const; int NbFaces() const; diff --git a/src/SMESH/SMESH_Algo.cxx b/src/SMESH/SMESH_Algo.cxx index 8aad675b4..579d5ad41 100644 --- a/src/SMESH/SMESH_Algo.cxx +++ b/src/SMESH/SMESH_Algo.cxx @@ -223,7 +223,7 @@ bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face& theFace, const SMDS_PositionPtr& pos = node->GetPosition(); if ( !pos ) continue; if ( pos->GetTypeOfPosition() == SMDS_TOP_FACE ) { - fPos = dynamic_cast< const SMDS_FacePosition* >( pos.get() ); + fPos = dynamic_cast< const SMDS_FacePosition* >( pos ); } else if ( pos->GetTypeOfPosition() == SMDS_TOP_VERTEX ) { vID = pos->GetShapeId(); @@ -334,7 +334,7 @@ bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh, if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE ) return false; const SMDS_EdgePosition* epos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); if ( !paramSet.insert( epos->GetUParameter() ).second ) return false; // equal parameters } @@ -401,7 +401,7 @@ bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theM if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE ) return false; const SMDS_EdgePosition* epos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); theNodes.insert( make_pair( epos->GetUParameter(), node )); ++nbNodes; } diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 742a6ae62..314bbb206 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -304,6 +304,8 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, total += subMesh->getSize(); } cerr << "total elements and nodes in submesh sets:" << total << endl; + cerr << "Number of node objects " << SMDS_MeshNode::nbNodes << endl; + cerr << "Number of cell objects " << SMDS_MeshCell::nbCells << endl; return ret; } diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 32dcba796..851108365 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -337,7 +337,7 @@ int SMESH_MeshEditor::FindShape (const SMDS_MeshElement * theElem) if ( theElem->GetType() == SMDSAbs_Node ) { const SMDS_PositionPtr& aPosition = static_cast( theElem )->GetPosition(); - if ( aPosition.get() ) + if ( aPosition ) return aPosition->GetShapeId(); else return 0; @@ -348,7 +348,7 @@ int SMESH_MeshEditor::FindShape (const SMDS_MeshElement * theElem) while ( nodeIt->more() ) { const SMDS_MeshNode* node = static_cast( nodeIt->next() ); const SMDS_PositionPtr& aPosition = node->GetPosition(); - if ( aPosition.get() ) { + if ( aPosition ) { int aShapeID = aPosition->GetShapeId(); SMESHDS_SubMesh * sm = aMesh->MeshElements( aShapeID ); if ( sm ) { @@ -2345,7 +2345,7 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems, while ( nn++ < nbn ) { node = static_cast( itN->next() ); const SMDS_PositionPtr& pos = node->GetPosition(); - posType = pos.get() ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE; + posType = pos ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE; if (posType != SMDS_TOP_EDGE && posType != SMDS_TOP_VERTEX && theFixedNodes.find( node ) == theFixedNodes.end()) @@ -2403,11 +2403,11 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems, node = *n; gp_XY uv( 0, 0 ); const SMDS_PositionPtr& pos = node->GetPosition(); - posType = pos.get() ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE; + posType = pos ? pos->GetTypeOfPosition() : SMDS_TOP_3DSPACE; // get existing UV switch ( posType ) { case SMDS_TOP_FACE: { - SMDS_FacePosition* fPos = ( SMDS_FacePosition* ) pos.get(); + SMDS_FacePosition* fPos = ( SMDS_FacePosition* ) pos; uv.SetCoord( fPos->GetUParameter(), fPos->GetVParameter() ); break; } @@ -2417,7 +2417,7 @@ void SMESH_MeshEditor::Smooth (TIDSortedElemSet & theElems, if ( !S.IsNull() && S.ShapeType() == TopAbs_EDGE ) pcurve = BRep_Tool::CurveOnSurface( TopoDS::Edge( S ), face, f,l ); if ( !pcurve.IsNull() ) { - double u = (( SMDS_EdgePosition* ) pos.get() )->GetUParameter(); + double u = (( SMDS_EdgePosition* ) pos )->GetUParameter(); uv = pcurve->Value( u ).XY(); } break; @@ -4020,7 +4020,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements, while ( aItN->more() ) { const SMDS_MeshNode* pNode = aItN->next(); const SMDS_EdgePosition* pEPos = - static_cast( pNode->GetPosition().get() ); + static_cast( pNode->GetPosition() ); double aT = pEPos->GetUParameter(); aPrms.push_back( aT ); } @@ -4064,7 +4064,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements, while ( aItN->more() ) { const SMDS_MeshNode* pNode = aItN->next(); const SMDS_EdgePosition* pEPos = - static_cast( pNode->GetPosition().get() ); + static_cast( pNode->GetPosition() ); double aT = pEPos->GetUParameter(); aPrms.push_back( aT ); } @@ -4192,7 +4192,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements, const SMDS_MeshNode* pNode = aItN->next(); if( pNode==aN1 || pNode==aN2 ) continue; const SMDS_EdgePosition* pEPos = - static_cast( pNode->GetPosition().get() ); + static_cast( pNode->GetPosition() ); double aT = pEPos->GetUParameter(); aPrms.push_back( aT ); } @@ -4239,7 +4239,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements, while ( aItN->more() ) { const SMDS_MeshNode* pNode = aItN->next(); const SMDS_EdgePosition* pEPos = - static_cast( pNode->GetPosition().get() ); + static_cast( pNode->GetPosition() ); double aT = pEPos->GetUParameter(); aPrms.push_back( aT ); } diff --git a/src/SMESH/SMESH_MesherHelper.cxx b/src/SMESH/SMESH_MesherHelper.cxx index 0ca91a4d3..829f5e324 100644 --- a/src/SMESH/SMESH_MesherHelper.cxx +++ b/src/SMESH/SMESH_MesherHelper.cxx @@ -343,7 +343,7 @@ gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face& F, { // node has position on face const SMDS_FacePosition* fpos = - static_cast(n->GetPosition().get()); + static_cast(n->GetPosition()); uv.SetCoord(fpos->GetUParameter(),fpos->GetVParameter()); uvOK = CheckNodeUV( F, n, uv.ChangeCoord(), BRep_Tool::Tolerance( F )); } @@ -353,7 +353,7 @@ gp_XY SMESH_MesherHelper::GetNodeUV(const TopoDS_Face& F, // corresponding edge from face, get pcurve for this // edge and retrieve value from this pcurve const SMDS_EdgePosition* epos = - static_cast(n->GetPosition().get()); + static_cast(n->GetPosition()); int edgeID = Pos->GetShapeId(); TopoDS_Edge E = TopoDS::Edge(GetMeshDS()->IndexToShape(edgeID)); double f, l, u = epos->GetUParameter(); @@ -548,7 +548,7 @@ double SMESH_MesherHelper::GetNodeU(const TopoDS_Edge& E, const SMDS_PositionPtr Pos = n->GetPosition(); if(Pos->GetTypeOfPosition()==SMDS_TOP_EDGE) { const SMDS_EdgePosition* epos = - static_cast(n->GetPosition().get()); + static_cast(n->GetPosition()); param = epos->GetUParameter(); } else if(Pos->GetTypeOfPosition()==SMDS_TOP_VERTEX) { @@ -1176,7 +1176,7 @@ bool SMESH_MesherHelper::LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap, if(IsMedium(node, SMDSAbs_Edge)) continue; const SMDS_EdgePosition* pos = - dynamic_cast( node->GetPosition().get() ); + dynamic_cast( node->GetPosition() ); if ( !pos ) { return false; } @@ -1198,7 +1198,7 @@ bool SMESH_MesherHelper::LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap, if(IsMedium(node)) continue; const SMDS_EdgePosition* pos = - dynamic_cast( node->GetPosition().get() ); + dynamic_cast( node->GetPosition() ); if ( !pos ) { return false; } diff --git a/src/SMESH/SMESH_Pattern.cxx b/src/SMESH/SMESH_Pattern.cxx index 834003e8c..ae63f672e 100644 --- a/src/SMESH/SMESH_Pattern.cxx +++ b/src/SMESH/SMESH_Pattern.cxx @@ -733,7 +733,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, { const SMDS_MeshNode* node = smdsNode( nIt->next() ); const SMDS_EdgePosition* epos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); double u = epos->GetUParameter(); paramNodeMap.insert( make_pair( u, node )); } @@ -850,7 +850,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, p->myInitUV = project( node, projector ); else { const SMDS_FacePosition* pos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); p->myInitUV.SetCoord( pos->GetUParameter(), pos->GetVParameter() ); } p->myInitXYZ.SetCoord( p->myInitUV.X(), p->myInitUV.Y(), 0 ); @@ -3208,7 +3208,7 @@ bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, { const SMDS_MeshNode* node = smdsNode( nIt->next() ); const SMDS_EdgePosition* epos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); double u = ( epos->GetUParameter() - f ) / ( l - f ); (*pIt)->myInitXYZ.SetCoord( iCoord, isForward ? u : 1 - u ); } diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index 146df73d1..f14bb5a73 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -325,14 +325,14 @@ void SMESHDS_SubMesh::Clear() int SMESHDS_SubMesh::getSize() { - int a = sizeof(myElements); - int b = sizeof(myNodes); +// int a = sizeof(myElements); +// int b = sizeof(myNodes); int c = NbNodes(); int d = NbElements(); cerr << "SMESHDS_SubMesh::NbNodes " << c << endl; cerr << "SMESHDS_SubMesh::NbElements " << d << endl; - cerr << "SMESHDS_SubMesh::myNodes " << b << endl; - cerr << "SMESHDS_SubMesh::myElements " << a << endl; +// cerr << "SMESHDS_SubMesh::myNodes " << b << endl; +// cerr << "SMESHDS_SubMesh::myElements " << a << endl; return c+d; } diff --git a/src/SMESH_I/Makefile.am b/src/SMESH_I/Makefile.am index d74457f35..a2258d6b4 100644 --- a/src/SMESH_I/Makefile.am +++ b/src/SMESH_I/Makefile.am @@ -109,6 +109,7 @@ libSMESHEngine_la_CPPFLAGS = \ libSMESHEngine_la_LDFLAGS = \ ../../idl/libSalomeIDLSMESH.la \ ../SMESH/libSMESHimpl.la \ + ../SMDS/libSMDS.la \ ../Controls/libSMESHControls.la \ $(KERNEL_LDFLAGS) \ -lSalomeContainer \ diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index 9e041d589..488accd76 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -2983,7 +2983,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, const SMDS_PositionPtr pos = node->GetPosition(); if ( onFace ) { // on FACE const SMDS_FacePosition* fPos = - dynamic_cast( pos.get() ); + dynamic_cast( pos ); if ( fPos ) { aUPos[ iNode ] = fPos->GetUParameter(); aVPos[ iNode ] = fPos->GetVParameter(); @@ -2994,7 +2994,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, } else { // on EDGE const SMDS_EdgePosition* ePos = - dynamic_cast( pos.get() ); + dynamic_cast( pos ); if ( ePos ) { aUPos[ iNode ] = ePos->GetUParameter(); iNode++; @@ -3973,7 +3973,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, // not fixed bugs in SMDS_MeshInfo if ( aPos->GetTypeOfPosition() == SMDS_TOP_FACE ) { SMDS_FacePosition* fPos = const_cast - ( static_cast( aPos.get() )); + ( static_cast( aPos )); fPos->SetUParameter( aUPos[ iNode ]); fPos->SetVParameter( aVPos[ iNode ]); } @@ -3982,7 +3982,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, // ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE );-- issue 20182 if ( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE ) { SMDS_EdgePosition* fPos = const_cast - ( static_cast( aPos.get() )); + ( static_cast( aPos )); fPos->SetUParameter( aUPos[ iNode ]); } } diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 6b6d8220b..3f5ccd718 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -2949,15 +2949,15 @@ SMESH::NodePosition* SMESH_Mesh_i::GetNodePosition(CORBA::Long NodeID) aNodePosition->shapeType = GEOM::EDGE; aNodePosition->params.length(1); aNodePosition->params[0] = - static_cast( pos.get() )->GetUParameter(); + static_cast( pos )->GetUParameter(); break; case SMDS_TOP_FACE: aNodePosition->shapeType = GEOM::FACE; aNodePosition->params.length(2); aNodePosition->params[0] = - static_cast( pos.get() )->GetUParameter(); + static_cast( pos )->GetUParameter(); aNodePosition->params[1] = - static_cast( pos.get() )->GetVParameter(); + static_cast( pos )->GetVParameter(); break; case SMDS_TOP_VERTEX: aNodePosition->shapeType = GEOM::VERTEX; diff --git a/src/StdMeshers/StdMeshers_FaceSide.cxx b/src/StdMeshers/StdMeshers_FaceSide.cxx index c677973be..f34def734 100644 --- a/src/StdMeshers/StdMeshers_FaceSide.cxx +++ b/src/StdMeshers/StdMeshers_FaceSide.cxx @@ -238,7 +238,7 @@ const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, if ( myIgnoreMediumNodes && SMESH_MeshEditor::IsMedium( node, SMDSAbs_Edge )) continue; const SMDS_EdgePosition* epos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); double u = epos->GetUParameter(); // paramSize is signed so orientation is taken into account double normPar = prevNormPar + r * ( u - myFirst[i] ) / paramSize; @@ -288,7 +288,7 @@ const vector& StdMeshers_FaceSide::GetUVPtStruct(bool isXConst, paramSize = myNormPar[ EdgeIndex ] - prevNormPar; } const SMDS_EdgePosition* epos = - dynamic_cast(uvPt.node->GetPosition().get()); + dynamic_cast(uvPt.node->GetPosition()); if ( epos ) { uvPt.param = epos->GetUParameter(); } diff --git a/src/StdMeshers/StdMeshers_Hexa_3D.cxx b/src/StdMeshers/StdMeshers_Hexa_3D.cxx index 42b5488ec..7e1c49a35 100644 --- a/src/StdMeshers/StdMeshers_Hexa_3D.cxx +++ b/src/StdMeshers/StdMeshers_Hexa_3D.cxx @@ -161,7 +161,7 @@ inline bool isCloser(const int i, const int j, const int nbhoriz, static bool findIJ (const SMDS_MeshNode* node, const FaceQuadStruct * quad, int& I, int& J) { const SMDS_FacePosition* fpos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); if ( ! fpos ) return false; gp_Pnt2d uv( fpos->GetUParameter(), fpos->GetVParameter() ); @@ -206,9 +206,9 @@ static bool findIJ (const SMDS_MeshNode* node, const FaceQuadStruct * quad, int& * -0. - shape and face mesh verification * -1. - identify faces and vertices of the "cube" * -2. - Algorithm from: - * "Application de l'interpolation transfinie à la création de maillages + * "Application de l'interpolation transfinie a la creation de maillages * C0 ou G1 continus sur des triangles, quadrangles, tetraedres, pentaedres - * et hexaedres déformés." + * et hexaedres deformes." * Alain PERONNET - 8 janvier 1999 */ //============================================================================= @@ -407,6 +407,9 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, int i1, j1, nbxyz = nbx * nby * nbz; Point3DStruct *np = new Point3DStruct[nbxyz]; + + aMesh.GetMeshDS()->incrementNodesCapacity(nbx * nby * nbz); + aMesh.GetMeshDS()->incrementCellsCapacity((nbx-1) * (nby-1) * (nbz-1)); // 1.9 - store node indexes of faces diff --git a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx index ca1ef9e11..f4ef0198d 100644 --- a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx +++ b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx @@ -511,7 +511,7 @@ static bool fixCommonVertexUV (R2 & theUV, if ( theCreateQuadratic && SMESH_MesherHelper::IsMedium( node, SMDSAbs_Edge )) continue; const SMDS_EdgePosition* epos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); double u = epos->GetUParameter(); if ( u < umin ) umin = u; diff --git a/src/StdMeshers/StdMeshers_Penta_3D.cxx b/src/StdMeshers/StdMeshers_Penta_3D.cxx index 7ae2e3a54..a12a3f088 100644 --- a/src/StdMeshers/StdMeshers_Penta_3D.cxx +++ b/src/StdMeshers/StdMeshers_Penta_3D.cxx @@ -234,7 +234,7 @@ void StdMeshers_Penta_3D::MakeNodes() // if ( SMESH_Block::IsEdgeID (aSID)) { const SMDS_EdgePosition* epos = - static_cast(aNode->GetPosition().get()); + static_cast(aNode->GetPosition()); myBlock.ComputeParameters( epos->GetUParameter(), aS, aCoords ); } else { @@ -1470,7 +1470,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, if(myTool->IsMedium(node)) continue; const SMDS_EdgePosition* pos = - dynamic_cast( node->GetPosition().get() ); + dynamic_cast( node->GetPosition() ); if ( !pos ) { return false; } @@ -1493,7 +1493,7 @@ bool StdMeshers_Penta_3D::LoadIJNodes(StdMeshers_IJNodeMap & theIJNodes, if(myTool->IsMedium(node)) continue; const SMDS_EdgePosition* pos = - dynamic_cast( node->GetPosition().get() ); + dynamic_cast( node->GetPosition() ); if ( !pos ) { return false; } diff --git a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx index a4d4fdfbc..a964b99c9 100644 --- a/src/StdMeshers/StdMeshers_ProjectionUtils.cxx +++ b/src/StdMeshers/StdMeshers_ProjectionUtils.cxx @@ -1750,7 +1750,7 @@ FindMatchingNodesOnFaces( const TopoDS_Face& face1, while ( nIt->more() ) { const SMDS_MeshNode* node = nIt->next(); const SMDS_EdgePosition* pos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); pos2nodes.insert( make_pair( pos->GetUParameter(), node )); } if ( pos2nodes.size() != edgeSM->NbNodes() ) diff --git a/src/StdMeshers/StdMeshers_Projection_2D.cxx b/src/StdMeshers/StdMeshers_Projection_2D.cxx index a433e2dc3..63b843d32 100644 --- a/src/StdMeshers/StdMeshers_Projection_2D.cxx +++ b/src/StdMeshers/StdMeshers_Projection_2D.cxx @@ -339,7 +339,7 @@ namespace { RETURN_BAD_RESULT("Bad node position type: node " << node->GetID() << " pos type " << node->GetPosition()->GetTypeOfPosition()); const SMDS_EdgePosition* pos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); u2nodes.insert( make_pair( pos->GetUParameter(), node )); seamNodes.insert( node ); } @@ -644,7 +644,7 @@ bool StdMeshers_Projection_2D::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& } case SMDS_TOP_EDGE: { const SMDS_EdgePosition* pos = - static_cast(node->GetPosition().get()); + static_cast(node->GetPosition()); pos2nodes.insert( make_pair( pos->GetUParameter(), node )); break; } -- 2.30.2