From f35204c6bd94ceaec3f09176fd39e0fabf1c68f1 Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 13 Jan 2009 12:34:32 +0000 Subject: [PATCH] 0019941: EDF 766 SMESH : Max length hypothesis + interface StdMeshers_MaxLength : SMESH::SMESH_Hypothesis --- idl/SMESH_BasicHypothesis.idl | 38 +++ resources/StdMeshers.xml | 13 +- src/SMESH_I/SMESH_2smeshpy.cxx | 7 + src/SMESH_SWIG/smeshDC.py | 26 ++ src/StdMeshers/Makefile.am | 6 +- src/StdMeshers/StdMeshers_MaxLength.cxx | 241 ++++++++++++++++++ src/StdMeshers/StdMeshers_MaxLength.hxx | 71 ++++++ .../StdMeshersGUI_StdHypothesisCreator.cxx | 67 ++++- .../StdMeshersGUI_StdHypothesisCreator.h | 2 + src/StdMeshersGUI/StdMeshers_images.ts | 8 + src/StdMeshersGUI/StdMeshers_msg_en.ts | 12 + src/StdMeshers_I/Makefile.am | 4 +- src/StdMeshers_I/StdMeshers_MaxLength_i.cxx | 204 +++++++++++++++ src/StdMeshers_I/StdMeshers_MaxLength_i.hxx | 84 ++++++ src/StdMeshers_I/StdMeshers_i.cxx | 3 + 15 files changed, 778 insertions(+), 8 deletions(-) create mode 100644 src/StdMeshers/StdMeshers_MaxLength.cxx create mode 100644 src/StdMeshers/StdMeshers_MaxLength.hxx create mode 100644 src/StdMeshers_I/StdMeshers_MaxLength_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_MaxLength_i.hxx diff --git a/idl/SMESH_BasicHypothesis.idl b/idl/SMESH_BasicHypothesis.idl index 1fd3f02d7..07d594a04 100644 --- a/idl/SMESH_BasicHypothesis.idl +++ b/idl/SMESH_BasicHypothesis.idl @@ -72,6 +72,44 @@ module StdMeshers double GetPrecision(); }; + /*! + * StdMeshers_MaxLength: interface of "Max length" hypothesis + */ + interface StdMeshers_MaxLength : SMESH::SMESH_Hypothesis + { + /*! + * Sets parameter value + */ + void SetLength(in double length) + raises (SALOME::SALOME_Exception); + /*! + * Returns parameter value + */ + double GetLength(); + /*! + * Returns true if preestemated length is defined + */ + boolean HavePreestimatedLength(); + /*! + * Returns preestemated length + */ + double GetPreestimatedLength(); + /*! + * Sets preestemated length + */ + void SetPreestimatedLength(in double length); + /*! + * Sets boolean parameter enabling/desabling usage of length computed + * basing on size of bounding box of shape to mesh + */ + void SetUsePreestimatedLength(in boolean toUse); + /*! + * Returns value of boolean parameter enabling/desabling usage of length computed + * basing on size of bounding box of shape to mesh + */ + boolean GetUsePreestimatedLength(); + }; + /*! * StdMeshers_AutomaticLength: interface of "Automatic length" hypothesis */ diff --git a/resources/StdMeshers.xml b/resources/StdMeshers.xml index 892779e3c..e4673ce53 100644 --- a/resources/StdMeshers.xml +++ b/resources/StdMeshers.xml @@ -21,6 +21,11 @@ icon-id="mesh_hypo_length.png" dim="1"/> + + diff --git a/src/SMESH_I/SMESH_2smeshpy.cxx b/src/SMESH_I/SMESH_2smeshpy.cxx index 179275305..91332d7ed 100644 --- a/src/SMESH_I/SMESH_2smeshpy.cxx +++ b/src/SMESH_I/SMESH_2smeshpy.cxx @@ -1187,6 +1187,13 @@ Handle(_pyHypothesis) _pyHypothesis::NewHypothesis( const Handle(_pyCommand)& th // i.e. convertion result will be "locallength = regular1d.LocalLength()" hyp->AddArgMethod( "SetLength" ); } + else if ( hypType == "MaxLength" ) { + // set algo's method creating hyp, and algo type + hyp->SetConvMethodAndType( "MaxSize", "Regular_1D"); + // set method whose 1 arg will become the 1-st arg of hyp creation command + // i.e. convertion result will be "maxsize = regular1d.MaxSize()" + hyp->AddArgMethod( "SetLength" ); + } else if ( hypType == "NumberOfSegments" ) { hyp = new _pyNumberOfSegmentsHyp( theCreationCmd ); hyp->SetConvMethodAndType( "NumberOfSegments", "Regular_1D"); diff --git a/src/SMESH_SWIG/smeshDC.py b/src/SMESH_SWIG/smeshDC.py index b22ea3674..da15d1fa0 100644 --- a/src/SMESH_SWIG/smeshDC.py +++ b/src/SMESH_SWIG/smeshDC.py @@ -3040,6 +3040,32 @@ class Mesh_Segment(Mesh_Algorithm): return IsEqual(hyp.GetPrecision(), args[1]) return False + ## Defines "MaxSize" hypothesis to cut an edge into segments not longer than given value + # @param length is optional maximal allowed length of segment, if it is omitted + # the preestimated length is used that depends on geometry size + # @param UseExisting if ==true - searches for an existing hypothesis created with + # the same parameters, else (default) - create a new one + # @return an instance of StdMeshers_MaxLength hypothesis + # @ingroup l3_hypos_1dhyps + def MaxSize(self, length=0.0, UseExisting=0): + hyp = self.Hypothesis("MaxLength", [length], UseExisting=UseExisting) + if length > 0.0: + # set given length + hyp.SetLength(length) + if not UseExisting: + # set preestimated length + gen = self.mesh.smeshpyD + initHyp = gen.GetHypothesisParameterValues("MaxLength", "libStdMeshersEngine.so", + self.mesh.GetMesh(), self.mesh.GetShape(), + False) # <- byMesh + preHyp = initHyp._narrow(StdMeshers.StdMeshers_MaxLength) + if preHyp: + hyp.SetPreestimatedLength( preHyp.GetPreestimatedLength() ) + pass + pass + hyp.SetUsePreestimatedLength( length == 0.0 ) + return hyp + ## Defines "NumberOfSegments" hypothesis to cut an edge in a fixed number of segments # @param n for the number of segments that cut an edge # @param s for the scale factor (optional) diff --git a/src/StdMeshers/Makefile.am b/src/StdMeshers/Makefile.am index 89241464c..eead610af 100644 --- a/src/StdMeshers/Makefile.am +++ b/src/StdMeshers/Makefile.am @@ -67,7 +67,8 @@ salomeinclude_HEADERS = \ StdMeshers_QuadToTriaAdaptor.hxx \ SMESH_StdMeshers.hxx \ StdMeshers_TrianglePreference.hxx \ - StdMeshers_CompositeHexa_3D.hxx + StdMeshers_CompositeHexa_3D.hxx \ + StdMeshers_MaxLength.hxx # Libraries targets @@ -111,7 +112,8 @@ dist_libStdMeshers_la_SOURCES = \ StdMeshers_UseExisting_1D2D.cxx \ StdMeshers_QuadToTriaAdaptor.cxx \ StdMeshers_TrianglePreference.cxx \ - StdMeshers_CompositeHexa_3D.cxx + StdMeshers_CompositeHexa_3D.cxx \ + StdMeshers_MaxLength.cxx # additionnal information to compil and link file diff --git a/src/StdMeshers/StdMeshers_MaxLength.cxx b/src/StdMeshers/StdMeshers_MaxLength.cxx new file mode 100644 index 000000000..32ba95ddc --- /dev/null +++ b/src/StdMeshers/StdMeshers_MaxLength.cxx @@ -0,0 +1,241 @@ +// 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_MaxLength.cxx +// Module : SMESH + +#include "StdMeshers_MaxLength.hxx" + +#include "SMESH_Mesh.hxx" +#include "SMESH_Algo.hxx" + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_MaxLength::StdMeshers_MaxLength(int hypId, int studyId, SMESH_Gen * gen) + :SMESH_Hypothesis(hypId, studyId, gen) +{ + _length = 1.; + _preestimated = 0.; + _preestimation = false; + _name = "MaxLength"; + _param_algo_dim = 1; // is used by SMESH_Regular_1D +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_MaxLength::~StdMeshers_MaxLength() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_MaxLength::SetLength(double length) throw(SALOME_Exception) +{ + if (length <= 0) + throw SALOME_Exception(LOCALIZED("length must be positive")); + if ( _length != length ) { + _length = length; + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_MaxLength::GetLength() const +{ + return ( _preestimation && _preestimated > 0. ) ? _preestimated : _length; +} + +//================================================================================ +/*! + * \brief Sets boolean parameter enabling/desabling usage of length computed + * basing on size of bounding box of shape to mesh + */ +//================================================================================ + +void StdMeshers_MaxLength::SetUsePreestimatedLength(bool toUse) +{ + if ( toUse != _preestimation ) + { + _preestimation = toUse; + NotifySubMeshesHypothesisModification(); + } +} + +//================================================================================ +/*! + * \brief Store preestemated length + */ +//================================================================================ + +void StdMeshers_MaxLength::SetPreestimatedLength(double length) +{ + if ( length > 0 ) + _preestimated = length; +} + +//================================================================================ +/*! + * \brief Returns value of boolean parameter enabling/desabling usage of length computed + * basing on size of bounding box of shape to mesh + */ +//================================================================================ + +bool StdMeshers_MaxLength::GetUsePreestimatedLength() const +{ + return _preestimation; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_MaxLength::SaveTo(ostream & save) +{ + save << _length << " " << _preestimated << " " << _preestimation; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_MaxLength::LoadFrom(istream & load) +{ + bool isOK = true; + double a; + + isOK = (load >> a); + if (isOK) + _length = a; + else + load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> a); + if (isOK) + _preestimated = a; + else + load.clear(ios::badbit | load.rdstate()); + + bool pre; + isOK = (load >> pre); + if ( isOK ) + _preestimation = pre; + else + load.clear(ios::badbit | load.rdstate()); + + return load; +} + +//================================================================================ +/*! + * \brief Initialize segment length by the mesh built on the geometry + * \param theMesh - the built mesh + * \param theShape - the geometry of interest + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_MaxLength::SetParametersByMesh(const SMESH_Mesh* theMesh, + const TopoDS_Shape& theShape) +{ + if ( !theMesh || theShape.IsNull() ) + return false; + + _length = 0.; + + Standard_Real UMin, UMax; + TopLoc_Location L; + + int nbEdges = 0; + TopTools_IndexedMapOfShape edgeMap; + TopExp::MapShapes( theShape, TopAbs_EDGE, edgeMap ); + for ( int iE = 1; iE <= edgeMap.Extent(); ++iE ) + { + const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( iE )); + Handle(Geom_Curve) C = BRep_Tool::Curve( edge, L, UMin, UMax ); + GeomAdaptor_Curve AdaptCurve(C); + + vector< double > params; + SMESHDS_Mesh* aMeshDS = const_cast< SMESH_Mesh* >( theMesh )->GetMeshDS(); + if ( SMESH_Algo::GetNodeParamOnEdge( aMeshDS, edge, params )) + { + for ( int i = 1; i < params.size(); ++i ) + _length += GCPnts_AbscissaPoint::Length( AdaptCurve, params[ i-1 ], params[ i ]); + nbEdges += params.size() - 1; + } + } + if ( nbEdges ) + _length /= nbEdges; + + return nbEdges; +} +//================================================================================ +/*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ +//================================================================================ + +bool StdMeshers_MaxLength::SetParametersByElementSize(double elemLenght, + const SMESH_Mesh* /*theMesh*/) +{ + _preestimation = ( elemLenght > 0.); + if ( _preestimation ) + _preestimated = elemLenght; + return bool( _length = elemLenght ); +} + diff --git a/src/StdMeshers/StdMeshers_MaxLength.hxx b/src/StdMeshers/StdMeshers_MaxLength.hxx new file mode 100644 index 000000000..507706bb0 --- /dev/null +++ b/src/StdMeshers/StdMeshers_MaxLength.hxx @@ -0,0 +1,71 @@ +// 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_MaxLength.hxx +// Module : SMESH + +#ifndef _SMESH_MaxLength_HXX_ +#define _SMESH_MaxLength_HXX_ + +#include "SMESH_StdMeshers.hxx" + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class STDMESHERS_EXPORT StdMeshers_MaxLength: public SMESH_Hypothesis +{ + public: + StdMeshers_MaxLength(int hypId, int studyId, SMESH_Gen * gen); + virtual ~ StdMeshers_MaxLength(); + + void SetLength(double length) throw(SALOME_Exception); + double GetLength() const; + + bool HavePreestimatedLength() const { return _preestimated > 0.; } + double GetPreestimatedLength() const { return _preestimated; } + void SetPreestimatedLength(double length); + + void SetUsePreestimatedLength(bool toUse); + bool GetUsePreestimatedLength() const; + + virtual std::ostream & SaveTo(std::ostream & save); + virtual std::istream & LoadFrom(std::istream & load); + + /*! + * \brief Initialize segment length by the mesh built on the geometry + * \param theMesh - the built mesh + * \param theShape - the geometry of interest + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByMesh(const SMESH_Mesh* theMesh, const TopoDS_Shape& theShape); + + /*! + * \brief Initialize my parameter values by linear size of mesh element. + * \retval bool - true if parameter values have been successfully defined + */ + virtual bool SetParametersByElementSize( double elemLenght, const SMESH_Mesh* theMesh=0); + + protected: + double _length, _preestimated; + bool _preestimation; +}; + +#endif diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index 499b9bf28..5fc050ece 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -45,6 +45,7 @@ #include #include #include +#include const double VALUE_MAX = 1.0e+15, // COORD_MAX VALUE_MAX_2 = VALUE_MAX * VALUE_MAX, @@ -91,7 +92,7 @@ QWidget* StdMeshersGUI_StdHypothesisCreator::getWidgetForParam( int i ) const if ( i < myCustomWidgets.count() ) { QList::const_iterator anIt = myCustomWidgets.begin(); QList::const_iterator aLast = myCustomWidgets.end(); - for ( int j = 0 ; !w && anIt != aLast; ++anIt ) + for ( int j = 0 ; !w && anIt != aLast; ++anIt, ++j ) if ( i == j ) w = *anIt; } @@ -408,6 +409,19 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const h->SetLength( params[0].myValue.toDouble() ); h->SetPrecision( params[1].myValue.toDouble() ); } + else if( hypType()=="MaxLength" ) + { + StdMeshers::StdMeshers_MaxLength_var h = + StdMeshers::StdMeshers_MaxLength::_narrow( hypothesis() ); + + h->SetLength( params[0].myValue.toDouble() ); + h->SetUsePreestimatedLength( widget< QCheckBox >( 1 )->isChecked() ); + if ( !h->HavePreestimatedLength() && !h->_is_equivalent( initParamsHypothesis() )) { + StdMeshers::StdMeshers_MaxLength_var hInit = + StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() ); + h->SetPreestimatedLength( hInit->GetPreestimatedLength() ); + } + } else if( hypType()=="SegmentLengthAroundVertex" ) { StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h = @@ -558,6 +572,29 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const item.myValue = h->GetPrecision(); p.append( item ); } + if( hypType()=="MaxLength" ) + { + StdMeshers::StdMeshers_MaxLength_var h = + StdMeshers::StdMeshers_MaxLength::_narrow( hyp ); + + item.myName = tr("SMESH_LOCAL_LENGTH_PARAM"); + item.myValue = h->GetLength(); + p.append( item ); + customWidgets()->append(0); + + item.myName = tr("SMESH_USE_PREESTIMATED_LENGTH"); + p.append( item ); + QCheckBox* aQCheckBox = new QCheckBox(dlg()); + if ( h->HavePreestimatedLength() ) { + aQCheckBox->setChecked( h->GetUsePreestimatedLength() ); + connect( aQCheckBox, SIGNAL( stateChanged(int) ), this, SLOT( onValueChanged() ) ); + } + else { + aQCheckBox->setChecked( false ); + aQCheckBox->setEnabled( false ); + } + customWidgets()->append( aQCheckBox ); + } else if( hypType()=="SegmentLengthAroundVertex" ) { StdMeshers::StdMeshers_SegmentLengthAroundVertex_var h = @@ -740,6 +777,11 @@ void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) { sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 ); } + else if( hypType()=="MaxLength" && sb ) + { + sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, 6 ); + sb->setEnabled( !widget< QCheckBox >( 1 )->isChecked() ); + } else if( hypType()=="MaxElementArea" && sb ) { sb->RangeStepAndValidator( VALUE_SMALL_2, VALUE_MAX_2, 1.0, 6 ); @@ -827,6 +869,7 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons types.insert( "NumberOfLayers", "NUMBER_OF_LAYERS" ); types.insert( "LayerDistribution", "LAYER_DISTRIBUTION" ); types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" ); + types.insert( "MaxLength", "MAX_LENGTH" ); } QString res; @@ -878,6 +921,10 @@ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & pa return true; } } + if ( hypType() == "MaxLength" ) { + param.myValue = ""; + return true; + } if ( widget->inherits( "StdMeshersGUI_ObjectReferenceParamWdg" )) { // show only 1st reference value @@ -912,3 +959,21 @@ void StdMeshersGUI_StdHypothesisCreator::onReject() deactivateObjRefParamWdg( customWidgets() ); } } + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +void StdMeshersGUI_StdHypothesisCreator::valueChanged( QWidget* paramWidget) +{ + if ( hypType() == "MaxLength" && paramWidget == getWidgetForParam(1) ) { + getWidgetForParam(0)->setEnabled( !widget< QCheckBox >( 1 )->isChecked() ); + if ( !getWidgetForParam(0)->isEnabled() ) { + StdMeshers::StdMeshers_MaxLength_var h = + StdMeshers::StdMeshers_MaxLength::_narrow( initParamsHypothesis() ); + widget< QtxDoubleSpinBox >( 0 )->setValue( h->GetPreestimatedLength() ); + } + } +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h index 501e7aa91..66f34bd82 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.h @@ -59,6 +59,8 @@ protected: virtual ListOfWidgets* customWidgets() const; virtual void onReject(); + virtual void valueChanged( QWidget* ); + template T* widget(int i) const { return dynamic_cast< T* >( getWidgetForParam( i )); diff --git a/src/StdMeshersGUI/StdMeshers_images.ts b/src/StdMeshersGUI/StdMeshers_images.ts index a58fd4017..cd7e0e1b7 100644 --- a/src/StdMeshersGUI/StdMeshers_images.ts +++ b/src/StdMeshersGUI/StdMeshers_images.ts @@ -26,6 +26,10 @@ ICON_DLG_LOCAL_LENGTH mesh_hypo_length.png + + ICON_DLG_MAX_LENGTH + mesh_hypo_length.png + ICON_DLG_MAX_ELEMENT_AREA mesh_hypo_area.png @@ -130,6 +134,10 @@ ICON_SMESH_TREE_HYPO_LocalLength mesh_tree_hypo_length.png + + ICON_SMESH_TREE_HYPO_MaxLength + mesh_tree_hypo_length.png + ICON_SMESH_TREE_HYPO_MaxElementArea mesh_tree_hypo_area.png diff --git a/src/StdMeshersGUI/StdMeshers_msg_en.ts b/src/StdMeshersGUI/StdMeshers_msg_en.ts index 723f5ffaf..0f7ac022b 100644 --- a/src/StdMeshersGUI/StdMeshers_msg_en.ts +++ b/src/StdMeshersGUI/StdMeshers_msg_en.ts @@ -126,6 +126,18 @@ SMESH_LOCAL_LENGTH_TITLE Hypothesis Construction + + SMESH_MAX_LENGTH_HYPOTHESIS + Max Length + + + SMESH_USE_PREESTIMATED_LENGTH + Use preestimated length + + + SMESH_MAX_LENGTH_TITLE + Hypothesis Construction + SMESH_MAX_ELEMENT_AREA_HYPOTHESIS Max. Element Area diff --git a/src/StdMeshers_I/Makefile.am b/src/StdMeshers_I/Makefile.am index 1ae2885ad..167e40e71 100644 --- a/src/StdMeshers_I/Makefile.am +++ b/src/StdMeshers_I/Makefile.am @@ -60,6 +60,7 @@ salomeinclude_HEADERS = \ StdMeshers_SegmentLengthAroundVertex_i.hxx \ StdMeshers_UseExisting_1D2D_i.hxx \ StdMeshers_TrianglePreference_i.hxx \ + StdMeshers_MaxLength_i.hxx \ SMESH_StdMeshers_I.hxx # Libraries targets @@ -96,7 +97,8 @@ dist_libStdMeshersEngine_la_SOURCES = \ StdMeshers_SegmentAroundVertex_0D_i.cxx \ StdMeshers_SegmentLengthAroundVertex_i.cxx \ StdMeshers_UseExisting_1D2D_i.cxx \ - StdMeshers_TrianglePreference_i.cxx + StdMeshers_TrianglePreference_i.cxx \ + StdMeshers_MaxLength_i.cxx # additionnal information to compil and link file libStdMeshersEngine_la_CPPFLAGS = \ diff --git a/src/StdMeshers_I/StdMeshers_MaxLength_i.cxx b/src/StdMeshers_I/StdMeshers_MaxLength_i.cxx new file mode 100644 index 000000000..bbed6c448 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_MaxLength_i.cxx @@ -0,0 +1,204 @@ +// 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_MaxLength_i.cxx +// Module : SMESH + +#include "StdMeshers_MaxLength_i.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_PythonDump.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include + +using namespace std; + +//============================================================================= +/*! + * StdMeshers_MaxLength_i::StdMeshers_MaxLength_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_MaxLength_i::StdMeshers_MaxLength_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + myBaseImpl = new ::StdMeshers_MaxLength( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_MaxLength_i::~StdMeshers_MaxLength_i() +{ +} + +//============================================================================= +/*! + * StdMeshers_MaxLength_i::SetLength + * + * Set length + */ +//============================================================================= +void StdMeshers_MaxLength_i::SetLength( CORBA::Double theLength ) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetLength( theLength ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + + // Update Python script + SMESH::TPythonDump() << _this() << ".SetLength( " << theLength << " )"; +} + +//============================================================================= +/*! + * Sets preestimation flag + */ +//============================================================================= +void StdMeshers_MaxLength_i::SetUsePreestimatedLength( CORBA::Boolean toUse ) + throw ( SALOME::SALOME_Exception ) +{ + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetUsePreestimatedLength( toUse ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + + // this is an internal kitchen call - no Python dump + // Update Python script + //SMESH::TPythonDump() << _this() << ".SetUsePreestimatedLength( " << toUse << " )"; +} + +//============================================================================= +/*! + * Sets preestimation length + */ +//============================================================================= +void StdMeshers_MaxLength_i::SetPreestimatedLength( CORBA::Double theLength ) +{ + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetPreestimatedLength( theLength ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + // this is an internal kitchen call - no Python dump + // Update Python script + //SMESH::TPythonDump() << _this() << ".SetPreestimatedLength( " << toUse << " )"; +} + +//============================================================================= +/*! + * StdMeshers_MaxLength_i::GetLength + * + * Get length + */ +//============================================================================= +CORBA::Double StdMeshers_MaxLength_i::GetLength() +{ + ASSERT( myBaseImpl ); + return this->GetImpl()->GetLength(); +} + +//============================================================================= +/*! + * StdMeshers_MaxLength_i::GetPreestimatedLength + */ +//============================================================================= +CORBA::Double StdMeshers_MaxLength_i::GetPreestimatedLength() +{ + ASSERT( myBaseImpl ); + return this->GetImpl()->GetPreestimatedLength(); +} + +//============================================================================= +/*! + * Returns preestimation flag + */ +//============================================================================= +CORBA::Boolean StdMeshers_MaxLength_i::GetUsePreestimatedLength() +{ + ASSERT( myBaseImpl ); + return this->GetImpl()->GetUsePreestimatedLength(); +} + +//================================================================================ +/*! + * \brief Returns true if preestemated length is defined + */ +//================================================================================ + +CORBA::Boolean StdMeshers_MaxLength_i::HavePreestimatedLength() +{ + ASSERT( myBaseImpl ); + return this->GetImpl()->HavePreestimatedLength(); +} + +//============================================================================= +/*! + * StdMeshers_MaxLength_i::GetImpl + * + * Get implementation + */ +//============================================================================= +::StdMeshers_MaxLength* StdMeshers_MaxLength_i::GetImpl() +{ + return ( ::StdMeshers_MaxLength* )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_MaxLength_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_1D; +} diff --git a/src/StdMeshers_I/StdMeshers_MaxLength_i.hxx b/src/StdMeshers_I/StdMeshers_MaxLength_i.hxx new file mode 100644 index 000000000..715da7a23 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_MaxLength_i.hxx @@ -0,0 +1,84 @@ +// 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_MaxLength_i.hxx +// Module : SMESH + +#ifndef _SMESH_MaxLength_I_HXX_ +#define _SMESH_MaxLength_I_HXX_ + +#include "SMESH_StdMeshers_I.hxx" + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_MaxLength.hxx" + +class SMESH_Gen; + +// ====================================================== +// Local Length hypothesis +// ====================================================== +class STDMESHERS_I_EXPORT StdMeshers_MaxLength_i: + public virtual POA_StdMeshers::StdMeshers_MaxLength, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_MaxLength_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_MaxLength_i(); + + // Set length + void SetLength( CORBA::Double theLength ) + throw ( SALOME::SALOME_Exception ); + // Set precision + + // Sets preestimation flag + void SetUsePreestimatedLength( CORBA::Boolean toUse) + throw ( SALOME::SALOME_Exception ); + + // Get length + CORBA::Double GetLength(); + + // Returns true if preestemated length is defined + CORBA::Boolean HavePreestimatedLength(); + + CORBA::Double GetPreestimatedLength(); + + // Sets preestemated length + void SetPreestimatedLength(CORBA::Double theLength); + + // Returns preestimation flag + CORBA::Boolean GetUsePreestimatedLength(); + + // Get implementation + ::StdMeshers_MaxLength* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_i.cxx b/src/StdMeshers_I/StdMeshers_i.cxx index 38fae1733..eba605497 100644 --- a/src/StdMeshers_I/StdMeshers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_i.cxx @@ -51,6 +51,7 @@ #include "StdMeshers_NumberOfLayers_i.hxx" #include "StdMeshers_LayerDistribution_i.hxx" #include "StdMeshers_SegmentLengthAroundVertex_i.hxx" +#include "StdMeshers_MaxLength_i.hxx" #include "StdMeshers_Regular_1D_i.hxx" #include "StdMeshers_MEFISTO_2D_i.hxx" @@ -87,6 +88,8 @@ STDMESHERS_I_EXPORT // Hypotheses if (strcmp(aHypName, "LocalLength") == 0) aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "MaxLength") == 0) + aCreator = new StdHypothesisCreator_i; else if (strcmp(aHypName, "NumberOfSegments") == 0) aCreator = new StdHypothesisCreator_i; else if (strcmp(aHypName, "LengthFromEdges") == 0) -- 2.39.2