From b73a16f1cdc3210d826b5c7327bf210d4ca29f73 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 6 Dec 2006 15:33:29 +0000 Subject: [PATCH] PAL13473 (Build repetitive mesh): New meshers implemented --- src/SMESH_I/SMESH_2smeshpy.cxx | 288 +++++++-- src/SMESH_I/SMESH_2smeshpy.hxx | 49 +- src/StdMeshersGUI/Makefile.in | 8 +- ...tdMeshersGUI_LayerDistributionParamWdg.cxx | 199 ++++++ .../StdMeshersGUI_LayerDistributionParamWdg.h | 83 +++ .../StdMeshersGUI_ObjectReferenceParamWdg.cxx | 206 ++++++ .../StdMeshersGUI_ObjectReferenceParamWdg.h | 109 ++++ .../StdMeshersGUI_StdHypothesisCreator.cxx | 592 ++++++++++++++++-- .../StdMeshersGUI_StdHypothesisCreator.h | 17 +- src/StdMeshersGUI/StdMeshers_images.po | 72 ++- src/StdMeshersGUI/StdMeshers_msg_en.po | 83 ++- src/StdMeshers_I/Makefile.in | 20 +- .../StdMeshers_LayerDistribution_i.cxx | 215 +++++++ .../StdMeshers_LayerDistribution_i.hxx | 88 +++ .../StdMeshers_NumberOfLayers_i.cxx | 135 ++++ .../StdMeshers_NumberOfLayers_i.hxx | 75 +++ src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx | 106 ++++ src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx | 109 ++++ src/StdMeshers_I/StdMeshers_Prism_3D_i.cxx | 103 +++ src/StdMeshers_I/StdMeshers_Prism_3D_i.hxx | 83 +++ .../StdMeshers_ProjectionSource1D_i.cxx | 288 +++++++++ .../StdMeshers_ProjectionSource1D_i.hxx | 118 ++++ .../StdMeshers_ProjectionSource2D_i.cxx | 300 +++++++++ .../StdMeshers_ProjectionSource2D_i.hxx | 122 ++++ .../StdMeshers_ProjectionSource3D_i.cxx | 299 +++++++++ .../StdMeshers_ProjectionSource3D_i.hxx | 122 ++++ .../StdMeshers_Projection_1D_2D_3D_i.cxx | 140 +++++ .../StdMeshers_Projection_1D_2D_3D_i.hxx | 109 ++++ src/StdMeshers_I/StdMeshers_i.cxx | 30 + 29 files changed, 4017 insertions(+), 151 deletions(-) create mode 100644 src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.cxx create mode 100644 src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.h create mode 100644 src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.cxx create mode 100644 src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h create mode 100644 src/StdMeshers_I/StdMeshers_LayerDistribution_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_LayerDistribution_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_NumberOfLayers_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_NumberOfLayers_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx create mode 100644 src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx create mode 100644 src/StdMeshers_I/StdMeshers_Prism_3D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_Prism_3D_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_Projection_1D_2D_3D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_Projection_1D_2D_3D_i.hxx diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 3171cbca2..db50e6285 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -54,6 +54,7 @@ IMPLEMENT_STANDARD_RTTIEXT(_pyHypothesis ,_pyObject); IMPLEMENT_STANDARD_RTTIEXT(_pyAlgorithm ,_pyHypothesis); IMPLEMENT_STANDARD_RTTIEXT(_pyComplexParamHypo,_pyHypothesis); IMPLEMENT_STANDARD_RTTIEXT(_pyNumberOfSegmentsHyp,_pyHypothesis); +IMPLEMENT_STANDARD_RTTIEXT(_pyLayerDistributionHypo,_pyHypothesis); using namespace std; using SMESH::TPythonDump; @@ -706,127 +707,139 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th Handle(_pyHypothesis) hyp, algo; // "theHypType" - const TCollection_AsciiString & hypTypeWithQuotes = theCreationCmd->GetArg( 1 ); - if ( hypTypeWithQuotes.IsEmpty() ) + const TCollection_AsciiString & hypTypeQuoted = theCreationCmd->GetArg( 1 ); + if ( hypTypeQuoted.IsEmpty() ) return hyp; // theHypType TCollection_AsciiString hypType = - hypTypeWithQuotes.SubString( 2, hypTypeWithQuotes.Length() - 1 ); + hypTypeQuoted.SubString( 2, hypTypeQuoted.Length() - 1 ); algo = new _pyAlgorithm( theCreationCmd ); hyp = new _pyHypothesis( theCreationCmd ); // 1D Regular_1D ---------- if ( hypType == "Regular_1D" ) { - algo->myDim = 1; - algo->myCreationMethod = "Segment"; + algo->SetDimMethodType( 1, "Segment"); } else if ( hypType == "LocalLength" ) { - hyp->myDim = 1; - hyp->myCreationMethod = "LocalLength"; - hyp->myType = "Regular_1D"; - hyp->myArgMethods.Append( "SetLength" ); + hyp->SetDimMethodType( 1, "LocalLength", "Regular_1D"); + hyp->AddArgMethod( "SetLength" ); } else if ( hypType == "NumberOfSegments" ) { hyp = new _pyNumberOfSegmentsHyp( theCreationCmd ); - hyp->myDim = 1; - hyp->myCreationMethod = "NumberOfSegments"; - hyp->myType = "Regular_1D"; - hyp->myArgMethods.Append( "SetNumberOfSegments" ); - hyp->myArgMethods.Append( "SetScaleFactor" ); + hyp->SetDimMethodType( 1, "NumberOfSegments", "Regular_1D"); + hyp->AddArgMethod( "SetNumberOfSegments" ); + hyp->AddArgMethod( "SetScaleFactor" ); } else if ( hypType == "Arithmetic1D" ) { hyp = new _pyComplexParamHypo( theCreationCmd ); - hyp->myDim = 1; - hyp->myCreationMethod = "Arithmetic1D"; - hyp->myType = "Regular_1D"; + hyp->SetDimMethodType( 1, "Arithmetic1D", "Regular_1D"); } else if ( hypType == "StartEndLength" ) { hyp = new _pyComplexParamHypo( theCreationCmd ); - hyp->myDim = 1; - hyp->myCreationMethod = "StartEndLength"; - hyp->myType = "Regular_1D"; + hyp->SetDimMethodType( 1, "StartEndLength", "Regular_1D"); } else if ( hypType == "Deflection1D" ) { - hyp->myDim = 1; - hyp->myCreationMethod = "Deflection1D"; - hyp->myArgMethods.Append( "SetDeflection" ); - hyp->myType = "Regular_1D"; + hyp->SetDimMethodType( 1, "Deflection1D", "Regular_1D"); + hyp->AddArgMethod( "SetDeflection" ); } else if ( hypType == "Propagation" ) { - hyp->myDim = 1; - hyp->myCreationMethod = "Propagation"; - hyp->myType = "Regular_1D"; + hyp->SetDimMethodType( 1, "Propagation", "Regular_1D"); } else if ( hypType == "QuadraticMesh" ) { - hyp->myDim = 1; - hyp->myCreationMethod = "QuadraticMesh"; - hyp->myType = "Regular_1D"; + hyp->SetDimMethodType( 1, "QuadraticMesh", "Regular_1D"); } else if ( hypType == "AutomaticLength" ) { - hyp->myDim = 1; - hyp->myCreationMethod = "AutomaticLength"; - hyp->myType = "Regular_1D"; - hyp->myArgMethods.Append( "SetFineness"); + hyp->SetDimMethodType( 1, "AutomaticLength", "Regular_1D"); + hyp->AddArgMethod( "SetFineness"); } // 1D Python_1D ---------- else if ( hypType == "Python_1D" ) { - algo->myDim = 1; - algo->myCreationMethod = "Segment"; + algo->SetDimMethodType( 1, "Segment"); algo->myArgs.Append( "algo=smesh.PYTHON"); } else if ( hypType == "PythonSplit1D" ) { - hyp->myDim = 1; - hyp->myCreationMethod = "PythonSplit1D"; - hyp->myType = "Python_1D"; - hyp->myArgMethods.Append( "SetNumberOfSegments"); - hyp->myArgMethods.Append( "SetPythonLog10RatioFunction"); + hyp->SetDimMethodType( 1, "PythonSplit1D", "Python_1D"); + hyp->AddArgMethod( "SetNumberOfSegments"); + hyp->AddArgMethod( "SetPythonLog10RatioFunction"); } // 2D ---------- else if ( hypType == "MEFISTO_2D" ) { - algo->myDim = 2; - algo->myCreationMethod = "Triangle"; + algo->SetDimMethodType( 2, "Triangle"); } else if ( hypType == "MaxElementArea" ) { - hyp->myDim = 2; - hyp->myCreationMethod = "MaxElementArea"; - hyp->myType = "MEFISTO_2D"; - hyp->myArgMethods.Append( "SetMaxElementArea"); + hyp->SetDimMethodType( 2, "MaxElementArea", "MEFISTO_2D"); + hyp->AddArgMethod( "SetMaxElementArea"); } else if ( hypType == "LengthFromEdges" ) { - hyp->myDim = 2; - hyp->myCreationMethod = "LengthFromEdges"; - hyp->myType = "MEFISTO_2D"; + hyp->SetDimMethodType( 2, "LengthFromEdges", "MEFISTO_2D"); } else if ( hypType == "Quadrangle_2D" ) { - algo->myDim = 2; - algo->myCreationMethod = "Quadrangle"; + algo->SetDimMethodType( 2, "Quadrangle" ); } else if ( hypType == "QuadranglePreference" ) { - hyp->myDim = 2; - hyp->myCreationMethod = "QuadranglePreference"; - hyp->myType = "Quadrangle_2D"; + hyp->SetDimMethodType( 2, "QuadranglePreference", "Quadrangle_2D"); } // 3D ---------- else if ( hypType == "NETGEN_3D") { - algo->myDim = 3; - algo->myCreationMethod = "Tetrahedron"; + algo->SetDimMethodType( 3, "Tetrahedron" ); algo->myArgs.Append( "algo=smesh.NETGEN" ); } else if ( hypType == "MaxElementVolume") { - hyp->myDim = 3; - hyp->myCreationMethod = "MaxElementVolume"; - hyp->myType = "NETGEN_3D"; - hyp->myArgMethods.Append( "SetMaxElementVolume" ); + hyp->SetDimMethodType( 3, "MaxElementVolume", "NETGEN_3D"); + hyp->AddArgMethod( "SetMaxElementVolume" ); } else if ( hypType == "GHS3D_3D" ) { - algo->myDim = 3; - algo->myCreationMethod = "Tetrahedron"; + algo->SetDimMethodType( 3, "Tetrahedron"); algo->myArgs.Append( "algo=smesh.GHS3D" ); } else if ( hypType == "Hexa_3D" ) { - algo->myDim = 3; - algo->myCreationMethod = "Hexahedron"; + algo->SetDimMethodType( 3, "Hexahedron"); + } + // Repetitive --------- + else if ( hypType == "Projection_1D" ) { + algo->SetDimMethodType( 1, "Projection1D"); + } + else if ( hypType == "ProjectionSource1D" ) { + hyp->SetDimMethodType( 1, "SourceEdge", "Projection_1D"); + hyp->AddArgMethod( "SetSourceEdge"); + hyp->AddArgMethod( "SetSourceMesh"); + hyp->AddArgMethod( "SetVertexAssociation", 2 ); + } + else if ( hypType == "Projection_2D" ) { + algo->SetDimMethodType( 2, "Projection2D"); + } + else if ( hypType == "ProjectionSource2D" ) { + hyp->SetDimMethodType( 2, "SourceFace", "Projection_2D"); + hyp->AddArgMethod( "SetSourceFace"); + hyp->AddArgMethod( "SetSourceMesh"); + hyp->AddArgMethod( "SetVertexAssociation", 4 ); + } + else if ( hypType == "Projection_3D" ) { + algo->SetDimMethodType( 3, "Projection3D"); + } + else if ( hypType == "ProjectionSource3D" ) { + hyp->SetDimMethodType( 3, "SourceShape3D", "Projection_3D"); + hyp->AddArgMethod( "SetSource3DShape"); + hyp->AddArgMethod( "SetSourceMesh"); + hyp->AddArgMethod( "SetVertexAssociation", 4 ); + } + else if ( hypType == "Prism_3D" ) { + algo->SetDimMethodType( 3, "Prism"); + } + else if ( hypType == "RadialPrism_3D" ) { + algo->SetDimMethodType( 3, "Prism"); + } + else if ( hypType == "NumberOfLayers" ) { + hyp->SetDimMethodType( 3, "NumberOfLayers", "RadialPrism_3D"); + hyp->AddArgMethod( "SetNumberOfLayers" ); + } + else if ( hypType == "LayerDistribution" ) { + hyp = new _pyLayerDistributionHypo( theCreationCmd ); + hyp->SetDimMethodType( 3, "LayerDistribution", "RadialPrism_3D"); +// hyp->AddArgMethod( "SetSource3DShape"); +// hyp->AddArgMethod( "SetSourceMesh"); +// hyp->AddArgMethod( "SetVertexAssociation", 4 ); } if ( algo->GetDim() ) { @@ -908,14 +921,17 @@ void _pyHypothesis::Process( const Handle(_pyCommand)& theCommand) { ASSERT( !myIsAlgo ); // set args + int nbArgs = 0; for ( int i = 1; i <= myArgMethods.Length(); ++i ) { if ( myArgMethods( i ) == theCommand->GetMethod() ) { - while ( myArgs.Length() < i ) + while ( myArgs.Length() < nbArgs + myNbArgsByMethod( i )) myArgs.Append( "[]" ); - myArgs( i ) = theCommand->GetArg( 1 ); // arg value + for ( int iArg = 1; iArg <= myNbArgsByMethod( i ); ++iArg ) + myArgs( nbArgs + iArg ) = theCommand->GetArg( iArg ); // arg value myArgCommands.push_back( theCommand ); return; } + nbArgs += myNbArgsByMethod( i ); } myUnknownCommands.push_back( theCommand ); } @@ -935,6 +951,23 @@ void _pyHypothesis::Flush() } } +//================================================================================ +/*! + * \brief clear creation, arg and unkown commands + */ +//================================================================================ + +void _pyHypothesis::ClearAllCommands() +{ + GetCreationCmd()->Clear(); + list::iterator cmd = myArgCommands.begin(); + for ( ; cmd != myArgCommands.end(); ++cmd ) + ( *cmd )->Clear(); + cmd = myUnknownCommands.begin(); + for ( ; cmd != myUnknownCommands.end(); ++cmd ) + ( *cmd )->Clear(); +} + //================================================================================ /*! * \brief Remember hypothesis parameter values @@ -955,6 +988,127 @@ void _pyComplexParamHypo::Process( const Handle(_pyCommand)& theCommand) myArgCommands.push_back( theCommand ); } +//================================================================================ +/*! + * \brief Convert methods of 1D hypotheses to my own methods + * \param theCommand - The called hypothesis method + */ +//================================================================================ + +void _pyLayerDistributionHypo::Process( const Handle(_pyCommand)& theCommand) +{ + if ( theCommand->GetMethod() != "SetLayerDistribution" ) + return; + + _pyID newName; // name for 1D hyp = "HypType" + "_Distribution" + + const _pyID& hyp1dID = theCommand->GetArg( 1 ); + Handle(_pyHypothesis) hyp1d = theGen->FindHyp( hyp1dID ); + if ( hyp1d.IsNull() ) // apparently hypId changed at study restoration + hyp1d = my1dHyp; + else if ( !my1dHyp.IsNull() && hyp1dID != my1dHyp->GetID() ) { + // 1D hypo is already set, so distribution changes and the old + // 1D hypo is thrown away + my1dHyp->ClearAllCommands(); + } + my1dHyp = hyp1d; + if ( my1dHyp.IsNull() ) + return; // something wrong :( + + // make a new name for 1D hyp = "HypType" + "_Distribution" + if ( my1dHyp->GetCreationCmd()->GetMethod() == "CreateHypothesis" ) { + // not yet converted creation cmd + TCollection_AsciiString hypTypeQuoted = my1dHyp->GetCreationCmd()->GetArg(1); + TCollection_AsciiString hypType = hypTypeQuoted.SubString( 2, hypTypeQuoted.Length() - 1 ); + newName = hypType + "_Distribution"; + my1dHyp->GetCreationCmd()->SetResultValue( newName ); + } + else { + // already converted creation cmd + newName = my1dHyp->GetCreationCmd()->GetResultValue(); + } + + // as creation of 1D hyp was written later then it's edition, + // we need to find all it's edition calls and process them + list< Handle(_pyCommand) >& cmds = theGen->GetCommands(); + list< Handle(_pyCommand) >::iterator cmdIt = cmds.begin(); + for ( ; cmdIt != cmds.end(); ++cmdIt ) { + const _pyID& objID = (*cmdIt)->GetObject(); + if ( objID == hyp1dID ) { + my1dHyp->Process( *cmdIt ); + my1dHyp->GetCreationCmd()->AddDependantCmd( *cmdIt ); + ( *cmdIt )->SetObject( newName ); + } + } + if ( !myArgCommands.empty() ) + myArgCommands.front()->Clear(); + theCommand->SetArg( 1, newName ); + myArgCommands.push_back( theCommand ); + // copy hyp1d's creation method and args +// myCreationMethod = hyp1d->GetCreationMethod(); +// myArgs = hyp1d->GetArgs(); +// // make them cleared at conversion +// myArgCommands = hyp1d->GetArgCommands(); + +// // to be cleared at convertion only +// myArgCommands.push_back( theCommand ); +} + +//================================================================================ +/*! + * \brief + * \param theAdditionCmd - + * \param theMesh - + * \retval bool - + */ +//================================================================================ + +bool _pyLayerDistributionHypo::Addition2Creation( const Handle(_pyCommand)& theAdditionCmd, + const _pyID& theMesh) +{ + myIsWrapped = false; + + if ( my1dHyp.IsNull() ) + return false; + + // set "SetLayerDistribution()" after addition cmd + theAdditionCmd->AddDependantCmd( myArgCommands.front() ); + + _pyID geom = theAdditionCmd->GetArg( 1 ); + + my1dHyp->SetMesh( theMesh ); + if ( !my1dHyp->Addition2Creation( theAdditionCmd, theMesh )) + return false; + + // clear "SetLayerDistribution()" cmd + myArgCommands.front()->Clear(); + + // Convert my creation => me = RadialPrismAlgo.Get3DHypothesis() + + // find RadialPrism algo created on for theMesh + Handle(_pyHypothesis) algo = theGen->FindAlgo( geom, theMesh, this->GetType() ); + if ( !algo.IsNull() ) { + GetCreationCmd()->SetObject( algo->GetID() ); + GetCreationCmd()->SetMethod( "Get3DHypothesis" ); + GetCreationCmd()->RemoveArgs(); + theAdditionCmd->AddDependantCmd( GetCreationCmd() ); + myIsWrapped = true; + } + return myIsWrapped; +} + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +void _pyLayerDistributionHypo::Flush() +{ + //my1dHyp.Nullify(); + //_pyHypothesis::Flush(); +} + //================================================================================ /*! * \brief additionally to Addition2Creation, clears SetDistrType() command diff --git a/src/SMESH_I/SMESH_2smeshpy.hxx b/src/SMESH_I/SMESH_2smeshpy.hxx index 5319af279..7a426df97 100644 --- a/src/SMESH_I/SMESH_2smeshpy.hxx +++ b/src/SMESH_I/SMESH_2smeshpy.hxx @@ -34,6 +34,7 @@ #include #include +// =========================================================================================== /*! * \brief Tool converting SMESH engine calls into commands defined in smesh.py * @@ -49,6 +50,7 @@ * * See comments to _pyHypothesis class to know how to assure convertion of a new hypothesis */ +// =========================================================================================== class Resource_DataMapOfAsciiStringAsciiString; @@ -74,9 +76,11 @@ public: static char* GenName() { return "smesh.smesh"; } }; +// =========================================================================================== // ===================== // INTERNAL STUFF // ===================== +// =========================================================================================== class _pyCommand; class _pyObject; @@ -154,9 +158,11 @@ public: DEFINE_STANDARD_RTTI (_pyCommand) }; +// ------------------------------------------------------------------------------------- /*! * \brief Root of all objects */ +// ------------------------------------------------------------------------------------- class _pyObject: public Standard_Transient { @@ -174,10 +180,12 @@ public: DEFINE_STANDARD_RTTI (_pyObject) }; +// ------------------------------------------------------------------------------------- /*! * \brief Class corresponding to SMESH_Gen. It holds info on existing * meshes and hypotheses */ +// ------------------------------------------------------------------------------------- class _pyGen: public _pyObject { public: @@ -205,9 +213,11 @@ private: DEFINE_STANDARD_RTTI (_pyGen) }; +// ------------------------------------------------------------------------------------- /*! * \brief Contains commands concerning mesh substructures */ +// ------------------------------------------------------------------------------------- #define _pyMesh_ACCESS_METHOD "GetMesh()" class _pyMesh: public _pyObject { @@ -229,6 +239,7 @@ private: }; #undef _pyMesh_ACCESS_METHOD +// ------------------------------------------------------------------------------------- /*! * \brief Root class for hypothesis * @@ -245,19 +256,29 @@ private: * to derive a specific class from _pyHypothesis that would redefine Process(), * see _pyComplexParamHypo for example */ +// ------------------------------------------------------------------------------------- class _pyHypothesis: public _pyObject { protected: bool myIsAlgo, /*myIsLocal, */myIsWrapped, myIsConverted; - int myDim, myAdditionCmdNb; + int myDim, /*myAdditionCmdNb*/; _pyID myGeom, myMesh; TCollection_AsciiString myCreationMethod, myType; TColStd_SequenceOfAsciiString myArgs; TColStd_SequenceOfAsciiString myArgMethods; + TColStd_SequenceOfInteger myNbArgsByMethod; std::list myArgCommands; std::list myUnknownCommands; public: _pyHypothesis(const Handle(_pyCommand)& theCreationCmd); + void SetDimMethodType(const int dim, const char* creationMethod, const char* type=0) + { myDim = dim; myCreationMethod = (char*)creationMethod; if ( type ) myType = (char*)type; } + void AddArgMethod(const char* method, const int nbArgs = 1) + { myArgMethods.Append( (char*)method ); myNbArgsByMethod.Append( nbArgs ); } + const TColStd_SequenceOfAsciiString& GetArgs() const { return myArgs; } + const TCollection_AsciiString& GetCreationMethod() const { return myCreationMethod; } + const std::list& GetArgCommands() const { return myArgCommands; } + void ClearAllCommands(); virtual bool IsAlgo() const { return myIsAlgo; } bool IsWrapped() const { return myIsWrapped; } bool & IsConverted() { return myIsConverted; } @@ -278,9 +299,11 @@ public: DEFINE_STANDARD_RTTI (_pyHypothesis) }; +// ------------------------------------------------------------------------------------- /*! * \brief Class for hypotheses having several parameters modified by one method */ +// ------------------------------------------------------------------------------------- class _pyComplexParamHypo: public _pyHypothesis { public: @@ -291,10 +314,32 @@ public: }; DEFINE_STANDARD_HANDLE (_pyComplexParamHypo, _pyHypothesis); +// ------------------------------------------------------------------------------------- +/*! + * \brief Class for LayerDistribution hypothesis conversion + */ +// ------------------------------------------------------------------------------------- +class _pyLayerDistributionHypo: public _pyHypothesis +{ + Handle(_pyHypothesis) my1dHyp; +public: + _pyLayerDistributionHypo(const Handle(_pyCommand)& theCreationCmd): + _pyHypothesis(theCreationCmd) {} + void Process( const Handle(_pyCommand)& theCommand); + void Flush(); + bool Addition2Creation( const Handle(_pyCommand)& theAdditionCmd, + const _pyID& theMesh); + + DEFINE_STANDARD_RTTI (_pyLayerDistributionHypo) +}; +DEFINE_STANDARD_HANDLE (_pyLayerDistributionHypo, _pyHypothesis); + +// ------------------------------------------------------------------------------------- /*! * \brief Class representing NumberOfSegments hypothesis */ +// ------------------------------------------------------------------------------------- class _pyNumberOfSegmentsHyp: public _pyHypothesis { public: @@ -307,9 +352,11 @@ public: }; DEFINE_STANDARD_HANDLE (_pyNumberOfSegmentsHyp, _pyHypothesis); +// ------------------------------------------------------------------------------------- /*! * \brief Class representing smesh.Mesh_Algorithm */ +// ------------------------------------------------------------------------------------- class _pyAlgorithm: public _pyHypothesis { public: diff --git a/src/StdMeshersGUI/Makefile.in b/src/StdMeshersGUI/Makefile.in index 5d7689351..d84f17c24 100644 --- a/src/StdMeshersGUI/Makefile.in +++ b/src/StdMeshersGUI/Makefile.in @@ -44,13 +44,17 @@ LIB_SRC = \ StdMeshersGUI_StdHypothesisCreator.cxx \ StdMeshersGUI_DistrPreview.cxx \ StdMeshersGUI_DistrTable.cxx \ - StdMeshersGUI_NbSegmentsCreator.cxx + StdMeshersGUI_NbSegmentsCreator.cxx \ + StdMeshersGUI_ObjectReferenceParamWdg.cxx \ + StdMeshersGUI_LayerDistributionParamWdg.cxx LIB_MOC = \ StdMeshersGUI_StdHypothesisCreator.h \ StdMeshersGUI_DistrPreview.h \ StdMeshersGUI_DistrTable.h \ - StdMeshersGUI_NbSegmentsCreator.h + StdMeshersGUI_NbSegmentsCreator.h \ + StdMeshersGUI_ObjectReferenceParamWdg.h \ + StdMeshersGUI_LayerDistributionParamWdg.h EXPORT_HEADERS = StdMeshersGUI_StdHypothesisCreator.h diff --git a/src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.cxx b/src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.cxx new file mode 100644 index 000000000..f8c90e728 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.cxx @@ -0,0 +1,199 @@ +// SMESH StdMeshersGUI +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshersGUI_LayerDistributionParamWdg.cxx +// Module : SMESH + +#include "StdMeshersGUI_LayerDistributionParamWdg.h" + +#include +#include +#include +#include + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_HypothesesUtils.h" +#include "SMESHGUI_Hypotheses.h" +// #include "SUIT_ResourceMgr.h" +// #include "LightApp_SelectionMgr.h" +#include "SALOMEDSClient_SObject.hxx" +#include "SALOMEDS_Study.hxx" +#include "SalomeApp_Tools.h" + +//================================================================================ +/*! + * \brief Constructor initialized by filter + * \param f - object filter + */ +//================================================================================ + +StdMeshersGUI_LayerDistributionParamWdg::StdMeshersGUI_LayerDistributionParamWdg +( SMESH::SMESH_Hypothesis_ptr hyp, + QDialog* dlg ): QHGroupBox(), myDlg( dlg ) +{ + init(); + set( hyp ); +// if ( IsOk() ) +// onEdit(); +} + +//================================================================================ +/*! + * \brief initialize fields with hypothesis + * \param hyp - hypothesis + */ +//================================================================================ + +void StdMeshersGUI_LayerDistributionParamWdg::set(SMESH::SMESH_Hypothesis_ptr hyp) +{ + myHyp = SMESH::SMESH_Hypothesis::_nil(); + if ( !CORBA::is_nil( hyp )) { + myHyp = SMESH::SMESH_Hypothesis::_duplicate( hyp ); + myEditButton->setEnabled( true ); + myCreateButton->setText( tr("CHANGE_TYPE")); + myParamValue = hyp->GetName(); + } + else { + myEditButton->setEnabled( false ); + myCreateButton->setText( tr("CREATE")); + myParamValue = ""; + } +} + +//================================================================================ +/*! + * \brief Destructor + */ +//================================================================================ + +StdMeshersGUI_LayerDistributionParamWdg::~StdMeshersGUI_LayerDistributionParamWdg() +{ + if ( myHypTypePopup ) + delete myHypTypePopup; +} + +//================================================================================ +/*! + * \brief Create a leayout, initialize fields + */ +//================================================================================ + +void StdMeshersGUI_LayerDistributionParamWdg::init() +{ + setFrameStyle(QFrame::NoFrame); + setInsideMargin(0); + + mySMESHGUI = SMESHGUI::GetSMESHGUI(); + + myCreateButton = new QPushButton( this, "createBut"); + myEditButton = new QPushButton( tr("EDIT"), this, "createBut"); + +// SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); +// QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT"))); +// mySelButton->setPixmap(iconSlct); +// mySelButton->setToggleButton( true ); + + myHypTypePopup = new QPopupMenu(); + + QStringList aHypTypeNameList = SMESH::GetAvailableHypotheses( false, 0 ); + myHypTypePopup->clear(); + for ( int i = 0, n = aHypTypeNameList.count(); i < n; i++ ) { + myHypTypePopup->insertItem( aHypTypeNameList[ i ] ); + } + + connect( myCreateButton, SIGNAL(clicked()), SLOT(onCreate())); + connect( myEditButton, SIGNAL(clicked()), SLOT(onEdit())); + connect( myHypTypePopup, SIGNAL( activated( int ) ), SLOT( onHypTypePopup( int ) ) ); +} + +//================================================================================ +/*! + * \brief Create a new hyp of selected type + * \param int - selected type index + */ +//================================================================================ + +void StdMeshersGUI_LayerDistributionParamWdg::onHypTypePopup( int theIndex ) +{ + SMESH::SMESH_Gen_var gen = mySMESHGUI->GetSMESHGen(); + + // avoid publishing a new 1D hyp + gen->SetCurrentStudy( SALOMEDS::Study::_nil() ); + + // create a hyp + QString aHypType = myHypTypePopup->text( theIndex ); + HypothesisData* aHypData = SMESH::GetHypothesisData(aHypType.latin1()); + QString aServLib = aHypData->ServerLibName; + try { + set( gen->CreateHypothesis(aHypType, aServLib)); + } + catch (const SALOME::SALOME_Exception & S_ex) { + SalomeApp_Tools::QtCatchCorbaException(S_ex); + } + + // restore current study + mySMESHGUI->GetSMESHGen(); + + onEdit(); +} + +//================================================================================ +/*! + * \brief Show popup with available types + */ +//================================================================================ + +void StdMeshersGUI_LayerDistributionParamWdg::onCreate() +{ + myHypTypePopup->exec( QCursor::pos() ); +} + +//================================================================================ +/*! + * \brief Edit hypothesis + */ +//================================================================================ + +void StdMeshersGUI_LayerDistributionParamWdg::onEdit() +{ + if ( myHyp->_is_nil() ) + return; + + CORBA::String_var hypType = myHyp->GetName(); + SMESHGUI_GenericHypothesisCreator* + editor = SMESH::GetHypothesisCreator( hypType.in() ); + if ( !editor ) return; + + if ( myDlg ) myDlg->hide(); + + try { + QWidget* parent = this; + if ( myDlg ) parent = myDlg->parentWidget(); + editor->edit( myHyp, parent ); + } + catch(...) { + } + + if ( myDlg ) myDlg->show(); +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.h b/src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.h new file mode 100644 index 000000000..fec3785f0 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_LayerDistributionParamWdg.h @@ -0,0 +1,83 @@ +// SMESH StdMeshersGUI +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshersGUI_LayerDistributionParamWdg.h +// Module : SMESH +// $Header$ + +#ifndef StdMeshersGUI_LayerDistributionParamWdg_Header +#define StdMeshersGUI_LayerDistributionParamWdg_Header + +#include +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Hypothesis) + +class SMESHGUI; +class QPushButton; +class QPopupMenu; +class QDialog; + +/*! + * \brief Widget controlling hypothesis parameter that is another hypothesis + */ +class StdMeshersGUI_LayerDistributionParamWdg : public QHGroupBox +{ + Q_OBJECT + +public: + StdMeshersGUI_LayerDistributionParamWdg(SMESH::SMESH_Hypothesis_ptr hyp, + QDialog* dlg); + ~StdMeshersGUI_LayerDistributionParamWdg(); + + SMESH::SMESH_Hypothesis_var GetHypothesis() { return myHyp; } + + QString GetValue() const { return myParamValue; } + + bool IsOk() const { return !myHyp->_is_nil(); } + +private slots: + void onCreate(); + void onEdit(); + void onHypTypePopup( int ); + +private: + void init(); + void set(SMESH::SMESH_Hypothesis_ptr hyp); + +private: + SMESH::SMESH_Hypothesis_var myHyp; + SMESHGUI* mySMESHGUI; + + QPushButton* myCreateButton; + QPushButton* myEditButton; + QPopupMenu* myHypTypePopup; + QDialog* myDlg; + QString myParamValue; + + QStringList myHypTypes; +}; + +#endif + diff --git a/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.cxx b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.cxx new file mode 100644 index 000000000..85ec4d6b4 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.cxx @@ -0,0 +1,206 @@ +// SMESH StdMeshersGUI +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshersGUI_ObjectReferenceParamWdg.cxx +// Module : SMESH + +#include "StdMeshersGUI_ObjectReferenceParamWdg.h" + +#include +#include +#include + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESH_TypeFilter.hxx" +#include "SUIT_ResourceMgr.h" +#include "LightApp_SelectionMgr.h" +#include "SVTK_ViewWindow.h" +#include "SALOME_ListIO.hxx" +#include "SALOMEDSClient_SObject.hxx" + +//================================================================================ +/*! + * \brief Constructor initialized by filter + * \param f - object filter + */ +//================================================================================ + +StdMeshersGUI_ObjectReferenceParamWdg::StdMeshersGUI_ObjectReferenceParamWdg +( SUIT_SelectionFilter* f, QWidget* parent) + : QHGroupBox( parent ) +{ + myFilter = f; + init(); +} + +//================================================================================ +/*! + * \brief Constructor initialized by object type + * \param MeshObjectType - type of object to select + */ +//================================================================================ + +StdMeshersGUI_ObjectReferenceParamWdg::StdMeshersGUI_ObjectReferenceParamWdg +( MeshObjectType objType, QWidget* parent ) + : QHGroupBox( parent ) +{ + myFilter = new SMESH_TypeFilter( objType ); + init(); +} +//================================================================================ +/*! + * \brief Destructor + */ +//================================================================================ + +StdMeshersGUI_ObjectReferenceParamWdg::~StdMeshersGUI_ObjectReferenceParamWdg() +{ + if ( myFilter ) + delete myFilter; +} + + +//================================================================================ +/*! + * \brief Create a leayout, initialize fields + */ +//================================================================================ + +void StdMeshersGUI_ObjectReferenceParamWdg::init() +{ + setFrameStyle(QFrame::NoFrame); + setInsideMargin(0); + + mySMESHGUI = SMESHGUI::GetSMESHGUI(); + mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI ); + mySelectionActivated = false; + myParamValue = ""; + + SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( mySMESHGUI ); + QPixmap iconSlct ( mgr->loadPixmap("SMESH", tr("ICON_SELECT"))); + + mySelButton = new QPushButton(this); + mySelButton->setPixmap(iconSlct); + mySelButton->setToggleButton( true ); + + myObjNameLineEdit = new QLineEdit(this); + myObjNameLineEdit->setReadOnly(true); + + connect( mySelButton, SIGNAL(clicked()), SLOT(activateSelection())); +} + +//================================================================================ +/*! + * \brief SLOT: Installs selection filter that is not done automatically + */ +//================================================================================ + +void StdMeshersGUI_ObjectReferenceParamWdg::activateSelection() +{ + if ( !mySelectionActivated && mySelectionMgr ) + { + mySelectionActivated = true; + mySelectionMgr->clearFilters(); + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode(ActorSelection); + if ( myFilter ) + mySelectionMgr->installFilter( myFilter ); + connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), SLOT(onSelectionDone())); + } + emit selectionActivated(); + + mySelButton->setOn( mySelectionActivated ); +} + +//================================================================================ +/*! + * \brief SLOT: stop treating selection changes + */ +//================================================================================ + +void StdMeshersGUI_ObjectReferenceParamWdg::deactivateSelection() +{ + mySelectionActivated = false; + disconnect(mySelectionMgr, 0, this, 0 ); + mySelectionMgr->removeFilter( myFilter ); + + mySelButton->setOn( mySelectionActivated ); +} + +//================================================================================ +/*! + * \brief Connect selection slots + * \param other - another StdMeshersGUI_ObjectReferenceParamWdg + */ +//================================================================================ + +void StdMeshersGUI_ObjectReferenceParamWdg::AvoidSimultaneousSelection + ( StdMeshersGUI_ObjectReferenceParamWdg* other) +{ + connect(other, SIGNAL(selectionActivated()), this, SLOT(deactivateSelection())); + connect(this, SIGNAL(selectionActivated()), other, SLOT(deactivateSelection())); +} + +//================================================================================ +/*! + * \brief Initialize selected object name + * \param obj - the current object + */ +//================================================================================ + +void StdMeshersGUI_ObjectReferenceParamWdg::SetObject(CORBA::Object_ptr obj) +{ + myObject = CORBA::Object::_nil(); + myObjNameLineEdit->setText( "" ); + myParamValue = ""; + + _PTR(SObject) sobj; + if ( !CORBA::is_nil( obj )) + sobj = SMESH::FindSObject (obj); + if ( sobj ) { + string name = sobj->GetName(); + myObjNameLineEdit->setText( name.c_str() ); + myObject = CORBA::Object::_duplicate( obj ); + myParamValue = sobj->GetID(); + } +} + +//================================================================================ +/*! + * \brief Takes selected object + */ +//================================================================================ + +void StdMeshersGUI_ObjectReferenceParamWdg::onSelectionDone() +{ + if ( mySelectionActivated ) { + CORBA::Object_var obj; + SALOME_ListIO aList; + mySelectionMgr->selectedObjects(aList); + if (aList.Extent() == 1) + obj = SMESH::IObjectToObject( aList.First() ); + SetObject( obj.in() ); + } +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h new file mode 100644 index 000000000..c9d987424 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_ObjectReferenceParamWdg.h @@ -0,0 +1,109 @@ +// SMESH StdMeshersGUI +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshersGUI_ObjectReferenceParamWdg.h +// Module : SMESH +// $Header$ + +#ifndef StdMeshersGUI_ObjectReferenceParamWdg_Header +#define StdMeshersGUI_ObjectReferenceParamWdg_Header + +#include "SMESH_Type.h" +#include "qhgroupbox.h" + +#include + +class SUIT_SelectionFilter; +class SMESHGUI; +class LightApp_SelectionMgr; +class QLineEdit; +class QPushButton; + +/*! + * \brief Widget controlling hypothesis parameter that is an object reference + */ +class StdMeshersGUI_ObjectReferenceParamWdg : public QHGroupBox +{ + Q_OBJECT + +public: + StdMeshersGUI_ObjectReferenceParamWdg( SUIT_SelectionFilter* filter, + QWidget* parent); + StdMeshersGUI_ObjectReferenceParamWdg( MeshObjectType objType, + QWidget* parent); + ~StdMeshersGUI_ObjectReferenceParamWdg(); + + void SetObject(CORBA::Object_ptr obj); + + template + typename TInterface::_var_type GetObject() const { + if ( IsObjectSelected() ) return TInterface::_narrow(myObject); + return TInterface::_nil(); + } + + QString GetValue() const { return myParamValue; } + + bool IsObjectSelected() const { return !CORBA::is_nil(myObject); } + + void AvoidSimultaneousSelection( StdMeshersGUI_ObjectReferenceParamWdg* other); + +public slots: + /*! + * \brief Activates selection (if not yet done), emits selectionActivated() + * + * Useful to deactivate one Object Reference param widget when an other + * one is activated + */ + void activateSelection(); + void deactivateSelection(); + +signals: + /*! + * \brief Emitted when selection is activated + * + * Useful to deactivate one Object Reference param widget when an other + * one is activated + */ + void selectionActivated(); + +private slots: + void onSelectionDone(); + +private: + void init(); + +private: + CORBA::Object_var myObject; + SUIT_SelectionFilter* myFilter; + bool mySelectionActivated; + + SMESHGUI* mySMESHGUI; + LightApp_SelectionMgr* mySelectionMgr; + + QLineEdit* myObjNameLineEdit; + QPushButton* mySelButton; + QString myParamValue; +}; + +#endif + diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index e90634cf7..76a946c65 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -27,12 +27,16 @@ #include "StdMeshersGUI_StdHypothesisCreator.h" -#include -#include -#include -#include +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_HypothesesUtils.h" +#include "SMESHGUI_Utils.h" +#include "SMESH_TypeFilter.hxx" +#include "SMESH_NumberFilter.hxx" +#include "StdMeshersGUI_ObjectReferenceParamWdg.h" +#include "StdMeshersGUI_LayerDistributionParamWdg.h" -#include +#include "SUIT_ResourceMgr.h" #include #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) @@ -51,30 +55,311 @@ const double VALUE_MAX = 1.0e+15, // COORD_MAX VALUE_SMALL_2 = VALUE_SMALL * VALUE_SMALL, VALUE_SMALL_3 = VALUE_SMALL_2 * VALUE_SMALL; +//================================================================================ +/*! + * \brief Constructor + * \param type - hypothesis type + */ +//================================================================================ + StdMeshersGUI_StdHypothesisCreator::StdMeshersGUI_StdHypothesisCreator( const QString& type ) : SMESHGUI_GenericHypothesisCreator( type ) { } +//================================================================================ +/*! + * \brief Destructor + */ +//================================================================================ + StdMeshersGUI_StdHypothesisCreator::~StdMeshersGUI_StdHypothesisCreator() { } +//================================================================================ +/*! + * \brief Return widget for i-th hypothesis parameter (got from myParamWidgets) + * \param i - index of hypothesis parameter + * \retval QWidget* - found widget + */ +//================================================================================ + +QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const +{ + QWidget* w = 0; + if ( isCreation() ) ++i; // skip widget of 'name' parameter + + if ( i < myCustomWidgets.count() ) { + QPtrList::const_iterator anIt = myCustomWidgets.begin(); + QPtrList::const_iterator aLast = myCustomWidgets.end(); + for ( int j = 0 ; !w && anIt != aLast; ++anIt ) + if ( i == j ) + w = *anIt; + } + if ( !w ) { + // list has no at() const, so we iterate + QPtrList::const_iterator anIt = widgets().begin(); + QPtrList::const_iterator aLast = widgets().end(); + for( int j = 0; !w && anIt!=aLast; anIt++, ++j ) { + if ( i == j ) + w = *anIt; + } + } + return w; +} + +//================================================================================ +/*! + * \brief Allow modifing myCustomWidgets in const methods + * \retval ListOfWidgets* - non-const pointer to myCustomWidgets + */ +//================================================================================ + +StdMeshersGUI_StdHypothesisCreator::ListOfWidgets* +StdMeshersGUI_StdHypothesisCreator::customWidgets() const +{ + return const_cast< ListOfWidgets* >( & myCustomWidgets ); +} + +//================================================================================ +/*! + * \brief Builds dlg layout + * \retval QFrame* - the built widget + */ +//================================================================================ + QFrame* StdMeshersGUI_StdHypothesisCreator::buildFrame() { return buildStdFrame(); } -bool StdMeshersGUI_StdHypothesisCreator::checkParams() const +//================================================================================ +/*! + * \brief Initialise parameter values in controls + */ +//================================================================================ + +void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const { - return true; + // buildStdFrame() sets values itself calling stdParams() + + if ( hypType().startsWith("ProjectionSource" )) + { + // we use this method to connect depending custom widgets + StdMeshersGUI_ObjectReferenceParamWdg* widgetToActivate = 0; + ListOfWidgets::const_iterator anIt = myCustomWidgets.begin(); + for ( ; anIt != myCustomWidgets.end(); anIt++) + { + if ( *anIt && (*anIt)->inherits("StdMeshersGUI_ObjectReferenceParamWdg")) + { + StdMeshersGUI_ObjectReferenceParamWdg * w1 = + ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt ); + ListOfWidgets::const_iterator anIt2 = anIt; + for ( ++anIt2; anIt2 != myCustomWidgets.end(); anIt2++) + if ( *anIt2 && (*anIt2)->inherits("StdMeshersGUI_ObjectReferenceParamWdg")) + { + StdMeshersGUI_ObjectReferenceParamWdg * w2 = + ( StdMeshersGUI_ObjectReferenceParamWdg* ) ( *anIt2 ); + w1->AvoidSimultaneousSelection( w2 ); + } + if ( !widgetToActivate ) + widgetToActivate = w1; + } + } + if ( widgetToActivate ) + widgetToActivate->activateSelection(); + } } -void StdMeshersGUI_StdHypothesisCreator::retrieveParams() const +//================================================================================ +/*! + * \brief Widget: slider with left and right labels + */ +//================================================================================ + +class TDoubleSliderWith2Lables: public QHBox +{ +public: + TDoubleSliderWith2Lables( const QString& leftLabel, const QString& rightLabel, + const double initValue, const double bottom, + const double top , const double precision, + QWidget * parent=0 , const char * name=0 ) + :QHBox(parent,name), _bottom(bottom), _precision(precision) + { + if ( !leftLabel.isEmpty() ) (new QLabel( this ))->setText( leftLabel ); + _slider = new QSlider( Horizontal, this ); + _slider->setRange( 0, toInt( top )); + _slider->setValue( toInt( initValue )); + if ( !rightLabel.isEmpty() ) (new QLabel( this ))->setText( rightLabel ); + } + double value() const { return _bottom + _slider->value() * _precision; } + QSlider * getSlider() const { return _slider; } + int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); } +private: + double _bottom, _precision; + QSlider * _slider; +}; + +namespace { + + //================================================================================ + /*! + * \brief Retrieve GEOM_Object held by widget + */ + //================================================================================ + + inline GEOM::GEOM_Object_var geomFromWdg(const QWidget* wdg) + { + const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg = + dynamic_cast( wdg ); + if ( objRefWdg ) + return objRefWdg->GetObject< GEOM::GEOM_Object >(); + + return GEOM::GEOM_Object::_nil(); + } + //================================================================================ + /*! + * \brief Retrieve SMESH_Mesh held by widget + */ + //================================================================================ + + inline SMESH::SMESH_Mesh_var meshFromWdg(const QWidget* wdg) + { + const StdMeshersGUI_ObjectReferenceParamWdg * objRefWdg = + dynamic_cast( wdg ); + if ( objRefWdg ) + return objRefWdg->GetObject< SMESH::SMESH_Mesh >(); + + return SMESH::SMESH_Mesh::_nil(); + } + //================================================================================ + /*! + * \brief creates a filter for selection of shapes of given dimension + * \param dim - dimension + * \param subShapeType - required type of subshapes, number of which must be \a nbSubShapes + * \param nbSubShapes - number of subshapes of given type + * \param closed - required closeness flag of a shape + * \retval SUIT_SelectionFilter* - created filter + */ + //================================================================================ + + SUIT_SelectionFilter* filterForShapeOfDim(const int dim, + const int nbSubShapes = 0, + const TopAbs_ShapeEnum subShapeType = TopAbs_SHAPE, + const bool closed = false) + { + TColStd_MapOfInteger shapeTypes; + switch ( dim ) { + case 0: shapeTypes.Add( TopAbs_VERTEX ); break; + case 1: shapeTypes.Add( TopAbs_EDGE ); break; + case 2: shapeTypes.Add( TopAbs_FACE ); break; + case 3: + shapeTypes.Add( TopAbs_SHELL ); + shapeTypes.Add( TopAbs_SOLID ); + shapeTypes.Add( TopAbs_COMPSOLID ); + shapeTypes.Add( TopAbs_COMPOUND ); + break; + } + return new SMESH_NumberFilter("GEOM", subShapeType, nbSubShapes, + shapeTypes, GEOM::GEOM_Object::_nil(), closed); + } + + //================================================================================ + /*! + * \brief Create a widget for object selection + * \param object - initial object + * \param filter - selection filter + * \retval QWidget* - created widget + */ + //================================================================================ + + QWidget* newObjRefParamWdg( SUIT_SelectionFilter* filter, + CORBA::Object_var object) + { + StdMeshersGUI_ObjectReferenceParamWdg* w = + new StdMeshersGUI_ObjectReferenceParamWdg( filter, 0); + w->SetObject( object.in() ); + return w; + } + + //================================================================================ + /*! + * \brief calls deactivateSelection() for StdMeshersGUI_ObjectReferenceParamWdg + * \param widgetList - list of widgets + */ + //================================================================================ + + void deactivateObjRefParamWdg( QPtrList* widgetList ) + { + StdMeshersGUI_ObjectReferenceParamWdg* w = 0; + QPtrList::iterator anIt = widgetList->begin(); + QPtrList::iterator aLast = widgetList->end(); + for ( ; anIt != aLast; anIt++ ) { + if ( (*anIt) && (*anIt)->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" )) + { + w = (StdMeshersGUI_ObjectReferenceParamWdg* )( *anIt ); + w->deactivateSelection(); + } + } + } +} + +//================================================================================ +/*! + * \brief Check parameter values before accept() + * \retval bool - true if OK + */ +//================================================================================ + +bool StdMeshersGUI_StdHypothesisCreator::checkParams() const { - //here this method must be empty because buildStdParam sets values itself + // check if object reference parameter is set, as it has no default value + bool ok = true; + if ( hypType().startsWith("ProjectionSource" )) + { + StdMeshersGUI_ObjectReferenceParamWdg* w = + widget< StdMeshersGUI_ObjectReferenceParamWdg >( 0 ); + ok = ( w->IsObjectSelected() ); + if ( !ok ) w->SetObject( CORBA::Object::_nil() ); + int nbAssocVert = ( hypType() == "ProjectionSource1D" ? 1 : 2 ); + for ( int i = 0; ok && i < nbAssocVert; i += 2) + { + QString srcV, tgtV; + StdMeshersGUI_ObjectReferenceParamWdg* w1 = + widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+2 ); + StdMeshersGUI_ObjectReferenceParamWdg* w2 = + widget< StdMeshersGUI_ObjectReferenceParamWdg >( i+3 ); + srcV = w1->GetValue(); + tgtV = w2->GetValue(); + ok = (( srcV.isEmpty() && tgtV.isEmpty() ) || + ( !srcV.isEmpty() && !tgtV.isEmpty() && srcV != tgtV )); + if ( !ok ) { + w1->SetObject( CORBA::Object::_nil() ); + w2->SetObject( CORBA::Object::_nil() ); + } + } + + // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg + if ( ok ) + deactivateObjRefParamWdg( customWidgets() ); + } + else if ( hypType() == "LayerDistribution" ) + { + StdMeshersGUI_LayerDistributionParamWdg* w = + widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 ); + ok = ( w && w->IsOk() ); + } + return ok; } +//================================================================================ +/*! + * \brief Store params from GUI controls to a hypothesis + * \retval QString - text representation of parameters + */ +//================================================================================ + QString StdMeshersGUI_StdHypothesisCreator::storeParams() const { ListOfStdParams params; @@ -140,22 +425,89 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const h->SetFineness( params[0].myValue.toDouble() ); } + else if( hypType()=="NumberOfLayers" ) + { + StdMeshers::StdMeshers_NumberOfLayers_var h = + StdMeshers::StdMeshers_NumberOfLayers::_narrow( hypothesis() ); + + h->SetNumberOfLayers( params[0].myValue.toInt() ); + } + else if( hypType()=="LayerDistribution" ) + { + StdMeshers::StdMeshers_LayerDistribution_var h = + StdMeshers::StdMeshers_LayerDistribution::_narrow( hypothesis() ); + StdMeshersGUI_LayerDistributionParamWdg* w = + widget< StdMeshersGUI_LayerDistributionParamWdg >( 0 ); + + h->SetLayerDistribution( w->GetHypothesis() ); + } + else if( hypType()=="ProjectionSource1D" ) + { + StdMeshers::StdMeshers_ProjectionSource1D_var h = + StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hypothesis() ); + + h->SetSourceEdge ( geomFromWdg ( getWidgetForParam( 0 ))); + h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 ))); + h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), + geomFromWdg ( getWidgetForParam( 3 ))); + } + else if( hypType()=="ProjectionSource2D" ) + { + StdMeshers::StdMeshers_ProjectionSource2D_var h = + StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hypothesis() ); + + h->SetSourceFace ( geomFromWdg ( getWidgetForParam( 0 ))); + h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 ))); + h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1 + geomFromWdg ( getWidgetForParam( 4 )), // src2 + geomFromWdg ( getWidgetForParam( 3 )), // tgt1 + geomFromWdg ( getWidgetForParam( 5 ))); // tgt2 + } + else if( hypType()=="ProjectionSource3D" ) + { + StdMeshers::StdMeshers_ProjectionSource3D_var h = + StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hypothesis() ); + + h->SetSource3DShape ( geomFromWdg ( getWidgetForParam( 0 ))); + h->SetSourceMesh ( meshFromWdg ( getWidgetForParam( 1 ))); + h->SetVertexAssociation( geomFromWdg ( getWidgetForParam( 2 )), // src1 + geomFromWdg ( getWidgetForParam( 4 )), // src2 + geomFromWdg ( getWidgetForParam( 3 )), // tgt1 + geomFromWdg ( getWidgetForParam( 5 ))); // tgt2 + } } return valueStr; } +//================================================================================ +/*! + * \brief Return parameter values as SMESHGUI_GenericHypothesisCreator::StdParam + * \param p - list of parameters + * \retval bool - success flag + * + * Is called from SMESHGUI_GenericHypothesisCreator::buildStdFrame(). + * Parameters will be shown using "standard" controls: + * Int by QtxIntSpinBox + * Double by SMESHGUI_SpinBox + * String by QLineEdit + * getCustomWidget() allows to redefine control for a parameter + */ +//================================================================================ + bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const { bool res = true; SMESHGUI_GenericHypothesisCreator::StdParam item; p.clear(); + customWidgets()->clear(); if( isCreation() ) { HypothesisData* data = SMESH::GetHypothesisData( hypType() ); item.myName = tr( "SMESH_NAME" ); item.myValue = data ? data->Label : QString(); p.append( item ); + customWidgets()->append(0); } SMESH::SMESH_Hypothesis_var hyp = initParamsHypothesis(); @@ -226,14 +578,108 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const StdMeshers::StdMeshers_AutomaticLength::_narrow( hyp ); item.myName = tr( "SMESH_FINENESS_PARAM" ); - item.myValue = h->GetFineness(); + //item.myValue = h->GetFineness(); p.append( item ); + customWidgets()->append + ( new TDoubleSliderWith2Lables( "0 ", " 1", h->GetFineness(), 0, 1, 0.01, 0 )); + } + else if( hypType()=="NumberOfLayers" ) + { + StdMeshers::StdMeshers_NumberOfLayers_var h = + StdMeshers::StdMeshers_NumberOfLayers::_narrow( hyp ); + + item.myName = tr( "SMESH_NUMBER_OF_LAYERS" ); + item.myValue = (int) h->GetNumberOfLayers(); + p.append( item ); + } + else if( hypType()=="LayerDistribution" ) + { + StdMeshers::StdMeshers_LayerDistribution_var h = + StdMeshers::StdMeshers_LayerDistribution::_narrow( hyp ); + + item.myName = tr( "SMESH_LAYERS_DISTRIBUTION" ); p.append( item ); + customWidgets()->append + ( new StdMeshersGUI_LayerDistributionParamWdg( h->GetLayerDistribution(), dlg())); + } + else if( hypType()=="ProjectionSource1D" ) + { + StdMeshers::StdMeshers_ProjectionSource1D_var h = + StdMeshers::StdMeshers_ProjectionSource1D::_narrow( hyp ); + + item.myName = tr( "SMESH_SOURCE_EDGE" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 1 ), + h->GetSourceEdge())); + item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ), + h->GetSourceMesh())); + item.myName = tr( "SMESH_SOURCE_VERTEX" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetSourceVertex())); + item.myName = tr( "SMESH_TARGET_VERTEX" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetTargetVertex())); + } + else if( hypType()=="ProjectionSource2D" ) + { + StdMeshers::StdMeshers_ProjectionSource2D_var h = + StdMeshers::StdMeshers_ProjectionSource2D::_narrow( hyp ); + + item.myName = tr( "SMESH_SOURCE_FACE" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 2 ), + h->GetSourceFace())); + item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ), + h->GetSourceMesh())); + item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetSourceVertex( 1 ))); + item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetTargetVertex( 1 ))); + item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetSourceVertex( 2 ))); + item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetTargetVertex( 2 ))); + } + else if( hypType()=="ProjectionSource3D" ) + { + StdMeshers::StdMeshers_ProjectionSource3D_var h = + StdMeshers::StdMeshers_ProjectionSource3D::_narrow( hyp ); + + item.myName = tr( "SMESH_SOURCE_3DSHAPE" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 3 , 6, TopAbs_FACE, true ), + h->GetSource3DShape())); + item.myName = tr( "SMESH_SOURCE_MESH" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( new SMESH_TypeFilter( MESH ), + h->GetSourceMesh())); + item.myName = tr( "SMESH_SOURCE_VERTEX1" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetSourceVertex( 1 ))); + item.myName = tr( "SMESH_TARGET_VERTEX1" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetTargetVertex( 1 ))); + item.myName = tr( "SMESH_SOURCE_VERTEX2" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetSourceVertex( 2 ))); + item.myName = tr( "SMESH_TARGET_VERTEX2" ); p.append( item ); + customWidgets()->append( newObjRefParamWdg( filterForShapeOfDim( 0 ), + h->GetTargetVertex( 2 ))); } else res = false; return res; } +//================================================================================ +/*! + * \brief tune "standard" control + * \param w - control widget + * \param int - parameter index + */ +//================================================================================ + void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget( QWidget* w, const int ) const { SMESHGUI_SpinBox* sb = w->inherits( "SMESHGUI_SpinBox" ) ? ( SMESHGUI_SpinBox* )w : 0; @@ -267,22 +713,52 @@ void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget( QWidget* w, const int } } +//================================================================================ +/*! + * \brief Return dlg title + * \retval QString - title string + */ +//================================================================================ + QString StdMeshersGUI_StdHypothesisCreator::caption() const { return tr( QString( "SMESH_%1_TITLE" ).arg( hypTypeName( hypType() ) ) ); } +//================================================================================ +/*! + * \brief return pixmap for dlg icon + * \retval QPixmap - + */ +//================================================================================ + QPixmap StdMeshersGUI_StdHypothesisCreator::icon() const { QString hypIconName = tr( QString( "ICON_DLG_%1" ).arg( hypTypeName( hypType() ) ) ); return SMESHGUI::resourceMgr()->loadPixmap( "SMESH", hypIconName ); } +//================================================================================ +/*! + * \brief Return hypothesis type name to show in dlg + * \retval QString - + */ +//================================================================================ + QString StdMeshersGUI_StdHypothesisCreator::type() const { return tr( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeName( hypType() ) ) ); } +//================================================================================ +/*! + * \brief String to insert in "SMESH_%1_HYPOTHESIS" to get hypothesis type name + * from message resouce file + * \param t - hypothesis type + * \retval QString - result string + */ +//================================================================================ + QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) const { static QMap types; @@ -296,6 +772,11 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons types.insert( "Deflection1D", "DEFLECTION1D" ); types.insert( "Arithmetic1D", "ARITHMETIC_1D" ); types.insert( "AutomaticLength", "AUTOMATIC_LENGTH" ); + types.insert( "ProjectionSource1D", "PROJECTION_SOURCE_1D" ); + types.insert( "ProjectionSource2D", "PROJECTION_SOURCE_2D" ); + types.insert( "ProjectionSource3D", "PROJECTION_SOURCE_3D" ); + types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" ); + types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" ); } QString res; @@ -305,54 +786,35 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons return res; } -//================================================================================ -/*! - * \brief Widget: slider with left and right labels - */ -//================================================================================ - -class TDoubleSliderWith2Lables: public QHBox -{ -public: - TDoubleSliderWith2Lables( const QString& leftLabel, const QString& rightLabel, - const double initValue, const double bottom, - const double top , const double precision, - QWidget * parent=0 , const char * name=0 ) - :QHBox(parent,name), _bottom(bottom), _precision(precision) - { - if ( !leftLabel.isEmpty() ) (new QLabel( this ))->setText( leftLabel ); - _slider = new QSlider( Horizontal, this ); - _slider->setRange( 0, toInt( top )); - _slider->setValue( toInt( initValue )); - if ( !rightLabel.isEmpty() ) (new QLabel( this ))->setText( rightLabel ); - } - double value() const { return _bottom + _slider->value() * _precision; } - QSlider * getSlider() const { return _slider; } - int toInt( double val ) const { return (int) ceil(( val - _bottom ) / _precision ); } -private: - double _bottom, _precision; - QSlider * _slider; -}; //======================================================================= //function : getCustomWidget -//purpose : +//purpose : is called from buildStdFrame() //======================================================================= QWidget* StdMeshersGUI_StdHypothesisCreator::getCustomWidget( const StdParam & param, - QWidget* parent) const + QWidget* parent, + const int index) const { - if ( hypType()=="AutomaticLength" && param.myValue.type() == QVariant::Double ) - return new TDoubleSliderWith2Lables( "0 ", " 1", param.myValue.toDouble(), - 0, 1, 0.01, parent ); - - return 0; + QWidget* w = 0; + if ( index < customWidgets()->count() ) { + w = customWidgets()->at( index ); + if ( w ) + w->reparent( parent, QPoint( 0, 0 )); + } + return w; } -//======================================================================= -//function : getParamFromCustomWidget -//purpose : -//======================================================================= +//================================================================================ +/*! + * \brief Set param value taken from a custom widget + * \param param - SMESHGUI_GenericHypothesisCreator::StdParam structure + * \param widget - widget presenting param + * \retval bool - success flag + * + * this method is called from getStdParamFromDlg() + */ +//================================================================================ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & param, QWidget* widget) const @@ -364,5 +826,37 @@ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & pa return true; } } + if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" )) + { + // show only 1st reference value + if ( true /*widget == getWidgetForParam( 0 )*/) { + const StdMeshersGUI_ObjectReferenceParamWdg * w = + static_cast( widget ); + param.myValue = w->GetValue(); + } + return true; + } + if ( widget->inherits( "StdMeshersGUI_LayerDistributionParamWdg" )) + { + const StdMeshersGUI_LayerDistributionParamWdg * w = + static_cast( widget ); + param.myValue = w->GetValue(); + return true; + } return false; } + +//================================================================================ +/*! + * \brief called when operation cancelled + */ +//================================================================================ + +void StdMeshersGUI_StdHypothesisCreator::onReject() +{ + if ( hypType().startsWith("ProjectionSource" )) + { + // Uninstall filters of StdMeshersGUI_ObjectReferenceParamWdg + deactivateObjRefParamWdg( customWidgets() ); + } +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h index c5c2c8db0..bbf1037f7 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h @@ -28,10 +28,11 @@ #ifndef STDMESHERSGUI_StdHypothesisCreator_HeaderFile #define STDMESHERSGUI_StdHypothesisCreator_HeaderFile +#include #include /*! - * \brief Class for creation of simple hypotheses (only set of parameters without dependencies) + * \brief Class for creation of standard hypotheses */ class StdMeshersGUI_StdHypothesisCreator : public SMESHGUI_GenericHypothesisCreator { @@ -52,10 +53,20 @@ protected: virtual QString caption() const; virtual QPixmap icon() const; virtual QString type() const; - virtual QWidget* getCustomWidget( const StdParam&, QWidget* ) const; + virtual QWidget* getCustomWidget( const StdParam&, QWidget*, const int ) const; virtual bool getParamFromCustomWidget( StdParam& , QWidget* ) const; - virtual QString hypTypeName( const QString& ) const; + virtual QString hypTypeName( const QString& ) const; + virtual QWidget* getWidgetForParam( int paramIndex ) const; + virtual ListOfWidgets* customWidgets() const; + virtual void onReject(); + + template + T* widget(int i) const { + return dynamic_cast< T* >( getWidgetForParam( i )); + } + + ListOfWidgets myCustomWidgets; }; #endif diff --git a/src/StdMeshersGUI/StdMeshers_images.po b/src/StdMeshersGUI/StdMeshers_images.po index c7397e2e1..5c8ff756a 100644 --- a/src/StdMeshersGUI/StdMeshers_images.po +++ b/src/StdMeshersGUI/StdMeshers_images.po @@ -38,111 +38,131 @@ msgstr "select1.png" # Hypothesis creation, see StdMeshersGUI_CreateStdHypothesisDlg() #----------------------------------------------------------------- -#Hypo Local Length msgid "ICON_DLG_LOCAL_LENGTH" msgstr "mesh_hypo_length.png" -#Hypo Nb Segments msgid "ICON_DLG_NB_SEGMENTS" msgstr "mesh_hypo_segment.png" -#Hypo Max Area msgid "ICON_DLG_MAX_ELEMENT_AREA" msgstr "mesh_hypo_area.png" -#Hypo Max Volume msgid "ICON_DLG_MAX_ELEMENT_VOLUME" msgstr "mesh_hypo_volume.png" -#Hypo Start End Length msgid "ICON_DLG_START_END_LENGTH" msgstr "mesh_hypo_length.png" -#Hypo deflection 1D msgid "ICON_DLG_DEFLECTION1D" msgstr "mesh_hypo_length.png" -#Hypo Geometric 1D msgid "ICON_DLG_GEOMETRIC_1D" msgstr "mesh_hypo_length.png" -#Hypo Arithmetic 1D msgid "ICON_DLG_ARITHMETIC_1D" msgstr "mesh_hypo_length.png" -#Hypo AutomaticLength msgid "ICON_DLG_AUTOMATIC_LENGTH" msgstr "mesh_hypo_length.png" +msgid "ICON_DLG_NUMBER_OF_LAYERS" +msgstr "mesh_hypo_layer_distribution.png" + +msgid "ICON_DLG_LAYER_DISTRIBUTION" +msgstr "mesh_hypo_layer_distribution.png" + +msgid "ICON_DLG_PROJECTION_SOURCE_1D" +msgstr "mesh_hypo_source_edge.png" + +msgid "ICON_DLG_PROJECTION_SOURCE_2D" +msgstr "mesh_hypo_source_face.png" + +msgid "ICON_DLG_PROJECTION_SOURCE_3D" +msgstr "mesh_hypo_source_3d.png" + #----------------------------------------------------------- # ObjectBrowser #----------------------------------------------------------- -#mesh_tree_algo_regular msgid "ICON_SMESH_TREE_ALGO_Regular_1D" msgstr "mesh_tree_algo_regular.png" -#mesh_tree_algo_hexa msgid "ICON_SMESH_TREE_ALGO_Hexa_3D" msgstr "mesh_tree_algo_hexa.png" -#mesh_tree_algo_mefisto msgid "ICON_SMESH_TREE_ALGO_MEFISTO_2D" msgstr "mesh_tree_algo_mefisto.png" -#mesh_tree_algo_quad msgid "ICON_SMESH_TREE_ALGO_Quadrangle_2D" msgstr "mesh_tree_algo_quad.png" -#mesh_tree_hypo_area msgid "ICON_SMESH_TREE_HYPO_MaxElementArea" msgstr "mesh_tree_hypo_area.png" -#mesh_tree_hypo_quadranglepreference msgid "ICON_SMESH_TREE_HYPO_QuadranglePreference" msgstr "mesh_tree_algo_quad.png" -#mesh_tree_hypo_quadraticmesh msgid "ICON_SMESH_TREE_HYPO_QuadraticMesh" msgstr "mesh_tree_hypo_length.png" -#mesh_tree_hypo_length msgid "ICON_SMESH_TREE_HYPO_LocalLength" msgstr "mesh_tree_hypo_length.png" -#mesh_tree_hypo_segment msgid "ICON_SMESH_TREE_HYPO_NumberOfSegments" msgstr "mesh_tree_hypo_segment.png" -#mesh_tree_hypo_volume msgid "ICON_SMESH_TREE_HYPO_MaxElementVolume" msgstr "mesh_tree_hypo_volume.png" -#mesh_tree_hypo_length msgid "ICON_SMESH_TREE_HYPO_LengthFromEdges" msgstr "mesh_tree_hypo_area.png" -#mesh_tree_hypo_nonconform msgid "ICON_SMESH_TREE_HYPO_NotConformAllowed" msgstr "mesh_tree_hypo_length.png" -#mesh_tree_hypo_start_end_length msgid "ICON_SMESH_TREE_HYPO_StartEndLength" msgstr "mesh_tree_hypo_length.png" -#mesh_tree_hypo_deflection1d msgid "ICON_SMESH_TREE_HYPO_Deflection1D" msgstr "mesh_tree_hypo_length.png" -#mesh_tree_hypo_Arithmetic1d msgid "ICON_SMESH_TREE_HYPO_Arithmetic1D" msgstr "mesh_tree_hypo_length.png" -#mesh_tree_hypo_AutomaticLength msgid "ICON_SMESH_TREE_HYPO_AutomaticLength" msgstr "mesh_tree_hypo_length.png" -#mesh_tree_hypo_propagation msgid "ICON_SMESH_TREE_HYPO_Propagation" msgstr "mesh_tree_hypo_length.png" + + +msgid "ICON_SMESH_TREE_ALGO_RadialPrism_3D" +msgstr "mesh_tree_algo_radial_prism.png" + +msgid "ICON_SMESH_TREE_ALGO_Prism_3D" +msgstr "mesh_tree_algo_projection_3d.png" + +msgid "ICON_SMESH_TREE_ALGO_Projection_3D" +msgstr "mesh_tree_hypo_projection_3d.png" + +msgid "ICON_SMESH_TREE_ALGO_Projection_2D" +msgstr "mesh_tree_algo_projection_2d.png" + +msgid "ICON_SMESH_TREE_ALGO_Projection_1D" +msgstr "mesh_tree_algo_regular.png" + +msgid "ICON_SMESH_TREE_HYPO_NumberOfLayers" +msgstr "mesh_tree_hypo_layers_distribution.png" + +msgid "ICON_SMESH_TREE_HYPO_LayerDistribution" +msgstr "mesh_tree_hypo_layers_distribution.png" + +msgid "ICON_SMESH_TREE_HYPO_ProjectionSource1D" +msgstr "mesh_tree_hypo_source_edge.png" + +msgid "ICON_SMESH_TREE_HYPO_ProjectionSource2D" +msgstr "mesh_tree_hypo_source_face.png" + +msgid "ICON_SMESH_TREE_HYPO_ProjectionSource3D" +msgstr "mesh_tree_hypo_source_3d_shape.png" diff --git a/src/StdMeshersGUI/StdMeshers_msg_en.po b/src/StdMeshersGUI/StdMeshers_msg_en.po index b7d2616da..b1842159e 100644 --- a/src/StdMeshersGUI/StdMeshers_msg_en.po +++ b/src/StdMeshersGUI/StdMeshers_msg_en.po @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "POT-Creation-Date: 2002-05-28 10:46:48 AM CEST\n" -"PO-Revision-Date: YYYY-MM-DD\n" +"PO-Revision-Date: 2006-11-14 16:17+0300\n" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" @@ -175,3 +175,84 @@ msgstr "Fineness" msgid "SMESH_AUTOMATIC_LENGTH_TITLE" msgstr "Hypothesis Construction" + + +# -------------- PROJECTION_SOURCE_... -------------- + +msgid "SMESH_PROJECTION_SOURCE_1D_HYPOTHESIS" +msgstr "Projection Source 1D" +msgid "SMESH_PROJECTION_SOURCE_2D_HYPOTHESIS" +msgstr "Projection Source 2D" +msgid "SMESH_PROJECTION_SOURCE_3D_HYPOTHESIS" +msgstr "Projection Source 3D" + +msgid "SMESH_PROJECTION_SOURCE_1D_TITLE" +msgstr "Hypothesis Construction" +msgid "SMESH_PROJECTION_SOURCE_2D_TITLE" +msgstr "Hypothesis Construction" +msgid "SMESH_PROJECTION_SOURCE_3D_TITLE" +msgstr "Hypothesis Construction" + +msgid "SMESH_SOURCE_MESH" +msgstr "Mesh" + +msgid "SMESH_SOURCE_EDGE" +msgstr "Edge" + +msgid "SMESH_SOURCE_FACE" +msgstr "Face" + +msgid "SMESH_SOURCE_3DSHAPE" +msgstr "3D shape" + +msgid "SMESH_SOURCE_VERTEX" +msgstr "Source Vertex" + +msgid "SMESH_TARGET_VERTEX" +msgstr "Target Vertex" + +msgid "SMESH_SOURCE_VERTEX1" +msgstr "Source Vertex 1" + +msgid "SMESH_TARGET_VERTEX1" +msgstr "Target Vertex 1" + +msgid "SMESH_SOURCE_VERTEX2" +msgstr "Source Vertex 2" + +msgid "SMESH_TARGET_VERTEX2" +msgstr "Target Vertex 2" + + +# ---------------- NUMBER_OF_LAYERS ---------------- + +msgid "SMESH_NUMBER_OF_LAYERS_HYPOTHESIS" +msgstr "Radial Prism Parameter" + +msgid "SMESH_NUMBER_OF_LAYERS" +msgstr "Number of Layers" + +msgid "SMESH_NUMBER_OF_LAYERS_TITLE" +msgstr "Hypothesis Construction" + + +# ---------------- LAYER_DISTRIBUTION ---------------- + +msgid "SMESH_LAYER_DISTRIBUTION_HYPOTHESIS" +msgstr "Distribution of Layers" + +msgid "SMESH_LAYERS_DISTRIBUTION" +msgstr "1D Hypothesis" + +msgid "SMESH_LAYER_DISTRIBUTION_TITLE" +msgstr "Hypothesis Construction" + +msgid "StdMeshersGUI_LayerDistributionParamWdg::CHANGE_TYPE" +msgstr "Change Type" + +msgid "StdMeshersGUI_LayerDistributionParamWdg::CREATE" +msgstr "Create" + +msgid "StdMeshersGUI_LayerDistributionParamWdg::EDIT" +msgstr "Edit" + diff --git a/src/StdMeshers_I/Makefile.in b/src/StdMeshers_I/Makefile.in index 0c836ae9f..ad995c7e1 100644 --- a/src/StdMeshers_I/Makefile.in +++ b/src/StdMeshers_I/Makefile.in @@ -53,7 +53,15 @@ EXPORT_HEADERS = \ StdMeshers_Hexa_3D_i.hxx \ StdMeshers_AutomaticLength_i.hxx \ StdMeshers_QuadranglePreference_i.hxx \ - StdMeshers_QuadraticMesh_i.hxx + StdMeshers_QuadraticMesh_i.hxx \ + StdMeshers_NumberOfLayers_i.hxx \ + StdMeshers_Prism_3D_i.hxx \ + StdMeshers_ProjectionSource1D_i.hxx \ + StdMeshers_ProjectionSource2D_i.hxx \ + StdMeshers_ProjectionSource3D_i.hxx \ + StdMeshers_Projection_1D_2D_3D_i.hxx \ + StdMeshers_ObjRefUlils.hxx \ + StdMeshers_LayerDistribution_i.hxx # Libraries targets @@ -77,7 +85,15 @@ LIB_SRC = \ StdMeshers_Hexa_3D_i.cxx \ StdMeshers_AutomaticLength_i.cxx \ StdMeshers_QuadranglePreference_i.cxx \ - StdMeshers_QuadraticMesh_i.cxx + StdMeshers_QuadraticMesh_i.cxx \ + StdMeshers_NumberOfLayers_i.cxx \ + StdMeshers_Prism_3D_i.cxx \ + StdMeshers_ProjectionSource1D_i.cxx \ + StdMeshers_ProjectionSource2D_i.cxx \ + StdMeshers_ProjectionSource3D_i.cxx \ + StdMeshers_Projection_1D_2D_3D_i.cxx \ + StdMeshers_ObjRefUlils.cxx \ + StdMeshers_LayerDistribution_i.cxx LIB_SERVER_IDL = SMESH_BasicHypothesis.idl diff --git a/src/StdMeshers_I/StdMeshers_LayerDistribution_i.cxx b/src/StdMeshers_I/StdMeshers_LayerDistribution_i.cxx new file mode 100644 index 000000000..598ea2dcd --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_LayerDistribution_i.cxx @@ -0,0 +1,215 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_LayerDistribution_i.cxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_LayerDistribution_i.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_PythonDump.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include + +//============================================================================= +/*! + * StdMeshers_LayerDistribution_i::StdMeshers_LayerDistribution_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_LayerDistribution_i::StdMeshers_LayerDistribution_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_LayerDistribution_i::StdMeshers_LayerDistribution_i" ); + myBaseImpl = new ::StdMeshers_LayerDistribution( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_LayerDistribution_i::~StdMeshers_LayerDistribution_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_LayerDistribution_i::~StdMeshers_LayerDistribution_i() +{ + MESSAGE( "StdMeshers_LayerDistribution_i::~StdMeshers_LayerDistribution_i" ); +} + +//============================================================================= +/*! + * StdMeshers_LayerDistribution_i::SetLayerDistribution + * + + */ +//============================================================================= + +void StdMeshers_LayerDistribution_i::SetLayerDistribution(SMESH::SMESH_Hypothesis_ptr hyp1D) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + try { + SMESH_Hypothesis_i * hyp_i = SMESH::DownCast< SMESH_Hypothesis_i*>( hyp1D ); + bool isNewHyp = ( hyp_i->GetImpl() != this->GetImpl()->GetLayerDistribution() ); + this->GetImpl()->SetLayerDistribution( hyp_i->GetImpl() ); + myHyp = SMESH::SMESH_Hypothesis::_duplicate( hyp1D ); + // Remove SO of 1D hypothesis if it was published + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { + SALOMEDS::Study_var study = gen->GetCurrentStudy(); + SALOMEDS::SObject_var SO = gen->ObjectToSObject( study, hyp1D ); + if ( ! SO->_is_nil() ) + study->NewBuilder()->RemoveObjectWithChildren( SO ); + } + // Update Python script: write creation of 1D hyp as it is not published and + // for this, SMESH_Gen does not write it's creation + if ( isNewHyp ) + SMESH::TPythonDump() << hyp1D << " = " + << SMESH_Gen_i::GetSMESHGen() << ".CreateHypothesis('" + << hyp_i->GetName() << "', '" << hyp_i->GetLibName() << "')"; + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + // Update Python script + SMESH::TPythonDump() << _this() << ".SetLayerDistribution( " << hyp1D << " )"; +} + +//============================================================================= +/*! + * StdMeshers_LayerDistribution_i::GetLayerDistribution + * + * Returns parameter value + */ +//============================================================================= + +SMESH::SMESH_Hypothesis_ptr StdMeshers_LayerDistribution_i::GetLayerDistribution() +{ + SMESH::SMESH_Hypothesis_var hyp = myHyp; + return hyp._retn(); +} + +//============================================================================= +/*! + * StdMeshers_LayerDistribution_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_LayerDistribution* StdMeshers_LayerDistribution_i::GetImpl() +{ + return ( ::StdMeshers_LayerDistribution* )myBaseImpl; +} + +//================================================================================ +/*! + * \brief Verify whether hypothesis supports given entity type + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * + * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) + */ +//================================================================================ +CORBA::Boolean StdMeshers_LayerDistribution_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_3D; +} + +//================================================================================ +/*! + * \brief Write parameters in a string + * \retval char* - resulting string + */ +//================================================================================ + +char* StdMeshers_LayerDistribution_i::SaveTo() +{ + ASSERT( myBaseImpl ); + std::ostringstream os; + + ::SMESH_Hypothesis* hyp1D = GetImpl()->GetLayerDistribution(); + SMESH_Hypothesis_i* hyp1D_i = SMESH::DownCast< SMESH_Hypothesis_i*>( myHyp ); + if ( !hyp1D || !hyp1D_i ) + os << "NULL_HYPO "; + else { + os << hyp1D->GetName() << " " + << hyp1D->GetLibName() << " " + << hyp1D_i->SaveTo(); + } + //myBaseImpl->SaveTo( os ); + + return CORBA::string_dup( os.str().c_str() ); +} + +//================================================================================ +/*! + * \brief Retrieve parameters from the string + * \param theStream - the input string + */ +//================================================================================ + +void StdMeshers_LayerDistribution_i::LoadFrom( const char* theStream ) +{ + ASSERT( myBaseImpl ); + std::istringstream is( theStream ); + + string typeName, libName; + if ( is >> typeName && + is >> libName ) + { + SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen(); + SALOMEDS::Study_var curStudy = gen->GetCurrentStudy(); + gen->SetCurrentStudy( SALOMEDS::Study::_nil() ); // prevent hypo publishing + + try { + SMESH::SMESH_Hypothesis_var hyp1D = + gen->CreateHypothesis( typeName.c_str(), libName.c_str() ); + SMESH_Hypothesis_i* hyp1D_i = SMESH::DownCast< SMESH_Hypothesis_i*>( hyp1D ); + if ( hyp1D_i ) { + hyp1D_i->LoadFrom( & theStream[ is.tellg() ]); + this->GetImpl()->SetLayerDistribution( hyp1D_i->GetImpl() ); + myHyp = hyp1D; + // as hyp1D is not published, its ID changes + //SMESH::TPythonDump() << _this() << ".SetLayerDistribution( " << hyp1D << " )"; + } + } + catch (...) { + } + gen->SetCurrentStudy( curStudy ); // enable hypo publishing + } +} + diff --git a/src/StdMeshers_I/StdMeshers_LayerDistribution_i.hxx b/src/StdMeshers_I/StdMeshers_LayerDistribution_i.hxx new file mode 100644 index 000000000..7112d84c5 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_LayerDistribution_i.hxx @@ -0,0 +1,88 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_LayerDistribution_i.hxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +#ifndef _SMESH_LayerDistribution_I_HXX_ +#define _SMESH_LayerDistribution_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_LayerDistribution.hxx" + +class SMESH_Gen; + +// ========================================================= +/*! + * This hypothesis is used by "Radial prism" algorithm. + * It specifies 1D hypothesis defining distribution of segments between the internal + * and the external surfaces. + */ +// ========================================================= + +class StdMeshers_LayerDistribution_i: + public virtual POA_StdMeshers::StdMeshers_LayerDistribution, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_LayerDistribution_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_LayerDistribution_i(); + + /*! + * \brief Sets 1D hypothesis specifying distribution of layers + * \param hyp1D - 1D hypothesis + */ + void SetLayerDistribution(SMESH::SMESH_Hypothesis_ptr hyp1D) + throw ( SALOME::SALOME_Exception ); + + /*! + * \brief Returns 1D hypothesis specifying distribution of layers + * \retval SMESH::SMESH_Hypothesis_ptr - 1D hypothesis + */ + SMESH::SMESH_Hypothesis_ptr GetLayerDistribution(); + + // Get implementation + ::StdMeshers_LayerDistribution* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Redefined Persistence + virtual char* SaveTo(); + virtual void LoadFrom( const char* theStream ); + +private: + SMESH::SMESH_Hypothesis_var myHyp; +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.cxx b/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.cxx new file mode 100644 index 000000000..0318ca649 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.cxx @@ -0,0 +1,135 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_NumberOfLayers_i.cxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_NumberOfLayers_i.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_PythonDump.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include + +//============================================================================= +/*! + * StdMeshers_NumberOfLayers_i::StdMeshers_NumberOfLayers_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_NumberOfLayers_i::StdMeshers_NumberOfLayers_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_NumberOfLayers_i::StdMeshers_NumberOfLayers_i" ); + myBaseImpl = new ::StdMeshers_NumberOfLayers( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_NumberOfLayers_i::~StdMeshers_NumberOfLayers_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_NumberOfLayers_i::~StdMeshers_NumberOfLayers_i() +{ + MESSAGE( "StdMeshers_NumberOfLayers_i::~StdMeshers_NumberOfLayers_i" ); +} + +//============================================================================= +/*! + * StdMeshers_NumberOfLayers_i::SetNumberOfLayers + * + * Sets parameter value + */ +//============================================================================= + +void StdMeshers_NumberOfLayers_i::SetNumberOfLayers(CORBA::Long numberOfLayers) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetNumberOfLayers( numberOfLayers ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + // Update Python script + SMESH::TPythonDump() << _this() << ".SetNumberOfLayers( " << numberOfLayers << " )"; +} + +//============================================================================= +/*! + * StdMeshers_NumberOfLayers_i::GetNumberOfLayers + * + * Returns parameter value + */ +//============================================================================= + +CORBA::Long StdMeshers_NumberOfLayers_i::GetNumberOfLayers() +{ + ASSERT( myBaseImpl ); + return this->GetImpl()->GetNumberOfLayers(); +} + +//============================================================================= +/*! + * StdMeshers_NumberOfLayers_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_NumberOfLayers* StdMeshers_NumberOfLayers_i::GetImpl() +{ + return ( ::StdMeshers_NumberOfLayers* )myBaseImpl; +} + +//================================================================================ +/*! + * \brief Verify whether hypothesis supports given entity type + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * + * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) + */ +//================================================================================ +CORBA::Boolean StdMeshers_NumberOfLayers_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_3D; +} + diff --git a/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.hxx b/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.hxx new file mode 100644 index 000000000..e738b88a7 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_NumberOfLayers_i.hxx @@ -0,0 +1,75 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_NumberOfLayers_i.hxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +#ifndef _SMESH_NumberOfLayers_I_HXX_ +#define _SMESH_NumberOfLayers_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_NumberOfLayers.hxx" + +class SMESH_Gen; + +// ========================================================= +/*! + * This hypothesis is used by "Radial prism" algorithm. + * It specifies number of segments between the internal + * and the external surfaces. + */ +// ========================================================= + +class StdMeshers_NumberOfLayers_i: + public virtual POA_StdMeshers::StdMeshers_NumberOfLayers, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_NumberOfLayers_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_NumberOfLayers_i(); + + // Sets parameter value + void SetNumberOfLayers(CORBA::Long numberOfLayers) + throw ( SALOME::SALOME_Exception ); + + // Returns parameter value + CORBA::Long GetNumberOfLayers(); + + // Get implementation + ::StdMeshers_NumberOfLayers* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx b/src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx new file mode 100644 index 000000000..da8fa8921 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ObjRefUlils.cxx @@ -0,0 +1,106 @@ +// SMESH SMESH : implementaion of SMESH idl descriptions +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_ObjRefUlils.cxx +// Created : Wed Oct 18 15:38:22 2006 +// Author : Edward AGAPOV (eap) + +#include "StdMeshers_ObjRefUlils.hxx" + +#include + +using namespace std; + +//================================================================================ + /*! + * \brief Store the shape in the stream + * \param theShape - shape to store + * \param stream - the stream + */ +//================================================================================ + +void StdMeshers_ObjRefUlils::SaveToStream( const TopoDS_Shape& theShape, ostream & stream) +{ + bool ok = false; + if ( !theShape.IsNull() ) { + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { + GEOM::GEOM_Object_var geom = gen->ShapeToGeomObject( theShape ); + if ( ! geom->_is_nil() ) { + SALOMEDS::SObject_var sobj = gen->ObjectToSObject( gen->GetCurrentStudy(), geom ); + if ( !sobj->_is_nil() ) { + stream << " " << sobj->GetID(); + ok = true; + } + } + } + } + if ( ! ok ) + stream << " NULL_SHAPE "; +} + +//================================================================================ + /*! + * \brief Retrieve a shape from the stream + * \param stream - the stream + * \retval TopoDS_Shape - resulting shape + */ +//================================================================================ + +TopoDS_Shape StdMeshers_ObjRefUlils::LoadFromStream( istream & stream) +{ + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { + SALOMEDS::Study_var study = gen->GetCurrentStudy(); + if ( ! study->_is_nil() ) { + string str; + if (stream >> str) { + SALOMEDS::SObject_var sobj= study->FindObjectID( str.c_str() ); + CORBA::Object_var obj = gen->SObjectToObject( sobj ); + GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( obj ); + return gen->GeomObjectToShape( geom.in() ); + } + } + } + return TopoDS_Shape(); +} + +//================================================================================ + /*! + * \brief Store the CORBA object in the stream + * \param obj - object to store + * \param stream - the stream + */ +//================================================================================ + +void StdMeshers_ObjRefUlils::SaveToStream( CORBA::Object_ptr obj, + std::ostream & stream) +{ + bool ok = false; + if ( !CORBA::is_nil( obj ) ) { + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { + stream << " " << gen->GetObjectId( obj ); + ok = true; + } + } + if ( ! ok ) + stream << " NULL_OBJECT "; +} diff --git a/src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx b/src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx new file mode 100644 index 000000000..e0c6cf669 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ObjRefUlils.hxx @@ -0,0 +1,109 @@ +// SMESH SMESH : implementaion of SMESH idl descriptions +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_ObjRefUlils.hxx +// Created : Wed Oct 18 15:15:27 2006 +// Author : Edward AGAPOV (eap) +// Copyright : Open CASCADE + + +#ifndef StdMeshers_ObjRefUlils_HeaderFile +#define StdMeshers_ObjRefUlils_HeaderFile + +#include "SMESH_Gen_i.hxx" + +/*! + * \brief Class encapsulates methods + * - converting internal objects to CORBA objects and backward and + * - persistence methods for such objects + * + * These methods are useful for hypotheses referring to other objects + * like meshes, geom objects, other hypotheses, etc. + */ +class StdMeshers_ObjRefUlils +{ +public: + /*! + * \brief Return GEOM Object correspoding to TopoDS_Shape + * \param theShape - input TopoDS_Shape + * \retval GEOM::GEOM_Object_ptr - result object + */ + static GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape ) { + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) + return gen->ShapeToGeomObject( theShape ); + else + return GEOM::GEOM_Object::_nil(); + } + + /*! + * \brief Return TopoDS_Shape correspoding to GEOM_Object + * \param theGeomObject - input object + * \retval TopoDS_Shape - result TopoDS_Shape + */ + static TopoDS_Shape GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject) { + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) + return gen->GeomObjectToShape( theGeomObject ); + else + return TopoDS_Shape(); + } + + /*! + * \brief Store the shape in the stream + * \param theShape - shape to store + * \param stream - the stream + */ + static void SaveToStream( const TopoDS_Shape& theShape, std::ostream & stream); + + /*! + * \brief Retrieve a shape from the stream + * \param stream - the stream + * \retval TopoDS_Shape - resulting shape + */ + static TopoDS_Shape LoadFromStream( std::istream & stream); + + /*! + * \brief Store the CORBA object in the stream + * \param obj - object to store + * \param stream - the stream + */ + static void SaveToStream( CORBA::Object_ptr obj, std::ostream & stream); + + /*! + * \brief Retrieve a CORBA object from the stream + * \param stream - the stream + * \retval CORBA::Object_ptr - result object + */ + template + static + typename TInterface::_var_type LoadObjectFromStream( std::istream & stream ) + { + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { + string str; + if (stream >> str) + return gen->GetObjectByOldId< TInterface >( atoi( str.c_str() )); + } + return TInterface::_nil(); + } +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_Prism_3D_i.cxx b/src/StdMeshers_I/StdMeshers_Prism_3D_i.cxx new file mode 100644 index 000000000..1d44f135d --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Prism_3D_i.cxx @@ -0,0 +1,103 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_Prism_3D_i.cxx +// Moved here from SMESH_Prism_3D_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Prism_3D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_Prism_3D_i::StdMeshers_Prism_3D_i + */ +//============================================================================= + +StdMeshers_Prism_3D_i::StdMeshers_Prism_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_3D_Algo_i( thePOA ) +{ + MESSAGE( "StdMeshers_Prism_3D_i::StdMeshers_Prism_3D_i" ); + myBaseImpl = new ::StdMeshers_Prism_3D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} +//----------------------------------------------------------------------------- + +StdMeshers_Prism_3D_i::~StdMeshers_Prism_3D_i() +{ + MESSAGE( "StdMeshers_Prism_3D_i::~StdMeshers_Prism_3D_i" ); +} +//----------------------------------------------------------------------------- + +::StdMeshers_Prism_3D* StdMeshers_Prism_3D_i::GetImpl() +{ + MESSAGE( "StdMeshers_Prism_3D_i::GetImpl" ); + return ( ::StdMeshers_Prism_3D* )myBaseImpl; +} + + +//============================================================================= +/*! + * StdMeshers_RadialPrism_3D_i::StdMeshers_RadialPrism_3D_i + */ +//============================================================================= + +StdMeshers_RadialPrism_3D_i::StdMeshers_RadialPrism_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_3D_Algo_i( thePOA ) +{ + MESSAGE( "StdMeshers_RadialPrism_3D_i::StdMeshers_RadialPrism_3D_i" ); + myBaseImpl = new ::StdMeshers_RadialPrism_3D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} +//----------------------------------------------------------------------------- + +StdMeshers_RadialPrism_3D_i::~StdMeshers_RadialPrism_3D_i() +{ + MESSAGE( "StdMeshers_RadialPrism_3D_i::~StdMeshers_RadialPrism_3D_i" ); +} +//----------------------------------------------------------------------------- + +::StdMeshers_RadialPrism_3D* StdMeshers_RadialPrism_3D_i::GetImpl() +{ + MESSAGE( "StdMeshers_RadialPrism_3D_i::GetImpl" ); + return ( ::StdMeshers_RadialPrism_3D* )myBaseImpl; +} + diff --git a/src/StdMeshers_I/StdMeshers_Prism_3D_i.hxx b/src/StdMeshers_I/StdMeshers_Prism_3D_i.hxx new file mode 100644 index 000000000..5d4a7b7d1 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Prism_3D_i.hxx @@ -0,0 +1,83 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_Prism_3D_i.hxx +// Moved here from SMESH_Prism_3D_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_Prism_3D_I_HXX_ +#define _SMESH_Prism_3D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_3D_Algo_i.hxx" +#include "StdMeshers_Prism_3D.hxx" +#include "StdMeshers_RadialPrism_3D.hxx" + +class SMESH_Gen; + +// ====================================================== +// Prism 3d algorithm +// ====================================================== +class StdMeshers_Prism_3D_i: + public virtual POA_StdMeshers::StdMeshers_Prism_3D, + public virtual SMESH_3D_Algo_i +{ +public: + // Constructor + StdMeshers_Prism_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + + // Destructor + virtual ~StdMeshers_Prism_3D_i(); + + // Get implementation + ::StdMeshers_Prism_3D* GetImpl(); +}; + +// ====================================================== +// Radial Prism 3d algorithm +// ====================================================== +class StdMeshers_RadialPrism_3D_i: + public virtual POA_StdMeshers::StdMeshers_RadialPrism_3D, + public virtual SMESH_3D_Algo_i +{ +public: + // Constructor + StdMeshers_RadialPrism_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + + // Destructor + virtual ~StdMeshers_RadialPrism_3D_i(); + + // Get implementation + ::StdMeshers_RadialPrism_3D* GetImpl(); +}; + + +#endif diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx b/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx new file mode 100644 index 000000000..b998940c6 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.cxx @@ -0,0 +1,288 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_ProjectionSource1D_i.cxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +using namespace std; + +#include "StdMeshers_ProjectionSource1D_i.hxx" + +#include "SMESH_Gen_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_PythonDump.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include "StdMeshers_ObjRefUlils.hxx" + +//============================================================================= +/*! + * StdMeshers_ProjectionSource1D_i::StdMeshers_ProjectionSource1D_i + * + * Constructor + */ +//============================================================================= + +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 ); +} + +//============================================================================= +/*! + * StdMeshers_ProjectionSource1D_i::~StdMeshers_ProjectionSource1D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_ProjectionSource1D_i::~StdMeshers_ProjectionSource1D_i() +{ + MESSAGE( "StdMeshers_ProjectionSource1D_i::~StdMeshers_ProjectionSource1D_i" ); +} + +//============================================================================= + /*! + * Sets source to take a mesh pattern from + */ +//============================================================================= + +void StdMeshers_ProjectionSource1D_i::SetSourceEdge(GEOM::GEOM_Object_ptr edge) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetSourceEdge( StdMeshers_ObjRefUlils::GeomObjectToShape( edge )); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + // Update Python script + SMESH::TPythonDump() << _this() << ".SetSourceEdge( " << edge << " )"; +} + +//============================================================================= +/*! + * Sets vertex association between the source edge and the target one. + * This parameter is optional + */ +//============================================================================= + +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 ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + // Update Python script + SMESH::TPythonDump() << _this() << ".SetVertexAssociation( " + << sourceVertex << ", " << targetVertex << " )"; +} + +//============================================================================= +/*! + * Sets source to take a mesh pattern from + */ +//============================================================================= + +void StdMeshers_ProjectionSource1D_i::SetSourceMesh(SMESH::SMESH_Mesh_ptr theMesh) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + + ::SMESH_Mesh* mesh = 0; + + if ( !CORBA::is_nil( theMesh )) + { + SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( theMesh ); + if ( !mesh_i ) + THROW_SALOME_CORBA_EXCEPTION( "bad mesh", SALOME::BAD_PARAM ); + mesh = &mesh_i->GetImpl(); + } + + try { + this->GetImpl()->SetSourceMesh ( mesh ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + + myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( theMesh ); + + // Update Python script + SMESH::TPythonDump() << _this() << ".SetSourceMesh( " << theMesh << " )"; +} + +//============================================================================= +/*! + * Return source mesh + */ +//============================================================================= + +SMESH::SMESH_Mesh_ptr StdMeshers_ProjectionSource1D_i::GetSourceMesh() +{ + SMESH::SMESH_Mesh_var mesh = myCorbaMesh; + return mesh._retn(); +} + +//============================================================================= +/*! + * Returns the source edge + */ +//============================================================================= + +GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetSourceEdge() +{ + ASSERT( myBaseImpl ); + return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceEdge() ); +} + +//============================================================================= +/*! + * Returns the vertex associated with the target vertex. + * Result may be nil if association not set + */ +//============================================================================= + +GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetSourceVertex() +{ + ASSERT( myBaseImpl ); + return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceVertex() ); +} + +//============================================================================= +/*! + * Returns the vertex associated with the source vertex. + * Result may be nil if association not set + */ +//============================================================================= + +GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource1D_i::GetTargetVertex() +{ + ASSERT( myBaseImpl ); + return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetTargetVertex() ); +} + +//============================================================================= +/*! + * StdMeshers_ProjectionSource1D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_ProjectionSource1D* StdMeshers_ProjectionSource1D_i::GetImpl() +{ + return ( ::StdMeshers_ProjectionSource1D* )myBaseImpl; +} + +//================================================================================ +/*! + * \brief Verify whether hypothesis supports given entity type + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * + * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) + */ +//================================================================================ +CORBA::Boolean StdMeshers_ProjectionSource1D_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_1D; +} + +//================================================================================ +/*! + * \brief Write parameters in a string + * \retval char* - resulting string + */ +//================================================================================ + +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 ); + StdMeshers_ObjRefUlils::SaveToStream( GetSourceMesh(), os ); + + myBaseImpl->SaveTo( os ); + + return CORBA::string_dup( os.str().c_str() ); +} + +//================================================================================ +/*! + * \brief Retrieve parameters from the string + * \param theStream - the input string + */ +//================================================================================ + +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 ); + SMESH::SMESH_Mesh_var mesh = + StdMeshers_ObjRefUlils::LoadObjectFromStream< SMESH::SMESH_Mesh >( is ); + + ::SMESH_Mesh* meshImpl = 0; + + if ( !CORBA::is_nil( mesh )) + { + SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( mesh ); + if ( mesh_i ) + meshImpl = &mesh_i->GetImpl(); + } + + myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( mesh ); + GetImpl()->RestoreParams( s1, s2, s3, meshImpl ); + + myBaseImpl->LoadFrom( is ); +} + diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.hxx b/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.hxx new file mode 100644 index 000000000..0284ba09b --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource1D_i.hxx @@ -0,0 +1,118 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_ProjectionSource1D_i.hxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +#ifndef _SMESH_ProjectionSource1D_I_HXX_ +#define _SMESH_ProjectionSource1D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_ProjectionSource1D.hxx" + +class SMESH_Gen; + +// ========================================================= +/*! + * This hypothesis specifies a meshed edge to take a mesh pattern from + * and optionally association of vertices between the source edge and a + * target one (where a hipothesis is assigned to) + */ +// ========================================================= + +class StdMeshers_ProjectionSource1D_i: + public virtual POA_StdMeshers::StdMeshers_ProjectionSource1D, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_ProjectionSource1D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_ProjectionSource1D_i(); + + /*! + * Sets source to take a mesh pattern from + */ + void SetSourceEdge(GEOM::GEOM_Object_ptr edge) + throw ( SALOME::SALOME_Exception ); + + /*! + * Returns the source edge + */ + GEOM::GEOM_Object_ptr GetSourceEdge(); + + /*! + * Sets source to take a mesh pattern from + */ + void SetSourceMesh(SMESH::SMESH_Mesh_ptr mesh) + throw ( SALOME::SALOME_Exception ); + + /*! + * Return source mesh + */ + SMESH::SMESH_Mesh_ptr GetSourceMesh(); + + /*! + * Sets vertex association between the source edge and the target one. + * This parameter is optional + */ + void SetVertexAssociation(GEOM::GEOM_Object_ptr sourceVertex, + GEOM::GEOM_Object_ptr targetVertex) + throw ( SALOME::SALOME_Exception ); + + /*! + * Returns the vertex associated with the target vertex. + * Result may be nil if association not set + */ + GEOM::GEOM_Object_ptr GetSourceVertex(); + + /*! + * Returns the vertex associated with the source vertex. + * Result may be nil if association not set + */ + GEOM::GEOM_Object_ptr GetTargetVertex(); + + // Get implementation + ::StdMeshers_ProjectionSource1D* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Redefined Persistence + virtual char* SaveTo(); + virtual void LoadFrom( const char* theStream ); + +private: + SMESH::SMESH_Mesh_var myCorbaMesh; +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx b/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx new file mode 100644 index 000000000..ad8b2a106 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.cxx @@ -0,0 +1,300 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_ProjectionSource2D_i.cxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +using namespace std; + +#include "StdMeshers_ProjectionSource2D_i.hxx" + +#include "SMESH_Gen_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_PythonDump.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include "StdMeshers_ObjRefUlils.hxx" + +//============================================================================= +/*! + * StdMeshers_ProjectionSource2D_i::StdMeshers_ProjectionSource2D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_ProjectionSource2D_i::StdMeshers_ProjectionSource2D_i +( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_ProjectionSource2D_i::StdMeshers_ProjectionSource2D_i" ); + myBaseImpl = new ::StdMeshers_ProjectionSource2D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_ProjectionSource2D_i::~StdMeshers_ProjectionSource2D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_ProjectionSource2D_i::~StdMeshers_ProjectionSource2D_i() +{ + MESSAGE( "StdMeshers_ProjectionSource2D_i::~StdMeshers_ProjectionSource2D_i" ); +} + +//============================================================================= + /*! + * Sets a source to take a mesh pattern from + */ +//============================================================================= + +void StdMeshers_ProjectionSource2D_i::SetSourceFace(GEOM::GEOM_Object_ptr face) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetSourceFace( StdMeshers_ObjRefUlils::GeomObjectToShape( face )); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + // Update Python script + SMESH::TPythonDump() << _this() << ".SetSourceFace( " << face << " )"; +} + +//============================================================================= +/*! + * Sets source to take a mesh pattern from + */ +//============================================================================= + +void StdMeshers_ProjectionSource2D_i::SetSourceMesh(SMESH::SMESH_Mesh_ptr theMesh) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + + ::SMESH_Mesh* mesh = 0; + + if ( !CORBA::is_nil( theMesh )) + { + SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( theMesh ); + if ( !mesh_i ) + THROW_SALOME_CORBA_EXCEPTION( "bad mesh", SALOME::BAD_PARAM ); + mesh = &mesh_i->GetImpl(); + } + + try { + this->GetImpl()->SetSourceMesh ( mesh ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + + myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( theMesh ); + + // Update Python script + SMESH::TPythonDump() << _this() << ".SetSourceMesh( " << theMesh << " )"; +} + +//============================================================================= +/*! + * Return source mesh + */ +//============================================================================= + +SMESH::SMESH_Mesh_ptr StdMeshers_ProjectionSource2D_i::GetSourceMesh() +{ + SMESH::SMESH_Mesh_var mesh = myCorbaMesh; + return mesh._retn(); +} + +//============================================================================= +/*! + * Sets vertex association between the source face and the target one. + * This parameter is optional. + * Two vertices must belong to one edge of a face + */ +//============================================================================= + +void StdMeshers_ProjectionSource2D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr sourceVertex1, + GEOM::GEOM_Object_ptr sourceVertex2, + GEOM::GEOM_Object_ptr targetVertex1, + GEOM::GEOM_Object_ptr targetVertex2) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + try { + TopoDS_Shape v1 = StdMeshers_ObjRefUlils::GeomObjectToShape( sourceVertex1 ); + TopoDS_Shape v2 = StdMeshers_ObjRefUlils::GeomObjectToShape( sourceVertex2 ); + TopoDS_Shape v3 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex1 ); + TopoDS_Shape v4 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex2 ); + this->GetImpl()->SetVertexAssociation( v1, v2, v3, v4 ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + // Update Python script + SMESH::TPythonDump() << _this() << ".SetVertexAssociation( " + << sourceVertex1 << ", " + << sourceVertex2 << ", " + << targetVertex1 << ", " + << targetVertex2 << " )"; +} + +//============================================================================= +/*! + * Returns the source face + */ +//============================================================================= + +GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetSourceFace() +{ + ASSERT( myBaseImpl ); + return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceFace() ); +} + +//============================================================================= +/*! + * Returns the vertex associated with the target vertex. + * Result may be nil if association not set + */ +//============================================================================= + +GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetSourceVertex(CORBA::Long i) +{ + ASSERT( myBaseImpl ); + return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceVertex((int) i )); +} + +//============================================================================= +/*! + * Returns the -th target vertex associated with the -th source vertex. + * Result may be nil if association not set. + */ +//============================================================================= + +GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource2D_i::GetTargetVertex(CORBA::Long i) +{ + ASSERT( myBaseImpl ); + return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetTargetVertex( (int)i )); +} + +//============================================================================= +/*! + * StdMeshers_ProjectionSource2D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_ProjectionSource2D* StdMeshers_ProjectionSource2D_i::GetImpl() +{ + return ( ::StdMeshers_ProjectionSource2D* )myBaseImpl; +} + +//================================================================================ +/*! + * \brief Verify whether hypothesis supports given entity type + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * + * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) + */ +//================================================================================ +CORBA::Boolean StdMeshers_ProjectionSource2D_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_2D; +} + +//================================================================================ +/*! + * \brief Write parameters in a string + * \retval char* - resulting string + */ +//================================================================================ + +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 ); + StdMeshers_ObjRefUlils::SaveToStream( GetSourceMesh(), os ); + + myBaseImpl->SaveTo( os ); + + return CORBA::string_dup( os.str().c_str() ); +} + +//================================================================================ +/*! + * \brief Retrieve parameters from the string + * \param theStream - the input string + */ +//================================================================================ + +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 ); + SMESH::SMESH_Mesh_var mesh = + StdMeshers_ObjRefUlils::LoadObjectFromStream< SMESH::SMESH_Mesh >( is ); + + ::SMESH_Mesh* meshImpl = 0; + + if ( !CORBA::is_nil( mesh )) + { + SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( mesh ); + if ( mesh_i ) + meshImpl = &mesh_i->GetImpl(); + } + + myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( mesh ); + GetImpl()->RestoreParams( s1, s2, s3, s4, s5, meshImpl ); + + myBaseImpl->LoadFrom( is ); +} + diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.hxx b/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.hxx new file mode 100644 index 000000000..836edfc23 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource2D_i.hxx @@ -0,0 +1,122 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_ProjectionSource2D_i.hxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +#ifndef _SMESH_ProjectionSource2D_I_HXX_ +#define _SMESH_ProjectionSource2D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_ProjectionSource2D.hxx" + +class SMESH_Gen; + +// ========================================================= +/*! + * This hypothesis specifies a meshed face to take a mesh pattern from + * and optionally association of vertices between the source face and a + * target one (where a hipothesis is assigned to) + */ +// ========================================================= + +class StdMeshers_ProjectionSource2D_i: + public virtual POA_StdMeshers::StdMeshers_ProjectionSource2D, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_ProjectionSource2D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_ProjectionSource2D_i(); + + /*! + * Sets a source to take a mesh pattern from + */ + void SetSourceFace(GEOM::GEOM_Object_ptr face) + throw ( SALOME::SALOME_Exception ); + + /*! + * Returns the source face + */ + GEOM::GEOM_Object_ptr GetSourceFace(); + + /*! + * Sets source to take a mesh pattern from + */ + void SetSourceMesh(SMESH::SMESH_Mesh_ptr mesh) + throw ( SALOME::SALOME_Exception ); + + /*! + * Return source mesh + */ + SMESH::SMESH_Mesh_ptr GetSourceMesh(); + + /*! + * Sets vertex association between the source face and the target one. + * This parameter is optional. + * Two vertices must belong to one edge of a face + */ + void SetVertexAssociation(GEOM::GEOM_Object_ptr sourceVertex1, + GEOM::GEOM_Object_ptr sourceVertex2, + GEOM::GEOM_Object_ptr targetVertex1, + GEOM::GEOM_Object_ptr targetVertex2) + throw ( SALOME::SALOME_Exception ); + + /*! + * Returns the -th source vertex associated with the -th target vertex. + * Result may be nil if association not set. + */ + GEOM::GEOM_Object_ptr GetSourceVertex(CORBA::Long i); + + /*! + * Returns the -th target vertex associated with the -th source vertex. + * Result may be nil if association not set. + */ + GEOM::GEOM_Object_ptr GetTargetVertex(CORBA::Long i); + + // Get implementation + ::StdMeshers_ProjectionSource2D* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Redefined Persistence + virtual char* SaveTo(); + virtual void LoadFrom( const char* theStream ); + +private: + SMESH::SMESH_Mesh_var myCorbaMesh; +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.cxx b/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.cxx new file mode 100644 index 000000000..3676905a9 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.cxx @@ -0,0 +1,299 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_ProjectionSource3D_i.cxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +using namespace std; + +#include "StdMeshers_ProjectionSource3D_i.hxx" + +#include "SMESH_Gen_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_PythonDump.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include "StdMeshers_ObjRefUlils.hxx" + +//============================================================================= +/*! + * StdMeshers_ProjectionSource3D_i::StdMeshers_ProjectionSource3D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_ProjectionSource3D_i::StdMeshers_ProjectionSource3D_i +( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_ProjectionSource3D_i::StdMeshers_ProjectionSource3D_i" ); + myBaseImpl = new ::StdMeshers_ProjectionSource3D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_ProjectionSource3D_i::~StdMeshers_ProjectionSource3D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_ProjectionSource3D_i::~StdMeshers_ProjectionSource3D_i() +{ + MESSAGE( "StdMeshers_ProjectionSource3D_i::~StdMeshers_ProjectionSource3D_i" ); +} + +//============================================================================= + /*! + * Sets a source to take a mesh pattern from + */ +//============================================================================= + +void StdMeshers_ProjectionSource3D_i::SetSource3DShape(GEOM::GEOM_Object_ptr shape) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetSource3DShape( StdMeshers_ObjRefUlils::GeomObjectToShape( shape )); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + // Update Python script + SMESH::TPythonDump() << _this() << ".SetSource3DShape( " << shape << " )"; +} + +//============================================================================= +/*! + * Sets source to take a mesh pattern from + */ +//============================================================================= + +void StdMeshers_ProjectionSource3D_i::SetSourceMesh(SMESH::SMESH_Mesh_ptr theMesh) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + + ::SMESH_Mesh* mesh = 0; + + if ( !CORBA::is_nil( theMesh )) + { + SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( theMesh ); + if ( !mesh_i ) + THROW_SALOME_CORBA_EXCEPTION( "bad mesh", SALOME::BAD_PARAM ); + mesh = &mesh_i->GetImpl(); + } + + try { + this->GetImpl()->SetSourceMesh ( mesh ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + + myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( theMesh ); + + // Update Python script + SMESH::TPythonDump() << _this() << ".SetSourceMesh( " << theMesh << " )"; +} + +//============================================================================= +/*! + * Return source mesh + */ +//============================================================================= + +SMESH::SMESH_Mesh_ptr StdMeshers_ProjectionSource3D_i::GetSourceMesh() +{ + SMESH::SMESH_Mesh_var mesh = myCorbaMesh; + return mesh._retn(); +} + +//============================================================================= +/*! + * Sets vertex association between the source shape and the target one. + * This parameter is optional. + * Two vertices must belong to one edge of a shape + */ +//============================================================================= + +void StdMeshers_ProjectionSource3D_i::SetVertexAssociation(GEOM::GEOM_Object_ptr sourceVertex1, + GEOM::GEOM_Object_ptr sourceVertex2, + GEOM::GEOM_Object_ptr targetVertex1, + GEOM::GEOM_Object_ptr targetVertex2) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + try { + TopoDS_Shape v1 = StdMeshers_ObjRefUlils::GeomObjectToShape( sourceVertex1 ); + TopoDS_Shape v2 = StdMeshers_ObjRefUlils::GeomObjectToShape( sourceVertex2 ); + TopoDS_Shape v3 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex1 ); + TopoDS_Shape v4 = StdMeshers_ObjRefUlils::GeomObjectToShape( targetVertex2 ); + this->GetImpl()->SetVertexAssociation( v1, v2, v3, v4 ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM ); + } + // Update Python script + SMESH::TPythonDump() << _this() << ".SetVertexAssociation( " + << sourceVertex1 << ", " + << sourceVertex2 << ", " + << targetVertex1 << ", " + << targetVertex2 << " )"; +} + +//============================================================================= +/*! + * Returns the source face + */ +//============================================================================= + +GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_i::GetSource3DShape() +{ + ASSERT( myBaseImpl ); + return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSource3DShape() ); +} + +//============================================================================= +/*! + * Returns the vertex associated with the target vertex. + * Result may be nil if association not set + */ +//============================================================================= + +GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_i::GetSourceVertex(CORBA::Long i) +{ + ASSERT( myBaseImpl ); + return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetSourceVertex((int) i )); +} + +//============================================================================= +/*! + * Returns the -th target vertex associated with the -th source vertex. + * Result may be nil if association not set. + */ +//============================================================================= + +GEOM::GEOM_Object_ptr StdMeshers_ProjectionSource3D_i::GetTargetVertex(CORBA::Long i) +{ + ASSERT( myBaseImpl ); + return StdMeshers_ObjRefUlils::ShapeToGeomObject( this->GetImpl()->GetTargetVertex( (int)i )); +} + +//============================================================================= +/*! + * StdMeshers_ProjectionSource3D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_ProjectionSource3D* StdMeshers_ProjectionSource3D_i::GetImpl() +{ + return ( ::StdMeshers_ProjectionSource3D* )myBaseImpl; +} + +//================================================================================ +/*! + * \brief Verify whether hypothesis supports given entity type + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * + * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) + */ +//================================================================================ +CORBA::Boolean StdMeshers_ProjectionSource3D_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_3D; +} + +//================================================================================ +/*! + * \brief Write parameters in a string + * \retval char* - resulting string + */ +//================================================================================ + +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 ); + StdMeshers_ObjRefUlils::SaveToStream( GetSourceMesh(), os ); + + myBaseImpl->SaveTo( os ); + + return CORBA::string_dup( os.str().c_str() ); +} + +//================================================================================ +/*! + * \brief Retrieve parameters from the string + * \param theStream - the input string + */ +//================================================================================ + +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 ); + SMESH::SMESH_Mesh_var mesh = + StdMeshers_ObjRefUlils::LoadObjectFromStream< SMESH::SMESH_Mesh >( is ); + + ::SMESH_Mesh* meshImpl = 0; + + if ( !CORBA::is_nil( mesh )) + { + SMESH_Mesh_i* mesh_i = SMESH::DownCast< SMESH_Mesh_i* >( mesh ); + if ( mesh_i ) + meshImpl = &mesh_i->GetImpl(); + } + + myCorbaMesh = SMESH::SMESH_Mesh::_duplicate( mesh ); + GetImpl()->RestoreParams( s1, s2, s3, s4, s5, meshImpl ); + myBaseImpl->LoadFrom( is ); +} + diff --git a/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.hxx b/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.hxx new file mode 100644 index 000000000..753331488 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ProjectionSource3D_i.hxx @@ -0,0 +1,122 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_ProjectionSource3D_i.hxx +// Author : Edward AGAPOV +// Module : SMESH +// $Header$ + +#ifndef _SMESH_ProjectionSource3D_I_HXX_ +#define _SMESH_ProjectionSource3D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_ProjectionSource3D.hxx" + +class SMESH_Gen; + +// ========================================================= +/*! + * This hypothesis specifies a meshed shell or solid to take a mesh pattern from + * and optionally association of vertices between the source shape and a + * target one (where a hipothesis is assigned to) + */ +// ========================================================= + +class StdMeshers_ProjectionSource3D_i: + public virtual POA_StdMeshers::StdMeshers_ProjectionSource3D, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_ProjectionSource3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_ProjectionSource3D_i(); + + /*! + * Sets a source to take a mesh pattern from + */ + void SetSource3DShape(GEOM::GEOM_Object_ptr shape) + throw ( SALOME::SALOME_Exception ); + + /*! + * Returns the source shape + */ + GEOM::GEOM_Object_ptr GetSource3DShape(); + + /*! + * Sets source to take a mesh pattern from + */ + void SetSourceMesh(SMESH::SMESH_Mesh_ptr mesh) + throw ( SALOME::SALOME_Exception ); + + /*! + * Return source mesh + */ + SMESH::SMESH_Mesh_ptr GetSourceMesh(); + + /*! + * Sets vertex association between the source shape and the target one. + * This parameter is optional. + * Two vertices must belong to one edge of a shape + */ + void SetVertexAssociation(GEOM::GEOM_Object_ptr sourceVertex1, + GEOM::GEOM_Object_ptr sourceVertex2, + GEOM::GEOM_Object_ptr targetVertex1, + GEOM::GEOM_Object_ptr targetVertex2) + throw ( SALOME::SALOME_Exception ); + + /*! + * Returns the -th source vertex associated with the -th target vertex. + * Result may be nil if association not set. + */ + GEOM::GEOM_Object_ptr GetSourceVertex(CORBA::Long i); + + /*! + * Returns the -th target vertex associated with the -th source vertex. + * Result may be nil if association not set. + */ + GEOM::GEOM_Object_ptr GetTargetVertex(CORBA::Long i); + + // Get implementation + ::StdMeshers_ProjectionSource3D* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + + // Redefined Persistence + virtual char* SaveTo(); + virtual void LoadFrom( const char* theStream ); + +private: + SMESH::SMESH_Mesh_var myCorbaMesh; +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_Projection_1D_2D_3D_i.cxx b/src/StdMeshers_I/StdMeshers_Projection_1D_2D_3D_i.cxx new file mode 100644 index 000000000..1e01e1355 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Projection_1D_2D_3D_i.cxx @@ -0,0 +1,140 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_Projection_3D_i.cxx +// Moved here from SMESH_Projection_3D_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; + +#include "StdMeshers_Projection_1D_2D_3D_i.hxx" + +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include "StdMeshers_ObjRefUlils.hxx" + +//============================================================================= +/*! + * StdMeshers_Projection_3D_i::StdMeshers_Projection_3D_i + */ +//============================================================================= + +StdMeshers_Projection_3D_i::StdMeshers_Projection_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_3D_Algo_i( thePOA ) +{ + MESSAGE( "StdMeshers_Projection_3D_i::StdMeshers_Projection_3D_i" ); + myBaseImpl = new ::StdMeshers_Projection_3D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} +//----------------------------------------------------------------------------- + +StdMeshers_Projection_3D_i::~StdMeshers_Projection_3D_i() +{ + MESSAGE( "StdMeshers_Projection_3D_i::~StdMeshers_Projection_3D_i" ); +} +//----------------------------------------------------------------------------- + +::StdMeshers_Projection_3D* StdMeshers_Projection_3D_i::GetImpl() +{ + MESSAGE( "StdMeshers_Projection_3D_i::GetImpl" ); + return ( ::StdMeshers_Projection_3D* )myBaseImpl; +} + + +//============================================================================= +/*! + * StdMeshers_Projection_2D_i::StdMeshers_Projection_2D_i + */ +//============================================================================= + +StdMeshers_Projection_2D_i::StdMeshers_Projection_2D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_2D_Algo_i( thePOA ) +{ + MESSAGE( "StdMeshers_Projection_2D_i::StdMeshers_Projection_2D_i" ); + myBaseImpl = new ::StdMeshers_Projection_2D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} +//----------------------------------------------------------------------------- + +StdMeshers_Projection_2D_i::~StdMeshers_Projection_2D_i() +{ + MESSAGE( "StdMeshers_Projection_2D_i::~StdMeshers_Projection_2D_i" ); +} +//----------------------------------------------------------------------------- + +::StdMeshers_Projection_2D* StdMeshers_Projection_2D_i::GetImpl() +{ + MESSAGE( "StdMeshers_Projection_2D_i::GetImpl" ); + return ( ::StdMeshers_Projection_2D* )myBaseImpl; +} + + +//============================================================================= +/*! + * StdMeshers_Projection_1D_i::StdMeshers_Projection_1D_i + */ +//============================================================================= + +StdMeshers_Projection_1D_i::StdMeshers_Projection_1D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_1D_Algo_i( thePOA ) +{ + MESSAGE( "StdMeshers_Projection_1D_i::StdMeshers_Projection_1D_i" ); + myBaseImpl = new ::StdMeshers_Projection_1D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} +//----------------------------------------------------------------------------- + +StdMeshers_Projection_1D_i::~StdMeshers_Projection_1D_i() +{ + MESSAGE( "StdMeshers_Projection_1D_i::~StdMeshers_Projection_1D_i" ); +} +//----------------------------------------------------------------------------- + +::StdMeshers_Projection_1D* StdMeshers_Projection_1D_i::GetImpl() +{ + MESSAGE( "StdMeshers_Projection_1D_i::GetImpl" ); + return ( ::StdMeshers_Projection_1D* )myBaseImpl; +} diff --git a/src/StdMeshers_I/StdMeshers_Projection_1D_2D_3D_i.hxx b/src/StdMeshers_I/StdMeshers_Projection_1D_2D_3D_i.hxx new file mode 100644 index 000000000..d55280a96 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Projection_1D_2D_3D_i.hxx @@ -0,0 +1,109 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 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 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 +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : StdMeshers_Hexa_3D_i.hxx +// Moved here from SMESH_Hexa_3D_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_Projection_3D_I_HXX_ +#define _SMESH_Projection_3D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_1D_Algo_i.hxx" +#include "SMESH_2D_Algo_i.hxx" +#include "SMESH_3D_Algo_i.hxx" +#include "StdMeshers_Projection_1D.hxx" +#include "StdMeshers_Projection_2D.hxx" +#include "StdMeshers_Projection_3D.hxx" + +class SMESH_Gen; + +// ====================================================== +// Projection 3D algorithm +// ====================================================== + +class StdMeshers_Projection_3D_i: + public virtual POA_StdMeshers::StdMeshers_Projection_3D, + public virtual SMESH_3D_Algo_i +{ +public: + // Constructor + StdMeshers_Projection_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + + // Destructor + virtual ~StdMeshers_Projection_3D_i(); + + // Get implementation + ::StdMeshers_Projection_3D* GetImpl(); +}; + +// ====================================================== +// Projection 3D algorithm +// ====================================================== + +class StdMeshers_Projection_2D_i: + public virtual POA_StdMeshers::StdMeshers_Projection_2D, + public virtual SMESH_2D_Algo_i +{ +public: + // Constructor + StdMeshers_Projection_2D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + + // Destructor + virtual ~StdMeshers_Projection_2D_i(); + + // Get implementation + ::StdMeshers_Projection_2D* GetImpl(); +}; + +// ====================================================== +// Projection 3D algorithm +// ====================================================== + +class StdMeshers_Projection_1D_i: + public virtual POA_StdMeshers::StdMeshers_Projection_1D, + public virtual SMESH_1D_Algo_i +{ +public: + // Constructor + StdMeshers_Projection_1D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + + // Destructor + virtual ~StdMeshers_Projection_1D_i(); + + // Get implementation + ::StdMeshers_Projection_1D* GetImpl(); +}; + + +#endif diff --git a/src/StdMeshers_I/StdMeshers_i.cxx b/src/StdMeshers_I/StdMeshers_i.cxx index 42f4c68fd..00ffe482f 100644 --- a/src/StdMeshers_I/StdMeshers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_i.cxx @@ -44,11 +44,21 @@ using namespace std; #include "StdMeshers_MaxElementVolume_i.hxx" #include "StdMeshers_NotConformAllowed_i.hxx" +#include "StdMeshers_ProjectionSource3D_i.hxx" +#include "StdMeshers_ProjectionSource2D_i.hxx" +#include "StdMeshers_ProjectionSource1D_i.hxx" +#include "StdMeshers_NumberOfLayers_i.hxx" +#include "StdMeshers_LayerDistribution_i.hxx" + #include "StdMeshers_Regular_1D_i.hxx" #include "StdMeshers_MEFISTO_2D_i.hxx" #include "StdMeshers_Quadrangle_2D_i.hxx" #include "StdMeshers_Hexa_3D_i.hxx" +#include "StdMeshers_Projection_1D_2D_3D_i.hxx" +#include "StdMeshers_Prism_3D_i.hxx" + + template class StdHypothesisCreator_i:public HypothesisCreator_i { // as we have 'module StdMeshers' in SMESH_BasicHypothesis.idl @@ -96,6 +106,16 @@ extern "C" aCreator = new StdHypothesisCreator_i; else if (strcmp(aHypName, "QuadraticMesh") == 0) aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "ProjectionSource3D") == 0) + aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "ProjectionSource2D") == 0) + aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "ProjectionSource1D") == 0) + aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "NumberOfLayers") == 0) + aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "LayerDistribution") == 0) + aCreator = new StdHypothesisCreator_i; // Algorithms else if (strcmp(aHypName, "Regular_1D") == 0) @@ -106,6 +126,16 @@ extern "C" aCreator = new StdHypothesisCreator_i; else if (strcmp(aHypName, "Hexa_3D") == 0) aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "Projection_1D") == 0) + aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "Projection_2D") == 0) + aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "Projection_3D") == 0) + aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "Prism_3D") == 0) + aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "RadialPrism_3D") == 0) + aCreator = new StdHypothesisCreator_i; else ; return aCreator; -- 2.39.2