Salome HOME
PR: mesh and visu hexa no copy
[modules/smesh.git] / src / SMDS / SMDS_UnstructuredGrid.cxx
1
2
3 #include "SMDS_UnstructuredGrid.hxx"
4
5 using namespace std;
6
7 vtkCellLinks::Link* SMDS_CellLinks::AdjustSize(vtkIdType sz)
8 {
9   vtkIdType i;
10   vtkCellLinks::Link *newArray;
11   vtkIdType newSize = sz;
12   vtkCellLinks::Link linkInit = {0,NULL};
13
14   newArray = new vtkCellLinks::Link[newSize];
15
16   for (i=0; i<sz && i<this->Size; i++)
17     {
18     newArray[i] = this->Array[i];
19     }
20
21   for (i=this->Size; i < newSize ; i++)
22     {
23     newArray[i] = linkInit;
24     }
25
26   this->Size = newSize;
27   delete [] this->Array;
28   this->Array = newArray;
29
30   return this->Array;
31 }
32
33 SMDS_CellLinks* SMDS_CellLinks::New()
34 {
35   return new SMDS_CellLinks();
36 }
37
38 SMDS_CellLinks::SMDS_CellLinks() : vtkCellLinks()
39 {
40 }
41
42 SMDS_CellLinks::~SMDS_CellLinks()
43 {
44 }
45
46 /*! initialize an SMDS_CellLinks instance instead of a vtkCellLinks instance
47  *
48  */
49 void SMDS_UnstructuredGrid::BuildLinks()
50 {
51   // Remove the old links if they are already built
52   if (this->Links)
53     {
54     this->Links->UnRegister(this);
55     }
56
57   this->Links = SMDS_CellLinks::New();
58   this->Links->Allocate(this->GetNumberOfPoints());
59   this->Links->Register(this);
60   this->Links->BuildLinks(this, this->Connectivity);
61   this->Links->Delete();
62 }
63
64 SMDS_CellLinks* SMDS_UnstructuredGrid::GetCellLinks()
65 {
66   return static_cast<SMDS_CellLinks*>(this->Links);
67 }
68
69 SMDS_UnstructuredGrid* SMDS_UnstructuredGrid::New()
70 {
71   return new SMDS_UnstructuredGrid();
72 }
73
74 SMDS_UnstructuredGrid::SMDS_UnstructuredGrid() : vtkUnstructuredGrid()
75 {
76 }
77
78 SMDS_UnstructuredGrid::~SMDS_UnstructuredGrid()
79 {
80 }
81
82