Salome HOME
merge from branch BR_SMDS_MEMIMP 29 nov 2010
[modules/smesh.git] / src / SMDS / SMDS_UnstructuredGrid.hxx
1 /* 
2  * File:   SMDS_UnstructuredGrid.hxx
3  * Author: prascle
4  *
5  * Created on September 16, 2009, 10:28 PM
6  */
7
8 #ifndef _SMDS_UNSTRUCTUREDGRID_HXX
9 #define _SMDS_UNSTRUCTUREDGRID_HXX
10
11 #include <vtkUnstructuredGrid.h>
12 #include "chrono.hxx"
13
14 #include <vector>
15 #include <set>
16 #include <map>
17
18 //#define VTK_HAVE_POLYHEDRON
19 //#ifdef VTK_HAVE_POLYHEDRON
20   #define VTK_MAXTYPE VTK_POLYHEDRON
21 //#else
22 //  #define VTK_MAXTYPE VTK_QUADRATIC_PYRAMID
23 //#endif
24
25 #define NBMAXNEIGHBORS 100
26
27 // allow very huge polyhedrons in tests
28 #define NBMAXNODESINCELL 5000
29
30 class SMDS_Downward;
31 class SMDS_Mesh;
32
33 class SMDS_UnstructuredGrid: public vtkUnstructuredGrid
34 {
35 public:
36   void setSMDS_mesh(SMDS_Mesh *mesh);
37   void compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize, std::vector<int>& idCellsOldToNew,
38                    int newCellSize);
39
40   virtual unsigned long GetMTime();
41   virtual void Update();
42   virtual void UpdateInformation();
43   virtual vtkPoints *GetPoints();
44
45 //#ifdef VTK_HAVE_POLYHEDRON
46   int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
47 //#endif
48
49   int CellIdToDownId(int vtkCellId);
50   void setCellIdToDownId(int vtkCellId, int downId);
51   void BuildDownwardConnectivity(bool withEdges);
52   int GetNeighbors(int* neighborsVtkIds, int* downIds, unsigned char* downTypes, int vtkId);
53   void GetNodeIds(std::set<int>& nodeSet, int downId, unsigned char downType);
54   void ModifyCellNodes(int vtkVolId, std::map<int, int> localClonedNodeIds);
55   int getOrderedNodesOfFace(int vtkVolId, std::vector<int>& orderedNodes);
56   vtkCellLinks* GetLinks()
57   {
58     return Links;
59   }
60   SMDS_Downward* getDownArray(unsigned char vtkType)
61   {
62     return _downArray[vtkType];
63   }
64   static SMDS_UnstructuredGrid* New();
65   SMDS_Mesh *_mesh;
66 protected:
67   SMDS_UnstructuredGrid();
68   ~SMDS_UnstructuredGrid();
69   void copyNodes(vtkPoints *newPoints, std::vector<int>& idNodesOldToNew, int& alreadyCopied, int start, int end);
70   void copyBloc(vtkUnsignedCharArray *newTypes, std::vector<int>& idCellsOldToNew, std::vector<int>& idNodesOldToNew,
71                 vtkCellArray* newConnectivity, vtkIdTypeArray* newLocations, vtkIdType* pointsCell, int& alreadyCopied,
72                 int start, int end);
73
74   std::vector<int> _cellIdToDownId; //!< convert vtk Id to downward[vtkType] id, initialized with -1
75   std::vector<unsigned char> _downTypes;
76   std::vector<SMDS_Downward*> _downArray;
77 };
78
79 #endif  /* _SMDS_UNSTRUCTUREDGRID_HXX */
80