Salome HOME
Merge from V5_1_main 14/05/2010
[modules/smesh.git] / src / StdMeshers / StdMeshers_Prism_3D.hxx
index d6fab7b38dc0a096c9f94023d7ae39aedebe0577..d7278e813a5dc2ec590ba555f30e80d4b5f5e043 100644 (file)
@@ -1,29 +1,29 @@
-//  SMESH SMESH : implementaion of SMESH idl descriptions
+//  Copyright (C) 2007-2010  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
 //
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  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. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//  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.
 //
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
 //
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SMESH SMESH : implementaion of SMESH idl descriptions
 //  File   : StdMeshers_Prism_3D.hxx
 //  Module : SMESH
-
+//
 #ifndef _SMESH_Prism_3D_HXX_
 #define _SMESH_Prism_3D_HXX_
 
@@ -47,6 +47,7 @@
 #include <BRepAdaptor_Surface.hxx>
 #include <TopTools_IndexedMapOfOrientedShape.hxx>
 #include <gp_XYZ.hxx>
+#include <gp_Trsf.hxx>
 
 
 class SMESHDS_SubMesh;
@@ -59,7 +60,7 @@ typedef std::vector<const SMDS_MeshNode* > TNodeColumn;
 
 // map of bottom nodes to the column of nodes above them
 // (the column includes the bottom nodes)
-typedef std::map< TNode, TNodeColumn > TNode2ColumnMap;
+typedef std::map< TNode, TNodeColumn >  TNode2ColumnMap;
 typedef std::map< double, TNodeColumn > TParam2ColumnMap;
 typedef std::map< double, TNodeColumn >::const_iterator TParam2ColumnIt;
 
@@ -74,18 +75,18 @@ typedef TopTools_IndexedMapOfOrientedShape TBlockShapes;
 struct TNode
 {
   const SMDS_MeshNode* myNode;
-  gp_XYZ               myParams;
+  mutable gp_XYZ       myParams;
 
   gp_XYZ GetCoords() const { return gp_XYZ( myNode->X(), myNode->Y(), myNode->Z() ); }
   gp_XYZ GetParams() const { return myParams; }
-  gp_XYZ& ChangeParams() { return myParams; }
+  gp_XYZ& ChangeParams() const { return myParams; }
   bool HasParams() const { return myParams.X() >= 0.0; }
   SMDS_TypeOfPosition GetPositionType() const
   { return myNode ? myNode->GetPosition()->GetTypeOfPosition() : SMDS_TOP_UNSPEC; }
   bool IsNeighbor( const TNode& other ) const;
 
   TNode(const SMDS_MeshNode* node = 0): myNode(node), myParams(-1,-1,-1) {}
-  bool operator < (const TNode& other) const { return myNode < other.myNode; }
+  bool operator < (const TNode& other) const { return myNode->GetID() < other.myNode->GetID(); }
 };
 
 // ===============================================================
@@ -145,13 +146,20 @@ public:
     * \retval const TParam2ColumnMap& - map
    */
   const TParam2ColumnMap& GetParam2ColumnMap(const int baseEdgeID,
-                                             bool &    isReverse)
+                                             bool &    isReverse) const
   {
-    std::pair< TParam2ColumnMap*, bool > col_frw =
-      myShapeIndex2ColumnMap[ baseEdgeID ];
+    std::pair< TParam2ColumnMap*, bool > col_frw =
+      myShapeIndex2ColumnMap.find( baseEdgeID )->second;
     isReverse = !col_frw.second;
     return * col_frw.first;
   }
+
+  /*!
+   * \brief Return transformations to get coordinates of nodes of each internal layer
+   *        by nodes of the bottom. Layer is a set of nodes at a certain step
+   *        from bottom to top.
+   */
+  bool GetLayersTransformation(std::vector<gp_Trsf> & trsf) const;
   
   /*!
    * \brief Return pointer to mesh
@@ -242,9 +250,9 @@ private:
     BRepAdaptor_Surface             mySurface;
     TopoDS_Edge                     myBaseEdge;
     // first and last normalized params and orientaion for each component or it-self
-    vector< pair< double, double> > myParams;
+    std::vector< std::pair< double, double> > myParams;
     bool                            myIsForward;
-    vector< TSideFace* >            myComponents;
+    std::vector< TSideFace* >       myComponents;
     SMESH_MesherHelper *            myHelper;
   public:
     TSideFace( SMESH_MesherHelper* helper,
@@ -255,7 +263,7 @@ private:
                const double        first = 0.0,
                const double        last = 1.0);
     TSideFace( const std::vector< TSideFace* >&             components,
-               const std::vector< pair< double, double> > & params);
+               const std::vector< std::pair< double, double> > & params);
     TSideFace( const TSideFace& other );
     ~TSideFace();
     bool IsComplex() const
@@ -285,6 +293,8 @@ private:
     int InsertSubShapes( TBlockShapes& shapeMap ) const;
     // redefine Adaptor methods
     gp_Pnt Value(const Standard_Real U,const Standard_Real V) const;
+    // debug
+    void dumpNodes(int nbNodes) const;
   };
 
   // --------------------------------------------------------------------
@@ -300,6 +310,8 @@ private:
     gp_Pnt Value(const Standard_Real U) const;
     Standard_Real FirstParameter() const { return 0; }
     Standard_Real LastParameter() const { return 1; }
+    // debug
+    void dumpNodes(int nbNodes) const;
   };
 
   // --------------------------------------------------------------------
@@ -317,6 +329,8 @@ private:
     gp_Pnt Value(const Standard_Real U) const;
     Standard_Real FirstParameter() const { return 0; }
     Standard_Real LastParameter() const { return 1; }
+    // debug
+    void dumpNodes(int nbNodes) const;
   };
 
   // --------------------------------------------------------------------
@@ -338,20 +352,19 @@ private:
     Standard_Real FirstParameter() const { return 0; }
     Standard_Real LastParameter() const { return 1; }
   };
-  // --------------------------------------------------------------------
 
-  bool myNotQuadOnTop;
-  SMESH_MesherHelper* myHelper;
-  TBlockShapes myShapeIDMap;
+  bool                  myNotQuadOnTop;
+  SMESH_MesherHelper*   myHelper;
+  TBlockShapes          myShapeIDMap;
+  SMESH_ComputeErrorPtr myError;
 
   // container of 4 side faces
-  TSideFace*                 mySide; 
+  TSideFace*            mySide; 
   // node columns for each base edge
-  vector< TParam2ColumnMap > myParam2ColumnMaps;
+  std::vector< TParam2ColumnMap >                       myParam2ColumnMaps;
   // to find a column for a node by edge SMESHDS Index
-  map< int, pair< TParam2ColumnMap*, bool > > myShapeIndex2ColumnMap;
+  std::map< int, std::pair< TParam2ColumnMap*, bool > > myShapeIndex2ColumnMap;
 
-  SMESH_ComputeErrorPtr myError;
   /*!
    * \brief store error and comment and then return ( error == COMPERR_OK )
    */
@@ -359,7 +372,6 @@ private:
     myError = SMESH_ComputeError::New(error,comment);
     return myError->IsOK();
   }
-  //vector< SMESH_subMesh* >           mySubMeshesVec; // submesh by in-block id
 };
 
 // =============================================
@@ -380,6 +392,9 @@ public:
 
   virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
 
+  virtual bool Evaluate(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape,
+                        MapShapeNbElems& aResMap);
+
   /*!
    * \brief Enable removal of quadrangles from the bottom face and
    * triangles creation there by projection from the top
@@ -395,7 +410,7 @@ public:
     * \param nodeColumns - columns of nodes generated from nodes of a mesh face
     * \param helper - helper initialized by mesh and shape to add prisms to
    */
-  static void AddPrisms( vector<const TNodeColumn*> & nodeColumns,
+  static void AddPrisms( std::vector<const TNodeColumn*> & nodeColumns,
                          SMESH_MesherHelper*          helper);
 
 private:
@@ -430,12 +445,11 @@ private:
   StdMeshers_PrismAsBlock myBlock;
   SMESH_MesherHelper*     myHelper;
 
-  vector<gp_XYZ>            myShapeXYZ; // point on each sub-shape
+  std::vector<gp_XYZ>     myShapeXYZ; // point on each sub-shape of the block
 
   // map of bottom nodes to the column of nodes above them
   // (the column includes the bottom node)
-  typedef std::map< TNode, TNodeColumn > TNode2ColumnMap;
-  TNode2ColumnMap  myBotToColumnMap;
+  TNode2ColumnMap         myBotToColumnMap;
 };
 
 #endif