Version: 6.3.1

src/StdMeshers_I/StdMeshers_ProjectionSource2D_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_ProjectionSource2D_i.cxx
00025 //  Author : Edward AGAPOV
00026 //  Module : SMESH
00027 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx,v 1.3.20.1.8.1 2011-06-02 05:57:35 vsr Exp $
00028 //
00029 #include "StdMeshers_ProjectionSource2D_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_ProjectionSource2D_i::StdMeshers_ProjectionSource2D_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_ProjectionSource2D_i::StdMeshers_ProjectionSource2D_i" );
00057   myBaseImpl = new ::StdMeshers_ProjectionSource2D( theGenImpl->GetANewId(),
00058                                                     theStudyId,
00059                                                     theGenImpl );
00060 }
00061 
00062 //=============================================================================
00068 //=============================================================================
00069 
00070 StdMeshers_ProjectionSource2D_i::~StdMeshers_ProjectionSource2D_i()
00071 {
00072   MESSAGE( "StdMeshers_ProjectionSource2D_i::~StdMeshers_ProjectionSource2D_i" );
00073 }
00074 
00075 //=============================================================================
00079 //=============================================================================
00080 
00081 void StdMeshers_ProjectionSource2D_i::SetSourceFace(GEOM::GEOM_Object_ptr face)
00082   throw ( SALOME::SALOME_Exception )
00083 {
00084   ASSERT( myBaseImpl );
00085   try {
00086     this->GetImpl()->SetSourceFace( StdMeshers_ObjRefUlils::GeomObjectToShape( face ));
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() << ".SetSourceFace( " << face << " )";
00093 }
00094 
00095 //=============================================================================
00099 //=============================================================================
00100 
00101 void StdMeshers_ProjectionSource2D_i::SetSourceMesh(SMESH::SMESH_Mesh_ptr theMesh)
00102   throw ( SALOME::SALOME_Exception )
00103 {
00104   ASSERT( myBaseImpl );
00105 
00106   ::SMESH_Mesh* mesh = 0;
00107 
00108   if ( !CORBA::is_nil( theMesh ))
00109   {
00110     SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( theMesh );
00111     if ( !mesh_i )
00112       THROW_SALOME_CORBA_EXCEPTION( "bad mesh", SALOME::BAD_PARAM );
00113     mesh = &mesh_i->GetImpl();
00114   }
00115 
00116   try {
00117     this->GetImpl()->SetSourceMesh ( mesh );
00118   }
00119   catch ( SALOME_Exception& S_ex ) {
00120     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
00121   }
00122 
00123   myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( theMesh );
00124 
00125   // Update Python script
00126   SMESH::TPythonDump() << _this() << ".SetSourceMesh( " << theMesh << " )";
00127 }
00128 
00129 //=============================================================================
00133 //=============================================================================
00134 
00135 SMESH::SMESH_Mesh_ptr StdMeshers_ProjectionSource2D_i::GetSourceMesh()
00136 {
00137   SMESH::SMESH_Mesh_var mesh = myCorbaMesh;
00138   return mesh._retn();
00139 }
00140 
00141 //=============================================================================
00147 //=============================================================================
00148 
00149 void StdMeshers_ProjectionSource2D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr sourceVertex1,
00150                                                            GEOM::GEOM_Object_ptr sourceVertex2,
00151                                                            GEOM::GEOM_Object_ptr targetVertex1,
00152                                                            GEOM::GEOM_Object_ptr targetVertex2)
00153   throw ( SALOME::SALOME_Exception )
00154 {
00155   ASSERT( myBaseImpl );
00156   try {
00157     TopoDS_Shape v1 = StdMeshers_ObjRefUlils::GeomObjectToShape( sourceVertex1 );
00158     TopoDS_Shape v2 = StdMeshers_ObjRefUlils::GeomObjectToShape( sourceVertex2 );
00159     TopoDS_Shape v3 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex1 );
00160     TopoDS_Shape v4 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex2 );
00161     this->GetImpl()->SetVertexAssociation( v1, v2, v3, v4 );
00162   }
00163   catch ( SALOME_Exception& S_ex ) {
00164     THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
00165   }
00166   // Update Python script
00167   SMESH::TPythonDump() << _this() << ".SetVertexAssociation( "
00168                        << sourceVertex1 << ", "
00169                        << sourceVertex2 << ", "
00170                        << targetVertex1 << ", "
00171                        << targetVertex2 << " )";
00172 }
00173 
00174 //=============================================================================
00178 //=============================================================================
00179 
00180 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetSourceFace()
00181 {
00182   ASSERT( myBaseImpl );
00183   return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceFace() );
00184 }
00185 
00186 //=============================================================================
00191 //=============================================================================
00192 
00193 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetSourceVertex(CORBA::Long i)
00194 {
00195   ASSERT( myBaseImpl );
00196   return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceVertex((int) i ));
00197 }
00198 
00199 //=============================================================================
00204 //=============================================================================
00205 
00206 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetTargetVertex(CORBA::Long i)
00207 {
00208   ASSERT( myBaseImpl );
00209   return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetTargetVertex( (int)i ));
00210 }
00211 
00212 //=============================================================================
00218 //=============================================================================
00219 
00220 ::StdMeshers_ProjectionSource2D* StdMeshers_ProjectionSource2D_i::GetImpl()
00221 {
00222   return ( ::StdMeshers_ProjectionSource2D* )myBaseImpl;
00223 }
00224 
00225 //================================================================================
00233 //================================================================================  
00234 CORBA::Boolean StdMeshers_ProjectionSource2D_i::IsDimSupported( SMESH::Dimension type )
00235 {
00236   return type == SMESH::DIM_2D;
00237 }
00238 
00239 //================================================================================
00244 //================================================================================
00245 
00246 char* StdMeshers_ProjectionSource2D_i::SaveTo()
00247 {
00248   ASSERT( myBaseImpl );
00249   std::ostringstream os;
00250 
00251   TopoDS_Shape s1, s2, s3, s4, s5;
00252   GetImpl()->GetStoreParams( s1, s2, s3, s4, s5 );
00253 
00254   StdMeshers_ObjRefUlils::SaveToStream( s1, os );
00255   StdMeshers_ObjRefUlils::SaveToStream( s2, os );
00256   StdMeshers_ObjRefUlils::SaveToStream( s3, os );
00257   StdMeshers_ObjRefUlils::SaveToStream( s4, os );
00258   StdMeshers_ObjRefUlils::SaveToStream( s5, os );
00259   StdMeshers_ObjRefUlils::SaveToStream( GetSourceMesh(), os );
00260 
00261   myBaseImpl->SaveTo( os );
00262 
00263   return CORBA::string_dup( os.str().c_str() );
00264 }
00265 
00266 //================================================================================
00271 //================================================================================
00272 
00273 void StdMeshers_ProjectionSource2D_i::LoadFrom( const char* theStream )
00274 {
00275   ASSERT( myBaseImpl );
00276   std::istringstream is( theStream );
00277 
00278   TopoDS_Shape s1 = StdMeshers_ObjRefUlils::LoadFromStream( is );
00279   TopoDS_Shape s2 = StdMeshers_ObjRefUlils::LoadFromStream( is );
00280   TopoDS_Shape s3 = StdMeshers_ObjRefUlils::LoadFromStream( is );
00281   TopoDS_Shape s4 = StdMeshers_ObjRefUlils::LoadFromStream( is );
00282   TopoDS_Shape s5 = StdMeshers_ObjRefUlils::LoadFromStream( is );
00283   SMESH::SMESH_Mesh_var mesh = 
00284     StdMeshers_ObjRefUlils::LoadObjectFromStream< SMESH::SMESH_Mesh >( is );
00285 
00286   ::SMESH_Mesh* meshImpl = 0;
00287 
00288   if ( !CORBA::is_nil( mesh ))
00289   {
00290     SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( mesh );
00291     if ( mesh_i )
00292       meshImpl = &mesh_i->GetImpl();
00293   }
00294 
00295   myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( mesh );
00296   GetImpl()->RestoreParams( s1, s2, s3, s4, s5, meshImpl );
00297 
00298   myBaseImpl->LoadFrom( is );
00299 }
00300 
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