From: dmv Date: Wed, 8 Jul 2009 10:34:09 +0000 (+0000) Subject: 0020082: EDF 869 GEOM : Edges Orientation indicator/reverse X-Git-Tag: V5_1_3rc1~149 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=184f00f38ef65b5d58b798e8c13042c16e030a4f 0020082: EDF 869 GEOM : Edges Orientation indicator/reverse --- diff --git a/doc/salome/gui/SMESH/images/a-arithmetic1d.png b/doc/salome/gui/SMESH/images/a-arithmetic1d.png index d34a5e24c..aa43beb5f 100755 Binary files a/doc/salome/gui/SMESH/images/a-arithmetic1d.png and b/doc/salome/gui/SMESH/images/a-arithmetic1d.png differ diff --git a/doc/salome/gui/SMESH/images/a-nbsegments1.png b/doc/salome/gui/SMESH/images/a-nbsegments1.png index 27668505c..0cd778fc4 100755 Binary files a/doc/salome/gui/SMESH/images/a-nbsegments1.png and b/doc/salome/gui/SMESH/images/a-nbsegments1.png differ diff --git a/doc/salome/gui/SMESH/images/a-nbsegments2.png b/doc/salome/gui/SMESH/images/a-nbsegments2.png index 8d4f277d9..2a7c9fcaa 100755 Binary files a/doc/salome/gui/SMESH/images/a-nbsegments2.png and b/doc/salome/gui/SMESH/images/a-nbsegments2.png differ diff --git a/doc/salome/gui/SMESH/images/a-startendlength.png b/doc/salome/gui/SMESH/images/a-startendlength.png index 947567d7f..ba29d91df 100755 Binary files a/doc/salome/gui/SMESH/images/a-startendlength.png and b/doc/salome/gui/SMESH/images/a-startendlength.png differ diff --git a/doc/salome/gui/SMESH/images/distributionwithanalyticdensity.png b/doc/salome/gui/SMESH/images/distributionwithanalyticdensity.png index 7dea248c6..83c086b43 100755 Binary files a/doc/salome/gui/SMESH/images/distributionwithanalyticdensity.png and b/doc/salome/gui/SMESH/images/distributionwithanalyticdensity.png differ diff --git a/doc/salome/gui/SMESH/images/distributionwithtabledensity.png b/doc/salome/gui/SMESH/images/distributionwithtabledensity.png index 3bd40bc45..60847cde5 100755 Binary files a/doc/salome/gui/SMESH/images/distributionwithtabledensity.png and b/doc/salome/gui/SMESH/images/distributionwithtabledensity.png differ diff --git a/doc/salome/gui/SMESH/input/1d_meshing_hypo.doc b/doc/salome/gui/SMESH/input/1d_meshing_hypo.doc index 705354692..38c0055df 100644 --- a/doc/salome/gui/SMESH/input/1d_meshing_hypo.doc +++ b/doc/salome/gui/SMESH/input/1d_meshing_hypo.doc @@ -21,6 +21,12 @@ length that changes in arithmetic progression (Lk = Lk-1 + d) beginning from a given starting length and up to a given end length. +The direction of the splitting is defined by the orientation of the underlying geometrical edge. +"Reverse Edges" list box allows to specify the edges for which the splitting should be made +in the direction opposing to their orientation. This list box is enabled only if the geometry object +is selected for the meshing. In this case the user can select edges to be reversed either directly +picking them in the 3D viewer or by selecting the edges or groups of edges in the Object browser. + \image html a-arithmetic1d.png \image html b-ithmetic1d.png "Arithmetic 1D hypothesis - the size of mesh elements gradually increases" @@ -106,6 +112,12 @@ edges generated by these segments will represent nodes of your mesh. Later these nodes will be used for meshing of the faces abutting to these edges. +The direction of the splitting is defined by the orientation of the underlying geometrical edge. +"Reverse Edges" list box allows to specify the edges for which the splitting should be made +in the direction opposing to their orientation. This list box is enabled only if the geometry object +is selected for the meshing. In this case the user can select edges to be reversed either directly +picking them in the 3D viewer or by selecting the edges or groups of edges in the Object browser. + \image html image46.gif You can set the type of distribution for this hypothesis in the @@ -149,6 +161,12 @@ geometric progression. Then mesh nodes are constructed at segment ends location and 1D mesh elements are constructed on them. +The direction of the splitting is defined by the orientation of the underlying geometrical edge. +"Reverse Edges" list box allows to specify the edges for which the splitting should be made +in the direction opposing to their orientation. This list box is enabled only if the geometry object +is selected for the meshing. In this case the user can select edges to be reversed either directly +picking them in the 3D viewer or by selecting the edges or groups of edges in the Object browser. + \image html a-startendlength.png \image html b-art_end_length.png "The lengths of the first and the last segment are strictly defined" diff --git a/idl/SMESH_BasicHypothesis.idl b/idl/SMESH_BasicHypothesis.idl index 9c428ba14..db057f860 100644 --- a/idl/SMESH_BasicHypothesis.idl +++ b/idl/SMESH_BasicHypothesis.idl @@ -29,7 +29,6 @@ #include "SMESH_Hypothesis.idl" #include "SMESH_Mesh.idl" - /*! * StdMeshers: interfaces to standard hypotheses and algorithms */ @@ -209,6 +208,26 @@ module StdMeshers */ long ConversionMode() raises (SALOME::SALOME_Exception); + + /*! + * Set list of edges to reverse + */ + void SetReversedEdges( in SMESH::long_array list ); + + /*! + * Returns list of edges to reverse + */ + SMESH::long_array GetReversedEdges(); + + /*! + * Set entry of the main object + */ + void SetObjectEntry( in string entry ); + + /*! + * Get the entry of the main object + */ + string GetObjectEntry(); }; /*! @@ -226,6 +245,26 @@ module StdMeshers * Returns or parameter value */ double GetLength(in boolean isStartLength); + + /*! + * Set list of edges to reverse + */ + void SetReversedEdges( in SMESH::long_array list ); + + /*! + * Returns list of edges to reverse + */ + SMESH::long_array GetReversedEdges(); + + /*! + * Set entry of the main object + */ + void SetObjectEntry( in string entry ); + + /*! + * Get the entry of the main object + */ + string GetObjectEntry(); }; /*! @@ -277,6 +316,26 @@ module StdMeshers * Returns or parameter value */ double GetLength(in boolean isStartLength); + + /*! + * Set list of edges to reverse + */ + void SetReversedEdges( in SMESH::long_array list ); + + /*! + * Returns list of edges to reverse + */ + SMESH::long_array GetReversedEdges(); + + /*! + * Set entry of the main object + */ + void SetObjectEntry( in string entry ); + + /*! + * Get the entry of the main object + */ + string GetObjectEntry(); }; diff --git a/src/OBJECT/Makefile.am b/src/OBJECT/Makefile.am index bd233661a..8ef36754f 100644 --- a/src/OBJECT/Makefile.am +++ b/src/OBJECT/Makefile.am @@ -34,6 +34,7 @@ salomeinclude_HEADERS = \ SMESH_ActorUtils.h \ SMESH_ActorDef.h \ SMESH_DeviceActor.h \ + SMESH_PreviewActorsCollection.h \ SMESH_ExtractGeometry.h \ SMESH_ActorUtils.h \ SMESH_FaceOrientationFilter.h @@ -45,11 +46,13 @@ dist_libSMESHObject_la_SOURCES = \ SMESH_Object.cxx \ SMESH_DeviceActor.cxx \ SMESH_Actor.cxx \ + SMESH_PreviewActorsCollection.cxx \ SMESH_ExtractGeometry.cxx \ SMESH_ActorUtils.cxx \ SMESH_FaceOrientationFilter.cxx libSMESHObject_la_CPPFLAGS = \ + $(QT_INCLUDES) \ $(KERNEL_CXXFLAGS) \ $(GUI_CXXFLAGS) \ $(MED_CXXFLAGS) \ diff --git a/src/OBJECT/SMESH_PreviewActorsCollection.cxx b/src/OBJECT/SMESH_PreviewActorsCollection.cxx new file mode 100644 index 000000000..59238dcf1 --- /dev/null +++ b/src/OBJECT/SMESH_PreviewActorsCollection.cxx @@ -0,0 +1,206 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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. +// +// 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 +// +// SMESH OBJECT : interactive object for SMESH visualization +// File : SMESH_PreviewActorsCollection.cxx +// Author : +// Module : SMESH +// + +#include "SMESH_PreviewActorsCollection.h" + +#include "utilities.h" + +#include "SALOME_InteractiveObject.hxx" + +// OCC includes +#include +#include +#include + +// VTK includes +#include +#include +#include +#include +#include + +#include "VTKViewer_Actor.h" + +#include "SVTK_DeviceActor.h" +#include "SALOME_Actor.h" + +// QT +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +using namespace std; + + +//vtkStandardNewMacro(SMESH_PreviewActorsCollection); + + +SMESH_PreviewActorsCollection +::SMESH_PreviewActorsCollection() +{ + if(MYDEBUG) MESSAGE("SMESH_PreviewActorsCollection - "<setEntry( theEntry.toLatin1().constData() ); + + // get indexes of seleted elements + TopExp::MapShapes(theShape, myMapOfShapes); + + TopExp_Explorer exp( theShape, theType ); + for ( ; exp.More(); exp.Next() ) { + int index = myMapOfShapes.FindIndex( exp.Current() ); + if ( index ) { + // create actor if the index is present + if ( GEOM_Actor* anActor = createActor( exp.Current() )) { + // Create new entry for actor + QString aString = theEntry; + aString += QString("_%1").arg( index ); // add index to actor entry + + // Create interactive object + Handle( SALOME_InteractiveObject ) anIO = new SALOME_InteractiveObject(); + anIO->setEntry( aString.toLatin1().constData() ); + + // Init Actor + anActor->SetVectorMode( true ); + anActor->setIO( anIO ); + anActor->SetSelector( mySelector ); + anActor->SetPickable( true ); + anActor->SetResolveCoincidentTopology( true ); + + // Add Actor to the Actors Map + myMapOfActors.insert(index, anActor); + } + } + } + mySelector->ClearIObjects(); + + return true; +} + +GEOM_Actor* SMESH_PreviewActorsCollection::createActor(const TopoDS_Shape& shape) +{ + GEOM_Actor* actor = GEOM_Actor::New(); + actor->SetShape(shape,0,0); + + //Color Properties + /* + vtkProperty* aProp = vtkProperty::New(); + vtkProperty* aHLProp = vtkProperty::New(); + vtkProperty* aPHLProp = vtkProperty::New(); + + aProp->SetColor( 255, 0, 0); + actor->SetProperty(aProp); + + aHLProp->SetColor( 255, 255, 255); + actor->SetHighlightProperty(aHLProp); + + aPHLProp->SetColor( 155, 155, 155); + aPHLProp->SetLineWidth ( 3 ); + aPHLProp->SetOpacity ( 0.75 ); + actor->SetPreHighlightProperty(aPHLProp); + + aProp->Delete(); + aHLProp->Delete(); + aPHLProp->Delete(); + */ + + return actor; +} + +GEOM_Actor* SMESH_PreviewActorsCollection::GetActorByIndex(int index) +{ + return myMapOfActors.value(index); +} + +int SMESH_PreviewActorsCollection::GetIndexByShape( const TopoDS_Shape& theShape ) +{ + return myMapOfShapes.FindIndex( theShape ); +} + +void SMESH_PreviewActorsCollection::AddToRender(vtkRenderer* theRenderer) +{ + myRenderer = theRenderer; + + QMap::iterator iter = myMapOfActors.begin(); + for ( ; iter != myMapOfActors.end(); ++iter ) + iter.value()->AddToRender( theRenderer ); +} + +void SMESH_PreviewActorsCollection::RemoveFromRender(vtkRenderer* theRenderer){ + QMap::iterator iter = myMapOfActors.begin(); + for ( ; iter != myMapOfActors.end(); ++iter ) + iter.value()->RemoveFromRender( theRenderer ); +} + +void SMESH_PreviewActorsCollection::SetSelector(SVTK_Selector* theSelector) +{ + mySelector = theSelector; +} + +void SMESH_PreviewActorsCollection::HighlightAll( bool theHighlight ){ + QMap::iterator iter = myMapOfActors.begin(); + for ( ; iter != myMapOfActors.end(); ++iter ) + iter.value()->Highlight( theHighlight ); +} + +void SMESH_PreviewActorsCollection::HighlightID( int index ){ + GEOM_Actor* anActor = GetActorByIndex( index ); + if ( anActor && !anActor->isHighlighted() ) + anActor->Highlight( true ); +} + +void SMESH_PreviewActorsCollection::SetShown( bool shown ){ + QMap::iterator iter = myMapOfActors.begin(); + for ( ; iter != myMapOfActors.end(); ++iter ) + iter.value()->SetVisibility( shown ); +} diff --git a/src/OBJECT/SMESH_PreviewActorsCollection.h b/src/OBJECT/SMESH_PreviewActorsCollection.h new file mode 100644 index 000000000..857570ace --- /dev/null +++ b/src/OBJECT/SMESH_PreviewActorsCollection.h @@ -0,0 +1,78 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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. +// +// 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 +// +// SMESH OBJECT : interactive object for SMESH visualization +// File : SMESH_PreviewActorsCollection.h +// Author : OCN +// Module : SMESH +// $Header: /home/server/cvs/SMESH/SMESH_SRC/src/OBJECT/SMESH_PreviewActorsCollection.h,v 1 +// +#ifndef SMESH_PREVIEW_ACTOR_COLLECTION_H +#define SMESH_PREVIEW_ACTOR_COLLECTION_H + +#include +#include +#include "SMESH_Object.h" +#include +#include +#include +#include +#include +#include + +class vtkRenderer; +class GEOM_Actor; + +class SMESHOBJECT_EXPORT SMESH_PreviewActorsCollection +{ + public: + SMESH_PreviewActorsCollection(); + ~SMESH_PreviewActorsCollection(); + + virtual void AddToRender(vtkRenderer* theRenderer); + virtual void RemoveFromRender(vtkRenderer* theRenderer); + + bool Init( const TopoDS_Shape& theShape, TopAbs_ShapeEnum subShapeType = TopAbs_EDGE, const QString& = QString("") ); + + void SetSelector( SVTK_Selector* ); + + void HighlightAll( bool ); + void HighlightID( int ); + + GEOM_Actor* GetActorByIndex( int ); + + int GetIndexByShape( const TopoDS_Shape& ); + + void SetShown( bool ); + + protected: + GEOM_Actor* createActor( const TopoDS_Shape& ); + + protected: + TopoDS_Shape myMainShape; + SVTK_Selector* mySelector; + vtkRenderer* myRenderer; + TopTools_IndexedMapOfShape myMapOfShapes; + QMap myMapOfActors; +}; + + +#endif //SMESH_DEVICE_ACTOR_COLLECTION_H diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.cxx b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx index e636ea8d6..3e3c6338f 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.cxx +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx @@ -159,6 +159,7 @@ bool SMESHGUI_GenericHypothesisCreator::editHypothesis( SMESH::SMESH_Hypothesis_ Dlg->setType( type() ); retrieveParams(); Dlg->show(); + Dlg->resize( Dlg->minimumSizeHint() ); if ( !myEventLoop ) myEventLoop = new QEventLoop( this ); myEventLoop->exec(); // make myDlg not modal @@ -383,6 +384,11 @@ SMESH::SMESH_Hypothesis_var SMESHGUI_GenericHypothesisCreator::hypothesis() cons return myHypo; } +void SMESHGUI_GenericHypothesisCreator::setShapeEntry( const QString& theEntry ) +{ + myShapeEntry = theEntry; +} + //================================================================================ /*! * \brief Return hypothesis containing initial parameters diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.h b/src/SMESHGUI/SMESHGUI_Hypotheses.h index 6cf6c524d..f4db07a2e 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.h +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.h @@ -64,6 +64,9 @@ public: QString hypType() const; QString hypName() const; bool isCreation() const; + + QString getShapeEntry() const { return myShapeEntry; } + void setShapeEntry( const QString& theEntry ); protected: struct StdParam @@ -121,6 +124,7 @@ private: bool myIsCreate; QtxDialog* myDlg; QEventLoop* myEventLoop; + QString myShapeEntry; }; class SMESHGUI_HypothesisDlg : public QtxDialog diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index ae29fc4b1..c617ecc79 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -1063,6 +1063,15 @@ void SMESHGUI_MeshOp::createHypothesis (const int theDim, int obj = myDlg->getActiveObject(); removeCustomFilters(); // Issue 0020170 + + // Set Geometry + QStringList aList; + myDlg->selectedObject( SMESHGUI_MeshDlg::Geom, aList ); + if (aList.count() != 0) + aCreator->setShapeEntry( aList.first() ); + else + aCreator->setShapeEntry( QString() ); + myDlg->setEnabled( false ); aCreator->create(initParamHyp, aHypName, myDlg); onActivateObject( obj ); // Issue 0020170. Restore filters @@ -1116,6 +1125,14 @@ void SMESHGUI_MeshOp::onEditHyp( const int theHypType, const int theIndex ) getInitParamsHypothesis( aHyp->GetName(), aHyp->GetLibName()); aCreator->setInitParamsHypothesis( initParamHyp ); + // Set Geometry + QStringList aList; + myDlg->selectedObject( SMESHGUI_MeshDlg::Geom, aList ); + if (aList.count() > 0) + aCreator->setShapeEntry( aList.first() ); + else + aCreator->setShapeEntry( "" ); + int obj = myDlg->getActiveObject(); removeCustomFilters(); // Issue 0020170 myDlg->setEnabled( false ); diff --git a/src/StdMeshers/StdMeshers_Arithmetic1D.cxx b/src/StdMeshers/StdMeshers_Arithmetic1D.cxx index d2e0b1bf2..a24909a0c 100644 --- a/src/StdMeshers/StdMeshers_Arithmetic1D.cxx +++ b/src/StdMeshers/StdMeshers_Arithmetic1D.cxx @@ -104,9 +104,32 @@ double StdMeshers_Arithmetic1D::GetLength(bool isStartLength) const */ //============================================================================= +void StdMeshers_Arithmetic1D::SetReversedEdges( std::vector& ids ) +{ + if ( ids != _edgeIDs ) { + _edgeIDs = ids; + + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save) { - save << _begLength << " " << _endLength; + int listSize = _edgeIDs.size(); + save << _begLength << " " << _endLength << " " << listSize; + + if ( listSize > 0 ) { + for ( int i = 0; i < listSize; i++) + save << " " << _edgeIDs[i]; + save << " " << _objEntry; + } + return save; } @@ -119,12 +142,25 @@ ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save) istream & StdMeshers_Arithmetic1D::LoadFrom(istream & load) { bool isOK = true; + int intVal; isOK = (load >> _begLength); if (!isOK) load.clear(ios::badbit | load.rdstate()); isOK = (load >> _endLength); + if (!isOK) load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> intVal); + if (isOK && intVal > 0) { + _edgeIDs.reserve( intVal ); + for (int i = 0; i < _edgeIDs.capacity() && isOK; i++) { + isOK = (load >> intVal); + if ( isOK ) _edgeIDs.push_back( intVal ); + } + isOK = (load >> _objEntry); + } + return load; } diff --git a/src/StdMeshers/StdMeshers_Arithmetic1D.hxx b/src/StdMeshers/StdMeshers_Arithmetic1D.hxx index 94952b774..e3f3c37a8 100644 --- a/src/StdMeshers/StdMeshers_Arithmetic1D.hxx +++ b/src/StdMeshers/StdMeshers_Arithmetic1D.hxx @@ -27,11 +27,15 @@ #ifndef _SMESH_ARITHMETIC1D_HXX_ #define _SMESH_ARITHMETIC1D_HXX_ + + #include "SMESH_StdMeshers.hxx" #include "SMESH_Hypothesis.hxx" #include "Utils_SALOME_Exception.hxx" +#include + class STDMESHERS_EXPORT StdMeshers_Arithmetic1D: public SMESH_Hypothesis { @@ -43,6 +47,14 @@ public: double GetLength(bool isStartLength) const; + void SetReversedEdges( std::vector& ids); + + void SetObjectEntry( const char* entry ) { _objEntry = entry; } + + const char* GetObjectEntry() { return _objEntry.c_str(); } + + const std::vector& GetReversedEdges() const { return _edgeIDs; } + virtual std::ostream & SaveTo(std::ostream & save); virtual std::istream & LoadFrom(std::istream & load); friend std::ostream& operator << (std::ostream & save, StdMeshers_Arithmetic1D & hyp); @@ -64,6 +76,8 @@ public: protected: double _begLength, _endLength; + std::vector _edgeIDs; + std::string _objEntry; }; #endif diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx index 0d05c5b1c..e03a921e8 100644 --- a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx @@ -481,6 +481,7 @@ int StdMeshers_NumberOfSegments::ConversionMode() const ostream & StdMeshers_NumberOfSegments::SaveTo(ostream & save) { + int listSize = _edgeIDs.size(); save << _numberOfSegments << " " << (int)_distrType; switch (_distrType) { @@ -503,6 +504,13 @@ ostream & StdMeshers_NumberOfSegments::SaveTo(ostream & save) if (_distrType == DT_TabFunc || _distrType == DT_ExprFunc) save << " " << _convMode; + + if ( _distrType != DT_Regular && listSize > 0 ) { + save << " " << listSize; + for ( int i = 0; i < listSize; i++ ) + save << " " << _edgeIDs[i]; + save << " " << _objEntry; + } return save; } @@ -619,6 +627,18 @@ istream & StdMeshers_NumberOfSegments::LoadFrom(istream & load) load.clear(ios::badbit | load.rdstate()); } + // load reversed edges IDs + int intVal; + isOK = (load >> intVal); + if ( isOK && _distrType != DT_Regular && intVal > 0 ) { + _edgeIDs.reserve( intVal ); + for (int i = 0; i < _edgeIDs.capacity() && isOK; i++) { + isOK = (load >> intVal); + if ( isOK ) _edgeIDs.push_back( intVal ); + } + isOK = (load >> _objEntry); + } + return load; } @@ -695,3 +715,18 @@ bool StdMeshers_NumberOfSegments::SetParametersByDefaults(const TDefaults& dflt return (_numberOfSegments = dflts._nbSegments ); } +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_NumberOfSegments::SetReversedEdges( std::vector& ids ) +{ + if ( ids != _edgeIDs ) { + _edgeIDs = ids; + + NotifySubMeshesHypothesisModification(); + } +} + diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.hxx b/src/StdMeshers/StdMeshers_NumberOfSegments.hxx index 1be5b9176..985d192b2 100644 --- a/src/StdMeshers/StdMeshers_NumberOfSegments.hxx +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.hxx @@ -161,6 +161,13 @@ public: int ConversionMode() const throw (SALOME_Exception); + void SetReversedEdges( std::vector& ids); + + void SetObjectEntry( const char* entry ) { _objEntry = entry; } + + const char* GetObjectEntry() { return _objEntry.c_str(); } + + const std::vector& GetReversedEdges() const { return _edgeIDs; } /*! * \brief Initialize number of segments by the mesh built on the geometry @@ -188,6 +195,8 @@ protected: std::vector _table, _distr; //!< the table for DT_TabFunc, a sequence of pairs of numbers std::string _func; //!< the expression of the function for DT_ExprFunc int _convMode; //!< flag of conversion mode: 0=exponent, 1=cut negative + std::vector _edgeIDs; //!< list of reversed edges ids + std::string _objEntry; //!< Entry of the main object to reverse edges }; #endif diff --git a/src/StdMeshers/StdMeshers_Regular_1D.cxx b/src/StdMeshers/StdMeshers_Regular_1D.cxx index 6edeeb036..3b5abcbee 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.cxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.cxx @@ -180,12 +180,15 @@ bool StdMeshers_Regular_1D::CheckHypothesis { case StdMeshers_NumberOfSegments::DT_Scale: _value[ SCALE_FACTOR_IND ] = hyp->GetScaleFactor(); + _revEdgesIDs = hyp->GetReversedEdges(); break; case StdMeshers_NumberOfSegments::DT_TabFunc: _vvalue[ TAB_FUNC_IND ] = hyp->GetTableFunction(); + _revEdgesIDs = hyp->GetReversedEdges(); break; case StdMeshers_NumberOfSegments::DT_ExprFunc: _svalue[ EXPR_FUNC_IND ] = hyp->GetExpressionFunction(); + _revEdgesIDs = hyp->GetReversedEdges(); break; case StdMeshers_NumberOfSegments::DT_Regular: break; @@ -209,6 +212,9 @@ bool StdMeshers_Regular_1D::CheckHypothesis _value[ END_LENGTH_IND ] = hyp->GetLength( false ); ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 ); _hypType = ARITHMETIC_1D; + + _revEdgesIDs = hyp->GetReversedEdges(); + aStatus = SMESH_Hypothesis::HYP_OK; } @@ -221,6 +227,9 @@ bool StdMeshers_Regular_1D::CheckHypothesis _value[ END_LENGTH_IND ] = hyp->GetLength( false ); ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 ); _hypType = BEG_END_LENGTH; + + _revEdgesIDs = hyp->GetReversedEdges(); + aStatus = SMESH_Hypothesis::HYP_OK; } @@ -821,6 +830,11 @@ bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & theMesh, const TopoDS_Shape & t bool reversed = false; if ( !_mainEdge.IsNull() ) reversed = ( _mainEdge.Orientation() == TopAbs_REVERSED ); + else if ( _revEdgesIDs.size() > 0 ) { + for ( int i = 0; i < _revEdgesIDs.size(); i++) + if ( _revEdgesIDs[i] == shapeID ) + reversed = true; + } BRepAdaptor_Curve C3d( E ); double length = EdgeLength( E ); @@ -948,7 +962,7 @@ bool StdMeshers_Regular_1D::Evaluate(SMESH_Mesh & theMesh, const TopoDS_Edge & EE = TopoDS::Edge(theShape); TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); - int shapeID = meshDS->ShapeToIndex( E ); + // int shapeID = meshDS->ShapeToIndex( E ); double f, l; Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l); diff --git a/src/StdMeshers/StdMeshers_Regular_1D.hxx b/src/StdMeshers/StdMeshers_Regular_1D.hxx index 244ebe6a1..0ee10b45b 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.hxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.hxx @@ -127,6 +127,7 @@ protected: int _ivalue[3]; std::vector _vvalue[1]; std::string _svalue[1]; + std::vector _revEdgesIDs; // a source of propagated hypothesis, is set by CheckHypothesis() // always called before Compute() diff --git a/src/StdMeshers/StdMeshers_StartEndLength.cxx b/src/StdMeshers/StdMeshers_StartEndLength.cxx index d22555ffb..46e9a7cc3 100644 --- a/src/StdMeshers/StdMeshers_StartEndLength.cxx +++ b/src/StdMeshers/StdMeshers_StartEndLength.cxx @@ -105,9 +105,33 @@ double StdMeshers_StartEndLength::GetLength(bool isStartLength) const */ //============================================================================= +void StdMeshers_StartEndLength::SetReversedEdges( std::vector& ids ) +{ + if ( ids != _edgeIDs ) { + _edgeIDs = ids; + + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + ostream & StdMeshers_StartEndLength::SaveTo(ostream & save) { - save << _begLength << " " <<_endLength; + int listSize = _edgeIDs.size(); + save << _begLength << " " << _endLength << " " << listSize; + + if ( listSize > 0 ) { + for ( int i = 0; i < listSize; i++) { + save << " " << _edgeIDs[i]; + } + save << " " << _objEntry; + } + return save; } @@ -120,12 +144,25 @@ ostream & StdMeshers_StartEndLength::SaveTo(ostream & save) istream & StdMeshers_StartEndLength::LoadFrom(istream & load) { bool isOK = true; + int intVal; isOK = (load >> _begLength); if (!isOK) load.clear(ios::badbit | load.rdstate()); isOK = (load >> _endLength); + if (!isOK) load.clear(ios::badbit | load.rdstate()); + + isOK = (load >> intVal); + if (isOK && intVal > 0) { + _edgeIDs.reserve( intVal ); + for (int i = 0; i < _edgeIDs.capacity() && isOK; i++) { + isOK = (load >> intVal); + if ( isOK ) _edgeIDs.push_back( intVal ); + } + isOK = (load >> _objEntry); + } + return load; } diff --git a/src/StdMeshers/StdMeshers_StartEndLength.hxx b/src/StdMeshers/StdMeshers_StartEndLength.hxx index 00f228771..35ae4e0c4 100644 --- a/src/StdMeshers/StdMeshers_StartEndLength.hxx +++ b/src/StdMeshers/StdMeshers_StartEndLength.hxx @@ -31,6 +31,8 @@ #include "SMESH_Hypothesis.hxx" #include "Utils_SALOME_Exception.hxx" +#include + class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis { public: @@ -40,6 +42,14 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis void SetLength(double length, bool isStartLength) throw(SALOME_Exception); double GetLength(bool isStartLength) const; + + void SetReversedEdges( std::vector& ids); + + const std::vector& GetReversedEdges() const { return _edgeIDs; } + + void SetObjectEntry( const char* entry ) { _objEntry = entry; } + + const char* GetObjectEntry() { return _objEntry.c_str(); } virtual std::ostream & SaveTo(std::ostream & save); virtual std::istream & LoadFrom(std::istream & load); @@ -63,6 +73,8 @@ class STDMESHERS_EXPORT StdMeshers_StartEndLength:public SMESH_Hypothesis protected: double _begLength, _endLength; + std::vector _edgeIDs; + std::string _objEntry; }; #endif diff --git a/src/StdMeshersGUI/Makefile.am b/src/StdMeshersGUI/Makefile.am index 38425ec0c..6d1ceae87 100644 --- a/src/StdMeshersGUI/Makefile.am +++ b/src/StdMeshersGUI/Makefile.am @@ -35,7 +35,8 @@ salomeinclude_HEADERS = \ StdMeshersGUI_DistrTable.h \ StdMeshersGUI_NbSegmentsCreator.h \ StdMeshersGUI_ObjectReferenceParamWdg.h \ - StdMeshersGUI_LayerDistributionParamWdg.h + StdMeshersGUI_LayerDistributionParamWdg.h \ + StdMeshersGUI_EdgeDirectionParamWdg.h # Libraries targets lib_LTLIBRARIES = libStdMeshersGUI.la @@ -46,7 +47,8 @@ dist_libStdMeshersGUI_la_SOURCES = \ StdMeshersGUI_DistrTable.cxx \ StdMeshersGUI_NbSegmentsCreator.cxx \ StdMeshersGUI_ObjectReferenceParamWdg.cxx \ - StdMeshersGUI_LayerDistributionParamWdg.cxx + StdMeshersGUI_LayerDistributionParamWdg.cxx \ + StdMeshersGUI_EdgeDirectionParamWdg.cxx MOC_FILES = \ StdMeshersGUI_StdHypothesisCreator_moc.cxx \ @@ -54,7 +56,8 @@ MOC_FILES = \ StdMeshersGUI_DistrTable_moc.cxx \ StdMeshersGUI_NbSegmentsCreator_moc.cxx \ StdMeshersGUI_ObjectReferenceParamWdg_moc.cxx \ - StdMeshersGUI_LayerDistributionParamWdg_moc.cxx + StdMeshersGUI_LayerDistributionParamWdg_moc.cxx \ + StdMeshersGUI_EdgeDirectionParamWdg_moc.cxx nodist_libStdMeshersGUI_la_SOURCES= \ $(MOC_FILES) diff --git a/src/StdMeshersGUI/StdMeshersGUI_EdgeDirectionParamWdg.cxx b/src/StdMeshersGUI/StdMeshersGUI_EdgeDirectionParamWdg.cxx new file mode 100644 index 000000000..01b64b3a4 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_EdgeDirectionParamWdg.cxx @@ -0,0 +1,417 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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. +// +// 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_EdgeDirectionParamWdg.cxx +// Author : Open CASCADE S.A.S. (dmv) +// SMESH includes +// +#include "StdMeshersGUI_EdgeDirectionParamWdg.h" + +// SMESH Includes +#include +#include "SMESHGUI_MeshUtils.h" +#include +#include +#include +#include "SMESHGUI_GroupUtils.h" +#include "SMESH_Gen_i.hxx" +#include "SMESHGUI_GEOMGenUtils.h" + +// SVTK Includes +#include +#include +#include +#include + +// SALOME GUI includes +#include +#include +#include + +// SUIT Includes +#include + +// GEOM Includes +#include + +// Qt includes +#include +#include +#include +#include +#include + +// OCCT includes +#include +#include +#include +#include +#include + +// SALOME KERNEL includes +#include + +#define SPACING 6 +#define MARGIN 0 + +//================================================================================ +/*! + * Constructor + */ +//================================================================================ + +StdMeshersGUI_EdgeDirectionParamWdg +::StdMeshersGUI_EdgeDirectionParamWdg( QWidget * parent ): + QWidget( parent ) +{ + QPixmap image0( SMESH::GetResourceMgr( mySMESHGUI )->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); + + QGridLayout* edgesLayout = new QGridLayout( this ); + edgesLayout->setMargin( MARGIN ); + edgesLayout->setSpacing( SPACING ); + + myListWidget = new QListWidget( this ); + myAddButton = new QPushButton( tr( "SMESH_BUT_ADD" ), this ); + myRemoveButton = new QPushButton( tr( "SMESH_BUT_REMOVE" ), this ); + myListWidget->setSelectionMode( QListWidget::ExtendedSelection ); + + edgesLayout->addWidget(myListWidget, 0, 0, 3, 3); + edgesLayout->addWidget(myAddButton, 0, 4); + edgesLayout->addWidget(myRemoveButton, 1, 4); + + edgesLayout->setRowStretch(2, 5); + edgesLayout->setColumnStretch(2, 5); + + setLayout( edgesLayout ); + setMinimumWidth( 300 ); + + init(); +} + +//================================================================================ +/*! + * Destructor + */ +//================================================================================ + +StdMeshersGUI_EdgeDirectionParamWdg::~StdMeshersGUI_EdgeDirectionParamWdg() +{ + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) { + myPreviewActor->RemoveFromRender( myRenderer ); + aViewWindow->Repaint(); + } + myEntry = ""; + myParamValue = ""; + myMainShape.Nullify(); + + delete myPreviewActor; +} + +//================================================================================ +/*! + * Create a layout, initialize fields + */ +//================================================================================ + +void StdMeshersGUI_EdgeDirectionParamWdg::init() +{ + myParamValue = ""; + myListOfIDs.clear(); + mySelectedIDs.clear(); + + mySMESHGUI = SMESHGUI::GetSMESHGUI(); + mySelectionMgr = SMESH::GetSelectionMgr( mySMESHGUI ); + mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector(); + + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->SetSelectionMode( ActorSelection ); + + connect( myAddButton, SIGNAL(clicked()), SLOT(onAdd())); + connect( myRemoveButton, SIGNAL(clicked()), SLOT(onRemove())); + + connect( mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect( myListWidget, SIGNAL(itemSelectionChanged()), this, SLOT(onListSelectionChanged())); + + updateState(); +} + +//================================================================================ +/*! + * Create a layout, initialize fields + */ +//================================================================================ + +void StdMeshersGUI_EdgeDirectionParamWdg::showPreview( bool visible) +{ + if ( myIsShown != visible ) { + myPreviewActor->SetShown( visible ); + + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) + aViewWindow->Repaint(); + + myIsShown = visible; + } +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void StdMeshersGUI_EdgeDirectionParamWdg::SelectionIntoArgument() +{ + mySelectedIDs.clear(); + + // get selected mesh + SALOME_ListIO aList; + mySelectionMgr->selectedObjects( aList ); + int nbSel = aList.Extent(); + + if (nbSel < 1) + return; + + SALOME_ListIteratorOfListIO anIt (aList); + + for ( ; anIt.More(); anIt.Next()) { // Loop on selected objects + Handle(SALOME_InteractiveObject) IO = anIt.Value(); + + GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( IO->getEntry() ); + if ( !CORBA::is_nil( aGeomObj ) ) { // Selected Object From Study + GEOM::GEOM_Object_ptr aGeomFatherObj = aGeomObj->GetMainShape(); + QString aFatherEntry = ""; + QString aMainFatherEntry = ""; + TopoDS_Shape shape; + if ( !CORBA::is_nil( aGeomFatherObj ) ) { + // Get Main Shape + GEOM::GEOM_Object_var aGeomMain = GetGeomObjectByEntry( myEntry ); + if ( !CORBA::is_nil( aGeomMain ) || aGeomMain->GetType() == 37 ) { // Main Shape is a Group + GEOM::GEOM_Object_ptr aMainFatherObj = aGeomMain->GetMainShape(); + if ( !CORBA::is_nil( aMainFatherObj ) ) + aMainFatherEntry = aMainFatherObj->GetStudyEntry(); + } + aFatherEntry = aGeomFatherObj->GetStudyEntry(); + } + + if ( aFatherEntry != "" && ( aFatherEntry == myEntry || aFatherEntry == aMainFatherEntry ) ) { + if ( aGeomObj->GetType() == 37 /*GEOM_GROUP*/ ) { // Selected Group that belongs the main object + GEOMBase::GetShape(aGeomObj, shape); + if ( !shape.IsNull() ) { + TopExp_Explorer exp( shape, TopAbs_EDGE ); + for ( ; exp.More(); exp.Next() ) { + int index = myPreviewActor->GetIndexByShape( exp.Current() ); + if ( index ) { + mySelectedIDs.append( index ); + myPreviewActor->HighlightID( index ); + } + } + } + } else if ( aGeomObj->GetType() == 28 /*GEOM_SUBSHAPE*/ ) { + GEOMBase::GetShape(aGeomObj, shape); + if ( !shape.IsNull() && shape.ShapeType() == TopAbs_EDGE ) { + int index = myPreviewActor->GetIndexByShape( shape ); + if ( index ) { + mySelectedIDs.append( index ); + myPreviewActor->HighlightID( index ); + } + } + } + } + } else { // Selected Actor from Actor Collection + QString anEntry = IO->getEntry(); + QString str = "_"; + int index = anEntry.lastIndexOf( str ); + anEntry.remove(0, index+1); + int ind = anEntry.toInt(); + if ( ind ) + mySelectedIDs.append( ind ); + } + } +} + +//================================================================================= +// function : onAdd() +// purpose : Called when Add Button Clicked +//================================================================================= +void StdMeshersGUI_EdgeDirectionParamWdg::onAdd() +{ + if ( mySelectedIDs.size() < 1 ) + return; + + myListWidget->blockSignals( true ); + for (int i = 0; i < mySelectedIDs.size(); i++) { + if ( myListOfIDs.indexOf( mySelectedIDs.at(i) ) == -1 ) { + QString anID = QString(" %1").arg( mySelectedIDs.at(i) ); + + QListWidgetItem* anItem = new QListWidgetItem( anID, myListWidget ); + anItem->setSelected(true); + + myListOfIDs.append( mySelectedIDs.at(i) ); + } + } + onListSelectionChanged(); + + myListWidget->blockSignals( false ); +} + +//================================================================================= +// function : onRemove() +// purpose : Called when Remove Button Clicked +//================================================================================= +void StdMeshersGUI_EdgeDirectionParamWdg::onRemove() +{ + if ( myListWidget->count() < 1 ) + return; + + myListWidget->blockSignals( true ); + QList selItems = myListWidget->selectedItems(); + QListWidgetItem* item; + foreach(item, selItems) { + QString idStr = item->text(); + int id = idStr.toInt(); + + int index = myListOfIDs.indexOf( id ); + myListOfIDs.removeAt( index ); + delete item; + } + + onListSelectionChanged(); + myListWidget->blockSignals( false ); +} + +//================================================================================= +// function : onListSelectionChanged() +// purpose : Called when selection in element list is changed +//================================================================================= +void StdMeshersGUI_EdgeDirectionParamWdg::onListSelectionChanged() +{ + mySelectionMgr->clearSelected(); + TColStd_MapOfInteger aIndexes; + QList selItems = myListWidget->selectedItems(); + QListWidgetItem* anItem; + foreach(anItem, selItems) + myPreviewActor->HighlightID( anItem->text().toInt() ); +} + +//================================================================================= +// function : setGeomShape +// purpose : Called to set geometry +//================================================================================ +void StdMeshersGUI_EdgeDirectionParamWdg::SetMainShapeEntry( const QString& theEntry ) +{ + if ( theEntry != "") { + myParamValue = theEntry; + myEntry = theEntry; + myMainShape = GetTopoDSByEntry( theEntry ); + updateState(); + } +} + +//================================================================================= +// function : updateState +// purpose : update Widget state +//================================================================================= +void StdMeshersGUI_EdgeDirectionParamWdg::updateState() +{ + bool state = false; + if ( !myMainShape.IsNull() ) + state = true; + + myListWidget->setEnabled( state ); + myAddButton->setEnabled( state ); + myRemoveButton->setEnabled( state ); + + if (state = true) { + myPreviewActor = new SMESH_PreviewActorsCollection(); + myPreviewActor->SetSelector( mySelector ); + myPreviewActor->Init( myMainShape, TopAbs_EDGE, myEntry ); + myPreviewActor->SetShown( false ); + myIsShown = false; + if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI )) { + myRenderer = aViewWindow->getRenderer(); + myPreviewActor->AddToRender( myRenderer ); + aViewWindow->Repaint(); + } + } +} + +//================================================================================= +// function : GetGeomObjectByEntry +// purpose : Called to get GeomObject +//================================================================================= +GEOM::GEOM_Object_var StdMeshersGUI_EdgeDirectionParamWdg::GetGeomObjectByEntry( const QString& theEntry ) +{ + GEOM::GEOM_Object_var aGeomObj; + SALOMEDS::Study_var aStudy = SMESHGUI::GetSMESHGen()->GetCurrentStudy(); + if (aStudy != 0) { + SALOMEDS::SObject_var aSObj = aStudy->FindObjectID( theEntry.toLatin1().data() ); + SALOMEDS::GenericAttribute_var anAttr; + + if (!aSObj->_is_nil() && aSObj->FindAttribute(anAttr, "AttributeIOR")) { + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var aVal = anIOR->Value(); + CORBA::Object_var obj = aStudy->ConvertIORToObject(aVal); + aGeomObj = GEOM::GEOM_Object::_narrow(obj); + } + } + return aGeomObj; +} + +//================================================================================= +// function : setObjectByEntry +// purpose : Called to get GeomObject +//================================================================================= +TopoDS_Shape StdMeshersGUI_EdgeDirectionParamWdg::GetTopoDSByEntry( const QString& theEntry ) +{ + TopoDS_Shape shape; + GEOM::GEOM_Object_var aGeomObj = GetGeomObjectByEntry( theEntry ); + GEOMBase::GetShape(aGeomObj, shape); + return shape; +} + +//================================================================================= +// function : GetListOfIds +// purpose : Called to get the list of Edges IDs +//================================================================================= +SMESH::long_array_var StdMeshersGUI_EdgeDirectionParamWdg::GetListOfIDs() +{ + SMESH::long_array_var anArray = new SMESH::long_array; + int size = myListOfIDs.size(); + anArray->length( size ); + if ( size ) { + for (int i = 0; i < size; i++) { + anArray[i] = myListOfIDs.at(i); + } + } + return anArray; +} + +//================================================================================= +// function : SetListOfIds +// purpose : Called to set the list of Edges IDs +//================================================================================= +void StdMeshersGUI_EdgeDirectionParamWdg::SetListOfIDs( SMESH::long_array_var theIds) +{ + mySelectedIDs.clear(); + myListOfIDs.clear(); + int size = theIds->length(); + for ( int i = 0; i < size; i++ ) + mySelectedIDs.append( theIds[ i ] ); + onAdd(); +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_EdgeDirectionParamWdg.h b/src/StdMeshersGUI/StdMeshersGUI_EdgeDirectionParamWdg.h new file mode 100644 index 000000000..e05df9881 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_EdgeDirectionParamWdg.h @@ -0,0 +1,107 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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. +// +// 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_EdgeDirectionParamWdg.h +// Author : Open CASCADE S.A.S. (dmv) +// +#ifndef STDMESHERSGUI_EDGEDIRECTIONPARAMWGD_H +#define STDMESHERSGUI_EDGEDIRECTIONPARAMWGD_H + +// SMESH includes +#include +#include "SMESH_StdMeshersGUI.hxx" +#include "SMESH_SMESHGUI.hxx" + +// Qt includes +#include +#include +#include + +#include + +class SMESHGUI; +class LightApp_SelectionMgr; +class SVTK_Selector; +class QPushButton; +class QLineEdit; +class QCheckBox; +class QListWidget; +class SMESH_Actor; +class SMESH_PreviewActorsCollection; +class vtkRenderer; + +class STDMESHERSGUI_EXPORT StdMeshersGUI_EdgeDirectionParamWdg : public QWidget +{ + Q_OBJECT + +public: + StdMeshersGUI_EdgeDirectionParamWdg( QWidget* parent = 0 ); + ~StdMeshersGUI_EdgeDirectionParamWdg(); + + SMESH::long_array_var GetListOfIDs(); + void SetListOfIDs( SMESH::long_array_var ); + + void SetMainShapeEntry( const QString& theEntry ); + const char* GetMainShapeEntry() { return myEntry.toLatin1().data();} + + TopoDS_Shape GetMainShape() { return myMainShape; } + + static GEOM::GEOM_Object_var GetGeomObjectByEntry( const QString& ); + static TopoDS_Shape GetTopoDSByEntry( const QString& ); + + QString GetValue() const { return myParamValue; } + + void showPreview ( bool ); + +private: + void updateState(); + +private slots: + void onAdd(); + void onRemove(); + void SelectionIntoArgument(); + void onListSelectionChanged(); + +private: + void init(); + +private: + SMESHGUI* mySMESHGUI; + LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */ + SVTK_Selector* mySelector; + SMESH::SMESH_Mesh_var myMesh; + TopoDS_Shape myMainShape; + QString myEntry; + vtkRenderer* myRenderer; + + QListWidget* myListWidget; + QPushButton* myAddButton; + QPushButton* myRemoveButton; + QList mySelectedIDs; + QList myListOfIDs; + + QString myParamValue; + bool myIsShown; + + SMESH_PreviewActorsCollection* myPreviewActor; +}; + +#endif // STDMESHERSGUI_EDGEDIRECTIONPARAMWGD_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx index 9e8e0bda8..d89746054 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx @@ -26,6 +26,7 @@ #include "StdMeshersGUI_NbSegmentsCreator.h" #include "StdMeshersGUI_DistrTable.h" #include "StdMeshersGUI_DistrPreview.h" +#include "StdMeshersGUI_EdgeDirectionParamWdg.h" #include #include @@ -99,7 +100,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() QVBoxLayout* lay = new QVBoxLayout( fr ); lay->setMargin( 0 ); - lay->setSpacing( 0 ); + lay->setSpacing( SPACING ); QGroupBox* GroupC1 = new QGroupBox( tr( "SMESH_ARGUMENTS" ), fr ); lay->addWidget( GroupC1 ); @@ -195,11 +196,25 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() myPreviewRow = row; row++; + // 8) reverce edge parameters + myReversedEdgesBox = new QGroupBox(tr( "SMESH_REVERCE_EDGES" ), fr); + QHBoxLayout* edgeLay = new QHBoxLayout( myReversedEdgesBox ); + + myDirectionWidget = new StdMeshersGUI_EdgeDirectionParamWdg(); + QString anEntry = getShapeEntry(); + if ( anEntry == "" ) + anEntry = h->GetObjectEntry(); + myDirectionWidget->SetMainShapeEntry( anEntry ); + myDirectionWidget->SetListOfIDs( h->GetReversedEdges() ); + edgeLay->addWidget( myDirectionWidget ); + + lay->addWidget( myReversedEdgesBox ); + connect( myNbSeg, SIGNAL( valueChanged( const QString& ) ), this, SLOT( onValueChanged() ) ); connect( myDistr, SIGNAL( activated( int ) ), this, SLOT( onValueChanged() ) ); connect( myTable, SIGNAL( valueChanged( int, int ) ), this, SLOT( onValueChanged() ) ); connect( myExpr, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) ); - connect( myConv, SIGNAL( cuttonClicked( int ) ), this, SLOT( onValueChanged() ) ); + connect( myConv, SIGNAL( buttonClicked( int ) ), this, SLOT( onValueChanged() ) ); return fr; } @@ -348,6 +363,11 @@ bool StdMeshersGUI_NbSegmentsCreator::storeParamsToHypo( const NbSegmentsHypothe if( distr==2 || distr==3 ) h->SetConversionMode( h_data.myConv ); + if( distr==1 || distr==2 || distr==3 ) { + h->SetReversedEdges( myDirectionWidget->GetListOfIDs() ); + h->SetObjectEntry( myDirectionWidget->GetMainShapeEntry() ); + } + if( distr==2 ) h->SetTableFunction( h_data.myTable ); @@ -400,6 +420,8 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged() myScale->setShown( distr==1 ); myLScale->setShown( distr==1 ); + myReversedEdgesBox->setShown( !distr==0 ); + myDirectionWidget->showPreview( !distr==0 ); bool isFunc = distr==2 || distr==3; myPreview->setShown( isFunc ); @@ -434,8 +456,11 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged() if ( (QtxComboBox*)sender() == myDistr && dlg() ) { QApplication::instance()->processEvents(); + myGroupLayout->invalidate(); + dlg()->layout()->invalidate(); dlg()->updateGeometry(); - dlg()->setMinimumSize( dlg()->minimumSizeHint().width(), dlg()->minimumSizeHint().height() ); + dlg()->setMinimumSize( dlg()->minimumSizeHint() ); dlg()->resize( dlg()->minimumSize() ); + QApplication::instance()->processEvents(); } } diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h index ba7c7bff8..188674497 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h @@ -44,6 +44,7 @@ class QButtonGroup; class QGroupBox; class QGridLayout; class QRadioButton; +class StdMeshersGUI_EdgeDirectionParamWdg; typedef struct { @@ -91,6 +92,9 @@ private: QGridLayout* myGroupLayout; int myTableRow, myPreviewRow; QRadioButton* myCutNeg; + QGroupBox* myReversedEdgesBox; + + StdMeshersGUI_EdgeDirectionParamWdg* myDirectionWidget; }; #endif // STDMESHERSGUI_NBSEGMENTSCREATOR_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index cdcdcc8f1..df4370d6d 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -33,6 +33,7 @@ #include #include "StdMeshersGUI_ObjectReferenceParamWdg.h" #include "StdMeshersGUI_LayerDistributionParamWdg.h" +#include "StdMeshersGUI_EdgeDirectionParamWdg.h" #include // SALOME GUI includes @@ -444,10 +445,18 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_Arithmetic1D_var h = StdMeshers::StdMeshers_Arithmetic1D::_narrow( hypothesis() ); + StdMeshersGUI_EdgeDirectionParamWdg* w = + widget< StdMeshersGUI_EdgeDirectionParamWdg >( 2 ); + h->SetLength( params[0].myValue.toDouble(), true ); h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); h->SetLength( params[1].myValue.toDouble(), false ); h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); + if (w) { + h->SetReversedEdges( w->GetListOfIDs() ); + const char * entry = w->GetMainShapeEntry(); + h->SetObjectEntry( entry ); + } } else if( hypType()=="MaxElementArea" ) { @@ -469,10 +478,17 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const StdMeshers::StdMeshers_StartEndLength_var h = StdMeshers::StdMeshers_StartEndLength::_narrow( hypothesis() ); + StdMeshersGUI_EdgeDirectionParamWdg* w = + widget< StdMeshersGUI_EdgeDirectionParamWdg >( 2 ); + h->SetLength( params[0].myValue.toDouble(), true ); h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); h->SetLength( params[1].myValue.toDouble(), false ); h->SetParameters(SMESHGUI::JoinObjectParameters(aVariablesList)); + if (w) { + h->SetReversedEdges( w->GetListOfIDs() ); + h->SetObjectEntry( w->GetMainShapeEntry() ); + } } else if( hypType()=="Deflection1D" ) { @@ -650,10 +666,26 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const item.myValue = h->GetLength( true ); p.append( item ); + customWidgets()->append (0); + item.myName = tr( "SMESH_END_LENGTH_PARAM" ); if(!initVariableName(aParameters,item,1)) item.myValue = h->GetLength( false ); p.append( item ); + + customWidgets()->append (0); + + item.myName = tr( "SMESH_REVERCE_EDGES" ); + p.append( item ); + + StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget = new StdMeshersGUI_EdgeDirectionParamWdg(); + QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); + if ( anEntry == "" ) + anEntry = h->GetObjectEntry(); + aDirectionWidget->SetMainShapeEntry( anEntry ); + aDirectionWidget->SetListOfIDs( h->GetReversedEdges() ); + aDirectionWidget->showPreview( true ); + customWidgets()->append ( aDirectionWidget ); } else if( hypType()=="MaxElementArea" ) { @@ -686,12 +718,26 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const if(!initVariableName(aParameters,item,0)) item.myValue = h->GetLength( true ); p.append( item ); + customWidgets()->append(0); item.myName = tr( "SMESH_END_LENGTH_PARAM" ); if(!initVariableName(aParameters,item,1)) item.myValue = h->GetLength( false ); p.append( item ); - + customWidgets()->append(0); + + item.myName = tr( "SMESH_REVERCE_EDGES" ); + p.append( item ); + + StdMeshersGUI_EdgeDirectionParamWdg* aDirectionWidget = new StdMeshersGUI_EdgeDirectionParamWdg(); + QString anEntry = SMESHGUI_GenericHypothesisCreator::getShapeEntry(); + if ( anEntry == "" ) + anEntry = h->GetObjectEntry(); + aDirectionWidget->SetMainShapeEntry( anEntry ); + aDirectionWidget->SetListOfIDs( h->GetReversedEdges() ); + aDirectionWidget->SetMainShapeEntry( h->GetObjectEntry() ); + aDirectionWidget->showPreview( true ); + customWidgets()->append ( aDirectionWidget ); } else if( hypType()=="Deflection1D" ) { @@ -1000,6 +1046,13 @@ bool StdMeshersGUI_StdHypothesisCreator::getParamFromCustomWidget( StdParam & pa param.myValue = w->GetValue(); return true; } + if ( widget->inherits( "StdMeshersGUI_EdgeDirectionParamWdg" )) + { + const StdMeshersGUI_EdgeDirectionParamWdg * w = + static_cast( widget ); + param.myValue = w->GetValue(); + return true; + } return false; } diff --git a/src/StdMeshersGUI/StdMeshers_msg_en.ts b/src/StdMeshersGUI/StdMeshers_msg_en.ts index f11a5d675..30651e813 100644 --- a/src/StdMeshersGUI/StdMeshers_msg_en.ts +++ b/src/StdMeshersGUI/StdMeshers_msg_en.ts @@ -245,6 +245,10 @@ SMESH_REMOVE_ROW Remove row + + SMESH_REVERCE_EDGES + Reverce Edges + SMESH_SEGMENT_LENGTH_AROUND_VERTEX_HYPOTHESIS Segment Length Around Vertex diff --git a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx index 20a0b2909..3bf9e825b 100644 --- a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx +++ b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx @@ -107,11 +107,109 @@ void StdMeshers_Arithmetic1D_i::SetLength(CORBA::Double theLength, CORBA::Double StdMeshers_Arithmetic1D_i::GetLength( CORBA::Boolean theIsStart) { - MESSAGE( "StdMeshers_StartEndLength_i::GetLength" ); + MESSAGE( "StdMeshers_Arithmetic1D_i::GetLength" ); ASSERT( myBaseImpl ); return this->GetImpl()->GetLength( theIsStart ); } +//============================================================================= +/*! + * StdMeshers_Arithmetic1D_i::SetReversedEdges + * + * Set edges to reverse + */ +//============================================================================= + +void StdMeshers_Arithmetic1D_i::SetReversedEdges( const SMESH::long_array& theIds ) +{ + MESSAGE( "StdMeshers_Arithmetic1D_i::SetReversedEdges" ); + ASSERT( myBaseImpl ); + try { + std::vector ids( theIds.length() ); + CORBA::Long iEnd = theIds.length(); + for ( CORBA::Long i = 0; i < iEnd; i++ ) + ids[ i ] = theIds[ i ]; + + this->GetImpl()->SetReversedEdges( ids ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + + // Update Python script + /* SMESH::TPythonDump() << _this() << ".SetEdgesToReverse( " + << theList << " )";*/ +} + +//============================================================================= +/*! + * StdMeshers_Arithmetic1D_i::SetObjectEntry + * + * Set the Entry for the Main Object + */ +//============================================================================= + +void StdMeshers_Arithmetic1D_i::SetObjectEntry( const char* entry ) +{ + MESSAGE( "StdMeshers_Arithmetic1D_i::SetObjectEntry" ); + ASSERT( myBaseImpl ); + + try { + this->GetImpl()->SetObjectEntry( entry ); + // Update Python script + // SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry << "' )"; + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_Arithmetic1D_i::GetObjectEntry + * + * Set the Entry for the Main Object + */ +//============================================================================= + +char* StdMeshers_Arithmetic1D_i::GetObjectEntry() +{ + MESSAGE( "StdMeshers_Arithmetic1D_i::SetObjectEntry" ); + ASSERT( myBaseImpl ); + const char* entry; + try { + entry = this->GetImpl()->GetObjectEntry(); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + return CORBA::string_dup( entry ); +} + +//============================================================================= +/*! + * StdMeshers_Arithmetic1D_i::GetReversedEdges + * + * Get reversed edges + */ +//============================================================================= + +SMESH::long_array* StdMeshers_Arithmetic1D_i::GetReversedEdges() +{ + MESSAGE( "StdMeshers_StartEndLength_i::GetReversedEdges" ); + ASSERT( myBaseImpl ); + SMESH::long_array_var anArray = new SMESH::long_array; + std::vector ids = this->GetImpl()->GetReversedEdges(); + anArray->length( ids.size() ); + for ( CORBA::Long i = 0; i < ids.size(); i++) + anArray [ i ] = ids [ i ]; + + return anArray._retn(); +} + //============================================================================= /*! * StdMeshers_Arithmetic1D_i::GetImpl diff --git a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx index 3d8ec8642..7abea29e1 100644 --- a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx +++ b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx @@ -54,9 +54,22 @@ public: // Set length void SetLength( CORBA::Double theLength, CORBA::Boolean theIsStart ) throw ( SALOME::SALOME_Exception ); + // Get length CORBA::Double GetLength(CORBA::Boolean theIsStart); + //Set Reversed Edges + void SetReversedEdges( const SMESH::long_array& theIDs); + + //Get Reversed Edges + SMESH::long_array* GetReversedEdges(); + + //Set the Entry of the Object + void SetObjectEntry( const char* theEntry); + + //Get Object Entry + char* GetObjectEntry(); + // Get implementation ::StdMeshers_Arithmetic1D* GetImpl(); diff --git a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx index 7b2d215a5..8efa554d3 100644 --- a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx +++ b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx @@ -162,6 +162,105 @@ CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments() return this->GetImpl()->GetNumberOfSegments(); } +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::SetReversedEdges + * + * Set edges to reverse + */ +//============================================================================= + +void StdMeshers_NumberOfSegments_i::SetReversedEdges( const SMESH::long_array& theIds ) +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::SetReversedEdges" ); + ASSERT( myBaseImpl ); + try { + std::vector ids( theIds.length() ); + CORBA::Long iEnd = theIds.length(); + for ( CORBA::Long i = 0; i < iEnd; i++ ) + ids[ i ] = theIds[ i ]; + + this->GetImpl()->SetReversedEdges( ids ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + + // Update Python script + /* SMESH::TPythonDump() << _this() << ".SetEdgesToReverse( " + << theList << " )";*/ +} + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::SetObjectEntry + * + * Set the Entry for the Main Object + */ +//============================================================================= + +void StdMeshers_NumberOfSegments_i::SetObjectEntry( const char* entry ) +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::SetObjectEntry" ); + ASSERT( myBaseImpl ); + + try { + this->GetImpl()->SetObjectEntry( entry ); + // Update Python script + // SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry << "' )"; + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::GetObjectEntry + * + * Set the Entry for the Main Object + */ +//============================================================================= + +char* StdMeshers_NumberOfSegments_i::GetObjectEntry() +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::SetObjectEntry" ); + ASSERT( myBaseImpl ); + + const char* entry; + try { + entry = this->GetImpl()->GetObjectEntry(); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + return CORBA::string_dup( entry ); +} + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::GetReversedEdges + * + * Get reversed edges + */ +//============================================================================= + +SMESH::long_array* StdMeshers_NumberOfSegments_i::GetReversedEdges() +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::GetReversedEdges" ); + ASSERT( myBaseImpl ); + SMESH::long_array_var anArray = new SMESH::long_array; + std::vector ids = this->GetImpl()->GetReversedEdges(); + anArray->length( ids.size() ); + for ( CORBA::Long i = 0; i < ids.size(); i++) + anArray [ i ] = ids [ i ]; + + return anArray._retn(); +} + //============================================================================= /*! */ diff --git a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx index 208a59b0b..30b9d08b7 100644 --- a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx +++ b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx @@ -104,6 +104,18 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + //Set Reversed Edges + void SetReversedEdges( const SMESH::long_array& theIDs); + + //Get Reversed Edges + SMESH::long_array* GetReversedEdges(); + + //Set Object Entry + void SetObjectEntry( const char* entry); + + //Get Object Entry + char* GetObjectEntry(); }; #endif diff --git a/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx b/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx index 1154b63f2..c9a75a3d5 100644 --- a/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx +++ b/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx @@ -113,6 +113,103 @@ CORBA::Double StdMeshers_StartEndLength_i::GetLength( CORBA::Boolean theIsStart) return this->GetImpl()->GetLength( theIsStart ); } +//============================================================================= +/*! + * StdMeshers_StartEndLength_i::SetReversedEdges + * + * Set edges to reverse + */ +//============================================================================= + +void StdMeshers_StartEndLength_i::SetReversedEdges( const SMESH::long_array& theIds ) +{ + MESSAGE( "StdMeshers_StartEndLength_i::SetReversedEdges" ); + ASSERT( myBaseImpl ); + try { + std::vector ids( theIds.length() ); + CORBA::Long iEnd = theIds.length(); + for ( CORBA::Long i = 0; i < iEnd; i++ ) + ids[ i ] = theIds[ i ]; + + this->GetImpl()->SetReversedEdges( ids ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + + // Update Python script + /* SMESH::TPythonDump() << _this() << ".SetEdgesToReverse( " + << theList << " )";*/ +} + +//============================================================================= +/*! + * StdMeshers_StartEndLength_i::SetObjectEntry + * + * Set the Entry for the Main Object + */ +//============================================================================= + +void StdMeshers_StartEndLength_i::SetObjectEntry( const char* entry ) +{ + MESSAGE( "StdMeshers_StartEndLength_i::SetObjectEntry" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetObjectEntry( entry ); + // Update Python script + // SMESH::TPythonDump() << _this() << ".SetObjectEntry( '" << entry << "' )"; + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_StartEndLength_i::GetObjectEntry + * + * Set the Entry for the Main Object + */ +//============================================================================= + +char* StdMeshers_StartEndLength_i::GetObjectEntry() +{ + MESSAGE( "StdMeshers_StartEndLength_i::SetObjectEntry" ); + ASSERT( myBaseImpl ); + const char* entry; + try { + entry = this->GetImpl()->GetObjectEntry(); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } + return CORBA::string_dup( entry ); +} + +//============================================================================= +/*! + * StdMeshers_StartEndLength_i::GetReversedEdges + * + * Get reversed edges + */ +//============================================================================= + +SMESH::long_array* StdMeshers_StartEndLength_i::GetReversedEdges() +{ + MESSAGE( "StdMeshers_StartEndLength_i::GetReversedEdges" ); + ASSERT( myBaseImpl ); + SMESH::long_array_var anArray = new SMESH::long_array; + std::vector ids = this->GetImpl()->GetReversedEdges(); + anArray->length( ids.size() ); + for ( CORBA::Long i = 0; i < ids.size(); i++) + anArray [ i ] = ids [ i ]; + + return anArray._retn(); +} + //============================================================================= /*! * StdMeshers_StartEndLength_i::GetImpl diff --git a/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx b/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx index d7a4c4bcd..3ce0e9db3 100644 --- a/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx +++ b/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx @@ -65,6 +65,18 @@ public: // Verify whether hypothesis supports given entity type CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + //Set Reversed Edges + void SetReversedEdges( const SMESH::long_array& theIDs); + + //Get Reversed Edges + SMESH::long_array* GetReversedEdges(); + + //Set Object Entry + void SetObjectEntry( const char* entry); + + //Get Object Entry + char* GetObjectEntry(); }; #endif