Salome HOME
23427: [CEA 2073] No hypothesis "Viscous Layers" with Netgen 1D-2D-3D
[modules/smesh.git] / src / SMDS / SMDS_Mesh.hxx
index 7e03612867568cae15b26cee5ed7b0cf55ef377f..d1d0b1120a83f9c196119639d9fdaf5ca6ed7f9e 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -58,7 +58,7 @@
 
 #define MYASSERT(val) if (!(val)) throw SALOME_Exception(LOCALIZED("assertion not verified"));
 
-class SMDS_EXPORT SMDS_Mesh:public SMDS_MeshObject
+class SMDS_EXPORT SMDS_Mesh : public SMDS_MeshObject
 {
 public:
   friend class SMDS_MeshIDFactory;
@@ -69,12 +69,12 @@ public:
 
   SMDS_Mesh();
   
-  //! to retreive this SMDS_Mesh instance from its elements (index stored in SMDS_Elements)
+  //! to retrieve this SMDS_Mesh instance from its elements (index stored in SMDS_Elements)
   static std::vector<SMDS_Mesh*> _meshList;
 
   //! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
-  inline SMDS_UnstructuredGrid* getGrid() {return myGrid; }
-  inline int getMeshId() {return myMeshId; }
+  inline SMDS_UnstructuredGrid* getGrid() { return myGrid; }
+  inline int getMeshId() { return myMeshId; }
 
   virtual SMDS_NodeIteratorPtr   nodesIterator     (bool idInceasingOrder=false) const;
   virtual SMDS_EdgeIteratorPtr   edgesIterator     (bool idInceasingOrder=false) const;
@@ -170,6 +170,25 @@ public:
                                  const SMDS_MeshNode * n23,
                                  const SMDS_MeshNode * n31);
 
+  // 2d order triangle of 7 nodes
+  virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3,
+                                       int n12,int n23,int n31, int nCenter, int ID);
+  virtual SMDS_MeshFace* AddFaceWithID(const SMDS_MeshNode * n1,
+                                       const SMDS_MeshNode * n2,
+                                       const SMDS_MeshNode * n3,
+                                       const SMDS_MeshNode * n12,
+                                       const SMDS_MeshNode * n23,
+                                       const SMDS_MeshNode * n31,
+                                       const SMDS_MeshNode * nCenter,
+                                       int ID);
+  virtual SMDS_MeshFace* AddFace(const SMDS_MeshNode * n1,
+                                 const SMDS_MeshNode * n2,
+                                 const SMDS_MeshNode * n3,
+                                 const SMDS_MeshNode * n12,
+                                 const SMDS_MeshNode * n23,
+                                 const SMDS_MeshNode * n31,
+                                 const SMDS_MeshNode * nCenter);
+
   // 2d order quadrangle
   virtual SMDS_MeshFace* AddFaceWithID(int n1, int n2, int n3, int n4,
                                        int n12,int n23,int n34,int n41, int ID);
@@ -557,14 +576,22 @@ public:
 
   virtual SMDS_MeshFace* AddPolygonalFace (const std::vector<const SMDS_MeshNode*> & nodes);
 
+  virtual SMDS_MeshFace* AddQuadPolygonalFaceWithID(const std::vector<int> & nodes_ids,
+                                                    const int                ID);
+
+  virtual SMDS_MeshFace* AddQuadPolygonalFaceWithID(const std::vector<const SMDS_MeshNode*> & nodes,
+                                                    const int                                 ID);
+
+  virtual SMDS_MeshFace* AddQuadPolygonalFace(const std::vector<const SMDS_MeshNode*> & nodes);
+
   virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
-                           (const std::vector<int> & nodes_ids,
-                            const std::vector<int> & quantities,
-                            const int                ID);
+    (const std::vector<int> & nodes_ids,
+     const std::vector<int> & quantities,
+     const int                ID);
 
   virtual SMDS_MeshVolume* AddPolyhedralVolumeWithID
-                           (const std::vector<const SMDS_MeshNode*> & nodes,
-                            const std::vector<int>                  & quantities,
+    (const std::vector<const SMDS_MeshNode*> & nodes,
+     const std::vector<int>                  & quantities,
                             const int                                 ID);
 
   virtual SMDS_MeshVolume* AddPolyhedralVolume
@@ -580,6 +607,7 @@ public:
 
   virtual SMDS_MeshFace* AddFaceFromVtkIdsWithID(const std::vector<vtkIdType>& vtkNodeIds,
                                                      const int ID);
+  virtual void MoveNode(const SMDS_MeshNode *n, double x, double y, double z);
 
   virtual void RemoveElement(const SMDS_MeshElement *        elem,
                              std::list<const SMDS_MeshElement *>& removedElems,
@@ -661,6 +689,9 @@ public:
   static const SMDS_MeshElement* FindElement(const std::vector<const SMDS_MeshNode *>& nodes,
                                              const SMDSAbs_ElementType                 type=SMDSAbs_All,
                                              const bool                                noMedium=true);
+  static int GetElementsByNodes(const std::vector<const SMDS_MeshNode *>& nodes,
+                                std::vector<const SMDS_MeshElement *>&    foundElems,
+                                const SMDSAbs_ElementType                 type=SMDSAbs_All);
 
   /*!
    * \brief Raise an exception if free memory (ram+swap) too low
@@ -677,6 +708,7 @@ public:
   const SMDS_MeshInfo& GetMeshInfo() const { return myInfo; }
 
   virtual int NbNodes() const;
+  virtual int NbElements() const;
   virtual int Nb0DElements() const;
   virtual int NbBalls() const;
   virtual int NbEdges() const;
@@ -711,22 +743,18 @@ public:
   typedef std::vector<SMDS_MeshNode *> SetOfNodes;
   typedef std::vector<SMDS_MeshCell *> SetOfCells;
 
-  void updateNodeMinMax();
-  void updateBoundingBox();
+  //void updateBoundingBox();
   double getMaxDim();
   int fromVtkToSmds(int vtkid);
 
-  void incrementNodesCapacity(int nbNodes);
-  void incrementCellsCapacity(int nbCells);
-  void adjustStructure();
-  void dumpGrid(string ficdump="dumpGrid");
+  void dumpGrid(std::string ficdump="dumpGrid");
   static int chunkSize;
 
   //! low level modification: add, change or remove node or element
   inline void setMyModified() { this->myModified = true; }
 
   void Modified();
-  unsigned long GetMTime() const;
+  vtkMTimeType GetMTime() const;
   bool isCompacted();
 
 protected:
@@ -754,14 +782,14 @@ protected:
   bool registerElement(int ID, SMDS_MeshElement * element);
 
   void addChildrenWithNodes(std::set<const SMDS_MeshElement*>& setOfChildren,
-                            const SMDS_MeshElement * element,
+                            const SMDS_MeshElement *           element,
                             std::set<const SMDS_MeshElement*>& nodes);
 
   inline void adjustmyCellsCapacity(int ID)
   {
     assert(ID >= 0);
     myElementIDFactory->adjustMaxId(ID);
-    if (ID >= myCells.size())
+    if (ID >= (int)myCells.size())
       myCells.resize(ID+SMDS_Mesh::chunkSize,0);
   }
 
@@ -781,10 +809,10 @@ protected:
   int myMeshId;
 
   //! actual nodes coordinates, cells definition and reverse connectivity are stored in a vtkUnstructuredGrid
-  SMDS_UnstructuredGrid*      myGrid;
+  SMDS_UnstructuredGrid*        myGrid;
 
   //! Small objects like SMDS_MeshNode are allocated by chunks to limit memory costs of new
-  ObjectPool<SMDS_MeshNode>* myNodePool;
+  ObjectPool<SMDS_MeshNode>*    myNodePool;
 
   //! Small objects like SMDS_VtkVolume are allocated by chunks to limit memory costs of new
   ObjectPool<SMDS_VtkVolume>*   myVolumePool;
@@ -792,37 +820,31 @@ protected:
   ObjectPool<SMDS_VtkEdge>*     myEdgePool;
   ObjectPool<SMDS_BallElement>* myBallPool;
 
-  //! SMDS_MeshNodes refer to vtk nodes (vtk id = index in myNodes),store reference to this mesh, and sub-shape
-  SetOfNodes             myNodes;
-
-  //! SMDS_MeshCells refer to vtk cells (vtk id != index in myCells),store reference to this mesh, and sub-shape
-  SetOfCells             myCells;
+  //! SMDS_MeshNodes refer to vtk nodes (vtk id != index in myNodes),store reference to this mesh, and sub-shape
+  SetOfNodes                    myNodes;
+  SetOfCells                    myCells;
 
-  //! for cells only: index = ID for SMDS users, value = ID in vtkUnstructuredGrid
-  //std::vector<int>       myCellIdSmdsToVtk;
+  //! a buffer to speed up elements addition by excluding some memory allocation
+  std::vector<vtkIdType>        myNodeIds;
 
   //! for cells only: index = ID in vtkUnstructuredGrid, value = ID for SMDS users
-  std::vector<int>       myCellIdVtkToSmds;
+  std::vector<int>              myCellIdVtkToSmds;
 
-  SMDS_Mesh *            myParent;
-  std::list<SMDS_Mesh *> myChildren;
-  SMDS_MeshNodeIDFactory *myNodeIDFactory;
-  SMDS_MeshElementIDFactory *myElementIDFactory;
-  SMDS_MeshInfo          myInfo;
+  SMDS_Mesh *                   myParent;
+  std::list<SMDS_Mesh *>        myChildren;
+  SMDS_MeshNodeIDFactory *      myNodeIDFactory;
+  SMDS_MeshElementIDFactory *   myElementIDFactory;
+  SMDS_MeshInfo                 myInfo;
 
+  //! any add, remove or change of node or cell
+  bool myModified;
   //! use a counter to keep track of modifications
   unsigned long myModifTime, myCompactTime;
 
-  int myNodeMin;
-  int myNodeMax;
-
   bool myHasConstructionEdges;
   bool myHasConstructionFaces;
   bool myHasInverseElements;
 
-  //! any add, remove or change of node or cell
-  bool myModified;
-
   double xmin;
   double xmax;
   double ymin;