Salome HOME
PR: adjust points number
authorprascle <prascle>
Mon, 1 Feb 2010 13:51:19 +0000 (13:51 +0000)
committerprascle <prascle>
Mon, 1 Feb 2010 13:51:19 +0000 (13:51 +0000)
src/OBJECT/SMESH_Object.cxx
src/SMDS/SMDS_Mesh.cxx
src/SMDS/SMDS_Mesh.hxx
src/SMDS/SMDS_UnstructuredGrid.hxx
src/SMESH/SMESH_Gen.cxx

index 0d05206676ced4528e56227872a55b3b38956827..ea86d22c5a7f724796abfce938e43fa0099e57ea 100644 (file)
@@ -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() = "<<myGrid->GetNumberOfCells() );
+  MESSAGE("----------------------------------------------------------SMESH_VisualObjDef::buildPrs");
+  vtkUnstructuredGrid *theGrid = GetMesh()->getGrid();
+  myGrid->ShallowCopy(theGrid);
+  MESSAGE(myGrid->GetReferenceCount());
+  MESSAGE( "Update - myGrid->GetNumberOfCells() = "<<myGrid->GetNumberOfCells() );
+  MESSAGE( "Update - myGrid->GetNumberOfPoints() = "<<myGrid->GetNumberOfPoints() );
   if( MYDEBUGWITHFILES ) SMESH::WriteUnstructuredGrid( myGrid,"/tmp/buildPrs" );
 }
 
index f5d44ed8a4164be03e08c6dbe2ad1a4fc33041e7..1fbe8d3242dfeed12b3baa2fd118fe8fd394c99e 100644 (file)
@@ -39,6 +39,7 @@
 #include "SMDS_SpacePosition.hxx"
 
 #include <vtkUnstructuredGrid.h>
+#include <vtkUnsignedCharArray.h>
 
 #include <algorithm>
 #include <map>
@@ -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 <InverseElements> 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);
+}
+
index e471ca99a2626b406e60ee8183c7801f7db1deca..7b00f886310df11b370a54b021297c1f59db1e92 100644 (file)
@@ -568,6 +568,7 @@ public:
 
   void incrementNodesCapacity(int nbNodes);
   void incrementCellsCapacity(int nbCells);
+  void adjustStructure();
   
   int myCellLinksSize;
 
index 603305d9ddaf78f49b7ca17096c63e6cc9389216..aba1c52014bf5c9e8e445e1a45cb689a626037f0 100644 (file)
@@ -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:
index 314bbb2062509fdd951a527a6fb04dbc89353f3d..8fb0ec276f84ce1f9b44752c584508aa41d3e137 100644 (file)
@@ -295,6 +295,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh &          aMesh,
   MEMOSTAT;
 
   SMESHDS_Mesh *myMesh = aMesh.GetMeshDS();
+  myMesh->adjustStructure();
   list<int> listind = myMesh->SubMeshIndices();
   list<int>::iterator it = listind.begin();
   int total = 0;