Salome HOME
suppression de l'argument geometriesSaines
[modules/smesh.git] / src / StdMeshers_I / StdMeshers_ProjectionSource1D_i.cxx
index 62d7d7af7503fee9276ee86019a8011033486c14..78c9c56b98bb1c8cbf64a19b823b7895907ba9af 100644 (file)
@@ -1,29 +1,29 @@
-//  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021  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, 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
-//  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_I : idl implementation based on 'SMESH' unit's classes
 //  File   : StdMeshers_ProjectionSource1D_i.cxx
 //  Author : Edward AGAPOV
 //  Module : SMESH
-//  $Header$
 //
 #include "StdMeshers_ProjectionSource1D_i.hxx"
 
@@ -48,13 +48,10 @@ using namespace std;
 
 StdMeshers_ProjectionSource1D_i::StdMeshers_ProjectionSource1D_i
 ( PortableServer::POA_ptr thePOA,
-  int                     theStudyId,
   ::SMESH_Gen*            theGenImpl ) : SALOME::GenericObj_i( thePOA ), 
                                          SMESH_Hypothesis_i( thePOA )
 {
-  MESSAGE( "StdMeshers_ProjectionSource1D_i::StdMeshers_ProjectionSource1D_i" );
   myBaseImpl = new ::StdMeshers_ProjectionSource1D( theGenImpl->GetANewId(),
-                                                    theStudyId,
                                                     theGenImpl );
 }
 
@@ -68,7 +65,6 @@ StdMeshers_ProjectionSource1D_i::StdMeshers_ProjectionSource1D_i
 
 StdMeshers_ProjectionSource1D_i::~StdMeshers_ProjectionSource1D_i()
 {
-  MESSAGE( "StdMeshers_ProjectionSource1D_i::~StdMeshers_ProjectionSource1D_i" );
 }
 
 //=============================================================================
@@ -78,11 +74,12 @@ StdMeshers_ProjectionSource1D_i::~StdMeshers_ProjectionSource1D_i()
 //=============================================================================
 
 void StdMeshers_ProjectionSource1D_i::SetSourceEdge(GEOM::GEOM_Object_ptr edge)
-  throw ( SALOME::SALOME_Exception )
 {
   ASSERT( myBaseImpl );
   try {
     this->GetImpl()->SetSourceEdge( StdMeshers_ObjRefUlils::GeomObjectToShape( edge ));
+    CORBA::String_var entry = edge->GetStudyEntry();
+    myShapeEntries[ SRC_EDGE ] = entry.in();
   }
   catch ( SALOME_Exception& S_ex ) {
     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
@@ -100,13 +97,15 @@ void StdMeshers_ProjectionSource1D_i::SetSourceEdge(GEOM::GEOM_Object_ptr edge)
 
 void StdMeshers_ProjectionSource1D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr sourceVertex,
                                                            GEOM::GEOM_Object_ptr targetVertex)
-  throw ( SALOME::SALOME_Exception )
 {
   ASSERT( myBaseImpl );
   try {
     TopoDS_Shape v1 = StdMeshers_ObjRefUlils::GeomObjectToShape( sourceVertex );
     TopoDS_Shape v2 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex );
     this->GetImpl()->SetVertexAssociation( v1, v2 );
+
+    myShapeEntries[ SRC_VERTEX ] = StdMeshers_ObjRefUlils::GeomObjectToEntry( sourceVertex );
+    myShapeEntries[ TGT_VERTEX ] = StdMeshers_ObjRefUlils::GeomObjectToEntry( targetVertex );
   }
   catch ( SALOME_Exception& S_ex ) {
     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
@@ -123,7 +122,6 @@ void StdMeshers_ProjectionSource1D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr
 //=============================================================================
 
 void StdMeshers_ProjectionSource1D_i::SetSourceMesh(SMESH::SMESH_Mesh_ptr theMesh)
-  throw ( SALOME::SALOME_Exception )
 {
   ASSERT( myBaseImpl );
 
@@ -171,7 +169,9 @@ SMESH::SMESH_Mesh_ptr StdMeshers_ProjectionSource1D_i::GetSourceMesh()
 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetSourceEdge()
 {
   ASSERT( myBaseImpl );
-  return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceEdge() );
+  return StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject
+    ( myShapeEntries[ SRC_EDGE ],
+      this->GetImpl()->GetSourceEdge() );
 }
 
 //=============================================================================
@@ -184,7 +184,9 @@ GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetSourceEdge()
 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetSourceVertex()
 {
   ASSERT( myBaseImpl );
-  return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceVertex() );
+  return StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject
+    ( myShapeEntries[ SRC_VERTEX ],
+      this->GetImpl()->GetSourceVertex() );
 }
 
 //=============================================================================
@@ -197,7 +199,9 @@ GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetSourceVertex()
 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetTargetVertex()
 {
   ASSERT( myBaseImpl );
-  return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetTargetVertex() );
+  return StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject
+    ( myShapeEntries[ TGT_VERTEX ],
+      this->GetImpl()->GetTargetVertex() );
 }
 
 //=============================================================================
@@ -239,12 +243,8 @@ char* StdMeshers_ProjectionSource1D_i::SaveTo()
   ASSERT( myBaseImpl );
   std::ostringstream os;
 
-  TopoDS_Shape s1, s2, s3;
-  GetImpl()->GetStoreParams( s1, s2, s3 );
-
-  StdMeshers_ObjRefUlils::SaveToStream( s1, os );
-  StdMeshers_ObjRefUlils::SaveToStream( s2, os );
-  StdMeshers_ObjRefUlils::SaveToStream( s3, os );
+  for ( int i = 0; i < NB_SHAPES; ++i )
+    StdMeshers_ObjRefUlils::SaveToStream( myShapeEntries[ i ], os );
   StdMeshers_ObjRefUlils::SaveToStream( GetSourceMesh(), os );
 
   myBaseImpl->SaveTo( os );
@@ -264,9 +264,9 @@ void StdMeshers_ProjectionSource1D_i::LoadFrom( const char* theStream )
   ASSERT( myBaseImpl );
   std::istringstream is( theStream );
 
-  TopoDS_Shape s1 = StdMeshers_ObjRefUlils::LoadFromStream( is );
-  TopoDS_Shape s2 = StdMeshers_ObjRefUlils::LoadFromStream( is );
-  TopoDS_Shape s3 = StdMeshers_ObjRefUlils::LoadFromStream( is );
+  TopoDS_Shape shapes[ NB_SHAPES ];
+  for ( int i = 0; i < NB_SHAPES; ++i )
+    shapes[ i ] = StdMeshers_ObjRefUlils::LoadFromStream( is );
   SMESH::SMESH_Mesh_var mesh = 
     StdMeshers_ObjRefUlils::LoadObjectFromStream< SMESH::SMESH_Mesh >( is );
 
@@ -280,8 +280,61 @@ void StdMeshers_ProjectionSource1D_i::LoadFrom( const char* theStream )
   }
 
   myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( mesh );
-  GetImpl()->RestoreParams( s1, s2, s3, meshImpl );
-
+  try {
+    GetImpl()->SetSourceMesh       ( meshImpl );
+    GetImpl()->SetSourceEdge       ( shapes[ SRC_EDGE ] );
+    GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX ],
+                                     shapes[ TGT_VERTEX ]);
+  }
+  catch (...) {
+  }
   myBaseImpl->LoadFrom( is );
+
+  std::istringstream str( theStream );
+  for ( int i = 0; i < NB_SHAPES; ++i )
+    str >> myShapeEntries[ i ];
+}
+
+//================================================================================
+/*!
+ * \brief Return geometry this hypothesis depends on. Return false if there is no geometry parameter
+ */
+//================================================================================
+
+bool
+StdMeshers_ProjectionSource1D_i::getObjectsDependOn( std::vector< std::string > & entryArray,
+                                                     std::vector< int >         & /*subIDArray*/ ) const
+{
+  for ( int i = 0; i < NB_SHAPES; ++i )
+    entryArray.push_back( myShapeEntries[ i ]);
+
+  return true;
 }
 
+//================================================================================
+/*!
+ * \brief Set new geometry instead of that returned by getObjectsDependOn()
+ */
+//================================================================================
+
+bool
+StdMeshers_ProjectionSource1D_i::setObjectsDependOn( std::vector< std::string > & entryArray,
+                                                     std::vector< int >         & /*subIDArray*/ )
+{
+  TopoDS_Shape shapes[ NB_SHAPES ];
+  for ( int i = 0; i < NB_SHAPES; ++i )
+  {
+    myShapeEntries[ i ] = entryArray[ i ];
+    shapes[ i ] = StdMeshers_ObjRefUlils::EntryToShape( entryArray[ i ]);
+  }
+
+  try {
+    GetImpl()->SetSourceEdge       ( shapes[ SRC_EDGE ] );
+    GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX ],
+                                     shapes[ TGT_VERTEX ]);
+  }
+  catch (...) {
+    return false;
+  }
+  return true;
+}