0021530: EDF 2176 SMESH: Projection 1D-2D with compounds

keep entries of shapes to be able to return a correct GEOM_Object in
case if it is published several times with different names
This commit is contained in:
eap 2012-04-11 08:23:17 +00:00
parent b9b021a25d
commit 719b352189
6 changed files with 122 additions and 52 deletions

View File

@ -24,7 +24,6 @@
// File : StdMeshers_ProjectionSource1D_i.cxx
// Author : Edward AGAPOV
// Module : SMESH
// $Header$
//
#include "StdMeshers_ProjectionSource1D_i.hxx"
@ -84,6 +83,8 @@ void StdMeshers_ProjectionSource1D_i::SetSourceEdge(GEOM::GEOM_Object_ptr edge)
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 );
@ -108,6 +109,12 @@ void StdMeshers_ProjectionSource1D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr
TopoDS_Shape v1 = StdMeshers_ObjRefUlils::GeomObjectToShape( sourceVertex );
TopoDS_Shape v2 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex );
this->GetImpl()->SetVertexAssociation( v1, v2 );
CORBA::String_var entry;
entry = sourceVertex->GetStudyEntry();
myShapeEntries[ SRC_VERTEX ] = entry.in();
entry = targetVertex->GetStudyEntry();
myShapeEntries[ TGT_VERTEX ] = entry.in();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
@ -172,7 +179,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() );
}
//=============================================================================
@ -185,7 +194,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() );
}
//=============================================================================
@ -198,7 +209,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() );
}
//=============================================================================
@ -240,12 +253,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 );
@ -265,9 +274,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 );
@ -281,8 +290,15 @@ void StdMeshers_ProjectionSource1D_i::LoadFrom( const char* theStream )
}
myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( mesh );
GetImpl()->RestoreParams( s1, s2, s3, meshImpl );
GetImpl()->SetSourceMesh ( meshImpl );
GetImpl()->SetSourceEdge ( shapes[ SRC_EDGE ] );
GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX ],
shapes[ TGT_VERTEX ]);
myBaseImpl->LoadFrom( is );
std::istringstream str( theStream );
for ( int i = 0; i < NB_SHAPES; ++i )
str >> myShapeEntries[ i ];
}

View File

@ -111,6 +111,11 @@ public:
virtual void LoadFrom( const char* theStream );
private:
// keep entries because the same shape can be published several times with
// different names and in this case a correct name can't be restored by a TopoDS_Shape
// kept by ::StdMeshers_ProjectionSource1D
enum { SRC_EDGE=0, SRC_VERTEX, TGT_VERTEX, NB_SHAPES };
std::string myShapeEntries[NB_SHAPES];
SMESH::SMESH_Mesh_var myCorbaMesh;
};

View File

@ -24,7 +24,6 @@
// File : StdMeshers_ProjectionSource2D_i.cxx
// Author : Edward AGAPOV
// Module : SMESH
// $Header$
//
#include "StdMeshers_ProjectionSource2D_i.hxx"
@ -84,6 +83,8 @@ void StdMeshers_ProjectionSource2D_i::SetSourceFace(GEOM::GEOM_Object_ptr face)
ASSERT( myBaseImpl );
try {
this->GetImpl()->SetSourceFace( StdMeshers_ObjRefUlils::GeomObjectToShape( face ));
CORBA::String_var entry = face->GetStudyEntry();
myShapeEntries[ SRC_FACE ] = entry.in();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
@ -159,6 +160,16 @@ void StdMeshers_ProjectionSource2D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr
TopoDS_Shape v3 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex1 );
TopoDS_Shape v4 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex2 );
this->GetImpl()->SetVertexAssociation( v1, v2, v3, v4 );
CORBA::String_var entry;
entry = sourceVertex1->GetStudyEntry();
myShapeEntries[ SRC_VERTEX1 ] = entry.in();
entry = sourceVertex2->GetStudyEntry();
myShapeEntries[ SRC_VERTEX2 ] = entry.in();
entry = targetVertex1->GetStudyEntry();
myShapeEntries[ TGT_VERTEX1 ] = entry.in();
entry = targetVertex2->GetStudyEntry();
myShapeEntries[ TGT_VERTEX2 ] = entry.in();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
@ -180,7 +191,9 @@ void StdMeshers_ProjectionSource2D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr
GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetSourceFace()
{
ASSERT( myBaseImpl );
return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceFace() );
return StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject
( myShapeEntries[ SRC_FACE ],
this->GetImpl()->GetSourceFace() );
}
//=============================================================================
@ -193,7 +206,9 @@ GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetSourceFace()
GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetSourceVertex(CORBA::Long i)
{
ASSERT( myBaseImpl );
return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceVertex((int) i ));
return StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject
( myShapeEntries[ i == 1 ? SRC_VERTEX1 : SRC_VERTEX2 ],
this->GetImpl()->GetSourceVertex((int) i ));
}
//=============================================================================
@ -206,7 +221,9 @@ GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetSourceVertex(CORBA::Lo
GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetTargetVertex(CORBA::Long i)
{
ASSERT( myBaseImpl );
return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetTargetVertex( (int)i ));
return StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject
( myShapeEntries[ i == 1 ? TGT_VERTEX1 : TGT_VERTEX2 ],
this->GetImpl()->GetTargetVertex( (int)i ));
}
//=============================================================================
@ -248,14 +265,8 @@ char* StdMeshers_ProjectionSource2D_i::SaveTo()
ASSERT( myBaseImpl );
std::ostringstream os;
TopoDS_Shape s1, s2, s3, s4, s5;
GetImpl()->GetStoreParams( s1, s2, s3, s4, s5 );
StdMeshers_ObjRefUlils::SaveToStream( s1, os );
StdMeshers_ObjRefUlils::SaveToStream( s2, os );
StdMeshers_ObjRefUlils::SaveToStream( s3, os );
StdMeshers_ObjRefUlils::SaveToStream( s4, os );
StdMeshers_ObjRefUlils::SaveToStream( s5, os );
for ( int i = 0; i < NB_SHAPES; ++i )
StdMeshers_ObjRefUlils::SaveToStream( myShapeEntries[ i ], os );
StdMeshers_ObjRefUlils::SaveToStream( GetSourceMesh(), os );
myBaseImpl->SaveTo( os );
@ -275,11 +286,9 @@ void StdMeshers_ProjectionSource2D_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 s4 = StdMeshers_ObjRefUlils::LoadFromStream( is );
TopoDS_Shape s5 = 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 );
@ -293,8 +302,17 @@ void StdMeshers_ProjectionSource2D_i::LoadFrom( const char* theStream )
}
myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( mesh );
GetImpl()->RestoreParams( s1, s2, s3, s4, s5, meshImpl );
GetImpl()->SetSourceMesh ( meshImpl );
GetImpl()->SetSourceFace ( shapes[ SRC_FACE ] );
GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX1 ],
shapes[ SRC_VERTEX2 ],
shapes[ TGT_VERTEX1 ],
shapes[ TGT_VERTEX2 ]);
myBaseImpl->LoadFrom( is );
std::istringstream str( theStream );
for ( int i = 0; i < NB_SHAPES; ++i )
str >> myShapeEntries[ i ];
}

View File

@ -24,7 +24,6 @@
// File : StdMeshers_ProjectionSource2D_i.hxx
// Author : Edward AGAPOV
// Module : SMESH
// $Header$
//
#ifndef _SMESH_ProjectionSource2D_I_HXX_
#define _SMESH_ProjectionSource2D_I_HXX_
@ -94,6 +93,7 @@ public:
/*!
* Returns the <i>-th source vertex associated with the <i>-th target vertex.
* Result may be nil if association not set.
* Valid indices are 1 and 2
*/
GEOM::GEOM_Object_ptr GetSourceVertex(CORBA::Long i);
@ -115,8 +115,12 @@ public:
virtual void LoadFrom( const char* theStream );
private:
// keep entries because the same shape can be published several times with
// different names and in this case a correct name can't be restored by a TopoDS_Shape
// kept by ::StdMeshers_ProjectionSource2D
enum { SRC_FACE=0, SRC_VERTEX1, SRC_VERTEX2, TGT_VERTEX1, TGT_VERTEX2, NB_SHAPES };
std::string myShapeEntries[NB_SHAPES];
SMESH::SMESH_Mesh_var myCorbaMesh;
};
#endif

View File

@ -24,7 +24,6 @@
// File : StdMeshers_ProjectionSource3D_i.cxx
// Author : Edward AGAPOV
// Module : SMESH
// $Header$
//
#include "StdMeshers_ProjectionSource3D_i.hxx"
@ -84,6 +83,9 @@ void StdMeshers_ProjectionSource3D_i::SetSource3DShape(GEOM::GEOM_Object_ptr sha
ASSERT( myBaseImpl );
try {
this->GetImpl()->SetSource3DShape( StdMeshers_ObjRefUlils::GeomObjectToShape( shape ));
CORBA::String_var entry = shape->GetStudyEntry();
myShapeEntries[ SRC_SHAPE3D ] = entry.in();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
@ -159,6 +161,16 @@ void StdMeshers_ProjectionSource3D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr
TopoDS_Shape v3 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex1 );
TopoDS_Shape v4 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex2 );
this->GetImpl()->SetVertexAssociation( v1, v2, v3, v4 );
CORBA::String_var entry;
entry = sourceVertex1->GetStudyEntry();
myShapeEntries[ SRC_VERTEX1 ] = entry.in();
entry = sourceVertex2->GetStudyEntry();
myShapeEntries[ SRC_VERTEX2 ] = entry.in();
entry = targetVertex1->GetStudyEntry();
myShapeEntries[ TGT_VERTEX1 ] = entry.in();
entry = targetVertex2->GetStudyEntry();
myShapeEntries[ TGT_VERTEX2 ] = entry.in();
}
catch ( SALOME_Exception& S_ex ) {
THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
@ -180,7 +192,9 @@ void StdMeshers_ProjectionSource3D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr
GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_i::GetSource3DShape()
{
ASSERT( myBaseImpl );
return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSource3DShape() );
return StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject
( myShapeEntries[ SRC_SHAPE3D ],
this->GetImpl()->GetSource3DShape() );
}
//=============================================================================
@ -193,7 +207,9 @@ GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_i::GetSource3DShape()
GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_i::GetSourceVertex(CORBA::Long i)
{
ASSERT( myBaseImpl );
return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceVertex((int) i ));
return StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject
( myShapeEntries[ i == 1 ? SRC_VERTEX1 : SRC_VERTEX2 ],
this->GetImpl()->GetSourceVertex((int) i ));
}
//=============================================================================
@ -206,7 +222,9 @@ GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_i::GetSourceVertex(CORBA::Lo
GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_i::GetTargetVertex(CORBA::Long i)
{
ASSERT( myBaseImpl );
return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetTargetVertex( (int)i ));
return StdMeshers_ObjRefUlils::EntryOrShapeToGeomObject
( myShapeEntries[ i == 1 ? TGT_VERTEX1 : TGT_VERTEX2 ],
this->GetImpl()->GetTargetVertex( (int)i ));
}
//=============================================================================
@ -248,14 +266,8 @@ char* StdMeshers_ProjectionSource3D_i::SaveTo()
ASSERT( myBaseImpl );
std::ostringstream os;
TopoDS_Shape s1, s2, s3, s4, s5;
GetImpl()->GetStoreParams( s1, s2, s3, s4, s5 );
StdMeshers_ObjRefUlils::SaveToStream( s1, os );
StdMeshers_ObjRefUlils::SaveToStream( s2, os );
StdMeshers_ObjRefUlils::SaveToStream( s3, os );
StdMeshers_ObjRefUlils::SaveToStream( s4, os );
StdMeshers_ObjRefUlils::SaveToStream( s5, os );
for ( int i = 0; i < NB_SHAPES; ++i )
StdMeshers_ObjRefUlils::SaveToStream( myShapeEntries[ i ], os );
StdMeshers_ObjRefUlils::SaveToStream( GetSourceMesh(), os );
myBaseImpl->SaveTo( os );
@ -275,11 +287,9 @@ void StdMeshers_ProjectionSource3D_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 s4 = StdMeshers_ObjRefUlils::LoadFromStream( is );
TopoDS_Shape s5 = 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 );
@ -293,7 +303,18 @@ void StdMeshers_ProjectionSource3D_i::LoadFrom( const char* theStream )
}
myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( mesh );
GetImpl()->RestoreParams( s1, s2, s3, s4, s5, meshImpl );
GetImpl()->SetSourceMesh ( meshImpl );
GetImpl()->SetSource3DShape ( shapes[ SRC_SHAPE3D ] );
GetImpl()->SetVertexAssociation( shapes[ SRC_VERTEX1 ],
shapes[ SRC_VERTEX2 ],
shapes[ TGT_VERTEX1 ],
shapes[ TGT_VERTEX2 ]);
myBaseImpl->LoadFrom( is );
std::istringstream str( theStream );
for ( int i = 0; i < NB_SHAPES; ++i )
str >> myShapeEntries[ i ];
}

View File

@ -94,6 +94,7 @@ public:
/*!
* Returns the <i>-th source vertex associated with the <i>-th target vertex.
* Result may be nil if association not set.
* Valid indices are 1 and 2
*/
GEOM::GEOM_Object_ptr GetSourceVertex(CORBA::Long i);
@ -115,6 +116,11 @@ public:
virtual void LoadFrom( const char* theStream );
private:
// keep entries because the same shape can be published several times with
// different names and in this case a correct name can't be restored by a TopoDS_Shape
// kept by ::StdMeshers_ProjectionSource3D
enum { SRC_SHAPE3D=0, SRC_VERTEX1, SRC_VERTEX2, TGT_VERTEX1, TGT_VERTEX2, NB_SHAPES };
std::string myShapeEntries[NB_SHAPES];
SMESH::SMESH_Mesh_var myCorbaMesh;
};