Salome HOME
PR: synchro V7_main tag mergefrom_V6_main_28Feb13
[modules/smesh.git] / src / StdMeshers / StdMeshers_Projection_3D.cxx
index 689c920064da60417f5ebc88763342081e344308..cf42d5d4183c64cf834a554bff3a45d6a97fba52 100644 (file)
@@ -1,23 +1,23 @@
-//  Copyright (C) 2007-2010  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
@@ -57,7 +57,7 @@
 // cout << msg << " ("<< p.X() << "; " <<p.Y() << "; " <<p.Z() << ") " <<endl;\
 // }
 
-typedef StdMeshers_ProjectionUtils TAssocTool;
+namespace TAssocTool = StdMeshers_ProjectionUtils;
 
 
 //=======================================================================
@@ -219,13 +219,13 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS
                  SMESH_Comment("Target shape must have 1 shell but not ") << nbShell);
 
   // Check that shapes are blocks
-  if ( TAssocTool::Count( tgtShell, TopAbs_FACE , 1 ) != 6 ||
-       TAssocTool::Count( tgtShell, TopAbs_EDGE , 1 ) != 12 ||
-       TAssocTool::Count( tgtShell, TopAbs_WIRE , 1 ) != 6 )
+  if ( SMESH_MesherHelper::Count( tgtShell, TopAbs_FACE , 1 ) != 6 ||
+       SMESH_MesherHelper::Count( tgtShell, TopAbs_EDGE , 1 ) != 12 ||
+       SMESH_MesherHelper::Count( tgtShell, TopAbs_WIRE , 1 ) != 6 )
     return error(COMPERR_BAD_SHAPE, "Target shape is not a block");
-  if ( TAssocTool::Count( srcShell, TopAbs_FACE , 1 ) != 6 ||
-       TAssocTool::Count( srcShell, TopAbs_EDGE , 1 ) != 12 ||
-       TAssocTool::Count( srcShell, TopAbs_WIRE , 1 ) != 6 )
+  if ( SMESH_MesherHelper::Count( srcShell, TopAbs_FACE , 1 ) != 6 ||
+       SMESH_MesherHelper::Count( srcShell, TopAbs_EDGE , 1 ) != 12 ||
+       SMESH_MesherHelper::Count( srcShell, TopAbs_WIRE , 1 ) != 6 )
     return error(COMPERR_BAD_SHAPE, "Source shape is not a block");
 
   // Assure that mesh on a source shape is computed
@@ -233,13 +233,14 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS
   SMESH_subMesh* srcSubMesh = srcMesh->GetSubMesh( _sourceHypo->GetSource3DShape() );
   //SMESH_subMesh* tgtSubMesh = tgtMesh->GetSubMesh( aShape );
 
-  if ( tgtMesh == srcMesh && !aShape.IsSame( _sourceHypo->GetSource3DShape() )) {
+  string srcMeshError;
+  if ( tgtMesh == srcMesh  && !aShape.IsSame( _sourceHypo->GetSource3DShape() )) {
     if ( !TAssocTool::MakeComputed( srcSubMesh ))
-      return error(COMPERR_BAD_INPUT_MESH,"Source mesh not computed");
+      srcMeshError = TAssocTool::SourceNotComputedError( srcSubMesh, this );
   }
   else {
     if ( !srcSubMesh->IsMeshComputed() )
-      return error(COMPERR_BAD_INPUT_MESH,"Source mesh not computed");
+      srcMeshError = TAssocTool::SourceNotComputedError();
   }
 
   // Find 2 pairs of corresponding vertices
@@ -264,12 +265,12 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS
     TopExp::Vertices( TopoDS::Edge( exp.Current() ), tgtV000, tgtV100 );
 
     if ( !shape2ShapeMap.IsBound( tgtV000 ) || !shape2ShapeMap.IsBound( tgtV100 ))
-      return error("Association of subshapes failed" );
+      return error("Association of sub-shapes failed" );
     srcV000 = TopoDS::Vertex( shape2ShapeMap( tgtV000 ));
     srcV100 = TopoDS::Vertex( shape2ShapeMap( tgtV100 ));
     if ( !SMESH_MesherHelper::IsSubShape( srcV000, srcShell ) ||
          !SMESH_MesherHelper::IsSubShape( srcV100, srcShell ))
-      return error("Incorrect association of subshapes" );
+      return error("Incorrect association of sub-shapes" );
   }
 
   // Load 2 SMESH_Block's with src and tgt shells
@@ -277,31 +278,31 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS
   SMESH_Block srcBlock, tgtBlock;
   TopTools_IndexedMapOfOrientedShape scrShapes, tgtShapes;
   if ( !tgtBlock.LoadBlockShapes( tgtShell, tgtV000, tgtV100, tgtShapes ))
-    return error(COMPERR_BAD_SHAPE, "Can't detect block subshapes. Not a block?");
+    return error(COMPERR_BAD_SHAPE, "Can't detect block sub-shapes. Not a block?");
 
   if ( !srcBlock.LoadBlockShapes( srcShell, srcV000, srcV100, scrShapes ))
-    return error(COMPERR_BAD_SHAPE, "Can't detect block subshapes. Not a block?");
+    return error(COMPERR_BAD_SHAPE, "Can't detect block sub-shapes. Not a block?");
 
   // Find matching nodes of src and tgt shells
 
   TNodeNodeMap src2tgtNodeMap;
   for ( int fId = SMESH_Block::ID_FirstF; fId < SMESH_Block::ID_Shell; ++fId )
   {
-    // Corresponding subshapes
+    // Corresponding sub-shapes
     TopoDS_Face srcFace = TopoDS::Face( scrShapes( fId ));
     TopoDS_Face tgtFace = TopoDS::Face( tgtShapes( fId ));
-    if ( _sourceHypo->HasVertexAssociation() ) { // associate face subshapes
+    if ( _sourceHypo->HasVertexAssociation() ) { // associate face sub-shapes
       shape2ShapeMap.Clear();
       vector< int > edgeIdVec;
       SMESH_Block::GetFaceEdgesIDs( fId, edgeIdVec );
       for ( int i = 0; i < edgeIdVec.size(); ++i ) {
         int eID = edgeIdVec[ i ];
-        shape2ShapeMap.Bind( tgtShapes( eID ), scrShapes( eID ));
+        shape2ShapeMap.Bind( scrShapes( eID ), tgtShapes( eID ));
         if ( i < 2 ) {
           vector< int > vertexIdVec;
           SMESH_Block::GetEdgeVertexIDs( eID, vertexIdVec );
-          shape2ShapeMap.Bind( tgtShapes( vertexIdVec[0] ), scrShapes( vertexIdVec[0] ));
-          shape2ShapeMap.Bind( tgtShapes( vertexIdVec[1] ), scrShapes( vertexIdVec[1] ));
+          shape2ShapeMap.Bind( scrShapes( vertexIdVec[0]), tgtShapes( vertexIdVec[0]) );
+          shape2ShapeMap.Bind( scrShapes( vertexIdVec[1]), tgtShapes( vertexIdVec[1]) );
         }
       }
     }
@@ -459,13 +460,13 @@ bool StdMeshers_Projection_3D::Evaluate(SMESH_Mesh& aMesh,
                  SMESH_Comment("Target shape must have 1 shell but not ") << nbShell);
 
   // Check that shapes are blocks
-  if ( TAssocTool::Count( tgtShell, TopAbs_FACE , 1 ) != 6 ||
-       TAssocTool::Count( tgtShell, TopAbs_EDGE , 1 ) != 12 ||
-       TAssocTool::Count( tgtShell, TopAbs_WIRE , 1 ) != 6 )
+  if ( SMESH_MesherHelper::Count( tgtShell, TopAbs_FACE , 1 ) != 6 ||
+       SMESH_MesherHelper::Count( tgtShell, TopAbs_EDGE , 1 ) != 12 ||
+       SMESH_MesherHelper::Count( tgtShell, TopAbs_WIRE , 1 ) != 6 )
     return error(COMPERR_BAD_SHAPE, "Target shape is not a block");
-  if ( TAssocTool::Count( srcShell, TopAbs_FACE , 1 ) != 6 ||
-       TAssocTool::Count( srcShell, TopAbs_EDGE , 1 ) != 12 ||
-       TAssocTool::Count( srcShell, TopAbs_WIRE , 1 ) != 6 )
+  if ( SMESH_MesherHelper::Count( srcShell, TopAbs_FACE , 1 ) != 6 ||
+       SMESH_MesherHelper::Count( srcShell, TopAbs_EDGE , 1 ) != 12 ||
+       SMESH_MesherHelper::Count( srcShell, TopAbs_WIRE , 1 ) != 6 )
     return error(COMPERR_BAD_SHAPE, "Source shape is not a block");
 
   // Assure that mesh on a source shape is computed