Enable setting of Numeric Functors as criteria in Split Quadrangles and Union Triangles functionalities in GUI

This commit is contained in:
jfa 2005-08-11 08:06:39 +00:00
parent aa376b221a
commit c9c6669fab
10 changed files with 876 additions and 578 deletions

View File

@ -162,12 +162,11 @@ module SMESH
interface SMESH_MeshEditor; interface SMESH_MeshEditor;
interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource
{ {
/*! ///*!
* Associate a Shape to a Mesh created with NewEmpty // * Associate a Shape to a Mesh created with NewEmpty
*/ // */
//boolean SetMesh(in GEOM::GEOM_Object anObject)
// boolean SetMesh(in GEOM::GEOM_Object anObject) // raises (SALOME::SALOME_Exception);
// raises (SALOME::SALOME_Exception);
/*! /*!
* Get the subMesh object associated to a subShape. The subMesh object * Get the subMesh object associated to a subShape. The subMesh object
@ -178,11 +177,11 @@ module SMESH
SMESH_subMesh GetSubMesh(in GEOM::GEOM_Object aSubObject, in string name) SMESH_subMesh GetSubMesh(in GEOM::GEOM_Object aSubObject, in string name)
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! ///*!
* Create a subMesh without reference to a subShape // * Create a subMesh without reference to a subShape
*/ // */
// SMESH_subMesh NewEmpty() //SMESH_subMesh NewEmpty()
// raises (SALOME::SALOME_Exception); // raises (SALOME::SALOME_Exception);
/*! /*!
* Get geom shape to mesh. A result may be nil * Get geom shape to mesh. A result may be nil
@ -217,11 +216,11 @@ module SMESH
void RemoveGroup(in SMESH_GroupBase aGroup) void RemoveGroup(in SMESH_GroupBase aGroup)
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! /*!
* Remove group with its contents * Remove group with its contents
*/ */
void RemoveGroupWithContents( in SMESH_GroupBase aGroup ) void RemoveGroupWithContents( in SMESH_GroupBase aGroup )
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! /*!
* Union of two groups * Union of two groups
@ -231,7 +230,7 @@ module SMESH
SMESH_Group UnionGroups (in SMESH_GroupBase aGroup1, SMESH_Group UnionGroups (in SMESH_GroupBase aGroup1,
in SMESH_GroupBase aGroup2, in SMESH_GroupBase aGroup2,
in string name ) in string name )
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! /*!
* Intersection of two groups * Intersection of two groups
@ -241,17 +240,17 @@ module SMESH
SMESH_Group IntersectGroups (in SMESH_GroupBase aGroup1, SMESH_Group IntersectGroups (in SMESH_GroupBase aGroup1,
in SMESH_GroupBase aGroup2, in SMESH_GroupBase aGroup2,
in string name ) in string name )
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! /*!
* Cut of two groups * Cut of two groups
* New group is created. All mesh elements that are present in * New group is created. All mesh elements that are present in
* main group but do not present in tool group are added to the new one * main group but do not present in tool group are added to the new one
*/ */
SMESH_Group CutGroups (in SMESH_GroupBase aMainGroup, SMESH_Group CutGroups (in SMESH_GroupBase aMainGroup,
in SMESH_GroupBase aToolGroup, in SMESH_GroupBase aToolGroup,
in string name ) in string name )
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! /*!
* Add hypothesis to the mesh, under a particular subShape * Add hypothesis to the mesh, under a particular subShape
@ -276,7 +275,6 @@ module SMESH
// boolean AddHypothesis(in SMESH_subMesh aSubMesh, in SMESH_Hypothesis anHyp) // boolean AddHypothesis(in SMESH_subMesh aSubMesh, in SMESH_Hypothesis anHyp)
// raises (SALOME::SALOME_Exception); // raises (SALOME::SALOME_Exception);
/*! /*!
* Remove an hypothesis previouly added with AddHypothesis. * Remove an hypothesis previouly added with AddHypothesis.
*/ */
@ -323,8 +321,11 @@ module SMESH
*/ */
long GetStudyId(); long GetStudyId();
/*!
* Obtain instance of SMESH_MeshEditor
*/
SMESH_MeshEditor GetMeshEditor() SMESH_MeshEditor GetMeshEditor()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! /*!
* Export Mesh to different MED Formats * Export Mesh to different MED Formats
@ -336,6 +337,7 @@ module SMESH
*/ */
void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion ) void ExportToMED( in string file, in boolean auto_groups, in MED_VERSION theVersion )
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*! /*!
* Export Mesh to MED_V2_1 MED format * Export Mesh to MED_V2_1 MED format
* Works, just the same as ExportToMED, with MED_VERSION parameter equal to MED_V2_1. * Works, just the same as ExportToMED, with MED_VERSION parameter equal to MED_V2_1.
@ -360,6 +362,9 @@ module SMESH
SALOME_MED::MESH GetMEDMesh() SALOME_MED::MESH GetMEDMesh()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*!
* Get informations about mesh contents
*/
long NbNodes() long NbNodes()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
@ -411,6 +416,9 @@ module SMESH
long_array GetNodesId() long_array GetNodesId()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*!
* Get mesh description
*/
string Dump(); string Dump();
}; };
@ -474,9 +482,8 @@ module SMESH
* This interface makes modifications on the Mesh - removing elements and nodes etc. * This interface makes modifications on the Mesh - removing elements and nodes etc.
*/ */
interface NumericalFunctor; interface NumericalFunctor;
interface SMESH_MeshEditor { interface SMESH_MeshEditor
{
boolean RemoveElements(in long_array IDsOfElements); boolean RemoveElements(in long_array IDsOfElements);
boolean RemoveNodes(in long_array IDsOfNodes); boolean RemoveNodes(in long_array IDsOfNodes);
@ -489,8 +496,6 @@ module SMESH
boolean AddVolume(in long_array IDsOfNodes); boolean AddVolume(in long_array IDsOfNodes);
//boolean AddPolygonalFace (in long_array IdsOfNodes);
/*! /*!
* Create volume of many faces, giving nodes for each face. * Create volume of many faces, giving nodes for each face.
* \param IdsOfNodes List of node IDs for volume creation face by face. * \param IdsOfNodes List of node IDs for volume creation face by face.
@ -516,24 +521,72 @@ module SMESH
boolean Reorient(in long_array IDsOfElements); boolean Reorient(in long_array IDsOfElements);
boolean ReorientObject(in SMESH_IDSource theObject); boolean ReorientObject(in SMESH_IDSource theObject);
boolean TriToQuad(in long_array IDsOfElements, /*!
in NumericalFunctor Criterion, * \brief Fuse neighbour triangles into quadrangles.
in double MaxAngle); * \param theElems The triangles to be fused.
* \param theCriterion Is used to choose a neighbour to fuse with.
* \param theMaxAngle Is a max angle between element normals at which fusion
* is still performed; theMaxAngle is mesured in radians.
* \return TRUE in case of success, FALSE otherwise.
*/
boolean TriToQuad (in long_array IDsOfElements,
in NumericalFunctor Criterion,
in double MaxAngle);
boolean TriToQuadObject(in SMESH_IDSource theObject, /*!
in NumericalFunctor Criterion, * \brief Fuse neighbour triangles into quadrangles.
in double MaxAngle); *
* Behaves like the above method, taking list of elements from \a theObject
*/
boolean TriToQuadObject (in SMESH_IDSource theObject,
in NumericalFunctor Criterion,
in double MaxAngle);
boolean QuadToTri(in long_array IDsOfElements, /*!
in NumericalFunctor Criterion); * \brief Split quadrangles into triangles.
* \param theElems The faces to be splitted.
* \param theCriterion Is used to choose a diagonal for splitting.
* \return TRUE in case of success, FALSE otherwise.
*/
boolean QuadToTri (in long_array IDsOfElements,
in NumericalFunctor Criterion);
boolean SplitQuad(in long_array IDsOfElements, /*!
in boolean Diag13); * \brief Split quadrangles into triangles.
*
* Behaves like the above method, taking list of elements from \a theObject
*/
boolean QuadToTriObject (in SMESH_IDSource theObject,
in NumericalFunctor Criterion);
boolean SplitQuadObject(in SMESH_IDSource theObject, /*!
in boolean Diag13); * \brief Split quadrangles into triangles.
* \param theElems The faces to be splitted.
* \param the13Diag Is used to choose a diagonal for splitting.
* \return TRUE in case of success, FALSE otherwise.
*/
boolean SplitQuad (in long_array IDsOfElements,
in boolean Diag13);
/*!
* \brief Split quadrangles into triangles.
*
* Behaves like the above method, taking list of elements from \a theObject
*/
boolean SplitQuadObject (in SMESH_IDSource theObject,
in boolean Diag13);
/*!
* Find better splitting of the given quadrangle.
* \param IDOfQuad ID of the quadrangle to be splitted.
* \param Criterion A criterion to choose a diagonal for splitting.
* \return 1 if 1-3 diagonal is better, 2 if 2-4
* diagonal is better, 0 if error occurs.
*/
long BestSplit (in long IDOfQuad,
in NumericalFunctor Criterion);
enum Smooth_Method { LAPLACIAN_SMOOTH, CENTROIDAL_SMOOTH }; enum Smooth_Method { LAPLACIAN_SMOOTH, CENTROIDAL_SMOOTH };

View File

@ -224,12 +224,13 @@ double MinimumAngle::GetValue( const TSequenceOfXYZ& P )
aMin = Min(aMin,A0); aMin = Min(aMin,A0);
} }
return aMin * 180 / PI; return aMin * 180.0 / PI;
} }
double MinimumAngle::GetBadRate( double Value, int nbNodes ) const double MinimumAngle::GetBadRate( double Value, int nbNodes ) const
{ {
const double aBestAngle = PI / nbNodes; //const double aBestAngle = PI / nbNodes;
const double aBestAngle = 180.0 - ( 360.0 / double(nbNodes) );
return ( fabs( aBestAngle - Value )); return ( fabs( aBestAngle - Value ));
} }

View File

@ -552,6 +552,7 @@ static double getBadRate (const SMDS_MeshElement* theElem,
if ( !theElem || !theCrit->GetPoints( theElem, P )) if ( !theElem || !theCrit->GetPoints( theElem, P ))
return 1e100; return 1e100;
return theCrit->GetBadRate( theCrit->GetValue( P ), theElem->NbNodes() ); return theCrit->GetBadRate( theCrit->GetValue( P ), theElem->NbNodes() );
//return theCrit->GetBadRate( theCrit->GetValue( theElem->GetID() ), theElem->NbNodes() );
} }
//======================================================================= //=======================================================================
@ -622,6 +623,42 @@ bool SMESH_MeshEditor::QuadToTri (set<const SMDS_MeshElement*> & theElems,
return true; return true;
} }
//=======================================================================
//function : BestSplit
//purpose : Find better diagonal for cutting.
//=======================================================================
int SMESH_MeshEditor::BestSplit (const SMDS_MeshElement* theQuad,
SMESH::Controls::NumericalFunctorPtr theCrit)
{
if (!theCrit.get())
return -1;
if (!theQuad || theQuad->GetType() != SMDSAbs_Face || theQuad->NbNodes() != 4)
return -1;
// retrieve element nodes
const SMDS_MeshNode* aNodes [4];
SMDS_ElemIteratorPtr itN = theQuad->nodesIterator();
int i = 0;
while (itN->more())
aNodes[ i++ ] = static_cast<const SMDS_MeshNode*>( itN->next() );
// compare two sets of possible triangles
double aBadRate1, aBadRate2; // to what extent a set is bad
SMDS_FaceOfNodes tr1 ( aNodes[0], aNodes[1], aNodes[2] );
SMDS_FaceOfNodes tr2 ( aNodes[2], aNodes[3], aNodes[0] );
aBadRate1 = getBadRate( &tr1, theCrit ) + getBadRate( &tr2, theCrit );
SMDS_FaceOfNodes tr3 ( aNodes[1], aNodes[2], aNodes[3] );
SMDS_FaceOfNodes tr4 ( aNodes[3], aNodes[0], aNodes[1] );
aBadRate2 = getBadRate( &tr3, theCrit ) + getBadRate( &tr4, theCrit );
if (aBadRate1 <= aBadRate2) // tr1 + tr2 is better
return 1; // diagonal 1-3
return 2; // diagonal 2-4
}
//======================================================================= //=======================================================================
//function : AddToSameGroups //function : AddToSameGroups
//purpose : add elemToAdd to the groups the elemInGroups belongs to //purpose : add elemToAdd to the groups the elemInGroups belongs to

View File

@ -74,22 +74,44 @@ class SMESH_MeshEditor {
// Reverse theElement orientation // Reverse theElement orientation
/*!
* \brief Fuse neighbour triangles into quadrangles.
* \param theElems - The triangles to be fused.
* \param theCriterion - Is used to choose a neighbour to fuse with.
* \param theMaxAngle - Is a max angle between element normals at which fusion
* is still performed; theMaxAngle is mesured in radians.
* \retval bool - Success or not.
*/
bool TriToQuad (std::set<const SMDS_MeshElement*> & theElems, bool TriToQuad (std::set<const SMDS_MeshElement*> & theElems,
SMESH::Controls::NumericalFunctorPtr theCriterion, SMESH::Controls::NumericalFunctorPtr theCriterion,
const double theMaxAngle); const double theMaxAngle);
// Fuse neighbour triangles into quadrangles.
// theCriterion is used to choose a neighbour to fuse with.
// theMaxAngle is a max angle between element normals at which
// fusion is still performed; theMaxAngle is mesured in radians.
/*!
* \brief Split quadrangles into triangles.
* \param theElems - The faces to be splitted.
* \param theCriterion - Is used to choose a diagonal for splitting.
* \retval bool - Success or not.
*/
bool QuadToTri (std::set<const SMDS_MeshElement*> & theElems, bool QuadToTri (std::set<const SMDS_MeshElement*> & theElems,
SMESH::Controls::NumericalFunctorPtr theCriterion); SMESH::Controls::NumericalFunctorPtr theCriterion);
// Cut quadrangles into triangles.
// theCriterion is used to choose a diagonal to cut
/*!
* \brief Split quadrangles into triangles.
* \param theElems - The faces to be splitted.
* \param the13Diag - Is used to choose a diagonal for splitting.
* \retval bool - Success or not.
*/
bool QuadToTri (std::set<const SMDS_MeshElement*> & theElems, bool QuadToTri (std::set<const SMDS_MeshElement*> & theElems,
const bool the13Diag); const bool the13Diag);
// Cut quadrangles into triangles
/*!
* \brief Find better diagonal for splitting.
* \param theQuad - The face to find better splitting of.
* \param theCriterion - Is used to choose a diagonal for splitting.
* \retval int - 1 for 1-3 diagonal, 2 for 2-4, -1 - for errors.
*/
int BestSplit (const SMDS_MeshElement* theQuad,
SMESH::Controls::NumericalFunctorPtr theCriterion);
enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL }; enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL };

View File

@ -25,6 +25,7 @@
// $Header$ // $Header$
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_InitMeshDlg.h" #include "SMESHGUI_InitMeshDlg.h"
#include "SMESHGUI_AddSubMeshDlg.h" #include "SMESHGUI_AddSubMeshDlg.h"
#include "SMESHGUI_NodesDlg.h" #include "SMESHGUI_NodesDlg.h"
@ -39,7 +40,6 @@
#include "SMESHGUI_Preferences_ScalarBarDlg.h" #include "SMESHGUI_Preferences_ScalarBarDlg.h"
#include "SMESHGUI_Preferences_SelectionDlg.h" #include "SMESHGUI_Preferences_SelectionDlg.h"
#include "SMESHGUI_Hypotheses.h" #include "SMESHGUI_Hypotheses.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESHGUI_MoveNodesDlg.h" #include "SMESHGUI_MoveNodesDlg.h"
#include "SMESHGUI_AddMeshElementDlg.h" #include "SMESHGUI_AddMeshElementDlg.h"
#include "SMESHGUI_EditHypothesesDlg.h" #include "SMESHGUI_EditHypothesesDlg.h"
@ -66,13 +66,37 @@
#include "SMESHGUI_Selection.h" #include "SMESHGUI_Selection.h"
#include "SMESHGUI_CreatePolyhedralVolumeDlg.h" #include "SMESHGUI_CreatePolyhedralVolumeDlg.h"
#include <SVTK_InteractorStyle.h> #include "SMESHGUI_Utils.h"
#include <SVTK_RenderWindowInteractor.h> #include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_PatternUtils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_HypothesesUtils.h"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_Object.h" #include "SMESH_Object.h"
#include "SMESH_TypeFilter.hxx" #include "SMESH_TypeFilter.hxx"
#include "SalomeApp_Tools.h"
#include "SalomeApp_Study.h"
#include "SalomeApp_NameDlg.h"
#include "SalomeApp_DataOwner.h"
#include "SalomeApp_Application.h"
#include "SalomeApp_Preferences.h"
#include "SalomeApp_VTKSelector.h"
#include "SalomeApp_ImportOperation.h"
#include <SVTK_ViewWindow.h>
#include <SVTK_ViewModel.h>
#include <SVTK_InteractorStyle.h>
#include <SVTK_RenderWindowInteractor.h>
#include <VTKViewer_ViewManager.h>
#include "OB_Browser.h"
#include "SUIT_Tools.h" #include "SUIT_Tools.h"
#include "SUIT_MessageBox.h" #include "SUIT_MessageBox.h"
#include "SUIT_ResourceMgr.h" #include "SUIT_ResourceMgr.h"
@ -83,63 +107,28 @@
#include "SUIT_Study.h" #include "SUIT_Study.h"
#include "SUIT_Session.h" #include "SUIT_Session.h"
#include "SALOME_NamingService.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_ListIO.hxx"
#include <SALOME_LifeCycleCORBA.hxx>
#include "OB_Browser.h"
#include "QtxPopupMgr.h" #include "QtxPopupMgr.h"
#include "SalomeApp_Tools.h" #include "SALOME_ListIO.hxx"
#include "SalomeApp_Study.h" #include "SALOME_ListIteratorOfListIO.hxx"
#include "SalomeApp_NameDlg.h" #include "SALOME_InteractiveObject.hxx"
#include "SalomeApp_DataOwner.h" #include "SALOME_NamingService.hxx"
#include "SalomeApp_Application.h" #include "SALOME_LifeCycleCORBA.hxx"
#include "SalomeApp_Preferences.h"
#include "SalomeApp_VTKSelector.h"
#include "SalomeApp_ImportOperation.h"
#include <SVTK_ViewWindow.h>
#include <SVTK_ViewModel.h>
#include <VTKViewer_ViewManager.h>
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_GEOMGenUtils.h"
#include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_GroupUtils.h"
#include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_PatternUtils.h"
#include "SMESHGUI_VTKUtils.h"
#include "SALOMEconfig.h" #include "SALOMEconfig.h"
#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes)
// QT Includes // QT Includes
#define INCLUDE_MENUITEM_DEF #define INCLUDE_MENUITEM_DEF
#include <qapplication.h>
#include <qlineedit.h>
#include <qmenudata.h>
#include <qmenubar.h>
#include <qpopupmenu.h> #include <qpopupmenu.h>
#include <qfont.h>
#include <qstring.h> #include <qstring.h>
#include <qpainter.h>
#include <qcheckbox.h>
#include <qcolordialog.h>
#include <qspinbox.h>
#include <qlist.h>
#include <qwidget.h> #include <qwidget.h>
#include <qevent.h>
#include <qaction.h> #include <qaction.h>
#include <qradiobutton.h>
// BOOST Includes
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
// VTK Includes
#include <vtkRenderer.h> #include <vtkRenderer.h>
#include <vtkRenderWindow.h> #include <vtkRenderWindow.h>
#include <vtkActorCollection.h> #include <vtkActorCollection.h>

View File

@ -26,13 +26,15 @@
// Module : SMESH // Module : SMESH
#include "SMESHGUI_MultiEditDlg.h" #include "SMESHGUI_MultiEditDlg.h"
#include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI_Filter.h"
#include "SMESHGUI.h" #include "SMESHGUI.h"
#include "SMESHGUI_Filter.h"
#include "SMESHGUI_FilterDlg.h"
#include "SMESHGUI_Utils.h" #include "SMESHGUI_Utils.h"
#include "SMESHGUI_VTKUtils.h" #include "SMESHGUI_VTKUtils.h"
#include "SMESHGUI_MeshUtils.h" #include "SMESHGUI_MeshUtils.h"
#include "SMESHGUI_FilterUtils.h"
#include "SMESHGUI_SpinBox.h"
#include "SMESH_Actor.h" #include "SMESH_Actor.h"
#include "SMESH_TypeFilter.hxx" #include "SMESH_TypeFilter.hxx"
@ -71,17 +73,18 @@
#include <vtkDataSetMapper.h> #include <vtkDataSetMapper.h>
// QT Includes // QT Includes
#include <qcheckbox.h>
#include <qframe.h> #include <qframe.h>
#include <qgroupbox.h>
#include <qlabel.h> #include <qlabel.h>
#include <qlayout.h> #include <qlayout.h>
#include <qlineedit.h>
#include <qlistbox.h> #include <qlistbox.h>
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qgroupbox.h>
#include <qlineedit.h>
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qapplication.h> #include <qapplication.h>
#include <qhbuttongroup.h>
#include <qradiobutton.h> #include <qradiobutton.h>
#include <qhbuttongroup.h>
// IDL Headers // IDL Headers
#include "SALOMEconfig.h" #include "SALOMEconfig.h"
@ -158,7 +161,6 @@ QFrame* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool t
myListBox = new QListBox(aFrame); myListBox = new QListBox(aFrame);
myListBox->setSelectionMode(QListBox::Extended); myListBox->setSelectionMode(QListBox::Extended);
myListBox->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding)); myListBox->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
// myListBox->setColumnMode(QListBox::FitToHeight);
myListBox->installEventFilter(this); myListBox->installEventFilter(this);
myFilterBtn = new QPushButton(tr("FILTER") , aFrame); myFilterBtn = new QPushButton(tr("FILTER") , aFrame);
@ -178,6 +180,29 @@ QFrame* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool t
myToAllChk = new QCheckBox(tr("TO_ALL"), mySelGrp); myToAllChk = new QCheckBox(tr("TO_ALL"), mySelGrp);
// Split/Join criterion group
myCriterionGrp = new QGroupBox(3, Qt::Vertical, tr("SPLIT_JOIN_CRITERION"), aMainGrp);
myGroupChoice = new QButtonGroup(3, Qt::Vertical, myCriterionGrp);
myGroupChoice->setInsideMargin(0);
myGroupChoice->setFrameStyle(QFrame::NoFrame);
(new QRadioButton(tr("USE_DIAGONAL_1_3"), myGroupChoice))->setChecked(true);
(new QRadioButton(tr("USE_DIAGONAL_2_4"), myGroupChoice));
(new QRadioButton(tr("USE_NUMERIC_FUNC"), myGroupChoice));
myComboBoxFunctor = new QComboBox(myCriterionGrp);
myComboBoxFunctor->insertItem(tr("ASPECTRATIO_ELEMENTS"));
myComboBoxFunctor->insertItem(tr("MINIMUMANGLE_ELEMENTS"));
myComboBoxFunctor->insertItem(tr("SKEW_ELEMENTS"));
myComboBoxFunctor->insertItem(tr("AREA_ELEMENTS"));
//myComboBoxFunctor->insertItem(tr("LENGTH2D_EDGES")); // for existing elements only
//myComboBoxFunctor->insertItem(tr("MULTI2D_BORDERS")); // for existing elements only
myComboBoxFunctor->setCurrentItem(0);
myCriterionGrp->hide();
myGroupChoice->hide();
myComboBoxFunctor->setEnabled(false);
// "Select from" group // "Select from" group
QGroupBox* aGrp = new QGroupBox(3, Qt::Horizontal, tr("SELECT_FROM"), aMainGrp); QGroupBox* aGrp = new QGroupBox(3, Qt::Horizontal, tr("SELECT_FROM"), aMainGrp);
@ -187,7 +212,7 @@ QFrame* SMESHGUI_MultiEditDlg::createMainFrame (QWidget* theParent, const bool t
mySubmesh->setReadOnly(true); mySubmesh->setReadOnly(true);
mySubmeshBtn->setPixmap(aPix); mySubmeshBtn->setPixmap(aPix);
myGroupChk = new QCheckBox(tr("GROUP"), aGrp); myGroupChk = new QCheckBox(tr("SMESH_GROUP"), aGrp);
myGroupBtn = new QPushButton(aGrp); myGroupBtn = new QPushButton(aGrp);
myGroup = new QLineEdit(aGrp); myGroup = new QLineEdit(aGrp);
myGroup->setReadOnly(true); myGroup->setReadOnly(true);
@ -258,6 +283,39 @@ bool SMESHGUI_MultiEditDlg::eventFilter (QObject* object, QEvent* event)
return QDialog::eventFilter(object, event); return QDialog::eventFilter(object, event);
} }
//=======================================================================
// name : SMESHGUI_MultiEditDlg::getNumericalFunctor
// Purpose :
//=======================================================================
SMESH::NumericalFunctor_ptr SMESHGUI_MultiEditDlg::getNumericalFunctor()
{
SMESH::NumericalFunctor_var aNF = SMESH::NumericalFunctor::_nil();
SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager();
if (aFilterMgr->_is_nil())
return aNF._retn();
if (myComboBoxFunctor->currentText() == tr("ASPECTRATIO_ELEMENTS"))
aNF = aFilterMgr->CreateAspectRatio();
else if (myComboBoxFunctor->currentText() == tr("WARP_ELEMENTS"))
aNF = aFilterMgr->CreateWarping();
else if (myComboBoxFunctor->currentText() == tr("MINIMUMANGLE_ELEMENTS"))
aNF = aFilterMgr->CreateMinimumAngle();
else if (myComboBoxFunctor->currentText() == tr("TAPER_ELEMENTS"))
aNF = aFilterMgr->CreateTaper();
else if (myComboBoxFunctor->currentText() == tr("SKEW_ELEMENTS"))
aNF = aFilterMgr->CreateSkew();
else if (myComboBoxFunctor->currentText() == tr("AREA_ELEMENTS"))
aNF = aFilterMgr->CreateArea();
else if (myComboBoxFunctor->currentText() == tr("LENGTH2D_EDGES"))
aNF = aFilterMgr->CreateLength2D();
else if (myComboBoxFunctor->currentText() == tr("MULTI2D_BORDERS"))
aNF = aFilterMgr->CreateMultiConnection2D();
else ;
return aNF._retn();
}
//======================================================================= //=======================================================================
// name : SMESHGUI_MultiEditDlg::Init // name : SMESHGUI_MultiEditDlg::Init
// Purpose : Init dialog fields, connect signals and slots, show dialog // Purpose : Init dialog fields, connect signals and slots, show dialog
@ -932,7 +990,7 @@ int SMESHGUI_MultiEditDlg::entityType()
return myEntityType; return myEntityType;
} }
/* /*!
* Class : SMESHGUI_ChangeOrientationDlg * Class : SMESHGUI_ChangeOrientationDlg
* Description : Modification of orientation of faces * Description : Modification of orientation of faces
*/ */
@ -966,6 +1024,21 @@ SMESHGUI_UnionOfTrianglesDlg
SMESHGUI_MultiEditDlg(theModule, SMESHGUI_TriaFilter, false, theName) SMESHGUI_MultiEditDlg(theModule, SMESHGUI_TriaFilter, false, theName)
{ {
setCaption(tr("CAPTION")); setCaption(tr("CAPTION"));
myComboBoxFunctor->setEnabled(true);
myComboBoxFunctor->insertItem(tr("WARP_ELEMENTS")); // for quadrangles only
myComboBoxFunctor->insertItem(tr("TAPER_ELEMENTS")); // for quadrangles only
// Maximum angle
QGroupBox* aMaxAngleGrp = new QGroupBox (2, Qt::Horizontal, myCriterionGrp);
aMaxAngleGrp->setInsideMargin(0);
aMaxAngleGrp->setFrameStyle(QFrame::NoFrame);
new QLabel (tr("MAXIMUM_ANGLE"), aMaxAngleGrp);
myMaxAngleSpin = new SMESHGUI_SpinBox (aMaxAngleGrp);
myMaxAngleSpin->RangeStepAndValidator(0, 180.0, 1.0, 3);
myMaxAngleSpin->SetValue(30.0);
myCriterionGrp->show();
} }
SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg() SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg()
@ -975,12 +1048,15 @@ SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg()
bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, bool SMESHGUI_UnionOfTrianglesDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
const SMESH::long_array& theIds) const SMESH::long_array& theIds)
{ {
return theEditor->TriToQuad(theIds, SMESH::NumericalFunctor::_nil(), 1.); SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
double aMaxAngle = myMaxAngleSpin->GetValue() * PI / 180.0;
return theEditor->TriToQuad(theIds, aCriterion, aMaxAngle);
} }
/*! /*!
* Class : SMESHGUI_CuttingOfQuadsDlg * Class : SMESHGUI_CuttingOfQuadsDlg
* Description : Construction of quadrangles by automatic association of triangles * Description : Automatic splitting of quadrangles into triangles
*/ */
SMESHGUI_CuttingOfQuadsDlg SMESHGUI_CuttingOfQuadsDlg
@ -991,12 +1067,16 @@ SMESHGUI_CuttingOfQuadsDlg
setCaption(tr("CAPTION")); setCaption(tr("CAPTION"));
myPreviewActor = 0; myPreviewActor = 0;
myUseDiagChk = new QCheckBox (tr("USE_DIAGONAL_2_4"), mySelGrp);
myPreviewChk = new QCheckBox (tr("PREVIEW"), mySelGrp); myPreviewChk = new QCheckBox (tr("PREVIEW"), mySelGrp);
connect(myPreviewChk, SIGNAL(stateChanged(int)), this, SLOT(onPreviewChk())); myCriterionGrp->show();
connect(myUseDiagChk, SIGNAL(stateChanged(int)), this, SLOT(onPreviewChk())); myGroupChoice->show();
connect(this, SIGNAL(ListContensChanged()), this, SLOT(onPreviewChk())); myComboBoxFunctor->setEnabled(false);
connect(myPreviewChk , SIGNAL(stateChanged(int)) , this, SLOT(onPreviewChk()));
connect(myGroupChoice , SIGNAL(clicked(int)) , this, SLOT(onCriterionRB()));
connect(myComboBoxFunctor, SIGNAL(activated(int)) , this, SLOT(onPreviewChk()));
connect(this , SIGNAL(ListContensChanged()), this, SLOT(onPreviewChk()));
} }
SMESHGUI_CuttingOfQuadsDlg::~SMESHGUI_CuttingOfQuadsDlg() SMESHGUI_CuttingOfQuadsDlg::~SMESHGUI_CuttingOfQuadsDlg()
@ -1012,7 +1092,27 @@ void SMESHGUI_CuttingOfQuadsDlg::onClose()
bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor, bool SMESHGUI_CuttingOfQuadsDlg::process (SMESH::SMESH_MeshEditor_ptr theEditor,
const SMESH::long_array& theIds) const SMESH::long_array& theIds)
{ {
return theEditor->SplitQuad(theIds, !myUseDiagChk->isChecked()); switch (myGroupChoice->id(myGroupChoice->selected())) {
case 0: // use diagonal 1-3
return theEditor->SplitQuad(theIds, true);
case 1: // use diagonal 2-4
return theEditor->SplitQuad(theIds, false);
default: // use numeric functor
break;
}
SMESH::NumericalFunctor_var aCriterion = getNumericalFunctor();
return theEditor->QuadToTri(theIds, aCriterion);
}
void SMESHGUI_CuttingOfQuadsDlg::onCriterionRB()
{
if (myGroupChoice->id(myGroupChoice->selected()) == 2) // Use numeric functor
myComboBoxFunctor->setEnabled(true);
else
myComboBoxFunctor->setEnabled(false);
onPreviewChk();
} }
void SMESHGUI_CuttingOfQuadsDlg::onPreviewChk() void SMESHGUI_CuttingOfQuadsDlg::onPreviewChk()
@ -1050,7 +1150,16 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
if (aMesh == 0) if (aMesh == 0)
return; return;
bool isDiag24 = myUseDiagChk->isChecked(); // 0 - use diagonal 1-3, 1 - use diagonal 2-4, 2 - use numerical functor
int aChoice = myGroupChoice->id(myGroupChoice->selected());
SMESH::NumericalFunctor_var aCriterion = SMESH::NumericalFunctor::_nil();
SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH::SMESH_MeshEditor::_nil();
if (aChoice == 2) {
aCriterion = getNumericalFunctor();
aMeshEditor = myMesh->GetMeshEditor();
if (aMeshEditor->_is_nil())
return;
}
//Create grid //Create grid
vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
@ -1082,8 +1191,9 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); SMDS_ElemIteratorPtr anIter = anElem->nodesIterator();
int k = 0; int k = 0;
while(anIter->more()) while (anIter->more()) {
if (const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next()) const SMDS_MeshNode* aNode = static_cast<const SMDS_MeshNode*>(anIter->next());
if (aNode)
{ {
if (!anIdToVtk.IsBound(aNode->GetID())) if (!anIdToVtk.IsBound(aNode->GetID()))
{ {
@ -1093,11 +1203,33 @@ void SMESHGUI_CuttingOfQuadsDlg::displayPreview()
aNodes[ k++ ] = aNode->GetID(); aNodes[ k++ ] = aNode->GetID();
} }
}
if (k != 4) if (k != 4)
continue; continue;
if (!isDiag24) bool isDiag13 = true;
if (aChoice == 0) // use diagonal 1-3
{
isDiag13 = true;
}
else if (aChoice == 1) // use diagonal 2-4
{
isDiag13 = false;
}
else // use numerical functor
{
// compare two sets of possible triangles
int diag = aMeshEditor->BestSplit(anElemIds[i], aCriterion);
if (diag == 1) // 1-3
isDiag13 = true;
else if (diag == 2) // 2-4
isDiag13 = false;
else // error
continue;
}
if (isDiag13)
{ {
anIdList->SetId(0, anIdToVtk(aNodes[ 0 ])); anIdList->SetId(0, anIdToVtk(aNodes[ 0 ]));
anIdList->SetId(1, anIdToVtk(aNodes[ 1 ])); anIdList->SetId(1, anIdToVtk(aNodes[ 1 ]));

View File

@ -35,32 +35,34 @@
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Mesh)
#include CORBA_SERVER_HEADER(SMESH_Filter)
class SMESHGUI_FilterDlg;
class QCheckBox;
class QGroupBox;
class QListBox;
class QFrame;
class QLineEdit;
class SMESHGUI_SpinBox;
class QPushButton;
class QButtonGroup;
class QObject;
class SMESH_Actor;
class SALOME_Actor;
class SalomeApp_SelectionMgr;
class SMESHGUI; class SMESHGUI;
class SMESHGUI_FilterDlg;
class SMESHGUI_SpinBox;
class SMESH_Actor; class SMESH_Actor;
class SalomeApp_SelectionMgr;
class SALOME_Actor;
class SVTK_Selector; class SVTK_Selector;
class SVTK_ViewWindow; class SVTK_ViewWindow;
/* class QFrame;
Class : SMESHGUI_MultiEditDlg class QObject;
Description : Base class for dialogs of diagonal inversion and class QListBox;
union of two neighboring triangles class QComboBox;
*/ class QCheckBox;
class QGroupBox;
class QLineEdit;
class QPushButton;
class QButtonGroup;
/*!
* Class : SMESHGUI_MultiEditDlg
* Description : Base class for dialogs of diagonal inversion and
* union of two neighboring triangles
*/
class SMESHGUI_MultiEditDlg : public QDialog class SMESHGUI_MultiEditDlg : public QDialog
{ {
@ -73,7 +75,7 @@ public:
const char* = 0 ); const char* = 0 );
virtual ~SMESHGUI_MultiEditDlg(); virtual ~SMESHGUI_MultiEditDlg();
void Init() ; void Init();
bool eventFilter( QObject* object, QEvent* event ); bool eventFilter( QObject* object, QEvent* event );
@ -81,7 +83,6 @@ signals:
void ListContensChanged(); void ListContensChanged();
protected slots: protected slots:
void onOk(); void onOk();
virtual bool onApply(); virtual bool onApply();
virtual void onClose(); virtual void onClose();
@ -100,8 +101,9 @@ protected slots:
void onFilterAccepted(); void onFilterAccepted();
void on3d2dChanged(int); void on3d2dChanged(int);
protected: SMESH::NumericalFunctor_ptr getNumericalFunctor();
protected:
void closeEvent( QCloseEvent* e ) ; void closeEvent( QCloseEvent* e ) ;
void enterEvent ( QEvent * ) ; void enterEvent ( QEvent * ) ;
void hideEvent ( QHideEvent * ); /* ESC key */ void hideEvent ( QHideEvent * ); /* ESC key */
@ -116,7 +118,6 @@ protected:
int entityType(); int entityType();
protected: protected:
QPushButton* myOkBtn; QPushButton* myOkBtn;
QPushButton* myApplyBtn; QPushButton* myApplyBtn;
QPushButton* myCloseBtn; QPushButton* myCloseBtn;
@ -128,6 +129,10 @@ protected:
SMESHGUI* mySMESHGUI; SMESHGUI* mySMESHGUI;
QGroupBox* mySelGrp; QGroupBox* mySelGrp;
QGroupBox* myCriterionGrp;
QButtonGroup* myGroupChoice;
QComboBox* myComboBoxFunctor;
QListBox* myListBox; QListBox* myListBox;
QPushButton* myFilterBtn; QPushButton* myFilterBtn;
@ -153,40 +158,41 @@ protected:
int myEntityType; int myEntityType;
}; };
/* /*!
Class : SMESHGUI_ChangeOrientationDlg * Class : SMESHGUI_ChangeOrientationDlg
Description : Modification of orientation of faces * Description : Modification of orientation of faces
*/ */
class SMESHGUI_ChangeOrientationDlg : public SMESHGUI_MultiEditDlg class SMESHGUI_ChangeOrientationDlg : public SMESHGUI_MultiEditDlg
{ {
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_ChangeOrientationDlg(SMESHGUI* theModule, SMESHGUI_ChangeOrientationDlg(SMESHGUI* theModule,
const char* = 0); const char* = 0);
virtual ~SMESHGUI_ChangeOrientationDlg(); virtual ~SMESHGUI_ChangeOrientationDlg();
protected: protected:
virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& );
virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& );
}; };
/* /*!
Class : SMESHGUI_UnionOfTrianglesDlg * Class : SMESHGUI_UnionOfTrianglesDlg
Description : Construction of quadrangles by automatic association of triangles * Description : Construction of quadrangles by automatic association of triangles
*/ */
class SMESHGUI_UnionOfTrianglesDlg : public SMESHGUI_MultiEditDlg class SMESHGUI_UnionOfTrianglesDlg : public SMESHGUI_MultiEditDlg
{ {
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_UnionOfTrianglesDlg(SMESHGUI* theModule, SMESHGUI_UnionOfTrianglesDlg(SMESHGUI* theModule,
const char* = 0); const char* = 0);
virtual ~SMESHGUI_UnionOfTrianglesDlg(); virtual ~SMESHGUI_UnionOfTrianglesDlg();
protected: protected:
virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& );
virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ); private:
SMESHGUI_SpinBox* myMaxAngleSpin;
}; };
/* /*
@ -198,25 +204,25 @@ class SMESHGUI_CuttingOfQuadsDlg : public SMESHGUI_MultiEditDlg
Q_OBJECT Q_OBJECT
public: public:
SMESHGUI_CuttingOfQuadsDlg(SMESHGUI* theModule, SMESHGUI_CuttingOfQuadsDlg(SMESHGUI* theModule,
const char* = 0); const char* = 0);
virtual ~SMESHGUI_CuttingOfQuadsDlg(); virtual ~SMESHGUI_CuttingOfQuadsDlg();
protected: protected:
virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ); virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& );
protected slots: protected slots:
virtual void onClose(); virtual void onClose();
void onPreviewChk(); void onCriterionRB();
void onPreviewChk();
private: private:
void displayPreview(); void displayPreview();
void erasePreview(); void erasePreview();
private: private:
QCheckBox* myUseDiagChk; SALOME_Actor* myPreviewActor;
SALOME_Actor* myPreviewActor; QCheckBox* myPreviewChk;
QCheckBox* myPreviewChk;
}; };
#endif #endif

View File

@ -1346,24 +1346,33 @@ msgstr "Sort list"
msgid "SMESHGUI_MultiEditDlg::TO_ALL" msgid "SMESHGUI_MultiEditDlg::TO_ALL"
msgstr "Apply to all" msgstr "Apply to all"
msgid "SMESHGUI_MultiEditDlg::SPLIT_JOIN_CRITERION"
msgstr "Criterion"
msgid "SMESHGUI_MultiEditDlg::USE_DIAGONAL_1_3"
msgstr "Use diagonal 1-3"
msgid "SMESHGUI_MultiEditDlg::USE_DIAGONAL_2_4"
msgstr "Use diagonal 2-4"
msgid "SMESHGUI_MultiEditDlg::USE_NUMERIC_FUNC"
msgstr "Use numeric functor"
msgid "SMESHGUI_MultiEditDlg::SELECT_FROM" msgid "SMESHGUI_MultiEditDlg::SELECT_FROM"
msgstr "Select from" msgstr "Select from"
msgid "SMESHGUI_MultiEditDlg::GROUP"
msgstr "Group"
msgid "SMESHGUI_ChangeOrientationDlg::CAPTION" msgid "SMESHGUI_ChangeOrientationDlg::CAPTION"
msgstr "Modification of orientation" msgstr "Modification of orientation"
msgid "SMESHGUI_UnionOfTrianglesDlg::CAPTION" msgid "SMESHGUI_UnionOfTrianglesDlg::CAPTION"
msgstr "Union of triangles" msgstr "Union of triangles"
msgid "SMESHGUI_UnionOfTrianglesDlg::MAXIMUM_ANGLE"
msgstr "Maximum bending angle"
msgid "SMESHGUI_CuttingOfQuadsDlg::CAPTION" msgid "SMESHGUI_CuttingOfQuadsDlg::CAPTION"
msgstr "Cutting of quadrangles" msgstr "Cutting of quadrangles"
msgid "SMESHGUI_CuttingOfQuadsDlg::USE_DIAGONAL_2_4"
msgstr "Use diagonal 2-4"
msgid "SMESHGUI_CuttingOfQuadsDlg::PREVIEW" msgid "SMESHGUI_CuttingOfQuadsDlg::PREVIEW"
msgstr "Preview" msgstr "Preview"

View File

@ -443,11 +443,9 @@ CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theO
* *
*/ */
//============================================================================= //=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements,
CORBA::Boolean SMESH::NumericalFunctor_ptr Criterion,
SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements, CORBA::Double MaxAngle)
SMESH::NumericalFunctor_ptr Criterion,
CORBA::Double MaxAngle)
{ {
set<const SMDS_MeshElement*> faces; set<const SMDS_MeshElement*> faces;
for (int i = 0; i < IDsOfElements.length(); i++) for (int i = 0; i < IDsOfElements.length(); i++)
@ -468,8 +466,8 @@ CORBA::Boolean
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.TriToQuad("); TCollection_AsciiString str ("isDone = mesh_editor.TriToQuad(");
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None, "; SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None, ";
str += (Standard_Real) MaxAngle; str += TCollection_AsciiString((Standard_Real) MaxAngle) + ")";
SMESH_Gen_i::AddToCurrentPyScript( str + ")" ); SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuad: \", isDone" ); SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuad: \", isDone" );
#endif #endif
@ -483,11 +481,9 @@ CORBA::Boolean
* *
*/ */
//============================================================================= //=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
CORBA::Boolean SMESH::NumericalFunctor_ptr Criterion,
SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject, CORBA::Double MaxAngle)
SMESH::NumericalFunctor_ptr Criterion,
CORBA::Double MaxAngle)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle); CORBA::Boolean isDone = TriToQuad(anElementsId, Criterion, MaxAngle);
@ -502,8 +498,8 @@ CORBA::Boolean
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.TriToQuadObject("); TCollection_AsciiString str ("isDone = mesh_editor.TriToQuadObject(");
SMESH_Gen_i::AddObject( str, theObject ) += ", None, "; SMESH_Gen_i::AddObject( str, theObject ) += ", None, ";
str += (Standard_Real) MaxAngle; str += TCollection_AsciiString((Standard_Real) MaxAngle) + ")";
SMESH_Gen_i::AddToCurrentPyScript( str + ")" ); SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuadObject: \", isDone" ); SMESH_Gen_i::AddToCurrentPyScript( "print \"TriToQuadObject: \", isDone" );
#endif #endif
@ -516,10 +512,8 @@ CORBA::Boolean
* *
*/ */
//============================================================================= //=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::QuadToTri (const SMESH::long_array & IDsOfElements,
CORBA::Boolean SMESH::NumericalFunctor_ptr Criterion)
SMESH_MeshEditor_i::QuadToTri(const SMESH::long_array & IDsOfElements,
SMESH::NumericalFunctor_ptr Criterion)
{ {
set<const SMDS_MeshElement*> faces; set<const SMDS_MeshElement*> faces;
for (int i = 0; i < IDsOfElements.length(); i++) for (int i = 0; i < IDsOfElements.length(); i++)
@ -540,7 +534,7 @@ CORBA::Boolean
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.QuadToTri("); TCollection_AsciiString str ("isDone = mesh_editor.QuadToTri(");
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None ), "; SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", None )";
SMESH_Gen_i::AddToCurrentPyScript( str ); SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTri: \", isDone" ); SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTri: \", isDone" );
@ -555,10 +549,37 @@ CORBA::Boolean
* *
*/ */
//============================================================================= //=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
SMESH::NumericalFunctor_ptr Criterion)
{
SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = QuadToTri(anElementsId, Criterion);
CORBA::Boolean // Clear python line(s), created by QuadToTri()
SMESH_MeshEditor_i::SplitQuad(const SMESH::long_array & IDsOfElements, SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen();
CORBA::Boolean Diag13) aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
#ifdef _DEBUG_
aSMESHGen->RemoveLastFromPythonScript(aSMESHGen->GetCurrentStudyID());
#endif
// Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.QuadToTriObject(");
SMESH_Gen_i::AddObject( str, theObject ) += ", None )";
SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"QuadToTriObject: \", isDone" );
#endif
return isDone;
}
//=============================================================================
/*!
*
*/
//=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::SplitQuad (const SMESH::long_array & IDsOfElements,
CORBA::Boolean Diag13)
{ {
set<const SMDS_MeshElement*> faces; set<const SMDS_MeshElement*> faces;
for (int i = 0; i < IDsOfElements.length(); i++) for (int i = 0; i < IDsOfElements.length(); i++)
@ -572,8 +593,8 @@ CORBA::Boolean
// Update Python script // Update Python script
TCollection_AsciiString str ("isDone = mesh_editor.SplitQuad("); TCollection_AsciiString str ("isDone = mesh_editor.SplitQuad(");
SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", "; SMESH_Gen_i::AddArray( str, IDsOfElements ) += ", ";
str += TCollection_AsciiString( Diag13 ); str += TCollection_AsciiString( Diag13 ) + ")";
SMESH_Gen_i::AddToCurrentPyScript( str + ")" ); SMESH_Gen_i::AddToCurrentPyScript( str );
#ifdef _DEBUG_ #ifdef _DEBUG_
SMESH_Gen_i::AddToCurrentPyScript( "print \"SplitQuad: \", isDone" ); SMESH_Gen_i::AddToCurrentPyScript( "print \"SplitQuad: \", isDone" );
#endif #endif
@ -587,10 +608,8 @@ CORBA::Boolean
* *
*/ */
//============================================================================= //=============================================================================
CORBA::Boolean SMESH_MeshEditor_i::SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
CORBA::Boolean CORBA::Boolean Diag13)
SMESH_MeshEditor_i::SplitQuadObject(SMESH::SMESH_IDSource_ptr theObject,
CORBA::Boolean Diag13)
{ {
SMESH::long_array_var anElementsId = theObject->GetIDs(); SMESH::long_array_var anElementsId = theObject->GetIDs();
CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13); CORBA::Boolean isDone = SplitQuad(anElementsId, Diag13);
@ -614,6 +633,31 @@ CORBA::Boolean
return isDone; return isDone;
} }
//=============================================================================
/*!
* BestSplit
*/
//=============================================================================
CORBA::Long SMESH_MeshEditor_i::BestSplit (CORBA::Long IDOfQuad,
SMESH::NumericalFunctor_ptr Criterion)
{
const SMDS_MeshElement* quad = GetMeshDS()->FindElement(IDOfQuad);
if (quad && quad->GetType() == SMDSAbs_Face && quad->NbNodes() == 4)
{
SMESH::NumericalFunctor_i* aNumericalFunctor =
dynamic_cast<SMESH::NumericalFunctor_i*>(SMESH_Gen_i::GetServant(Criterion).in());
SMESH::Controls::NumericalFunctorPtr aCrit;
if (aNumericalFunctor)
aCrit = aNumericalFunctor->GetNumericalFunctor();
else
aCrit.reset(new SMESH::Controls::AspectRatio());
::SMESH_MeshEditor anEditor (_myMesh);
return anEditor.BestSplit(quad, aCrit);
}
return -1;
}
//======================================================================= //=======================================================================
//function : Smooth //function : Smooth
//purpose : //purpose :
@ -774,7 +818,7 @@ CORBA::Boolean
str += (Standard_Integer) MaxNbOfIterations; str += (Standard_Integer) MaxNbOfIterations;
str += ", "; str += ", ";
str += (Standard_Real) MaxAspectRatio; str += (Standard_Real) MaxAspectRatio;
if ( Method == ::SMESH_MeshEditor::CENTROIDAL ) if ( Method == SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH )
str += ", SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH, "; str += ", SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH, ";
else else
str += ", SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH, "; str += ", SMESH.SMESH_MeshEditor.LAPLACIAN_SMOOTH, ";

View File

@ -64,18 +64,23 @@ class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor
CORBA::Boolean Reorient(const SMESH::long_array & IDsOfElements); CORBA::Boolean Reorient(const SMESH::long_array & IDsOfElements);
CORBA::Boolean ReorientObject(SMESH::SMESH_IDSource_ptr theObject); CORBA::Boolean ReorientObject(SMESH::SMESH_IDSource_ptr theObject);
CORBA::Boolean TriToQuad(const SMESH::long_array & IDsOfElements, // Split/Join faces
SMESH::NumericalFunctor_ptr Criterion, CORBA::Boolean TriToQuad (const SMESH::long_array & IDsOfElements,
CORBA::Double MaxAngle); SMESH::NumericalFunctor_ptr Criterion,
CORBA::Boolean TriToQuadObject(SMESH::SMESH_IDSource_ptr theObject, CORBA::Double MaxAngle);
SMESH::NumericalFunctor_ptr Criterion, CORBA::Boolean TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject,
CORBA::Double MaxAngle); SMESH::NumericalFunctor_ptr Criterion,
CORBA::Boolean QuadToTri(const SMESH::long_array & IDsOfElements, CORBA::Double MaxAngle);
SMESH::NumericalFunctor_ptr Criterion); CORBA::Boolean QuadToTri (const SMESH::long_array & IDsOfElements,
CORBA::Boolean SplitQuad(const SMESH::long_array & IDsOfElements, SMESH::NumericalFunctor_ptr Criterion);
CORBA::Boolean Diag13); CORBA::Boolean QuadToTriObject (SMESH::SMESH_IDSource_ptr theObject,
CORBA::Boolean SplitQuadObject(SMESH::SMESH_IDSource_ptr theObject, SMESH::NumericalFunctor_ptr Criterion);
CORBA::Boolean Diag13); CORBA::Boolean SplitQuad (const SMESH::long_array & IDsOfElements,
CORBA::Boolean Diag13);
CORBA::Boolean SplitQuadObject (SMESH::SMESH_IDSource_ptr theObject,
CORBA::Boolean Diag13);
CORBA::Long BestSplit (CORBA::Long IDOfQuad,
SMESH::NumericalFunctor_ptr Criterion);
CORBA::Boolean Smooth(const SMESH::long_array & IDsOfElements, CORBA::Boolean Smooth(const SMESH::long_array & IDsOfElements,
const SMESH::long_array & IDsOfFixedNodes, const SMESH::long_array & IDsOfFixedNodes,