Salome HOME
fix vagrind error at incrementing an iterator pointing to a deleted
[modules/smesh.git] / src / StdMeshers / StdMeshers_Projection_3D.cxx
index d8939feadf14986318733aff833ab9e3297622be..76c29c82215f3cc96ac1a6784801c970ff30fbcc 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_Projection_3D.cxx
 // Module    : SMESH
@@ -141,12 +142,12 @@ bool StdMeshers_Projection_3D::CheckHypothesis(SMESH_Mesh&
       TopoDS_Shape edge = TAssocTool::GetEdgeByVertices
         ( srcMesh, _sourceHypo->GetSourceVertex(1), _sourceHypo->GetSourceVertex(2) );
       if ( edge.IsNull() ||
-           !TAssocTool::IsSubShape( edge, srcMesh ) ||
-           !TAssocTool::IsSubShape( edge, _sourceHypo->GetSource3DShape() ))
+           !SMESH_MesherHelper::IsSubShape( edge, srcMesh ) ||
+           !SMESH_MesherHelper::IsSubShape( edge, _sourceHypo->GetSource3DShape() ))
       {
         SCRUTE((edge.IsNull()));
-        SCRUTE((TAssocTool::IsSubShape( edge, srcMesh )));
-        SCRUTE((TAssocTool::IsSubShape( edge, _sourceHypo->GetSource3DShape() )));
+        SCRUTE((SMESH_MesherHelper::IsSubShape( edge, srcMesh )));
+        SCRUTE((SMESH_MesherHelper::IsSubShape( edge, _sourceHypo->GetSource3DShape() )));
         aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
       }
       else
@@ -155,21 +156,21 @@ bool StdMeshers_Projection_3D::CheckHypothesis(SMESH_Mesh&
         edge = TAssocTool::GetEdgeByVertices
           ( tgtMesh, _sourceHypo->GetTargetVertex(1), _sourceHypo->GetTargetVertex(2) );
         if ( edge.IsNull() ||
-             !TAssocTool::IsSubShape( edge, tgtMesh ) ||
-             !TAssocTool::IsSubShape( edge, aShape ))
+             !SMESH_MesherHelper::IsSubShape( edge, tgtMesh ) ||
+             !SMESH_MesherHelper::IsSubShape( edge, aShape ))
         {
           SCRUTE((edge.IsNull()));
-          SCRUTE((TAssocTool::IsSubShape( edge, tgtMesh )));
-          SCRUTE((TAssocTool::IsSubShape( edge, aShape )));
+          SCRUTE((SMESH_MesherHelper::IsSubShape( edge, tgtMesh )));
+          SCRUTE((SMESH_MesherHelper::IsSubShape( edge, aShape )));
           aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
         }
       }
     }
     // check a source shape
-    if ( !TAssocTool::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh ) ||
+    if ( !SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh ) ||
          ( srcMesh == tgtMesh && aShape == _sourceHypo->GetSource3DShape()))
     {
-      SCRUTE((TAssocTool::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh)));
+      SCRUTE((SMESH_MesherHelper::IsSubShape( _sourceHypo->GetSource3DShape(), srcMesh)));
       SCRUTE((srcMesh == tgtMesh));
       SCRUTE((aShape == _sourceHypo->GetSource3DShape()));
       aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER;
@@ -263,12 +264,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 ( !TAssocTool::IsSubShape( srcV000, srcShell ) ||
-         !TAssocTool::IsSubShape( srcV100, srcShell ))
-      return error("Incorrect association of subshapes" );
+    if ( !SMESH_MesherHelper::IsSubShape( srcV000, srcShell ) ||
+         !SMESH_MesherHelper::IsSubShape( srcV100, srcShell ))
+      return error("Incorrect association of sub-shapes" );
   }
 
   // Load 2 SMESH_Block's with src and tgt shells
@@ -276,20 +277,20 @@ 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 );
@@ -406,11 +407,13 @@ bool StdMeshers_Projection_3D::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aS
                                  nodes[6],
                                  nodes[7], id, force3d); break;
     default: // polyhedron
-      const SMDS_PolyhedralVolumeOfNodes * poly =
-        dynamic_cast<const SMDS_PolyhedralVolumeOfNodes*>( srcVol );
+      const SMDS_VtkVolume * poly =
+        dynamic_cast<const SMDS_VtkVolume*>( srcVol );
       if ( !poly )
         RETURN_BAD_RESULT("Unexpected volume type");
-      tgtVol = tgtMeshDS->AddPolyhedralVolume( nodes, poly->GetQuanities() );
+      if ( !poly->IsPoly())
+        RETURN_BAD_RESULT("Unexpected volume type");
+      tgtVol = tgtMeshDS->AddPolyhedralVolume( nodes, poly->GetQuantities() );
     }
     if ( tgtVol ) {
       tgtMeshDS->SetMeshElementOnShape( tgtVol, helper.GetSubShapeID() );