--- /dev/null
+/*!
+
+\page blsurf_hypo_page BLSURF Parameters hypothesis
+
+\n BLSURF Parameters hypothesis works only with <b>BLSURF</b> 2d
+algorithm. This algorithm is a commercial software.
+
+\image html blsurf_parameters.png
+
+<ul>
+<li><b>Name</b> - allows to define the name of the hypothesis (BLSURF
+Parameters by default).</li>
+
+<li><b>Physical Mesh</b> - if is set to "Custom", allows to set size
+of mesh elements to generate in <b>User size</b> field.
+</li>
+
+<li><b>User size</b> - size of mesh elements to generate. </li>
+
+<li><b>Max Physical Size</b> - is an upper limit of mesh element size. </li>
+
+<li><b>Min Physical Size</b> - is a lower limit of mesh element size. </li>
+
+<li><b>Geometrical mesh</b> - if is set to "Custom", allows to set
+mesh element deflection from curves and surfaces and element
+size change rate in <b>Angle Mesh S</b>, <b>Angle Mesh C</b> and
+<b>Gradation</b> fields correspondingly. These fields control
+computation of element size, so called <i>geometrical size</i>, conform to
+the surface geometry considering local curvatures. \n
+The eventual element size at each point will be minimum of <b>User
+size</b>, if given, and the <i>geometrical size</i>. </li>
+
+<li><b>Angle Mesh S</b> - maximal allowed angle in degrees at a mesh
+node between the mesh face and the tangent to the geometrical surface. </li>
+
+<li><b>Angle Mesh C</b> - maximal allowed angle in degrees at a mesh
+node between the mesh edge and the tangent to the geometrical curve. </li>
+
+<li><b>Max Geometrical Size</b> - is an upper limit of <i>geometrical size</i>.</li>
+
+<li><b>Min Geometrical Size</b> - is a lower limit of <i>geometrical size</i>.</li>
+
+<li><b>Gradation</b> - maximal allowed ratio between the lengths of
+two adjacent edges. </li>
+
+<li><b>Allow Quadrangles</b> - to create quadrilateral elements.</li>
+
+<li><b>Patch independent</b> - if this box is checked on, geometrical
+edges are not respected and all geometrical faces are meshed as one
+hyper-face.</li>
+
+\image html blsurf_parameters_advanced.png
+
+<li><b>Topology</b> - allows creation of a conform mesh on a shell of
+not sewed faces.
+<ul>
+ <li>"From CAD" means that mesh conformity is assured by conformity
+ of a shape.</li>
+ <li>"Pre-process" and "Pre-process++" let BLSURF software
+ pre-process the geometrical model to eventually produce a conform
+ mesh. </li>
+</ul>
+
+<li><b>Verbosity level</b> - Defines the percentage of "verbosity" of
+BLSURF [0-100].</li>
+
+<li><b>Add option</b> - provides a choice of multiple advanced
+options, each of which, if selected, appear in a table where you can
+enter a value of the option and edit it later.</li>
+
+<li><b>Clear option</b> - removes option selected in the table.
+
+</ul>
+
+\n
+Commonly usable options are following. The name <i>diag</i> stands there for
+the diagonal of the bounding box of the geometrical object to mesh.
+
+<ul>
+<li><b>topo_eps1</b> (real) - is the tolerance level inside a CAD
+patch. By default is equal to <i>diag</i> × 10-4. This tolerance is used to
+identify nodes to merge within one geometrical face when \b Topology
+option is to pre-process. Default is <i>diag</i>/10.0.</li>
+
+<li><b>topo_eps2</b> (real) - is the tolerance level between two CAD
+patches. By default is equal to <i>diag</i> × 10-4. This tolerance is used to
+identify nodes to merge over different geometrical faces when
+\b Topology option is to pre-process. Default is <i>diag</i>/10.0.</li>
+
+<li>\b LSS (real) - is an abbreviation for "length of sub-segment". It is
+a maximal allowed length of a mesh edge. Default is 0.5.</li>
+
+<li>\b frontal (integer)
+<ul>
+<li> 1 - the mesh generator inserts points with an advancing front method.</li>
+<li> 0 - it inserts them with an algebraic method (on internal edges). This method is
+slightly faster but generates less regular meshes. </li>
+</ul>
+Default is 0.</li>
+
+<li>\b hinterpol_flag (integer) - determines the computation of an
+interpolated value <i>v</i> between two points <i>P1</i> and <i>P2</i> on a
+curve. Let <i>h1</i> be the value at point <i>P1,</i> <i>h2</i> be the value at point
+<i>P2,</i> and <i>t</i> be a parameter varying from 0 to 1 when moving from <i>P1
+to</i> <i>P2</i> .
+<ul>
+<li>0 - the interpolation is linear: <i>v = h1 + t (h2 - h1 )</i></li>
+<li>1 - the interpolation is geometric: <i>v = h1 * pow( h2/h1, t)</i></li>
+<li>2 - the interpolation is sinusoidal: <i>v = (h1+h2)/2 +
+(h1-h2)/2*cos(PI*t)</i></li>
+</ul>
+Default is 0.</li>
+
+<li>\b hmean_flag (integer) - determines the computation of the mean of several
+values:<ul>
+<li>-1 - the minimum is computed.</li>
+<li>0 or 2 - the arithmetic mean computed.
+<li>1 - the geometric mean is computed.</li>
+</ul>
+Default is 0.</li>
+
+<li>\b CheckAdjacentEdges, \b CheckCloseEdges and \b CheckWellDefined
+(integers) - give number of calls of equally named subroutines the
+purpose of which is to improve the mesh of domains having narrow
+parts. At each iteration,\b CheckCloseEdges decreases the sizes of the
+edges when two boundary curves are neighboring,\b CheckAdjacentEdges
+balances the sizes of adjacent edges, and \b CheckWellDefined checks if
+the parametric domain is well defined. Default values are 0.</li>
+
+
+<li>\b CoefRectangle (real)- defines the relative thickness of the rectangles
+used by subroutine \b CheckCloseEdges (see above). Default is 0.25.</li>
+
+<li>\b eps_collapse (real) - if is more than 0.0, BLSURF removes
+curves whose lengths are less than \b eps_collapse. Here, to obtain an
+approximate value of the length of a curve, the latter is arbitrarily
+split into 20 edges. Default is 0.0.</li>
+
+<li>\b eps_ends (real) - is used to detect curves whose lengths are very
+small, which sometimes constitutes an error. A message is printed
+if<i> fabs(P2-P1) < eps_ends</i>, where <i>P1</i> and <i>P2</i> are the
+extremities of a curve. Default is <i>diag</i>/500.0.</li>
+
+<li>\b prefix (char) - is a prefix of the files generated by
+BLSURF. Default is "x".</li>
+
+<li>\b refs (integer) - reference of a surface, used when exporting
+files. Default is 1.</li>
+</ul>
+
+\n
+The following advanced options are not documented and you can use them
+at your own risk.
+\n\n Interger variables:
+<ul>
+<li> addsurf_ivertex</li>
+<li> background </li>
+<li> coiter </li>
+<li> communication </li>
+<li> decim </li>
+<li> export_flag </li>
+<li> file_h </li>
+<li> gridnu </li>
+<li> gridnv </li>
+<li> intermedfile </li>
+<li> memory </li>
+<li> normals </li>
+<li> optim </li>
+<li> pardom_flag </li>
+<li> pinch </li>
+<li> rigid </li>
+<li> surforient </li>
+<li> tconf </li>
+<li> topo_collapse </li>
+</ul>
+Real variables:
+<ul>
+<li> addsurf_angle </li>
+<li> addsurf_R </li>
+<li> addsurf_H </li>
+<li> addsurf_FG </li>
+<li> addsurf_r </li>
+<li> addsurf_PA </li>
+<li> angle_compcurv </li>
+<li> angle_ridge </li>
+<li> eps_pardom </li>
+</ul>
+String variables:
+<ul>
+<li> export_format </li>
+<li> export_option </li>
+<li> import_option </li>
+</ul>
+
+
+\n
+Currently BLSURF plugin has the following limitations.
+<ul>
+ <li>Mesh contains inverted elements, if it is based on shape,
+ consisting of more than one face (box, cone, torus...) and if
+ the option "Allow Quadrangles (Test)" was checked before
+ computation.</li>
+
+ <li>SIGFPE exception is raised at trying to compute mesh, based on
+ box, with checked option "Patch independent".</li>
+
+ <li>It has been found out that BLSURF algorithm can't be used as a
+ local algorithm (on sub-meshes) and as a provider of low-level
+ mesh for some 3D algorithms because BLSURF mesher (and
+ consequently plugin) does not provide information on node
+ parameters on edges (U) and faces (U,V). For example the
+ following combinations of algorithms are impossible:
+ <ul>
+ <li> global MEFISTO or Quadrangle(mapping) + local BLSURF;</li>
+ <li> BLSUFR + Projection 2D from faces meshed by BLSURF;</li>
+ <li> local BLSURF + Extrusion 3D;</li>
+ </ul>
+ </li>
+</ul>
+
+*/
--- /dev/null
+/*!
+
+\page ghs3d_hypo_page GHS3D Parameters hypothesis
+
+\n GHS3D Parameters hypothesis works only with <b>Tetrahedron (GHS3D)</b>
+algorithm. This algorithm is a commercial software.
+
+\image html ghs3d_parameters_basic.png
+
+<ul>
+<li><b>Name</b> - allows to define the name of the hypothesis (GHS3D
+Parameters by default).</li>
+
+<li><b>To mesh holes</b> - if this box is checked, the algorithm will
+create mesh also in holes inside a solid shape, else only the outermost
+shape will be meshed. Volumic elements created within holes are bound
+to the solid.</li>
+
+<li><b>Optimization level</b> - sets the desired optimization level.
+Optimization levels are: none, light, medium, strong, in increasing
+order of "quality vs speed" ratio.
+</li>
+
+\image html ghs3d_parameters_advanced.png
+
+<li><b>Maximum memory size</b> - launches ghs3d software with
+work space limited to specified Megabytes of memory. If this option is
+checked off, the software will be launched with 0.7 * total RAM space. </li>
+
+<li><b>Initial memory size</b> - starts ghs3d software with
+specified Megabytes of work space. If this option is checked off, the
+software will be started with 100 Megabytes of working space. </li>
+
+<li><b>Working directory</b> - defines folder for input and output
+files of ghs3d software, which are files starting with "GHS3D_" prefix. </li>
+
+<li><b>Keep working files</b> - allows to check input and output files
+of ghs3d software, while usually these files are removed after mesher launch.</li>
+
+<li><b>Verbose level</b> - to choose verbosity level in the range 0 to 10.
+<ul> <li>0, no standard output,
+</li><li>2, prints the data, quality statistics of the skin and final
+meshes and indicates when the final mesh is being saved. In addition
+the software gives indication regarding the CPU time.
+</li><li>10, same as 2 plus the main steps in the computation, quality
+statistics histogram of the skin mesh, quality statistics histogram
+together with the characteristics of the final mesh.
+</li></ul></li>
+
+<li><b>To create new nodes</b> - if this option is checked off, ghs3d
+tries to create tetrahedrons using only nodes of 2D mesh.</li>
+
+<li><b>To use boundary recovery version</b> - enables using a
+boundary recovery module which tries to
+create volume meshes starting from very poor quality surface meshes
+(almost flat triangles on the surface, high density propagation,
+extreme aspect ratios, etc.) which fails with the standard version. The
+resulting volume mesh will however most likely have a very poor
+quality (poor aspect ratio of elements, tetrahedra with a very small
+positive volume).</li>
+
+<li><b>Option as text</b> - allows entering any text that will be
+used as command line option of ghs3d. This is for giving
+advanced options in a free from. </li>
+
+</ul>
+
+*/
\ No newline at end of file
--- /dev/null
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+// File : SMESHGUI_FileInfoDlg.cxx
+// Author : Alexandre SOLOVYOV
+// Module : SMESH
+// $Header$
+
+#include <SMESHGUI_FileInfoDlg.h>
+
+#include <MED_Common.hxx>
+
+#include <qlayout.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+
+SMESHGUI_FileInfoDlg::SMESHGUI_FileInfoDlg( QWidget* parent, SALOME_MED::MedFileInfo* inf )
+ : QtxDialog( parent, 0, true, true, QtxDialog::OK )
+{
+ setCaption( tr( "CAPTION" ) );
+ setSizeGripEnabled( true );
+
+ QLineEdit* fname = new QLineEdit( mainFrame() );
+ fname->setReadOnly( true );
+ QLineEdit* fsize = new QLineEdit( mainFrame() );
+ fsize->setReadOnly( true );
+ QLineEdit* medversion = new QLineEdit( mainFrame() );
+ medversion->setReadOnly( true );
+ fname->setMinimumWidth( 300 );
+
+ QGridLayout* lay = new QGridLayout( mainFrame(), 4, 2, 5, 5 );
+ lay->addWidget( new QLabel( tr( "FILE_NAME" ), mainFrame() ), 0, 0 );
+ lay->addWidget( fname, 0, 1 );
+ lay->addWidget( new QLabel( tr( "FILE_SIZE" ), mainFrame() ), 1, 0 );
+ lay->addWidget( fsize, 1, 1 );
+ lay->addWidget( new QLabel( tr( "MED_VERSION" ), mainFrame() ), 2, 0 );
+ lay->addWidget( medversion, 2, 1 );
+
+ fname->setText( (char*)inf->fileName );
+ fname->home( false );
+ fsize->setText( QString::number( inf->fileSize ) );
+
+ QString version;
+ if( inf->major>=0 )
+ {
+ version = QString::number( inf->major );
+ if( inf->minor>=0 )
+ {
+ version += "." + QString::number( inf->minor );
+ if( inf->release>=0 )
+ version += "." + QString::number( inf->release );
+ }
+ }
+ medversion->setText( version );
+}
+
+SMESHGUI_FileInfoDlg::~SMESHGUI_FileInfoDlg()
+{
+}
--- /dev/null
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : SMESHGUI_FileInfoDlg.h
+// Author : Alexandre SOLOVYOV
+// Module : SMESH
+// $Header$
+
+#ifndef SMESHGUI_FILE_INFO_DIALOG
+#define SMESHGUI_FILE_INFO_DIALOG
+
+#include <MED.hh>
+#include <QtxDialog.h>
+
+class SMESHGUI_FileInfoDlg : public QtxDialog
+{
+ Q_OBJECT
+
+public:
+ SMESHGUI_FileInfoDlg( QWidget*, SALOME_MED::MedFileInfo* );
+ virtual ~SMESHGUI_FileInfoDlg();
+};
+
+#endif
--- /dev/null
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : SMESHGUI_WhatIsDlg.cxx
+// Author : Vladimir TURIN
+// Module : SMESH
+// $Header:
+
+#include "SMESHGUI_WhatIsDlg.h"
+
+#include "SMESHGUI.h"
+#include "SMESHGUI_SpinBox.h"
+#include "SMESHGUI_Utils.h"
+#include "SMESHGUI_VTKUtils.h"
+#include "SMESHGUI_MeshUtils.h"
+#include "SMESHGUI_IdValidator.h"
+
+#include "SMESH_Actor.h"
+#include "SMESH_TypeFilter.hxx"
+#include "SMESH_LogicalFilter.hxx"
+#include "SMDS_Mesh.hxx"
+#include "SMDS_VolumeTool.hxx"
+
+#include "SUIT_Desktop.h"
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+#include "SUIT_MessageBox.h"
+
+#include "LightApp_Application.h"
+
+#include "SVTK_ViewModel.h"
+#include "SVTK_Selection.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_Selector.h"
+#include "SALOME_ListIO.hxx"
+
+#include "utilities.h"
+
+// OCCT Includes
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_IndexedMapOfInteger.hxx>
+#include <gp_XYZ.hxx>
+
+// QT Includes
+#include <qapplication.h>
+#include <qbuttongroup.h>
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qspinbox.h>
+#include <qpixmap.h>
+#include <qtextbrowser.h>
+
+// IDL Headers
+#include "SALOMEconfig.h"
+#include CORBA_SERVER_HEADER(SMESH_Group)
+#include CORBA_SERVER_HEADER(SMESH_MeshEditor)
+
+using namespace std;
+
+//=================================================================================
+// class : SMESHGUI_WhatIsDlg()
+// purpose :
+//=================================================================================
+SMESHGUI_WhatIsDlg::SMESHGUI_WhatIsDlg( SMESHGUI* theModule, const char* name,
+ bool modal, WFlags fl)
+ : QDialog( SMESH::GetDesktop( theModule ), name, modal, WStyle_Customize | WStyle_NormalBorder |
+ WStyle_Title | WStyle_SysMenu | Qt::WDestructiveClose),
+ mySMESHGUI( theModule ),
+ mySelectionMgr( SMESH::GetSelectionMgr( theModule ) )
+{
+ if (!name)
+ setName("SMESHGUI_WhatIsDlg");
+ resize(300, 500);
+ setCaption(tr("SMESH_WHAT_IS_TITLE"));
+ setSizeGripEnabled(TRUE);
+ SMESHGUI_WhatIsDlgLayout = new QGridLayout(this);
+ SMESHGUI_WhatIsDlgLayout->setSpacing(6);
+ SMESHGUI_WhatIsDlgLayout->setMargin(11);
+
+ /***************************************************************/
+ GroupMesh = new QButtonGroup(this, "GroupSelections");
+ GroupMesh->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupMesh->sizePolicy().hasHeightForWidth()));
+ GroupMesh->setTitle(tr(""));
+ GroupMesh->setColumnLayout(0, Qt::Vertical);
+ GroupMesh->layout()->setSpacing(0);
+ GroupMesh->layout()->setMargin(0);
+ GroupMeshLayout = new QGridLayout(GroupMesh->layout());
+ GroupMeshLayout->setAlignment(Qt::AlignTop);
+ GroupMeshLayout->setSpacing(6);
+ GroupMeshLayout->setMargin(11);
+ MeshLabel = new QLabel(GroupMesh, "MeshLabel");
+ MeshLabel->setText(tr("SMESH_NAME"));
+ GroupMeshLayout->addWidget(MeshLabel, 0, 0);
+ MeshName = new QLabel(GroupMesh, "MeshName");
+ MeshName->setText(tr(""));
+ GroupMeshLayout->addWidget(MeshName, 0, 1);
+ SMESHGUI_WhatIsDlgLayout->addWidget(GroupMesh, 0, 0);
+
+ /***************************************************************/
+ GroupSelections = new QButtonGroup(this, "GroupSelections");
+ GroupSelections->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupSelections->sizePolicy().hasHeightForWidth()));
+ GroupSelections->setTitle(tr("ENTITY_TYPE" ));
+ GroupSelections->setExclusive(TRUE);
+ GroupSelections->setColumnLayout(0, Qt::Vertical);
+ GroupSelections->layout()->setSpacing(0);
+ GroupSelections->layout()->setMargin(0);
+ GroupSelectionsLayout = new QGridLayout(GroupSelections->layout());
+ GroupSelectionsLayout->setAlignment(Qt::AlignTop);
+ GroupSelectionsLayout->setSpacing(6);
+ GroupSelectionsLayout->setMargin(11);
+ RadioButtonNodes = new QRadioButton(GroupSelections, "RadioButtonNodes");
+ RadioButtonNodes->setText(tr("SMESH_NODES"));
+ GroupSelectionsLayout->addWidget(RadioButtonNodes, 0, 0);
+ RadioButtonElements = new QRadioButton(GroupSelections, "RadioButtonElements");
+ RadioButtonElements->setText(tr("SMESH_ELEMENTS"));
+ GroupSelectionsLayout->addWidget(RadioButtonElements, 0, 1 );
+ SMESHGUI_WhatIsDlgLayout->addWidget(GroupSelections, 1, 0);
+
+ /***************************************************************/
+ GroupArguments = new QGroupBox(this, "GroupArguments");
+ GroupArguments->setTitle(tr("SMESH_INFORMATION"));
+ GroupArguments->setColumnLayout(0, Qt::Vertical);
+ GroupArguments->layout()->setSpacing(0);
+ GroupArguments->layout()->setMargin(0);
+ GroupArgumentsLayout = new QGridLayout(GroupArguments->layout());
+ GroupArgumentsLayout->setAlignment(Qt::AlignTop);
+ GroupArgumentsLayout->setSpacing(6);
+ GroupArgumentsLayout->setMargin(11);
+
+ // Controls for elements selection
+ TextLabelElements = new QLabel(GroupArguments, "TextLabelElements");
+ TextLabelElements->setText(tr("SMESH_ID_ELEMENTS" ));
+ TextLabelElements->setFixedWidth(74);
+ GroupArgumentsLayout->addWidget(TextLabelElements, 0, 0);
+
+ LineEditElements = new QLineEdit(GroupArguments, "LineEditElements");
+ LineEditElements->setValidator(new SMESHGUI_IdValidator(this, "validator"));
+ GroupArgumentsLayout->addMultiCellWidget(LineEditElements, 0, 0, 2, 7);
+
+ // information text browser
+ Info = new QTextBrowser(GroupArguments, "Info");
+ Info->setHScrollBarMode(QScrollView::AlwaysOff);
+ Info->setVScrollBarMode(QScrollView::AlwaysOff);
+ GroupArgumentsLayout->addMultiCellWidget(Info, 1, 1, 0, 7);
+
+ SMESHGUI_WhatIsDlgLayout->addWidget(GroupArguments, 2, 0);
+
+ /***************************************************************/
+ GroupButtons = new QGroupBox(this, "GroupButtons");
+ GroupButtons->setSizePolicy(QSizePolicy((QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth()));
+ GroupButtons->setTitle(tr("" ));
+ GroupButtons->setColumnLayout(0, Qt::Vertical);
+ GroupButtons->layout()->setSpacing(0);
+ GroupButtons->layout()->setMargin(0);
+ GroupButtonsLayout = new QGridLayout(GroupButtons->layout());
+ GroupButtonsLayout->setAlignment(Qt::AlignTop);
+ GroupButtonsLayout->setSpacing(6);
+ GroupButtonsLayout->setMargin(11);
+ buttonHelp = new QPushButton(GroupButtons, "buttonHelp");
+ buttonHelp->setText(tr("SMESH_BUT_HELP" ));
+ buttonHelp->setAutoDefault(TRUE);
+ GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
+ QSpacerItem* spacer_9 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
+ GroupButtonsLayout->addItem(spacer_9, 0, 1);
+ buttonOk = new QPushButton(GroupButtons, "buttonOk");
+ buttonOk->setText(tr("SMESH_BUT_OK" ));
+ buttonOk->setAutoDefault(TRUE);
+ buttonOk->setDefault(TRUE);
+ GroupButtonsLayout->addWidget(buttonOk, 0, 0);
+ SMESHGUI_WhatIsDlgLayout->addWidget(GroupButtons, 3, 0);
+
+ GroupArguments->show();
+ RadioButtonNodes->setChecked(TRUE);
+
+ mySelector = (SMESH::GetViewWindow( mySMESHGUI ))->GetSelector();
+
+ mySMESHGUI->SetActiveDialogBox((QDialog*)this);
+
+ // Costruction of the logical filter
+ SMESH_TypeFilter* aMeshOrSubMeshFilter = new SMESH_TypeFilter (MESHorSUBMESH);
+ SMESH_TypeFilter* aSmeshGroupFilter = new SMESH_TypeFilter (GROUP);
+
+ QPtrList<SUIT_SelectionFilter> aListOfFilters;
+ if (aMeshOrSubMeshFilter) aListOfFilters.append(aMeshOrSubMeshFilter);
+ if (aSmeshGroupFilter) aListOfFilters.append(aSmeshGroupFilter);
+
+ myMeshOrSubMeshOrGroupFilter =
+ new SMESH_LogicalFilter(aListOfFilters, SMESH_LogicalFilter::LO_OR);
+
+ myHelpFileName = "/files/viewing_mesh_info.htm#element_infos";
+
+ Init();
+
+ /* signals and slots connections */
+ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
+ connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
+ connect(GroupSelections, SIGNAL(clicked(int)), SLOT(SelectionsClicked(int)));
+
+ connect(mySMESHGUI, SIGNAL (SignalDeactivateActiveDialog()), this, SLOT(DeactivateActiveDialog()));
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+ /* to close dialog if study change */
+ connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnCancel()));
+ connect(LineEditElements, SIGNAL(textChanged(const QString&)), SLOT(onTextChange(const QString&)));
+ this->show(); /* displays Dialog */
+
+ SelectionsClicked(0);
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : ~SMESHGUI_WhatIsDlg()
+// purpose : Destroys the object and frees any allocated resources
+//=================================================================================
+SMESHGUI_WhatIsDlg::~SMESHGUI_WhatIsDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+//=================================================================================
+// function : Init()
+// purpose :
+//=================================================================================
+void SMESHGUI_WhatIsDlg::Init (bool ResetControls)
+{
+ myBusy = false;
+
+ LineEditElements->clear();
+
+ myActor = 0;
+ myMesh = SMESH::SMESH_Mesh::_nil();
+
+ if (ResetControls) {
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode( CellSelection );
+ onTextChange(LineEditElements->text());
+
+ SelectionIntoArgument();
+ }
+}
+
+//=================================================================================
+// function : SelectionsClicked()
+// purpose : Radio button management
+//=================================================================================
+void SMESHGUI_WhatIsDlg::SelectionsClicked (int selectionId)
+{
+ disconnect(mySelectionMgr, 0, this, 0);
+
+ mySelectionMgr->clearFilters();
+
+ switch (selectionId) {
+ case 0:
+ {
+ SMESH::SetPointRepresentation(true);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode( NodeSelection );
+ break;
+ }
+ case 1:
+ {
+ SMESH::SetPointRepresentation(false);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode( CellSelection );
+ break;
+ }
+ }
+
+ connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : ClickOnOk()
+// purpose :
+//=================================================================================
+void SMESHGUI_WhatIsDlg::ClickOnOk()
+{
+ if (mySMESHGUI->isActiveStudyLocked())
+ return;
+
+ SMESH::UpdateView();
+ Init(false);
+ SelectionIntoArgument();
+ ClickOnCancel();
+}
+
+//=================================================================================
+// function : ClickOnCancel()
+// purpose :
+//=================================================================================
+void SMESHGUI_WhatIsDlg::ClickOnCancel()
+{
+ disconnect(mySelectionMgr, 0, this, 0);
+ mySelectionMgr->clearFilters();
+ SMESH::SetPointRepresentation(false);
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->SetSelectionMode( ActorSelection );
+ mySMESHGUI->ResetState();
+ reject();
+}
+
+//=================================================================================
+// function : ClickOnHelp()
+// purpose :
+//=================================================================================
+void SMESHGUI_WhatIsDlg::ClickOnHelp()
+{
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName);
+ else {
+ SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName),
+ QObject::tr("BUT_OK"));
+ }
+}
+
+//=======================================================================
+// function : onTextChange()
+// purpose :
+//=======================================================================
+void SMESHGUI_WhatIsDlg::onTextChange (const QString& theNewText)
+{
+ if (myBusy) return;
+ myBusy = true;
+
+ // hilight entered elements
+ SMDS_Mesh* aMesh = 0;
+ if (myActor)
+ aMesh = myActor->GetObject()->GetMesh();
+
+ if (aMesh) {
+ Handle(SALOME_InteractiveObject) anIO = myActor->getIO();
+
+ TColStd_MapOfInteger newIndices;
+
+ QStringList aListId = QStringList::split(" ", theNewText, false);
+
+ for (int i = 0; i < aListId.count(); i++) {
+ const SMDS_MeshElement * e = RadioButtonNodes->isChecked()?
+ aMesh->FindNode(aListId[ i ].toInt()):
+ aMesh->FindElement(aListId[ i ].toInt());
+ if (e)
+ newIndices.Add(e->GetID());
+ }
+
+ mySelector->AddOrRemoveIndex( anIO, newIndices, false );
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ aViewWindow->highlight( anIO, true, true );
+ }
+
+ SelectionIntoArgument();
+
+ myBusy = false;
+}
+
+//=================================================================================
+// function : SelectionIntoArgument()
+// purpose : Called when selection as changed or other case
+//=================================================================================
+void SMESHGUI_WhatIsDlg::SelectionIntoArgument()
+{
+ int curBusy = myBusy;
+
+ // clear
+ myActor = 0;
+ QString aString = "";
+
+ myBusy = true;
+ if(!curBusy)
+ LineEditElements->setText(aString);
+ MeshName->setText(aString);
+ GroupMesh->setTitle(tr(""));
+ Info->clear();
+ myBusy = curBusy;
+
+ if (!GroupButtons->isEnabled()) // inactive
+ return;
+
+ // get selected mesh
+ SALOME_ListIO aList;
+ mySelectionMgr->selectedObjects(aList,SVTK_Viewer::Type());
+
+ int nbSel = aList.Extent();
+
+ if (nbSel != 1)
+ return;
+
+ Handle(SALOME_InteractiveObject) IO = aList.First();
+ myMesh = SMESH::GetMeshByIO(IO);
+ if (myMesh->_is_nil())
+ return;
+
+ myActor = SMESH::FindActorByObject(myMesh);
+ if (!myActor)
+ myActor = SMESH::FindActorByEntry(IO->getEntry());
+ if (!myActor)
+ return;
+
+ QString aName;
+ SMESH::GetNameOfSelectedIObjects(mySelectionMgr, aName);
+ MeshName->setText(aName);
+ if(!SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IO)->_is_nil()) {
+ GroupMesh->setTitle(tr("SMESH_MESH"));
+ } else if(!SMESH::IObjectToInterface<SMESH::SMESH_subMesh>(IO)->_is_nil()) {
+ GroupMesh->setTitle(tr("SMESH_SUBMESH"));
+ } else if(!SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IO)->_is_nil()) {
+ GroupMesh->setTitle(tr("SMESH_GROUP"));
+ }
+
+ int aNbUnits = 0;
+
+ aNbUnits = SMESH::GetNameOfSelectedElements(mySelector, IO, aString);
+
+ if (aNbUnits < 1)
+ return;
+
+ const SMDS_MeshElement * e = RadioButtonNodes->isChecked()?
+ myActor->GetObject()->GetMesh()->FindNode(aString.toInt()):
+ myActor->GetObject()->GetMesh()->FindElement(aString.toInt());
+ if (e) {
+ QString anInfo;
+ anInfo=tr("ENTITY_TYPE") + ": ";
+ if(e->GetType() == SMDSAbs_Node) {
+ anInfo+=tr("MESH_NODE")+"\n";
+ const SMDS_MeshNode *en = (SMDS_MeshNode*) e;
+ } else if(e->GetType() == SMDSAbs_Edge) {
+ anInfo+=tr("SMESH_EDGE")+"\n";
+ anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
+ const SMDS_MeshEdge *ee = (SMDS_MeshEdge*) e;
+ anInfo+=(ee->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+"\n";
+ } else if(e->GetType() == SMDSAbs_Face) {
+ const SMDS_MeshFace *ef = (SMDS_MeshFace*) e;
+ anInfo+=tr("SMESH_FACE")+"\n";
+ anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
+ if(!ef->IsPoly())
+ anInfo+=(ef->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
+ switch(ef->NbNodes()) {
+ case 3:
+ case 6:
+ {
+ anInfo+=tr("SMESH_TRIANGLE");
+ break;
+ }
+ case 4:
+ case 8:
+ {
+ anInfo+=tr("SMESH_QUADRANGLE");
+ break;
+ }
+ default:
+ break;
+ }
+ anInfo+="\n";
+ } else if(e->GetType() == SMDSAbs_Volume) {
+ anInfo+=tr("SMESH_VOLUME")+"\n";
+ anInfo+=tr("SMESH_MESHINFO_TYPE")+": ";
+ const SMDS_MeshVolume *ev = (SMDS_MeshVolume*) e;
+ SMDS_VolumeTool vt(ev);
+ if(vt.GetVolumeType() != SMDS_VolumeTool::POLYHEDA)
+ anInfo+=(ev->IsQuadratic()?tr("SMESH_MESHINFO_ORDER2"):tr("SMESH_MESHINFO_ORDER1"))+" ";
+ switch(vt.GetVolumeType()) {
+ case SMDS_VolumeTool::TETRA:
+ case SMDS_VolumeTool::QUAD_TETRA:
+ {
+ anInfo+=tr("SMESH_TETRAS");
+ break;
+ }
+ case SMDS_VolumeTool::PYRAM:
+ case SMDS_VolumeTool::QUAD_PYRAM:
+ {
+ anInfo+=tr("SMESH_PYRAMID");
+ break;
+ }
+ case SMDS_VolumeTool::PENTA:
+ case SMDS_VolumeTool::QUAD_PENTA:
+ {
+ anInfo+=tr("SMESH_PRISM");
+ break;
+ }
+ case SMDS_VolumeTool::HEXA:
+ case SMDS_VolumeTool::QUAD_HEXA:
+ {
+ anInfo+=tr("SMESH_HEXAS");
+ break;
+ }
+ case SMDS_VolumeTool::POLYHEDA:
+ {
+ anInfo+=tr("SMESH_POLYEDRON");
+ break;
+ }
+ default:
+ break;
+ }
+ anInfo+="\n";
+ }
+ if(e->GetType() != SMDSAbs_Node)
+ anInfo+=tr("GRAVITY_CENTER") + ":\n";
+ gp_XYZ anXYZ(0.,0.,0.);
+ SMDS_ElemIteratorPtr nodeIt = e->nodesIterator();
+ int nbNodes = 0;
+ for(; nodeIt->more(); nbNodes++) {
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ anXYZ.Add( gp_XYZ( node->X(), node->Y(), node->Z() ) );
+ }
+ anXYZ.Divide(e->NbNodes()) ;
+ anInfo+=QString("X=%1\nY=%2\nZ=%3\n").arg(anXYZ.X()).arg(anXYZ.Y()).arg(anXYZ.Z());
+ Info->setText(anInfo);
+ }
+
+ if(!curBusy) {
+ myBusy = true;
+ LineEditElements->setText(aString);
+ myBusy = false;
+ }
+}
+
+//=================================================================================
+// function : DeactivateActiveDialog()
+// purpose :
+//=================================================================================
+void SMESHGUI_WhatIsDlg::DeactivateActiveDialog()
+{
+ if (GroupArguments->isEnabled()) {
+ GroupSelections->setEnabled(false);
+ GroupMesh->setEnabled(false);
+ GroupArguments->setEnabled(false);
+ GroupButtons->setEnabled(false);
+ mySMESHGUI->ResetState();
+ mySMESHGUI->SetActiveDialogBox(0);
+ }
+}
+
+//=================================================================================
+// function : ActivateThisDialog()
+// purpose :
+//=================================================================================
+void SMESHGUI_WhatIsDlg::ActivateThisDialog()
+{
+ /* Emit a signal to deactivate the active dialog */
+ mySMESHGUI->EmitSignalDeactivateDialog();
+ GroupArguments->setEnabled(true);
+ GroupButtons->setEnabled(true);
+ GroupSelections->setEnabled(true);
+ GroupMesh->setEnabled(true);
+
+ mySMESHGUI->SetActiveDialogBox((QDialog*)this);
+
+ if ( SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow( mySMESHGUI ))
+ SelectionsClicked(RadioButtonNodes->isChecked()?0:1);
+
+ SelectionIntoArgument();
+}
+
+//=================================================================================
+// function : enterEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_WhatIsDlg::enterEvent (QEvent*)
+{
+ if (!GroupArguments->isEnabled())
+ ActivateThisDialog();
+}
+
+//=================================================================================
+// function : closeEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_WhatIsDlg::closeEvent (QCloseEvent*)
+{
+ /* same than click on cancel button */
+ this->ClickOnCancel();
+}
+
+//=======================================================================
+//function : hideEvent
+//purpose : caused by ESC key
+//=======================================================================
+void SMESHGUI_WhatIsDlg::hideEvent (QHideEvent*)
+{
+ if (!isMinimized())
+ ClickOnCancel();
+}
+
+//=================================================================================
+// function : keyPressEvent()
+// purpose :
+//=================================================================================
+void SMESHGUI_WhatIsDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Key_F1 )
+ {
+ e->accept();
+ ClickOnHelp();
+ }
+}
--- /dev/null
+// SMESH SMESHGUI : GUI for SMESH component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : SMESHGUI_WhatIsDlg.h
+// Author : Vladimir TURIN
+// Module : SMESH
+// $Header:
+
+#ifndef SMESHGUI_WHATISDLG_H
+#define SMESHGUI_WHATISDLG_H
+
+#include "LightApp_SelectionMgr.h"
+
+#include "SMESH_LogicalFilter.hxx"
+
+// QT Includes
+#include <qdialog.h>
+
+class QGridLayout;
+class QButtonGroup;
+class QGroupBox;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+class QRadioButton;
+class QCheckBox;
+class QTextBrowser;
+class SMESHGUI;
+class SMESHGUI_SpinBox;
+class SMESH_Actor;
+class SVTK_ViewWindow;
+class SVTK_Selector;
+
+// IDL Headers
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_Mesh)
+
+
+//=================================================================================
+// class : SMESHGUI_WhatIsDlg
+// purpose :
+//=================================================================================
+class SMESHGUI_WhatIsDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+
+ SMESHGUI_WhatIsDlg( SMESHGUI*,
+ const char* name = 0,
+ bool modal = FALSE,
+ WFlags fl = 0);
+ ~SMESHGUI_WhatIsDlg();
+
+private:
+
+ void Init (bool ResetControls = true);
+ void closeEvent (QCloseEvent*);
+ void enterEvent (QEvent*); /* mouse enter the QWidget */
+ void hideEvent (QHideEvent*); /* ESC key */
+ void keyPressEvent(QKeyEvent*);
+
+ SMESHGUI* mySMESHGUI; /* Current SMESHGUI object */
+ LightApp_SelectionMgr* mySelectionMgr; /* User shape selection */
+
+ SVTK_Selector* mySelector;
+
+ bool myBusy;
+ SMESH::SMESH_Mesh_var myMesh;
+ SMESH_Actor* myActor;
+ SMESH_LogicalFilter* myMeshOrSubMeshOrGroupFilter;
+
+ QButtonGroup* GroupSelections;
+ QRadioButton* RadioButtonNodes;
+ QRadioButton* RadioButtonElements;
+ QGroupBox* GroupButtons;
+ QPushButton* buttonOk;
+ QPushButton* buttonHelp;
+ QGroupBox* GroupArguments;
+ QGroupBox* GroupMesh;
+ QLabel* TextLabelElements;
+ QLineEdit* LineEditElements;
+ QLabel* MeshLabel;
+ QLabel* MeshName;
+
+ QTextBrowser* Info;
+
+ QString myHelpFileName;
+
+private slots:
+
+ void SelectionsClicked(int selectionId);
+ void ClickOnOk();
+ void ClickOnCancel();
+ void ClickOnHelp();
+ void SelectionIntoArgument() ;
+ void DeactivateActiveDialog() ;
+ void ActivateThisDialog() ;
+ void onTextChange(const QString&);
+
+protected:
+
+ QGridLayout* SMESHGUI_WhatIsDlgLayout;
+ QGridLayout* GroupSelectionsLayout;
+ QGridLayout* GroupMeshLayout;
+ QGridLayout* GroupButtonsLayout;
+ QGridLayout* GroupArgumentsLayout;
+};
+
+#endif // SMESHGUI_WHATISDLG_H
--- /dev/null
+# CEA/LGLS 2007, Francis KLOSS (OCC)
+# ==================================
+
+import math
+
+import geompy
+import smesh
+
+geo = geompy
+
+# Parameters
+# ----------
+
+radius = 50
+height = 200
+
+# Build a cylinder
+# ----------------
+
+base = geo.MakeVertex(0, 0, 0)
+direction = geo.MakeVectorDXDYDZ(0, 0, 1)
+
+cylinder = geo.MakeCylinder(base, direction, radius, height)
+
+geo.addToStudy(cylinder, "cylinder")
+
+# Build blocks
+# ------------
+
+size = radius/2.0
+
+box_rot = geo.MakeBox(-size, -size, 0, +size, +size, height)
+box_axis = geo.MakeLine(base, direction)
+box = geo.MakeRotation(box_rot, box_axis, math.pi/4)
+
+hole = geo.MakeCut(cylinder, box)
+
+plane_trim = 2000
+
+plane_a = geo.MakePlane(base, geo.MakeVectorDXDYDZ(1, 0, 0), plane_trim)
+plane_b = geo.MakePlane(base, geo.MakeVectorDXDYDZ(0, 1, 0), plane_trim)
+
+blocks_part = geo.MakePartition([hole], [plane_a, plane_b], [], [], geo.ShapeType["SOLID"])
+blocks_list = [box] + geo.SubShapeAll(blocks_part, geo.ShapeType["SOLID"])
+blocks_all = geo.MakeCompound(blocks_list)
+blocks = geo.MakeGlueFaces(blocks_all, 0.0001)
+
+geo.addToStudy(blocks, "cylinder:blocks")
+
+# Build geometric groups
+# ----------------------
+
+def group(name, shape, type, base=None, direction=None):
+ t = geo.ShapeType[type]
+ g = geo.CreateGroup(shape, t)
+
+ geo.addToStudy(g, name)
+ g.SetName(name)
+
+ if base!=None:
+ l = geo.GetShapesOnPlaneWithLocationIDs(shape, t, direction, base, geo.GEOM.ST_ON)
+ geo.UnionIDs(g, l)
+
+ return g
+
+group_a = group("baseA", blocks, "FACE", base, direction)
+
+base_b = geo.MakeVertex(0, 0, height)
+group_b = group("baseB", blocks, "FACE", base_b, direction)
+
+group_1 = group("limit", blocks, "SOLID")
+group_1_all = geo.SubShapeAllIDs(blocks, geo.ShapeType["SOLID"])
+geo.UnionIDs(group_1, group_1_all)
+group_1_box = geo.GetBlockNearPoint(blocks, base)
+geo.DifferenceList(group_1, [group_1_box])
+
+# Mesh the blocks with hexahedral
+# -------------------------------
+
+def discretize(x, y, z, n, s=blocks):
+ p = geo.MakeVertex(x, y, z)
+ e = geo.GetEdgeNearPoint(s, p)
+ a = hexa.Segment(e)
+ a.NumberOfSegments(n)
+ a.Propagation()
+
+hexa = smesh.Mesh(blocks)
+
+hexa_1d = hexa.Segment()
+hexa_1d.NumberOfSegments(1)
+
+discretize(+radius , +radius, 0, 5)
+discretize(-radius , +radius, 0, 8)
+discretize((radius+size)/2, 0, 0, 10)
+discretize( +radius, 0, height/2, 20)
+
+hexa.Quadrangle()
+hexa.Hexahedron()
+
+hexa.Compute()
+
+hexa.Group(group_a)
+hexa.Group(group_b)
+hexa.Group(group_1)
--- /dev/null
+// SMESH SMESH : implementaion of SMESH idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : StdMeshers_QuadToTriaAdaptor.cxx
+// Module : SMESH
+// Created : Wen May 07 16:37:07 2008
+// Author : Sergey KUUL (skl)
+
+
+#include "StdMeshers_QuadToTriaAdaptor.hxx"
+
+//#include <TColgp_HArray1OfPnt.hxx>
+//#include <TColgp_HArray1OfVec.hxx>
+#include <TopExp_Explorer.hxx>
+#include <TopoDS.hxx>
+#include <SMESH_Algo.hxx>
+#include <TColgp_HSequenceOfPnt.hxx>
+#include <TColStd_MapOfInteger.hxx>
+#include <TColStd_HSequenceOfInteger.hxx>
+#include <IntAna_Quadric.hxx>
+#include <IntAna_IntConicQuad.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Pln.hxx>
+#include <SMDS_FaceOfNodes.hxx>
+
+#include <NCollection_Array1.hxx>
+typedef NCollection_Array1<TColStd_SequenceOfInteger> StdMeshers_Array1OfSequenceOfInteger;
+
+
+//=======================================================================
+//function : StdMeshers_QuadToTriaAdaptor
+//purpose :
+//=======================================================================
+
+StdMeshers_QuadToTriaAdaptor::StdMeshers_QuadToTriaAdaptor()
+{
+}
+
+
+//================================================================================
+/*!
+ * \brief Destructor
+ */
+//================================================================================
+
+StdMeshers_QuadToTriaAdaptor::~StdMeshers_QuadToTriaAdaptor()
+{}
+
+
+//=======================================================================
+//function : FindBestPoint
+//purpose : Auxilare for Compute()
+// V - normal to (P1,P2,PC)
+//=======================================================================
+static gp_Pnt FindBestPoint(const gp_Pnt& P1, const gp_Pnt& P2,
+ const gp_Pnt& PC, const gp_Vec& V)
+{
+ double a = P1.Distance(P2);
+ double b = P1.Distance(PC);
+ double c = P2.Distance(PC);
+ if( a < (b+c)/2 )
+ return PC;
+ else {
+ // find shift along V in order to a became equal to (b+c)/2
+ double shift = sqrt( a*a + (b*b-c*c)*(b*b-c*c)/16/a/a - (b*b+c*c)/2 );
+ gp_Dir aDir(V);
+ gp_Pnt Pbest( PC.X() + aDir.X()*shift, PC.Y() + aDir.Y()*shift,
+ PC.Z() + aDir.Z()*shift );
+ return Pbest;
+ }
+}
+
+
+//=======================================================================
+//function : HasIntersection3
+//purpose : Auxilare for HasIntersection()
+// find intersection point between triangle (P1,P2,P3)
+// and segment [PC,P]
+//=======================================================================
+static bool HasIntersection3(const gp_Pnt& P, const gp_Pnt& PC, gp_Pnt& Pint,
+ const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3)
+{
+ //cout<<"HasIntersection3"<<endl;
+ //cout<<" PC("<<PC.X()<<","<<PC.Y()<<","<<PC.Z()<<")"<<endl;
+ //cout<<" P("<<P.X()<<","<<P.Y()<<","<<P.Z()<<")"<<endl;
+ //cout<<" P1("<<P1.X()<<","<<P1.Y()<<","<<P1.Z()<<")"<<endl;
+ //cout<<" P2("<<P2.X()<<","<<P2.Y()<<","<<P2.Z()<<")"<<endl;
+ //cout<<" P3("<<P3.X()<<","<<P3.Y()<<","<<P3.Z()<<")"<<endl;
+ gp_Vec VP1(P1,P2);
+ gp_Vec VP2(P1,P3);
+ IntAna_Quadric IAQ(gp_Pln(P1,VP1.Crossed(VP2)));
+ IntAna_IntConicQuad IAICQ(gp_Lin(PC,gp_Dir(gp_Vec(PC,P))),IAQ);
+ if(IAICQ.IsDone()) {
+ if( IAICQ.IsInQuadric() )
+ return false;
+ if( IAICQ.NbPoints() == 1 ) {
+ gp_Pnt PIn = IAICQ.Point(1);
+ double preci = 1.e-6;
+ // check if this point is internal for segment [PC,P]
+ bool IsExternal =
+ ( (PC.X()-PIn.X())*(P.X()-PIn.X()) > preci ) ||
+ ( (PC.Y()-PIn.Y())*(P.Y()-PIn.Y()) > preci ) ||
+ ( (PC.Z()-PIn.Z())*(P.Z()-PIn.Z()) > preci );
+ if(IsExternal) {
+ return false;
+ }
+ // check if this point is internal for triangle (P1,P2,P3)
+ gp_Vec V1(PIn,P1);
+ gp_Vec V2(PIn,P2);
+ gp_Vec V3(PIn,P3);
+ if( V1.Magnitude()<preci || V2.Magnitude()<preci ||
+ V3.Magnitude()<preci ) {
+ Pint = PIn;
+ return true;
+ }
+ gp_Vec VC1 = V1.Crossed(V2);
+ gp_Vec VC2 = V2.Crossed(V3);
+ gp_Vec VC3 = V3.Crossed(V1);
+ if(VC1.Magnitude()<preci) {
+ if(VC2.IsOpposite(VC3,preci)) {
+ return false;
+ }
+ }
+ else if(VC2.Magnitude()<preci) {
+ if(VC1.IsOpposite(VC3,preci)) {
+ return false;
+ }
+ }
+ else if(VC3.Magnitude()<preci) {
+ if(VC1.IsOpposite(VC2,preci)) {
+ return false;
+ }
+ }
+ else {
+ if( VC1.IsOpposite(VC2,preci) || VC1.IsOpposite(VC3,preci) ||
+ VC2.IsOpposite(VC3,preci) ) {
+ return false;
+ }
+ }
+ Pint = PIn;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+//=======================================================================
+//function : HasIntersection
+//purpose : Auxilare for CheckIntersection()
+//=======================================================================
+static bool HasIntersection(const gp_Pnt& P, const gp_Pnt& PC, gp_Pnt& Pint,
+ Handle(TColgp_HSequenceOfPnt)& aContour)
+{
+ if(aContour->Length()==3) {
+ return HasIntersection3( P, PC, Pint, aContour->Value(1),
+ aContour->Value(2), aContour->Value(3) );
+ }
+ else {
+ bool check = false;
+ if( (aContour->Value(1).Distance(aContour->Value(2)) > 1.e-6) &&
+ (aContour->Value(1).Distance(aContour->Value(3)) > 1.e-6) &&
+ (aContour->Value(2).Distance(aContour->Value(3)) > 1.e-6) ) {
+ check = HasIntersection3( P, PC, Pint, aContour->Value(1),
+ aContour->Value(2), aContour->Value(3) );
+ }
+ if(check) return true;
+ if( (aContour->Value(1).Distance(aContour->Value(4)) > 1.e-6) &&
+ (aContour->Value(1).Distance(aContour->Value(3)) > 1.e-6) &&
+ (aContour->Value(4).Distance(aContour->Value(3)) > 1.e-6) ) {
+ check = HasIntersection3( P, PC, Pint, aContour->Value(1),
+ aContour->Value(3), aContour->Value(4) );
+ }
+ if(check) return true;
+ }
+
+ return false;
+}
+
+
+//=======================================================================
+//function : CheckIntersection
+//purpose : Auxilare for Compute()
+// NotCheckedFace - for optimization
+//=======================================================================
+bool StdMeshers_QuadToTriaAdaptor::CheckIntersection
+ (const gp_Pnt& P, const gp_Pnt& PC,
+ gp_Pnt& Pint, SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ const TopoDS_Shape& NotCheckedFace)
+{
+ SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+ //cout<<" CheckIntersection: meshDS->NbFaces() = "<<meshDS->NbFaces()<<endl;
+ bool res = false;
+ double dist = RealLast();
+ gp_Pnt Pres;
+ for (TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next()) {
+ const TopoDS_Shape& aShapeFace = exp.Current();
+ if(aShapeFace==NotCheckedFace)
+ continue;
+ const SMESHDS_SubMesh * aSubMeshDSFace = meshDS->MeshElements(aShapeFace);
+ if ( aSubMeshDSFace ) {
+ SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
+ while ( iteratorElem->more() ) { // loop on elements on a face
+ const SMDS_MeshElement* face = iteratorElem->next();
+ Handle(TColgp_HSequenceOfPnt) aContour = new TColgp_HSequenceOfPnt;
+ SMDS_ElemIteratorPtr nodeIt = face->nodesIterator();
+ if( !face->IsQuadratic() ) {
+ while ( nodeIt->more() ) {
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ aContour->Append(gp_Pnt(node->X(), node->Y(), node->Z()));
+ }
+ }
+ else {
+ int nn = 0;
+ while ( nodeIt->more() ) {
+ nn++;
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ aContour->Append(gp_Pnt(node->X(), node->Y(), node->Z()));
+ if(nn==face->NbNodes()/2) break;
+ }
+ }
+ if( HasIntersection(P, PC, Pres, aContour) ) {
+ res = true;
+ double tmp = PC.Distance(Pres);
+ if(tmp<dist) {
+ Pint = Pres;
+ dist = tmp;
+ }
+ }
+ }
+ }
+ }
+ return res;
+}
+
+
+//=======================================================================
+//function : CompareTrias
+//purpose : Auxilare for Compute()
+//=======================================================================
+static bool CompareTrias(const SMDS_MeshElement* F1,const SMDS_MeshElement* F2)
+{
+ SMDS_ElemIteratorPtr nIt = F1->nodesIterator();
+ const SMDS_MeshNode* Ns1[3];
+ int k = 0;
+ while( nIt->more() ) {
+ Ns1[k] = static_cast<const SMDS_MeshNode*>( nIt->next() );
+ k++;
+ }
+ nIt = F2->nodesIterator();
+ const SMDS_MeshNode* Ns2[3];
+ k = 0;
+ while( nIt->more() ) {
+ Ns2[k] = static_cast<const SMDS_MeshNode*>( nIt->next() );
+ k++;
+ }
+ if( ( Ns1[1]==Ns2[1] && Ns1[2]==Ns2[2] ) ||
+ ( Ns1[1]==Ns2[2] && Ns1[2]==Ns2[1] ) )
+ return true;
+ return false;
+}
+
+
+//=======================================================================
+//function : IsDegenarate
+//purpose : Auxilare for Preparation()
+//=======================================================================
+static int IsDegenarate(const Handle(TColgp_HArray1OfPnt)& PN)
+{
+ int i = 1;
+ for(; i<4; i++) {
+ int j = i+1;
+ for(; j<=4; j++) {
+ if( PN->Value(i).Distance(PN->Value(j)) < 1.e-6 )
+ return j;
+ }
+ }
+ return 0;
+}
+
+
+//=======================================================================
+//function : Preparation
+//purpose : Auxilare for Compute()
+// : Return 0 if given face is not quad,
+// 1 if given face is quad,
+// 2 if given face is degenerate quad (two nodes are coincided)
+//=======================================================================
+int StdMeshers_QuadToTriaAdaptor::Preparation(const SMDS_MeshElement* face,
+ Handle(TColgp_HArray1OfPnt) PN,
+ Handle(TColgp_HArray1OfVec) VN,
+ std::vector<const SMDS_MeshNode*>& FNodes,
+ gp_Pnt& PC, gp_Vec& VNorm)
+{
+ int i = 0;
+ double xc=0., yc=0., zc=0.;
+ SMDS_ElemIteratorPtr nodeIt = face->nodesIterator();
+ if( !face->IsQuadratic() ) {
+ if( face->NbNodes() != 4 )
+ return 0;
+ while ( nodeIt->more() ) {
+ i++;
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ FNodes[i-1] = node;
+ PN->SetValue( i, gp_Pnt(node->X(), node->Y(), node->Z()) );
+ xc += node->X();
+ yc += node->Y();
+ zc += node->Z();
+ }
+ }
+ else {
+ if( face->NbNodes() != 8)
+ return 0;
+ while ( nodeIt->more() ) {
+ i++;
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ FNodes[i-1] = node;
+ PN->SetValue( i, gp_Pnt(node->X(), node->Y(), node->Z()) );
+ xc += node->X();
+ yc += node->Y();
+ zc += node->Z();
+ if(i==4) break;
+ }
+ }
+
+ int nbp = 4;
+
+ int j = 0;
+ for(i=1; i<4; i++) {
+ j = i+1;
+ for(; j<=4; j++) {
+ if( PN->Value(i).Distance(PN->Value(j)) < 1.e-6 )
+ break;
+ }
+ if(j<=4) break;
+ }
+ //int deg_num = IsDegenarate(PN);
+ //if(deg_num>0) {
+ bool hasdeg = false;
+ if(i<4) {
+ //cout<<"find degeneration"<<endl;
+ hasdeg = true;
+ gp_Pnt Pdeg = PN->Value(i);
+
+ std::list< const SMDS_MeshNode* >::iterator itdg = myDegNodes.begin();
+ const SMDS_MeshNode* DegNode = 0;
+ for(; itdg!=myDegNodes.end(); itdg++) {
+ const SMDS_MeshNode* N = (*itdg);
+ gp_Pnt Ptmp(N->X(),N->Y(),N->Z());
+ if(Pdeg.Distance(Ptmp)<1.e-6) {
+ DegNode = N;
+ //DegNode = const_cast<SMDS_MeshNode*>(N);
+ break;
+ }
+ }
+ if(!DegNode) {
+ DegNode = FNodes[i-1];
+ myDegNodes.push_back(DegNode);
+ }
+ else {
+ FNodes[i-1] = DegNode;
+ }
+ for(i=j; i<4; i++) {
+ PN->SetValue(i,PN->Value(i+1));
+ FNodes[i-1] = FNodes[i];
+ }
+ nbp = 3;
+ //PC = gp_Pnt( PN->Value(1).X() + PN.Value
+ }
+
+ PC = gp_Pnt(xc/4., yc/4., zc/4.);
+ //cout<<" PC("<<PC.X()<<","<<PC.Y()<<","<<PC.Z()<<")"<<endl;
+
+ //PN->SetValue(5,PN->Value(1));
+ PN->SetValue(nbp+1,PN->Value(1));
+ //FNodes[4] = FNodes[0];
+ FNodes[nbp] = FNodes[0];
+ // find normal direction
+ //gp_Vec V1(PC,PN->Value(4));
+ gp_Vec V1(PC,PN->Value(nbp));
+ gp_Vec V2(PC,PN->Value(1));
+ VNorm = V1.Crossed(V2);
+ //VN->SetValue(4,VNorm);
+ VN->SetValue(nbp,VNorm);
+ //for(i=1; i<4; i++) {
+ for(i=1; i<nbp; i++) {
+ V1 = gp_Vec(PC,PN->Value(i));
+ V2 = gp_Vec(PC,PN->Value(i+1));
+ gp_Vec Vtmp = V1.Crossed(V2);
+ VN->SetValue(i,Vtmp);
+ VNorm += Vtmp;
+ }
+ //cout<<" VNorm("<<VNorm.X()<<","<<VNorm.Y()<<","<<VNorm.Z()<<")"<<endl;
+ if(hasdeg) return 2;
+ return 1;
+}
+
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+bool StdMeshers_QuadToTriaAdaptor::Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape)
+{
+ myResMap.clear();
+ myMapFPyram.clear();
+
+ SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+
+ for (TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next()) {
+ const TopoDS_Shape& aShapeFace = exp.Current();
+ const SMESHDS_SubMesh * aSubMeshDSFace = meshDS->MeshElements( aShapeFace );
+ if ( aSubMeshDSFace ) {
+ bool isRev = SMESH_Algo::IsReversedSubMesh( TopoDS::Face(aShapeFace), meshDS );
+
+ SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
+ while ( iteratorElem->more() ) { // loop on elements on a face
+ const SMDS_MeshElement* face = iteratorElem->next();
+ //cout<<endl<<"================= face->GetID() = "<<face->GetID()<<endl;
+ // preparation step using face info
+ Handle(TColgp_HArray1OfPnt) PN = new TColgp_HArray1OfPnt(1,5);
+ Handle(TColgp_HArray1OfVec) VN = new TColgp_HArray1OfVec(1,4);
+ std::vector<const SMDS_MeshNode*> FNodes(5);
+ gp_Pnt PC;
+ gp_Vec VNorm;
+ int stat = Preparation(face, PN, VN, FNodes, PC, VNorm);
+ if(stat==0)
+ continue;
+
+ if(stat==2) {
+ // degenerate face
+ // add triangles to result map
+ std::list<const SMDS_FaceOfNodes*> aList;
+ SMDS_FaceOfNodes* NewFace;
+ if(!isRev)
+ NewFace = new SMDS_FaceOfNodes( FNodes[0], FNodes[1], FNodes[2] );
+ else
+ NewFace = new SMDS_FaceOfNodes( FNodes[0], FNodes[2], FNodes[1] );
+ aList.push_back(NewFace);
+ myResMap.insert(make_pair(face,aList));
+ continue;
+ }
+
+ if(!isRev) VNorm.Reverse();
+ double xc = 0., yc = 0., zc = 0.;
+ int i = 1;
+ for(; i<=4; i++) {
+ gp_Pnt Pbest;
+ if(!isRev)
+ Pbest = FindBestPoint(PN->Value(i), PN->Value(i+1), PC, VN->Value(i).Reversed());
+ else
+ Pbest = FindBestPoint(PN->Value(i), PN->Value(i+1), PC, VN->Value(i));
+ xc += Pbest.X();
+ yc += Pbest.Y();
+ zc += Pbest.Z();
+ }
+ gp_Pnt PCbest(xc/4., yc/4., zc/4.);
+
+ // check PCbest
+ double height = PCbest.Distance(PC);
+ if(height<1.e-6) {
+ // create new PCbest using a bit shift along VNorm
+ PCbest = gp_Pnt( PC.X() + VNorm.X()*0.001,
+ PC.Y() + VNorm.Y()*0.001,
+ PC.Z() + VNorm.Z()*0.001);
+ }
+ else {
+ // check possible intersection with other faces
+ gp_Pnt Pint;
+ bool check = CheckIntersection(PCbest, PC, Pint, aMesh, aShape, aShapeFace);
+ if(check) {
+ //cout<<"--PC("<<PC.X()<<","<<PC.Y()<<","<<PC.Z()<<")"<<endl;
+ //cout<<" PCbest("<<PCbest.X()<<","<<PCbest.Y()<<","<<PCbest.Z()<<")"<<endl;
+ double dist = PC.Distance(Pint)/3.;
+ gp_Dir aDir(gp_Vec(PC,PCbest));
+ PCbest = gp_Pnt( PC.X() + aDir.X()*dist,
+ PC.Y() + aDir.Y()*dist,
+ PC.Z() + aDir.Z()*dist );
+ }
+ else {
+ gp_Vec VB(PC,PCbest);
+ gp_Pnt PCbestTmp(PC.X()+VB.X()*3, PC.X()+VB.X()*3, PC.X()+VB.X()*3);
+ bool check = CheckIntersection(PCbestTmp, PC, Pint, aMesh, aShape, aShapeFace);
+ if(check) {
+ double dist = PC.Distance(Pint)/3.;
+ if(dist<height) {
+ gp_Dir aDir(gp_Vec(PC,PCbest));
+ PCbest = gp_Pnt( PC.X() + aDir.X()*dist,
+ PC.Y() + aDir.Y()*dist,
+ PC.Z() + aDir.Z()*dist );
+ }
+ }
+ }
+ }
+ // create node for PCbest
+ SMDS_MeshNode* NewNode = meshDS->AddNode( PCbest.X(), PCbest.Y(), PCbest.Z() );
+ // add triangles to result map
+ std::list<const SMDS_FaceOfNodes*> aList;
+ for(i=0; i<4; i++) {
+ SMDS_FaceOfNodes* NewFace = new SMDS_FaceOfNodes( NewNode, FNodes[i], FNodes[i+1] );
+ aList.push_back(NewFace);
+ }
+ myResMap.insert(make_pair(face,aList));
+ // create pyramid
+ SMDS_MeshVolume* aPyram =
+ meshDS->AddVolume( FNodes[0], FNodes[1], FNodes[2], FNodes[3], NewNode );
+ myMapFPyram.insert(make_pair(face,aPyram));
+ } // end loop on elements on a face
+ }
+ } // end for(TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next()) {
+
+ return Compute2ndPart(aMesh);
+}
+
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+bool StdMeshers_QuadToTriaAdaptor::Compute(SMESH_Mesh& aMesh)
+{
+ myResMap.clear();
+ myMapFPyram.clear();
+
+ SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+
+ SMDS_FaceIteratorPtr itFace = meshDS->facesIterator();
+
+ while(itFace->more()) {
+ const SMDS_MeshElement* face = itFace->next();
+ if ( !face ) continue;
+ //cout<<endl<<"================= face->GetID() = "<<face->GetID()<<endl;
+ // preparation step using face info
+ Handle(TColgp_HArray1OfPnt) PN = new TColgp_HArray1OfPnt(1,5);
+ Handle(TColgp_HArray1OfVec) VN = new TColgp_HArray1OfVec(1,4);
+ std::vector<const SMDS_MeshNode*> FNodes(5);
+ gp_Pnt PC;
+ gp_Vec VNorm;
+
+ int stat = Preparation(face, PN, VN, FNodes, PC, VNorm);
+ if(stat==0)
+ continue;
+
+ if(stat==2) {
+ // degenerate face
+ // add triangles to result map
+ std::list<const SMDS_FaceOfNodes*> aList;
+ SMDS_FaceOfNodes* NewFace;
+ // check orientation
+
+ double tmp = PN->Value(1).Distance(PN->Value(2)) +
+ PN->Value(2).Distance(PN->Value(3));
+ gp_Dir tmpDir(VNorm);
+ gp_Pnt Ptmp1( PC.X() + tmpDir.X()*tmp*1.e6,
+ PC.Y() + tmpDir.Y()*tmp*1.e6,
+ PC.Z() + tmpDir.Z()*tmp*1.e6 );
+ gp_Pnt Ptmp2( PC.X() + tmpDir.Reversed().X()*tmp*1.e6,
+ PC.Y() + tmpDir.Reversed().Y()*tmp*1.e6,
+ PC.Z() + tmpDir.Reversed().Z()*tmp*1.e6 );
+ // check intersection for Ptmp1 and Ptmp2
+ bool IsRev = false;
+ bool IsOK1 = false;
+ bool IsOK2 = false;
+ double dist1 = RealLast();
+ double dist2 = RealLast();
+ gp_Pnt Pres1,Pres2;
+ SMDS_FaceIteratorPtr itf = meshDS->facesIterator();
+ while(itf->more()) {
+ const SMDS_MeshElement* F = itf->next();
+ if(F==face) continue;
+ Handle(TColgp_HSequenceOfPnt) aContour = new TColgp_HSequenceOfPnt;
+ SMDS_ElemIteratorPtr nodeIt = F->nodesIterator();
+ if( !F->IsQuadratic() ) {
+ while ( nodeIt->more() ) {
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ aContour->Append(gp_Pnt(node->X(), node->Y(), node->Z()));
+ }
+ }
+ else {
+ int nn = 0;
+ while ( nodeIt->more() ) {
+ nn++;
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ aContour->Append(gp_Pnt(node->X(), node->Y(), node->Z()));
+ if(nn==face->NbNodes()/2) break;
+ }
+ }
+ gp_Pnt PPP;
+ if( HasIntersection(Ptmp1, PC, PPP, aContour) ) {
+ IsOK1 = true;
+ double tmp = PC.Distance(PPP);
+ if(tmp<dist1) {
+ Pres1 = PPP;
+ dist1 = tmp;
+ }
+ }
+ if( HasIntersection(Ptmp2, PC, PPP, aContour) ) {
+ IsOK2 = true;
+ double tmp = PC.Distance(PPP);
+ if(tmp<dist2) {
+ Pres2 = PPP;
+ dist2 = tmp;
+ }
+ }
+ }
+
+ if( IsOK1 && !IsOK2 ) {
+ // using existed direction
+ }
+ else if( !IsOK1 && IsOK2 ) {
+ // using opposite direction
+ IsRev = true;
+ }
+ else { // IsOK1 && IsOK2
+ double tmp1 = PC.Distance(Pres1)/3.;
+ double tmp2 = PC.Distance(Pres2)/3.;
+ if(tmp1<tmp2) {
+ // using existed direction
+ }
+ else {
+ // using opposite direction
+ IsRev = true;
+ }
+ }
+ if(!IsRev)
+ NewFace = new SMDS_FaceOfNodes( FNodes[0], FNodes[1], FNodes[2] );
+ else
+ NewFace = new SMDS_FaceOfNodes( FNodes[0], FNodes[2], FNodes[1] );
+ aList.push_back(NewFace);
+ myResMap.insert(make_pair(face,aList));
+ continue;
+ }
+
+ double xc = 0., yc = 0., zc = 0.;
+ int i = 1;
+ for(; i<=4; i++) {
+ gp_Pnt Pbest = FindBestPoint(PN->Value(i), PN->Value(i+1), PC, VN->Value(i));
+ xc += Pbest.X();
+ yc += Pbest.Y();
+ zc += Pbest.Z();
+ }
+ gp_Pnt PCbest(xc/4., yc/4., zc/4.);
+ double height = PCbest.Distance(PC);
+ if(height<1.e-6) {
+ // create new PCbest using a bit shift along VNorm
+ PCbest = gp_Pnt( PC.X() + VNorm.X()*0.001,
+ PC.Y() + VNorm.Y()*0.001,
+ PC.Z() + VNorm.Z()*0.001);
+ height = PCbest.Distance(PC);
+ }
+ //cout<<" PCbest("<<PCbest.X()<<","<<PCbest.Y()<<","<<PCbest.Z()<<")"<<endl;
+
+ gp_Vec V1(PC,PCbest);
+ double tmp = PN->Value(1).Distance(PN->Value(3)) +
+ PN->Value(2).Distance(PN->Value(4));
+ gp_Dir tmpDir(V1);
+ gp_Pnt Ptmp1( PC.X() + tmpDir.X()*tmp*1.e6,
+ PC.Y() + tmpDir.Y()*tmp*1.e6,
+ PC.Z() + tmpDir.Z()*tmp*1.e6 );
+ gp_Pnt Ptmp2( PC.X() + tmpDir.Reversed().X()*tmp*1.e6,
+ PC.Y() + tmpDir.Reversed().Y()*tmp*1.e6,
+ PC.Z() + tmpDir.Reversed().Z()*tmp*1.e6 );
+ // check intersection for Ptmp1 and Ptmp2
+ bool IsRev = false;
+ bool IsOK1 = false;
+ bool IsOK2 = false;
+ double dist1 = RealLast();
+ double dist2 = RealLast();
+ gp_Pnt Pres1,Pres2;
+ SMDS_FaceIteratorPtr itf = meshDS->facesIterator();
+ while(itf->more()) {
+ const SMDS_MeshElement* F = itf->next();
+ if(F==face) continue;
+ Handle(TColgp_HSequenceOfPnt) aContour = new TColgp_HSequenceOfPnt;
+ SMDS_ElemIteratorPtr nodeIt = F->nodesIterator();
+ if( !F->IsQuadratic() ) {
+ while ( nodeIt->more() ) {
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ aContour->Append(gp_Pnt(node->X(), node->Y(), node->Z()));
+ }
+ }
+ else {
+ int nn = 0;
+ while ( nodeIt->more() ) {
+ nn++;
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ aContour->Append(gp_Pnt(node->X(), node->Y(), node->Z()));
+ if(nn==face->NbNodes()/2) break;
+ }
+ }
+ gp_Pnt PPP;
+ if( HasIntersection(Ptmp1, PC, PPP, aContour) ) {
+ IsOK1 = true;
+ double tmp = PC.Distance(PPP);
+ if(tmp<dist1) {
+ Pres1 = PPP;
+ dist1 = tmp;
+ }
+ }
+ if( HasIntersection(Ptmp2, PC, PPP, aContour) ) {
+ IsOK2 = true;
+ double tmp = PC.Distance(PPP);
+ if(tmp<dist2) {
+ Pres2 = PPP;
+ dist2 = tmp;
+ }
+ }
+ }
+
+ if( IsOK1 && !IsOK2 ) {
+ // using existed direction
+ double tmp = PC.Distance(Pres1)/3.;
+ if( height > tmp ) {
+ height = tmp;
+ PCbest = gp_Pnt( PC.X() + tmpDir.X()*height,
+ PC.Y() + tmpDir.Y()*height,
+ PC.Z() + tmpDir.Z()*height );
+ }
+ }
+ else if( !IsOK1 && IsOK2 ) {
+ // using opposite direction
+ IsRev = true;
+ double tmp = PC.Distance(Pres2)/3.;
+ if( height > tmp ) height = tmp;
+ PCbest = gp_Pnt( PC.X() + tmpDir.Reversed().X()*height,
+ PC.Y() + tmpDir.Reversed().Y()*height,
+ PC.Z() + tmpDir.Reversed().Z()*height );
+ }
+ else { // IsOK1 && IsOK2
+ double tmp1 = PC.Distance(Pres1)/3.;
+ double tmp2 = PC.Distance(Pres2)/3.;
+ if(tmp1<tmp2) {
+ // using existed direction
+ if( height > tmp1 ) {
+ height = tmp1;
+ PCbest = gp_Pnt( PC.X() + tmpDir.X()*height,
+ PC.Y() + tmpDir.Y()*height,
+ PC.Z() + tmpDir.Z()*height );
+ }
+ }
+ else {
+ // using opposite direction
+ IsRev = true;
+ if( height > tmp2 ) height = tmp2;
+ PCbest = gp_Pnt( PC.X() + tmpDir.Reversed().X()*height,
+ PC.Y() + tmpDir.Reversed().Y()*height,
+ PC.Z() + tmpDir.Reversed().Z()*height );
+ }
+ }
+
+ // create node for PCbest
+ SMDS_MeshNode* NewNode = meshDS->AddNode( PCbest.X(), PCbest.Y(), PCbest.Z() );
+ // add triangles to result map
+ std::list<const SMDS_FaceOfNodes*> aList;
+ for(i=0; i<4; i++) {
+ SMDS_FaceOfNodes* NewFace;
+ if(IsRev)
+ NewFace = new SMDS_FaceOfNodes( NewNode, FNodes[i], FNodes[i+1] );
+ else
+ NewFace = new SMDS_FaceOfNodes( NewNode, FNodes[i+1], FNodes[i] );
+ aList.push_back(NewFace);
+ }
+ myResMap.insert(make_pair(face,aList));
+ // create pyramid
+ SMDS_MeshVolume* aPyram;
+ if(IsRev)
+ aPyram = meshDS->AddVolume( FNodes[0], FNodes[1], FNodes[2], FNodes[3], NewNode );
+ else
+ aPyram = meshDS->AddVolume( FNodes[0], FNodes[3], FNodes[2], FNodes[1], NewNode );
+ myMapFPyram.insert(make_pair(face,aPyram));
+ } // end loop on elements on a face
+
+ return Compute2ndPart(aMesh);
+}
+
+
+//=======================================================================
+//function : Compute2ndPart
+//purpose :
+//=======================================================================
+
+bool StdMeshers_QuadToTriaAdaptor::Compute2ndPart(SMESH_Mesh& aMesh)
+{
+ SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+
+ // check intersections between created pyramids
+ int NbPyram = myMapFPyram.size();
+ //cout<<"NbPyram = "<<NbPyram<<endl;
+ if(NbPyram==0)
+ return true;
+
+ std::vector< const SMDS_MeshElement* > Pyrams(NbPyram);
+ std::vector< const SMDS_MeshElement* > Faces(NbPyram);
+ std::map< const SMDS_MeshElement*,
+ const SMDS_MeshElement* >::iterator itp = myMapFPyram.begin();
+ int i = 0;
+ for(; itp!=myMapFPyram.end(); itp++, i++) {
+ Faces[i] = (*itp).first;
+ Pyrams[i] = (*itp).second;
+ }
+ StdMeshers_Array1OfSequenceOfInteger MergesInfo(0,NbPyram-1);
+ for(i=0; i<NbPyram; i++) {
+ TColStd_SequenceOfInteger aMerges;
+ aMerges.Append(i);
+ MergesInfo.SetValue(i,aMerges);
+ }
+ for(i=0; i<NbPyram-1; i++) {
+ const SMDS_MeshElement* Prm1 = Pyrams[i];
+ SMDS_ElemIteratorPtr nIt = Prm1->nodesIterator();
+ std::vector<gp_Pnt> Ps1(5);
+ const SMDS_MeshNode* Ns1[5];
+ int k = 0;
+ while( nIt->more() ) {
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nIt->next() );
+ Ns1[k] = node;
+ Ps1[k] = gp_Pnt(node->X(), node->Y(), node->Z());
+ k++;
+ }
+ bool NeedMove = false;
+ for(int j=i+1; j<NbPyram; j++) {
+ //cout<<" i="<<i<<" j="<<j<<endl;
+ const TColStd_SequenceOfInteger& aMergesI = MergesInfo.Value(i);
+ int nbI = aMergesI.Length();
+ const TColStd_SequenceOfInteger& aMergesJ = MergesInfo.Value(j);
+ int nbJ = aMergesJ.Length();
+
+ int k = 2;
+ bool NeedCont = false;
+ for(; k<=nbI; k++) {
+ if(aMergesI.Value(k)==j) {
+ NeedCont = true;
+ break;
+ }
+ }
+ if(NeedCont) continue;
+
+ const SMDS_MeshElement* Prm2 = Pyrams[j];
+ nIt = Prm2->nodesIterator();
+ std::vector<gp_Pnt> Ps2(5);
+ const SMDS_MeshNode* Ns2[5];
+ k = 0;
+ while( nIt->more() ) {
+ const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nIt->next() );
+ Ns2[k] = node;
+ Ps2[k] = gp_Pnt(node->X(), node->Y(), node->Z());
+ k++;
+ }
+
+ bool hasInt = false;
+ gp_Pnt Pint;
+ for(k=0; k<4; k++) {
+ gp_Vec Vtmp(Ps1[k],Ps1[4]);
+ gp_Pnt Pshift( Ps1[k].X() + Vtmp.X()*0.01,
+ Ps1[k].Y() + Vtmp.Y()*0.01,
+ Ps1[k].Z() + Vtmp.Z()*0.01 );
+ int m=0;
+ for(; m<3; m++) {
+ if( HasIntersection3( Pshift, Ps1[4], Pint, Ps2[m], Ps2[m+1], Ps2[4]) ) {
+ hasInt = true;
+ break;
+ }
+ }
+ if( HasIntersection3( Pshift, Ps1[4], Pint, Ps2[3], Ps2[0], Ps2[4]) ) {
+ hasInt = true;
+ }
+ if(hasInt) break;
+ }
+ if(!hasInt) {
+ for(k=0; k<4; k++) {
+ gp_Vec Vtmp(Ps2[k],Ps2[4]);
+ gp_Pnt Pshift( Ps2[k].X() + Vtmp.X()*0.01,
+ Ps2[k].Y() + Vtmp.Y()*0.01,
+ Ps2[k].Z() + Vtmp.Z()*0.01 );
+ int m=0;
+ for(; m<3; m++) {
+ if( HasIntersection3( Pshift, Ps2[4], Pint, Ps1[m], Ps1[m+1], Ps1[4]) ) {
+ hasInt = true;
+ break;
+ }
+ }
+ if( HasIntersection3( Pshift, Ps2[4], Pint, Ps1[3], Ps1[0], Ps1[4]) ) {
+ hasInt = true;
+ }
+ if(hasInt) break;
+ }
+ }
+
+ if(hasInt) {
+ //cout<<" has intersec for i="<<i<<" j="<<j<<endl;
+ // check if MeshFaces have 2 common node
+ int nbc = 0;
+ for(k=0; k<4; k++) {
+ for(int m=0; m<4; m++) {
+ if( Ns1[k]==Ns2[m] ) nbc++;
+ }
+ }
+ //cout<<" nbc = "<<nbc<<endl;
+ if(nbc>0) {
+ // create common node
+ SMDS_MeshNode* CommonNode = const_cast<SMDS_MeshNode*>(Ns1[4]);
+ CommonNode->setXYZ( ( nbI*Ps1[4].X() + nbJ*Ps2[4].X() ) / (nbI+nbJ),
+ ( nbI*Ps1[4].Y() + nbJ*Ps2[4].Y() ) / (nbI+nbJ),
+ ( nbI*Ps1[4].Z() + nbJ*Ps2[4].Z() ) / (nbI+nbJ) );
+ NeedMove = true;
+ //cout<<" CommonNode: "<<CommonNode;
+ const SMDS_MeshNode* Nrem = Ns2[4];
+ Ns2[4] = CommonNode;
+ meshDS->ChangeElementNodes(Prm2, Ns2, 5);
+ // update pyramids for J
+ for(k=2; k<=nbJ; k++) {
+ const SMDS_MeshElement* tmpPrm = Pyrams[aMergesJ.Value(k)];
+ SMDS_ElemIteratorPtr tmpIt = tmpPrm->nodesIterator();
+ const SMDS_MeshNode* Ns[5];
+ int m = 0;
+ while( tmpIt->more() ) {
+ Ns[m] = static_cast<const SMDS_MeshNode*>( tmpIt->next() );
+ m++;
+ }
+ Ns[4] = CommonNode;
+ meshDS->ChangeElementNodes(tmpPrm, Ns, 5);
+ }
+
+ // update MergesInfo
+ for(k=1; k<=nbI; k++) {
+ int num = aMergesI.Value(k);
+ const TColStd_SequenceOfInteger& aSeq = MergesInfo.Value(num);
+ TColStd_SequenceOfInteger tmpSeq;
+ int m = 1;
+ for(; m<=aSeq.Length(); m++) {
+ tmpSeq.Append(aSeq.Value(m));
+ }
+ for(m=1; m<=nbJ; m++) {
+ tmpSeq.Append(aMergesJ.Value(m));
+ }
+ MergesInfo.SetValue(num,tmpSeq);
+ }
+ for(k=1; k<=nbJ; k++) {
+ int num = aMergesJ.Value(k);
+ const TColStd_SequenceOfInteger& aSeq = MergesInfo.Value(num);
+ TColStd_SequenceOfInteger tmpSeq;
+ int m = 1;
+ for(; m<=aSeq.Length(); m++) {
+ tmpSeq.Append(aSeq.Value(m));
+ }
+ for(m=1; m<=nbI; m++) {
+ tmpSeq.Append(aMergesI.Value(m));
+ }
+ MergesInfo.SetValue(num,tmpSeq);
+ }
+
+ // update triangles for aMergesJ
+ for(k=1; k<=nbJ; k++) {
+ std::list< std::list< const SMDS_MeshNode* > > aFNodes;
+ std::list< const SMDS_MeshElement* > aFFaces;
+ int num = aMergesJ.Value(k);
+ std::map< const SMDS_MeshElement*,
+ std::list<const SMDS_FaceOfNodes*> >::iterator itrm = myResMap.find(Faces[num]);
+ std::list<const SMDS_FaceOfNodes*> trias = (*itrm).second;
+ std::list<const SMDS_FaceOfNodes*>::iterator itt = trias.begin();
+ for(; itt!=trias.end(); itt++) {
+ int nn = -1;
+ SMDS_ElemIteratorPtr nodeIt = (*itt)->nodesIterator();
+ const SMDS_MeshNode* NF[3];
+ while ( nodeIt->more() ) {
+ nn++;
+ NF[nn] = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
+ }
+ NF[0] = CommonNode;
+ SMDS_FaceOfNodes* Ftria = const_cast< SMDS_FaceOfNodes*>( (*itt) );
+ Ftria->ChangeNodes(NF, 3);
+ }
+ }
+
+ // check and remove coincided faces
+ TColStd_SequenceOfInteger IdRemovedTrias;
+ int i1 = 1;
+ for(; i1<=nbI; i1++) {
+ int numI = aMergesI.Value(i1);
+ std::map< const SMDS_MeshElement*,
+ std::list<const SMDS_FaceOfNodes*> >::iterator itrmI = myResMap.find(Faces[numI]);
+ std::list<const SMDS_FaceOfNodes*> triasI = (*itrmI).second;
+ std::list<const SMDS_FaceOfNodes*>::iterator ittI = triasI.begin();
+ int nbfI = triasI.size();
+ const SMDS_FaceOfNodes* FsI[nbfI];
+ k = 0;
+ for(; ittI!=triasI.end(); ittI++) {
+ FsI[k] = (*ittI);
+ k++;
+ }
+ int i2 = 0;
+ for(; i2<nbfI; i2++) {
+ const SMDS_FaceOfNodes* FI = FsI[i2];
+ if(FI==0) continue;
+ int j1 = 1;
+ for(; j1<=nbJ; j1++) {
+ int numJ = aMergesJ.Value(j1);
+ std::map< const SMDS_MeshElement*,
+ std::list<const SMDS_FaceOfNodes*> >::iterator itrmJ = myResMap.find(Faces[numJ]);
+ std::list<const SMDS_FaceOfNodes*> triasJ = (*itrmJ).second;
+ std::list<const SMDS_FaceOfNodes*>::iterator ittJ = triasJ.begin();
+ int nbfJ = triasJ.size();
+ const SMDS_FaceOfNodes* FsJ[nbfJ];
+ k = 0;
+ for(; ittJ!=triasJ.end(); ittJ++) {
+ FsJ[k] = (*ittJ);
+ k++;
+ }
+ int j2 = 0;
+ for(; j2<nbfJ; j2++) {
+ const SMDS_FaceOfNodes* FJ = FsJ[j2];
+ // compare triangles
+ if( CompareTrias(FI,FJ) ) {
+ IdRemovedTrias.Append( FI->GetID() );
+ IdRemovedTrias.Append( FJ->GetID() );
+ FsI[i2] = 0;
+ FsJ[j2] = 0;
+ std::list<const SMDS_FaceOfNodes*> new_triasI;
+ for(k=0; k<nbfI; k++) {
+ if( FsI[k]==0 ) continue;
+ new_triasI.push_back( FsI[k] );
+ }
+ (*itrmI).second = new_triasI;
+ triasI = new_triasI;
+ std::list<const SMDS_FaceOfNodes*> new_triasJ;
+ for(k=0; k<nbfJ; k++) {
+ if( FsJ[k]==0 ) continue;
+ new_triasJ.push_back( FsJ[k] );
+ }
+ (*itrmJ).second = new_triasJ;
+ triasJ = new_triasJ;
+ // remove faces
+ delete FI;
+ delete FJ;
+ // close for j2 and j1
+ j1 = nbJ;
+ break;
+ }
+ } // j2
+ } // j1
+ } // i2
+ } // i1
+ // removing node
+ meshDS->RemoveNode(Nrem);
+ }
+ else { // nbc==0
+ //cout<<"decrease height of pyramids"<<endl;
+ // decrease height of pyramids
+ double xc1 = 0., yc1 = 0., zc1 = 0.;
+ double xc2 = 0., yc2 = 0., zc2 = 0.;
+ for(k=0; k<4; k++) {
+ xc1 += Ps1[k].X();
+ yc1 += Ps1[k].Y();
+ zc1 += Ps1[k].Z();
+ xc2 += Ps2[k].X();
+ yc2 += Ps2[k].Y();
+ zc2 += Ps2[k].Z();
+ }
+ gp_Pnt PC1(xc1/4.,yc1/4.,zc1/4.);
+ gp_Pnt PC2(xc2/4.,yc2/4.,zc2/4.);
+ gp_Vec VN1(PC1,Ps1[4]);
+ gp_Vec VI1(PC1,Pint);
+ gp_Vec VN2(PC2,Ps2[4]);
+ gp_Vec VI2(PC2,Pint);
+ double ang1 = fabs(VN1.Angle(VI1));
+ double ang2 = fabs(VN2.Angle(VI2));
+ double h1,h2;
+ if(ang1>PI/3.)
+ h1 = VI1.Magnitude()/2;
+ else
+ h1 = VI1.Magnitude()*cos(ang1);
+ if(ang2>PI/3.)
+ h2 = VI2.Magnitude()/2;
+ else
+ h2 = VI2.Magnitude()*cos(ang2);
+ double coef1 = 0.5;
+ if(ang1<PI/3)
+ coef1 -= cos(ang1)*0.25;
+ double coef2 = 0.5;
+ if(ang2<PI/3)
+ coef2 -= cos(ang1)*0.25;
+
+ SMDS_MeshNode* aNode1 = const_cast<SMDS_MeshNode*>(Ns1[4]);
+ VN1.Scale(coef1);
+ aNode1->setXYZ( PC1.X()+VN1.X(), PC1.Y()+VN1.Y(), PC1.Z()+VN1.Z() );
+ SMDS_MeshNode* aNode2 = const_cast<SMDS_MeshNode*>(Ns2[4]);
+ VN2.Scale(coef2);
+ aNode2->setXYZ( PC2.X()+VN2.X(), PC2.Y()+VN2.Y(), PC2.Z()+VN2.Z() );
+ NeedMove = true;
+ }
+ } // end if(hasInt)
+ else {
+ //cout<<" no intersec for i="<<i<<" j="<<j<<endl;
+ }
+
+ }
+ if( NeedMove && !meshDS->IsEmbeddedMode() ) {
+ meshDS->MoveNode( Ns1[4], Ns1[4]->X(), Ns1[4]->Y(), Ns1[4]->Z() );
+ }
+ }
+
+ return true;
+}
+
+
+//================================================================================
+/*!
+ * \brief Return list of created triangles for given face
+ */
+//================================================================================
+std::list<const SMDS_FaceOfNodes*> StdMeshers_QuadToTriaAdaptor::GetTriangles
+ (const SMDS_MeshElement* aFace)
+{
+ std::list<const SMDS_FaceOfNodes*> aRes;
+ std::map< const SMDS_MeshElement*,
+ std::list<const SMDS_FaceOfNodes*> >::iterator it = myResMap.find(aFace);
+ if( it != myResMap.end() ) {
+ aRes = (*it).second;
+ }
+ return aRes;
+}
+
+
+//================================================================================
+/*!
+ * \brief Remove all create auxilary faces
+ */
+//================================================================================
+//void StdMeshers_QuadToTriaAdaptor::RemoveFaces(SMESH_Mesh& aMesh)
+//{
+// SMESHDS_Mesh * meshDS = aMesh.GetMeshDS();
+// std::map< const SMDS_MeshElement*,
+// std::list<const SMDS_MeshElement*> >::iterator it = myResMap.begin();
+// for(; it != myResMap.end(); it++ ) {
+// std::list<const SMDS_MeshElement*> aFaces = (*it).second;
+// std::list<const SMDS_MeshElement*>::iterator itf = aFaces.begin();
+// for(; itf!=aFaces.end(); itf++ ) {
+// meshDS->RemoveElement( (*itf) );
+// }
+// }
+//}
--- /dev/null
+// SMESH SMESH : implementaion of SMESH idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : StdMeshers_QuadToTriaAdaptor.hxx
+// Module : SMESH
+
+#ifndef _SMESH_QuadToTriaAdaptor_HXX_
+#define _SMESH_QuadToTriaAdaptor_HXX_
+
+#include <SMESH_Mesh.hxx>
+#include <SMESH_StdMeshers.hxx>
+#include <SMDS_FaceOfNodes.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <TColgp_HArray1OfVec.hxx>
+
+#include <map>
+#include <list>
+#include <vector>
+
+class STDMESHERS_EXPORT StdMeshers_QuadToTriaAdaptor
+{
+public:
+
+ StdMeshers_QuadToTriaAdaptor();
+
+ ~StdMeshers_QuadToTriaAdaptor();
+
+ bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
+
+ bool Compute(SMESH_Mesh& aMesh);
+
+ std::list<const SMDS_FaceOfNodes*> GetTriangles(const SMDS_MeshElement* aFace);
+
+protected:
+
+ //bool CheckDegenerate(const SMDS_MeshElement* aFace);
+
+ int Preparation(const SMDS_MeshElement* face,
+ Handle(TColgp_HArray1OfPnt) PN,
+ Handle(TColgp_HArray1OfVec) VN,
+ std::vector<const SMDS_MeshNode*>& FNodes,
+ gp_Pnt& PC, gp_Vec& VNorm);
+
+ bool CheckIntersection(const gp_Pnt& P, const gp_Pnt& PC,
+ gp_Pnt& Pint, SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ const TopoDS_Shape& NotCheckedFace);
+
+ bool Compute2ndPart(SMESH_Mesh& aMesh);
+
+ std::map< const SMDS_MeshElement*, std::list<const SMDS_FaceOfNodes*> > myResMap;
+ std::map< const SMDS_MeshElement*, const SMDS_MeshElement* > myMapFPyram;
+ std::list< const SMDS_MeshNode* > myDegNodes;
+
+};
+
+#endif
--- /dev/null
+// SMESH SMESH : implementaion of SMESH idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : StdMeshers_UseExisting_1D2D.cxx
+// Module : SMESH
+// Created : Fri Oct 20 11:37:07 2006
+// Author : Edward AGAPOV (eap)
+
+
+#include "StdMeshers_UseExisting_1D2D.hxx"
+
+//=======================================================================
+//function : StdMeshers_UseExisting_1D
+//purpose :
+//=======================================================================
+
+StdMeshers_UseExisting_1D::StdMeshers_UseExisting_1D
+ (int hypId, int studyId, SMESH_Gen* gen)
+ :SMESH_1D_Algo(hypId, studyId, gen)
+{
+ _name = "UseExisting_1D";
+ _shapeType = (1 << TopAbs_EDGE); // 1 bit per shape type
+}
+
+//=======================================================================
+//function : CheckHypothesis
+//purpose :
+//=======================================================================
+
+bool StdMeshers_UseExisting_1D::CheckHypothesis(SMESH_Mesh& ,
+ const TopoDS_Shape& ,
+ Hypothesis_Status& aStatus)
+{
+ return (aStatus = HYP_OK) == HYP_OK;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+bool StdMeshers_UseExisting_1D::Compute(SMESH_Mesh&, const TopoDS_Shape&)
+{
+ // This algorithm exists to allow mesh generation by mesh edition functions in TUI mode
+ return true;
+}
+
+//=======================================================================
+//function : StdMeshers_UseExisting_2D
+//purpose :
+//=======================================================================
+
+StdMeshers_UseExisting_2D::StdMeshers_UseExisting_2D
+ (int hypId, int studyId, SMESH_Gen* gen)
+ :SMESH_2D_Algo(hypId, studyId, gen)
+{
+ _name = "UseExisting_2D";
+ _shapeType = (1 << TopAbs_FACE); // 1 bit per shape type
+}
+
+//=======================================================================
+//function : CheckHypothesis
+//purpose :
+//=======================================================================
+
+bool StdMeshers_UseExisting_2D::CheckHypothesis(SMESH_Mesh& ,
+ const TopoDS_Shape& ,
+ Hypothesis_Status& aStatus)
+{
+ return (aStatus = HYP_OK) == HYP_OK;
+}
+
+//=======================================================================
+//function : Compute
+//purpose :
+//=======================================================================
+
+bool StdMeshers_UseExisting_2D::Compute(SMESH_Mesh&, const TopoDS_Shape&)
+{
+ // This algorithm exists to allow mesh generation by mesh edition functions in TUI mode
+ return true;
+}
--- /dev/null
+// SMESH SMESH : implementaion of SMESH idl descriptions
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : StdMeshers_UseExisting_1D2D.hxx
+// Module : SMESH
+
+#ifndef _SMESH_UseExisting_1D2D_HXX_
+#define _SMESH_UseExisting_1D2D_HXX_
+
+#include "SMESH_StdMeshers.hxx"
+
+#include "SMESH_1D_Algo.hxx"
+#include "SMESH_2D_Algo.hxx"
+
+/*!
+ * \brief 1D and 2D algorithms doing nothing to allow mesh generation
+ * by mesh edition functions in TUI mode
+ */
+class STDMESHERS_EXPORT StdMeshers_UseExisting_2D: public SMESH_2D_Algo
+{
+public:
+ StdMeshers_UseExisting_2D(int hypId, int studyId, SMESH_Gen* gen);
+
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ SMESH_Hypothesis::Hypothesis_Status& aStatus);
+
+ virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
+
+};
+
+class StdMeshers_UseExisting_1D: public SMESH_1D_Algo
+{
+public:
+ StdMeshers_UseExisting_1D(int hypId, int studyId, SMESH_Gen* gen);
+
+ virtual bool CheckHypothesis(SMESH_Mesh& aMesh,
+ const TopoDS_Shape& aShape,
+ SMESH_Hypothesis::Hypothesis_Status& aStatus);
+
+ virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape);
+
+};
+
+#endif
--- /dev/null
+// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : StdMeshers_Projection_3D_i.cxx
+// Moved here from SMESH_Projection_3D_i.cxx
+// Author : Paul RASCLE, EDF
+// Module : SMESH
+// $Header$
+
+#include "StdMeshers_UseExisting_1D2D_i.hxx"
+
+#include "SMESH_Gen.hxx"
+
+#include "utilities.h"
+
+//=============================================================================
+/*!
+ * StdMeshers_UseExisting_1D_i::StdMeshers_UseExisting_1D_i
+ */
+//=============================================================================
+
+StdMeshers_UseExisting_1D_i::StdMeshers_UseExisting_1D_i
+ ( PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl )
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
+ SMESH_Algo_i( thePOA ),
+ SMESH_1D_Algo_i( thePOA )
+{
+ MESSAGE( "StdMeshers_UseExisting_1D_i::StdMeshers_UseExisting_1D_i" );
+ myBaseImpl = new ::StdMeshers_UseExisting_1D( theGenImpl->GetANewId(),
+ theStudyId,
+ theGenImpl );
+}
+//-----------------------------------------------------------------------------
+
+StdMeshers_UseExisting_1D_i::~StdMeshers_UseExisting_1D_i()
+{
+ MESSAGE( "StdMeshers_UseExisting_1D_i::~StdMeshers_UseExisting_1D_i" );
+}
+//-----------------------------------------------------------------------------
+
+::StdMeshers_UseExisting_1D* StdMeshers_UseExisting_1D_i::GetImpl()
+{
+ MESSAGE( "StdMeshers_UseExisting_1D_i::GetImpl" );
+ return ( ::StdMeshers_UseExisting_1D* )myBaseImpl;
+}
+
+
+//=============================================================================
+/*!
+ * StdMeshers_UseExisting_2D_i::StdMeshers_UseExisting_2D_i
+ */
+//=============================================================================
+
+StdMeshers_UseExisting_2D_i::StdMeshers_UseExisting_2D_i
+ ( PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl )
+ : SALOME::GenericObj_i( thePOA ),
+ SMESH_Hypothesis_i( thePOA ),
+ SMESH_Algo_i( thePOA ),
+ SMESH_2D_Algo_i( thePOA )
+{
+ MESSAGE( "StdMeshers_UseExisting_2D_i::StdMeshers_UseExisting_2D_i" );
+ myBaseImpl = new ::StdMeshers_UseExisting_2D( theGenImpl->GetANewId(),
+ theStudyId,
+ theGenImpl );
+}
+//-----------------------------------------------------------------------------
+
+StdMeshers_UseExisting_2D_i::~StdMeshers_UseExisting_2D_i()
+{
+ MESSAGE( "StdMeshers_UseExisting_2D_i::~StdMeshers_UseExisting_2D_i" );
+}
+//-----------------------------------------------------------------------------
+
+::StdMeshers_UseExisting_2D* StdMeshers_UseExisting_2D_i::GetImpl()
+{
+ MESSAGE( "StdMeshers_UseExisting_2D_i::GetImpl" );
+ return ( ::StdMeshers_UseExisting_2D* )myBaseImpl;
+}
--- /dev/null
+// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : StdMeshers_UseExisting_1D2D.hxx
+// Module : SMESH
+// $Header$
+
+#ifndef _SMESH_UseExisting_1D2D_I_HXX_
+#define _SMESH_UseExisting_1D2D_I_HXX_
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis)
+
+#include "SMESH_1D_Algo_i.hxx"
+#include "SMESH_2D_Algo_i.hxx"
+#include "StdMeshers_UseExisting_1D2D.hxx"
+
+class SMESH_Gen;
+
+/*!
+ * \brief 1D and 2D algorithms doing nothing to allow mesh generation
+ * by mesh edition functions in TUI mode
+ */
+
+class StdMeshers_UseExisting_1D_i:
+ public virtual POA_StdMeshers::StdMeshers_UseExisting_1D,
+ public virtual SMESH_1D_Algo_i
+{
+public:
+ // Constructor
+ StdMeshers_UseExisting_1D_i( PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl );
+
+ // Destructor
+ virtual ~StdMeshers_UseExisting_1D_i();
+
+ // Get implementation
+ ::StdMeshers_UseExisting_1D* GetImpl();
+};
+
+class StdMeshers_UseExisting_2D_i:
+ public virtual POA_StdMeshers::StdMeshers_UseExisting_2D,
+ public virtual SMESH_2D_Algo_i
+{
+public:
+ // Constructor
+ StdMeshers_UseExisting_2D_i( PortableServer::POA_ptr thePOA,
+ int theStudyId,
+ ::SMESH_Gen* theGenImpl );
+
+ // Destructor
+ virtual ~StdMeshers_UseExisting_2D_i();
+
+ // Get implementation
+ ::StdMeshers_UseExisting_2D* GetImpl();
+};
+
+
+#endif