Back to index

salome-smesh  6.5.0
SMDS_UnstructuredGrid.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2010-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // File:    SMDS_UnstructuredGrid.hxx
00021 // Author:  prascle
00022 // Created: September 16, 2009, 10:28 PM
00023 
00024 #ifndef _SMDS_UNSTRUCTUREDGRID_HXX
00025 #define _SMDS_UNSTRUCTUREDGRID_HXX
00026 
00027 #include "SMESH_SMDS.hxx"
00028 
00029 #include <vtkUnstructuredGrid.h>
00030 #include <vtkCellLinks.h>
00031 #include "chrono.hxx"
00032 
00033 #include <vector>
00034 #include <set>
00035 #include <map>
00036 
00037 //#define VTK_HAVE_POLYHEDRON
00038 //#ifdef VTK_HAVE_POLYHEDRON
00039 #define VTK_MAXTYPE VTK_POLYHEDRON
00040 //#else
00041 //  #define VTK_MAXTYPE VTK_QUADRATIC_PYRAMID
00042 //#endif
00043 
00044 #define NBMAXNEIGHBORS 100
00045 
00046 // allow very huge polyhedrons in tests
00047 #define NBMAXNODESINCELL 5000
00048 
00049 class SMDS_Downward;
00050 class SMDS_Mesh;
00051 class SMDS_MeshCell;
00052 class SMDS_MeshVolume;
00053 
00054 class SMDS_EXPORT SMDS_CellLinks: public vtkCellLinks
00055 {
00056 public:
00057   vtkCellLinks::Link* ResizeL(vtkIdType sz);
00058   vtkIdType GetLinksSize();
00059   static SMDS_CellLinks* New();
00060 protected:
00061   SMDS_CellLinks();
00062   ~SMDS_CellLinks();
00063 };
00064 
00065 class SMDS_EXPORT SMDS_UnstructuredGrid: public vtkUnstructuredGrid
00066 {
00067 public:
00068   void setSMDS_mesh(SMDS_Mesh *mesh);
00069   void compactGrid(std::vector<int>& idNodesOldToNew, int newNodeSize, std::vector<int>& idCellsOldToNew,
00070                    int newCellSize);
00071 
00072   virtual unsigned long GetMTime();
00073   virtual void Update();
00074   virtual void UpdateInformation();
00075   virtual vtkPoints *GetPoints();
00076 
00077   //#ifdef VTK_HAVE_POLYHEDRON
00078   int InsertNextLinkedCell(int type, int npts, vtkIdType *pts);
00079   //#endif
00080 
00081   int CellIdToDownId(int vtkCellId);
00082   void setCellIdToDownId(int vtkCellId, int downId);
00083   void CleanDownwardConnectivity();
00084   void BuildDownwardConnectivity(bool withEdges);
00085   int GetNeighbors(int* neighborsVtkIds, int* downIds, unsigned char* downTypes, int vtkId);
00086   int GetParentVolumes(int* volVtkIds, int vtkId);
00087   int GetParentVolumes(int* volVtkIds, int downId, unsigned char downType);
00088   void GetNodeIds(std::set<int>& nodeSet, int downId, unsigned char downType);
00089   void ModifyCellNodes(int vtkVolId, std::map<int, int> localClonedNodeIds);
00090   int getOrderedNodesOfFace(int vtkVolId, int& dim, std::vector<vtkIdType>& orderedNodes);
00091   void BuildLinks();
00092   SMDS_MeshCell* extrudeVolumeFromFace(int vtkVolId, int domain1, int domain2, std::set<int>& originalNodes,
00093                                        std::map<int, std::map<int, int> >& nodeDomains,
00094                                        std::map<int, std::map<long,int> >& nodeQuadDomains);
00095   vtkCellLinks* GetLinks()
00096   {
00097     return Links;
00098   }
00099   SMDS_Downward* getDownArray(unsigned char vtkType)
00100   {
00101     return _downArray[vtkType];
00102   }
00103   static SMDS_UnstructuredGrid* New();
00104   SMDS_Mesh *_mesh;
00105 protected:
00106   SMDS_UnstructuredGrid();
00107   ~SMDS_UnstructuredGrid();
00108   void copyNodes(vtkPoints *newPoints, std::vector<int>& idNodesOldToNew, int& alreadyCopied, int start, int end);
00109   void copyBloc(vtkUnsignedCharArray *newTypes, std::vector<int>& idCellsOldToNew, std::vector<int>& idNodesOldToNew,
00110                 vtkCellArray* newConnectivity, vtkIdTypeArray* newLocations, vtkIdType* pointsCell, int& alreadyCopied,
00111                 int start, int end);
00112 
00113   std::vector<int> _cellIdToDownId; 
00114   std::vector<unsigned char> _downTypes;
00115   std::vector<SMDS_Downward*> _downArray;
00116 };
00117 
00118 #endif  /* _SMDS_UNSTRUCTUREDGRID_HXX */
00119