From: prascle Date: Mon, 22 Nov 2010 16:25:35 +0000 (+0000) Subject: PR: some more debug X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=405a5b87ab687ba07b5cbc70e86e169d9814c559;p=modules%2Fsmesh.git PR: some more debug --- diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index adc3232fe..99b551c93 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -186,7 +186,8 @@ vtkIdType SMESH_VisualObjDef::GetElemVTKId( int theObjID ) TMapOfIds::const_iterator i = mySMDS2VTKElems.find(theObjID); return i == mySMDS2VTKElems.end() ? -1 : i->second; } - return this->GetMesh()->fromSmdsToVtk(theObjID); + return this->GetMesh()->FindElement(theObjID)->getVtkId(); + //return this->GetMesh()->fromSmdsToVtk(theObjID); } //================================================================================= @@ -263,6 +264,11 @@ void SMESH_VisualObjDef::buildPrs(bool buildGrid) else { myLocalGrid = false; + if (!GetMesh()->isCompacted()) + { + MESSAGE("*** buildPrs ==> compactMesh!"); + GetMesh()->compactMesh(); + } vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); myGrid->ShallowCopy(theGrid); //MESSAGE(myGrid->GetReferenceCount()); diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 991b39fe7..132daa043 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -126,7 +126,7 @@ SMDS_Mesh::SMDS_Mesh() myHasInverseElements(true), myNodeMin(0), myNodeMax(0), myNodePool(0), myEdgePool(0), myFacePool(0), myVolumePool(0), - myModified(false), myRemovedNodes(false), myChangedNodes(false), + myModified(false), myModifTime(0), myCompactTime(0), xmin(0), xmax(0), ymin(0), ymax(0), zmin(0), zmax(0) { myMeshId = _meshList.size(); // --- index of the mesh to push back in the vector @@ -147,7 +147,7 @@ SMDS_Mesh::SMDS_Mesh() myNodes.clear(); myCells.clear(); - myCellIdSmdsToVtk.clear(); + //myCellIdSmdsToVtk.clear(); myCellIdVtkToSmds.clear(); myGrid = SMDS_UnstructuredGrid::New(); myGrid->setSMDS_mesh(this); @@ -158,6 +158,7 @@ SMDS_Mesh::SMDS_Mesh() myGrid->SetPoints( points ); points->Delete(); myGrid->BuildLinks(); + this->Modified(); } /////////////////////////////////////////////////////////////////////////////// @@ -1309,15 +1310,74 @@ SMDS_MeshVolume* SMDS_Mesh::AddPolyhedralVolume return v; } +SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIds(const std::vector& vtkNodeIds) +{ + int ID = myElementIDFactory->GetFreeID(); + SMDS_MeshVolume * v = SMDS_Mesh::AddVolumeFromVtkIdsWithID(vtkNodeIds, ID); + if (v == NULL) myElementIDFactory->ReleaseID(ID); + return v; +} + +SMDS_MeshVolume* SMDS_Mesh::AddVolumeFromVtkIdsWithID(const std::vector& vtkNodeIds, const int ID) +{ + SMDS_VtkVolume *volvtk = myVolumePool->getNew(); + volvtk->init(vtkNodeIds, this); + if (!this->registerElement(ID,volvtk)) + { + this->myGrid->GetCellTypesArray()->SetValue(volvtk->getVtkId(), VTK_EMPTY_CELL); + myVolumePool->destroy(volvtk); + return 0; + } + adjustmyCellsCapacity(ID); + myCells[ID] = volvtk; + vtkIdType aVtkType = volvtk->GetVtkType(); + switch (aVtkType) + { + case VTK_TETRA: + myInfo.myNbTetras++; + break; + case VTK_PYRAMID: + myInfo.myNbPyramids++; + break; + case VTK_WEDGE: + myInfo.myNbPrisms++; + break; + case VTK_HEXAHEDRON: + myInfo.myNbHexas++; + break; + case VTK_QUADRATIC_TETRA: + myInfo.myNbQuadTetras++; + break; + case VTK_QUADRATIC_PYRAMID: + myInfo.myNbQuadPyramids++; + break; + case VTK_QUADRATIC_WEDGE: + myInfo.myNbQuadPrisms++; + break; + case VTK_QUADRATIC_HEXAHEDRON: + myInfo.myNbQuadHexas++; + break; +#ifdef VTK_HAVE_POLYHEDRON + case VTK_POLYHEDRON: + myInfo.myNbPolyhedrons++; + break; +#endif + default: + myInfo.myNbPolyhedrons++; + break; + } + return volvtk; +} + /////////////////////////////////////////////////////////////////////////////// /// Registers element with the given ID, maintains inverse connections /////////////////////////////////////////////////////////////////////////////// bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element) { //MESSAGE("registerElement " << ID); - if ((ID < myCellIdSmdsToVtk.size()) && myCellIdSmdsToVtk[ID] >= 0) // --- already bound + if ((ID >=0) && (ID < myCells.size()) && myCells[ID]) // --- already bound { - MESSAGE(" --------------------------------- already bound "<< ID << " " << myCellIdSmdsToVtk[ID]); + MESSAGE(" ------------------ already bound "<< ID << " " << myCells[ID]->getVtkId()); return false; } @@ -1330,14 +1390,14 @@ bool SMDS_Mesh::registerElement(int ID, SMDS_MeshElement* element) if (vtkId == -1) vtkId = myElementIDFactory->SetInVtkGrid(element); - if (ID >= myCellIdSmdsToVtk.size()) // --- resize local vector - { - MESSAGE(" ------------------- resize myCellIdSmdsToVtk " << ID << " --> " << ID + SMDS_Mesh::chunkSize); - myCellIdSmdsToVtk.resize(ID + SMDS_Mesh::chunkSize, -1); // fill new elements with -1 - } - - myCellIdSmdsToVtk[ID] = vtkId; - //MESSAGE("smds:" << ID << " vtk:" << vtkId ); +// if (ID >= myCellIdSmdsToVtk.size()) // --- resize local vector +// { +// MESSAGE(" ------------------- resize myCellIdSmdsToVtk " << ID << " --> " << ID + SMDS_Mesh::chunkSize); +// myCellIdSmdsToVtk.resize(ID + SMDS_Mesh::chunkSize, -1); // fill new elements with -1 +// } +// +// myCellIdSmdsToVtk[ID] = vtkId; +// //MESSAGE("smds:" << ID << " vtk:" << vtkId ); if (vtkId >= myCellIdVtkToSmds.size()) // --- resize local vector { @@ -2328,10 +2388,16 @@ SMDS_Mesh::~SMDS_Mesh() { SMDS_ElemIteratorPtr eIt = elementsIterator(); while ( eIt->more() ) - myElementIDFactory->ReleaseID(eIt->next()->GetID()); + { + const SMDS_MeshElement *elem = eIt->next(); + myElementIDFactory->ReleaseID(elem->GetID(), elem->getVtkId()); + } SMDS_NodeIteratorPtr itn = nodesIterator(); while (itn->more()) - myNodeIDFactory->ReleaseID(itn->next()->GetID()); + { + const SMDS_MeshNode *node = itn->next(); + myNodeIDFactory->ReleaseID(node->GetID(), node->getVtkId()); + } } // SetOfNodes::Iterator itn(myNodes); @@ -2380,10 +2446,16 @@ void SMDS_Mesh::Clear() { SMDS_ElemIteratorPtr eIt = elementsIterator(); while ( eIt->more() ) - myElementIDFactory->ReleaseID(eIt->next()->GetID()); + { + const SMDS_MeshElement *elem = eIt->next(); + myElementIDFactory->ReleaseID(elem->GetID(), elem->getVtkId()); + } SMDS_NodeIteratorPtr itn = nodesIterator(); while (itn->more()) - myNodeIDFactory->ReleaseID(itn->next()->GetID()); + { + const SMDS_MeshNode *node = itn->next(); + myNodeIDFactory->ReleaseID(node->GetID(), node->getVtkId()); + } } else { @@ -2416,7 +2488,7 @@ void SMDS_Mesh::Clear() } myCells.clear(); myCellIdVtkToSmds.clear(); - myCellIdSmdsToVtk.clear(); + //myCellIdSmdsToVtk.clear(); SMDS_NodeIteratorPtr itn = nodesIterator(); while (itn->more()) @@ -2431,8 +2503,6 @@ void SMDS_Mesh::Clear() (*itc)->Clear(); myModified = false; - myRemovedNodes = false; - myChangedNodes = false; xmin = 0; xmax = 0; ymin = 0; ymax = 0; zmin = 0; zmax = 0; @@ -2923,7 +2993,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, n->RemoveInverseElement((*it)); } int IdToRemove = (*it)->GetID(); - int vtkid = this->fromSmdsToVtk(IdToRemove); + int vtkid = (*it)->getVtkId(); //MESSAGE("elem Id to remove " << IdToRemove << " vtkid " << vtkid << // " vtktype " << (*it)->GetVtkType() << " type " << (*it)->GetType()); switch ((*it)->GetType()) @@ -2939,7 +3009,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, myInfo.remove(*it); } removedElems.push_back((*it)); - myElementIDFactory->ReleaseID(IdToRemove); + myElementIDFactory->ReleaseID(IdToRemove, vtkid); delete (*it); break; case SMDSAbs_Edge: @@ -2949,7 +3019,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, myInfo.RemoveEdge(*it); } removedElems.push_back((*it)); - myElementIDFactory->ReleaseID(IdToRemove); + myElementIDFactory->ReleaseID(IdToRemove, vtkid); if (const SMDS_VtkEdge* vtkElem = dynamic_cast(*it)) myEdgePool->destroy((SMDS_VtkEdge*) vtkElem); else @@ -2962,7 +3032,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, myInfo.RemoveFace(*it); } removedElems.push_back((*it)); - myElementIDFactory->ReleaseID(IdToRemove); + myElementIDFactory->ReleaseID(IdToRemove, vtkid); if (const SMDS_VtkFace* vtkElem = dynamic_cast(*it)) myFacePool->destroy((SMDS_VtkFace*) vtkElem); else @@ -2975,7 +3045,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, myInfo.RemoveVolume(*it); } removedElems.push_back((*it)); - myElementIDFactory->ReleaseID(IdToRemove); + myElementIDFactory->ReleaseID(IdToRemove, vtkid); if (const SMDS_VtkVolume* vtkElem = dynamic_cast(*it)) myVolumePool->destroy((SMDS_VtkVolume*) vtkElem); else @@ -3003,7 +3073,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, myNodes[IdToRemove] = 0; myInfo.myNbNodes--; } - myNodeIDFactory->ReleaseID((*it)->GetID()); + myNodeIDFactory->ReleaseID((*it)->GetID(), (*it)->getVtkId()); removedNodes.push_back((*it)); if (const SMDS_MeshNode* vtkElem = dynamic_cast(*it)) myNodePool->destroy((SMDS_MeshNode*) vtkElem); @@ -3024,6 +3094,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) { int elemId = elem->GetID(); + int vtkId = elem->getVtkId(); //MESSAGE("SMDS_Mesh::RemoveFreeElement " << elemId); SMDSAbs_ElementType aType = elem->GetType(); SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem); @@ -3036,7 +3107,7 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) myNodes[elemId] = 0; myInfo.myNbNodes--; myNodePool->destroy(static_cast(todest)); - myNodeIDFactory->ReleaseID(elemId); + myNodeIDFactory->ReleaseID(elemId, vtkId); } } else { if (hasConstructionEdges() || hasConstructionFaces()) @@ -3044,8 +3115,6 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) return; //MESSAGE("Remove free element " << elemId); - int vtkid = this->fromSmdsToVtk(elemId); - // Remove element from of its nodes SMDS_ElemIteratorPtr itn = elem->nodesIterator(); while (itn->more()) { @@ -3079,9 +3148,9 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) default: break; } - myElementIDFactory->ReleaseID(elemId); + myElementIDFactory->ReleaseID(elemId, vtkId); - this->myGrid->GetCellTypesArray()->SetValue(vtkid, VTK_EMPTY_CELL); + this->myGrid->GetCellTypesArray()->SetValue(vtkId, VTK_EMPTY_CELL); // --- to do: keep vtkid in a list of reusable cells } } @@ -3980,10 +4049,10 @@ void SMDS_Mesh::updateNodeMinMax() void SMDS_Mesh::incrementNodesCapacity(int nbNodes) { - int val = myCellIdSmdsToVtk.size(); - MESSAGE(" ------------------- resize myCellIdSmdsToVtk " << val << " --> " << val + nbNodes); - myCellIdSmdsToVtk.resize(val + nbNodes, -1); // fill new elements with -1 - val = myNodes.size(); +// int val = myCellIdSmdsToVtk.size(); +// MESSAGE(" ------------------- resize myCellIdSmdsToVtk " << val << " --> " << val + nbNodes); +// myCellIdSmdsToVtk.resize(val + nbNodes, -1); // fill new elements with -1 + int val = myNodes.size(); MESSAGE(" ------------------- resize myNodes " << val << " --> " << val + nbNodes); myNodes.resize(val +nbNodes, 0); } @@ -4066,13 +4135,6 @@ int SMDS_Mesh::fromVtkToSmds(int vtkid) throw SALOME_Exception(LOCALIZED ("vtk id out of bounds")); } -int SMDS_Mesh::fromSmdsToVtk(int smdsid) -{ - if (smdsid >= 0 && smdsid < myCellIdSmdsToVtk.size()) - return myCellIdSmdsToVtk[smdsid]; - throw SALOME_Exception(LOCALIZED ("smds id out of bounds")); -} - void SMDS_Mesh::updateBoundingBox() { xmin = 0; xmax = 0; @@ -4105,3 +4167,31 @@ double SMDS_Mesh::getMaxDim() MESSAGE("getMaxDim " << dmax); return dmax; } + +//! modification that needs compact structure and redraw +void SMDS_Mesh::Modified() +{ + if (this->myModified) + { + this->myModifTime++; + MESSAGE("modified"); + myModified = false; + } +} + +//! get last modification timeStamp +unsigned long SMDS_Mesh::GetMTime() +{ + return this->myModifTime; +} + +bool SMDS_Mesh::isCompacted() +{ + if (this->myModifTime > this->myCompactTime) + { + MESSAGE(" *** isCompacted " << myCompactTime << " < " << myModifTime); + this->myCompactTime = this->myModifTime; + return false; + } + return true; +} diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index 72941961e..1642f1181 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -444,6 +444,11 @@ public: (std::vector nodes, std::vector quantities); + virtual SMDS_MeshVolume* AddVolumeFromVtkIds(const std::vector& vtkNodeIds); + + virtual SMDS_MeshVolume* AddVolumeFromVtkIdsWithID(const std::vector& vtkNodeIds, + const int ID); + virtual void RemoveElement(const SMDS_MeshElement * elem, std::list& removedElems, std::list& removedNodes, @@ -574,7 +579,6 @@ public: void updateBoundingBox(); double getMaxDim(); int fromVtkToSmds(int vtkid); - int fromSmdsToVtk(int smdsid); void incrementNodesCapacity(int nbNodes); void incrementCellsCapacity(int nbCells); @@ -582,6 +586,13 @@ public: void dumpGrid(string ficdump="dumpGrid"); static int chunkSize; + //! low level modification: add, change or remove node or element + inline void setMyModified() { this->myModified = true; }; + + void Modified(); + unsigned long GetMTime(); + bool isCompacted(); + protected: SMDS_Mesh(SMDS_Mesh * parent); @@ -652,7 +663,7 @@ protected: SetOfCells myCells; //! for cells only: index = ID for SMDS users, value = ID in vtkUnstructuredGrid - std::vector myCellIdSmdsToVtk; + //std::vector myCellIdSmdsToVtk; //! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users std::vector myCellIdVtkToSmds; @@ -663,6 +674,9 @@ protected: SMDS_MeshElementIDFactory *myElementIDFactory; SMDS_MeshInfo myInfo; + //! use a counter to keep track of modifications + unsigned long myModifTime, myCompactTime; + int myNodeMin; int myNodeMax; @@ -670,9 +684,9 @@ protected: bool myHasConstructionFaces; bool myHasInverseElements; - bool myModified; // any add remove or change of node or cell - bool myRemovedNodes; - bool myChangedNodes; + //! any add, remove or change of node or cell + bool myModified; + double xmin; double xmax; double ymin; diff --git a/src/SMDS/SMDS_MeshElementIDFactory.cxx b/src/SMDS/SMDS_MeshElementIDFactory.cxx index e447e3517..d4f6849f5 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.cxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.cxx @@ -120,7 +120,7 @@ bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem) //======================================================================= SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID) { - if ((ID<1) || (ID>myMax) || (myMesh->myCellIdSmdsToVtk[ID]<0)) + if ((ID<1) || (ID>=myMesh->myCells.size())) return NULL; const SMDS_MeshElement* elem = GetMesh()->FindElement(ID); return (SMDS_MeshElement*)(elem); @@ -130,19 +130,19 @@ SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID) //function : ReleaseID //purpose : //======================================================================= -void SMDS_MeshElementIDFactory::ReleaseID(const int ID) +void SMDS_MeshElementIDFactory::ReleaseID(int ID, int vtkId) { - if (ID < 1) + if (ID < 1) // TODO check case ID == O { - //MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID); + MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID ID = " << ID); return; } - int vtkId = myMesh->myCellIdSmdsToVtk[ID]; //MESSAGE("~~~~~~~~~~~~~~ SMDS_MeshElementIDFactory::ReleaseID smdsId vtkId " << ID << " " << vtkId); - if (ID >=0) + if (vtkId >= 0) { - myMesh->myCellIdSmdsToVtk[ID] = -1; + assert(vtkId < myMesh->myCellIdVtkToSmds.size()); myMesh->myCellIdVtkToSmds[vtkId] = -1; + myMesh->setMyModified(); } SMDS_MeshIDFactory::ReleaseID(ID); if (ID == myMax) @@ -160,12 +160,17 @@ void SMDS_MeshElementIDFactory::updateMinMax() const { myMin = IntegerLast(); myMax = 0; - for (int i=0; imyCellIdSmdsToVtk.size(); i++) - if (int id=myMesh->myCellIdSmdsToVtk[i] >=0) - { - if (id > myMax) myMax = id; - if (id < myMin) myMin = id; - } + for (int i = 0; i < myMesh->myCells.size(); i++) + { + if (myMesh->myCells[i]) + { + int id = myMesh->myCells[i]->GetID(); + if (id > myMax) + myMax = id; + if (id < myMin) + myMin = id; + } + } if (myMin == IntegerLast()) myMin = 0; } @@ -182,7 +187,8 @@ SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const void SMDS_MeshElementIDFactory::Clear() { - myMesh->myCellIdSmdsToVtk.clear(); + //myMesh->myCellIdSmdsToVtk.clear(); + myMesh->myCellIdVtkToSmds.clear(); myMin = myMax = 0; SMDS_MeshIDFactory::Clear(); } diff --git a/src/SMDS/SMDS_MeshElementIDFactory.hxx b/src/SMDS/SMDS_MeshElementIDFactory.hxx index dddbdcb95..3ce1674b4 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.hxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.hxx @@ -45,7 +45,7 @@ public: bool BindID(int ID, SMDS_MeshElement * elem); int SetInVtkGrid(SMDS_MeshElement * elem); SMDS_MeshElement * MeshElement(int ID); - virtual void ReleaseID(int ID); + virtual void ReleaseID(int ID, int vtkId = -1); SMDS_ElemIteratorPtr elementsIterator() const; virtual void Clear(); int GetVtkCellType(int SMDSType); diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index 981bbc1ae..f254c7003 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -62,7 +62,7 @@ int SMDS_MeshIDFactory::GetFreeID() //function : ReleaseID //purpose : //======================================================================= -void SMDS_MeshIDFactory::ReleaseID(const int ID) +void SMDS_MeshIDFactory::ReleaseID(int ID, int vtkId) { if ( ID > 0 ) { @@ -87,7 +87,6 @@ void SMDS_MeshIDFactory::ReleaseID(const int ID) } } } - myMesh->myModified = true; } void SMDS_MeshIDFactory::Clear() diff --git a/src/SMDS/SMDS_MeshIDFactory.hxx b/src/SMDS/SMDS_MeshIDFactory.hxx index 87c515145..fed18dc69 100644 --- a/src/SMDS/SMDS_MeshIDFactory.hxx +++ b/src/SMDS/SMDS_MeshIDFactory.hxx @@ -38,7 +38,7 @@ class SMDS_EXPORT SMDS_MeshIDFactory:public SMDS_MeshObject { public: int GetFreeID(); - virtual void ReleaseID(int ID); + virtual void ReleaseID(int ID, int vtkId = -1); virtual void Clear(); void SetMesh(SMDS_Mesh *mesh); diff --git a/src/SMDS/SMDS_MeshNode.cxx b/src/SMDS/SMDS_MeshNode.cxx index 5bf383965..fb52e05fc 100644 --- a/src/SMDS/SMDS_MeshNode.cxx +++ b/src/SMDS/SMDS_MeshNode.cxx @@ -295,8 +295,7 @@ void SMDS_MeshNode::setXYZ(double x, double y, double z) vtkPoints *points = mesh->getGrid()->GetPoints(); points->InsertPoint(myVtkID, x, y, z); mesh->adjustBoundingBox(x, y, z); - mesh->myChangedNodes = true; - mesh->myModified = true; + mesh->setMyModified(); } SMDSAbs_ElementType SMDS_MeshNode::GetType() const diff --git a/src/SMDS/SMDS_MeshNodeIDFactory.cxx b/src/SMDS/SMDS_MeshNodeIDFactory.cxx index db66103cd..4a310419d 100644 --- a/src/SMDS/SMDS_MeshNodeIDFactory.cxx +++ b/src/SMDS/SMDS_MeshNodeIDFactory.cxx @@ -72,10 +72,10 @@ SMDS_MeshElement* SMDS_MeshNodeIDFactory::MeshElement(int ID) //function : ReleaseID //purpose : //======================================================================= -void SMDS_MeshNodeIDFactory::ReleaseID(const int ID) +void SMDS_MeshNodeIDFactory::ReleaseID(const int ID, int vtkId) { SMDS_MeshIDFactory::ReleaseID(ID); - myMesh->myRemovedNodes = true; + myMesh->setMyModified(); if (ID == myMax) myMax = 0; // --- force updateMinMax if (ID == myMin) diff --git a/src/SMDS/SMDS_MeshNodeIDFactory.hxx b/src/SMDS/SMDS_MeshNodeIDFactory.hxx index 759dc8866..a79d68ea1 100644 --- a/src/SMDS/SMDS_MeshNodeIDFactory.hxx +++ b/src/SMDS/SMDS_MeshNodeIDFactory.hxx @@ -41,7 +41,7 @@ public: SMDS_MeshNodeIDFactory(); bool BindID(int ID, SMDS_MeshElement * elem); SMDS_MeshElement * MeshElement(int ID); - virtual void ReleaseID(int ID); + virtual void ReleaseID(int ID, int vtkId = -1); int GetMaxID() const; int GetMinID() const; SMDS_ElemIteratorPtr elementsIterator() const; diff --git a/src/SMDS/SMDS_UnstructuredGrid.hxx b/src/SMDS/SMDS_UnstructuredGrid.hxx index bf1c20f5b..13579d442 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.hxx +++ b/src/SMDS/SMDS_UnstructuredGrid.hxx @@ -22,7 +22,7 @@ #define VTK_MAXTYPE VTK_QUADRATIC_PYRAMID #endif -#define NBMAXNEIGHBORS 10 +#define NBMAXNEIGHBORS 100 // allow very huge polyhedrons in tests #define NBMAXNODESINCELL 5000 diff --git a/src/SMDS/SMDS_VtkEdge.cxx b/src/SMDS/SMDS_VtkEdge.cxx index c26a81262..6cd006d51 100644 --- a/src/SMDS/SMDS_VtkEdge.cxx +++ b/src/SMDS/SMDS_VtkEdge.cxx @@ -32,12 +32,14 @@ void SMDS_VtkEdge::init(std::vector nodeIds, SMDS_Mesh* mesh) if (nodeIds.size() == 3) aType = VTK_QUADRATIC_EDGE; myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]); + mesh->setMyModified(); //MESSAGE("SMDS_VtkEdge::init myVtkID " << myVtkID); } bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2) { const SMDS_MeshNode* nodes[] = { node1, node2 }; + SMDS_Mesh::_meshList[myMeshId]->setMyModified(); return ChangeNodes(nodes, 2); } @@ -56,6 +58,7 @@ bool SMDS_VtkEdge::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) { pts[i] = nodes[i]->getVtkId(); } + SMDS_Mesh::_meshList[myMeshId]->setMyModified(); return true; } diff --git a/src/SMDS/SMDS_VtkFace.cxx b/src/SMDS/SMDS_VtkFace.cxx index 7249cf4db..8362c2482 100644 --- a/src/SMDS/SMDS_VtkFace.cxx +++ b/src/SMDS/SMDS_VtkFace.cxx @@ -47,6 +47,7 @@ void SMDS_VtkFace::init(std::vector nodeIds, SMDS_Mesh* mesh) break; } myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]); + mesh->setMyModified(); //MESSAGE("SMDS_VtkFace::init myVtkID " << myVtkID); } @@ -56,6 +57,7 @@ void SMDS_VtkFace::initPoly(std::vector nodeIds, SMDS_Mesh* mesh) myIdInShape = -1; myMeshId = mesh->getMeshId(); myVtkID = grid->InsertNextLinkedCell(VTK_POLYGON, nodeIds.size(), &nodeIds[0]); + mesh->setMyModified(); } bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) @@ -73,6 +75,7 @@ bool SMDS_VtkFace::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes) { pts[i] = nodes[i]->getVtkId(); } + SMDS_Mesh::_meshList[myMeshId]->setMyModified(); return true; } diff --git a/src/SMDS/SMDS_VtkVolume.cxx b/src/SMDS/SMDS_VtkVolume.cxx index 26299a10e..841dc0b52 100644 --- a/src/SMDS/SMDS_VtkVolume.cxx +++ b/src/SMDS/SMDS_VtkVolume.cxx @@ -56,6 +56,7 @@ void SMDS_VtkVolume::init(std::vector nodeIds, SMDS_Mesh* mesh) break; } myVtkID = grid->InsertNextLinkedCell(aType, nodeIds.size(), &nodeIds[0]); + mesh->setMyModified(); //MESSAGE("SMDS_VtkVolume::init myVtkID " << myVtkID); } @@ -94,6 +95,7 @@ void SMDS_VtkVolume::initPoly(std::vector nodeIds, std::vector n k += nf; } myVtkID = grid->InsertNextLinkedCell(VTK_POLYHEDRON, nbFaces, &ptIds[0]); + mesh->setMyModified(); } #endif @@ -112,6 +114,7 @@ bool SMDS_VtkVolume::ChangeNodes(const SMDS_MeshNode* nodes[], const int nbNodes { pts[i] = nodes[i]->getVtkId(); } + SMDS_Mesh::_meshList[myMeshId]->setMyModified(); return true; } diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 9c5b8e20f..825d9c0da 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -159,6 +159,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, else if ( aShapesId ) aShapesId->insert( smToCompute->GetId() ); } + //aMesh.GetMeshDS()->Modified(); return ret; } else @@ -277,6 +278,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, SMESHDS_Mesh *myMesh = aMesh.GetMeshDS(); myMesh->adjustStructure(); + MESSAGE("*** compactMesh after compute"); myMesh->compactMesh(); //myMesh->adjustStructure(); list listind = myMesh->SubMeshIndices(); @@ -291,6 +293,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, MESSAGE("Number of node objects " << SMDS_MeshNode::nbNodes); MESSAGE("Number of cell objects " << SMDS_MeshCell::nbCells); //myMesh->dumpGrid(); + //aMesh.GetMeshDS()->Modified(); return ret; } diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 00998d206..f99b5ec51 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -3290,7 +3290,7 @@ void SMESH_MeshEditor::sweepElement(const SMDS_MeshElement* elem, const int nbSteps, SMESH_SequenceOfElemPtr& srcElements) { - MESSAGE("sweepElement " << nbSteps); + //MESSAGE("sweepElement " << nbSteps); SMESHDS_Mesh* aMesh = GetMeshDS(); // Loop on elem nodes: @@ -7376,7 +7376,11 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) // +---+---+ // 0 7 3 isOk = false; + if(nbRepl==2) { + MESSAGE("nbRepl=2: " << iRepl[0] << " " << iRepl[1]); + } if(nbRepl==3) { + MESSAGE("nbRepl=3: " << iRepl[0] << " " << iRepl[1] << " " << iRepl[2]); nbUniqueNodes = 6; if( iRepl[0]==0 && iRepl[1]==1 && iRepl[2]==4 ) { uniqueNodes[0] = curNodes[0]; @@ -7451,6 +7455,12 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) isOk = true; } } + if(nbRepl==4) { + MESSAGE("nbRepl=4: " << iRepl[0] << " " << iRepl[1] << " " << iRepl[2] << " " << iRepl[3]); + } + if(nbRepl==5) { + MESSAGE("nbRepl=5: " << iRepl[0] << " " << iRepl[1] << " " << iRepl[2] << " " << iRepl[3] << " " << iRepl[4]); + } break; } //////////////////////////////////// HEXAHEDRON @@ -7661,17 +7671,18 @@ void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) } } else { - //MESSAGE("Change regular element or polygon " << elem->GetID()); + int elemId = elem->GetID(); + //MESSAGE("Change regular element or polygon " << elemId); SMDSAbs_ElementType etyp = elem->GetType(); uniqueNodes.resize(nbUniqueNodes); - SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false); + aMesh->RemoveElement(elem); + SMDS_MeshElement* newElem = this->AddElement(uniqueNodes, etyp, false, elemId); if (newElem) { myLastCreatedElems.Append(newElem); if ( aShapeId ) aMesh->SetMeshElementOnShape( newElem, aShapeId ); } - aMesh->RemoveElement(elem); } } else { @@ -8984,6 +8995,8 @@ int SMESH_MeshEditor::convertElemToQuadratic(SMESHDS_SubMesh * theSm, if( !elem || elem->IsQuadratic() ) continue; int id = elem->GetID(); + //MESSAGE("elem " << id); + id = 0; // get a free number for new elements int nbNodes = elem->NbNodes(); vector aNds (nbNodes); @@ -8993,8 +9006,6 @@ int SMESH_MeshEditor::convertElemToQuadratic(SMESHDS_SubMesh * theSm, } SMDSAbs_ElementType aType = elem->GetType(); - GetMeshDS()->RemoveFreeElement(elem, theSm, notFromGroups); - const SMDS_MeshElement* NewElem = 0; switch( aType ) @@ -9047,8 +9058,11 @@ int SMESH_MeshEditor::convertElemToQuadratic(SMESHDS_SubMesh * theSm, ReplaceElemInGroups( elem, NewElem, GetMeshDS()); if( NewElem ) theSm->AddElement( NewElem ); + + GetMeshDS()->RemoveFreeElement(elem, theSm, notFromGroups); } - GetMeshDS()->compactMesh(); +// if (!GetMeshDS()->isCompacted()) +// GetMeshDS()->compactMesh(); return nbElem; } @@ -9176,7 +9190,8 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d) aHelper.SetSubShape(0); // apply to the whole mesh aHelper.FixQuadraticElements(); } - GetMeshDS()->compactMesh(); + if (!GetMeshDS()->isCompacted()) + GetMeshDS()->compactMesh(); } //======================================================================= @@ -10433,7 +10448,7 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vectorfromSmdsToVtk(anElem->GetID()); + int vtkId = anElem->getVtkId(); int neighborsVtkIds[NBMAXNEIGHBORS]; int downIds[NBMAXNEIGHBORS]; unsigned char downTypes[NBMAXNEIGHBORS]; @@ -10485,7 +10500,7 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vectorGetPoint(oldId); SMDS_MeshNode *newNode = meshDS->AddNode(coords[0], coords[1], coords[2]); - int newId = newNode->GetID(); + int newId = newNode->getVtkId(); nodeDomains[oldId][idom] = newId; // cloned node for other domains } } @@ -10531,13 +10546,12 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vectorfromVtkToSmds(vtkVolId); - meshDS->extrudeVolumeFromFace(smdsId, localClonedNodeIds); + meshDS->extrudeVolumeFromFace(vtkVolId, localClonedNodeIds); } } // --- iterate on shared faces (volumes to modify, face to extrude) - // get node id's of the face (id SMDS = id VTK) + // get node id's of the face // replace old nodes by new nodes in volumes, and update inverse connectivity itface = faceDomains.begin(); @@ -10563,8 +10577,7 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vectorfromVtkToSmds(vtkVolId); - meshDS->ModifyCellNodes(smdsId, localClonedNodeIds); + meshDS->ModifyCellNodes(vtkVolId, localClonedNodeIds); } } grid->BuildLinks(); diff --git a/src/SMESH/SMESH_MesherHelper.cxx b/src/SMESH/SMESH_MesherHelper.cxx index e73581e9e..7945cc3a4 100644 --- a/src/SMESH/SMESH_MesherHelper.cxx +++ b/src/SMESH/SMESH_MesherHelper.cxx @@ -740,6 +740,19 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1, const SMDS_PositionPtr Pos1 = n1->GetPosition(); const SMDS_PositionPtr Pos2 = n2->GetPosition(); + bool onGeom = true; + if ((Pos1->GetTypeOfPosition() != SMDS_TOP_FACE) && + (Pos1->GetTypeOfPosition() != SMDS_TOP_EDGE)) + onGeom = false; + if ((Pos2->GetTypeOfPosition() != SMDS_TOP_FACE) && + (Pos2->GetTypeOfPosition() != SMDS_TOP_EDGE)) + onGeom = false; + + TopoDS_Edge E; double u [2]; + TopoDS_Face F; gp_XY uv[2]; + bool uvOK[2] = { false, false }; + + if (onGeom) { if( myShape.IsNull() ) { if( Pos1->GetTypeOfPosition()==SMDS_TOP_FACE ) { @@ -757,9 +770,6 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1, } } // get positions of the given nodes on shapes - TopoDS_Edge E; double u [2]; - TopoDS_Face F; gp_XY uv[2]; - bool uvOK[2] = { false, false }; TopAbs_ShapeEnum shapeType = myShape.IsNull() ? TopAbs_SHAPE : myShape.ShapeType(); if ( faceID>0 || shapeType == TopAbs_FACE) { @@ -833,11 +843,15 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1, } } } + } // onGeom + // 3d variant double x = ( n1->X() + n2->X() )/2.; double y = ( n1->Y() + n2->Y() )/2.; double z = ( n1->Z() + n2->Z() )/2.; n12 = meshDS->AddNode(x,y,z); + + if (onGeom) { if ( !F.IsNull() ) { gp_XY UV = ( uv[0] + uv[1] ) / 2.; @@ -854,6 +868,8 @@ const SMDS_MeshNode* SMESH_MesherHelper::GetMediumNode(const SMDS_MeshNode* n1, { meshDS->SetNodeInVolume(n12, myShapeID); } + } // onGeom + myTLinkNodeMap.insert( make_pair( link, n12 )); return n12; } diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index c98d0a192..1f20c437c 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -250,7 +250,8 @@ bool SMESHDS_Mesh::ChangePolyhedronNodes void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID) { // TODO not possible yet to have node numbers not starting to O and continuous. - this->compactMesh(); + if (!this->isCompacted()) + this->compactMesh(); // SMDS_Mesh::Renumber( isNodes, startID, deltaID ); // myScript->Renumber( isNodes, startID, deltaID ); } @@ -1891,12 +1892,12 @@ void SMESHDS_Mesh::compactMesh() // << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() ); SetOfCells newCells; - vector newSmdsToVtk; + //vector newSmdsToVtk; vector newVtkToSmds; assert(maxVtkId < newCellSize); newCells.resize(newCellSize+1, 0); // 0 not used, SMDS numbers 1..n - newSmdsToVtk.resize(newCellSize+1, -1); + //newSmdsToVtk.resize(newCellSize+1, -1); newVtkToSmds.resize(newCellSize+1, -1); int myCellsSize = myCells.size(); @@ -1911,17 +1912,16 @@ void SMESHDS_Mesh::compactMesh() newCells[newSmdsId]->setId(newSmdsId); //MESSAGE("myCells["<< i << "] --> newCells[" << newSmdsId << "]"); int idvtk = myCells[i]->getVtkId(); - newSmdsToVtk[newSmdsId] = idvtk; + //newSmdsToVtk[newSmdsId] = idvtk; assert(idvtk < newCellSize); newVtkToSmds[idvtk] = newSmdsId; } } myCells.swap(newCells); - myCellIdSmdsToVtk.swap(newSmdsToVtk); + //myCellIdSmdsToVtk.swap(newSmdsToVtk); myCellIdVtkToSmds.swap(newVtkToSmds); MESSAGE("myCells.size()=" << myCells.size() - << " myCellIdSmdsToVtk.size()=" << myCellIdSmdsToVtk.size() << " myCellIdVtkToSmds.size()=" << myCellIdVtkToSmds.size() ); this->myElementIDFactory->emptyPool(newSmdsId); @@ -1944,13 +1944,12 @@ void SMESHDS_Mesh::BuildDownWardConnectivity(bool withEdges) /*! change some nodes in cell without modifying type or internal connectivity. * Nodes inverse connectivity is maintained up to date. - * @param smdsVolId smds id of the cell. + * @param vtkVolId vtk id of the cell. * @param localClonedNodeIds map old node id to new node id. * @return ok if success. */ -bool SMESHDS_Mesh::ModifyCellNodes(int smdsVolId, std::map localClonedNodeIds) +bool SMESHDS_Mesh::ModifyCellNodes(int vtkVolId, std::map localClonedNodeIds) { - int vtkVolId = this->fromSmdsToVtk(smdsVolId); myGrid->ModifyCellNodes(vtkVolId, localClonedNodeIds); return true; } @@ -1961,29 +1960,20 @@ bool SMESHDS_Mesh::ModifyCellNodes(int smdsVolId, std::map localClonedN * @param localClonedNodeIds map old node id to new node id. The old nodes define the face in the volume. * @return ok if success. */ -bool SMESHDS_Mesh::extrudeVolumeFromFace(int smdsVolId, std::map localClonedNodeIds) +bool SMESHDS_Mesh::extrudeVolumeFromFace(int vtkVolId, std::map& localClonedNodeIds) { - int vtkVolId = this->fromSmdsToVtk(smdsVolId); - //MESSAGE(smdsVolId << " " << vtkVolId); + //MESSAGE("extrudeVolumeFromFace " << vtkVolId); vector orderedNodes; orderedNodes.clear(); - map::iterator it = localClonedNodeIds.begin(); + map::const_iterator it = localClonedNodeIds.begin(); for (; it != localClonedNodeIds.end(); ++it) orderedNodes.push_back(it->first); int nbNodes = myGrid->getOrderedNodesOfFace(vtkVolId, orderedNodes); - if (nbNodes == 3) - { - int newVtkVolId =myElementIDFactory->GetFreeID(); - SMDS_MeshVolume *vol = this->AddVolumeWithID(orderedNodes[0], - orderedNodes[1], - orderedNodes[2], - localClonedNodeIds[orderedNodes[0]], - localClonedNodeIds[orderedNodes[1]], - localClonedNodeIds[orderedNodes[2]], - newVtkVolId); - } + for (int i=0; iAddVolumeFromVtkIds(orderedNodes); // TODO update subshape list of elements and nodes - return true; + return vol; } diff --git a/src/SMESHDS/SMESHDS_Mesh.hxx b/src/SMESHDS/SMESHDS_Mesh.hxx index daf12fbb2..eb7117861 100644 --- a/src/SMESHDS/SMESHDS_Mesh.hxx +++ b/src/SMESHDS/SMESHDS_Mesh.hxx @@ -399,7 +399,7 @@ public: std::vector nodes, std::vector quantities); bool ModifyCellNodes(int smdsVolId, std::map localClonedNodeIds); - bool extrudeVolumeFromFace(int smdsVolId, std::map localClonedNodeIds); + bool extrudeVolumeFromFace(int vtkVolId, std::map& localClonedNodeIds); void Renumber (const bool isNodes, const int startID=1, const int deltaID=1); void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S); diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index 8ccedd4c1..1b5bbfd0c 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -90,7 +90,7 @@ bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME, bool isElemDele myUnusedIdElements++; return true; } - MESSAGE("Try to remove an already deleted element from a submesh "); + //MESSAGE("Try to remove an already deleted element from a submesh "); return false; } MESSAGE("Try to remove an element from a complex submesh "); @@ -118,7 +118,7 @@ void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N) node->setIdInShape(myNodes.size()); myNodes.push_back(N); } - MESSAGE("try to add node in a complex submesh " << N->GetID()); + //MESSAGE("try to add node in a complex submesh " << N->GetID()); } //======================================================================= @@ -144,7 +144,7 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N, bool isNodeDeleted) myUnusedIdNodes++; return true; } - MESSAGE("Try to remove an already deleted node from a submesh"); + //MESSAGE("Try to remove an already deleted node from a submesh"); return false; } MESSAGE("Try to remove a node from a complex submesh"); diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index a01601680..f08adfc26 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -903,6 +903,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName // Dump creation of groups aServant->GetGroups(); + aServant->GetImpl().GetMeshDS()->Modified(); return aMesh._retn(); } @@ -976,6 +977,7 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, theStatus = status1; aResult[i++] = SMESH::SMESH_Mesh::_duplicate( mesh ); + meshServant->GetImpl().GetMeshDS()->Modified(); } aStudyBuilder->CommitCommand(); } @@ -1022,6 +1024,7 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName SMESH_Mesh_i* aServant = dynamic_cast( GetServant( aMesh ).in() ); ASSERT( aServant ); aServant->ImportSTLFile( theFileName ); + aServant->GetImpl().GetMeshDS()->Modified(); return aMesh._retn(); } @@ -1435,7 +1438,9 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, myLocShape = SMESH_Mesh::PseudoShape(); // call implementation compute ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); - return myGen.Compute( myLocMesh, myLocShape); + bool ret = myGen.Compute( myLocMesh, myLocShape); + myLocMesh.GetMeshDS()->Modified(); + return ret; } } catch ( std::bad_alloc ) { @@ -1924,11 +1929,12 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::mesh_array& theMeshesArray, // create mesh SMESH::SMESH_Mesh_var aNewMesh = CreateEmptyMesh(); + SMESHDS_Mesh* aNewMeshDS = 0; if ( !aNewMesh->_is_nil() ) { SMESH_Mesh_i* aNewImpl = dynamic_cast( GetServant( aNewMesh ).in() ); if ( aNewImpl ) { ::SMESH_Mesh& aLocMesh = aNewImpl->GetImpl(); - SMESHDS_Mesh* aNewMeshDS = aLocMesh.GetMeshDS(); + aNewMeshDS = aLocMesh.GetMeshDS(); TGroupsMap aGroupsMap; TListOfNewGroups aListOfNewGroups; @@ -2204,7 +2210,8 @@ SMESH_Gen_i::ConcatenateCommon(const SMESH::mesh_array& theMeshesArray, SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); aPixmap->SetPixMap("ICON_SMESH_TREE_MESH"); } - + if (aNewMeshDS) + aNewMeshDS->Modified(); return aNewMesh._retn(); } diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 4a1bbbc5e..37e82ad33 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -313,11 +313,12 @@ SMESH_MeshEditor_i::RemoveElements(const SMESH::long_array & IDsOfElements) // Update Python script TPythonDump() << "isDone = " << this << ".RemoveElements( " << IDsOfElements << " )"; + // Remove Elements + bool ret = anEditor.Remove( IdList, false ); + myMesh->GetMeshDS()->Modified(); if ( IDsOfElements.length() ) myMesh->SetIsModified( true ); // issue 0020693 - - // Remove Elements - return anEditor.Remove( IdList, false ); + return ret; } //============================================================================= @@ -338,10 +339,11 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH::long_array & IDsOfNo // Update Python script TPythonDump() << "isDone = " << this << ".RemoveNodes( " << IDsOfNodes << " )"; + bool ret = anEditor.Remove( IdList, true ); + myMesh->GetMeshDS()->Modified(); if ( IDsOfNodes.length() ) myMesh->SetIsModified( true ); // issue 0020693 - - return anEditor.Remove( IdList, true ); + return ret; } //============================================================================= @@ -361,8 +363,8 @@ CORBA::Long SMESH_MeshEditor_i::AddNode(CORBA::Double x, TPythonDump() << "nodeID = " << this << ".AddNode( " << x << ", " << y << ", " << z << " )"; + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); // issue 0020693 - return N->GetID(); } @@ -381,6 +383,7 @@ CORBA::Long SMESH_MeshEditor_i::Add0DElement(CORBA::Long IDOfNode) // Update Python script TPythonDump() << "elem0d = " << this << ".Add0DElement( " << IDOfNode <<" )"; + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); // issue 0020693 if (elem) @@ -423,6 +426,7 @@ CORBA::Long SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes) <GetMeshDS()->Modified(); if(elem) return myMesh->SetIsModified( true ), elem->GetID(); @@ -471,6 +475,7 @@ CORBA::Long SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes) // Update Python script TPythonDump() << "faceID = " << this << ".AddFace( " << IDsOfNodes << " )"; + myMesh->GetMeshDS()->Modified(); if(elem) return myMesh->SetIsModified( true ), elem->GetID(); @@ -496,6 +501,7 @@ CORBA::Long SMESH_MeshEditor_i::AddPolygonalFace (const SMESH::long_array & IDsO // Update Python script TPythonDump() <<"faceID = "<GetMeshDS()->Modified(); return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0; } @@ -539,6 +545,7 @@ CORBA::Long SMESH_MeshEditor_i::AddVolume(const SMESH::long_array & IDsOfNodes) // Update Python script TPythonDump() << "volID = " << this << ".AddVolume( " << IDsOfNodes << " )"; + myMesh->GetMeshDS()->Modified(); if(elem) return myMesh->SetIsModified( true ), elem->GetID(); @@ -574,6 +581,7 @@ CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolume (const SMESH::long_array & I // Update Python script TPythonDump() << "volID = " << this << ".AddPolyhedralVolume( " << IDsOfNodes << ", " << Quantities << " )"; + myMesh->GetMeshDS()->Modified(); return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0; } @@ -606,6 +614,7 @@ CORBA::Long SMESH_MeshEditor_i::AddPolyhedralVolumeByFaces (const SMESH::long_ar // Update Python script TPythonDump() << "volID = " << this << ".AddPolyhedralVolumeByFaces( " << IdsOfFaces << " )"; + myMesh->GetMeshDS()->Modified(); return elem ? ( myMesh->SetIsModified( true ), elem->GetID()) : 0; } @@ -726,7 +735,6 @@ void SMESH_MeshEditor_i::SetNodeOnFace(CORBA::Long NodeID, CORBA::Long FaceID, } mesh->SetNodeOnFace( node, FaceID, u, v ); - myMesh->SetIsModified( true ); } @@ -817,10 +825,12 @@ CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1, TPythonDump() << "isDone = " << this << ".InverseDiag( " << NodeID1 << ", " << NodeID2 << " )"; - myMesh->SetIsModified( true ); ::SMESH_MeshEditor aMeshEditor( myMesh ); - return aMeshEditor.InverseDiag ( n1, n2 ); + int ret = aMeshEditor.InverseDiag ( n1, n2 ); + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + return ret; } //============================================================================= @@ -847,6 +857,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1, bool stat = aMeshEditor.DeleteDiag ( n1, n2 ); + myMesh->GetMeshDS()->Modified(); if ( stat ) myMesh->SetIsModified( true ); // issue 0020693 @@ -876,6 +887,7 @@ CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfEleme // Update Python script TPythonDump() << "isDone = " << this << ".Reorient( " << IDsOfElements << " )"; + myMesh->GetMeshDS()->Modified(); if ( IDsOfElements.length() ) myMesh->SetIsModified( true ); // issue 0020693 @@ -962,6 +974,7 @@ CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfE ::SMESH_MeshEditor anEditor( myMesh ); bool stat = anEditor.TriToQuad( faces, aCrit, MaxAngle ); + myMesh->GetMeshDS()->Modified(); if ( stat ) myMesh->SetIsModified( true ); // issue 0020693 @@ -1025,6 +1038,7 @@ CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfE ::SMESH_MeshEditor anEditor( myMesh ); CORBA::Boolean stat = anEditor.QuadToTri( faces, aCrit ); + myMesh->GetMeshDS()->Modified(); if ( stat ) myMesh->SetIsModified( true ); // issue 0020693 @@ -1079,6 +1093,7 @@ CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfEle ::SMESH_MeshEditor anEditor( myMesh ); CORBA::Boolean stat = anEditor.QuadToTri( faces, Diag13 ); + myMesh->GetMeshDS()->Modified(); if ( stat ) myMesh->SetIsModified( true ); // issue 0020693 @@ -1155,6 +1170,7 @@ void SMESH_MeshEditor_i::SplitVolumesIntoTetra (SMESH::SMESH_IDSource_ptr elems, ::SMESH_MeshEditor anEditor (myMesh); anEditor.SplitVolumesIntoTetra( elemSet, int( methodFlags )); + myMesh->GetMeshDS()->Modified(); storeResult(anEditor); @@ -1269,6 +1285,7 @@ SMESH_MeshEditor_i::smooth(const SMESH::long_array & IDsOfElements, anEditor.Smooth(elements, fixedNodes, method, MaxNbOfIterations, MaxAspectRatio, IsParametric ); + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); // issue 0020693 storeResult(anEditor); @@ -1408,6 +1425,7 @@ SMESH_MeshEditor_i::rotationSweep(const SMESH::long_array & theIDsOfElements, anEditor.RotationSweep (*workElements, Ax1, theAngleInRadians, theNbOfSteps, theTolerance, theMakeGroups, makeWalls); storeResult(anEditor); + myMesh->GetMeshDS()->Modified(); // myMesh->SetIsModified( true ); -- it does not influence Compute() @@ -1686,6 +1704,7 @@ SMESH_MeshEditor_i::extrusionSweep(const SMESH::long_array & theIDsOfElements, ::SMESH_MeshEditor::PGroupIDs groupIds = anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps, aHystory, theMakeGroups); + myMesh->GetMeshDS()->Modified(); storeResult(anEditor); return theMakeGroups ? getGroups(groupIds.get()) : 0; @@ -2024,6 +2043,7 @@ SMESH_MeshEditor_i::extrusionAlongPath(const SMESH::long_array & theIDsOfEleme anEditor.ExtrusionAlongTrack( elements, aSubMesh, nodeStart, theHasAngles, angles, false, theHasRefPoint, refPnt, theMakeGroups ); + myMesh->GetMeshDS()->Modified(); storeResult(anEditor); theError = convExtrError( error ); @@ -2090,6 +2110,7 @@ SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements error = anEditor.ExtrusionAlongTrack( elements, &(aMeshImp->GetImpl()), aNodeStart, HasAngles, angles, LinearVariation, HasRefPoint, refPnt, MakeGroups ); + myMesh->GetMeshDS()->Modified(); } else { SMESH_subMesh_i* aSubMeshImp = SMESH::DownCast( Path ); @@ -2108,6 +2129,7 @@ SMESH_MeshEditor_i::extrusionAlongPathX(const SMESH::long_array & IDsOfElements error = anEditor.ExtrusionAlongTrack( elements, aSubMesh, aNodeStart, HasAngles, angles, LinearVariation, HasRefPoint, refPnt, MakeGroups ); + myMesh->GetMeshDS()->Modified(); } else { SMESH_Group_i* aGroupImp = SMESH::DownCast( Path ); @@ -2766,7 +2788,10 @@ SMESH_MeshEditor_i::mirror(const SMESH::long_array & theIDsOfElements, if(theCopy) storeResult(anEditor); else - myMesh->SetIsModified( true ); + { + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + } return theMakeGroups ? getGroups(groupIds.get()) : 0; } @@ -2975,7 +3000,10 @@ SMESH_MeshEditor_i::translate(const SMESH::long_array & theIDsOfElements, if(theCopy) storeResult(anEditor); else - myMesh->SetIsModified( true ); + { + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + } return theMakeGroups ? getGroups(groupIds.get()) : 0; } @@ -3183,7 +3211,10 @@ SMESH_MeshEditor_i::rotate(const SMESH::long_array & theIDsOfElements, if(theCopy) storeResult(anEditor); else - myMesh->SetIsModified( true ); + { + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + } return theMakeGroups ? getGroups(groupIds.get()) : 0; } @@ -3406,8 +3437,10 @@ SMESH_MeshEditor_i::scale(const SMESH::long_array & theIDsOfElements, if(theCopy) storeResult(anEditor); else - myMesh->SetIsModified( true ); - + { + myMesh->GetMeshDS()->Modified(); + myMesh->SetIsModified( true ); + } return theMakeGroups ? getGroups(groupIds.get()) : 0; } @@ -3633,7 +3666,7 @@ void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfN anEditor.MergeNodes( aListOfListOfNodes ); aTPythonDump << "])"; - + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); } @@ -3715,7 +3748,7 @@ void SMESH_MeshEditor_i::MergeElements(const SMESH::array_of_long_array& GroupsO ::SMESH_MeshEditor anEditor( myMesh ); anEditor.MergeElements(aListOfListOfElementsID); - + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); aTPythonDump << "] )"; @@ -3764,7 +3797,7 @@ CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID, // Update Python script TPythonDump() << "isDone = " << this << ".MoveNode( " << NodeID << ", " << x << ", " << y << ", " << z << " )"; - + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); return true; @@ -3862,6 +3895,7 @@ CORBA::Long SMESH_MeshEditor_i::MoveClosestNodeToPoint(CORBA::Double x, << ".MoveClosestNodeToPoint( "<< x << ", " << y << ", " << z << ", " << nodeID << " )"; + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); } @@ -4007,6 +4041,7 @@ SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1, storeResult(anEditor); + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); return error; @@ -4064,6 +4099,7 @@ SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1, storeResult(anEditor); + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); return error; @@ -4126,6 +4162,7 @@ SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, storeResult(anEditor); + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); return error; @@ -4183,6 +4220,7 @@ SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements, storeResult(anEditor); + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); return error; @@ -4221,6 +4259,7 @@ CORBA::Boolean SMESH_MeshEditor_i::ChangeElemNodes(CORBA::Long ide, bool res = GetMeshDS()->ChangeElementNodes( elem, & aNodes[0], nbn1+1 ); + myMesh->GetMeshDS()->Modified(); if ( res ) myMesh->SetIsModified( true ); @@ -4372,6 +4411,7 @@ void SMESH_MeshEditor_i::ConvertToQuadratic(CORBA::Boolean theForce3d) ::SMESH_MeshEditor anEditor( myMesh ); anEditor.ConvertToQuadratic(theForce3d); TPythonDump() << this << ".ConvertToQuadratic( " << theForce3d << " )"; + myMesh->GetMeshDS()->Modified(); myMesh->SetIsModified( true ); } @@ -4385,6 +4425,7 @@ CORBA::Boolean SMESH_MeshEditor_i::ConvertFromQuadratic() ::SMESH_MeshEditor anEditor( myMesh ); CORBA::Boolean isDone = anEditor.ConvertFromQuadratic(); TPythonDump() << this << ".ConvertFromQuadratic()"; + myMesh->GetMeshDS()->Modified(); if ( isDone ) myMesh->SetIsModified( true ); return isDone; @@ -4449,6 +4490,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodes( const SMESH::long_array& theNode bool aResult = aMeshEditor.DoubleNodes( aListOfNodes, aListOfElems ); + myMesh->GetMeshDS()->Modified(); storeResult( aMeshEditor) ; if ( aResult ) myMesh->SetIsModified( true ); @@ -4563,6 +4605,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeGroups( storeResult( aMeshEditor) ; + myMesh->GetMeshDS()->Modified(); if ( aResult ) myMesh->SetIsModified( true ); @@ -4601,6 +4644,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElem( const SMESH::long_array& theE storeResult( aMeshEditor) ; + myMesh->GetMeshDS()->Modified(); if ( aResult ) myMesh->SetIsModified( true ); @@ -4644,6 +4688,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemInRegion storeResult( aMeshEditor) ; + myMesh->GetMeshDS()->Modified(); if ( aResult ) myMesh->SetIsModified( true ); @@ -4698,6 +4743,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroup(SMESH::SMESH_GroupBase_pt storeResult( aMeshEditor) ; + myMesh->GetMeshDS()->Modified(); if ( aResult ) myMesh->SetIsModified( true ); @@ -4743,6 +4789,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroupInRegion( storeResult( aMeshEditor) ; + myMesh->GetMeshDS()->Modified(); if ( aResult ) myMesh->SetIsModified( true ); @@ -4800,6 +4847,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodeElemGroups(const SMESH::ListOfGroup storeResult( aMeshEditor) ; + myMesh->GetMeshDS()->Modified(); if ( aResult ) myMesh->SetIsModified( true ); @@ -4842,6 +4890,7 @@ SMESH_MeshEditor_i::DoubleNodeElemGroupsInRegion(const SMESH::ListOfGroups& theE storeResult( aMeshEditor) ; + myMesh->GetMeshDS()->Modified(); if ( aResult ) myMesh->SetIsModified( true ); @@ -4866,6 +4915,7 @@ CORBA::Boolean SMESH_MeshEditor_i::Make2DMeshFrom3D() ::SMESH_MeshEditor aMeshEditor( myMesh ); bool aResult = aMeshEditor.Make2DMeshFrom3D(); storeResult( aMeshEditor) ; + myMesh->GetMeshDS()->Modified(); TPythonDump() << "isDone = " << this << ".Make2DMeshFrom3D()"; return aResult; @@ -4912,6 +4962,7 @@ CORBA::Boolean SMESH_MeshEditor_i::DoubleNodesOnGroupBoundaries( const SMESH::Li bool aResult = aMeshEditor.DoubleNodesOnGroupBoundaries( domains, createJointElems ); storeResult( aMeshEditor) ; + myMesh->GetMeshDS()->Modified(); // Update Python script TPythonDump() << "isDone = " << this << ".DoubleNodesOnGroupBoundaries( " << &theDomains diff --git a/src/SMESH_I/SMESH_Pattern_i.cxx b/src/SMESH_I/SMESH_Pattern_i.cxx index 3d725b8fb..371ed32bb 100644 --- a/src/SMESH_I/SMESH_Pattern_i.cxx +++ b/src/SMESH_I/SMESH_Pattern_i.cxx @@ -215,7 +215,6 @@ SMESH::point_array* SMESH_Pattern_i::ApplyToFace(GEOM::GEOM_Object_ptr theFace, (*xyzIt)->Coord( p.x, p.y, p.z ); } } - // Update Python script TPythonDump() << "pattern.ApplyToFace( " << theFace << ", " << theVertexOnKeyPoint1 << ", " << theReverse << " )"; @@ -388,6 +387,7 @@ CORBA::Boolean SMESH_Pattern_i::MakeMesh (SMESH::SMESH_Mesh_ptr theMesh, addErrorCode( "MakeMesh" ); return myPattern.MakeMesh( aMesh, CreatePolygons, CreatePolyedrs ); + aMesh->GetMeshDS()->Modified(); } //=======================================================================