Version: 6.3.1

src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes
00024 //  File   : StdMeshers_ProjectionSource1D_i.cxx
00025 //  Author : Edward AGAPOV
00026 //  Module : SMESH
00027 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx,v 1.3.20.1.8.1 2011-06-02 05:57:35 vsr Exp $
00028 //
00029 #include "StdMeshers_ProjectionSource1D_i.hxx"
00030 
00031 #include "SMESH_Gen_i.hxx"
00032 #include "SMESH_Gen.hxx"
00033 #include "SMESH_PythonDump.hxx"
00034 
00035 #include "Utils_CorbaException.hxx"
00036 #include "utilities.h"
00037 
00038 #include "StdMeshers_ObjRefUlils.hxx"
00039 
00040 using namespace std;
00041 
00042 //=============================================================================
00048 //=============================================================================
00049 
00050 StdMeshers_ProjectionSource1D_i::StdMeshers_ProjectionSource1D_i
00051 ( PortableServer::POA_ptr thePOA,
00052   int                     theStudyId,
00053   ::SMESH_Gen*            theGenImpl ) : SALOME::GenericObj_i( thePOA ), 
00054                                          SMESH_Hypothesis_i( thePOA )
00055 {
00056   MESSAGE( "StdMeshers_ProjectionSource1D_i::StdMeshers_ProjectionSource1D_i" );
00057   myBaseImpl = new ::StdMeshers_ProjectionSource1D( theGenImpl->GetANewId(),
00058                                                     theStudyId,
00059                                                     theGenImpl );
00060 }
00061 
00062 //=============================================================================
00068 //=============================================================================
00069 
00070 StdMeshers_ProjectionSource1D_i::~StdMeshers_ProjectionSource1D_i()
00071 {
00072   MESSAGE( "StdMeshers_ProjectionSource1D_i::~StdMeshers_ProjectionSource1D_i" );
00073 }
00074 
00075 //=============================================================================
00079 //=============================================================================
00080 
00081 void StdMeshers_ProjectionSource1D_i::SetSourceEdge(GEOM::GEOM_Object_ptr edge)
00082   throw ( SALOME::SALOME_Exception )
00083 {
00084   ASSERT( myBaseImpl );
00085   try {
00086     this->GetImpl()->SetSourceEdge( StdMeshers_ObjRefUlils::GeomObjectToShape( edge ));
00087   }
00088   catch ( SALOME_Exception& S_ex ) {
00089     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
00090   }
00091   // Update Python script
00092   SMESH::TPythonDump() << _this() << ".SetSourceEdge( " << edge << " )";
00093 }
00094 
00095 //=============================================================================
00100 //=============================================================================
00101 
00102 void StdMeshers_ProjectionSource1D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr sourceVertex,
00103                                                            GEOM::GEOM_Object_ptr targetVertex)
00104   throw ( SALOME::SALOME_Exception )
00105 {
00106   ASSERT( myBaseImpl );
00107   try {
00108     TopoDS_Shape v1 = StdMeshers_ObjRefUlils::GeomObjectToShape( sourceVertex );
00109     TopoDS_Shape v2 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex );
00110     this->GetImpl()->SetVertexAssociation( v1, v2 );
00111   }
00112   catch ( SALOME_Exception& S_ex ) {
00113     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
00114   }
00115   // Update Python script
00116   SMESH::TPythonDump() << _this() << ".SetVertexAssociation( "
00117                        << sourceVertex << ", " << targetVertex << " )";
00118 }
00119 
00120 //=============================================================================
00124 //=============================================================================
00125 
00126 void StdMeshers_ProjectionSource1D_i::SetSourceMesh(SMESH::SMESH_Mesh_ptr theMesh)
00127   throw ( SALOME::SALOME_Exception )
00128 {
00129   ASSERT( myBaseImpl );
00130 
00131   ::SMESH_Mesh* mesh = 0;
00132 
00133   if ( !CORBA::is_nil( theMesh ))
00134   {
00135     SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( theMesh );
00136     if ( !mesh_i )
00137       THROW_SALOME_CORBA_EXCEPTION( "bad mesh", SALOME::BAD_PARAM );
00138     mesh = &mesh_i->GetImpl();
00139   }
00140 
00141   try {
00142     this->GetImpl()->SetSourceMesh ( mesh );
00143   }
00144   catch ( SALOME_Exception& S_ex ) {
00145     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
00146   }
00147 
00148   myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( theMesh );
00149 
00150   // Update Python script
00151   SMESH::TPythonDump() << _this() << ".SetSourceMesh( " << theMesh << " )";
00152 }
00153 
00154 //=============================================================================
00158 //=============================================================================
00159 
00160 SMESH::SMESH_Mesh_ptr StdMeshers_ProjectionSource1D_i::GetSourceMesh()
00161 {
00162   SMESH::SMESH_Mesh_var mesh = myCorbaMesh;
00163   return mesh._retn();
00164 }
00165 
00166 //=============================================================================
00170 //=============================================================================
00171 
00172 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetSourceEdge()
00173 {
00174   ASSERT( myBaseImpl );
00175   return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceEdge() );
00176 }
00177 
00178 //=============================================================================
00183 //=============================================================================
00184 
00185 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetSourceVertex()
00186 {
00187   ASSERT( myBaseImpl );
00188   return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceVertex() );
00189 }
00190 
00191 //=============================================================================
00196 //=============================================================================
00197 
00198 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetTargetVertex()
00199 {
00200   ASSERT( myBaseImpl );
00201   return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetTargetVertex() );
00202 }
00203 
00204 //=============================================================================
00210 //=============================================================================
00211 
00212 ::StdMeshers_ProjectionSource1D* StdMeshers_ProjectionSource1D_i::GetImpl()
00213 {
00214   return ( ::StdMeshers_ProjectionSource1D* )myBaseImpl;
00215 }
00216 
00217 //================================================================================
00225 //================================================================================  
00226 CORBA::Boolean StdMeshers_ProjectionSource1D_i::IsDimSupported( SMESH::Dimension type )
00227 {
00228   return type == SMESH::DIM_1D;
00229 }
00230 
00231 //================================================================================
00236 //================================================================================
00237 
00238 char* StdMeshers_ProjectionSource1D_i::SaveTo()
00239 {
00240   ASSERT( myBaseImpl );
00241   std::ostringstream os;
00242 
00243   TopoDS_Shape s1, s2, s3;
00244   GetImpl()->GetStoreParams( s1, s2, s3 );
00245 
00246   StdMeshers_ObjRefUlils::SaveToStream( s1, os );
00247   StdMeshers_ObjRefUlils::SaveToStream( s2, os );
00248   StdMeshers_ObjRefUlils::SaveToStream( s3, os );
00249   StdMeshers_ObjRefUlils::SaveToStream( GetSourceMesh(), os );
00250 
00251   myBaseImpl->SaveTo( os );
00252 
00253   return CORBA::string_dup( os.str().c_str() );
00254 }
00255 
00256 //================================================================================
00261 //================================================================================
00262 
00263 void StdMeshers_ProjectionSource1D_i::LoadFrom( const char* theStream )
00264 {
00265   ASSERT( myBaseImpl );
00266   std::istringstream is( theStream );
00267 
00268   TopoDS_Shape s1 = StdMeshers_ObjRefUlils::LoadFromStream( is );
00269   TopoDS_Shape s2 = StdMeshers_ObjRefUlils::LoadFromStream( is );
00270   TopoDS_Shape s3 = StdMeshers_ObjRefUlils::LoadFromStream( is );
00271   SMESH::SMESH_Mesh_var mesh = 
00272     StdMeshers_ObjRefUlils::LoadObjectFromStream< SMESH::SMESH_Mesh >( is );
00273 
00274   ::SMESH_Mesh* meshImpl = 0;
00275 
00276   if ( !CORBA::is_nil( mesh ))
00277   {
00278     SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( mesh );
00279     if ( mesh_i )
00280       meshImpl = &mesh_i->GetImpl();
00281   }
00282 
00283   myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( mesh );
00284   GetImpl()->RestoreParams( s1, s2, s3, meshImpl );
00285 
00286   myBaseImpl->LoadFrom( is );
00287 }
00288 
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS