From faf44b93566036dd93450abeae6df7db1060aba8 Mon Sep 17 00:00:00 2001 From: prascle Date: Mon, 1 Feb 2010 13:51:19 +0000 Subject: [PATCH] PR: adjust points number --- src/OBJECT/SMESH_Object.cxx | 15 ++++++++++----- src/SMDS/SMDS_Mesh.cxx | 14 +++++++++++++- src/SMDS/SMDS_Mesh.hxx | 1 + src/SMDS/SMDS_UnstructuredGrid.hxx | 2 ++ src/SMESH/SMESH_Gen.cxx | 1 + 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index 0d0520667..ea86d22c5 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -63,7 +63,7 @@ using namespace std; #endif #ifdef _DEBUG_ -static int MYDEBUG = 0; +static int MYDEBUG = 1; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; @@ -132,11 +132,13 @@ static inline vtkIdType getCellType( const SMDSAbs_ElementType theType, //================================================================================= SMESH_VisualObjDef::SMESH_VisualObjDef() { + MESSAGE("---------------------------------------------SMESH_VisualObjDef::SMESH_VisualObjDef"); myGrid = vtkUnstructuredGrid::New(); } SMESH_VisualObjDef::~SMESH_VisualObjDef() { - if ( MYDEBUG ) + MESSAGE("---------------------------------------------SMESH_VisualObjDef::~SMESH_VisualObjDef"); + //if ( MYDEBUG ) MESSAGE( "~SMESH_MeshObj - myGrid->GetReferenceCount() = " << myGrid->GetReferenceCount() ); myGrid->Delete(); } @@ -236,9 +238,12 @@ void SMESH_VisualObjDef::buildPrs() // myGrid->SetCells( 0, 0, 0 ); // throw; // } - myGrid = GetMesh()->getGrid(); - - if( MYDEBUG ) MESSAGE( "Update - myGrid->GetNumberOfCells() = "<GetNumberOfCells() ); + MESSAGE("----------------------------------------------------------SMESH_VisualObjDef::buildPrs"); + vtkUnstructuredGrid *theGrid = GetMesh()->getGrid(); + myGrid->ShallowCopy(theGrid); + MESSAGE(myGrid->GetReferenceCount()); + MESSAGE( "Update - myGrid->GetNumberOfCells() = "<GetNumberOfCells() ); + MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<GetNumberOfPoints() ); if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"/tmp/buildPrs" ); } diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index f5d44ed8a..1fbe8d324 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -39,6 +39,7 @@ #include "SMDS_SpacePosition.hxx" #include +#include #include #include @@ -2783,7 +2784,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) { int elemId = elem->GetID(); - //MESSAGE("SMDS_Mesh::RemoveFreeElement " << elemId); + MESSAGE("SMDS_Mesh::RemoveFreeElement " << elemId); SMDSAbs_ElementType aType = elem->GetType(); SMDS_MeshElement* todest = (SMDS_MeshElement*)(elem); if (aType == SMDSAbs_Node) { @@ -2801,6 +2802,8 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) // this methods is only for meshes without descendants return; + int vtkid = this->fromSmdsToVtk(elemId); + // Remove element from of its nodes SMDS_ElemIteratorPtr itn = elem->nodesIterator(); while (itn->more()) { @@ -2835,6 +2838,9 @@ void SMDS_Mesh::RemoveFreeElement(const SMDS_MeshElement * elem) break; } myElementIDFactory->ReleaseID(elemId); + + this->myGrid->GetCellTypesArray()->SetValue(vtkid, VTK_EMPTY_CELL); + // --- to do: keep vtkid in a list of reusable cells } } @@ -3582,3 +3588,9 @@ void SMDS_Mesh::incrementCellsCapacity(int nbCells) MESSAGE(" ------------------- resize myCells " << val << " --> " << val + nbCells); myNodes.resize(val +nbCells, 0); } + +void SMDS_Mesh::adjustStructure() +{ + myGrid->GetPoints()->GetData()->SetNumberOfTuples(myNodeIDFactory->GetMaxID()+1); +} + diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index e471ca99a..7b00f8863 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -568,6 +568,7 @@ public: void incrementNodesCapacity(int nbNodes); void incrementCellsCapacity(int nbCells); + void adjustStructure(); int myCellLinksSize; diff --git a/src/SMDS/SMDS_UnstructuredGrid.hxx b/src/SMDS/SMDS_UnstructuredGrid.hxx index 603305d9d..aba1c5201 100644 --- a/src/SMDS/SMDS_UnstructuredGrid.hxx +++ b/src/SMDS/SMDS_UnstructuredGrid.hxx @@ -29,6 +29,8 @@ public: void BuildLinks(); // initialise un SMDS_CellLinks; SMDS_CellLinks* GetCellLinks(); + vtkIdType GetCellArraySize() { return (this->Connectivity ? this->Connectivity->GetSize() : 0); }; + //virtual void Delete(); static SMDS_UnstructuredGrid* New(); protected: diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 314bbb206..8fb0ec276 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -295,6 +295,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, MEMOSTAT; SMESHDS_Mesh *myMesh = aMesh.GetMeshDS(); + myMesh->adjustStructure(); list listind = myMesh->SubMeshIndices(); list::iterator it = listind.begin(); int total = 0;