From: admin Date: Mon, 9 Jun 2008 07:09:37 +0000 (+0000) Subject: This commit was generated by cvs2git to create tag 'V4_1_0rc1'. X-Git-Tag: V4_1_0rc1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7fbea70d54c9e1b4f89d63ffa742aab8ede51855;p=modules%2Fsmesh.git This commit was generated by cvs2git to create tag 'V4_1_0rc1'. Sprout from BR_Dev_For_4_0 2007-11-07 14:19:00 UTC ouv 'CORBA includes' Cherrypick from V4_1_0_maintainance 2008-06-09 07:09:36 UTC vsr 'Issue 0016760: improve dialog box': doc/salome/gui/SMESH/images/blsurf_parameters.png doc/salome/gui/SMESH/images/blsurf_parameters_advanced.png doc/salome/gui/SMESH/images/extrusion2.png doc/salome/gui/SMESH/images/ghs3d_parameters_advanced.png doc/salome/gui/SMESH/images/ghs3d_parameters_basic.png doc/salome/gui/SMESH/images/mesh_clear.png doc/salome/gui/SMESH/images/revolutionsn1.png doc/salome/gui/SMESH/images/revolutionsn2.png doc/salome/gui/SMESH/input/blsurf_hypo.doc doc/salome/gui/SMESH/input/ghs3d_hypo.doc resources/mesh_clear.png src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx src/SMESHGUI/SMESHGUI_FileInfoDlg.h src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx src/StdMeshers/StdMeshers_QuadToTriaAdaptor.hxx Cherrypick from master 2008-03-07 07:47:05 UTC jfa 'Join modifications from BR_Dev_For_4_0 tag V4_1_1.': doc/salome/gui/SMESH/images/eleminfo1.png doc/salome/gui/SMESH/images/eleminfo2.png doc/salome/gui/SMESH/images/mesh_cylinder_hexa.png resources/mesh_whatis.png src/SMESHGUI/SMESHGUI_WhatIsDlg.cxx src/SMESHGUI/SMESHGUI_WhatIsDlg.h src/SMESH_SWIG/ex24_cylinder.py src/StdMeshers/StdMeshers_UseExisting_1D2D.cxx src/StdMeshers/StdMeshers_UseExisting_1D2D.hxx src/StdMeshers_I/StdMeshers_UseExisting_1D2D_i.cxx src/StdMeshers_I/StdMeshers_UseExisting_1D2D_i.hxx --- diff --git a/doc/salome/gui/SMESH/images/blsurf_parameters.png b/doc/salome/gui/SMESH/images/blsurf_parameters.png new file mode 100644 index 000000000..22d038ac5 Binary files /dev/null and b/doc/salome/gui/SMESH/images/blsurf_parameters.png differ diff --git a/doc/salome/gui/SMESH/images/blsurf_parameters_advanced.png b/doc/salome/gui/SMESH/images/blsurf_parameters_advanced.png new file mode 100644 index 000000000..0f2c07dc3 Binary files /dev/null and b/doc/salome/gui/SMESH/images/blsurf_parameters_advanced.png differ diff --git a/doc/salome/gui/SMESH/images/eleminfo1.png b/doc/salome/gui/SMESH/images/eleminfo1.png new file mode 100755 index 000000000..5e2c2a0c0 Binary files /dev/null and b/doc/salome/gui/SMESH/images/eleminfo1.png differ diff --git a/doc/salome/gui/SMESH/images/eleminfo2.png b/doc/salome/gui/SMESH/images/eleminfo2.png new file mode 100755 index 000000000..3ff8d1d9c Binary files /dev/null and b/doc/salome/gui/SMESH/images/eleminfo2.png differ diff --git a/doc/salome/gui/SMESH/images/extrusion2.png b/doc/salome/gui/SMESH/images/extrusion2.png new file mode 100755 index 000000000..958a8f2e9 Binary files /dev/null and b/doc/salome/gui/SMESH/images/extrusion2.png differ diff --git a/doc/salome/gui/SMESH/images/ghs3d_parameters_advanced.png b/doc/salome/gui/SMESH/images/ghs3d_parameters_advanced.png new file mode 100644 index 000000000..4f36203ba Binary files /dev/null and b/doc/salome/gui/SMESH/images/ghs3d_parameters_advanced.png differ diff --git a/doc/salome/gui/SMESH/images/ghs3d_parameters_basic.png b/doc/salome/gui/SMESH/images/ghs3d_parameters_basic.png new file mode 100644 index 000000000..0cce50bb8 Binary files /dev/null and b/doc/salome/gui/SMESH/images/ghs3d_parameters_basic.png differ diff --git a/doc/salome/gui/SMESH/images/mesh_clear.png b/doc/salome/gui/SMESH/images/mesh_clear.png new file mode 100644 index 000000000..0d44a126d Binary files /dev/null and b/doc/salome/gui/SMESH/images/mesh_clear.png differ diff --git a/doc/salome/gui/SMESH/images/mesh_cylinder_hexa.png b/doc/salome/gui/SMESH/images/mesh_cylinder_hexa.png new file mode 100644 index 000000000..f95dc67f7 Binary files /dev/null and b/doc/salome/gui/SMESH/images/mesh_cylinder_hexa.png differ diff --git a/doc/salome/gui/SMESH/images/revolutionsn1.png b/doc/salome/gui/SMESH/images/revolutionsn1.png new file mode 100644 index 000000000..6564c7fc6 Binary files /dev/null and b/doc/salome/gui/SMESH/images/revolutionsn1.png differ diff --git a/doc/salome/gui/SMESH/images/revolutionsn2.png b/doc/salome/gui/SMESH/images/revolutionsn2.png new file mode 100644 index 000000000..67a673144 Binary files /dev/null and b/doc/salome/gui/SMESH/images/revolutionsn2.png differ diff --git a/doc/salome/gui/SMESH/input/blsurf_hypo.doc b/doc/salome/gui/SMESH/input/blsurf_hypo.doc new file mode 100644 index 000000000..92e1f64f4 --- /dev/null +++ b/doc/salome/gui/SMESH/input/blsurf_hypo.doc @@ -0,0 +1,221 @@ +/*! + +\page blsurf_hypo_page BLSURF Parameters hypothesis + +\n BLSURF Parameters hypothesis works only with BLSURF 2d +algorithm. This algorithm is a commercial software. + +\image html blsurf_parameters.png + +
    +
  • Name - allows to define the name of the hypothesis (BLSURF +Parameters by default).
  • + +
  • Physical Mesh - if is set to "Custom", allows to set size +of mesh elements to generate in User size field. +
  • + +
  • User size - size of mesh elements to generate.
  • + +
  • Max Physical Size - is an upper limit of mesh element size.
  • + +
  • Min Physical Size - is a lower limit of mesh element size.
  • + +
  • Geometrical mesh - if is set to "Custom", allows to set +mesh element deflection from curves and surfaces and element +size change rate in Angle Mesh S, Angle Mesh C and +Gradation fields correspondingly. These fields control +computation of element size, so called geometrical size, conform to +the surface geometry considering local curvatures. \n +The eventual element size at each point will be minimum of User +size, if given, and the geometrical size.
  • + +
  • Angle Mesh S - maximal allowed angle in degrees at a mesh +node between the mesh face and the tangent to the geometrical surface.
  • + +
  • Angle Mesh C - maximal allowed angle in degrees at a mesh +node between the mesh edge and the tangent to the geometrical curve.
  • + +
  • Max Geometrical Size - is an upper limit of geometrical size.
  • + +
  • Min Geometrical Size - is a lower limit of geometrical size.
  • + +
  • Gradation - maximal allowed ratio between the lengths of +two adjacent edges.
  • + +
  • Allow Quadrangles - to create quadrilateral elements.
  • + +
  • Patch independent - if this box is checked on, geometrical +edges are not respected and all geometrical faces are meshed as one +hyper-face.
  • + +\image html blsurf_parameters_advanced.png + +
  • Topology - allows creation of a conform mesh on a shell of +not sewed faces. +
      +
    • "From CAD" means that mesh conformity is assured by conformity + of a shape.
    • +
    • "Pre-process" and "Pre-process++" let BLSURF software + pre-process the geometrical model to eventually produce a conform + mesh.
    • +
    + +
  • Verbosity level - Defines the percentage of "verbosity" of +BLSURF [0-100].
  • + +
  • Add option - 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.
  • + +
  • Clear option - removes option selected in the table. + +
+ +\n +Commonly usable options are following. The name diag stands there for +the diagonal of the bounding box of the geometrical object to mesh. + +
    +
  • topo_eps1 (real) - is the tolerance level inside a CAD +patch. By default is equal to diag × 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 diag/10.0.
  • + +
  • topo_eps2 (real) - is the tolerance level between two CAD +patches. By default is equal to diag × 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 diag/10.0.
  • + +
  • \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.
  • + +
  • \b frontal (integer) +
      +
    • 1 - the mesh generator inserts points with an advancing front method.
    • +
    • 0 - it inserts them with an algebraic method (on internal edges). This method is +slightly faster but generates less regular meshes.
    • +
    +Default is 0.
  • + +
  • \b hinterpol_flag (integer) - determines the computation of an +interpolated value v between two points P1 and P2 on a +curve. Let h1 be the value at point P1, h2 be the value at point +P2, and t be a parameter varying from 0 to 1 when moving from P1 +to P2 . +
      +
    • 0 - the interpolation is linear: v = h1 + t (h2 - h1 )
    • +
    • 1 - the interpolation is geometric: v = h1 * pow( h2/h1, t)
    • +
    • 2 - the interpolation is sinusoidal: v = (h1+h2)/2 + +(h1-h2)/2*cos(PI*t)
    • +
    +Default is 0.
  • + +
  • \b hmean_flag (integer) - determines the computation of the mean of several +values:
      +
    • -1 - the minimum is computed.
    • +
    • 0 or 2 - the arithmetic mean computed. +
    • 1 - the geometric mean is computed.
    • +
    +Default is 0.
  • + +
  • \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.
  • + + +
  • \b CoefRectangle (real)- defines the relative thickness of the rectangles +used by subroutine \b CheckCloseEdges (see above). Default is 0.25.
  • + +
  • \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.
  • + +
  • \b eps_ends (real) - is used to detect curves whose lengths are very +small, which sometimes constitutes an error. A message is printed +if fabs(P2-P1) < eps_ends, where P1 and P2 are the +extremities of a curve. Default is diag/500.0.
  • + +
  • \b prefix (char) - is a prefix of the files generated by +BLSURF. Default is "x".
  • + +
  • \b refs (integer) - reference of a surface, used when exporting +files. Default is 1.
  • +
+ +\n +The following advanced options are not documented and you can use them +at your own risk. +\n\n Interger variables: +
    +
  • addsurf_ivertex
  • +
  • background
  • +
  • coiter
  • +
  • communication
  • +
  • decim
  • +
  • export_flag
  • +
  • file_h
  • +
  • gridnu
  • +
  • gridnv
  • +
  • intermedfile
  • +
  • memory
  • +
  • normals
  • +
  • optim
  • +
  • pardom_flag
  • +
  • pinch
  • +
  • rigid
  • +
  • surforient
  • +
  • tconf
  • +
  • topo_collapse
  • +
+Real variables: +
    +
  • addsurf_angle
  • +
  • addsurf_R
  • +
  • addsurf_H
  • +
  • addsurf_FG
  • +
  • addsurf_r
  • +
  • addsurf_PA
  • +
  • angle_compcurv
  • +
  • angle_ridge
  • +
  • eps_pardom
  • +
+String variables: +
    +
  • export_format
  • +
  • export_option
  • +
  • import_option
  • +
+ + +\n +Currently BLSURF plugin has the following limitations. +
    +
  • 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.
  • + +
  • SIGFPE exception is raised at trying to compute mesh, based on + box, with checked option "Patch independent".
  • + +
  • 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: +
      +
    • global MEFISTO or Quadrangle(mapping) + local BLSURF;
    • +
    • BLSUFR + Projection 2D from faces meshed by BLSURF;
    • +
    • local BLSURF + Extrusion 3D;
    • +
    +
  • +
+ +*/ diff --git a/doc/salome/gui/SMESH/input/ghs3d_hypo.doc b/doc/salome/gui/SMESH/input/ghs3d_hypo.doc new file mode 100644 index 000000000..15622b971 --- /dev/null +++ b/doc/salome/gui/SMESH/input/ghs3d_hypo.doc @@ -0,0 +1,68 @@ +/*! + +\page ghs3d_hypo_page GHS3D Parameters hypothesis + +\n GHS3D Parameters hypothesis works only with Tetrahedron (GHS3D) +algorithm. This algorithm is a commercial software. + +\image html ghs3d_parameters_basic.png + +
    +
  • Name - allows to define the name of the hypothesis (GHS3D +Parameters by default).
  • + +
  • To mesh holes - 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.
  • + +
  • Optimization level - sets the desired optimization level. +Optimization levels are: none, light, medium, strong, in increasing +order of "quality vs speed" ratio. +
  • + +\image html ghs3d_parameters_advanced.png + +
  • Maximum memory size - 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.
  • + +
  • Initial memory size - 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.
  • + +
  • Working directory - defines folder for input and output +files of ghs3d software, which are files starting with "GHS3D_" prefix.
  • + +
  • Keep working files - allows to check input and output files +of ghs3d software, while usually these files are removed after mesher launch.
  • + +
  • Verbose level - to choose verbosity level in the range 0 to 10. +
    • 0, no standard output, +
    • 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. +
    • 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. +
  • + +
  • To create new nodes - if this option is checked off, ghs3d +tries to create tetrahedrons using only nodes of 2D mesh.
  • + +
  • To use boundary recovery version - 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).
  • + +
  • Option as text - allows entering any text that will be +used as command line option of ghs3d. This is for giving +advanced options in a free from.
  • + +
+ +*/ \ No newline at end of file diff --git a/resources/mesh_clear.png b/resources/mesh_clear.png new file mode 100644 index 000000000..0d44a126d Binary files /dev/null and b/resources/mesh_clear.png differ diff --git a/resources/mesh_whatis.png b/resources/mesh_whatis.png new file mode 100755 index 000000000..1b39f3544 Binary files /dev/null and b/resources/mesh_whatis.png differ diff --git a/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx b/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx new file mode 100644 index 000000000..f744561d3 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FileInfoDlg.cxx @@ -0,0 +1,77 @@ +// 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 + +#include + +#include +#include +#include + +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() +{ +} diff --git a/src/SMESHGUI/SMESHGUI_FileInfoDlg.h b/src/SMESHGUI/SMESHGUI_FileInfoDlg.h new file mode 100644 index 000000000..7cf917d65 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FileInfoDlg.h @@ -0,0 +1,44 @@ +// 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 +#include + +class SMESHGUI_FileInfoDlg : public QtxDialog +{ + Q_OBJECT + +public: + SMESHGUI_FileInfoDlg( QWidget*, SALOME_MED::MedFileInfo* ); + virtual ~SMESHGUI_FileInfoDlg(); +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_WhatIsDlg.cxx b/src/SMESHGUI/SMESHGUI_WhatIsDlg.cxx new file mode 100755 index 000000000..d7dd9579d --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_WhatIsDlg.cxx @@ -0,0 +1,626 @@ +// 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 +#include +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// 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 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(IO)->_is_nil()) { + GroupMesh->setTitle(tr("SMESH_MESH")); + } else if(!SMESH::IObjectToInterface(IO)->_is_nil()) { + GroupMesh->setTitle(tr("SMESH_SUBMESH")); + } else if(!SMESH::IObjectToInterface(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( 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(); + } +} diff --git a/src/SMESHGUI/SMESHGUI_WhatIsDlg.h b/src/SMESHGUI/SMESHGUI_WhatIsDlg.h new file mode 100755 index 000000000..af1c4ef3d --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_WhatIsDlg.h @@ -0,0 +1,130 @@ +// 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 + +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 +#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 diff --git a/src/SMESH_SWIG/ex24_cylinder.py b/src/SMESH_SWIG/ex24_cylinder.py new file mode 100644 index 000000000..25a1e96d6 --- /dev/null +++ b/src/SMESH_SWIG/ex24_cylinder.py @@ -0,0 +1,104 @@ +# 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) diff --git a/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx b/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx new file mode 100644 index 000000000..3892ddc9b --- /dev/null +++ b/src/StdMeshers/StdMeshers_QuadToTriaAdaptor.cxx @@ -0,0 +1,1164 @@ +// 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 +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +typedef NCollection_Array1 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"< 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()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() = "<NbFaces()<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( 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( 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(tmpnodesIterator(); + const SMDS_MeshNode* Ns1[3]; + int k = 0; + while( nIt->more() ) { + Ns1[k] = static_cast( nIt->next() ); + k++; + } + nIt = F2->nodesIterator(); + const SMDS_MeshNode* Ns2[3]; + k = 0; + while( nIt->more() ) { + Ns2[k] = static_cast( 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& 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( 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( 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"<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(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("<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; iValue(i)); + V2 = gp_Vec(PC,PN->Value(i+1)); + gp_Vec Vtmp = V1.Crossed(V2); + VN->SetValue(i,Vtmp); + VNorm += Vtmp; + } + //cout<<" VNorm("<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<GetID() = "<GetID()< 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 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("<AddNode( PCbest.X(), PCbest.Y(), PCbest.Z() ); + // add triangles to result map + std::list 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<GetID() = "<GetID()< 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 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( 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( 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(tmpValue(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("<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( 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( 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 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 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 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 = "< 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; inodesIterator(); + std::vector Ps1(5); + const SMDS_MeshNode* Ns1[5]; + int k = 0; + while( nIt->more() ) { + const SMDS_MeshNode* node = static_cast( nIt->next() ); + Ns1[k] = node; + Ps1[k] = gp_Pnt(node->X(), node->Y(), node->Z()); + k++; + } + bool NeedMove = false; + for(int j=i+1; jChangeElementNodes(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( 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 >::iterator itrm = myResMap.find(Faces[num]); + std::list trias = (*itrm).second; + std::list::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( 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 >::iterator itrmI = myResMap.find(Faces[numI]); + std::list triasI = (*itrmI).second; + std::list::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 >::iterator itrmJ = myResMap.find(Faces[numJ]); + std::list triasJ = (*itrmJ).second; + std::list::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(; j2GetID() ); + IdRemovedTrias.Append( FJ->GetID() ); + FsI[i2] = 0; + FsJ[j2] = 0; + std::list new_triasI; + for(k=0; k new_triasJ; + for(k=0; kRemoveNode(Nrem); + } + else { // nbc==0 + //cout<<"decrease height of pyramids"<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(Ns1[4]); + VN1.Scale(coef1); + aNode1->setXYZ( PC1.X()+VN1.X(), PC1.Y()+VN1.Y(), PC1.Z()+VN1.Z() ); + SMDS_MeshNode* aNode2 = const_cast(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="<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; +} diff --git a/src/StdMeshers_I/StdMeshers_UseExisting_1D2D_i.hxx b/src/StdMeshers_I/StdMeshers_UseExisting_1D2D_i.hxx new file mode 100644 index 000000000..6eaf23fb6 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_UseExisting_1D2D_i.hxx @@ -0,0 +1,80 @@ +// 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 +#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