Salome HOME
Merge from V6_5_BR 05/06/2012
[modules/smesh.git] / src / StdMeshers / StdMeshers_RadialPrism_3D.cxx
index 182798c941b9474198019ae80f2e7851cc671597..6ae4ac7873760e900178b83489e59f021251ef4c 100644 (file)
@@ -1,24 +1,25 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012  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-2007  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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 //  SMESH SMESH : implementaion of SMESH idl descriptions
 // File      : StdMeshers_RadialPrism_3D.cxx
 // Module    : SMESH
@@ -71,7 +72,7 @@ StdMeshers_RadialPrism_3D::StdMeshers_RadialPrism_3D(int hypId, int studyId, SME
   :SMESH_3D_Algo(hypId, studyId, gen)
 {
   _name = "RadialPrism_3D";
-  _shapeType = (1 << TopAbs_SOLID);    // 1 bit per shape type
+  _shapeType = (1 << TopAbs_SOLID);     // 1 bit per shape type
 
   _compatibleHypothesis.push_back("LayerDistribution");
   _compatibleHypothesis.push_back("NumberOfLayers");
@@ -171,12 +172,12 @@ bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& a
     return error(COMPERR_BAD_SHAPE, SMESH_Comment("Must be 2 shells but not ")<<nbShells);
 
   // ----------------------------------
-  // Associate subshapes of the shells
+  // Associate sub-shapes of the shells
   // ----------------------------------
 
   TAssocTool::TShapeShapeMap shape2ShapeMap;
-  if ( !TAssocTool::FindSubShapeAssociation( outerShell, &aMesh,
-                                             innerShell, &aMesh,
+  if ( !TAssocTool::FindSubShapeAssociation( innerShell, &aMesh,
+                                             outerShell, &aMesh,
                                              shape2ShapeMap) )
     return error(COMPERR_BAD_SHAPE,"Topology of inner and outer shells seems different" );
 
@@ -189,14 +190,14 @@ bool StdMeshers_RadialPrism_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& a
 
   for ( exp.Init( outerShell, TopAbs_FACE ); exp.More(); exp.Next() )
   {
-    // Corresponding subshapes
+    // Corresponding sub-shapes
     TopoDS_Face outFace = TopoDS::Face( exp.Current() );
     TopoDS_Face inFace;
-    if ( !shape2ShapeMap.IsBound( outFace )) {
+    if ( !shape2ShapeMap.IsBound( outFace, /*isOut=*/true )) {
       return error(SMESH_Comment("Corresponding inner face not found for face #" )
                    << meshDS->ShapeToIndex( outFace ));
     } else {
-      inFace = TopoDS::Face( shape2ShapeMap( outFace ));
+      inFace = TopoDS::Face( shape2ShapeMap( outFace, /*isOut=*/true ));
     }
 
     // Find matching nodes of in and out faces
@@ -396,8 +397,8 @@ bool StdMeshers_RadialPrism_3D::computeLayerPositions(const gp_Pnt& pIn,
 //=======================================================================
 
 bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
-                                        const TopoDS_Shape& aShape,
-                                        MapShapeNbElems& aResMap)
+                                         const TopoDS_Shape& aShape,
+                                         MapShapeNbElems& aResMap)
 {
   // get 2 shells
   TopoDS_Solid solid = TopoDS::Solid( aShape );
@@ -408,8 +409,8 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
     if ( !outerShell.IsSame( It.Value() ))
       innerShell = It.Value();
   if ( nbShells != 2 ) {
-    std::vector<int> aResVec(17);
-    for(int i=0; i<17; i++) aResVec[i] = 0;
+    std::vector<int> aResVec(SMDSEntity_Last);
+    for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
     SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
     aResMap.insert(std::make_pair(sm,aResVec));
     SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
@@ -417,13 +418,13 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
     return false;
   }
 
-  // Associate subshapes of the shells
+  // Associate sub-shapes of the shells
   TAssocTool::TShapeShapeMap shape2ShapeMap;
   if ( !TAssocTool::FindSubShapeAssociation( outerShell, &aMesh,
                                              innerShell, &aMesh,
                                              shape2ShapeMap) ) {
-    std::vector<int> aResVec(17);
-    for(int i=0; i<17; i++) aResVec[i] = 0;
+    std::vector<int> aResVec(SMDSEntity_Last);
+    for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
     SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
     aResMap.insert(std::make_pair(sm,aResVec));
     SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
@@ -439,9 +440,9 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
     SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
     MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
     std::vector<int> aVec = (*anIt).second;
-    nb0d_Out += aVec[0];
-    nb2d_3_Out += Max(aVec[3],aVec[4]);
-    nb2d_4_Out += Max(aVec[5],aVec[6]);
+    nb0d_Out += aVec[SMDSEntity_Node];
+    nb2d_3_Out += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
+    nb2d_4_Out += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
   }
   int nb1d_Out = 0;
   TopTools_MapOfShape tmpMap;
@@ -452,8 +453,8 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
     SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
     MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
     std::vector<int> aVec = (*anIt).second;
-    nb0d_Out += aVec[0];
-    nb1d_Out += Max(aVec[1],aVec[2]);
+    nb0d_Out += aVec[SMDSEntity_Node];
+    nb1d_Out += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
   }
   tmpMap.Clear();
   for (TopExp_Explorer exp(outerShell, TopAbs_VERTEX); exp.More(); exp.Next()) {
@@ -471,9 +472,9 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
     SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
     MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
     std::vector<int> aVec = (*anIt).second;
-    nb0d_In += aVec[0];
-    nb2d_3_In += Max(aVec[3],aVec[4]);
-    nb2d_4_In += Max(aVec[5],aVec[6]);
+    nb0d_In += aVec[SMDSEntity_Node];
+    nb2d_3_In += Max(aVec[SMDSEntity_Triangle],aVec[SMDSEntity_Quad_Triangle]);
+    nb2d_4_In += Max(aVec[SMDSEntity_Quadrangle],aVec[SMDSEntity_Quad_Quadrangle]);
   }
   int nb1d_In = 0;
   tmpMap.Clear();
@@ -486,10 +487,10 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
     SMESH_subMesh *aSubMesh = aMesh.GetSubMesh(exp.Current());
     MapShapeNbElemsItr anIt = aResMap.find(aSubMesh);
     std::vector<int> aVec = (*anIt).second;
-    nb0d_In += aVec[0];
-    nb1d_In += Max(aVec[1],aVec[2]);
+    nb0d_In += aVec[SMDSEntity_Node];
+    nb1d_In += Max(aVec[SMDSEntity_Edge],aVec[SMDSEntity_Quad_Edge]);
     if(IsFirst) {
-      IsQuadratic = (aVec[2] > aVec[1]);
+      IsQuadratic = (aVec[SMDSEntity_Quad_Edge] > aVec[SMDSEntity_Edge]);
       IsFirst = false;
     }
   }
@@ -504,8 +505,8 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
   bool IsOK = (nb0d_Out==nb0d_In) && (nb1d_Out==nb1d_In) && 
               (nb2d_3_Out==nb2d_3_In) && (nb2d_4_Out==nb2d_4_In);
   if(!IsOK) {
-    std::vector<int> aResVec(17);
-    for(int i=0; i<17; i++) aResVec[i] = 0;
+    std::vector<int> aResVec(SMDSEntity_Last);
+    for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
     SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
     aResMap.insert(std::make_pair(sm,aResVec));
     SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
@@ -519,8 +520,8 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
   }
   if ( myDistributionHypo ) {
     if ( !myDistributionHypo->GetLayerDistribution() ) {
-      std::vector<int> aResVec(17);
-      for(int i=0; i<17; i++) aResVec[i] = 0;
+      std::vector<int> aResVec(SMDSEntity_Last);
+      for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
       SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
       aResMap.insert(std::make_pair(sm,aResVec));
       SMESH_ComputeErrorPtr& smError = sm->GetComputeError();
@@ -538,18 +539,18 @@ bool StdMeshers_RadialPrism_3D::Evaluate(SMESH_Mesh& aMesh,
     nbLayers = myLayerPositions.size() + 1;
   }
 
-  std::vector<int> aResVec(17);
-  for(int i=0; i<17; i++) aResVec[i] = 0;
+  std::vector<int> aResVec(SMDSEntity_Last);
+  for(int i=SMDSEntity_Node; i<SMDSEntity_Last; i++) aResVec[i] = 0;
   if(IsQuadratic) {
-    aResVec[13] = nb2d_3_Out * nbLayers;
-    aResVec[15] = nb2d_4_Out * nbLayers;
+    aResVec[SMDSEntity_Quad_Penta] = nb2d_3_Out * nbLayers;
+    aResVec[SMDSEntity_Quad_Hexa] = nb2d_4_Out * nbLayers;
     int nb1d = ( nb2d_3_Out*3 + nb2d_4_Out*4 ) / 2;
-    aResVec[0] = nb0d_Out * ( 2*nbLayers - 1 ) - nb1d * nbLayers;
+    aResVec[SMDSEntity_Node] = nb0d_Out * ( 2*nbLayers - 1 ) - nb1d * nbLayers;
   }
   else {
-    aResVec[0] = nb0d_Out * ( nbLayers - 1 );
-    aResVec[12] = nb2d_3_Out * nbLayers;
-    aResVec[14] = nb2d_4_Out * nbLayers;
+    aResVec[SMDSEntity_Node] = nb0d_Out * ( nbLayers - 1 );
+    aResVec[SMDSEntity_Penta] = nb2d_3_Out * nbLayers;
+    aResVec[SMDSEntity_Hexa] = nb2d_4_Out * nbLayers;
   }
   SMESH_subMesh * sm = aMesh.GetSubMesh(aShape);
   aResMap.insert(std::make_pair(sm,aResVec));