Salome HOME
Replace oe by ?
[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 <vtkCellLinks.h>
13 #include "chrono.hxx"
14
15 #include <vector>
16 #include <set>
17 #include <map>
18
19 //#define VTK_HAVE_POLYHEDRON
20 //#ifdef VTK_HAVE_POLYHEDRON
21 #define VTK_MAXTYPE VTK_POLYHEDRON
22 //#else
23 //  #define VTK_MAXTYPE VTK_QUADRATIC_PYRAMID
24 //#endif
25
26 #define NBMAXNEIGHBORS 100
27
28 // allow very huge polyhedrons in tests
29 #define NBMAXNODESINCELL 5000
30
31 class SMDS_Downward;
32 class SMDS_Mesh;
33 class SMDS_MeshVolume;
34
35 class SMDS_CellLinks: public vtkCellLinks
36 {
37 public:
38   vtkCellLinks::Link* ResizeL(vtkIdType sz);
39   vtkIdType GetLinksSize();
40   static SMDS_CellLinks* New();
41 protected:
42   SMDS_CellLinks();
43   ~SMDS_CellLinks();
44 };
45
46 class SMDS_UnstructuredGrid: public vtkUnstructuredGrid
47 {
48 public:
49   void setSMDS_mesh(SMDS_Mesh *mesh);
50   void compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize, std::vector<int>& idCellsOldToNew,
51                    int newCellSize);
52
53   virtual unsigned long GetMTime();
54   virtual void Update();
55   virtual void UpdateInformation();
56   virtual vtkPoints *GetPoints();
57
58   //#ifdef VTK_HAVE_POLYHEDRON
59   int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
60   //#endif
61
62   int CellIdToDownId(int vtkCellId);
63   void setCellIdToDownId(int vtkCellId, int downId);
64   void CleanDownwardConnectivity();
65   void BuildDownwardConnectivity(bool withEdges);
66   int GetNeighbors(int* neighborsVtkIds, int* downIds, unsigned char* downTypes, int vtkId);
67   int GetParentVolumes(int* volVtkIds, int vtkId);
68   int GetParentVolumes(int* volVtkIds, int downId, unsigned char downType);
69   void GetNodeIds(std::set<int>& nodeSet, int downId, unsigned char downType);
70   void ModifyCellNodes(int vtkVolId, std::map<int, int> localClonedNodeIds);
71   int getOrderedNodesOfFace(int vtkVolId, std::vector<vtkIdType>& orderedNodes);
72   void BuildLinks();
73   SMDS_MeshVolume* extrudeVolumeFromFace(int vtkVolId, int domain1, int domain2, std::set<int>& originalNodes,
74                                          std::map<int, std::map<int, int> >& nodeDomains,
75                                          std::map<int, std::map<long,int> >& nodeQuadDomains);
76   vtkCellLinks* GetLinks()
77   {
78     return Links;
79   }
80   SMDS_Downward* getDownArray(unsigned char vtkType)
81   {
82     return _downArray[vtkType];
83   }
84   static SMDS_UnstructuredGrid* New();
85   SMDS_Mesh *_mesh;
86 protected:
87   SMDS_UnstructuredGrid();
88   ~SMDS_UnstructuredGrid();
89   void copyNodes(vtkPoints *newPoints, std::vector<int>& idNodesOldToNew, int& alreadyCopied, int start, int end);
90   void copyBloc(vtkUnsignedCharArray *newTypes, std::vector<int>& idCellsOldToNew, std::vector<int>& idNodesOldToNew,
91                 vtkCellArray* newConnectivity, vtkIdTypeArray* newLocations, vtkIdType* pointsCell, int& alreadyCopied,
92                 int start, int end);
93
94   std::vector<int> _cellIdToDownId; //!< convert vtk Id to downward[vtkType] id, initialized with -1
95   std::vector<unsigned char> _downTypes;
96   std::vector<SMDS_Downward*> _downArray;
97 };
98
99 #endif  /* _SMDS_UNSTRUCTUREDGRID_HXX */
100