Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "StdMeshers_ProjectionSource3D_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_ProjectionSource3D_i::StdMeshers_ProjectionSource3D_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_ProjectionSource3D_i::StdMeshers_ProjectionSource3D_i" );
00057 myBaseImpl = new ::StdMeshers_ProjectionSource3D( theGenImpl->GetANewId(),
00058 theStudyId,
00059 theGenImpl );
00060 }
00061
00062
00068
00069
00070 StdMeshers_ProjectionSource3D_i::~StdMeshers_ProjectionSource3D_i()
00071 {
00072 MESSAGE( "StdMeshers_ProjectionSource3D_i::~StdMeshers_ProjectionSource3D_i" );
00073 }
00074
00075
00079
00080
00081 void StdMeshers_ProjectionSource3D_i::SetSource3DShape(GEOM::GEOM_Object_ptr shape)
00082 throw ( SALOME::SALOME_Exception )
00083 {
00084 ASSERT( myBaseImpl );
00085 try {
00086 this->GetImpl()->SetSource3DShape( StdMeshers_ObjRefUlils::GeomObjectToShape( shape ));
00087 }
00088 catch ( SALOME_Exception& S_ex ) {
00089 THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
00090 }
00091
00092 SMESH::TPythonDump() << _this() << ".SetSource3DShape( " << shape << " )";
00093 }
00094
00095
00099
00100
00101 void StdMeshers_ProjectionSource3D_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
00126 SMESH::TPythonDump() << _this() << ".SetSourceMesh( " << theMesh << " )";
00127 }
00128
00129
00133
00134
00135 SMESH::SMESH_Mesh_ptr StdMeshers_ProjectionSource3D_i::GetSourceMesh()
00136 {
00137 SMESH::SMESH_Mesh_var mesh = myCorbaMesh;
00138 return mesh._retn();
00139 }
00140
00141
00147
00148
00149 void StdMeshers_ProjectionSource3D_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
00167 SMESH::TPythonDump() << _this() << ".SetVertexAssociation( "
00168 << sourceVertex1 << ", "
00169 << sourceVertex2 << ", "
00170 << targetVertex1 << ", "
00171 << targetVertex2 << " )";
00172 }
00173
00174
00178
00179
00180 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_i::GetSource3DShape()
00181 {
00182 ASSERT( myBaseImpl );
00183 return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSource3DShape() );
00184 }
00185
00186
00191
00192
00193 GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_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_ProjectionSource3D_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_ProjectionSource3D* StdMeshers_ProjectionSource3D_i::GetImpl()
00221 {
00222 return ( ::StdMeshers_ProjectionSource3D* )myBaseImpl;
00223 }
00224
00225
00233
00234 CORBA::Boolean StdMeshers_ProjectionSource3D_i::IsDimSupported( SMESH::Dimension type )
00235 {
00236 return type == SMESH::DIM_3D;
00237 }
00238
00239
00244
00245
00246 char* StdMeshers_ProjectionSource3D_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_ProjectionSource3D_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 myBaseImpl->LoadFrom( is );
00298 }
00299