X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FStdMeshers_I%2FStdMeshers_LayerDistribution_i.cxx;h=d958478e73e0f86e3ec6edd70a09bb37f4919827;hb=9c03aded93701016bfbe0de6cc654c2d97631ee5;hp=5c3b41315d5f0977e0a7b25451a711ac1e10465c;hpb=79b1ac2b6df9117f16f11d444b1f165d477a1813;p=modules%2Fsmesh.git diff --git a/src/StdMeshers_I/StdMeshers_LayerDistribution_i.cxx b/src/StdMeshers_I/StdMeshers_LayerDistribution_i.cxx index 5c3b41315..d958478e7 100644 --- a/src/StdMeshers_I/StdMeshers_LayerDistribution_i.cxx +++ b/src/StdMeshers_I/StdMeshers_LayerDistribution_i.cxx @@ -1,31 +1,29 @@ -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE // -// 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 +// Copyright (C) 2003-2007 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, or (at your option) any later version. // +// 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$ - +// #include "StdMeshers_LayerDistribution_i.hxx" #include "SMESH_Gen_i.hxx" #include "SMESH_Gen.hxx" @@ -47,9 +45,9 @@ using namespace std; //============================================================================= StdMeshers_LayerDistribution_i::StdMeshers_LayerDistribution_i( PortableServer::POA_ptr thePOA, - int theStudyId, - ::SMESH_Gen* theGenImpl ) - : SALOME::GenericObj_i( thePOA ), + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), SMESH_Hypothesis_i( thePOA ) { MESSAGE( "StdMeshers_LayerDistribution_i::StdMeshers_LayerDistribution_i" ); @@ -69,18 +67,20 @@ StdMeshers_LayerDistribution_i::StdMeshers_LayerDistribution_i( PortableServer:: StdMeshers_LayerDistribution_i::~StdMeshers_LayerDistribution_i() { MESSAGE( "StdMeshers_LayerDistribution_i::~StdMeshers_LayerDistribution_i" ); + if ( !myHyp->_is_nil() ) + myHyp->UnRegister(); } //============================================================================= /*! * StdMeshers_LayerDistribution_i::SetLayerDistribution * - + */ //============================================================================= void StdMeshers_LayerDistribution_i::SetLayerDistribution(SMESH::SMESH_Hypothesis_ptr hyp1D) - throw ( SALOME::SALOME_Exception ) + throw ( SALOME::SALOME_Exception ) { ASSERT( myBaseImpl ); try { @@ -88,12 +88,18 @@ void StdMeshers_LayerDistribution_i::SetLayerDistribution(SMESH::SMESH_Hypothesi bool isNewHyp = ( hyp_i->GetImpl() != this->GetImpl()->GetLayerDistribution() ); this->GetImpl()->SetLayerDistribution( hyp_i->GetImpl() ); myHyp = SMESH::SMESH_Hypothesis::_duplicate( hyp1D ); + myHyp->Register(); // Remove SO of 1D hypothesis if it was published - if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) { + if (SMESH_Gen_i* gen = SMESH_Gen_i::GetSMESHGen()) + { SALOMEDS::Study_var study = gen->GetCurrentStudy(); - SALOMEDS::SObject_var SO = gen->ObjectToSObject( study, hyp1D ); + SALOMEDS::SObject_var SO = gen->ObjectToSObject( study, hyp1D ); if ( ! SO->_is_nil() ) - study->NewBuilder()->RemoveObjectWithChildren( SO ); + { + SALOMEDS::StudyBuilder_var builder = study->NewBuilder(); + builder->RemoveObjectWithChildren( SO ); + SO->UnRegister(); + } } // Update Python script: write creation of 1D hyp as it is not published and // for this, SMESH_Gen does not write it's creation @@ -139,12 +145,13 @@ SMESH::SMESH_Hypothesis_ptr StdMeshers_LayerDistribution_i::GetLayerDistribution //================================================================================ /*! * \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 + * \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; @@ -153,7 +160,7 @@ CORBA::Boolean StdMeshers_LayerDistribution_i::IsDimSupported( SMESH::Dimension //================================================================================ /*! * \brief Write parameters in a string - * \retval char* - resulting string + * \retval char* - resulting string */ //================================================================================ @@ -169,9 +176,9 @@ char* StdMeshers_LayerDistribution_i::SaveTo() else { os << hyp1D->GetName() << " " << hyp1D->GetLibName() << " " - << hyp1D_i->SaveTo(); + << hyp1D_i->SaveTo() << " "; } - //myBaseImpl->SaveTo( os ); + os << SMESH_Hypothesis_i::SaveTo(); // to have a mark of storage version ("VARS...") return CORBA::string_dup( os.str().c_str() ); } @@ -179,7 +186,7 @@ char* StdMeshers_LayerDistribution_i::SaveTo() //================================================================================ /*! * \brief Retrieve parameters from the string - * \param theStream - the input string + * \param theStream - the input string */ //================================================================================ @@ -201,11 +208,17 @@ void StdMeshers_LayerDistribution_i::LoadFrom( const char* theStream ) 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() ]); + hyp1D_i->LoadFrom( & theStream[ (streamoff) is.tellg()+1 ]); this->GetImpl()->SetLayerDistribution( hyp1D_i->GetImpl() ); myHyp = hyp1D; + + SMESH::SMESH_Hypothesis_var me = _this(); + hyp1D->SetHolderHypothesis( me ); // as hyp1D is not published, its ID changes //SMESH::TPythonDump() << _this() << ".SetLayerDistribution( " << hyp1D << " )"; + + // restore a mark of storage version ("VARS...") + SMESH_Hypothesis_i::LoadFrom( & theStream[ (streamoff)is.tellg()+1 ]); } } catch (...) { @@ -214,3 +227,14 @@ void StdMeshers_LayerDistribution_i::LoadFrom( const char* theStream ) } } +//================================================================================ +/*! + * \brief Restore myMethod2VarParams by parameters stored in an old study + */ +//================================================================================ + +void StdMeshers_LayerDistribution_i::setOldParameters (const char* theParameters) +{ + if ( SMESH_Hypothesis_i* hyp1D_i = SMESH::DownCast< SMESH_Hypothesis_i*>( myHyp )) + hyp1D_i->setOldParameters( theParameters ); +}