From 143d55f45ff65cc53f4e45a03bd136c65df46219 Mon Sep 17 00:00:00 2001 From: smh Date: Mon, 5 Apr 2004 14:29:26 +0000 Subject: [PATCH] SALOME PAL V1_4_1 --- idl/SMESH_Filter.idl | 110 ++ idl/SMESH_Group.idl | 103 ++ idl/SMESH_NetgenAlgorithm.idl | 45 + resources/SMESH.config | 2 + resources/SMESH_Meshers.xml | 78 + resources/SMESH_MeshersWithNETGEN.xml | 89 ++ resources/StdMeshers.xml | 78 + resources/mesh_edit_group.png | Bin 0 -> 543 bytes resources/mesh_free_edges.png | Bin 0 -> 489 bytes resources/mesh_make_group.png | Bin 0 -> 432 bytes resources/mesh_multi_edges.png | Bin 0 -> 480 bytes resources/mesh_points.png | Bin 0 -> 499 bytes resources/mesh_tree_group.png | Bin 0 -> 411 bytes resources/mesh_tree_importedmesh.png | Bin 0 -> 912 bytes src/Controls/Makefile.in | 50 + src/Controls/SMESHControls.cxx | 42 + src/Controls/SMESH_Controls.cxx | 774 ++++++++++ src/Controls/SMESH_Controls.hxx | 340 +++++ src/Driver/Driver_Document.cxx | 36 + src/Driver/Driver_Document.h | 44 + src/Driver/Driver_Mesh.cxx | 46 + src/Driver/Driver_Mesh.h | 57 + src/Driver/Driver_SMDS_Mesh.cxx | 31 + src/Driver/Driver_SMDS_Mesh.h | 38 + src/Driver/Driver_SMESHDS_Mesh.cxx | 31 + src/Driver/Driver_SMESHDS_Mesh.h | 38 + src/DriverDAT/DAT_Test.cxx | 28 + src/DriverMED/DriverMED_Family.cxx | 367 +++++ src/DriverMED/DriverMED_Family.h | 121 ++ src/DriverMED/MED_Test.cxx | 28 + src/DriverUNV/UNV2411_Structure.cxx | 123 ++ src/DriverUNV/UNV2411_Structure.hxx | 46 + src/DriverUNV/UNV2412_Structure.cxx | 202 +++ src/DriverUNV/UNV2412_Structure.hxx | 59 + src/DriverUNV/UNV_Test.cxx | 69 + src/DriverUNV/UNV_Utilities.cxx | 37 + src/DriverUNV/UNV_Utilities.hxx | 104 ++ src/NETGENPlugin/Makefile.in | 67 + src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx | 1064 ++++++++++++++ src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx | 43 + src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx | 85 ++ src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.hxx | 58 + src/NETGENPlugin/NETGENPlugin_i.cxx | 60 + src/NETGENPlugin/NETGENPlugin_icons.po | 20 + src/OBJECT/SMESH_DeviceActor.cxx | 357 +++++ src/OBJECT/SMESH_DeviceActor.h | 133 ++ src/OBJECT/SMESH_Object.cxx | 1037 +++++++++++++ src/OBJECT/SMESH_Object.h | 207 +++ src/SMESH/SMESH_Group.cxx | 55 + src/SMESH/SMESH_Group.hxx | 64 + src/SMESHDS/SMESHDS_Group.cxx | 129 ++ src/SMESHDS/SMESHDS_Group.hxx | 72 + src/SMESHGUI/SMESHBin.cxx | 4 + src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx | 290 ++++ src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h | 97 ++ src/SMESHGUI/SMESHGUI_Filter.cxx | 114 ++ src/SMESHGUI/SMESHGUI_Filter.h | 68 + src/SMESHGUI/SMESHGUI_FilterDlg.cxx | 1302 +++++++++++++++++ src/SMESHGUI/SMESHGUI_FilterDlg.h | 195 +++ src/SMESHGUI/SMESHGUI_GroupDlg.cxx | 977 +++++++++++++ src/SMESHGUI/SMESHGUI_GroupDlg.h | 132 ++ src/SMESHGUI/SMESHGUI_Hypotheses.h | 74 + .../SMESHGUI_Preferences_SelectionDlg.cxx | 307 ++++ .../SMESHGUI_Preferences_SelectionDlg.h | 97 ++ src/SMESHGUI/SMESHGUI_XmlHandler.cxx | 187 +++ src/SMESHGUI/SMESHGUI_XmlHandler.h | 58 + src/SMESH_I/SMESHEngine.cxx | 23 + src/SMESH_I/SMESH_Filter_i.cxx | 914 ++++++++++++ src/SMESH_I/SMESH_Filter_i.hxx | 417 ++++++ src/SMESH_I/SMESH_Group_i.cxx | 358 +++++ src/SMESH_I/SMESH_Group_i.hxx | 82 ++ src/SMESH_SWIG/SMESH_controls.py | 227 +++ src/SMESH_SWIG/SMESH_freebord.py | 78 + src/SMESH_SWIG/SMESH_test4.py | 65 + src/SMESH_SWIG/SMESH_test5.py | 79 + src/SMESH_SWIG/batchmode_mefisto.py | 150 ++ src/StdMeshers/Makefile.in | 81 + src/StdMeshers/StdMeshers_Hexa_3D.cxx | 1004 +++++++++++++ src/StdMeshers/StdMeshers_Hexa_3D.hxx | 140 ++ src/StdMeshers/StdMeshers_LengthFromEdges.cxx | 139 ++ src/StdMeshers/StdMeshers_LengthFromEdges.hxx | 57 + src/StdMeshers/StdMeshers_LocalLength.cxx | 137 ++ src/StdMeshers/StdMeshers_LocalLength.hxx | 55 + src/StdMeshers/StdMeshers_MEFISTO_2D.cxx | 643 ++++++++ src/StdMeshers/StdMeshers_MEFISTO_2D.hxx | 88 ++ src/StdMeshers/StdMeshers_MaxElementArea.cxx | 139 ++ src/StdMeshers/StdMeshers_MaxElementArea.hxx | 55 + .../StdMeshers_MaxElementVolume.cxx | 141 ++ .../StdMeshers_MaxElementVolume.hxx | 57 + .../StdMeshers_NotConformAllowed.cxx | 98 ++ .../StdMeshers_NotConformAllowed.hxx | 48 + .../StdMeshers_NumberOfSegments.cxx | 171 +++ .../StdMeshers_NumberOfSegments.hxx | 63 + src/StdMeshers/StdMeshers_Quadrangle_2D.cxx | 644 ++++++++ src/StdMeshers/StdMeshers_Quadrangle_2D.hxx | 102 ++ src/StdMeshers/StdMeshers_Regular_1D.cxx | 331 +++++ src/StdMeshers/StdMeshers_Regular_1D.hxx | 65 + src/StdMeshersGUI/Makefile.in | 78 + src/StdMeshersGUI/StdMeshersGUI.cxx | 225 +++ .../StdMeshersGUI_LocalLengthDlg.cxx | 289 ++++ .../StdMeshersGUI_LocalLengthDlg.h | 89 ++ .../StdMeshersGUI_MaxElementAreaDlg.cxx | 291 ++++ .../StdMeshersGUI_MaxElementAreaDlg.h | 89 ++ .../StdMeshersGUI_MaxElementVolumeDlg.cxx | 290 ++++ .../StdMeshersGUI_MaxElementVolumeDlg.h | 89 ++ .../StdMeshersGUI_NbSegmentsDlg.cxx | 289 ++++ .../StdMeshersGUI_NbSegmentsDlg.h | 89 ++ src/StdMeshersGUI/StdMeshers_icons.po | 81 + src/StdMeshersGUI/StdMeshers_msg_en.po | 49 + src/StdMeshers_I/Makefile.in | 76 + src/StdMeshers_I/StdMeshers_Hexa_3D_i.cxx | 84 ++ src/StdMeshers_I/StdMeshers_Hexa_3D_i.hxx | 61 + .../StdMeshers_LengthFromEdges_i.cxx | 121 ++ .../StdMeshers_LengthFromEdges_i.hxx | 65 + src/StdMeshers_I/StdMeshers_LocalLength_i.cxx | 119 ++ src/StdMeshers_I/StdMeshers_LocalLength_i.hxx | 67 + src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.cxx | 85 ++ src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.hxx | 61 + .../StdMeshers_MaxElementArea_i.cxx | 119 ++ .../StdMeshers_MaxElementArea_i.hxx | 64 + .../StdMeshers_MaxElementVolume_i.cxx | 120 ++ .../StdMeshers_MaxElementVolume_i.hxx | 64 + .../StdMeshers_NotConformAllowed_i.cxx | 64 + .../StdMeshers_NotConformAllowed_i.hxx | 54 + .../StdMeshers_NumberOfSegments_i.cxx | 157 ++ .../StdMeshers_NumberOfSegments_i.hxx | 70 + .../StdMeshers_Quadrangle_2D_i.cxx | 86 ++ .../StdMeshers_Quadrangle_2D_i.hxx | 61 + src/StdMeshers_I/StdMeshers_Regular_1D_i.cxx | 85 ++ src/StdMeshers_I/StdMeshers_Regular_1D_i.hxx | 58 + src/StdMeshers_I/StdMeshers_i.cxx | 86 ++ 131 files changed, 20995 insertions(+) create mode 100644 idl/SMESH_Filter.idl create mode 100644 idl/SMESH_Group.idl create mode 100644 idl/SMESH_NetgenAlgorithm.idl create mode 100644 resources/SMESH.config create mode 100644 resources/SMESH_Meshers.xml create mode 100644 resources/SMESH_MeshersWithNETGEN.xml create mode 100644 resources/StdMeshers.xml create mode 100644 resources/mesh_edit_group.png create mode 100755 resources/mesh_free_edges.png create mode 100644 resources/mesh_make_group.png create mode 100755 resources/mesh_multi_edges.png create mode 100644 resources/mesh_points.png create mode 100644 resources/mesh_tree_group.png create mode 100644 resources/mesh_tree_importedmesh.png create mode 100644 src/Controls/Makefile.in create mode 100644 src/Controls/SMESHControls.cxx create mode 100644 src/Controls/SMESH_Controls.cxx create mode 100644 src/Controls/SMESH_Controls.hxx create mode 100644 src/Driver/Driver_Document.cxx create mode 100644 src/Driver/Driver_Document.h create mode 100644 src/Driver/Driver_Mesh.cxx create mode 100644 src/Driver/Driver_Mesh.h create mode 100644 src/Driver/Driver_SMDS_Mesh.cxx create mode 100644 src/Driver/Driver_SMDS_Mesh.h create mode 100644 src/Driver/Driver_SMESHDS_Mesh.cxx create mode 100644 src/Driver/Driver_SMESHDS_Mesh.h create mode 100644 src/DriverDAT/DAT_Test.cxx create mode 100644 src/DriverMED/DriverMED_Family.cxx create mode 100644 src/DriverMED/DriverMED_Family.h create mode 100644 src/DriverMED/MED_Test.cxx create mode 100644 src/DriverUNV/UNV2411_Structure.cxx create mode 100644 src/DriverUNV/UNV2411_Structure.hxx create mode 100644 src/DriverUNV/UNV2412_Structure.cxx create mode 100644 src/DriverUNV/UNV2412_Structure.hxx create mode 100644 src/DriverUNV/UNV_Test.cxx create mode 100644 src/DriverUNV/UNV_Utilities.cxx create mode 100644 src/DriverUNV/UNV_Utilities.hxx create mode 100644 src/NETGENPlugin/Makefile.in create mode 100644 src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx create mode 100644 src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx create mode 100644 src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx create mode 100644 src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.hxx create mode 100644 src/NETGENPlugin/NETGENPlugin_i.cxx create mode 100644 src/NETGENPlugin/NETGENPlugin_icons.po create mode 100644 src/OBJECT/SMESH_DeviceActor.cxx create mode 100644 src/OBJECT/SMESH_DeviceActor.h create mode 100644 src/OBJECT/SMESH_Object.cxx create mode 100644 src/OBJECT/SMESH_Object.h create mode 100644 src/SMESH/SMESH_Group.cxx create mode 100644 src/SMESH/SMESH_Group.hxx create mode 100644 src/SMESHDS/SMESHDS_Group.cxx create mode 100644 src/SMESHDS/SMESHDS_Group.hxx create mode 100644 src/SMESHGUI/SMESHBin.cxx create mode 100644 src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h create mode 100755 src/SMESHGUI/SMESHGUI_Filter.cxx create mode 100755 src/SMESHGUI/SMESHGUI_Filter.h create mode 100755 src/SMESHGUI/SMESHGUI_FilterDlg.cxx create mode 100755 src/SMESHGUI/SMESHGUI_FilterDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_GroupDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_GroupDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_Hypotheses.h create mode 100644 src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_XmlHandler.cxx create mode 100644 src/SMESHGUI/SMESHGUI_XmlHandler.h create mode 100644 src/SMESH_I/SMESHEngine.cxx create mode 100644 src/SMESH_I/SMESH_Filter_i.cxx create mode 100644 src/SMESH_I/SMESH_Filter_i.hxx create mode 100644 src/SMESH_I/SMESH_Group_i.cxx create mode 100644 src/SMESH_I/SMESH_Group_i.hxx create mode 100644 src/SMESH_SWIG/SMESH_controls.py create mode 100644 src/SMESH_SWIG/SMESH_freebord.py create mode 100755 src/SMESH_SWIG/SMESH_test4.py create mode 100644 src/SMESH_SWIG/SMESH_test5.py create mode 100644 src/SMESH_SWIG/batchmode_mefisto.py create mode 100644 src/StdMeshers/Makefile.in create mode 100644 src/StdMeshers/StdMeshers_Hexa_3D.cxx create mode 100644 src/StdMeshers/StdMeshers_Hexa_3D.hxx create mode 100644 src/StdMeshers/StdMeshers_LengthFromEdges.cxx create mode 100644 src/StdMeshers/StdMeshers_LengthFromEdges.hxx create mode 100644 src/StdMeshers/StdMeshers_LocalLength.cxx create mode 100644 src/StdMeshers/StdMeshers_LocalLength.hxx create mode 100644 src/StdMeshers/StdMeshers_MEFISTO_2D.cxx create mode 100644 src/StdMeshers/StdMeshers_MEFISTO_2D.hxx create mode 100644 src/StdMeshers/StdMeshers_MaxElementArea.cxx create mode 100644 src/StdMeshers/StdMeshers_MaxElementArea.hxx create mode 100644 src/StdMeshers/StdMeshers_MaxElementVolume.cxx create mode 100644 src/StdMeshers/StdMeshers_MaxElementVolume.hxx create mode 100644 src/StdMeshers/StdMeshers_NotConformAllowed.cxx create mode 100644 src/StdMeshers/StdMeshers_NotConformAllowed.hxx create mode 100644 src/StdMeshers/StdMeshers_NumberOfSegments.cxx create mode 100644 src/StdMeshers/StdMeshers_NumberOfSegments.hxx create mode 100644 src/StdMeshers/StdMeshers_Quadrangle_2D.cxx create mode 100644 src/StdMeshers/StdMeshers_Quadrangle_2D.hxx create mode 100644 src/StdMeshers/StdMeshers_Regular_1D.cxx create mode 100644 src/StdMeshers/StdMeshers_Regular_1D.hxx create mode 100644 src/StdMeshersGUI/Makefile.in create mode 100644 src/StdMeshersGUI/StdMeshersGUI.cxx create mode 100644 src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.cxx create mode 100644 src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.h create mode 100644 src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.cxx create mode 100644 src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.h create mode 100644 src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.cxx create mode 100644 src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.h create mode 100644 src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.cxx create mode 100644 src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.h create mode 100644 src/StdMeshersGUI/StdMeshers_icons.po create mode 100644 src/StdMeshersGUI/StdMeshers_msg_en.po create mode 100644 src/StdMeshers_I/Makefile.in create mode 100644 src/StdMeshers_I/StdMeshers_Hexa_3D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_Hexa_3D_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_LengthFromEdges_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_LengthFromEdges_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_LocalLength_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_LocalLength_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_MaxElementArea_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_MaxElementArea_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_MaxElementVolume_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_MaxElementVolume_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_NotConformAllowed_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_NotConformAllowed_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_Regular_1D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_Regular_1D_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_i.cxx diff --git a/idl/SMESH_Filter.idl b/idl/SMESH_Filter.idl new file mode 100644 index 000000000..e0a5d7739 --- /dev/null +++ b/idl/SMESH_Filter.idl @@ -0,0 +1,110 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Filter.idl +// Author : Alexey Petrov, OCC + +#ifndef _SMESH_FILTER_IDL_ +#define _SMESH_FILTER_IDL_ + +#include "SALOME_Exception.idl" +#include "SALOME_GenericObj.idl" +#include "SMESH_Mesh.idl" + +module SMESH{ + + interface Functor: SALOME::GenericObj{ + void SetMesh(in SMESH_Mesh theMesh); + }; + + interface NumericalFunctor: Functor{ + double GetValue(in long theElementId); + }; + + interface MinimumAngle: NumericalFunctor{}; + interface AspectRatio: NumericalFunctor{}; + interface Warping: NumericalFunctor{}; + interface Taper: NumericalFunctor{}; + interface Skew: NumericalFunctor{}; + interface Area: NumericalFunctor{}; + interface Length: NumericalFunctor{}; + interface MultiConnection: NumericalFunctor{}; + + interface Predicate: Functor{ + boolean IsSatisfy(in long thEntityId); + }; + + interface FreeBorders: Predicate{}; + + interface Comparator: Predicate{ + void SetMargin(in double theValue); + void SetNumFunctor(in NumericalFunctor theFunct); + }; + + interface LessThan: Comparator{}; + interface MoreThan: Comparator{}; + interface EqualTo: Comparator{ + void SetTolerance(in double theTolerance ); + }; + + interface Logical: Predicate{}; + + interface LogicalNOT: Logical{ + void SetPredicate(in Predicate thePredicate); + }; + + interface LogicalBinary: Logical{ + void SetPredicate1(in Predicate thePredicate); + void SetPredicate2(in Predicate thePredicate); + }; + + interface LogicalAND: LogicalBinary{}; + interface LogicalOR: LogicalBinary{}; + interface Filter: SALOME::GenericObj{ + void SetPredicate( in Predicate thePredicate ); + long_array GetElementsId( in SMESH_Mesh theMesh ); + }; + + interface FilterManager: SALOME::GenericObj{ + MinimumAngle CreateMinimumAngle(); + AspectRatio CreateAspectRatio(); + Warping CreateWarping(); + Taper CreateTaper(); + Skew CreateSkew(); + Area CreateArea(); + Length CreateLength(); + MultiConnection CreateMultiConnection(); + + FreeBorders CreateFreeBorders(); + + LessThan CreateLessThan(); + MoreThan CreateMoreThan(); + EqualTo CreateEqualTo(); + + LogicalNOT CreateLogicalNOT(); + LogicalAND CreateLogicalAND(); + LogicalOR CreateLogicalOR(); + Filter CreateFilter(); + }; + +}; + +#endif diff --git a/idl/SMESH_Group.idl b/idl/SMESH_Group.idl new file mode 100644 index 000000000..9842df2f6 --- /dev/null +++ b/idl/SMESH_Group.idl @@ -0,0 +1,103 @@ +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESH_Group.idl +// Author : Sergey ANIKIN, OCC +// $Header$ + +#ifndef _SMESH_GROUP_IDL_ +#define _SMESH_GROUP_IDL_ + +#include "SALOME_Exception.idl" +#include "SALOME_GenericObj.idl" + +#include "SMESH_Mesh.idl" + +module SMESH +{ + /*! + * SMESH_Group: interface of group object + */ + interface SMESH_Group : SALOME::GenericObj + { + /*! + * Sets group name + */ + void SetName( in string name ); + + /*! + * Returns group name + */ + string GetName(); + + /*! + * Returns group type (type of elements in the group) + */ + ElementType GetType(); + + /*! + * Returns the number of elements in the group + */ + long Size(); + + /*! + * Returns true if the group does not contain any elements + */ + boolean IsEmpty(); + + /*! + * Clears the group's contents + */ + void Clear(); + + /*! + * returns true if the group contains an element with ID == + */ + boolean Contains( in long elem_id ); + + /*! + * Adds elements to the group + */ + long Add( in long_array elem_ids ); + + /*! + * Returns ID of an element at position + */ + long GetID( in long elem_index ); + + /*! + * Returns a sequence of all element IDs in the group + */ + long_array GetListOfID(); + + /*! + * Removes elements from the group + */ + long Remove( in long_array elem_ids ); + + /*! + * Returns the mesh object this group belongs to + */ + SMESH_Mesh GetMesh(); + }; +}; + + +#endif diff --git a/idl/SMESH_NetgenAlgorithm.idl b/idl/SMESH_NetgenAlgorithm.idl new file mode 100644 index 000000000..afe23ad72 --- /dev/null +++ b/idl/SMESH_NetgenAlgorithm.idl @@ -0,0 +1,45 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_NetgenAlgorithm.idl +// Author : Julia DOROVSKIKH +// $Header$ + +#ifndef _SMESH_NETGENALGORITHM_IDL_ +#define _SMESH_NETGENALGORITHM_IDL_ + +#include "SMESH_Hypothesis.idl" + +/*! + * NETGENPlugin: interfaces to NETGEN related hypotheses and algorithms + */ +module NETGENPlugin +{ + /*! + * NETGENPlugin_NETGEN_3D: interface of "Tetrahedron (Netgen)" algorithm + */ + interface NETGENPlugin_NETGEN_3D : SMESH::SMESH_3D_Algo + { + }; + +}; + +#endif diff --git a/resources/SMESH.config b/resources/SMESH.config new file mode 100644 index 000000000..ec675575a --- /dev/null +++ b/resources/SMESH.config @@ -0,0 +1,2 @@ +language=en +resources=StdMeshers:NETGENPlugin \ No newline at end of file diff --git a/resources/SMESH_Meshers.xml b/resources/SMESH_Meshers.xml new file mode 100644 index 000000000..49aae9d0d --- /dev/null +++ b/resources/SMESH_Meshers.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/SMESH_MeshersWithNETGEN.xml b/resources/SMESH_MeshersWithNETGEN.xml new file mode 100644 index 000000000..2952c9279 --- /dev/null +++ b/resources/SMESH_MeshersWithNETGEN.xml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/StdMeshers.xml b/resources/StdMeshers.xml new file mode 100644 index 000000000..49aae9d0d --- /dev/null +++ b/resources/StdMeshers.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/mesh_edit_group.png b/resources/mesh_edit_group.png new file mode 100644 index 0000000000000000000000000000000000000000..4747a66b97d30a4f9be6a1a4d6807e645fc7ff03 GIT binary patch literal 543 zcmV+)0^t3LP)R=mT z>`ZZmrCejut#+~TEG)9c!Yvl}EOvJ?SwkKSyf-ud|7QO8o^n?vLS|bJPs?`zZo}*W z@bI*(3g27xWyB4)=R<~n?!jG|2m)k~Bj6+Cv9_J=ZX~+980yo97lOq#@u#sdYkDnOl*U7uzo^^Fwbdw3aecplQ~d<9_i zICwRmHhsWUJU~3h7tis<->ezmt`7M-t9F;ov*-95$DJMkY0_i+pb5|{>NWkX%B9O} z3*ioh=x$`la_}y~uW1TlelL_7Dqo+=EnW(&OS30C?|_o&S9Kc`v2?HsXf@Z&Y|fgp h#+kC9i^jS*djn1T4eyPjt^NQ2002ovPDHLkV1fx@@FV~L literal 0 HcmV?d00001 diff --git a/resources/mesh_free_edges.png b/resources/mesh_free_edges.png new file mode 100755 index 0000000000000000000000000000000000000000..5813e11e6544dc6e0178d9c93f540a616d837134 GIT binary patch literal 489 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VOS+@4BLl<6zM9{GlYxANWRD>fq}8a)5S5QVouVZ|Nrfo zO&J{+3}WL4Gx*1v=*7#zp&(YmnA4V(@h4sFnnMFak_(^ngv431czmK~ zuRC~jiqqDA6O({i6HNt3Jn{iIFcS4 zi)3)L-8eOscdJp5(Rl_Yj>8TDy?HOTd8$i_#GVc0iP*i5b#*r*Q-`2!qVjH`v=?7r z-{5`t;6cKJgog~54HyI*Bu=u)9^g5g#-Yxx&dkj1Y(L?zq#D0~0}HQ9x#S50N5+Gm zGBz^u4R78n9G(+1ciEvQj7%J>8yC!Q{${r6G>a>XBufR$yy~A-r3sh0fyS{lEs_(n zJh73p7^pi%e-U#7gVKxC8RZA{SgM4lpH2Y!=EGF8s|D8`l^I0RT4aDuh=}Dl=e4lI ziRnq~mm5b|8JId&d=hvQy9LbVSl_td&6nrb<&)mD0L?m-sc_=xrGF^0{P4g Yt=b*-KOWv&4vZ@XPgg&ebxsLQ0EKg`2mk;8 literal 0 HcmV?d00001 diff --git a/resources/mesh_make_group.png b/resources/mesh_make_group.png new file mode 100644 index 0000000000000000000000000000000000000000..19ba2e66eaaf380a718f336b6145601380036e2e GIT binary patch literal 432 zcmV;h0Z;ykP)((cdl$S3t@!YVSZgvg3x<#>KVd+Xa#4z9|d96>j-?T%} z?c*ZXF_wUZs(a}nPYT$MO8fRM3GFv+grDdDH=*hpLe+ir$hPZNyShvwm3Y#&!Vn6`Pf5z&kV+f{WmAO_o1tQ?<6YicC0Ee0000>fq^mG)5S5QVouVZ|Nrfo zO&J{+3}c%i>G|(CBZ!%ise?6^VfMlU35hD#92yvsT=<+PBwk-{Y;Y&K zmRIjt?DE!yoby>37+bD72soIDND6FXP-rmVxpS+e*HJTsd;P*4It-FL0uB+pEQ~d6 zNyVwo&dz&#rkpWuU^rwT;Ide{s{Xqt+j^T~5$32{Q5$wiC^Q5lNxn&062Z2UFGb^w zL5Z`4g@uGggv9|99tIWxw@r@hvu3TRNpZHYw2+jDkoeX3=Da~=1A|hA!miT}ZJb;j zevckJ{K1e?&o24w$tx34HGZ(|tX4WQ7h}~llujrdQ2ub|^!3%uv*W;yu#}mYEd0!9 zLgI-y7j_0lmkXy2-Z#Z^d{NVzevrX|K``{z0VM{Jw3aJOECPPa7x#9{&E5eNPc#*< z{oK5_TMW#5_|-_m`tQ%L?Gq$5fFV#I#ZjcHk-uq!;M9zopr0Q|C}Q~&?~ literal 0 HcmV?d00001 diff --git a/resources/mesh_points.png b/resources/mesh_points.png new file mode 100644 index 0000000000000000000000000000000000000000..f0d2c78a8647dc75ce74b92d72c89e174c949f61 GIT binary patch literal 499 zcmVRB+wodZ#fnEAd5bUz4$;|C|>neU!eFzZEw>2!MZ&pG3&;r zLLCTMmfde=elxRzeU zsUUKCVfnJ`jj#pQUeh$~Mo~rYfKjY*FHnMut#yIE978iTS$~ASxeh#(BST>Oww3T| z7wEjdaH8W;j(W$;%%Sd#QIL#(?6@-qK73!xmnHM3d2==fzTiZP8|kz_px0ut7M@>s6fXvaH;fu8BUri6!c!T(!^f5RT6#Wozv_&oJ3cqCC&DSYygv=}W;m;BBB+ zRg~w}Nl_NxstSN6I*@}nRmDsV=TdG9(oPZ9TGu!!%0d7%(nwYJ{zP>n3|mIvb@K`! zauD);P7Nc3!SAn4H5tNawO*0u6(oQW!Ycpg20f_sU2-RyXfLQg!eBCp`lI?ASX)zs p`{e#27@Th#pn4DMrCb7P><1vgh>SvKf2{xj002ovPDHLkV1iRA*X;lR literal 0 HcmV?d00001 diff --git a/resources/mesh_tree_group.png b/resources/mesh_tree_group.png new file mode 100644 index 0000000000000000000000000000000000000000..cfcfc687f397eebeaea38b740f9eef8ba18c79f0 GIT binary patch literal 411 zcmV;M0c8G(P)h*kgq0VqjC zK~#90g_Au_!$1&)zlkCg(WPWlrCYg8atca%sNHY?8oC@HC2~cdGRJUhWf+F|N70b=!HX%C&%=IjH~u002ovPDHLk FV1j0Ws9OL4 literal 0 HcmV?d00001 diff --git a/resources/mesh_tree_importedmesh.png b/resources/mesh_tree_importedmesh.png new file mode 100644 index 0000000000000000000000000000000000000000..0c37d0a7ec42c925da869172f040469d614828e7 GIT binary patch literal 912 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh3?wzC-F?i!z|0Wf6XFWwGW=)Q+H&nbkRAo2 zAuz&1Ann3uKVTMMDhcun{?G7qyMY&wXY1+W7*cU7^&B@Bg8~Qhg_+;?7q5HTE+i + +#include +#include +#include +#include +#include +#include + +#include "SMDS_Mesh.hxx" +#include "SMDS_Iterator.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" + +#include "SMESH_Controls.hxx" + +/* + AUXILIARY METHODS +*/ + +static inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 ) +{ + return gp_Vec( P1 - P2 ).Angle( gp_Vec( P3 - P2 ) ); +} + +static inline double getArea( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 ) +{ + gp_Vec aVec1( P2 - P1 ); + gp_Vec aVec2( P3 - P1 ); + return ( aVec1 ^ aVec2 ).Magnitude() * 0.5; +} + +static inline double getArea( const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3 ) +{ + return getArea( P1.XYZ(), P2.XYZ(), P3.XYZ() ); +} + +static inline double getDistance( const gp_XYZ& P1, const gp_XYZ& P2 ) +{ + double aDist = gp_Pnt( P1 ).Distance( gp_Pnt( P2 ) ); + return aDist; +} + +static int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId ) +{ + if ( theMesh == 0 ) + return 0; + + const SMDS_MeshElement* anEdge = theMesh->FindElement( theId ); + if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge || anEdge->NbNodes() != 2 ) + return 0; + + TColStd_MapOfInteger aMap; + + int aResult = 0; + SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator(); + if ( anIter != 0 ) + { + while( anIter->more() ) + { + const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); + if ( aNode == 0 ) + return 0; + SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator(); + while( anElemIter->more() ) + { + const SMDS_MeshElement* anElem = anElemIter->next(); + if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge ) + { + int anId = anElem->GetID(); + + if ( anIter->more() ) // i.e. first node + aMap.Add( anId ); + else if ( aMap.Contains( anId ) ) + aResult++; + } + } + } + } + + return aResult; +} + + +using namespace SMESH::Controls; + +/* + FUNCTORS +*/ + +/* + Class : NumericalFunctor + Description : Base class for numerical functors +*/ +NumericalFunctor::NumericalFunctor(): + myMesh(NULL) +{} + +void NumericalFunctor::SetMesh( SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; +} + +bool NumericalFunctor::getPoints( const int theId, + TColgp_SequenceOfXYZ& theRes ) const +{ + theRes.Clear(); + + if ( myMesh == 0 ) + return false; + + // Get nodes of the face + const SMDS_MeshElement* anElem = myMesh->FindElement( theId ); + if ( anElem == 0 || anElem->GetType() != GetType() ) + return false; + + int nbNodes = anElem->NbNodes(); + + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); + if ( anIter != 0 ) + { + while( anIter->more() ) + { + const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); + if ( aNode != 0 ) + theRes.Append( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) ); + } + } + + return true; +} + + +/* + Class : MinimumAngle + Description : Functor for calculation of minimum angle +*/ +double MinimumAngle::GetValue( long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) + return 0; + + double aMin; + + if ( P.Length() == 3 ) + { + double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) ); + double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); + double A2 = getAngle( P( 2 ), P( 3 ), P( 1 ) ); + + aMin = Min( A0, Min( A1, A2 ) ); + } + else + { + double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) ); + double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); + double A2 = getAngle( P( 2 ), P( 3 ), P( 4 ) ); + double A3 = getAngle( P( 3 ), P( 4 ), P( 1 ) ); + + aMin = Min( Min( A0, A1 ), Min( A2, A3 ) ); + } + + return aMin * 180 / PI; +} + +SMDSAbs_ElementType MinimumAngle::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : AspectRatio + Description : Functor for calculating aspect ratio +*/ +double AspectRatio::GetValue( long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) + return 0; + + int nbNodes = P.Length(); + + // Compute lengths of the sides + + double aLen[ nbNodes ]; + for ( int i = 0; i < nbNodes - 1; i++ ) + aLen[ i ] = getDistance( P( i + 1 ), P( i + 2 ) ); + aLen[ nbNodes - 1 ] = getDistance( P( 1 ), P( nbNodes ) ); + + // Compute aspect ratio + + if ( nbNodes == 3 ) + { + double aMaxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) ); + double anArea = getArea( P( 1 ), P( 2 ), P( 3 ) ); + static double aCoef = sqrt( 3. ) / 4; + + return anArea != 0 ? aCoef * aMaxLen * aMaxLen / anArea : 0; + } + else + { + double aMaxLen = Max( Max( aLen[ 0 ], aLen[ 1 ] ), Max( aLen[ 2 ], aLen[ 3 ] ) ); + double aMinLen = Min( Min( aLen[ 0 ], aLen[ 1 ] ), Min( aLen[ 2 ], aLen[ 3 ] ) ); + + return aMinLen != 0 ? aMaxLen / aMinLen : 0; + } +} + +SMDSAbs_ElementType AspectRatio::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : Warping + Description : Functor for calculating warping +*/ +double Warping::GetValue( long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 4 ) + return 0; + + gp_XYZ G = ( P( 1 ) + P( 2 ) + P( 3 ) + P( 4 ) ) / 4; + + double A1 = ComputeA( P( 1 ), P( 2 ), P( 3 ), G ); + double A2 = ComputeA( P( 2 ), P( 3 ), P( 4 ), G ); + double A3 = ComputeA( P( 3 ), P( 4 ), P( 1 ), G ); + double A4 = ComputeA( P( 4 ), P( 1 ), P( 2 ), G ); + + return Max( Max( A1, A2 ), Max( A3, A4 ) ); +} + +double Warping::ComputeA( const gp_XYZ& thePnt1, + const gp_XYZ& thePnt2, + const gp_XYZ& thePnt3, + const gp_XYZ& theG ) const +{ + double aLen1 = gp_Pnt( thePnt1 ).Distance( gp_Pnt( thePnt2 ) ); + double aLen2 = gp_Pnt( thePnt2 ).Distance( gp_Pnt( thePnt3 ) ); + double L = Min( aLen1, aLen2 ) * 0.5; + + gp_XYZ GI = ( thePnt2 - thePnt1 ) / 2. - theG; + gp_XYZ GJ = ( thePnt3 - thePnt2 ) / 2. - theG; + gp_XYZ N = GI.Crossed( GJ ); + N.Normalize(); + + double H = gp_Vec( thePnt2 - theG ).Dot( gp_Vec( N ) ); + return asin( fabs( H / L ) ) * 180 / PI; +} + +SMDSAbs_ElementType Warping::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : Taper + Description : Functor for calculating taper +*/ +double Taper::GetValue( long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 4 ) + return 0; + + // Compute taper + double J1 = getArea( P( 4 ), P( 1 ), P( 2 ) ) / 2; + double J2 = getArea( P( 3 ), P( 1 ), P( 2 ) ) / 2; + double J3 = getArea( P( 2 ), P( 3 ), P( 4 ) ) / 2; + double J4 = getArea( P( 3 ), P( 4 ), P( 1 ) ) / 2; + + double JA = 0.25 * ( J1 + J2 + J3 + J4 ); + + double T1 = fabs( ( J1 - JA ) / JA ); + double T2 = fabs( ( J2 - JA ) / JA ); + double T3 = fabs( ( J3 - JA ) / JA ); + double T4 = fabs( ( J4 - JA ) / JA ); + + return Max( Max( T1, T2 ), Max( T3, T4 ) ); +} + +SMDSAbs_ElementType Taper::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : Skew + Description : Functor for calculating skew in degrees +*/ +static inline double skewAngle( const gp_XYZ& p1, const gp_XYZ& p2, const gp_XYZ& p3 ) +{ + gp_XYZ p12 = ( p2 + p1 ) / 2; + gp_XYZ p23 = ( p3 + p2 ) / 2; + gp_XYZ p31 = ( p3 + p1 ) / 2; + + return gp_Vec( p31 - p2 ).Angle( p12 - p23 ); +} + +double Skew::GetValue( long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) + return 0; + + // Compute skew + static double PI2 = PI / 2; + if ( P.Length() == 3 ) + { + double A0 = fabs( PI2 - skewAngle( P( 3 ), P( 1 ), P( 2 ) ) ); + double A1 = fabs( PI2 - skewAngle( P( 1 ), P( 2 ), P( 3 ) ) ); + double A2 = fabs( PI2 - skewAngle( P( 2 ), P( 3 ), P( 1 ) ) ); + + return Max( A0, Max( A1, A2 ) ) * 180 / PI; + } + else + { + gp_XYZ p12 = ( P( 1 ) + P( 2 ) ) / 2; + gp_XYZ p23 = ( P( 2 ) + P( 3 ) ) / 2; + gp_XYZ p34 = ( P( 3 ) + P( 4 ) ) / 2; + gp_XYZ p41 = ( P( 4 ) + P( 1 ) ) / 2; + + double A = fabs( PI2 - gp_Vec( p34 - p12 ).Angle( p23 - p41 ) ); + + return A * 180 / PI; + } +} + +SMDSAbs_ElementType Skew::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : Area + Description : Functor for calculating area +*/ +double Area::GetValue( long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) + return 0; + + if ( P.Length() == 3 ) + return getArea( P( 1 ), P( 2 ), P( 3 ) ); + else + return getArea( P( 1 ), P( 2 ), P( 3 ) ) + getArea( P( 1 ), P( 3 ), P( 4 ) ); +} + +SMDSAbs_ElementType Area::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : Length + Description : Functor for calculating length off edge +*/ +double Length::GetValue( long theId ) +{ + TColgp_SequenceOfXYZ P; + return getPoints( theId, P ) && P.Length() == 2 ? getDistance( P( 1 ), P( 2 ) ) : 0; +} + +SMDSAbs_ElementType Length::GetType() const +{ + return SMDSAbs_Edge; +} + + +/* + Class : MultiConnection + Description : Functor for calculating number of faces conneted to the edge +*/ +double MultiConnection::GetValue( long theId ) +{ + return getNbMultiConnection( myMesh, theId ); +} + +SMDSAbs_ElementType MultiConnection::GetType() const +{ + return SMDSAbs_Edge; +} + + +/* + PREDICATES +*/ + +/* + Class : FreeBorders + Description : Predicate for free borders +*/ + +FreeBorders::FreeBorders() +{ + myMesh = 0; +} + +void FreeBorders::SetMesh( SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; +} + +bool FreeBorders::IsSatisfy( long theId ) +{ + return getNbMultiConnection( myMesh, theId ) == 1; +} + +SMDSAbs_ElementType FreeBorders::GetType() const +{ + return SMDSAbs_Edge; +} + + +/* + Class : FreeEdges + Description : Predicate for free Edges +*/ +FreeEdges::FreeEdges() +{ + myMesh = 0; +} + +void FreeEdges::SetMesh( SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; +} + +bool FreeEdges::IsSatisfy( long theId ) +{ + return getNbMultiConnection( myMesh, theId ) == 1; +} + +SMDSAbs_ElementType FreeEdges::GetType() const +{ + return SMDSAbs_Face; +} + +FreeEdges::Border::Border(long thePntId1, long thePntId2){ + PntId[0] = thePntId1; PntId[1] = thePntId2; + if(thePntId1 > thePntId2){ + PntId[1] = thePntId1; PntId[0] = thePntId2; + } +} + +//bool operator<(const FreeEdges::Border& x, const FreeEdges::Border& y){ +// if(x.PntId[0] < y.PntId[0]) return true; +// if(x.PntId[0] == y.PntId[0]) +// if(x.PntId[1] < y.PntId[1]) return true; +// return false; +//} + +namespace SMESH{ + namespace Controls{ + struct EdgeBorder: public FreeEdges::Border{ + long ElemId; + EdgeBorder(long theElemId, long thePntId1, long thePntId2): + FreeEdges::Border(thePntId1,thePntId2), + ElemId(theElemId) + {} + }; + + bool operator<(const FreeEdges::Border& x, const FreeEdges::Border& y){ + if(x.PntId[0] < y.PntId[0]) return true; + if(x.PntId[0] == y.PntId[0]) + if(x.PntId[1] < y.PntId[1]) return true; + return false; + } + + typedef std::set EdgeBorderS; + + inline void UpdateBorders(const EdgeBorder& theBorder, + EdgeBorderS& theRegistry, + EdgeBorderS& theContainer) + { + if(theRegistry.find(theBorder) == theRegistry.end()){ + theRegistry.insert(theBorder); + theContainer.insert(theBorder); + }else{ + theContainer.erase(theBorder); + } + } + + } +} + +void FreeEdges::GetBoreders(Borders& theBorders) +{ + EdgeBorderS aRegistry; + EdgeBorderS aContainer; + SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); + for(; anIter->more(); ){ + const SMDS_MeshFace* anElem = anIter->next(); + long anElemId = anElem->GetID(); + SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); + long aNodeId[2]; + const SMDS_MeshElement* aNode; + if(aNodesIter->more()){ + aNode = aNodesIter->next(); + aNodeId[0] = aNodeId[1] = aNode->GetID(); + } + for(; aNodesIter->more(); ){ + aNode = aNodesIter->next(); + EdgeBorder aBorder(anElemId,aNodeId[1],aNode->GetID()); + aNodeId[1] = aNode->GetID(); + //std::cout<SetMesh( theMesh ); +} + +void Comparator::SetMargin( double theValue ) +{ + myMargin = theValue; +} + +void Comparator::SetNumFunctor( NumericalFunctorPtr theFunct ) +{ + myFunctor = theFunct; +} + +SMDSAbs_ElementType Comparator::GetType() const +{ + return myFunctor ? myFunctor->GetType() : SMDSAbs_All; +} + + +/* + Class : LessThan + Description : Comparator "<" +*/ +bool LessThan::IsSatisfy( long theId ) +{ + return myFunctor && myFunctor->GetValue( theId ) < myMargin; +} + + +/* + Class : MoreThan + Description : Comparator ">" +*/ +bool MoreThan::IsSatisfy( long theId ) +{ + return myFunctor && myFunctor->GetValue( theId ) > myMargin; +} + + +/* + Class : EqualTo + Description : Comparator "=" +*/ +EqualTo::EqualTo(): + myToler(Precision::Confusion()) +{} + +bool EqualTo::IsSatisfy( long theId ) +{ + return myFunctor && fabs( myFunctor->GetValue( theId ) - myMargin ) < myToler; +} + +void EqualTo::SetTolerance( double theToler ) +{ + myToler = theToler; +} + + +/* + Class : LogicalNOT + Description : Logical NOT predicate +*/ +LogicalNOT::LogicalNOT() +{} + +LogicalNOT::~LogicalNOT() +{} + +bool LogicalNOT::IsSatisfy( long theId ) +{ + return myPredicate && !myPredicate->IsSatisfy( theId ); +} + +void LogicalNOT::SetMesh( SMDS_Mesh* theMesh ) +{ + if ( myPredicate ) + myPredicate->SetMesh( theMesh ); +} + +void LogicalNOT::SetPredicate( PredicatePtr thePred ) +{ + myPredicate = thePred; +} + +SMDSAbs_ElementType LogicalNOT::GetType() const +{ + return myPredicate ? myPredicate->GetType() : SMDSAbs_All; +} + + +/* + Class : LogicalBinary + Description : Base class for binary logical predicate +*/ +LogicalBinary::LogicalBinary() +{} + +LogicalBinary::~LogicalBinary() +{} + +void LogicalBinary::SetMesh( SMDS_Mesh* theMesh ) +{ + if ( myPredicate1 ) + myPredicate1->SetMesh( theMesh ); + + if ( myPredicate2 ) + myPredicate2->SetMesh( theMesh ); +} + +void LogicalBinary::SetPredicate1( PredicatePtr thePredicate ) +{ + myPredicate1 = thePredicate; +} + +void LogicalBinary::SetPredicate2( PredicatePtr thePredicate ) +{ + myPredicate2 = thePredicate; +} + +SMDSAbs_ElementType LogicalBinary::GetType() const +{ + if ( !myPredicate1 || !myPredicate2 ) + return SMDSAbs_All; + + SMDSAbs_ElementType aType1 = myPredicate1->GetType(); + SMDSAbs_ElementType aType2 = myPredicate2->GetType(); + + return aType1 == aType2 ? aType1 : SMDSAbs_All; +} + + +/* + Class : LogicalAND + Description : Logical AND +*/ +bool LogicalAND::IsSatisfy( long theId ) +{ + return + myPredicate1 && + myPredicate2 && + myPredicate1->IsSatisfy( theId ) && + myPredicate2->IsSatisfy( theId ); +} + + +/* + Class : LogicalOR + Description : Logical OR +*/ +bool LogicalOR::IsSatisfy( long theId ) +{ + return + myPredicate1 && + myPredicate2 && + myPredicate1->IsSatisfy( theId ) || + myPredicate2->IsSatisfy( theId ); +} + + +/* + FILTER +*/ + +Filter::Filter() +{} + +Filter::~Filter() +{} + +void Filter::SetPredicate( PredicatePtr thePredicate ) +{ + myPredicate = thePredicate; +} + +Filter::TIdSequence +Filter::GetElementsId( SMDS_Mesh* theMesh ) +{ + TIdSequence aSequence; + if ( !theMesh || !myPredicate ) return aSequence; + + myPredicate->SetMesh( theMesh ); + + SMDSAbs_ElementType aType = myPredicate->GetType(); + switch(aType){ + case SMDSAbs_Edge:{ + SMDS_EdgeIteratorPtr anIter = theMesh->edgesIterator(); + if ( anIter != 0 ) { + while( anIter->more() ) { + const SMDS_MeshElement* anElem = anIter->next(); + long anId = anElem->GetID(); + if ( myPredicate->IsSatisfy( anId ) ) + aSequence.push_back( anId ); + } + } + } + case SMDSAbs_Face:{ + SMDS_FaceIteratorPtr anIter = theMesh->facesIterator(); + if ( anIter != 0 ) { + while( anIter->more() ) { + const SMDS_MeshElement* anElem = anIter->next(); + long anId = anElem->GetID(); + if ( myPredicate->IsSatisfy( anId ) ) + aSequence.push_back( anId ); + } + } + } + } + return aSequence; +} diff --git a/src/Controls/SMESH_Controls.hxx b/src/Controls/SMESH_Controls.hxx new file mode 100644 index 000000000..1c771eb12 --- /dev/null +++ b/src/Controls/SMESH_Controls.hxx @@ -0,0 +1,340 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _SMESH_CONTROLS_HXX_ +#define _SMESH_CONTROLS_HXX_ + +#include +#include +#include +#include "SMDSAbs_ElementType.hxx" + +class SMDS_Mesh; +class gp_Pnt; +class gp_XYZ; +class TColgp_SequenceOfXYZ; + +namespace SMESH{ + namespace Controls{ + class Functor{ + public: + ~Functor(){} + virtual void SetMesh( SMDS_Mesh* theMesh ) = 0; + }; + typedef boost::shared_ptr FunctorPtr; + + class NumericalFunctor: public virtual Functor{ + public: + NumericalFunctor(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual double GetValue( long theElementId ) = 0; + virtual SMDSAbs_ElementType GetType() const = 0; + + protected: + bool getPoints( const int theId, + TColgp_SequenceOfXYZ& theRes ) const; + protected: + SMDS_Mesh* myMesh; + }; + typedef boost::shared_ptr NumericalFunctorPtr; + + + /* + Class : SMESH_MinimumAngle + Description : Functor for calculation of minimum angle + */ + class MinimumAngle: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : AspectRatio + Description : Functor for calculating aspect ratio + */ + class AspectRatio: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : Warping + Description : Functor for calculating warping + */ + class Warping: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + + private: + double ComputeA( const gp_XYZ&, const gp_XYZ&, + const gp_XYZ&, const gp_XYZ& ) const; + }; + + + /* + Class : Taper + Description : Functor for calculating taper + */ + class Taper: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : Skew + Description : Functor for calculating skew in degrees + */ + class Skew: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : Area + Description : Functor for calculating area + */ + class Area: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : Length + Description : Functor for calculating length of edge + */ + class Length: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : MultiConnection + Description : Functor for calculating number of faces conneted to the edge + */ + class MultiConnection: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + PREDICATES + */ + /* + Class : Predicate + Description : Base class for all predicates + */ + class Predicate: public virtual Functor{ + public: + virtual bool IsSatisfy( long theElementId ) = 0; + virtual SMDSAbs_ElementType GetType() const = 0; + }; + typedef boost::shared_ptr PredicatePtr; + + + + /* + Class : FreeBorders + Description : Predicate for free borders + */ + class FreeBorders: public virtual Predicate{ + public: + FreeBorders(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + + protected: + SMDS_Mesh* myMesh; + }; + + + /* + Class : FreeEdges + Description : Predicate for free Edges + */ + class FreeEdges: public virtual Predicate{ + public: + FreeEdges(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + struct Border{ + long PntId[2]; + Border(long thePntId1, long thePntId2); + }; + typedef long TElemId; + typedef std::map Borders; + void GetBoreders(Borders& theBorders); + + protected: + SMDS_Mesh* myMesh; + }; + typedef boost::shared_ptr FreeEdgesPtr; + + + /* + Class : Comparator + Description : Base class for comparators + */ + class Comparator: public virtual Predicate{ + public: + Comparator(); + virtual ~Comparator(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMargin(double theValue); + virtual void SetNumFunctor(NumericalFunctorPtr theFunct); + virtual bool IsSatisfy( long theElementId ) = 0; + virtual SMDSAbs_ElementType GetType() const; + + protected: + double myMargin; + NumericalFunctorPtr myFunctor; + }; + typedef boost::shared_ptr ComparatorPtr; + + + /* + Class : LessThan + Description : Comparator "<" + */ + class LessThan: public virtual Comparator{ + public: + virtual bool IsSatisfy( long theElementId ); + }; + + + /* + Class : MoreThan + Description : Comparator ">" + */ + class MoreThan: public virtual Comparator{ + public: + virtual bool IsSatisfy( long theElementId ); + }; + + + /* + Class : EqualTo + Description : Comparator "=" + */ + class EqualTo: public virtual Comparator{ + public: + EqualTo(); + virtual bool IsSatisfy( long theElementId ); + virtual void SetTolerance( double theTol ); + + private: + double myToler; + }; + typedef boost::shared_ptr EqualToPtr; + + + /* + Class : LogicalNOT + Description : Logical NOT predicate + */ + class LogicalNOT: public virtual Predicate{ + public: + LogicalNOT(); + virtual ~LogicalNOT(); + virtual bool IsSatisfy( long theElementId ); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetPredicate(PredicatePtr thePred); + virtual SMDSAbs_ElementType GetType() const; + + private: + PredicatePtr myPredicate; + }; + typedef boost::shared_ptr LogicalNOTPtr; + + + /* + Class : LogicalBinary + Description : Base class for binary logical predicate + */ + class LogicalBinary: public virtual Predicate{ + public: + LogicalBinary(); + virtual ~LogicalBinary(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetPredicate1(PredicatePtr thePred); + virtual void SetPredicate2(PredicatePtr thePred); + virtual SMDSAbs_ElementType GetType() const; + + protected: + PredicatePtr myPredicate1; + PredicatePtr myPredicate2; + }; + typedef boost::shared_ptr LogicalBinaryPtr; + + + /* + Class : LogicalAND + Description : Logical AND + */ + class LogicalAND: public virtual LogicalBinary{ + public: + virtual bool IsSatisfy( long theElementId ); + }; + + + /* + Class : LogicalOR + Description : Logical OR + */ + class LogicalOR: public virtual LogicalBinary{ + public: + virtual bool IsSatisfy( long theElementId ); + }; + + + /* + FILTER + */ + class Filter{ + public: + Filter(); + virtual ~Filter(); + virtual void SetPredicate(PredicatePtr thePred); + typedef std::vector TIdSequence; + virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh ); + + protected: + PredicatePtr myPredicate; + }; + }; +}; + + +#endif diff --git a/src/Driver/Driver_Document.cxx b/src/Driver/Driver_Document.cxx new file mode 100644 index 000000000..159c1a85a --- /dev/null +++ b/src/Driver/Driver_Document.cxx @@ -0,0 +1,36 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "Driver_Document.h" + +Driver_Document::Driver_Document(): + myDocument(NULL) +{} + + +void Driver_Document::SetFile(const std::string& theFileName) +{ + myFile = theFileName; +} + + +void Driver_Document::SetDocument(SMESHDS_Document * theDocument) +{ + myDocument = theDocument; +} diff --git a/src/Driver/Driver_Document.h b/src/Driver/Driver_Document.h new file mode 100644 index 000000000..8d4ff5a68 --- /dev/null +++ b/src/Driver/Driver_Document.h @@ -0,0 +1,44 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _INCLUDE_DRIVER_DOCUMENT +#define _INCLUDE_DRIVER_DOCUMENT + +#include + +class SMESHDS_Document; + +class Driver_Document +{ + public: + Driver_Document(); + virtual ~Driver_Document(){} + + virtual void Perform() = 0; + void SetFile(const std::string& theFileName); + void SetDocument(SMESHDS_Document *theDocument); + + protected: + SMESHDS_Document * myDocument; + std::string myFile; + +}; + + +#endif diff --git a/src/Driver/Driver_Mesh.cxx b/src/Driver/Driver_Mesh.cxx new file mode 100644 index 000000000..f656bdd5d --- /dev/null +++ b/src/Driver/Driver_Mesh.cxx @@ -0,0 +1,46 @@ +// SMESH Driver : implementaion of driver for reading and writing +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Mesh_Reader.cxx +// Module : SMESH + +#include "Driver_Mesh.h" + +using namespace std; + +Driver_Mesh::Driver_Mesh(): + myFile(""), + myMeshId(-1) +{} + + +void Driver_Mesh::SetMeshId(int theMeshId) +{ + myMeshId = theMeshId; +} + + +void Driver_Mesh::SetFile(const std::string& theFileName) +{ + myFile = theFileName; +} diff --git a/src/Driver/Driver_Mesh.h b/src/Driver/Driver_Mesh.h new file mode 100644 index 000000000..0bfac0cd8 --- /dev/null +++ b/src/Driver/Driver_Mesh.h @@ -0,0 +1,57 @@ +// SMESH Driver : implementaion of driver for reading and writing +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : Mesh_Reader.h +// Module : SMESH + +#ifndef _INCLUDE_DRIVER_MESH +#define _INCLUDE_DRIVER_MESH + +#include + +class Driver_Mesh +{ + public: + Driver_Mesh(); + virtual ~Driver_Mesh(){} + + enum Status { + DRS_OK, + DRS_EMPTY, // a file contains no mesh with the given name + DRS_WARN_RENUMBER, // a file has overlapped ranges of element numbers, + // so the numbers from the file are ignored + DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data + DRS_FAIL // general failure (exception etc.) + }; + + virtual Status Perform() = 0; + void SetMeshId(int theMeshId); + void SetFile(const std::string& theFileName); + + protected: + std::string myFile; + int myMeshId; + +}; + +#endif diff --git a/src/Driver/Driver_SMDS_Mesh.cxx b/src/Driver/Driver_SMDS_Mesh.cxx new file mode 100644 index 000000000..dae030df0 --- /dev/null +++ b/src/Driver/Driver_SMDS_Mesh.cxx @@ -0,0 +1,31 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "Driver_SMDS_Mesh.h" + +using namespace std; + +Driver_SMDS_Mesh::Driver_SMDS_Mesh(): + myMesh(NULL) +{} + +void Driver_SMDS_Mesh::SetMesh(SMDS_Mesh *theMesh) +{ + myMesh = theMesh; +} diff --git a/src/Driver/Driver_SMDS_Mesh.h b/src/Driver/Driver_SMDS_Mesh.h new file mode 100644 index 000000000..1ea37562d --- /dev/null +++ b/src/Driver/Driver_SMDS_Mesh.h @@ -0,0 +1,38 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _INCLUDE_DRIVER_SMDS_MESH +#define _INCLUDE_DRIVER_SMDS_MESH + +#include "Driver_Mesh.h" + +class SMDS_Mesh; + +class Driver_SMDS_Mesh: public Driver_Mesh +{ + public: + Driver_SMDS_Mesh(); + void SetMesh(SMDS_Mesh *theMesh); + + protected: + SMDS_Mesh *myMesh; + +}; + +#endif diff --git a/src/Driver/Driver_SMESHDS_Mesh.cxx b/src/Driver/Driver_SMESHDS_Mesh.cxx new file mode 100644 index 000000000..2bf88277d --- /dev/null +++ b/src/Driver/Driver_SMESHDS_Mesh.cxx @@ -0,0 +1,31 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "Driver_SMESHDS_Mesh.h" + +using namespace std; + +Driver_SMESHDS_Mesh::Driver_SMESHDS_Mesh(): + myMesh(NULL) +{} + +void Driver_SMESHDS_Mesh::SetMesh(SMESHDS_Mesh *theMesh) +{ + myMesh = theMesh; +} diff --git a/src/Driver/Driver_SMESHDS_Mesh.h b/src/Driver/Driver_SMESHDS_Mesh.h new file mode 100644 index 000000000..b401dbd1c --- /dev/null +++ b/src/Driver/Driver_SMESHDS_Mesh.h @@ -0,0 +1,38 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _INCLUDE_DRIVER_SMESHDS_MESH +#define _INCLUDE_DRIVER_SMESHDS_MESH + +#include "Driver_Mesh.h" + +class SMESHDS_Mesh; + +class Driver_SMESHDS_Mesh: public Driver_Mesh +{ + public: + Driver_SMESHDS_Mesh(); + void SetMesh(SMESHDS_Mesh *theMesh); + + protected: + SMESHDS_Mesh *myMesh; + +}; + +#endif diff --git a/src/DriverDAT/DAT_Test.cxx b/src/DriverDAT/DAT_Test.cxx new file mode 100644 index 000000000..a36b4dd10 --- /dev/null +++ b/src/DriverDAT/DAT_Test.cxx @@ -0,0 +1,28 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "DriverDAT_R_SMDS_Mesh.h" +#include "DriverDAT_W_SMDS_Mesh.h" + +int main(int argc, char** argv) +{ + DriverDAT_R_SMDS_Mesh aR; + DriverDAT_W_SMDS_Mesh aW; + return 1; +} diff --git a/src/DriverMED/DriverMED_Family.cxx b/src/DriverMED/DriverMED_Family.cxx new file mode 100644 index 000000000..ee1123ccd --- /dev/null +++ b/src/DriverMED/DriverMED_Family.cxx @@ -0,0 +1,367 @@ +// SMESH DriverMED : tool to split groups on families +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : DriverMED_Family.cxx +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +#include "DriverMED_Family.h" +#include + +//============================================================================= +/*! + * Split each group from list on some parts (families) + * on the basis of the elements membership in other groups from this list. + * Resulting families have no common elements. + */ +//============================================================================= +list DriverMED_Family::MakeFamilies + (const map & theSubMeshes, + const list& theGroups, + const bool doGroupOfNodes, + const bool doGroupOfEdges, + const bool doGroupOfFaces, + const bool doGroupOfVolumes) +{ + list aFamilies; + + string anAllNodesGroupName = "Group_Of_All_Nodes"; + string anAllEdgesGroupName = "Group_Of_All_Edges"; + string anAllFacesGroupName = "Group_Of_All_Faces"; + string anAllVolumesGroupName = "Group_Of_All_Volumes"; + + // Reserve four ids for families of free elements + // (1 - nodes, -1 - edges, -2 - faces, -3 - volumes). + // 'Free' means here not belonging to any group. + int aNodeFamId = FIRST_NODE_FAMILY; + int aElemFamId = FIRST_ELEM_FAMILY; + + // Process sub-meshes + map::const_iterator aSMIter = theSubMeshes.begin(); + for (; aSMIter != theSubMeshes.end(); aSMIter++) + { + list aSMFams = SplitByType((*aSMIter).second, (*aSMIter).first); + list::iterator aSMFamsIter = aSMFams.begin(); + for (; aSMFamsIter != aSMFams.end(); aSMFamsIter++) + { + DriverMED_FamilyPtr aFam2 = (*aSMFamsIter); + + list::iterator aFamsIter = aFamilies.begin(); + while (aFamsIter != aFamilies.end()) + { + DriverMED_FamilyPtr aFam1 = *aFamsIter; + list::iterator aCurrIter = aFamsIter++; + if (aFam1->myType == aFam2->myType) + { + DriverMED_FamilyPtr aCommon (new DriverMED_Family); + aFam1->Split(aFam2, aCommon); + if (!aCommon->IsEmpty()) + { + aFamilies.push_back(aCommon); + } + if (aFam1->IsEmpty()) + { + aFamilies.erase(aCurrIter); + } + if (aFam2->IsEmpty()) break; + } + } + // The rest elements of family + if (!aFam2->IsEmpty()) + { + aFamilies.push_back(aFam2); + } + } + } + + // Process groups + list::const_iterator aGroupsIter = theGroups.begin(); + for (; aGroupsIter != theGroups.end(); aGroupsIter++) + { + DriverMED_FamilyPtr aFam2 (new DriverMED_Family); + aFam2->Init(*aGroupsIter); + + list::iterator aFamsIter = aFamilies.begin(); + while (aFamsIter != aFamilies.end()) + { + DriverMED_FamilyPtr aFam1 = *aFamsIter; + list::iterator aCurrIter = aFamsIter++; + if (aFam1->myType == aFam2->myType) + { + DriverMED_FamilyPtr aCommon (new DriverMED_Family); + aFam1->Split(aFam2, aCommon); + if (!aCommon->IsEmpty()) + { + aFamilies.push_back(aCommon); + } + if (aFam1->IsEmpty()) + { + aFamilies.erase(aCurrIter); + } + if (aFam2->IsEmpty()) break; + } + } + // The rest elements of group + if (!aFam2->IsEmpty()) + { + aFamilies.push_back(aFam2); + } + } + + list::iterator aFamsIter = aFamilies.begin(); + for (; aFamsIter != aFamilies.end(); aFamsIter++) + { + DriverMED_FamilyPtr aFam = *aFamsIter; + if (aFam->myType == SMDSAbs_Node) { + aFam->SetId(aNodeFamId++); + if (doGroupOfNodes) aFam->myGroupNames.insert(anAllNodesGroupName); + } + else { + aFam->SetId(aElemFamId--); + if (aFam->myType == SMDSAbs_Edge) { + if (doGroupOfEdges) aFam->myGroupNames.insert(anAllEdgesGroupName); + } + else if (aFam->myType == SMDSAbs_Face) { + if (doGroupOfFaces) aFam->myGroupNames.insert(anAllFacesGroupName); + } + else if (aFam->myType == SMDSAbs_Volume) { + if (doGroupOfVolumes) aFam->myGroupNames.insert(anAllVolumesGroupName); + } + } + } + + // Create families for elements, not belonging to any group + if (doGroupOfNodes) + { + DriverMED_FamilyPtr aFreeNodesFam (new DriverMED_Family); + aFreeNodesFam->SetId(REST_NODES_FAMILY); + aFreeNodesFam->myType = SMDSAbs_Node; + aFreeNodesFam->myGroupNames.insert(anAllNodesGroupName); + aFamilies.push_back(aFreeNodesFam); + } + + if (doGroupOfEdges) + { + DriverMED_FamilyPtr aFreeEdgesFam (new DriverMED_Family); + aFreeEdgesFam->SetId(REST_EDGES_FAMILY); + aFreeEdgesFam->myType = SMDSAbs_Edge; + aFreeEdgesFam->myGroupNames.insert(anAllEdgesGroupName); + aFamilies.push_back(aFreeEdgesFam); + } + + if (doGroupOfFaces) + { + DriverMED_FamilyPtr aFreeFacesFam (new DriverMED_Family); + aFreeFacesFam->SetId(REST_FACES_FAMILY); + aFreeFacesFam->myType = SMDSAbs_Face; + aFreeFacesFam->myGroupNames.insert(anAllFacesGroupName); + aFamilies.push_back(aFreeFacesFam); + } + + if (doGroupOfVolumes) + { + DriverMED_FamilyPtr aFreeVolumesFam (new DriverMED_Family); + aFreeVolumesFam->SetId(REST_VOLUMES_FAMILY); + aFreeVolumesFam->myType = SMDSAbs_Volume; + aFreeVolumesFam->myGroupNames.insert(anAllVolumesGroupName); + aFamilies.push_back(aFreeVolumesFam); + } + + DriverMED_FamilyPtr aNullFam (new DriverMED_Family); + aNullFam->SetId(0); + aNullFam->myType = SMDSAbs_All; + aFamilies.push_back(aNullFam); + + return aFamilies; +} + +//============================================================================= +/*! + * Create TFamilyInfo for this family + */ +//============================================================================= +MEDA::PFamilyInfo DriverMED_Family::GetFamilyInfo + (const MEDA::PMeshInfo& theMeshInfo) const +{ + string aValue; + ostringstream aStr; + aStr << myId; + aValue = aStr.str(); + MED::TStringVector anAttrDescs (1, ""); // 1 attribute with empty description, + MED::TIntVector anAttrIds (1, myId); // Id=0, + MED::TIntVector anAttrVals (1, myId); // Value=0 + + MEDA::PFamilyInfo anInfo = MEDA::TWrapper::CrFamilyInfo(theMeshInfo, + aValue, + myId, + myGroupNames, + anAttrDescs,anAttrIds,anAttrVals); + +// cout << endl; +// cout << "Groups: "; +// set::iterator aGrIter = myGroupNames.begin(); +// for (; aGrIter != myGroupNames.end(); aGrIter++) +// { +// cout << " " << *aGrIter; +// } +// cout << endl; +// +// cout << "Elements: "; +// set::iterator anIter = myElements.begin(); +// for (; anIter != myElements.end(); anIter++) +// { +// cout << " " << (*anIter)->GetID(); +// } +// cout << endl; + + return anInfo; +} + +//============================================================================= +/*! + * Initialize the tool by SMESHDS_Group + */ +//============================================================================= +void DriverMED_Family::Init (SMESHDS_Group* group) +{ + // Elements + myElements.clear(); + group->InitIterator(); + while (group->More()) + { + myElements.insert(group->Next()); + } + + // Type + myType = group->GetType(); + + // Groups list + myGroupNames.clear(); + myGroupNames.insert(string(group->GetStoreName())); +} + +//============================================================================= +/*! + * Split on some parts (families) + * on the basis of the elements type. + */ +//============================================================================= +list DriverMED_Family::SplitByType (SMESHDS_SubMesh* theSubMesh, + const int theId) +{ + list aFamilies; + DriverMED_FamilyPtr aNodesFamily (new DriverMED_Family); + DriverMED_FamilyPtr anEdgesFamily (new DriverMED_Family); + DriverMED_FamilyPtr aFacesFamily (new DriverMED_Family); + DriverMED_FamilyPtr aVolumesFamily (new DriverMED_Family); + + char submeshGrpName[ 30 ]; + sprintf( submeshGrpName, "SubMesh %d", theId ); + + SMDS_NodeIteratorPtr aNodesIter = theSubMesh->GetNodes(); + while (aNodesIter->more()) + { + const SMDS_MeshNode* aNode = aNodesIter->next(); + aNodesFamily->AddElement(aNode); + } + + SMDS_ElemIteratorPtr anElemsIter = theSubMesh->GetElements(); + while (anElemsIter->more()) + { + const SMDS_MeshElement* anElem = anElemsIter->next(); + switch (anElem->GetType()) + { + case SMDSAbs_Edge: + anEdgesFamily->AddElement(anElem); + break; + case SMDSAbs_Face: + aFacesFamily->AddElement(anElem); + break; + case SMDSAbs_Volume: + aVolumesFamily->AddElement(anElem); + break; + default: + break; + } + } + + if (!aNodesFamily->IsEmpty()) { + aNodesFamily->SetType(SMDSAbs_Node); + aNodesFamily->AddGroupName(submeshGrpName); + aFamilies.push_back(aNodesFamily); + } + if (!anEdgesFamily->IsEmpty()) { + anEdgesFamily->SetType(SMDSAbs_Edge); + anEdgesFamily->AddGroupName(submeshGrpName); + aFamilies.push_back(anEdgesFamily); + } + if (!aFacesFamily->IsEmpty()) { + aFacesFamily->SetType(SMDSAbs_Face); + aFacesFamily->AddGroupName(submeshGrpName); + aFamilies.push_back(aFacesFamily); + } + if (!aVolumesFamily->IsEmpty()) { + aVolumesFamily->SetType(SMDSAbs_Volume); + aVolumesFamily->AddGroupName(submeshGrpName); + aFamilies.push_back(aVolumesFamily); + } + + return aFamilies; +} + +//============================================================================= +/*! + * Remove from elements, common with , + * Remove from elements, common with , + * Create family from common elements, with combined groups list. + */ +//============================================================================= +void DriverMED_Family::Split (DriverMED_FamilyPtr by, + DriverMED_FamilyPtr common) +{ + // Elements + set::iterator anIter = by->myElements.begin(); + for (; anIter != by->myElements.end(); anIter++) + { + if (myElements.find(*anIter) != myElements.end()) + { + common->myElements.insert(*anIter); + myElements.erase(*anIter); + by->myElements.erase(*anIter); + } + } + + if (!common->IsEmpty()) + { + // Groups list + common->myGroupNames = myGroupNames; + set::iterator aGrNamesIter = by->myGroupNames.begin(); + for (; aGrNamesIter != by->myGroupNames.end(); aGrNamesIter++) + { + common->myGroupNames.insert(*aGrNamesIter); + } + + // Type + common->myType = myType; + } +} diff --git a/src/DriverMED/DriverMED_Family.h b/src/DriverMED/DriverMED_Family.h new file mode 100644 index 000000000..cca2bf075 --- /dev/null +++ b/src/DriverMED/DriverMED_Family.h @@ -0,0 +1,121 @@ +// SMESH DriverMED : tool to split groups on families +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : DriverMED_Family.hxx +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +#ifndef _INCLUDE_DRIVERMED_FAMILY +#define _INCLUDE_DRIVERMED_FAMILY + +#include "SMDS_Mesh.hxx" +#include "SMESHDS_Group.hxx" +#include "SMESHDS_SubMesh.hxx" +#include "MEDA_Wrapper.hxx" + +#include +#include + +using namespace std; + +#define REST_NODES_FAMILY 1 +#define REST_EDGES_FAMILY -1 +#define REST_FACES_FAMILY -2 +#define REST_VOLUMES_FAMILY -3 +#define FIRST_NODE_FAMILY 2 +#define FIRST_ELEM_FAMILY -4 + +class DriverMED_Family; +typedef boost::shared_ptr DriverMED_FamilyPtr; + +class DriverMED_Family +{ + public: + + // Methods for groups storing to MED + + static list MakeFamilies (const map & theSubMeshes, + const list& theGroups, + const bool doGroupOfNodes, + const bool doGroupOfEdges, + const bool doGroupOfFaces, + const bool doGroupOfVolumes); + // Split each group from list and each sub-mesh from list + // on some parts (families) on the basis of the elements membership in other groups + // from and other sub-meshes from . + // Resulting families have no common elements. + + MEDA::PFamilyInfo GetFamilyInfo (const MEDA::PMeshInfo& theMeshInfo) const; + // Create TFamilyInfo for this family + + const set& GetElements () const { return myElements; } + // Returns elements of this family + + int GetId () const { return myId; } + // Returns a family ID + + public: + + // Methods for groups reading from MED + + void AddElement (const SMDS_MeshElement* theElement) { myElements.insert(theElement); } + + void AddGroupName (string theGroupName) { myGroupNames.insert(theGroupName); } + + void SetType (const SMDSAbs_ElementType theType) { myType = theType; } + SMDSAbs_ElementType GetType () { return myType; } + + bool MemberOf (string theGroupName) const + { return (myGroupNames.find(theGroupName) != myGroupNames.end()); } + + const MED::TStringSet& GetGroupNames () const { return myGroupNames; } + + private: + void Init (SMESHDS_Group* group); + // Initialize the tool by SMESHDS_Group + + static list SplitByType (SMESHDS_SubMesh* theSubMesh, + const int theId); + // Split on some parts (families) + // on the basis of the elements type. + + void Split (DriverMED_FamilyPtr by, + DriverMED_FamilyPtr common); + // Remove from elements, common with , + // Remove from elements, common with , + // Create family from common elements, with combined groups list. + + void SetId (const int theId) { myId = theId; } + // Sets a family ID + + bool IsEmpty () const { return myElements.empty(); } + // Check, if this family has empty list of elements + + private: + int myId; + SMDSAbs_ElementType myType; + set myElements; + MED::TStringSet myGroupNames; +}; + +#endif diff --git a/src/DriverMED/MED_Test.cxx b/src/DriverMED/MED_Test.cxx new file mode 100644 index 000000000..7d6c3cd21 --- /dev/null +++ b/src/DriverMED/MED_Test.cxx @@ -0,0 +1,28 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "DriverMED_R_SMESHDS_Mesh.h" +#include "DriverMED_W_SMESHDS_Mesh.h" + +int main(int argc, char** argv) +{ + DriverMED_R_SMESHDS_Mesh aR; + DriverMED_W_SMESHDS_Mesh aW; + return 1; +} diff --git a/src/DriverUNV/UNV2411_Structure.cxx b/src/DriverUNV/UNV2411_Structure.cxx new file mode 100644 index 000000000..8425f943b --- /dev/null +++ b/src/DriverUNV/UNV2411_Structure.cxx @@ -0,0 +1,123 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include + +#include "UNV2411_Structure.hxx" +#include "UNV_Utilities.hxx" + +using namespace std; +using namespace UNV; +using namespace UNV2411; + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + +static string _label_dataset = "2411"; + +UNV2411::TRecord::TRecord(): + exp_coord_sys_num(0), + disp_coord_sys_num(0), + color(0) +{} + +void UNV2411::Read(std::ifstream& in_stream, TDataSet& theDataSet) +{ + if(!in_stream.good()) + EXCEPTION(runtime_error,"ERROR: Input file not good."); + + /* + * adjust the \p istream to our + * position + */ + if(!beginning_of_dataset(in_stream,_label_dataset)) + EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!"); + + /** + * always 3 coordinates in the UNV file, no matter + * which dimensionality libMesh is in + */ + TNodeLab aLabel; + std::string num_buf; + for(; !in_stream.eof();){ + in_stream >> aLabel ; + if(aLabel == -1){ + // end of dataset is reached + break; + } + + TRecord aRec; + in_stream>>aRec.exp_coord_sys_num; + in_stream>>aRec.disp_coord_sys_num; + in_stream>>aRec.color; + + /* + * take care of the + * floating-point data + */ + for(int d = 0; d < 3; d++){ + in_stream>>num_buf; + aRec.coord[d] = D_to_e(num_buf); + } + + theDataSet.insert(TDataSet::value_type(aLabel,aRec)); + } +} + + +void UNV2411::Write(std::ofstream& out_stream, const TDataSet& theDataSet) +{ + if(!out_stream.good()) + EXCEPTION(runtime_error,"ERROR: Output file not good."); + + /* + * Write beginning of dataset + */ + out_stream<<" -1\n"; + out_stream<<" "<<_label_dataset<<"\n"; + + TDataSet::const_iterator anIter = theDataSet.begin(); + for(; anIter != theDataSet.end(); anIter++){ + const TNodeLab& aLabel = anIter->first; + const TRecord& aRec = anIter->second; + char buf[78]; + sprintf(buf, "%10d%10d%10d%10d\n", + aLabel, + aRec.exp_coord_sys_num, + aRec.disp_coord_sys_num, + aRec.color); + out_stream< +#include + +namespace UNV2411{ + + struct TRecord{ + TRecord(); + int exp_coord_sys_num; // export coordinate system number + int disp_coord_sys_num; // displacement coordinate system number + int color; // color + double coord[3]; // node coordinates in the part coordinate system + }; + + typedef int TNodeLab; // type of node label + typedef std::map TDataSet; + + void Read(std::ifstream& in_stream, TDataSet& theDataSet); + + void Write(std::ofstream& out_stream, const TDataSet& theDataSet); + +}; + + +#endif diff --git a/src/DriverUNV/UNV2412_Structure.cxx b/src/DriverUNV/UNV2412_Structure.cxx new file mode 100644 index 000000000..43699fcd8 --- /dev/null +++ b/src/DriverUNV/UNV2412_Structure.cxx @@ -0,0 +1,202 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include +#include + +#include "UNV2412_Structure.hxx" +#include "UNV_Utilities.hxx" + +using namespace std; +using namespace UNV; +using namespace UNV2412; + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + +static string _label_dataset = "2412"; + +UNV2412::TRecord::TRecord(): + phys_prop_tab_num(2), + mat_prop_tab_num(1), + color(7), + beam_orientation(0), + beam_fore_end(0), + beam_aft_end(0) +{} + +void UNV2412::Read(std::ifstream& in_stream, TDataSet& theDataSet) +{ + if(!in_stream.good()) + EXCEPTION(runtime_error,"ERROR: Input file not good."); + + /* + * adjust the \p istream to our + * position + */ + if(!beginning_of_dataset(in_stream,_label_dataset)) + EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!"); + + TElementLab aLabel; + for(; !in_stream.eof();){ + in_stream >> aLabel ; + if(aLabel == -1){ + // end of dataset is reached + break; + } + + int n_nodes; + TRecord aRec; + in_stream>>aRec.fe_descriptor_id; + in_stream>>aRec.phys_prop_tab_num; + in_stream>>aRec.mat_prop_tab_num; + in_stream>>aRec.color; + in_stream>>n_nodes; + + if(IsBeam(aRec.fe_descriptor_id)){ + in_stream>>aRec.beam_orientation; + in_stream>>aRec.beam_fore_end; + in_stream>>aRec.beam_aft_end; + } + + aRec.node_labels.resize(n_nodes); + for(int j=0; j < n_nodes; j++){ + // read node labels + in_stream>>aRec.node_labels[j]; + } + + theDataSet.insert(TDataSet::value_type(aLabel,aRec)); + } + +} + + +void UNV2412::Write(std::ofstream& out_stream, const TDataSet& theDataSet) +{ + if(!out_stream.good()) + EXCEPTION(runtime_error,"ERROR: Output file not good."); + + /* + * Write beginning of dataset + */ + out_stream<<" -1\n"; + out_stream<<" "<<_label_dataset<<"\n"; + + TDataSet::const_iterator anIter = theDataSet.begin(); + for(; anIter != theDataSet.end(); anIter++){ + const TElementLab& aLabel = anIter->first; + const TRecord& aRec = anIter->second; + out_stream< +#include +#include + + +namespace UNV2412{ + + struct TRecord{ + TRecord(); + + int fe_descriptor_id; // FE descriptor id + int phys_prop_tab_num; // physical property table number + int mat_prop_tab_num; // material property table number + int color; // color + std::vector node_labels; // node labels defining element + + //FOR BEAM ELEMENTS ONLY + int beam_orientation; // beam orientation node number + int beam_fore_end; // beam fore-end cross section number + int beam_aft_end; // beam aft-end cross section number + }; + + typedef int TElementLab; // type of element label + typedef std::map TDataSet; + + void Read(std::ifstream& in_stream, TDataSet& theDataSet); + + void Write(std::ofstream& out_stream, const TDataSet& theDataSet); + + bool IsBeam(int theFeDescriptorId); + bool IsFace(int theFeDescriptorId); + bool IsVolume(int theFeDescriptorId); + +}; + + +#endif diff --git a/src/DriverUNV/UNV_Test.cxx b/src/DriverUNV/UNV_Test.cxx new file mode 100644 index 000000000..f9d917207 --- /dev/null +++ b/src/DriverUNV/UNV_Test.cxx @@ -0,0 +1,69 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "UNV2411_Structure.hxx" +#include "UNV2412_Structure.hxx" +#include "UNV_Utilities.hxx" + +#include "DriverUNV_R_SMDS_Mesh.h" +#include "DriverUNV_W_SMDS_Mesh.h" + +using namespace std; + +#ifdef DEBUG +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + + +void ReadMed(const char* theFileName){ + std::ifstream in_stream(theFileName); + + UNV2411::TDataSet aDataSet2411; + UNV2411::Read(in_stream,aDataSet2411); + + in_stream.seekg(0); + UNV2412::TDataSet aDataSet2412; + UNV2412::Read(in_stream,aDataSet2412); + + string aFileName(theFileName); + aFileName += "-"; + std::ofstream out_stream(aFileName.c_str()); + + UNV2411::Write(out_stream,aDataSet2411); + UNV2412::Write(out_stream,aDataSet2412); +} + + +int main(int argc, char** argv){ + DriverUNV_R_SMDS_Mesh aR; + DriverUNV_W_SMDS_Mesh aW; + try{ + if(argc > 1){ + ReadMed(argv[1]); + } + return 0; + }catch(std::exception& exc){ + cout<<"Follow exception was accured :\n"< +#include +#include +#include + + +namespace UNV{ + using namespace std; + + class PrefixPrinter{ + static int myCounter; + public: + PrefixPrinter(); + ~PrefixPrinter(); + + static string GetPrefix(); + }; + + /** + * @returns \p false when error occured, \p true otherwise. + * Adjusts the \p in_stream to the beginning of the + * dataset \p ds_name. + */ + inline bool beginning_of_dataset(std::istream& in_file, const std::string& ds_name) + { + assert (in_file.good()); + assert (!ds_name.empty()); + + std::string olds, news; + + while(true){ + in_file >> olds >> news; + /* + * a "-1" followed by a number means the beginning of a dataset + * stop combing at the end of the file + */ + while( ((olds != "-1") || (news == "-1") ) && !in_file.eof() ){ + olds = news; + in_file >> news; + } + if(in_file.eof()) + return false; + if (news == ds_name) + return true; + } + // should never end up here + return false; + } + + /** + * Method for converting exponential notation + * from "D" to "e", for example + * \p 3.141592654D+00 \p --> \p 3.141592654e+00 + * in order to make it readable for C++. + */ + inline double D_to_e(std::string& number) + { + /* find "D" in string, start looking at + * 6th element, to improve speed. + * We dont expect a "D" earlier + */ + const int position = number.find("D",6); + if(position != std::string::npos){ + number.replace(position, 1, "e"); + } + return atof (number.c_str()); + } + +}; + + +#ifndef MESSAGE + +#define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"< +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "utilities.h" + +/* + Netgen include files +*/ + +#include "nglib.h" + +//============================================================================= +/*! + * + */ +//============================================================================= + +NETGENPlugin_NETGEN_3D::NETGENPlugin_NETGEN_3D(int hypId, int studyId, + SMESH_Gen* gen) + : SMESH_3D_Algo(hypId, studyId, gen) +{ + MESSAGE("NETGENPlugin_NETGEN_3D::NETGENPlugin_NETGEN_3D"); + _name = "NETGEN_3D"; +// _shapeType = TopAbs_SOLID; + _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type +// MESSAGE("_shapeType octal " << oct << _shapeType); + _compatibleHypothesis.push_back("MaxElementVolume"); + + _maxElementVolume = 0.; + + _hypMaxElementVolume = NULL; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +NETGENPlugin_NETGEN_3D::~NETGENPlugin_NETGEN_3D() +{ + MESSAGE("NETGENPlugin_NETGEN_3D::~NETGENPlugin_NETGEN_3D"); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool NETGENPlugin_NETGEN_3D::CheckHypothesis + (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + SMESH_Hypothesis::Hypothesis_Status& aStatus) +{ + MESSAGE("NETGENPlugin_NETGEN_3D::CheckHypothesis"); + + _hypMaxElementVolume = NULL; + + list::const_iterator itl; + const SMESHDS_Hypothesis* theHyp; + + const list& hyps = GetUsedHypothesis(aMesh, aShape); + int nbHyp = hyps.size(); + if (!nbHyp) + { + aStatus = SMESH_Hypothesis::HYP_MISSING; + return false; // can't work with no hypothesis + } + + itl = hyps.begin(); + theHyp = (*itl); // use only the first hypothesis + + string hypName = theHyp->GetName(); + int hypId = theHyp->GetID(); + SCRUTE(hypName); + + bool isOk = false; + + if (hypName == "MaxElementVolume") + { + _hypMaxElementVolume = static_cast (theHyp); + ASSERT(_hypMaxElementVolume); + _maxElementVolume = _hypMaxElementVolume->GetMaxVolume(); + isOk =true; + aStatus = SMESH_Hypothesis::HYP_OK; + } + else + aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE; + + return isOk; +} + +//============================================================================= +/*! + *Here we are going to use the NETGEN mesher + */ +//============================================================================= + +bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape) +{ + MESSAGE("NETGENPlugin_NETGEN_3D::Compute with maxElmentsize = " << _maxElementVolume); + + bool isOk = false; + SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); + SMESH_subMesh* theSubMesh = aMesh.GetSubMesh(aShape); + //const Handle(SMESHDS_SubMesh)& subMeshDS = theSubMesh->GetSubMeshDS(); + + map netgenToDS; + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute Checking the mesh Faces"); + + // check if all faces were meshed by a triangle mesher (here MESFISTO_2D) + + vector meshFaces; + vector shapeFaces; + + for (TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next()) + { + TopoDS_Shape aShapeFace = exp.Current(); + SMESH_subMesh* aSubMesh = aMesh.GetSubMeshContaining(exp.Current()); + ASSERT (aSubMesh); + int internal_size = meshFaces.size(); + int index = 0; + for (int i = 0;iGetSubShape(); + TopoDS_Shape aFace = shapeFaces[i]; + SMESH_Algo* algoFace = _gen->GetAlgo(aMesh, aShapeFace); + string algoFaceName = algoFace->GetName(); + SCRUTE(algoFaceName); + if (algoFaceName != "MEFISTO_2D") + { + SCRUTE(algoFaceName); + ASSERT(0); + return false; + } + + bool orientationMeshFace = (aFace.Orientation() == aShapeFace.Orientation()); + + const SMESHDS_SubMesh* aSubMeshDSFace = meshFaces[i]->GetSubMeshDS(); + SCRUTE(aSubMeshDSFace); + + int nbNodes = aSubMeshDSFace->NbNodes(); + NbTotOfNodesFaces += nbNodes; + int nbTria = aSubMeshDSFace->NbElements(); + NbTotOfTria += nbTria; + int index = 0; + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute The mesh Face " << (i+1) << " has " << nbNodes << " face internal Nodes, " << nbTria << " triangles"); + + SCRUTE(orientationMeshFace); + + if (orientationMeshFace) + { + MESSAGE("The mesh and face have the same orientation"); + } + else + { + MESSAGE("The mesh and face have different orientations"); + } + + SMDS_NodeIteratorPtr iteratorNodes = aSubMeshDSFace->GetNodes(); + SCRUTE(nbNodes); + index = 0; + while(iteratorNodes->more()) + { + index++; + const SMDS_MeshNode * node = iteratorNodes->next(); +// int nodeId = node->GetID(); +// double nodeX = node->X(); +// double nodeY = node->Y(); +// double nodeZ = node->Z(); +// MESSAGE("NODE -> ID = " << nodeId << " X = " << nodeX << " Y = " << nodeY << " Z = " << nodeZ); + } + + SCRUTE(index); + + SMDS_ElemIteratorPtr iteratorTriangle = aSubMeshDSFace->GetElements(); + + SCRUTE(nbTria); + index = 0; + int numberOfDegeneratedTriangle = 0; + while(iteratorTriangle->more()) + { + index++; + const SMDS_MeshElement * triangle = iteratorTriangle->next(); + int triangleId = triangle->GetID(); + + SMDS_ElemIteratorPtr triangleNodesIt = triangle->nodesIterator(); + + const SMDS_MeshNode * node1 = static_cast(triangleNodesIt->next()); + double node1X = node1->X(); + double node1Y = node1->Y(); + double node1Z = node1->Z(); + + const SMDS_MeshNode * node2 = static_cast(triangleNodesIt->next()); + double node2X = node2->X(); + double node2Y = node2->Y(); + double node2Z = node2->Z(); + + const SMDS_MeshNode * node3 = static_cast(triangleNodesIt->next()); + double node3X = node3->X(); + double node3Y = node3->Y(); + double node3Z = node3->Z(); + + int triangleNode1 = node1->GetID(); + int triangleNode2 = node2->GetID(); + int triangleNode3 = node3->GetID(); + + // Compute the triangle surface + + double vect1 = ((node2Y - node1Y)*(node3Z - node1Z) - (node2Z - node1Z)*(node3Y - node1Y)); + double vect2 = - ((node2X - node1X)*(node3Z - node1Z) - (node2Z - node1Z)*(node3X - node1X)); + double vect3 = ((node2X - node1X)*(node3Y - node1Y) - (node2Y - node1Y)*(node3X - node1X)); + double epsilon = 1.0e-6; + + bool triangleIsDegenerated = ((abs(vect1) ID = " << triangleId << " N1 = " << triangleNode1 << " N2 = " << triangleNode2 << " N3 = " << triangleNode3 << " is degenerated"); +// MESSAGE("NODE -> ID = " << triangleNode1 << " X = " << node1X << " Y = " << node1Y << " Z = " << node1Z); +// MESSAGE("NODE -> ID = " << triangleNode2 << " X = " << node2X << " Y = " << node2Y << " Z = " << node2Z); +// MESSAGE("NODE -> ID = " << triangleNode3 << " X = " << node3X << " Y = " << node3Y << " Z = " << node3Z); + numberOfDegeneratedTriangle++; + } + else + { +// MESSAGE("TRIANGLE -> ID = " << triangleId << " N1 = " << triangleNode1 << " N2 = " << triangleNode2 << " N3 = " << triangleNode3 << " is normal"); + } + } + + if (numberOfDegeneratedTriangle > 0) + MESSAGE("WARNING THERE IS(ARE) " << numberOfDegeneratedTriangle << " degenerated triangle on this face"); + + SCRUTE(index); + } + + + + SCRUTE(NbTotOfTria); + SCRUTE(NbTotOfNodesFaces); + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute Checking the mesh Edges"); + + // check if all edges were meshed by a edge mesher (here Regular_1D) + + vector meshEdges; + for (TopExp_Explorer exp(aShape,TopAbs_EDGE);exp.More();exp.Next()) + { + SMESH_subMesh* aSubMesh = aMesh.GetSubMeshContaining(exp.Current()); + ASSERT (aSubMesh); + int internal_size = meshEdges.size(); + int index = 0; + for (int i = 0;iGetSubShape(); + SMESH_Algo* algoEdge = _gen->GetAlgo(aMesh, aShapeEdge); + string algoEdgeName = algoEdge->GetName(); + SCRUTE(algoEdgeName); + if (algoEdgeName != "Regular_1D") + { + SCRUTE(algoEdgeName); + ASSERT(0); + return false; + } + + const SMESHDS_SubMesh* aSubMeshDSEdge = meshEdges[i]->GetSubMeshDS(); + SCRUTE(aSubMeshDSEdge); + + int nbNodes = aSubMeshDSEdge->NbNodes(); + NbTotOfNodesEdges += nbNodes; + int nbSegs = aSubMeshDSEdge->NbElements(); + NbTotOfSegs += nbSegs; + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute The mesh Edge " << (i+1) << " has " << nbNodes << " edge internal Nodes, " << nbSegs << " segments"); + + SMDS_NodeIteratorPtr iteratorNodes = aSubMeshDSEdge->GetNodes(); + SCRUTE(nbNodes); + int index = 0; + while(iteratorNodes->more()) + { + index++; + const SMDS_MeshNode * node = iteratorNodes->next(); +// int nodeId = node->GetID(); +// double nodeX = node->X(); +// double nodeY = node->Y(); +// double nodeZ = node->Z(); +// MESSAGE("NODE -> ID = " << nodeId << " X = " << nodeX << " Y = " << nodeY << " Z = " << nodeZ); + } + + SCRUTE(index); + } + + SCRUTE(NbTotOfNodesEdges); + SCRUTE(NbTotOfSegs); + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute Checking the mesh Vertices"); + + vector meshVertices; + for (TopExp_Explorer exp(aShape,TopAbs_VERTEX);exp.More();exp.Next()) + { + SMESH_subMesh* aSubMesh = aMesh.GetSubMeshContaining(exp.Current()); + ASSERT (aSubMesh); + int internal_size = meshVertices.size(); + int index = 0; + for (int i = 0;iGetSubShape(); + + const SMESHDS_SubMesh * aSubMeshDSVertex = meshVertices[i]->GetSubMeshDS(); + SCRUTE(aSubMeshDSVertex); + + int nbNodes = aSubMeshDSVertex->NbNodes(); + NbTotOfNodesVertices += nbNodes; + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute The mesh Vertex " << (i+1) << " has " << nbNodes << " Nodes"); + + SMDS_NodeIteratorPtr iteratorNodes = aSubMeshDSVertex->GetNodes(); + SCRUTE(nbNodes); + int index = 0; + while(iteratorNodes->more()) + { + index++; + const SMDS_MeshNode * node = iteratorNodes->next(); +// int nodeId = node->GetID(); +// double nodeX = node->X(); +// double nodeY = node->Y(); +// double nodeZ = node->Z(); +// MESSAGE("NODE -> ID = " << nodeId << " X = " << nodeX << " Y = " << nodeY << " Z = " << nodeZ); + } + + SCRUTE(index); + } + + SCRUTE(NbTotOfNodesVertices); + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute --> Analysis of all shell mesh"); + + vector meshShells; + TopoDS_Shell aShell; + + for (TopExp_Explorer exp(aShape,TopAbs_SHELL);exp.More();exp.Next()) + { + SMESH_subMesh* aSubMesh = aMesh.GetSubMesh(exp.Current()); + ASSERT(aSubMesh); + SCRUTE(aSubMesh); + aShell = TopoDS::Shell(exp.Current()); + meshShells.push_back(aSubMesh); + } + + int numberOfShells = meshShells.size(); + SCRUTE(numberOfShells); + + if (numberOfShells == 1) + { + MESSAGE("NETGENPlugin_NETGEN_3D::Compute Only one shell --> generation of the mesh using directly Netgen"); + + /* + Prepare the Netgen surface mesh from the SMESHDS + */ + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute Prepare the Netgen surface mesh from the SMESHDS"); + + int spaceDimension = 3; + int nbNodesByTri = 3; + int nbNodesByTetra = 4; + + int Netgen_NbOfNodes = NbTotOfNodesFaces + + NbTotOfNodesEdges + + NbTotOfNodesVertices; + int Netgen_NbOfTria = NbTotOfTria; + int Netgen_param2ndOrder = 0; + double Netgen_paramFine = 1.; + double Netgen_paramSize = _maxElementVolume; + + SCRUTE(Netgen_NbOfNodes); + SCRUTE(Netgen_NbOfTria); + + double * Netgen_Coordinates = new double [spaceDimension* + Netgen_NbOfNodes]; + int * listNodeCoresNetgenSmesh = new int [Netgen_NbOfNodes]; + int * Netgen_Connectivity = new int [nbNodesByTri*Netgen_NbOfTria]; + double * Netgen_point = new double [spaceDimension]; + int * Netgen_triangle = new int [nbNodesByTri]; + int * Netgen_tetrahedron = new int [nbNodesByTetra]; + + for (int i=0; iGetSubMeshDS(); + + SMDS_NodeIteratorPtr iteratorNodes = aSubMeshDSVertex->GetNodes(); + + while(iteratorNodes->more()) + { + const SMDS_MeshNode * node = iteratorNodes->next(); + int nodeId = node->GetID(); + double nodeX = node->X(); + double nodeY = node->Y(); + double nodeZ = node->Z(); +// MESSAGE("NODE -> ID = " << nodeId << " X = " << nodeX << " Y = " << nodeY << " Z = " << nodeZ); + listNodeCoresNetgenSmesh[indexNodes] = nodeId; + int index = indexNodes*spaceDimension; + Netgen_Coordinates[index] = nodeX; + Netgen_Coordinates[index+1] = nodeY; + Netgen_Coordinates[index+2] = nodeZ; + netgenToDS[indexNodes] = node; + indexNodes++; + } + } + + for (int i=0; iGetSubMeshDS(); + + SMDS_NodeIteratorPtr iteratorNodes = aSubMeshDSEdge->GetNodes(); + + while(iteratorNodes->more()) + { + const SMDS_MeshNode * node = iteratorNodes->next(); + int nodeId = node->GetID(); + double nodeX = node->X(); + double nodeY = node->Y(); + double nodeZ = node->Z(); +// MESSAGE("NODE -> ID = " << nodeId << " X = " << nodeX << " Y = " << nodeY << " Z = " << nodeZ); + listNodeCoresNetgenSmesh[indexNodes] = node->GetID(); + int index = indexNodes*spaceDimension; + Netgen_Coordinates[index] = node->X(); + Netgen_Coordinates[index+1] = node->Y(); + Netgen_Coordinates[index+2] = node->Z(); + netgenToDS[indexNodes] = node; + indexNodes++; + } + } + + for (int i=0; iGetSubMeshDS(); + + SMDS_NodeIteratorPtr iteratorNodes = aSubMeshDSFace->GetNodes(); + + while(iteratorNodes->more()) + { + const SMDS_MeshNode * node = iteratorNodes->next(); + int nodeId = node->GetID(); + double nodeX = node->X(); + double nodeY = node->Y(); + double nodeZ = node->Z(); +// MESSAGE("NODE -> ID = " << nodeId << " X = " << nodeX << " Y = " << nodeY << " Z = " << nodeZ); + listNodeCoresNetgenSmesh[indexNodes] = nodeId; + int index = indexNodes*spaceDimension; + Netgen_Coordinates[index] = nodeX; + Netgen_Coordinates[index+1] = nodeY; + Netgen_Coordinates[index+2] = nodeZ; + netgenToDS[indexNodes] = node; + indexNodes++; + } + } + + SCRUTE(indexNodes); + + for (int i=0; iGetSubMeshDS(); + + TopoDS_Shape aFace = shapeFaces[i]; + + SMDS_ElemIteratorPtr iteratorTriangle = aSubMeshDSFace->GetElements(); + + TopoDS_Shape aShapeFace = meshFaces[i]->GetSubShape(); + + bool orientationMeshFace = (aFace.Orientation() == aShapeFace.Orientation()); + + SCRUTE(orientationMeshFace); + + if (orientationMeshFace) + { + MESSAGE("The mesh and face have the same orientation"); + + while(iteratorTriangle->more()) + { + const SMDS_MeshElement * triangle = iteratorTriangle->next(); + int triangleId = triangle->GetID(); + + SMDS_ElemIteratorPtr triangleNodesIt = triangle->nodesIterator(); + + int triangleNode1 = (triangleNodesIt->next())->GetID(); + int triangleNode2 = (triangleNodesIt->next())->GetID(); + int triangleNode3 = (triangleNodesIt->next())->GetID(); + +// MESSAGE("TRIANGLE -> ID = " << triangleId << " N1 = " << triangleNode1 << " N2 = " << triangleNode2 << " N3 = " << triangleNode3); + + int N1New = 0; + int N2New = 0; + int N3New = 0; + int index = indexTrias*nbNodesByTri; + + for (int j=0; jmore()) + { + const SMDS_MeshElement * triangle = iteratorTriangle->next(); + int triangleId = triangle->GetID(); + + SMDS_ElemIteratorPtr triangleNodesIt = triangle->nodesIterator(); + + int triangleNode1 = (triangleNodesIt->next())->GetID(); + int triangleNode3 = (triangleNodesIt->next())->GetID(); + int triangleNode2 = (triangleNodesIt->next())->GetID(); + +// MESSAGE("TRIANGLE -> ID = " << triangleId << " N1 = " << triangleNode1 << " N2 = " << triangleNode2 << " N3 = " << triangleNode3); + + int N1New = 0; + int N2New = 0; + int N3New = 0; + int index = indexTrias*nbNodesByTri; + + for (int j=0; j=1) && (Nij<=Netgen_NbOfNodes)); + + nodesUsed[Nij-1] = 1; + Netgen_Connectivity[i*nbNodesByTri+j] = Nij; + } + + for (int i=0; i Adding the New Nodes to SMESHDS"); + + for (int i=0; iAddNode(Netgen_CoordinatesNew[index], + Netgen_CoordinatesNew[index+1], + Netgen_CoordinatesNew[index+2]); + + meshDS->SetNodeInVolume(node, aShell); + + index = i+Netgen_NbOfNodes; + netgenToDS[index] = node; + + listNodeShellCoresNetgenSmesh[i] = node->GetID(); + } + + SCRUTE(Netgen_NbOfNodesNew); + + SCRUTE(netgenToDS.size()); + + for (int i=0; i Adding the New elements (Tetrahedrons) to the SMESHDS"); + + for (int i=0; iAddVolume(node1,node2,node3,node4); + + meshDS->SetMeshElementOnShape(elt, aShell); + } + + /* + Free the memory needed by to generate the Netgen Mesh + */ + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute Free the memory needed by to generate the Netgen Mesh"); + + delete [] Netgen_Coordinates; + delete [] Netgen_Connectivity; + delete [] Netgen_CoordinatesNew; + delete [] Netgen_ConnectivityNew; + delete [] Netgen_point; + delete [] Netgen_triangle; + delete [] Netgen_tetrahedron; + + delete [] listNodeCoresNetgenSmesh; + delete [] listNodeShellCoresNetgenSmesh; + + Ng_DeleteMesh(Netgen_mesh); + Ng_Exit(); + + /* + Verification + */ + + { + MESSAGE("NETGENPlugin_NETGEN_3D::Compute Verification of the Shell mesh"); + + TopoDS_Shape aShapeShell = meshShells[0]->GetSubShape(); + SMESH_Algo* algoShell = _gen->GetAlgo(aMesh, aShapeShell); + string algoShellName = algoShell->GetName(); + SCRUTE(algoShellName); + if (algoShellName != "NETGEN_3D") + { + SCRUTE(algoShellName); + ASSERT(0); + return false; + } + + const SMESHDS_SubMesh * aSubMeshDSShell = meshShells[0]->GetSubMeshDS(); + SCRUTE(&aSubMeshDSShell); + + int nbNodes = aSubMeshDSShell->NbNodes(); + int nbTetra = aSubMeshDSShell->NbElements(); + + MESSAGE("NETGENPlugin_NETGEN_3D::Compute The mesh Shell has " << nbNodes << " shell internal Nodes, " << nbTetra << " tetrahedrons"); + + SMDS_NodeIteratorPtr iteratorNodes = aSubMeshDSShell->GetNodes(); + + SCRUTE(nbNodes); + + int index; + + index = 0; + + while(iteratorNodes->more()) + { + index++; + const SMDS_MeshNode * node = iteratorNodes->next(); + int nodeId = node->GetID(); + double nodeX = node->X(); + double nodeY = node->Y(); + double nodeZ = node->Z(); +// MESSAGE("NODE -> ID = " << nodeId << " X = " << nodeX << " Y = " << nodeY << " Z = " << nodeZ); + } + + SCRUTE(index); + + SMDS_ElemIteratorPtr iteratorTetra = aSubMeshDSShell->GetElements(); + + SCRUTE(nbTetra); + + index = 0; + while(iteratorTetra->more()) + { + index++; + const SMDS_MeshElement * tetra = iteratorTetra->next(); + int tetraId = tetra->GetID(); + + SMDS_ElemIteratorPtr tetraNodesIt = tetra->nodesIterator(); + + int tetraNode1 = (tetraNodesIt->next())->GetID(); + int tetraNode2 = (tetraNodesIt->next())->GetID(); + int tetraNode3 = (tetraNodesIt->next())->GetID(); + int tetraNode4 = (tetraNodesIt->next())->GetID(); + +// MESSAGE("TETRAHEDRON -> ID = " << tetraId << " N1 = " << tetraNode1 << " N2 = " << tetraNode2 << " N3 = " << tetraNode3 << " N4 = " << tetraNode4); + + } + + SCRUTE(index); + } + } + else + { + SCRUTE(numberOfShells); + MESSAGE("NETGENPlugin_NETGEN_3D::Compute ERROR More than one shell ????? "); + return false; + } + + return true; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & NETGENPlugin_NETGEN_3D::SaveTo(ostream & save) +{ + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & NETGENPlugin_NETGEN_3D::LoadFrom(istream & load) +{ + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator << (ostream & save, NETGENPlugin_NETGEN_3D & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >> (istream & load, NETGENPlugin_NETGEN_3D & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx new file mode 100644 index 000000000..b0858806d --- /dev/null +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.hxx @@ -0,0 +1,43 @@ +//============================================================================= +// File : NETGENPlugin_NETGEN_3D.hxx +// Moved here from SMESH_NETGEN_3D.hxx +// Created : lundi 27 Janvier 2003 +// Author : Nadir BOUHAMOU (CEA) +// Project : SALOME +// Copyright : CEA 2003 +// $Header$ +//============================================================================= + +#ifndef _NETGENPlugin_NETGEN_3D_HXX_ +#define _NETGENPlugin_NETGEN_3D_HXX_ + +#include "SMESH_3D_Algo.hxx" +#include "SMESH_Mesh.hxx" +#include "StdMeshers_MaxElementVolume.hxx" +#include "Utils_SALOME_Exception.hxx" + +class NETGENPlugin_NETGEN_3D: public SMESH_3D_Algo +{ +public: + NETGENPlugin_NETGEN_3D(int hypId, int studyId, SMESH_Gen* gen); + virtual ~NETGENPlugin_NETGEN_3D(); + + 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); + + ostream & SaveTo(ostream & save); + istream & LoadFrom(istream & load); + friend ostream & operator << (ostream & save, NETGENPlugin_NETGEN_3D & hyp); + friend istream & operator >> (istream & load, NETGENPlugin_NETGEN_3D & hyp); + +protected: + double _maxElementVolume; + + const StdMeshers_MaxElementVolume* _hypMaxElementVolume; +}; + +#endif diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx new file mode 100644 index 000000000..489d6822e --- /dev/null +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx @@ -0,0 +1,85 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : NETGENPlugin_NETGEN_3D_i.cxx +// Moved here from SMESH_NETGEN_3D_i.cxx +// Author : Nadir Bouhamou CEA +// Module : SMESH +// $Header$ + +using namespace std; +#include "NETGENPlugin_NETGEN_3D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i + * + * Constructor + */ +//============================================================================= + +NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_3D_Algo_i( thePOA ) +{ + MESSAGE( "NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i" ); + myBaseImpl = new ::NETGENPlugin_NETGEN_3D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * NETGENPlugin_NETGEN_3D_i::~NETGENPlugin_NETGEN_3D_i + * + * Destructor + */ +//============================================================================= + +NETGENPlugin_NETGEN_3D_i::~NETGENPlugin_NETGEN_3D_i() +{ + MESSAGE( "NETGENPlugin_NETGEN_3D_i::~NETGENPlugin_NETGEN_3D_i" ); +} + +//============================================================================= +/*! + * NETGENPlugin_NETGEN_3D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::NETGENPlugin_NETGEN_3D* NETGENPlugin_NETGEN_3D_i::GetImpl() +{ + MESSAGE( "NETGENPlugin_NETGEN_3D_i::GetImpl" ); + return ( ::NETGENPlugin_NETGEN_3D* )myBaseImpl; +} + diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.hxx new file mode 100644 index 000000000..724fafa55 --- /dev/null +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.hxx @@ -0,0 +1,58 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : NETGENPlugin_NETGEN_3D_i.hxx +// Moved here from SMESH_NETGEN_3D_i.hxx +// Author : Nadir Bouhamou CEA +// Module : SMESH +// $Header$ + +#ifndef _NETGENPlugin_NETGEN_3D_I_HXX_ +#define _NETGENPlugin_NETGEN_3D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_NetgenAlgorithm) + +#include "SMESH_3D_Algo_i.hxx" +#include "NETGENPlugin_NETGEN_3D.hxx" + +// ====================================================== +// NETGEN 3d algorithm +// ====================================================== +class NETGENPlugin_NETGEN_3D_i: + public virtual POA_NETGENPlugin::NETGENPlugin_NETGEN_3D, + public virtual SMESH_3D_Algo_i +{ +public: + // Constructor + NETGENPlugin_NETGEN_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~NETGENPlugin_NETGEN_3D_i(); + + // Get implementation + ::NETGENPlugin_NETGEN_3D* GetImpl(); +}; + +#endif diff --git a/src/NETGENPlugin/NETGENPlugin_i.cxx b/src/NETGENPlugin/NETGENPlugin_i.cxx new file mode 100644 index 000000000..7ec0e06f5 --- /dev/null +++ b/src/NETGENPlugin/NETGENPlugin_i.cxx @@ -0,0 +1,60 @@ +// SMESH NETGENPlugin : 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : NETGENPlugin.cxx +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +using namespace std; +#include "SMESH_Hypothesis_i.hxx" +#include "SMESH_Gen_i.hxx" + +#include "utilities.h" + +#include "NETGENPlugin_NETGEN_3D_i.hxx" + +//============================================================================= +/*! + * + */ +//============================================================================= + +extern "C" +{ + GenericHypothesisCreator_i* GetHypothesisCreator (const char* aHypName) + { + MESSAGE("GetHypothesisCreator " << aHypName); + + GenericHypothesisCreator_i* aCreator = 0; + + // Hypotheses + + // Algorithms + if (strcmp(aHypName, "NETGEN_3D") == 0) + aCreator = new HypothesisCreator_i; + else ; + + return aCreator; + } +} diff --git a/src/NETGENPlugin/NETGENPlugin_icons.po b/src/NETGENPlugin/NETGENPlugin_icons.po new file mode 100644 index 000000000..a3f6297d7 --- /dev/null +++ b/src/NETGENPlugin/NETGENPlugin_icons.po @@ -0,0 +1,20 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +#----------------------------------------------------------- +# ObjectBrowser +#----------------------------------------------------------- + +#mesh_tree_algo_netgen +msgid "ICON_SMESH_TREE_ALGO_NETGEN_3D" +msgstr "mesh_tree_algo_tetra.png" +#msgstr "mesh_tree_algo_netgen.png" diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx new file mode 100644 index 000000000..950bf83cd --- /dev/null +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -0,0 +1,357 @@ +// SMESH OBJECT : interactive object for SMESH visualization +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Actor.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + + +#include "SMESH_DeviceActor.h" + +#include "SALOME_Transform.h" +#include "SALOME_TransformFilter.h" +#include "SALOME_PassThroughFilter.h" +#include "SALOME_ExtractUnstructuredGrid.h" + +#include "utilities.h" + +// VTK Includes +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +#else +static int MYDEBUG = 0; +static int MYDEBUGWITHFILES = 0; +#endif + +using namespace std; + + +vtkStandardNewMacro(SMESH_DeviceActor); + + +SMESH_DeviceActor::SMESH_DeviceActor(){ + if(MYDEBUG) MESSAGE("SMESH_DeviceActor"); + myIsShrunk = false; + myIsShrinkable = false; + myRepresentation = eSurface; + + myProperty = vtkProperty::New(); + myMapper = vtkPolyDataMapper::New(); + + vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, + myPolygonOffsetUnits); + //myMapper->SetResolveCoincidentTopologyToShiftZBuffer(); + //myMapper->SetResolveCoincidentTopologyZShift(0.02); + + myMapper->UseLookupTableScalarRangeOn(); + myMapper->SetColorModeToMapScalars(); + + myShrinkFilter = vtkShrinkFilter::New(); + + myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New(); + myExtractUnstructuredGrid->SetStoreMapping(true); + + myMergeFilter = vtkMergeFilter::New(); + + myStoreMapping = false; + myGeomFilter = SALOME_GeometryFilter::New(); + + myTransformFilter = SALOME_TransformFilter::New(); + + for(int i = 0; i < 6; i++) + myPassFilter.push_back(SALOME_PassThroughFilter::New()); +} + + +SMESH_DeviceActor::~SMESH_DeviceActor(){ + if(MYDEBUG) MESSAGE("~SMESH_DeviceActor"); + myProperty->Delete(); + + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + myShrinkFilter->UnRegisterAllOutputs(); + myShrinkFilter->Delete(); + + myExtractUnstructuredGrid->UnRegisterAllOutputs(); + myExtractUnstructuredGrid->Delete(); + + myMergeFilter->UnRegisterAllOutputs(); + myMergeFilter->Delete(); + + myGeomFilter->UnRegisterAllOutputs(); + myGeomFilter->Delete(); + + myTransformFilter->UnRegisterAllOutputs(); + myTransformFilter->Delete(); + + for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++){ + myPassFilter[i]->UnRegisterAllOutputs(); + myPassFilter[i]->Delete(); + } +} + + +void SMESH_DeviceActor::SetStoreMapping(int theStoreMapping){ + myStoreMapping = theStoreMapping; + Modified(); +} + + +void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ + if(theGrid){ + //myIsShrinkable = theGrid->GetNumberOfCells() > 10; + myIsShrinkable = true; + + myExtractUnstructuredGrid->SetInput(theGrid); + myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput()); + + theGrid = static_cast(myMergeFilter->GetOutput()); + + int anId = 0; + myPassFilter.at( anId )->SetInput( theGrid ); + myPassFilter.at( anId + 1)->SetInput( myPassFilter.at( anId )->GetOutput() ); + + anId++; // 1 + myGeomFilter->SetStoreMapping( myStoreMapping ); + myGeomFilter->SetInput( myPassFilter.at( anId )->GetOutput() ); + + anId++; // 2 + myPassFilter.at( anId )->SetInput( myGeomFilter->GetOutput() ); + myPassFilter.at( anId + 1 )->SetInput( myPassFilter.at( anId )->GetOutput() ); + + anId++; // 3 + myTransformFilter->SetInput( myPassFilter.at( anId )->GetPolyDataOutput() ); + + anId++; // 4 + myPassFilter.at( anId )->SetInput( myTransformFilter->GetOutput() ); + myPassFilter.at( anId + 1 )->SetInput( myPassFilter.at( anId )->GetOutput() ); + + anId++; // 5 + myMapper->SetInput( myPassFilter.at( anId )->GetPolyDataOutput() ); + + vtkLODActor::SetMapper( myMapper ); + Modified(); + } +} + + +SALOME_ExtractUnstructuredGrid* SMESH_DeviceActor::GetExtractUnstructuredGrid(){ + return myExtractUnstructuredGrid; +} + + +vtkUnstructuredGrid* SMESH_DeviceActor::GetUnstructuredGrid(){ + myExtractUnstructuredGrid->Update(); + return myExtractUnstructuredGrid->GetOutput(); +} + + +vtkMergeFilter* SMESH_DeviceActor::GetMergeFilter(){ + return myMergeFilter; +} + + +vtkPolyData* SMESH_DeviceActor::GetPolyDataInput(){ + return myPassFilter.back()->GetPolyDataOutput(); +} + + +unsigned long int SMESH_DeviceActor::GetMTime(){ + unsigned long mTime = this->Superclass::GetMTime(); + mTime = max(mTime,myExtractUnstructuredGrid->GetMTime()); + mTime = max(mTime,myMergeFilter->GetMTime()); + mTime = max(mTime,myGeomFilter->GetMTime()); + mTime = max(mTime,myTransformFilter->GetMTime()); + return mTime; +} + + +void SMESH_DeviceActor::SetTransform(SALOME_Transform* theTransform){ + myTransformFilter->SetTransform(theTransform); +} + + +void SMESH_DeviceActor::SetShrink() +{ + if ( !myIsShrinkable ) return; + if ( vtkDataSet* aDataSet = myPassFilter.at( 0 )->GetOutput() ) + { + myShrinkFilter->SetInput( aDataSet ); + myPassFilter.at( 1 )->SetInput( myShrinkFilter->GetOutput() ); + myIsShrunk = true; + } +} + +void SMESH_DeviceActor::UnShrink() +{ + if ( !myIsShrunk ) return; + if ( vtkDataSet* aDataSet = myPassFilter.at( 0 )->GetOutput() ) + { + myPassFilter.at( 1 )->SetInput( aDataSet ); + myPassFilter.at( 1 )->Modified(); + myIsShrunk = false; + Modified(); + } +} + + +void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ + switch(theMode){ + case ePoint: + myGeomFilter->SetInside(true); + GetProperty()->SetRepresentation(0); + break; + case eInsideframe: + myGeomFilter->SetInside(true); + GetProperty()->SetRepresentation(1); + break; + default : + GetProperty()->SetRepresentation(theMode); + myGeomFilter->SetInside(false); + } + myRepresentation = theMode; + myMapper->Modified(); + Modified(); +} + + +void SMESH_DeviceActor::SetVisibility(int theMode){ + if(!myExtractUnstructuredGrid->GetInput() || GetUnstructuredGrid()->GetNumberOfCells()){ + vtkLODActor::SetVisibility(theMode); + }else{ + vtkLODActor::SetVisibility(false); + } +} + + +int SMESH_DeviceActor::GetVisibility(){ + if(!GetUnstructuredGrid()->GetNumberOfCells()){ + vtkLODActor::SetVisibility(false); + } + return vtkLODActor::GetVisibility(); +} + + +int SMESH_DeviceActor::GetObjId(int theVtkID){ + if (GetRepresentation() == ePoint){ + return GetNodeObjId(theVtkID); + }else{ + return GetElemObjId(theVtkID); + } +} + + +SMESH_DeviceActor::TVectorId SMESH_DeviceActor::GetVtkId(int theObjID){ + if (GetRepresentation() == ePoint){ + return GetNodeVtkId(theObjID); + }else{ + return GetElemVtkId(theObjID); + } +} + + +int SMESH_DeviceActor::GetNodeObjId(int theVtkID){ + vtkIdType aRetID = myVisualObj->GetNodeObjId(theVtkID); + if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "< + +class vtkProperty; +class vtkMergeFilter; +class vtkShrinkFilter; +class vtkPolyDataMapper; +class vtkUnstructuredGrid; + +class SALOME_Transform; +class SALOME_TransformFilter; +class SALOME_PassThroughFilter; +class SALOME_ExtractUnstructuredGrid; + + +class SMESH_DeviceActor: public vtkLODActor{ + friend class SMESH_Actor; + + public: + vtkTypeMacro(SMESH_DeviceActor,vtkLODActor); + static SMESH_DeviceActor* New(); + + void SetStoreMapping(int theStoreMapping); + int GetStoreMapping(){ return myStoreMapping;} + + typedef SALOME_GeometryFilter::TVectorId TVectorId; + int GetObjId(int theVtkID); + TVectorId GetVtkId(int theObjID); + + int GetNodeObjId(int theVtkID); + TVectorId GetNodeVtkId(int theObjID); + + int GetElemObjId(int theVtkID); + TVectorId GetElemVtkId(int theObjID); + + vtkPolyData* GetPolyDataInput(); + + virtual void SetTransform(SALOME_Transform* theTransform); + virtual unsigned long int GetMTime(); + + float GetShrinkFactor(); + void SetShrinkFactor(float value); + + bool IsShrunkable() { return myIsShrinkable;} + bool IsShrunk() { return myIsShrunk;} + void SetShrink(); + void UnShrink(); + + enum EReperesent { ePoint, eWireframe, eSurface, eInsideframe}; + EReperesent GetRepresentation(){ return myRepresentation;} + void SetRepresentation(EReperesent theMode); + + virtual void SetVisibility(int theMode); + virtual int GetVisibility(); + + SALOME_ExtractUnstructuredGrid* GetExtractUnstructuredGrid(); + vtkUnstructuredGrid* GetUnstructuredGrid(); + vtkMergeFilter* GetMergeFilter(); + + virtual void Render(vtkRenderer *, vtkMapper *); + + protected: + void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid); + + vtkPolyDataMapper *myMapper; + TVisualObjPtr myVisualObj; + + vtkProperty *myProperty; + EReperesent myRepresentation; + + vtkMergeFilter* myMergeFilter; + SALOME_ExtractUnstructuredGrid* myExtractUnstructuredGrid; + + bool myStoreMapping; + SALOME_GeometryFilter *myGeomFilter; + SALOME_TransformFilter *myTransformFilter; + std::vector myPassFilter; + + vtkShrinkFilter* myShrinkFilter; + bool myIsShrinkable; + bool myIsShrunk; + + float myPolygonOffsetFactor; + float myPolygonOffsetUnits; + + void SetPolygonOffsetParameters(float factor, float units); + void GetPolygonOffsetParameters(float& factor, float& units){ + factor = myPolygonOffsetFactor; + units = myPolygonOffsetUnits; + } + + SMESH_DeviceActor(); + ~SMESH_DeviceActor(); + SMESH_DeviceActor(const SMESH_DeviceActor&) {}; + void operator=(const SMESH_DeviceActor&) {}; + +}; + + +#endif //SMESH_ACTOR_H diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx new file mode 100644 index 000000000..eb39610cb --- /dev/null +++ b/src/OBJECT/SMESH_Object.cxx @@ -0,0 +1,1037 @@ +// SMESH OBJECT : interactive object for SMESH visualization +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Grid.cxx +// Author : Nicolas REJNERI +// Module : SMESH + +#include "SMESH_Object.h" +#include "SMDS_Mesh.hxx" +#include "SALOME_ExtractUnstructuredGrid.h" +#include "SMESH_Actor.h" + +#include CORBA_SERVER_HEADER(SALOME_Exception) + +#include +#include +#include + +#include +#include +#include +#include + +#include "utilities.h" + +using namespace std; + +#ifndef EXCEPTION +#define EXCEPTION(TYPE, MSG) {\ + std::ostringstream aStream;\ + aStream<<__FILE__<<"["<<__LINE__<<"]::"<SetFileName(theFileName); + aWriter->SetInput(theGrid); + aWriter->Write(); + aWriter->Delete(); +} + + +namespace{ + + inline const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, int theId){ + if(const SMDS_MeshNode* anElem = theMesh->FindNode(theId)) return anElem; + EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<FindElement(theId)) return anElem; + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot find a SMDS_MeshElement for ID = "<AddNodeWithID(aCoords[aCoordId], + aCoords[aCoordId+1], + aCoords[aCoordId+2], + anIndexes[anElemId]); + if(!anElem) + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddNodeWithID for ID = "<AddEdgeWithID(anIndexes[anIndexId+1], + anIndexes[anIndexId+2], + anIndexes[anIndexId]); + if(!anElem) + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddEdgeWithID for ID = "<AddFaceWithID(anIndexes[anIndexId+1], + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId]); + if(!anElem) + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<AddFaceWithID(anIndexes[anIndexId+1], + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId]); + if(!anElem) + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId]); + if(!anElem) + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId]); + if(!anElem) + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId]); + if(!anElem) + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<AddVolumeWithID(anIndexes[anIndexId+1], + anIndexes[anIndexId+2], + anIndexes[anIndexId+3], + anIndexes[anIndexId+4], + anIndexes[anIndexId+5], + anIndexes[anIndexId+6], + anIndexes[anIndexId+7], + anIndexes[anIndexId+8], + anIndexes[anIndexId]); + if(!anElem) + EXCEPTION(runtime_error,"SMDS_Mesh::FindElement - cannot AddFaceWithID for ID = "<GetReferenceCount() = " << myGrid->GetReferenceCount() ); + myGrid->Delete(); +} + +//================================================================================= +// functions : GetNodeObjId, GetNodeVTKId, GetElemObjId, GetElemVTKId +// purpose : Methods for retrieving VTK IDs by SMDS IDs and vice versa +//================================================================================= +vtkIdType SMESH_VisualObj::GetNodeObjId( int theVTKID ) +{ + return myVTK2SMDSNodes.find(theVTKID) == myVTK2SMDSNodes.end() ? -1 : myVTK2SMDSNodes[theVTKID]; +} + +vtkIdType SMESH_VisualObj::GetNodeVTKId( int theObjID ) +{ + return mySMDS2VTKNodes.find(theObjID) == mySMDS2VTKNodes.end() ? -1 : mySMDS2VTKNodes[theObjID]; +} + +vtkIdType SMESH_VisualObj::GetElemObjId( int theVTKID ) +{ + return myVTK2SMDSElems.find(theVTKID) == myVTK2SMDSElems.end() ? -1 : myVTK2SMDSElems[theVTKID]; +} + +vtkIdType SMESH_VisualObj::GetElemVTKId( int theObjID ) +{ + return mySMDS2VTKElems.find(theObjID) == mySMDS2VTKElems.end() ? -1 : mySMDS2VTKElems[theObjID]; +} + +//================================================================================= +// function : SMESH_VisualObj::createPoints +// purpose : Create points from nodes +//================================================================================= +void SMESH_VisualObj::createPoints( vtkPoints* thePoints ) +{ + if ( thePoints == 0 ) + return; + + TEntityList aNodes; + vtkIdType nbNodes = GetEntities( SMESH::NODE, aNodes ); + thePoints->SetNumberOfPoints( nbNodes ); + + int nbPoints = 0; + + TEntityList::const_iterator anIter; + for ( anIter = aNodes.begin(); anIter != aNodes.end(); ++anIter ) + { + const SMDS_MeshNode* aNode = ( const SMDS_MeshNode* )(*anIter); + if ( aNode != 0 ) + { + thePoints->SetPoint( nbPoints, aNode->X(), aNode->Y(), aNode->Z() ); + int anId = aNode->GetID(); + mySMDS2VTKNodes.insert( TMapOfIds::value_type( anId, nbPoints ) ); + myVTK2SMDSNodes.insert( TMapOfIds::value_type( nbPoints, anId ) ); + nbPoints++; + } + } + + if ( nbPoints != nbNodes ) + thePoints->SetNumberOfPoints( nbPoints ); +} + +//================================================================================= +// function : buildPrs +// purpose : create VTK cells( fill unstructured grid ) +//================================================================================= +void SMESH_VisualObj::buildPrs() +{ + try + { + mySMDS2VTKNodes.clear(); + myVTK2SMDSNodes.clear(); + mySMDS2VTKElems.clear(); + myVTK2SMDSElems.clear(); + + if ( IsNodePrs() ) + buildNodePrs(); + else + buildElemPrs(); + } + catch( const std::exception& exc ) + { + INFOS("Follow exception was cought:\n\t"<GetNumberOfCells() = "<GetNumberOfCells() ); + if( MYDEBUGWITHFILES ) WriteUnstructuredGrid( myGrid,"/tmp/buildPrs" ); +} + +//================================================================================= +// function : buildNodePrs +// purpose : create VTK cells for nodes +//================================================================================= +void SMESH_VisualObj::buildNodePrs() +{ + vtkPoints* aPoints = vtkPoints::New(); + createPoints( aPoints ); + int nbPoints = aPoints->GetNumberOfPoints(); + myGrid->SetPoints( aPoints ); + aPoints->Delete(); + + myGrid->SetCells( 0, 0, 0 ); + + // Create cells + + /*vtkIdList *anIdList = vtkIdList::New(); + anIdList->SetNumberOfIds( 1 ); + + vtkCellArray *aCells = vtkCellArray::New(); + aCells->Allocate( 2 * nbPoints, 0 ); + + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents( 1 ); + aCellTypesArray->Allocate( nbPoints ); + + for( vtkIdType aCellId = 0; aCellId < nbPoints; aCellId++ ) + { + anIdList->SetId( 0, aCellId ); + aCells->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_VERTEX ); + } + + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + aCellLocationsArray->SetNumberOfComponents( 1 ); + aCellLocationsArray->SetNumberOfTuples( nbPoints ); + + aCells->InitTraversal(); + for( vtkIdType i = 0, *pts, npts; aCells->GetNextCell( npts, pts ); i++ ) + aCellLocationsArray->SetValue( i, aCells->GetTraversalLocation( npts ) ); + + myGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells ); + + aCellLocationsArray->Delete(); + aCellTypesArray->Delete(); + aCells->Delete(); + anIdList->Delete(); */ +} + +//================================================================================= +// function : buildElemPrs +// purpose : Create VTK cells for elements +//================================================================================= +void SMESH_VisualObj::buildElemPrs() +{ + // Create points + + vtkPoints* aPoints = vtkPoints::New(); + createPoints( aPoints ); + myGrid->SetPoints( aPoints ); + aPoints->Delete(); + + if ( MYDEBUG ) + MESSAGE("Update - myGrid->GetNumberOfPoints() = "<GetNumberOfPoints()); + + // Calculate cells size + + static SMESH::ElementType aTypes[ 3 ] = { SMESH::EDGE, SMESH::FACE, SMESH::VOLUME }; + + // get entity data + map< int, int > nbEnts; + map< int, TEntityList > anEnts; + + for ( int i = 0; i <= 2; i++ ) + nbEnts[ aTypes[ i ] ] = GetEntities( aTypes[ i ], anEnts[ aTypes[ i ] ] ); + + vtkIdType aCellsSize = 3 * nbEnts[ SMESH::EDGE ]; + + for ( int i = 1; i <= 2; i++ ) // iterate through faces and volumes + { + if ( nbEnts[ aTypes[ i ] ] ) + { + const TEntityList& aList = anEnts[ aTypes[ i ] ]; + TEntityList::const_iterator anIter; + for ( anIter = aList.begin(); anIter != aList.end(); ++anIter ) + aCellsSize += (*anIter)->NbNodes() + 1; + } + } + + vtkIdType aNbCells = nbEnts[ SMESH::EDGE ] + nbEnts[ SMESH::FACE ] + nbEnts[ SMESH::VOLUME ]; + + if ( MYDEBUG ) + MESSAGE( "Update - aNbCells = "<_is_nil() = "<_is_nil()); + + myMeshServer = SMESH::SMESH_Mesh::_duplicate( theMesh ); + myMeshServer->Register(); + myMesh = new SMDS_Mesh(); +} + +//================================================================================= +// function : ~SMESH_MeshObj +// purpose : Destructor +//================================================================================= +SMESH_MeshObj::~SMESH_MeshObj() +{ + myMeshServer->Destroy(); + delete myMesh; +} + +//================================================================================= +// function : Update +// purpose : Update mesh and fill grid with new values if necessary +//================================================================================= +void SMESH_MeshObj::Update( int theIsClear ) +{ + // Update SMDS_Mesh on client part + + try + { + SMESH::log_array_var aSeq = myMeshServer->GetLog( theIsClear ); + CORBA::Long aLength = aSeq->length(); + + if( MYDEBUG ) MESSAGE( "Update: length of the script is "<RemoveNode( FindNode( myMesh, anIndexes[anElemId] ) ); + break; + + case SMESH::REMOVE_ELEMENT: + for( ; anElemId < aNbElems; anElemId++ ) + myMesh->RemoveElement( FindElement( myMesh, anIndexes[anElemId] ) ); + break; + } + } + } + catch ( SALOME::SALOME_Exception& exc ) + { + INFOS("Follow exception was cought:\n\t"<NbNodes() = "<NbNodes()); + MESSAGE("Update - myMesh->NbEdges() = "<NbEdges()); + MESSAGE("Update - myMesh->NbFaces() = "<NbFaces()); + MESSAGE("Update - myMesh->NbVolumes() = "<NbVolumes()); + } + + // Fill unstructured grid + buildPrs(); +} + +//================================================================================= +// function : GetElemDimension +// purpose : Get dimension of element +//================================================================================= +int SMESH_MeshObj::GetElemDimension( const int theObjId ) +{ + const SMDS_MeshElement* anElem = myMesh->FindElement( theObjId ); + if ( anElem == 0 ) + return 0; + + int aType = anElem->GetType(); + switch ( aType ) + { + case SMDSAbs_Edge : return 1; + case SMDSAbs_Face : return 2; + case SMDSAbs_Volume: return 3; + default : return 0; + } +} + +//================================================================================= +// function : GetEntities +// purpose : Get entities of specified type. Return number of entities +//================================================================================= +int SMESH_MeshObj::GetNbEntities( const SMESH::ElementType theType) const +{ + switch ( theType ) + { + case SMESH::NODE: + { + return myMesh->NbNodes(); + } + break; + case SMESH::EDGE: + { + return myMesh->NbEdges(); + } + break; + case SMESH::FACE: + { + return myMesh->NbFaces(); + } + break; + case SMESH::VOLUME: + { + return myMesh->NbVolumes(); + } + break; + default: + return 0; + break; + } +} + +int SMESH_MeshObj::GetEntities( const SMESH::ElementType theType, TEntityList& theObjs ) const +{ + theObjs.clear(); + + switch ( theType ) + { + case SMESH::NODE: + { + SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator(); + while ( anIter->more() ) theObjs.push_back( anIter->next() ); + } + break; + case SMESH::EDGE: + { + SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); + while ( anIter->more() ) theObjs.push_back( anIter->next() ); + } + break; + case SMESH::FACE: + { + SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); + while ( anIter->more() ) theObjs.push_back( anIter->next() ); + } + break; + case SMESH::VOLUME: + { + SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator(); + while ( anIter->more() ) theObjs.push_back( anIter->next() ); + } + break; + default: + break; + } + + return theObjs.size(); +} + +//================================================================================= +// function : UpdateFunctor +// purpose : Update functor in accordance with current mesh +//================================================================================= +void SMESH_MeshObj::UpdateFunctor( SMESH::Functor_ptr f ) +{ + f->SetMesh( myMeshServer ); +} + +//================================================================================= +// function : IsNodePrs +// purpose : Return true if node presentation is used +//================================================================================= +bool SMESH_MeshObj::IsNodePrs() const +{ + return myMesh->NbEdges() == 0 &&myMesh->NbFaces() == 0 &&myMesh->NbVolumes() == 0 ; +} + + +/* + Class : SMESH_SubMeshObj + Description : Base class for visualisation of submeshes and groups +*/ + +//================================================================================= +// function : SMESH_SubMeshObj +// purpose : Constructor +//================================================================================= +SMESH_SubMeshObj::SMESH_SubMeshObj( SMESH_MeshObj* theMeshObj ) +{ + if ( MYDEBUG ) MESSAGE( "SMESH_SubMeshObj - theMeshObj = " << theMeshObj ); + + myMeshObj = theMeshObj; +} + +SMESH_SubMeshObj::~SMESH_SubMeshObj() +{ +} + +//================================================================================= +// function : GetElemDimension +// purpose : Get dimension of element +//================================================================================= +int SMESH_SubMeshObj::GetElemDimension( const int theObjId ) +{ + return myMeshObj == 0 ? 0 : myMeshObj->GetElemDimension( theObjId ); +} + +//================================================================================= +// function : UpdateFunctor +// purpose : Update functor in accordance with current mesh +//================================================================================= +void SMESH_SubMeshObj::UpdateFunctor( SMESH::Functor_ptr f ) +{ + f->SetMesh( myMeshObj->GetMeshServer() ); +} + +//================================================================================= +// function : UpdateFunctor +// purpose : Update mesh object and fill grid with new values +//================================================================================= +void SMESH_SubMeshObj::Update( int theIsClear ) +{ + myMeshObj->Update( theIsClear ); + buildPrs(); +} + + +/* + Class : SMESH_GroupObj + Description : Class for visualisation of groups +*/ + +//================================================================================= +// function : SMESH_GroupObj +// purpose : Constructor +//================================================================================= +SMESH_GroupObj::SMESH_GroupObj( SMESH::SMESH_Group_ptr theGroup, + SMESH_MeshObj* theMeshObj ) +: SMESH_SubMeshObj( theMeshObj ), + myGroupServer( SMESH::SMESH_Group::_duplicate(theGroup) ) +{ + if ( MYDEBUG ) MESSAGE("SMESH_GroupObj - theGroup->_is_nil() = "<_is_nil()); + myGroupServer->Register(); +} + +SMESH_GroupObj::~SMESH_GroupObj() +{ + if ( MYDEBUG ) MESSAGE("~SMESH_GroupObj"); + myGroupServer->Destroy(); +} + +//================================================================================= +// function : IsNodePrs +// purpose : Return true if node presentation is used +//================================================================================= +bool SMESH_GroupObj::IsNodePrs() const +{ + return myGroupServer->GetType() == SMESH::NODE; +} + +//================================================================================= +// function : getNodesFromElems +// purpose : Retrieve nodes from elements +//================================================================================= +static int getNodesFromElems( SMESH::long_array_var& theElemIds, + const SMDS_Mesh* theMesh, + std::list& theResList ) +{ + set aNodeSet; + + for ( CORBA::Long i = 0, n = theElemIds->length(); i < n; i++ ) + { + const SMDS_MeshElement* anElem = theMesh->FindElement( theElemIds[ i ] ); + if ( anElem != 0 ) + { + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); + while ( anIter->more() ) + { + const SMDS_MeshElement* aNode = anIter->next(); + if ( aNode != 0 ) + aNodeSet.insert( aNode ); + } + } + } + + set::const_iterator anIter; + for ( anIter = aNodeSet.begin(); anIter != aNodeSet.end(); ++anIter ) + theResList.push_back( *anIter ); + + return theResList.size(); +} + +//================================================================================= +// function : getPointers +// purpose : Get std::list from list of IDs +//================================================================================= +static int getPointers( const SMESH::ElementType theRequestType, + SMESH::long_array_var& theElemIds, + const SMDS_Mesh* theMesh, + std::list& theResList ) +{ + for ( CORBA::Long i = 0, n = theElemIds->length(); i < n; i++ ) + { + const SMDS_MeshElement* anElem = theRequestType == SMESH::NODE + ? theMesh->FindNode( theElemIds[ i ] ) : theMesh->FindElement( theElemIds[ i ] ); + + if ( anElem != 0 ) + theResList.push_back( anElem ); + } + + return theResList.size(); +} + + +//================================================================================= +// function : GetEntities +// purpose : Get entities of specified type. Return number of entities +//================================================================================= +int SMESH_GroupObj::GetNbEntities( const SMESH::ElementType theType) const +{ + if(myGroupServer->GetType() == theType){ + return myGroupServer->Size(); + } + return 0; +} + +int SMESH_GroupObj::GetEntities( const SMESH::ElementType theType, TEntityList& theResList ) const +{ + theResList.clear(); + SMDS_Mesh* aMesh = myMeshObj->GetMesh(); + + if ( myGroupServer->Size() == 0 || aMesh == 0 ) + return 0; + + SMESH::ElementType aGrpType = myGroupServer->GetType(); + SMESH::long_array_var anIds = myGroupServer->GetListOfID(); + + if ( aGrpType == theType ) + return getPointers( theType, anIds, aMesh, theResList ); + else if ( theType == SMESH::NODE ) + return getNodesFromElems( anIds, aMesh, theResList ); + else + return 0; +} + + + +/* + Class : SMESH_subMeshObj + Description : Class for visualisation of submeshes +*/ + +//================================================================================= +// function : SMESH_subMeshObj +// purpose : Constructor +//================================================================================= +SMESH_subMeshObj::SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr theSubMesh, + SMESH_MeshObj* theMeshObj ) +: SMESH_SubMeshObj( theMeshObj ), + mySubMeshServer( SMESH::SMESH_subMesh::_duplicate( theSubMesh ) ) +{ + if ( MYDEBUG ) MESSAGE( "SMESH_subMeshObj - theSubMesh->_is_nil() = " << theSubMesh->_is_nil() ); + + mySubMeshServer->Register(); +} + +SMESH_subMeshObj::~SMESH_subMeshObj() +{ + if ( MYDEBUG ) MESSAGE( "~SMESH_subMeshObj" ); + mySubMeshServer->Destroy(); +} + +//================================================================================= +// function : GetEntities +// purpose : Get entities of specified type. Return number of entities +//================================================================================= +int SMESH_subMeshObj::GetNbEntities( const SMESH::ElementType theType) const +{ + switch ( theType ) + { + case SMESH::NODE: + { + return mySubMeshServer->GetNumberOfNodes(); + } + break; + case SMESH::EDGE: + case SMESH::FACE: + case SMESH::VOLUME: + { + SMESH::long_array_var anIds = mySubMeshServer->GetElementsByType( theType ); + return anIds->length(); + } + default: + return 0; + break; + } +} + +int SMESH_subMeshObj::GetEntities( const SMESH::ElementType theType, TEntityList& theResList ) const +{ + theResList.clear(); + + SMDS_Mesh* aMesh = myMeshObj->GetMesh(); + if ( aMesh == 0 ) + return 0; + + bool isNodal = IsNodePrs(); + + if ( isNodal ) + { + if ( theType == SMESH::NODE ) + { + SMESH::long_array_var anIds = mySubMeshServer->GetNodesId(); + return getPointers( SMESH::NODE, anIds, aMesh, theResList ); + } + } + else + { + if ( theType == SMESH::NODE ) + { + SMESH::long_array_var anIds = mySubMeshServer->GetElementsId(); + return getNodesFromElems( anIds, aMesh, theResList ); + } + else + { + SMESH::long_array_var anIds = mySubMeshServer->GetElementsByType( theType ); + return getPointers( theType, anIds, aMesh, theResList ); + } + } + + return 0; +} + +//================================================================================= +// function : IsNodePrs +// purpose : Return true if node presentation is used +//================================================================================= +bool SMESH_subMeshObj::IsNodePrs() const +{ + return mySubMeshServer->GetNumberOfElements() == 0; +} + + + + + + + + + + + + diff --git a/src/OBJECT/SMESH_Object.h b/src/OBJECT/SMESH_Object.h new file mode 100644 index 000000000..6ed30e2fa --- /dev/null +++ b/src/OBJECT/SMESH_Object.h @@ -0,0 +1,207 @@ +// SMESH OBJECT : interactive object for SMESH visualization +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Object.h +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#ifndef SMESH_OBJECT_H +#define SMESH_OBJECT_H + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Group) +#include CORBA_SERVER_HEADER(SMESH_Filter) + +#include +#include +#include +#include + +class vtkUnstructuredGrid; +class vtkPoints; +class SALOME_ExtractUnstructuredGrid; + +class SMESH_Actor; +class SMDS_Mesh; +class SMDS_MeshNode; +class SMDS_MeshElement; + +class SMESH_VisualObj; +typedef boost::shared_ptr TVisualObjPtr; + + +/* + Class : SMESH_VisualObj + Description : Base class for all mesh objects to be visuilised +*/ + +class SMESH_VisualObj +{ +protected: + + typedef std::list TEntityList; + typedef std::map TMapOfIds; + +public: + SMESH_VisualObj(); + virtual ~SMESH_VisualObj(); + + virtual void Update( int theIsClear = true ) = 0; + virtual void UpdateFunctor( SMESH::Functor_ptr theFunctor ) = 0; + virtual int GetElemDimension( const int theObjId ) = 0; + + virtual int GetNbEntities( const SMESH::ElementType) const = 0; + virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const = 0; + virtual bool IsNodePrs() const = 0; + + vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; } + + vtkIdType GetNodeObjId( int theVTKID ); + vtkIdType GetNodeVTKId( int theObjID ); + vtkIdType GetElemObjId( int theVTKID ); + vtkIdType GetElemVTKId( int theObjID ); + +protected: + + void createPoints( vtkPoints* ); + void buildPrs(); + void buildNodePrs(); + void buildElemPrs(); + +private: + + TMapOfIds mySMDS2VTKNodes; + TMapOfIds myVTK2SMDSNodes; + TMapOfIds mySMDS2VTKElems; + TMapOfIds myVTK2SMDSElems; + + vtkUnstructuredGrid* myGrid; +}; + + +/* + Class : SMESH_MeshObj + Description : Class for visualisation of mesh +*/ + +class SMESH_MeshObj: public SMESH_VisualObj +{ +public: + + SMESH_MeshObj( SMESH::SMESH_Mesh_ptr ); + virtual ~SMESH_MeshObj(); + + virtual void Update( int theIsClear = true ); + + virtual int GetNbEntities( const SMESH::ElementType) const; + virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const; + virtual bool IsNodePrs() const; + + virtual int GetElemDimension( const int theObjId ); + + virtual void UpdateFunctor( SMESH::Functor_ptr f ); + + SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); } + SMDS_Mesh* GetMesh() { return myMesh; } + +protected: + + SMESH::SMESH_Mesh_var myMeshServer; + SMDS_Mesh* myMesh; +}; + + +/* + Class : SMESH_SubMeshObj + Description : Base class for visualisation of submeshes and groups +*/ + +class SMESH_SubMeshObj: public SMESH_VisualObj +{ +public: + + SMESH_SubMeshObj(SMESH_MeshObj* theMeshObj); + virtual ~SMESH_SubMeshObj(); + + virtual void Update( int theIsClear = true ); + + virtual void UpdateFunctor( SMESH::Functor_ptr ); + virtual int GetElemDimension( const int theObjId ); + +protected: + + SMESH_MeshObj* myMeshObj; +}; + + +/* + Class : SMESH_GroupObj + Description : Class for visualisation of groups +*/ + +class SMESH_GroupObj: public SMESH_SubMeshObj +{ +public: + SMESH_GroupObj( SMESH::SMESH_Group_ptr, SMESH_MeshObj* ); + virtual ~SMESH_GroupObj(); + + virtual int GetNbEntities( const SMESH::ElementType) const; + virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const; + virtual bool IsNodePrs() const; + +private: + + SMESH::SMESH_Group_var myGroupServer; +}; + + +/* + Class : SMESH_subMeshObj + Description : Class for visualisation of submeshes +*/ + +class SMESH_subMeshObj : public SMESH_SubMeshObj +{ +public: + + SMESH_subMeshObj( SMESH::SMESH_subMesh_ptr, + SMESH_MeshObj* ); + virtual ~SMESH_subMeshObj(); + + virtual int GetNbEntities( const SMESH::ElementType) const; + virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const; + virtual bool IsNodePrs() const; + +protected: + + SMESH::SMESH_subMesh_var mySubMeshServer; +}; + + +extern void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName); + + +#endif diff --git a/src/SMESH/SMESH_Group.cxx b/src/SMESH/SMESH_Group.cxx new file mode 100644 index 000000000..da29a2989 --- /dev/null +++ b/src/SMESH/SMESH_Group.cxx @@ -0,0 +1,55 @@ +// SMESH SMESH : implementaion of SMESH idl descriptions +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESH_Group.cxx +// Author : Michael Sazonov (OCC) +// Module : SMESH +// $Header$ + +#include +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH_Group::SMESH_Group (const SMESH_Mesh* theMesh, + const SMDSAbs_ElementType theType, + const char* theName) + : myName(theName) +{ + myGroupDS = new SMESHDS_Group (const_cast(theMesh)->GetMeshDS(), theType); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH_Group::~SMESH_Group () +{ + delete myGroupDS; +} diff --git a/src/SMESH/SMESH_Group.hxx b/src/SMESH/SMESH_Group.hxx new file mode 100644 index 000000000..5147a44d7 --- /dev/null +++ b/src/SMESH/SMESH_Group.hxx @@ -0,0 +1,64 @@ +// SMESH SMESH : implementaion of SMESH idl descriptions +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESH_Group.hxx +// Author : Michael Sazonov (OCC) +// Module : SMESH +// $Header$ + +#ifndef _SMESH_Group_HeaderFile +#define _SMESH_Group_HeaderFile + +#include +#include +using namespace std; + +class SMESHDS_Group; +class SMESH_Mesh; + +class SMESH_Group +{ + public: + + SMESH_Group (const SMESH_Mesh* theMesh, + const SMDSAbs_ElementType theType, + const char* theName); + ~SMESH_Group (); + + void SetName (const char* theName) { myName = theName; } + + const char* GetName () const { return myName.c_str(); } + + SMESHDS_Group * GetGroupDS () { return myGroupDS; } + + private: + SMESH_Group (const SMESH_Group& theOther); + // prohibited copy constructor + SMESH_Group& operator = (const SMESH_Group& theOther); + // prohibited assign operator + + SMESHDS_Group * myGroupDS; + string myName; + +}; + +#endif diff --git a/src/SMESHDS/SMESHDS_Group.cxx b/src/SMESHDS/SMESHDS_Group.cxx new file mode 100644 index 000000000..29d7db4f4 --- /dev/null +++ b/src/SMESHDS/SMESHDS_Group.cxx @@ -0,0 +1,129 @@ +// SMESH SMESHDS : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESHDS_Group.cxx +// Author : Michael Sazonov, OCC +// Module : SMESH +// $Header$ + +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESHDS_Group::SMESHDS_Group (const SMESHDS_Mesh* theMesh, + const SMDSAbs_ElementType theType) + : SMDS_MeshGroup(theMesh,theType), myStoreName(""), + myCurIndex(0), myCurID(0) +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool SMESHDS_Group::Contains (const int theID) const +{ + const SMDS_MeshElement* aElem = findInMesh (theID); + if (aElem) + return SMDS_MeshGroup::Contains(aElem); + return false; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool SMESHDS_Group::Add (const int theID) +{ + const SMDS_MeshElement* aElem = findInMesh (theID); + if (!aElem || SMDS_MeshGroup::Contains(aElem)) + return false; + SMDS_MeshGroup::Add (aElem); + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool SMESHDS_Group::Remove (const int theID) +{ + const SMDS_MeshElement* aElem = findInMesh (theID); + if (!aElem || !SMDS_MeshGroup::Contains(aElem)) + return false; + SMDS_MeshGroup::Remove (aElem); + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +int SMESHDS_Group::GetID (const int theIndex) +{ + if (theIndex < 1 || theIndex > Extent()) + return -1; + if (myCurIndex < 1 || myCurIndex > theIndex) { + InitIterator(); + myCurIndex = 0; + myCurID = -1; + } + while (myCurIndex < theIndex && More()) { + myCurIndex++; + myCurID = Next()->GetID(); + } + return myCurID; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +const SMDS_MeshElement* SMESHDS_Group::findInMesh (const int theID) const +{ + SMDSAbs_ElementType aType = GetType(); + const SMDS_MeshElement* aElem = NULL; + if (aType == SMDSAbs_Node) { + aElem = GetMesh()->FindNode(theID); + } + else if (aType != SMDSAbs_All) { + aElem = GetMesh()->FindElement(theID); + if (aElem && aType != aElem->GetType()) + aElem = NULL; + } + return aElem; +} diff --git a/src/SMESHDS/SMESHDS_Group.hxx b/src/SMESHDS/SMESHDS_Group.hxx new file mode 100644 index 000000000..444914cee --- /dev/null +++ b/src/SMESHDS/SMESHDS_Group.hxx @@ -0,0 +1,72 @@ +// SMESH SMESHDS : management of mesh data and SMESH document +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESHDS_Group.hxx +// Author : Michael Sazonov (OCC) +// Module : SMESH +// $Header$ + +#ifndef _SMESHDS_Group_HeaderFile +#define _SMESHDS_Group_HeaderFile + +#include +#include + +class SMESHDS_Mesh; + +class SMESHDS_Group : public SMDS_MeshGroup +{ + public: + + SMESHDS_Group (const SMESHDS_Mesh* theMesh, + const SMDSAbs_ElementType theType); + + void SetStoreName (const char* theName) + { myStoreName = theName; } + + const char* GetStoreName () const + { return myStoreName.c_str(); } + + bool Contains (const int theID) const; + + bool Add (const int theID); + bool Remove (const int theID); + + int GetID (const int theIndex); + // use it for iterations 1..Extent() as alternative to parent's + // InitIterator(), More(), Next() + + private: + SMESHDS_Group (const SMESHDS_Group& theOther); + // prohibited copy constructor + SMESHDS_Group& operator = (const SMESHDS_Group& theOther); + // prohibited assign operator + + const SMDS_MeshElement* findInMesh (const int theID) const; + + string myStoreName; + int myCurIndex; + int myCurID; + +}; + +#endif diff --git a/src/SMESHGUI/SMESHBin.cxx b/src/SMESHGUI/SMESHBin.cxx new file mode 100644 index 000000000..61f9777fe --- /dev/null +++ b/src/SMESHGUI/SMESHBin.cxx @@ -0,0 +1,4 @@ +int main(int argc, char** argv){ + return 0; +} + diff --git a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx new file mode 100644 index 000000000..fd494fb60 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx @@ -0,0 +1,290 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : SMESHGUI_CreateHypothesesDlg.cxx +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +using namespace std; +#include "SMESHGUI_CreateHypothesesDlg.h" +#include "SMESHGUI.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : SMESHGUI_CreateHypothesesDlg() +// purpose : Constructs a SMESHGUI_CreateHypothesesDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +SMESHGUI_CreateHypothesesDlg::SMESHGUI_CreateHypothesesDlg (QWidget* parent, + const char* name, + bool modal, + bool isAlgo) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ), + myIsAlgo( isAlgo ) +{ + MESSAGE("SMESHGUI_CreateHypothesesDlg"); + + if ( !name ) + setName( "SMESHGUI_CreateHypothesesDlg" ); + setCaption( isAlgo ? tr( "SMESH_CREATE_ALGORITHMS" ) : tr( "SMESH_CREATE_HYPOTHESES" ) ); + setSizeGripEnabled( TRUE ); + + QGridLayout* SMESHGUI_CreateHypothesesDlgLayout = new QGridLayout( this ); + SMESHGUI_CreateHypothesesDlgLayout->setSpacing( 6 ); + SMESHGUI_CreateHypothesesDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupAlgorithms = new QGroupBox( this, "GroupAlgorithms" ); + GroupAlgorithms->setTitle( isAlgo ? tr("SMESH_AVAILABLE_ALGORITHMS") : tr("SMESH_AVAILABLE_HYPOTHESES") ); + GroupAlgorithms->setColumnLayout(0, Qt::Vertical ); + GroupAlgorithms->layout()->setSpacing( 0 ); + GroupAlgorithms->layout()->setMargin( 0 ); + + QGridLayout* hypLayout = new QGridLayout( GroupAlgorithms->layout() ); + hypLayout->setGeometry( QRect( 12, 18, 139, 250 ) ); + hypLayout->setAlignment( Qt::AlignTop ); + hypLayout->setSpacing( 6 ); + hypLayout->setMargin( 11 ); + + ListAlgoDefinition = new QListView( GroupAlgorithms, "ListAlgoDefinition" ); + ListAlgoDefinition->setMinimumSize( 400, 200 ); + ListAlgoDefinition->addColumn(""); + ListAlgoDefinition->header()->hide(); + ListAlgoDefinition->setSelectionMode(QListView::Single); + ListAlgoDefinition->setResizeMode(QListView::AllColumns); + ListAlgoDefinition->setRootIsDecorated( true ); + + hypLayout->addWidget( ListAlgoDefinition, 0, 0 ); + SMESHGUI_CreateHypothesesDlgLayout->addWidget( GroupAlgorithms, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout( 0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_CREATE" ) ); + buttonApply->setAutoDefault( TRUE ); + buttonApply->setDefault( FALSE ); + buttonApply->setEnabled( FALSE ) ; + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + buttonCancel->setDefault( TRUE ); + buttonCancel->setEnabled( TRUE ) ; + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + + SMESHGUI_CreateHypothesesDlgLayout->addWidget( GroupButtons, 1, 0 ); + /***************************************************************/ + + Init(); +} + +//================================================================================= +// function : ~SMESHGUI_CreateHypothesesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_CreateHypothesesDlg::~SMESHGUI_CreateHypothesesDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_CreateHypothesesDlg::Init() +{ + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + InitAlgoDefinition(); + + /* signals and slots connections */ + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply , SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) ) ; + +// connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + connect( ListAlgoDefinition, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) ); + connect( ListAlgoDefinition, SIGNAL( doubleClicked(QListViewItem*) ), this, SLOT( onDoubleClicked(QListViewItem*) ) ); + + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_CreateHypothesesDlg::ClickOnCancel() +{ + close() ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_CreateHypothesesDlg::ClickOnApply() +{ + QListViewItem* item = ListAlgoDefinition->selectedItem(); + if ( !item ) + return; + QString aHypType = item->text( 1 ); + MESSAGE("Apply " << aHypType); + char* sHypType = (char*)aHypType.latin1(); + + HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); + if ( !aHypData ) + return; + QString aClientLibName = aHypData->ClientLibName; + MESSAGE("Client lib name = " << aClientLibName); + + if (aClientLibName == "") + { + // Call hypothesis creation server method (without GUI) + QString aHypName = aHypData->Label; + mySMESHGUI->CreateHypothesis(sHypType, aHypName, myIsAlgo); + } + else + { + // Get hypotheses creator client (GUI) + SMESHGUI_GenericHypothesisCreator* aCreator = + mySMESHGUI->GetHypothesisCreator(sHypType); + + // Create hypothesis/algorithm + aCreator->CreateHypothesis(myIsAlgo, this); + } + +// buttonApply->setEnabled(FALSE); + return; +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_CreateHypothesesDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupButtons->setEnabled(true) ; + return ; +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_CreateHypothesesDlg::enterEvent(QEvent* e) +{ + ActivateThisDialog() ; + return ; +} + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_CreateHypothesesDlg::closeEvent( QCloseEvent* e ) +{ + mySMESHGUI->ResetState(); + QDialog::closeEvent( e ); +} + +//================================================================================= +// function : onSelectionChanged() +// purpose : +//================================================================================= +void SMESHGUI_CreateHypothesesDlg::onSelectionChanged() +{ + QListViewItem* item = ListAlgoDefinition->selectedItem(); + buttonApply->setEnabled( item && item->depth() > 0 ) ; +} + +//================================================================================= +// function : onDoubleClicked() +// purpose : +//================================================================================= +void SMESHGUI_CreateHypothesesDlg::onDoubleClicked(QListViewItem* i) +{ + if ( i && i->depth() > 0 ) + this->ClickOnApply(); +} + +//================================================================================= +// function : InitAlgoDefinition() +// purpose : +//================================================================================= +void SMESHGUI_CreateHypothesesDlg::InitAlgoDefinition() +{ + ListAlgoDefinition->clear(); + QStringList HypList = mySMESHGUI->GetAvailableHypotheses(myIsAlgo); + for ( int i = 0; i < HypList.count(); ++i ) { + HypothesisData* aHypData = mySMESHGUI->GetHypothesisData( HypList[i] ); + QListViewItem* parentItem = 0; + QListViewItem* childItem = ListAlgoDefinition->firstChild(); + while ( childItem ) { + if ( childItem->text(0) == aHypData->PluginName ) { + parentItem = childItem; + break; + } + childItem = childItem->nextSibling(); + } + if ( !parentItem ) + parentItem = new QListViewItem( ListAlgoDefinition, aHypData->PluginName ); + parentItem->setOpen( true ); + QListViewItem* aItem = new QListViewItem( parentItem, aHypData->Label, HypList[i] ); + QPixmap aPixMap (QAD_Desktop::getResourceManager()->loadPixmap + ("SMESH", tr(aHypData->IconId))); + if ( !aPixMap.isNull() ) + aItem->setPixmap( 0, aPixMap ); + } +} diff --git a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h new file mode 100644 index 000000000..4fa446d5c --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h @@ -0,0 +1,97 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : SMESHGUI_CreateHypothesesDlg.h +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +#ifndef DIALOGBOX_CREATE_HYPOTHESES_H +#define DIALOGBOX_CREATE_HYPOTHESES_H + +// QT Includes +#include +#include +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +#include +#include + +using namespace std; + +class QButtonGroup; +class QGroupBox; +class QPushButton; +class QListView; +class QListViewItem; +class SMESHGUI; + +//================================================================================= +// class : SMESHGUI_CreateHypothesesDlg +// purpose : +//================================================================================= +class SMESHGUI_CreateHypothesesDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_CreateHypothesesDlg (QWidget* parent = 0, + const char* name = 0, + bool modal = FALSE, + bool isAlgo = FALSE); + ~SMESHGUI_CreateHypothesesDlg (); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + void InitAlgoDefinition(); + + SMESHGUI* mySMESHGUI; + bool myIsAlgo; + + QGroupBox* GroupButtons; + QPushButton* buttonCancel; + QPushButton* buttonApply; + + QGroupBox* GroupAlgorithms; + QListView* ListAlgoDefinition; + +private slots: + + void ClickOnCancel(); + void ClickOnApply(); + void ActivateThisDialog() ; + + void onSelectionChanged(); + void onDoubleClicked(QListViewItem*); +}; + +#endif // DIALOGBOX_CREATE_HYPOTHESES_H diff --git a/src/SMESHGUI/SMESHGUI_Filter.cxx b/src/SMESHGUI/SMESHGUI_Filter.cxx new file mode 100755 index 000000000..22a2e8910 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Filter.cxx @@ -0,0 +1,114 @@ +// SMESHGUI_Filter : Filters for VTK viewer +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_Filter.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_Filter.h" + +#include + +#include +#include +#include "SMESH_Actor.h" +#include "SMESHGUI.h" + +IMPLEMENT_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter) +IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_Filter, VTKViewer_Filter) + +/* + Class : SMESHGUI_Filter + Description : Selection filter for VTK viewer. This class aggregate object + of SMESH_Filter class and uses it for verification of criterion +*/ + +//======================================================================= +// name : SMESHGUI_Filter::SMESHGUI_Filter +// Purpose : Constructor +//======================================================================= +SMESHGUI_Filter::SMESHGUI_Filter() +{ + myActor = 0; +} + +SMESHGUI_Filter::~SMESHGUI_Filter() +{ +} + +//======================================================================= +// name : SMESHGUI_Filter::IsValid +// Purpose : Verify whether entry id satisfies to criterion of the filter +//======================================================================= +bool SMESHGUI_Filter::IsValid( const int theCellId ) const +{ + if ( myActor == 0 || myPred->_is_nil() ) + return false; + + SMESH_Actor* anActor = ( SMESH_Actor* )myActor; + + int aMeshId = anActor->GetElemObjId( theCellId ); + + return myPred->IsSatisfy( aMeshId ); +} + +//======================================================================= +// name : SMESHGUI_Filter::SetPredicate +// Purpose : Set new pridicate to the filter +//======================================================================= +void SMESHGUI_Filter::SetPredicate( SMESH::Predicate_ptr thePred ) +{ + myPred = thePred; +} + +//======================================================================= +// name : SMESHGUI_Filter::GetActor +// Purpose : Get actor of the filter +//======================================================================= +SALOME_Actor* SMESHGUI_Filter::GetActor() const +{ + return myActor; +} + +//======================================================================= +// name : SMESHGUI_Filter::SetActor +// Purpose : Set new actor +//======================================================================= +void SMESHGUI_Filter::SetActor( SALOME_Actor* theActor ) +{ + if ( myActor == theActor ) + return; + VTKViewer_Filter::SetActor( theActor ); + + if ( myActor != 0 && !myPred->_is_nil() ) + { + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + if ( !anIO.IsNull() ) + { + Standard_Boolean aRes = false; + SMESH::SMESH_Mesh_ptr aMeshPtr = SMESHGUI::GetSMESHGUI()->ConvertIOinMesh( anIO, aRes ); + if ( aRes ) + myPred->SetMesh( aMeshPtr ); + } + } +} diff --git a/src/SMESHGUI/SMESHGUI_Filter.h b/src/SMESHGUI/SMESHGUI_Filter.h new file mode 100755 index 000000000..91f3bd700 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Filter.h @@ -0,0 +1,68 @@ +// SMESHGUI_Filter : Filters for VTK viewer +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_Filter.h +// Author : Sergey LITONIN +// Module : SMESH + +#ifndef SMESHGUI_Filter_HeaderFile +#define SMESHGUI_Filter_HeaderFile + +#include "VTKViewer_Filter.h" + +#include +#include CORBA_SERVER_HEADER(SMESH_Filter) + +class SALOME_Actor; + + +DEFINE_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter) + +/* + Class : SMESHGUI_Filter + Description : Selection filter for VTK viewer +*/ + +class SMESHGUI_Filter : public VTKViewer_Filter +{ + +public: + SMESHGUI_Filter(); + virtual ~SMESHGUI_Filter(); + + virtual bool IsValid( const int theCellId ) const; + + virtual void SetActor( SALOME_Actor* ); + SALOME_Actor* GetActor() const; + + void SetPredicate( SMESH::Predicate_ptr ); + +private: + + SMESH::Predicate_var myPred; + +public: + DEFINE_STANDARD_RTTI(SMESHGUI_Filter) +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx new file mode 100755 index 000000000..5995bd8ba --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -0,0 +1,1302 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_FilterDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI.h" +#include "SMESHGUI_FilterDlg.h" +#include "SMESHGUI_Filter.h" +#include "SMESH_Actor.h" +#include "VTKViewer_InteractorStyleSALOME.h" +#include "VTKViewer_ViewFrame.h" +#include "QAD_RightFrame.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 + +static int maxLength( const QStringList& theList, const QFontMetrics& theMetrics ) +{ + int aRes = 0; + QStringList::const_iterator anIter; + for ( anIter = theList.begin(); anIter != theList.end(); ++anIter ) + aRes = Max( aRes, theMetrics.width( *anIter ) ); + return aRes; +} + +/* + Class : SMESHGUI_FilterDlg::Table + Description : Table used by this dialog +*/ + +class SMESHGUI_FilterDlg::Table : public QTable +{ +public: + Table( QWidget* parent = 0 ); + Table( int numRows, int numCols, QWidget* parent = 0 ); + virtual ~Table(); + + void SetEditable( const bool state, const int row, const int col ); + bool IsEditable( const int row, const int col ) const; + + virtual bool eventFilter( QObject *o, QEvent *e ); + virtual void insertRows( int row, int count = 1 ); + virtual QString text( int row, int col ) const; +}; + +SMESHGUI_FilterDlg::Table::Table( QWidget* parent ) +: QTable( parent, "SMESHGUI_FilterDlg::Table" ) +{ +} + +SMESHGUI_FilterDlg::Table::Table( int numRows, int numCols, QWidget* parent ) +: QTable( numRows, numCols, parent, "SMESHGUI_FilterDlg::Table" ) +{ +} + +SMESHGUI_FilterDlg::Table::~Table() +{ +} + +void SMESHGUI_FilterDlg::Table::SetEditable( const bool isEditable, const int row, const int col ) +{ + QTableItem* anItem = item( row, col ); + if( anItem ) + takeItem( anItem ); + + if ( !isEditable ) + { + setItem( row, col, new QTableItem( this, QTableItem::Never, "" ) ); + } + else + { + setItem( row, col, new QTableItem( this, QTableItem::OnTyping, "" ) ); + } +} + +bool SMESHGUI_FilterDlg::Table::IsEditable( const int row, const int col ) const +{ + QTableItem* anItem = item( row, col ); + return anItem == 0 || anItem->editType() != QTableItem::Never; +} + +void SMESHGUI_FilterDlg::Table::insertRows( int row, int count ) +{ + int anEditRow = currEditRow(); + int anEditCol = currEditCol(); + +// printf( "sln: anEditRow = %d, anEditCol = %d\n", anEditRow, anEditCol ); + + if ( anEditRow >= 0 && anEditCol >= 0 ) + endEdit( anEditRow, anEditCol, true, false ); + + QTable::insertRows( row, count ); +} + +QString SMESHGUI_FilterDlg::Table::text( int row, int col ) const +{ + int anEditRow = currEditRow(); + int anEditCol = currEditCol(); + + if ( anEditRow >= 0 && anEditCol >= 0 && anEditRow == row && anEditCol == col ) + ((Table*)this)->endEdit( row, col, true, false ); + + return QTable::text( row, col ); +} + +bool SMESHGUI_FilterDlg::Table::eventFilter( QObject *o, QEvent *e ) +{ + return QTable::eventFilter( o, e ); +} + +/* + Class : SMESHGUI_FilterDlg + Description : Dialog to specify filters for VTK viewer +*/ + + +//======================================================================= +// name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( QWidget* theParent, + const int theType, + const bool theModal, + const char* theName ) +: QDialog( theParent, theName, theModal, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myType = theType; + + setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + myMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this, theModal ); + + aDlgLay->addWidget( myMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( myMainFrame, 1 ); + + Init( myType ); +} + + +//======================================================================= +// name : SMESHGUI_FilterDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_FilterDlg::createMainFrame( QWidget* theParent ) +{ + QGroupBox* aMainFrame = new QGroupBox( 1, Qt::Horizontal, theParent ); + aMainFrame->setFrameStyle( QFrame::NoFrame ); + aMainFrame->setInsideMargin( 0 ); + + // filter frame + + QGroupBox* aFilterGrp = new QGroupBox( 1, Qt::Horizontal, tr ( "Filter" ), aMainFrame ); + QFrame* aFilterFrame = new QFrame( aFilterGrp ); + + myTableGrp = new QGroupBox( 1, Qt::Horizontal, aFilterFrame ); + myTableGrp->setFrameStyle( QFrame::NoFrame ); + myTableGrp->setInsideMargin( 0 ); + + myTables[ myType ] = createTable( myTableGrp, myType ); + myAddBtn = new QPushButton( tr( "ADD" ), aFilterFrame ); + myRemoveBtn = new QPushButton( tr( "REMOVE" ), aFilterFrame ); + myClearBtn = new QPushButton( tr( "CLEAR" ), aFilterFrame ); + + QGridLayout* aLay = new QGridLayout( aFilterFrame, 4, 2, 0, SPACING ); + + aLay->addMultiCellWidget( myTableGrp, 0, 3, 0, 0 ); + aLay->addWidget( myAddBtn, 0, 1 ); + aLay->addWidget( myRemoveBtn, 1, 1 ); + aLay->addWidget( myClearBtn, 2, 1 ); + aLay->setColStretch( 0, 1 ); + aLay->setColStretch( 1, 0 ); + + mySetInViewer = new QCheckBox( tr( "SET_IN_VIEWER" ), aFilterGrp ); + mySetInViewer->setChecked( true ); + + QSpacerItem* aVSpacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aLay->addItem( aVSpacer, 3, 1 ); + + // other controls + mySourceGrp = createSourceGroup( aMainFrame ); + + // signals and slots + connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddBtn() ) ); + connect( myRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemoveBtn() ) ); + connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( onClearBtn() ) ); + + return aMainFrame; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::createSourceFrame +// Purpose : Create frame containing source radio button +//======================================================================= +QButtonGroup* SMESHGUI_FilterDlg::createSourceGroup( QWidget* theParent ) +{ + QButtonGroup* aGrp = new QButtonGroup( 1, Qt::Vertical, tr( "SOURCE" ), theParent ); + + QRadioButton* aMeshBtn = new QRadioButton( tr( "MESH" ), aGrp ); + QRadioButton* aSelBtn = new QRadioButton( tr( "SELECTION" ), aGrp ); + QRadioButton* aGrpBtn = new QRadioButton( tr( "CURRENT_GROUP" ), aGrp ); +// QRadioButton* aNoneBtn = new QRadioButton( tr( "NONE" ), aGrp ); + + aGrp->insert( aMeshBtn, Mesh ); + aGrp->insert( aSelBtn, Selection ); + aGrp->insert( aGrpBtn, Dialog ); +// aGrp->insert( aNoneBtn, None ); + + aGrp->setButton( Selection ); + + return aGrp; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::createTable +// Purpose : Create table +//======================================================================= +SMESHGUI_FilterDlg::Table* SMESHGUI_FilterDlg::createTable( QWidget* theParent, + const int theType ) +{ + // create table + Table* aTable= new Table( 0, 5, theParent ); + + QHeader* aHeaders = aTable->horizontalHeader(); + + QFontMetrics aMetrics( aHeaders->font() ); + + int aLenCr = abs( maxLength( getCriteria( theType ), aMetrics ) - + aMetrics.width( tr( "CRITERION" ) ) ) / aMetrics.width( ' ' ) + 5; + + int aLenCo = abs( maxLength( getCriteria( theType ), aMetrics ) - + aMetrics.width( tr( "COMPARE" ) ) ) / aMetrics.width( ' ' ) + 5; + + QString aCrStr; + aCrStr.fill( ' ', aLenCr ); + QString aCoStr; + aCoStr.fill( ' ', 10 ); + + aHeaders->setLabel( 0, tr( "CRITERION" ) + aCrStr ); + aHeaders->setLabel( 1, tr( "COMPARE" ) + aCoStr ); + aHeaders->setLabel( 2, tr( "THRESHOLD_VALUE" ) ); + aHeaders->setLabel( 3, tr( "UNARY" ) ); + aHeaders->setLabel( 4, tr( "BINARY" ) + " " ); + + // set geometry of the table + + for ( int i = 0; i <= 4; i++ ) + aTable->adjustColumn( i ); + + aTable->updateGeometry(); + QSize aSize = aTable->sizeHint(); + int aWidth = aSize.width(); + aTable->setMinimumSize( QSize( aWidth, aWidth / 2 ) ); + aTable->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); + + if ( theType == SMESH::EDGE ) + connect( aTable, SIGNAL( valueChanged( int, int ) ), + this, SLOT( onCriterionChanged( int, int ) ) ); + + return aTable; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_FilterDlg::createButtonFrame( QWidget* theParent, const bool theModal ) +{ + QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, theParent ); + + myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aGrp ); + myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aGrp ); + QLabel* aLbl = new QLabel( aGrp ); + myCloseBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aGrp ); + + aLbl->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + + if ( theModal ) + myApplyBtn->hide(); + + return aGrp; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg() +{ +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_FilterDlg::Init( const int theType ) +{ + mySourceWg = 0; + mySelection = 0; + myType = theType; + myMesh = SMESH::SMESH_Mesh::_nil(); + + // activate corresponding tab + if ( !myTables.contains( myType ) ) + myTables[ myType ] = createTable( myTableGrp, myType ); + + TableMap::iterator anIter; + for ( anIter = myTables.begin(); anIter != myTables.end(); ++anIter ) + if ( anIter.key() == theType ) + anIter.data()->show(); + else + anIter.data()->hide(); + + // set caption + setCaption( myType == SMESH::EDGE ? tr( "EDGES_TLT" ) : tr( "FACES_TLT" ) ); + + qApp->processEvents(); + updateGeometry(); + adjustSize(); + setEnabled( true ); + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + + connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ); + this->move( x, y ); + + this->show(); + + return; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +// Assign filters VTK viewer and close dialog +//======================================================================= +void SMESHGUI_FilterDlg::onOk() +{ + if ( onApply() ) + { + disconnect( mySMESHGUI, 0, this, 0 ); + mySMESHGUI->ResetState() ; + accept(); + } + +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_FilterDlg::onClose() +{ + disconnect( mySMESHGUI, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_FilterDlg::onDeactivate() +{ + setEnabled( false ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_FilterDlg::enterEvent( QEvent* ) +{ +// mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled( true ); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_FilterDlg::closeEvent( QCloseEvent* e ) +{ + onClose() ; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getCriteria +// Purpose : Retrieve list of ids from given widget +//======================================================================= +void SMESHGUI_FilterDlg::getIdsFromWg( const QWidget* theWg, QValueList& theRes ) const +{ + theRes.clear(); + if ( theWg == 0 ) + return; + + if ( theWg->inherits( "QListBox" ) ) + { + QListBox* aListBox = ( QListBox* )theWg; + bool b; + for ( int i = 0, n = aListBox->count(); i < n; i++ ) + { + int anId = aListBox->text( i ).toInt( &b ); + if ( b ) + theRes.append( anId ); + } + } + else if ( theWg->inherits( "QLineEdit" ) ) + { + QLineEdit* aLineEdit = ( QLineEdit* )theWg; + QString aStr = aLineEdit->text(); + QRegExp aRegExp( "(\\d+)" ); + bool b; + int aPos = 0; + while ( aPos >= 0 ) + { + aPos = aRegExp.search( aStr, aPos ); + if ( aPos > -1 ) + { + int anId = aRegExp.cap( 1 ).toInt( &b ); + if ( b ) + theRes.append( anId ); + aPos += aRegExp.matchedLength(); + } + } + } +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getSelMode +// Purpose : Get criteria for specified type +//======================================================================= +Selection_Mode SMESHGUI_FilterDlg::getSelMode( const int theType ) const +{ + switch ( theType ) + { + case SMESH::NODE : return NodeSelection; + case SMESH::EDGE : return EdgeSelection; + case SMESH::FACE : return FaceSelection; + case SMESH::VOLUME : return VolumeSelection; + default : return ActorSelection; + } + +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getCriteria +// Purpose : Get criteria for specified type +//======================================================================= +void SMESHGUI_FilterDlg::setIdsToWg( QWidget* theWg, const QValueList& theIds ) +{ + if ( theWg == 0 ) + return; + + if ( theWg->inherits( "QListBox" ) ) + { + QListBox* aListBox = ( QListBox* )theWg; + aListBox->clear(); + + QStringList aStrList; + QValueList::const_iterator anIter; + for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) + aStrList.append( QString( "%1" ).arg( *anIter ) ); + + aListBox->insertStringList( aStrList ); + } + else if ( theWg->inherits( "QLineEdit" ) ) + { + QLineEdit* aLineEdit = ( QLineEdit* )theWg; + QString aStr; + QValueList::const_iterator anIter; + + for ( anIter = theIds.begin(); anIter != theIds.end(); ++ anIter ) + aStr += QString( "%1 " ).arg( *anIter ); + + if ( !aStr.isEmpty() ) + aStr.remove( aStr.length() - 1, 1 ); + + aLineEdit->setText( aStr ); + } +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getCriteria +// Purpose : Get criteria for specified type +//======================================================================= +const QStringList& SMESHGUI_FilterDlg::getCriteria( const int theType ) const +{ + if ( theType == SMESH::EDGE ) + { + static QStringList aCriteria; + if ( aCriteria.isEmpty() ) + { + aCriteria.append( tr( "FREE_BORDERS" ) ); + aCriteria.append( tr( "MULTI_BORDERS" ) ); + aCriteria.append( tr( "LENGTH" ) ); + } + return aCriteria; + } + else if ( theType == SMESH::FACE ) + { + static QStringList aCriteria; + if ( aCriteria.isEmpty() ) + { + aCriteria.append( tr( "ASPECT_RATIO" ) ); + aCriteria.append( tr( "WARPING" ) ); + aCriteria.append( tr( "MINIMUM_ANGLE" ) ); + aCriteria.append( tr( "TAPER" ) ); + aCriteria.append( tr( "SKEW" ) ); + aCriteria.append( tr( "AREA" ) ); + } + return aCriteria; + } + else + { + static QStringList aCriteria; + return aCriteria; + } +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getCompare +// Purpose : Get operation of comparison +//======================================================================= +const QStringList& SMESHGUI_FilterDlg::getCompare () const +{ + static QStringList aList; + + if ( aList.isEmpty() ) + { + aList.append( tr( "LESS_THAN" ) ); + aList.append( tr( "MORE_THAN" ) ); + aList.append( tr( "EQUAL_TO" ) ); + } + + return aList; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getCriterionItem +// Purpose : Get combo table item for criteria of specified type +//======================================================================= +QTableItem* SMESHGUI_FilterDlg::getCriterionItem( QTable* theParent , const int theType ) +{ + return new QComboTableItem( theParent, getCriteria( theType ) ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getCompareItem +// Purpose : Get combo table item for operation of comparision +//======================================================================= +QTableItem* SMESHGUI_FilterDlg::getCompareItem( QTable* theParent ) +{ + return new QComboTableItem( theParent, getCompare() ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getLogOpItem +// Purpose : +//======================================================================= +QTableItem* SMESHGUI_FilterDlg::getLogOpItem( QTable* theParent ) +{ + static QStringList aList; + if ( aList.isEmpty() ) + { + aList.append( tr( "AND" ) ); + aList.append( tr( "OR" ) ); + } + + return new QComboTableItem( theParent, aList ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getNotItem +// Purpose : Get check table item +//======================================================================= +QTableItem* SMESHGUI_FilterDlg::getNotItem( QTable* theParent ) +{ + return new QCheckTableItem( theParent, tr( "NOT" ) ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getCurrType +// Purpose : Get current entity type +//======================================================================= +int SMESHGUI_FilterDlg::getCurrType() const +{ + return myType; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::getCriterion +// Purpose : +//======================================================================= +int SMESHGUI_FilterDlg::getCriterion( const int theType, const int theRow ) const +{ + QComboTableItem* anItem = ( QComboTableItem* )myTables[ getCurrType() ]->item( theRow, 0 ); + return anItem->currentItem(); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::addRow +// Purpose : +//======================================================================= +void SMESHGUI_FilterDlg::addRow( Table* theTable, const int theType ) +{ + theTable->insertRows( theTable->numRows() ); + int aCurrRow = theTable->numRows() - 1; + + // Criteria + theTable->setItem( aCurrRow, 0, getCriterionItem( theTable, theType ) ); + + // Compare + theTable->setItem( aCurrRow, 1, getCompareItem( theTable ) ); + + //Logical operation NOT + theTable->setItem( aCurrRow, 3, getNotItem( theTable ) ); + + // Logical binary operation for previous value + if ( aCurrRow > 0 ) + theTable->setItem( aCurrRow - 1, 4, getLogOpItem( theTable ) ); + theTable->SetEditable( false, aCurrRow, 4 ); + + onCriterionChanged( aCurrRow, 0 ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onAddBtn +// Purpose : SLOT. Called then "Add" button pressed. +// Adds new string to table +//======================================================================= +void SMESHGUI_FilterDlg::onAddBtn() +{ + // QTable + int aType = getCurrType(); + Table* aTable = myTables[ aType ]; + + addRow( aTable, aType ); + + updateBtnState(); + +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onCriterionChanged() +// Purpose : SLOT. Called then contents of table changed +// Provides reaction on change of criterion +//======================================================================= +void SMESHGUI_FilterDlg::onCriterionChanged( int row, int col ) +{ + int aType = getCurrType(); + if ( aType != SMESH::EDGE || col != 0 ) + return; + + Table* aTable = myTables[ aType ]; + QComboTableItem* aCompareItem = (QComboTableItem*)aTable->item( row, 1 ); + + if ( getCriterion( aType, row ) != FreeBorders ) + { + if ( aCompareItem->count() == 0 ) + aCompareItem->setStringList( getCompare() ); + + QString aText = aTable->text( row, 2 ); + aTable->SetEditable( true, row, 2 ); + aTable->setText( row, 2, aText ); + } + else + { + if ( aCompareItem->count() > 0 ) + aCompareItem->setStringList( QStringList() ); + aTable->SetEditable( false, row, 2 ); + } +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onRemoveBtn +// Purpose : SLOT. Called then "Remove" button pressed. +// Removes current string from table +//======================================================================= +void SMESHGUI_FilterDlg::onRemoveBtn() +{ + Table* aTable = myTables[ getCurrType() ]; + + if ( aTable->numRows() == 0 ) + return; + + QMemArray aRows; + for ( int i = 0, n = aTable->numRows(); i < n; i++ ) + { + if ( aTable->isRowSelected( i ) ) + { + aRows.resize( aRows.size() + 1 ); + aRows[ aRows.size() - 1 ] = i; + } + } + + aTable->removeRows( aRows ); + + // remove control of binary logical operation from last row + if ( aTable->numRows() > 0 ) + aTable->SetEditable( false, aTable->numRows() - 1, 4 ); + + updateBtnState(); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onClearBtn +// Purpose : SLOT. Called then "Clear" button pressed. +// Removes all strings from table +//======================================================================= +void SMESHGUI_FilterDlg::onClearBtn() +{ + QTable* aTable = myTables[ getCurrType() ]; + + if ( aTable->numRows() == 0 ) + return; + + while ( aTable->numRows() > 0 ) + aTable->removeRow( 0 ); + + updateBtnState(); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::updateBtnState +// Purpose : Update button state +//======================================================================= +void SMESHGUI_FilterDlg::updateBtnState() +{ + myRemoveBtn->setEnabled( myTables[ getCurrType() ]->numRows() > 0 ); + myClearBtn->setEnabled( myTables[ getCurrType() ]->numRows() > 0 ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::isValid +// Purpose : Verify validity of input data +//======================================================================= +bool SMESHGUI_FilterDlg::isValid() const +{ + Table* aTable = myTables[ getCurrType() ]; + for ( int i = 0, n = aTable->numRows(); i < n; i++ ) + { + bool isEditable = aTable->IsEditable( i ,2 ); + bool aRes = false; + int aThreshold = ( int )aTable->text( i, 2 ).toDouble( &aRes ); + if ( isEditable && !aRes ) + { + QMessageBox::information( mySMESHGUI->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR" ), + QMessageBox::Ok ); + return false; + } + else if ( getCurrType() == SMESH::EDGE && + getCriterion( SMESH::EDGE, i ) == MultiBorders && + aThreshold == 1 ) + { + QMessageBox::information( mySMESHGUI->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "MULTIEDGES_ERROR" ), + QMessageBox::Ok ); + return false; + } + } + + return true; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::GetResultIds +// Purpose : Get filtered ids +//======================================================================= +/*void SMESHGUI_FilterDlg::GetResultIds( SMESH::SMESH_Mesh_ptr theMesh, + QValueList& theIds ) const +{ + if ( !myPredicate->_is_nil() ) + theIds = myInputIds; + else + myPredicate->SetMesh( theMesh ); + + theIds.clear(); + QValueList::const_iterator anIter; + for ( anIter = myInputIds.begin(); anIter != myInputIds.end(); ++anIter ) + if ( myPredicate->IsSatisfy( *anIter ) ) + theIds.append( *anIter ); +} +*/ + +//======================================================================= +// name : SMESHGUI_FilterDlg::SetSourceWg +// Purpose : Set widget of parent dialog containing idsto be filtered if +// user select corresponding source radio button +//======================================================================= +void SMESHGUI_FilterDlg::SetSourceWg( QWidget* theWg ) +{ + mySourceWg = theWg; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::SetGroupIds +// Purpose : Set mesh +//======================================================================= +void SMESHGUI_FilterDlg::SetMesh( SMESH::SMESH_Mesh_ptr theMesh ) +{ + myMesh = theMesh; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::SetSelection +// Purpose : Get filtered ids +//======================================================================= +void SMESHGUI_FilterDlg::SetSelection( SALOME_Selection* theSel ) +{ + mySelection = theSel; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onApply +// Purpose : SLOT called when "Apply" button pressed. +// Assign filters to VTK viewer +//======================================================================= +bool SMESHGUI_FilterDlg::onApply() +{ + if ( !isValid() ) + return false; + + try + { + int aCurrType = getCurrType(); + + SMESH::Predicate_ptr aPredicate = createPredicate( aCurrType ); + + if ( mySetInViewer->isChecked() ) + insertFilterInViewer( aPredicate ); + + if ( !aPredicate->_is_nil() ) + { + QValueList aResultIds; + filterSource( aCurrType, aPredicate, aResultIds ); + selectInViewer( aCurrType, aResultIds ); + } + } + catch( const SALOME::SALOME_Exception& S_ex ) + { + QtCatchCorbaException( S_ex ); + } + catch( ... ) + { + } + + return true; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::createPredicate +// Purpose : Create predicate for given type +//======================================================================= +SMESH::Predicate_ptr SMESHGUI_FilterDlg::createPredicate( const int theType ) +{ + SMESH::FilterManager_ptr aFilterMgr = mySMESHGUI->GetFilterMgr(); + if ( aFilterMgr->_is_nil() ) + return SMESH::Predicate::_nil(); + + QTable* aTable = myTables[ theType ]; + if ( aTable == 0 ) + return SMESH::Predicate::_nil(); + + // CREATE two lists ( PREDICATES and LOG OP ) + + // Criterion + QValueList aPredicates; + QValueList aLogOps; + for ( int i = 0, n = aTable->numRows(); i < n; i++ ) + { + int aCriterion = getCriterion( theType, i ); + + SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil(); + SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil(); + + if ( theType == SMESH::EDGE ) + { + switch ( aCriterion ) + { + case FreeBorders: + aPredicate = aFilterMgr->CreateFreeBorders(); + break; + case MultiBorders: + aFunctor = aFilterMgr->CreateMultiConnection(); + break; + case Length: + aFunctor = aFilterMgr->CreateLength(); + break; + default: + continue; + } + } + else + { + switch ( aCriterion ) + { + case AspectRatio: + aFunctor = aFilterMgr->CreateAspectRatio(); + break; + case Warping: + aFunctor = aFilterMgr->CreateWarping(); + break; + case MinimumAngle: + aFunctor = aFilterMgr->CreateMinimumAngle(); + break; + case Taper: + aFunctor = aFilterMgr->CreateTaper(); + break; + case Skew: + aFunctor = aFilterMgr->CreateSkew(); + break; + case Area: + aFunctor = aFilterMgr->CreateArea(); + break; + default: + continue; + } + } + + // Comparator + if ( !aFunctor->_is_nil() && aPredicate->_is_nil() ) + { + QComboTableItem* aCombo = (QComboTableItem*)aTable->item( i, 1 ); + int aCompareOp = aCombo->currentItem(); + double aThreshold = aTable->text( i, 2 ).toDouble(); + + SMESH::Comparator_ptr aComparator = SMESH::Comparator::_nil(); + + if ( aCompareOp == LessThan ) + aComparator = aFilterMgr->CreateLessThan(); + else if ( aCompareOp == MoreThan ) + aComparator = aFilterMgr->CreateMoreThan(); + else if ( aCompareOp == EqualTo ) + aComparator = aFilterMgr->CreateEqualTo(); + else + continue; + + aComparator->SetNumFunctor( aFunctor ); + aComparator->SetMargin( aThreshold ); + + aPredicate = aComparator; + } + + // Logical not + QCheckTableItem* anItem = (QCheckTableItem*)aTable->item( i, 3 ); + if ( anItem->isChecked() ) + { + SMESH::LogicalNOT_ptr aNotPred = aFilterMgr->CreateLogicalNOT(); + aNotPred->SetPredicate( aPredicate ); + aPredicate = aNotPred; + } + + // logical op + int aLogOp = ( i == n - 1 ) ? LO_Undefined + : ( (QComboTableItem*)aTable->item( i, 4 ) )->currentItem(); + aPredicates.append( aPredicate ); + aLogOps.append( aLogOp ); + + } // for + + // CREATE ONE PREDICATE FROM PREVIOUSLY CREATED MAP + + // combine all "AND" operations + + QValueList aResList; + + QValueList::iterator aPredIter; + QValueList::iterator aLogOpIter; + + SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil(); + int aPrevLogOp = LO_Undefined; + + for ( aPredIter = aPredicates.begin(), aLogOpIter = aLogOps.begin(); + aPredIter != aPredicates.end() && aLogOpIter != aLogOps.end(); + ++aPredIter, ++aLogOpIter ) + { + int aCurrLogOp = *aLogOpIter; + + SMESH::Predicate_ptr aCurrPred = SMESH::Predicate::_nil(); + + if ( aPrevLogOp == LO_And ) + { + + SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalAND(); + aBinaryPred->SetPredicate1( aPrevPredicate ); + aBinaryPred->SetPredicate2( *aPredIter ); + aCurrPred = aBinaryPred; + } + else + aCurrPred = *aPredIter; + + if ( aCurrLogOp != LO_And ) + aResList.append( aCurrPred ); + + aPrevPredicate = aCurrPred; + aPrevLogOp = aCurrLogOp; + } + + // combine all "OR" operations + + SMESH::Predicate_ptr aResPredicate = SMESH::Predicate::_nil(); + + if ( aResList.count() == 1 ) + aResPredicate = aResList.first(); + else if ( aResList.count() > 1 ) + { + QValueList::iterator anIter = aResList.begin(); + aResPredicate = *anIter; + anIter++; + for ( ; anIter != aResList.end(); ++anIter ) + { + SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalOR(); + aBinaryPred->SetPredicate1( aResPredicate ); + aBinaryPred->SetPredicate2( *anIter ); + aResPredicate = aBinaryPred; + } + } + + return aResPredicate; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::insertFilterInViewer +// Purpose : Insert filter in viewer +//======================================================================= +void SMESHGUI_FilterDlg::insertFilterInViewer( SMESH::Predicate_ptr thePred ) +{ + VTKViewer_InteractorStyleSALOME* aStyle = ((VTKViewer_ViewFrame*)mySMESHGUI->GetActiveStudy()-> + getActiveStudyFrame()->getRightFrame()->getViewFrame())-> + getRWInteractor()->GetInteractorStyleSALOME(); + + if ( thePred->_is_nil() ) + { + if ( myType == SMESH::EDGE ) + aStyle->RemoveEdgeFilter(); + else if ( myType == SMESH::FACE ) + aStyle->RemoveFaceFilter(); + } + else + { + Handle(SMESHGUI_Filter) aFilter = new SMESHGUI_Filter(); + aFilter->SetPredicate( thePred ); + if ( myType == SMESH::EDGE ) + aStyle->SetEdgeFilter( aFilter ); + else if ( myType == SMESH::FACE ) + aStyle->SetFaceFilter( aFilter ); + } +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::filterSource +// Purpose : Filter source ids +//======================================================================= +void SMESHGUI_FilterDlg::filterSource( const int theType, + SMESH::Predicate_ptr thePred, + QValueList& theResIds ) +{ + theResIds.clear(); + + int aSourceId = mySourceGrp->id( mySourceGrp->selected() ); + + if ( aSourceId == Mesh ) + { + if ( myMesh->_is_nil() ) + return; + SMESH::FilterManager_ptr aFilterMgr = mySMESHGUI->GetFilterMgr(); + SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); + aFilter->SetPredicate( thePred ); + SMESH::long_array_var anIds = aFilter->GetElementsId( myMesh ); + for ( int i = 0, n = anIds->length(); i < n; i++ ) + theResIds.append( anIds[ i ] ); + } + else if ( aSourceId == Selection ) + { + filterSelectionSource( theType, thePred, theResIds ); + } + else if ( aSourceId == Dialog ) + { + // retrieve ids from dialog + QValueList aDialogIds; + getIdsFromWg( mySourceWg, aDialogIds ); + + if ( myMesh->_is_nil() ) + { + theResIds = aDialogIds; + return; + } + + // filter ids + thePred->SetMesh( myMesh ); + QValueList::const_iterator anIter; + for ( anIter = aDialogIds.begin(); anIter != aDialogIds.end(); ++ anIter ) + if ( thePred->IsSatisfy( *anIter ) ) + theResIds.append( *anIter ); + + // set ids to the dialog + setIdsToWg( mySourceWg, theResIds ); + } +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::filterSelectionSource +// Purpose : Filter source selection +//======================================================================= +void SMESHGUI_FilterDlg::filterSelectionSource( const int theType, + SMESH::Predicate_ptr thePred, + QValueList& theResIds ) +{ + theResIds.clear(); + if ( myMesh->_is_nil() || mySelection == 0 ) + return; + + // Create map of entities to be filtered + TColStd_MapOfInteger aToBeFiltered; + Standard_Boolean aRes = false; + SALOME_ListIteratorOfListIO anIter( mySelection->StoredIObjects() ); + + for ( ; anIter.More(); anIter.Next() ) + { + // process sub mesh + SMESH::SMESH_subMesh_ptr aSubMesh = mySMESHGUI->ConvertIOinSubMesh( anIter.Value(), aRes ); + if ( aRes && !aSubMesh->_is_nil() ) + { + if ( aSubMesh->GetFather()->GetId() == myMesh->GetId() ) + { + SMESH::long_array_var anIds = + theType == SMESH::NODE ? aSubMesh->GetNodesId() : aSubMesh->GetElementsId(); + for ( int i = 0, n = anIds->length(); i < n; i++ ) + aToBeFiltered.Add( anIds[ i ] ); + } + } + + // process group + SMESH::SMESH_Group_ptr aGroup = mySMESHGUI->ConvertIOinSMESHGroup( anIter.Value(), aRes ); + if ( aRes && !aGroup->_is_nil() ) + { + if ( aGroup->GetType() == theType && aGroup->GetMesh()->GetId() == myMesh->GetId() ) + { + SMESH::long_array_var anIds = aGroup->GetListOfID(); + for ( int i = 0, n = anIds->length(); i < n; i++ ) + aToBeFiltered.Add( anIds[ i ] ); + } + } + + // process mesh + SMESH::SMESH_Mesh_ptr aMeshPtr = mySMESHGUI->ConvertIOinMesh( anIter.Value(), aRes ); + if ( aRes && !aMeshPtr->_is_nil() && aMeshPtr->GetId() == myMesh->GetId() ) + { + TColStd_MapOfInteger aVtkMap; + mySelection->GetIndex( anIter.Value(), aVtkMap ); + + if ( aVtkMap.Extent() > 0 ) + { + SMESH_Actor *anActor = mySMESHGUI->FindActorByEntry( + anIter.Value()->getEntry(), aRes, true ); + if ( aRes && anActor != 0 ) + { + TColStd_MapIteratorOfMapOfInteger aVtkMapIter( aVtkMap ); + for ( ; aVtkMapIter.More(); aVtkMapIter.Next() ) + aToBeFiltered.Add( theType == SMESH::NODE + ? anActor->GetNodeObjId( aVtkMapIter.Key() ) + : anActor->GetElemObjId( aVtkMapIter.Key() ) ); + } + } + } + } + + // Filter entities + thePred->SetMesh( myMesh ); + TColStd_MapIteratorOfMapOfInteger aResIter( aToBeFiltered ); + for ( ; aResIter.More(); aResIter.Next() ) + if ( thePred->IsSatisfy( aResIter.Key() ) ) + theResIds.append( aResIter.Key() ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::selectInViewer +// Purpose : Select given entities in viewer +//======================================================================= +void SMESHGUI_FilterDlg::selectInViewer( const int theType, const QValueList& theIds ) +{ + if ( mySelection == 0 || myMesh->_is_nil() ) + return; + + // Set new selection mode if necessary + Selection_Mode aSelMode = getSelMode( theType ); + if ( aSelMode != mySelection->SelectionMode() ) + { + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + if ( aSelMode == NodeSelection ) + mySMESHGUI->ViewNodes(); + QAD_Application::getDesktop()->SetSelectionMode( aSelMode ); + } + + Standard_Boolean aRes = false; + SMESH_Actor* anActor = mySMESHGUI->FindActor( myMesh, aRes, true ); + if ( !aRes || anActor == 0 || !anActor->hasIO() ) + return; + + Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); + mySelection->ClearIObjects(); + mySelection->AddIObject( anIO, false ); + + TColStd_MapOfInteger aMap; + QValueList::const_iterator anIter; + for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) + { + std::vector aVtkList = anActor->GetElemVtkId( *anIter ); + std::vector::iterator it; + for ( it = aVtkList.begin(); it != aVtkList.end(); ++it ) + aMap.Add( *it ); + } + + mySelection->AddOrRemoveIndex( anIO, aMap, false, true ); + +} + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.h b/src/SMESHGUI/SMESHGUI_FilterDlg.h new file mode 100755 index 000000000..6ba1d4a79 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.h @@ -0,0 +1,195 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_FilterDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_FilterDlg_H +#define SMESHGUI_FilterDlg_H + +#include +#include +#include +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Filter) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +class QCloseEvent; +class QWidgetStack; +class QStringList; +class QTableItem; +class QFrame; +class QEvent; +class QPushButton; +class QTable; +class SALOME_Selection; +class SMESHGUI; +class QComboBox; +class QButtonGroup; +class QCheckBox; +class QGroupBox; + + +/* + Class : SMESHGUI_FilterDlg + Description : Dialog to specify filters for VTK viewer +*/ + +class SMESHGUI_FilterDlg : public QDialog +{ + Q_OBJECT + + class Table; + + // Edge criteria + enum { FreeBorders = 0, MultiBorders, Length }; + + // Face criteria + enum { AspectRatio = 0, Warping, MinimumAngle, Taper, Skew, Area }; + + // Comparision + enum { LessThan = 0, MoreThan, EqualTo }; + + // Logical operations + enum { LO_And = 0, LO_Or, LO_Undefined }; + + // Source elements to be selected + enum { Mesh, Selection, Dialog, None }; + + typedef QMap TableMap; + +public: + SMESHGUI_FilterDlg( QWidget* parent, + const int type, + const bool theModal = true, + const char* name = 0 ); + virtual ~SMESHGUI_FilterDlg(); + + void Init( const int type ); + + void SetSelection( SALOME_Selection* ); + void SetMesh( SMESH::SMESH_Mesh_ptr ); + void SetSourceWg( QWidget* ); + +private slots: + + void onAddBtn(); + void onRemoveBtn(); + void onClearBtn(); + void onCriterionChanged( int, int ); + + void onOk(); + bool onApply(); + void onClose(); + void onDeactivate(); + +private: + + void closeEvent( QCloseEvent* e ); + void enterEvent ( QEvent * ); + + void updateBtnState(); + + // dialog creation + QFrame* createButtonFrame( QWidget*, const bool ); + QFrame* createMainFrame( QWidget* ); + Table* createTable( QWidget*, const int ); + QButtonGroup* createSourceGroup( QWidget* ); + void addRow( Table*, const int ); + QTableItem* getCriterionItem( QTable*, const int ); + QTableItem* getCompareItem( QTable* ); + QTableItem* getNotItem( QTable* ); + QTableItem* getLogOpItem( QTable* ); + const QStringList& getCriteria( const int theType ) const; + const QStringList& getCompare () const; + + // query + int getCurrType() const; + int getCriterion( const int theType, const int theRow ) const; + + // execution + bool isValid() const; + SMESH::Predicate_ptr createPredicate( const int theType ); + void insertFilterInViewer( SMESH::Predicate_ptr thePred ); + void selectInViewer( const int theType, + const QValueList& theIds ); + void filterSource( const int theType, + SMESH::Predicate_ptr thePred, + QValueList& theResIds ); + void filterSelectionSource( const int theType, + SMESH::Predicate_ptr thePred, + QValueList& theResIds ); + void getIdsFromWg( const QWidget*, QValueList& ) const; + void setIdsToWg( QWidget*, const QValueList& ); + Selection_Mode getSelMode( const int ) const; + +private: + + // widgets + QFrame* myMainFrame; + QGroupBox* myTableGrp; + + TableMap myTables; + QPushButton* myAddBtn; + QPushButton* myRemoveBtn; + QPushButton* myClearBtn; + QButtonGroup* mySourceGrp; + QCheckBox* mySetInViewer; + + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + + // initial fields + int myType; + SMESHGUI* mySMESHGUI; + SALOME_Selection* mySelection; + SMESH::SMESH_Mesh_ptr myMesh; + QWidget* mySourceWg; +}; + +#endif + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx new file mode 100644 index 000000000..d6928d673 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -0,0 +1,977 @@ +// 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.org +// +// +// +// File : SMESHGUI_GroupDlg.cxx +// Author : Natalia KOPNOVA +// Module : SMESH +// $Header$ + +using namespace std; +#include "SMESHGUI_GroupDlg.h" +#include "SMESHGUI_FilterDlg.h" + +#include "SMESHGUI.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "VTKViewer_InteractorStyleSALOME.h" +#include "VTKViewer_ViewFrame.h" +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "QAD_RightFrame.h" +#include "utilities.h" + +#include "SMESH_Actor.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// STL includes +#include +#include + +//================================================================================= +// class : SMESHGUI_GroupDlg() +// purpose : +//================================================================================= +SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, + SMESH::SMESH_Mesh_ptr theMesh, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + if ( !name ) setName( "SMESHGUI_GroupDlg" ); + initDialog(theSel, true); + init(theMesh); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); +} + +SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, + SMESH::SMESH_Group_ptr theGroup, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + if ( !name ) setName( "SMESHGUI_GroupDlg" ); + initDialog(theSel, false); + init(theGroup); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition(this, x, y); + this->move(x, y); +} + +void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) +{ + myFilterDlg = 0; + + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if (create) + setCaption( tr( "SMESH_CREATE_GROUP_TITLE" ) ); + else + setCaption( tr( "SMESH_EDIT_GROUP_TITLE" ) ); + setSizeGripEnabled( TRUE ); + + QVBoxLayout* aMainLayout = new QVBoxLayout(this, 11, 6); + + /***************************************************************/ + myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types"); + myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE")); + myTypeGroup->setExclusive(true); + + QStringList types; + types.append(tr("MESH_NODE")); + types.append(tr("SMESH_EDGE")); + types.append(tr("SMESH_FACE")); + types.append(tr("SMESH_VOLUME")); + QRadioButton* rb; + for (int i = 0; i < types.count(); i++) { + rb = new QRadioButton(types[i], myTypeGroup); + } + myTypeGroup->setEnabled(create); + myTypeId = -1; + + /***************************************************************/ + QHBox* aNameBox = new QHBox(this, "name box"); + QLabel* aName = new QLabel(aNameBox, "name label"); + aName->setText(tr("SMESH_NAME")); + aName->setMinimumSize(50,0); + myName = new QLineEdit(aNameBox, "name"); + + /***************************************************************/ + QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, this, "content box"); + aContentBox->setTitle(tr("SMESH_CONTENT")); + QFrame* aContent = new QFrame(aContentBox, "content"); + QGridLayout* aLayout = new QGridLayout(aContent, 7, 4); + aLayout->setSpacing(6); + aLayout->setAutoAdd(false); + + QLabel* aLabel = new QLabel(aContent, "elements label"); + aLabel->setText(tr("SMESH_ID_ELEMENTS")); + myElements = new QListBox(aContent, "elements list"); + myElements->setSelectionMode(QListBox::Extended); + // myElements->setMinimumHeight(150); + + myFilter = new QPushButton(aContent, "filter"); + myFilter->setText(tr("SMESH_BUT_FILTER")); + QPushButton* aAddBtn = new QPushButton(aContent, "add"); + aAddBtn->setText(tr("SMESH_BUT_ADD")); + QPushButton* aRemoveBtn = new QPushButton(aContent, "remove"); + aRemoveBtn->setText(tr("SMESH_BUT_REMOVE")); + QPushButton* aSortBtn = new QPushButton(aContent, "sort"); + aSortBtn->setText(tr("SMESH_BUT_SORT")); + + aLayout->addWidget(aLabel, 0, 0); + aLayout->addMultiCellWidget(myElements, 1, 6, 0, 0); + aLayout->addWidget(myFilter, 1, 2); + aLayout->addWidget(aAddBtn, 3, 2); + aLayout->addWidget(aRemoveBtn, 4, 2); + aLayout->addWidget(aSortBtn, 6, 2); + + aLayout->setColStretch(0, 1); + aLayout->addColSpacing(1, 20); + aLayout->addColSpacing(3, 20); + aLayout->setRowStretch(2, 1); + aLayout->setRowStretch(5, 1); + + aContentBox->setMinimumHeight(aContent->sizeHint().height() + + aContentBox->sizeHint().height()); + + /***************************************************************/ + QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, this, "select box"); + aSelectBox->setTitle(tr("SMESH_SELECT_FROM")); + + mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox"); + mySelectSubMesh->setText(tr("SMESH_SUBMESH")); + mySelectSubMesh->setMinimumSize(50, 0); + mySubMeshBtn = new QPushButton(aSelectBox, "submesh button"); + mySubMeshBtn->setText(""); + mySubMeshBtn->setPixmap(image0); + mySubMeshLine = new QLineEdit(aSelectBox, "submesh line"); + mySubMeshLine->setReadOnly(true); + onSelectSubMesh(false); + + mySelectGroup = new QCheckBox(aSelectBox, "group checkbox"); + mySelectGroup->setText(tr("SMESH_GROUP")); + mySelectGroup->setMinimumSize(50, 0); + myGroupBtn = new QPushButton(aSelectBox, "group button"); + myGroupBtn->setText(""); + myGroupBtn->setPixmap(image0); + myGroupLine = new QLineEdit(aSelectBox, "group line"); + myGroupLine->setReadOnly(true); + onSelectGroup(false); + + aSelectBox->setMinimumHeight(mySubMeshBtn->sizeHint().height() + + myGroupBtn->sizeHint().height() + + aSelectBox->sizeHint().height()); + + /***************************************************************/ + QFrame* aButtons = new QFrame(this, "button box"); + aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken); + QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6); + aBtnLayout->setAutoAdd(false); + + QPushButton* aOKBtn = new QPushButton(aButtons, "ok"); + aOKBtn->setText(tr("SMESH_BUT_OK")); + aOKBtn->setAutoDefault(true); + aOKBtn->setDefault(true); + QPushButton* aApplyBtn = new QPushButton(aButtons, "apply"); + aApplyBtn->setText(tr("SMESH_BUT_APPLY")); + aApplyBtn->setAutoDefault(true); + QPushButton* aCloseBtn = new QPushButton(aButtons, "close"); + aCloseBtn->setText(tr("SMESH_BUT_CLOSE")); + aCloseBtn->setAutoDefault(true); + + aBtnLayout->addWidget(aOKBtn); + aBtnLayout->addWidget(aApplyBtn); + aBtnLayout->addStretch(); + aBtnLayout->addWidget(aCloseBtn); + + /***************************************************************/ + aMainLayout->addWidget(myTypeGroup); + aMainLayout->addWidget(aNameBox); + aMainLayout->addWidget(aContentBox); + aMainLayout->addWidget(aSelectBox); + aMainLayout->addWidget(aButtons); + + /* signals and slots connections */ + connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int))); + + connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&))); + connect(myElements, SIGNAL(selectionChanged()), this, SLOT(onListSelectionChanged())); + + connect(myFilter, SIGNAL(clicked()), this, SLOT(setFilters())); + connect(aAddBtn, SIGNAL(clicked()), this, SLOT(onAdd())); + connect(aRemoveBtn, SIGNAL(clicked()), this, SLOT(onRemove())); + connect(aSortBtn, SIGNAL(clicked()), this, SLOT(onSort())); + + connect(mySelectSubMesh, SIGNAL(toggled(bool)), this, SLOT(onSelectSubMesh(bool))); + connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool))); + connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); + connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); + + connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK())); + connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply())); + connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(onClose())); + + /* Init selection */ + mySelection = theSel; + mySMESHGUI = SMESHGUI::GetSMESHGUI(); + mySMESHGUI->SetActiveDialogBox(this); + mySMESHGUI->SetState(800); + + mySelectionMode = -1; + mySubMeshFilter = new SMESH_TypeFilter(SUBMESH); + myGroupFilter = new SMESH_TypeFilter(GROUP); + + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onClose())); + connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose())); + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); + + updateButtons(); +} + +//================================================================================= +// function : ~SMESHGUI_GroupDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::init(SMESH::SMESH_Mesh_ptr theMesh) +{ + /* init data from current selection */ + myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh); + myGroup = SMESH::SMESH_Group::_nil(); + + Standard_Boolean aResult; + myActor = mySMESHGUI->FindActor(myMesh, aResult, true); + mySMESHGUI->SetPickable(myActor); + + myTypeGroup->setButton(0); + onTypeChanged(0); +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) +{ + + myMesh = theGroup->GetMesh(); + myGroup = SMESH::SMESH_Group::_duplicate(theGroup); + + Standard_Boolean aResult; + myActor = mySMESHGUI->FindActor(myMesh, aResult, true); + if ( !myActor ) + myActor = mySMESHGUI->FindActor(myGroup, aResult, true); + mySMESHGUI->SetPickable(myActor); + + int aType = 0; + switch(theGroup->GetType()) { + case SMESH::NODE: aType= 0; break; + case SMESH::EDGE: aType = 1; break; + case SMESH::FACE: aType = 2; break; + case SMESH::VOLUME: aType = 3; break; + } + myTypeGroup->setButton(aType); + onTypeChanged(aType); + + myName->setText(myGroup->GetName()); + myName->home(false); + + if (!theGroup->IsEmpty()) { + SMESH::long_array_var anElements = myGroup->GetListOfID(); + int k = anElements->length(); + for (int i = 0; i < k; i++) { + myIdList.append(anElements[i]); + myElements->insertItem(QString::number(anElements[i])); + } + myElements->selectAll(true); + } +} + + +//================================================================================= +// function : updateButtons() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::updateButtons() +{ + bool enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0; + QPushButton* aBtn; + aBtn = (QPushButton*) child("ok", "QPushButton"); + if (aBtn) aBtn->setEnabled(enable); + aBtn = (QPushButton*) child("apply", "QPushButton"); + if (aBtn) aBtn->setEnabled(enable); +} + +//================================================================================= +// function : onNameChanged() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onNameChanged(const QString& text) +{ + updateButtons(); +} + +//================================================================================= +// function : onTypeChanged() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_GroupDlg::onTypeChanged(int id) +{ + if (myTypeId != id) { + myElements->clear(); + if (myCurrentLineEdit == 0) + setSelectionMode(id); + myFilter->setEnabled(id == 1 || id == 2); + } + myTypeId = id; +} + +//================================================================================= +// function : setSelectionMode() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_GroupDlg::setSelectionMode(int theMode) +{ + if (mySelectionMode != theMode) { + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + if (mySelectionMode == 0) + mySMESHGUI->EraseSimulationActors(); + if (theMode < 4) { + if (theMode == 0) { + mySMESHGUI->ViewNodes(); + QAD_Application::getDesktop()->SetSelectionMode(NodeSelection, true); + } + else if (theMode == 1) { + QAD_Application::getDesktop()->SetSelectionMode(EdgeSelection, true); + } + else if (theMode == 2) { + QAD_Application::getDesktop()->SetSelectionMode(FaceSelection, true); + } + else { + QAD_Application::getDesktop()->SetSelectionMode(VolumeSelection, true); + } + } + else { + QAD_Application::getDesktop()->SetSelectionMode(ActorSelection, true); + if (theMode == 4) + mySelection->AddFilter(mySubMeshFilter); + else if (theMode == 5) + mySelection->AddFilter(myGroupFilter); + } + mySelectionMode = theMode; + } +} + +//================================================================================= +// function : onApply() +// purpose : +//================================================================================= +bool SMESHGUI_GroupDlg::onApply() +{ + if (!myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0) { + mySelection->ClearIObjects(); + if (myGroup->_is_nil()) { + SMESH::ElementType aType = SMESH::ALL; + switch(myTypeId) { + case 0: aType = SMESH::NODE; break; + case 1: aType = SMESH::EDGE; break; + case 2: aType = SMESH::FACE; break; + case 3: aType = SMESH::VOLUME; break; + } + SMESH::long_array_var anIdList = new SMESH::long_array; + int i, k = myElements->count(); + anIdList->length(k); + QListBoxItem* anItem; + for (i = 0, anItem = myElements->firstItem(); anItem != 0; i++, anItem = anItem->next()) { + anIdList[i] = anItem->text().toInt(); + } + + myGroup = mySMESHGUI->AddGroup(myMesh, aType, myName->text()); + myGroup->Add(anIdList); + + /* init for next operation */ + myName->setText(""); + myElements->clear(); + myGroup = SMESH::SMESH_Group::_nil(); + } + else { + myGroup->SetName(myName->text()); + + QValueList aAddList; + QValueList::iterator anIt; + QListBoxItem* anItem; + for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) { + int anId = anItem->text().toInt(); + if ((anIt = myIdList.find(anId)) == myIdList.end()) + aAddList.append(anId); + else + myIdList.remove(anIt); + } + if (!aAddList.empty()) { + SMESH::long_array_var anIdList = new SMESH::long_array; + anIdList->length(aAddList.count()); + int i; + for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++) + anIdList[i] = *anIt; + myGroup->Add(anIdList); + } + if (!myIdList.empty()) { + SMESH::long_array_var anIdList = new SMESH::long_array; + anIdList->length(myIdList.count()); + int i; + for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++) + anIdList[i] = *anIt; + myGroup->Remove(anIdList); + } + /* init for next operation */ + myIdList.clear(); + for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) + myIdList.append(anItem->text().toInt()); + } + + mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); + mySelection->ClearIObjects(); + return true; + } + return false; +} + +//================================================================================= +// function : onOK() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onOK() +{ + if ( onApply() ) + onClose(); +} + +//================================================================================= +// function : onClose() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onClose() +{ + close(); +} + + +static bool busy = false; +//================================================================================= +// function : onListSelectionChanged() +// purpose : Called when selection in element list is changed +//================================================================================= +void SMESHGUI_GroupDlg::onListSelectionChanged() +{ + // MESSAGE("SMESHGUI_GroupDlg::onListSelectionChanged(); myActor = " << myActor); + if (busy || !myActor) return; + busy = true; + + if (myCurrentLineEdit == 0) { + mySelection->ClearIObjects(); + TColStd_MapOfInteger aIndexes; + QListBoxItem* anItem; + for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) { + if (anItem->isSelected()) { + std::vector aVtkList; + if (myTypeId == 0) + aVtkList = myActor->GetNodeVtkId(anItem->text().toInt()); + else + aVtkList = myActor->GetElemVtkId(anItem->text().toInt()); + + if (aVtkList.size() > 0) { + std::vector::iterator it; + for (it = aVtkList.begin(); it != aVtkList.end(); ++it) { + aIndexes.Add(*it); + } + } + } + } + mySelection->AddOrRemoveIndex(myActor->getIO(), aIndexes, false, false); + mySelection->AddIObject(myActor->getIO()); + } + busy = false; +} + +//================================================================================= +// function : onObjectSelectionChanged() +// purpose : Called when selection in 3D view or ObjectBrowser is changed +//================================================================================= +void SMESHGUI_GroupDlg::onObjectSelectionChanged() +{ + if (busy) return; + busy = true; + + int aNbSel = mySelection->IObjectCount(); + myElements->clearSelection(); + + if (myCurrentLineEdit) { + myCurrentLineEdit->setText("") ; + QString aString = ""; + if (aNbSel >= 1) { + if (aNbSel > 1) { + if (myCurrentLineEdit = mySubMeshLine) + aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel); + else if (myCurrentLineEdit = myGroupLine) + aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel); + } + else { + aString = mySelection->firstIObject()->getName(); + } + } + + myCurrentLineEdit->setText(aString) ; + myCurrentLineEdit->home( false ); + } + else { + if (aNbSel == 1) { + QString aListStr = ""; + int aNbItems = 0; + if (myTypeId == 0) { + aNbItems = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aListStr); + } + else { + aNbItems = mySMESHGUI->GetNameOfSelectedElements(mySelection, aListStr); + } + if (aNbItems > 0) { + QStringList anElements = QStringList::split(" ", aListStr); + QListBoxItem* anItem = 0; + for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) { + anItem = myElements->findItem(*it, Qt::ExactMatch); + if (anItem) myElements->setSelected(anItem, true); + } + } + } + } + busy = false; +} + + +//================================================================================= +// function : onSelectSubMesh() +// purpose : Called when selection in 3D view or ObjectBrowser is changed +//================================================================================= +void SMESHGUI_GroupDlg::onSelectSubMesh(bool on) +{ + if (on) { + if (mySelectGroup->isChecked()) { + mySelectGroup->setChecked(false); + } + myCurrentLineEdit = mySubMeshLine; + setSelectionMode(4); + } + else { + mySubMeshLine->setText(""); + myCurrentLineEdit = 0; + if (myTypeId != -1) + setSelectionMode(myTypeId); + } + mySubMeshBtn->setEnabled(on); + mySubMeshLine->setEnabled(on); +} + +//================================================================================= +// function : (onSelectGroup) +// purpose : Called when selection in 3D view or ObjectBrowser is changed +//================================================================================= +void SMESHGUI_GroupDlg::onSelectGroup(bool on) +{ + if (on) { + if (mySelectSubMesh->isChecked()) { + mySelectSubMesh->setChecked(false); + } + myCurrentLineEdit = myGroupLine; + setSelectionMode(5); + } + else { + myGroupLine->setText(""); + myCurrentLineEdit = 0; + if (myTypeId != -1) + setSelectionMode(myTypeId); + } + myGroupBtn->setEnabled(on); + myGroupLine->setEnabled(on); +} + +//================================================================================= +// function : setCurrentSelection() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::setCurrentSelection() +{ + QPushButton* send = (QPushButton*)sender(); + myCurrentLineEdit = 0; + if (send == mySubMeshBtn) { + myCurrentLineEdit = mySubMeshLine; + onObjectSelectionChanged(); + } + else if (send == myGroupBtn) { + myCurrentLineEdit = myGroupLine; + onObjectSelectionChanged(); + } +} + + +//================================================================================= +// function : setFilters() +// purpose : SLOT. Called when "Filter" button pressed. +//================================================================================= +void SMESHGUI_GroupDlg::setFilters() +{ + SMESH::ElementType aType = SMESH::ALL; + switch ( myTypeId ) + { + case 0 : aType = SMESH::NODE; break; + case 1 : aType = SMESH::EDGE; break; + case 2 : aType = SMESH::FACE; break; + case 3 : aType = SMESH::VOLUME; break; + default: return; + } + + if ( myFilterDlg == 0 ) + myFilterDlg = new SMESHGUI_FilterDlg( this, aType, true ); + else + myFilterDlg->Init( aType ); + + myFilterDlg->SetSelection( mySelection ); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( myElements ); + + if ( myFilterDlg->exec() != QDialog::Accepted ) + return; + + if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() ) + { + mySelectionMode = myTypeId; + mySelectSubMesh->setChecked( false ); + mySelectGroup->setChecked( false ); + } +} + +//================================================================================= +// function : onAdd() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onAdd() +{ + int aNbSel = mySelection->IObjectCount(); + if (aNbSel == 0) return; + + busy = true; + + SMESH::ElementType aType = SMESH::ALL; + switch(myTypeId) { + case 0: aType = SMESH::NODE; break; + case 1: aType = SMESH::EDGE; break; + case 2: aType = SMESH::FACE; break; + case 3: aType = SMESH::VOLUME; break; + } + + if (myCurrentLineEdit == 0) { + if (aNbSel != 1) { busy = false; return; } + QString aListStr = ""; + int aNbItems = 0; + if (myTypeId == 0) { + aNbItems = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aListStr); + } + else { + aNbItems = mySMESHGUI->GetNameOfSelectedElements(mySelection, aListStr); + } + if (aNbItems > 0) { + QStringList anElements = QStringList::split(" ", aListStr); + QListBoxItem* anItem = 0; + for (QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) { + anItem = myElements->findItem(*it, Qt::ExactMatch); + if (!anItem) { + anItem = new QListBoxText(*it); + myElements->insertItem(anItem); + } + myElements->setSelected(anItem, true); + } + } + } + else if (myCurrentLineEdit == mySubMeshLine) { + Standard_Boolean aRes; + SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + for (; anIt.More(); anIt.Next()) { + SMESH::SMESH_subMesh_var aSubMesh = mySMESHGUI->ConvertIOinSubMesh(anIt.Value(), aRes); + if (aRes && !aSubMesh->_is_nil()) { + // check if mesh is the same + if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { + if (aType == SMESH::NODE) { + try { + SMESH::long_array_var anElements = aSubMesh->GetNodesId(); + int k = anElements->length(); + QListBoxItem* anItem = 0; + for (int i = 0; i < k; i++) { + QString aText = QString::number(anElements[i]); + anItem = myElements->findItem(aText, Qt::ExactMatch); + if (!anItem) { + anItem = new QListBoxText(aText); + myElements->insertItem(anItem); + } + myElements->setSelected(anItem, true); + } + } + catch (const SALOME::SALOME_Exception& ex) { + QtCatchCorbaException(ex); + } + } + else { + try { + SMESH::long_array_var anElements = aSubMesh->GetElementsId(); + int k = anElements->length(); + QListBoxItem* anItem = 0; + for (int i = 0; i < k; i++) { + QString aText = QString::number(anElements[i]); + anItem = myElements->findItem(aText, Qt::ExactMatch); + if (!anItem) { + anItem = new QListBoxText(aText); + myElements->insertItem(anItem); + } + myElements->setSelected(anItem, true); + } + } + catch (const SALOME::SALOME_Exception& ex) { + QtCatchCorbaException(ex); + } + } + } + } + } + mySelectSubMesh->setChecked(false); + busy = false; + onListSelectionChanged(); + } + else if (myCurrentLineEdit == myGroupLine) { + Standard_Boolean aRes; + SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + for (; anIt.More(); anIt.Next()) { + SMESH::SMESH_Group_var aGroup = mySMESHGUI->ConvertIOinSMESHGroup(anIt.Value(), aRes); + if (aRes && !aGroup->_is_nil()) { + // check if mesh is the same + if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { + SMESH::long_array_var anElements = aGroup->GetListOfID(); + int k = anElements->length(); + QListBoxItem* anItem = 0; + for (int i = 0; i < k; i++) { + QString aText = QString::number(anElements[i]); + anItem = myElements->findItem(aText, Qt::ExactMatch); + if (!anItem) { + anItem = new QListBoxText(aText); + myElements->insertItem(anItem); + } + myElements->setSelected(anItem, true); + } + } + } + } + mySelectGroup->setChecked(false); + busy = false; + onListSelectionChanged(); + } + busy = false; + // mySelection->ClearIObjects(); + updateButtons(); +} + +//================================================================================= +// function : onRemove() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onRemove() +{ + busy = true; + if (myCurrentLineEdit == 0) { + for (int i = myElements->count(); i > 0; i--) { + if (myElements->isSelected(i-1)) { + myElements->removeItem(i-1); + } + } + } + else { + int aNbSel = mySelection->IObjectCount(); + if (aNbSel == 0) { busy = false; return; } + + SMESH::ElementType aType = SMESH::ALL; + switch(myTypeId) { + case 0: aType = SMESH::NODE; break; + case 1: aType = SMESH::EDGE; break; + case 2: aType = SMESH::FACE; break; + case 3: aType = SMESH::VOLUME; break; + } + + if (myCurrentLineEdit == mySubMeshLine) { + Standard_Boolean aRes; + SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + for (; anIt.More(); anIt.Next()) { + SMESH::SMESH_subMesh_var aSubMesh = mySMESHGUI->ConvertIOinSubMesh(anIt.Value(), aRes); + if (aRes && !aSubMesh->_is_nil()) { + // check if mesh is the same + if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { + if (aType == SMESH::NODE) { + try { + SMESH::long_array_var anElements = aSubMesh->GetNodesId(); + int k = anElements->length(); + QListBoxItem* anItem = 0; + for (int i = 0; i < k; i++) { + anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch); + if (anItem) delete anItem; + } + } + catch (const SALOME::SALOME_Exception& ex) { + QtCatchCorbaException(ex); + } + } + else { + try { + SMESH::long_array_var anElements = aSubMesh->GetElementsId(); + int k = anElements->length(); + QListBoxItem* anItem = 0; + for (int i = 0; i < k; i++) { + anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch); + if (anItem) delete anItem; + } + } + catch (const SALOME::SALOME_Exception& ex) { + QtCatchCorbaException(ex); + } + } + } + } + } + } + else if (myCurrentLineEdit == myGroupLine) { + Standard_Boolean aRes; + SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); + for (; anIt.More(); anIt.Next()) { + SMESH::SMESH_Group_var aGroup = mySMESHGUI->ConvertIOinSMESHGroup(anIt.Value(), aRes); + if (aRes && !aGroup->_is_nil()) { + // check if mesh is the same + if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { + SMESH::long_array_var anElements = aGroup->GetListOfID(); + int k = anElements->length(); + QListBoxItem* anItem = 0; + for (int i = 0; i < k; i++) { + anItem = myElements->findItem(QString::number(anElements[i]), Qt::ExactMatch); + if (anItem) delete anItem; + } + } + } + } + } + } + busy = false; + updateButtons(); +} + +//================================================================================= +// function : onSort() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::onSort() +{ + // PAL5412: sorts items in ascending by "string" value + // myElements->sort(true); + // myElements->update(); + int i, k = myElements->count(); + if (k > 0) { + busy = true; + QStringList aSelected; + std::vector anArray(k); + // QMemArray anArray(k); + QListBoxItem* anItem; + // fill the array + for (anItem = myElements->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) { + anArray[i] = anItem->text().toInt(); + if (anItem->isSelected()) + aSelected.append(anItem->text()); + } + // sort & update list + std::sort(anArray.begin(), anArray.end()); + // anArray.sort(); + myElements->clear(); + for (i = 0; i < k; i++) { + myElements->insertItem(QString::number(anArray[i])); + } + for (QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it) { + anItem = myElements->findItem(*it, Qt::ExactMatch); + if (anItem) myElements->setSelected(anItem, true); + } + busy = false; + } +} + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_GroupDlg::closeEvent( QCloseEvent* e ) +{ + QAD_StudyFrame* aStudyFrame = mySMESHGUI->GetActiveStudy()->getActiveStudyFrame(); + if (aStudyFrame->getTypeView() == VIEW_VTK) { + mySMESHGUI->SetPickable(); + if (mySelectionMode == 0) + mySMESHGUI->EraseSimulationActors(); + + // remove filters from viewer + VTKViewer_InteractorStyleSALOME* aStyle = ((VTKViewer_ViewFrame*)aStudyFrame->getRightFrame()->getViewFrame())->getRWInteractor()->GetInteractorStyleSALOME(); + aStyle->RemoveEdgeFilter(); + aStyle->RemoveFaceFilter(); + + } + + mySelection->ClearIObjects(); + QAD_Application::getDesktop()->SetSelectionMode(ActorSelection); + mySelection->ClearFilters(); + mySMESHGUI->ResetState(); + + QDialog::closeEvent( e ); +} diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.h b/src/SMESHGUI/SMESHGUI_GroupDlg.h new file mode 100644 index 000000000..b18abdfd1 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.h @@ -0,0 +1,132 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : SMESHGUI_GroupDlg.h +// Author : Natalia KOPNOVA +// Module : SMESH +// $Header$ + +#ifndef DIALOGBOX_GROUP_H +#define DIALOGBOX_GROUP_H + +#include "SALOME_Selection.h" +#include "SMESH_TypeFilter.hxx" + +// QT Includes +#include +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Group) + +class QLineEdit; +class QButtonGroup; +class QListBox; +class QPushButton; +class QCheckBox; +class SMESHGUI; +class SMESH_Actor; +class SMESHGUI_FilterDlg; + +//================================================================================= +// class : SMESHGUI_GroupDlg +// purpose : +//================================================================================= +class SMESHGUI_GroupDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_GroupDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* theSel = 0, + SMESH::SMESH_Mesh_ptr theMesh = SMESH::SMESH_Mesh::_nil(), + bool modal = FALSE, WFlags fl = 0 ); + SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_Selection* theSel, + SMESH::SMESH_Group_ptr theGroup, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_GroupDlg(); + +public slots: + + void onAdd(); + void onRemove(); + + +private slots: + + void onTypeChanged(int id); + + void onOK(); + void onClose(); + bool onApply(); + + void onListSelectionChanged(); + void onObjectSelectionChanged(); + + void onSelectSubMesh(bool on); + void onSelectGroup(bool on); + void setCurrentSelection(); + + void setFilters(); + void onSort(); + + void onNameChanged(const QString& text); + +private: + void initDialog(SALOME_Selection* theSel, bool create); + void init(SMESH::SMESH_Mesh_ptr theMesh); + void init(SMESH::SMESH_Group_ptr theGroup); + void closeEvent(QCloseEvent* e); + void setSelectionMode(int theMode); + void updateButtons(); + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + SMESH_Actor* myActor; /* Current mesh actor */ + int myTypeId ; /* Current type id = radio button id */ + QLineEdit* myCurrentLineEdit; /* Current LineEdit */ + + QButtonGroup* myTypeGroup; + QLineEdit* myName; + QListBox* myElements; + QPushButton* myFilter; + + QCheckBox* mySelectSubMesh; + QPushButton* mySubMeshBtn; + QLineEdit* mySubMeshLine; + + QCheckBox* mySelectGroup; + QPushButton* myGroupBtn; + QLineEdit* myGroupLine; + + SMESH::SMESH_Mesh_var myMesh; + SMESH::SMESH_Group_var myGroup; + QValueList myIdList; + + int mySelectionMode; + Handle(SMESH_TypeFilter) mySubMeshFilter; + Handle(SMESH_TypeFilter) myGroupFilter; + + SMESHGUI_FilterDlg* myFilterDlg; +}; + +#endif // DIALOGBOX_GROUP_H diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.h b/src/SMESHGUI/SMESHGUI_Hypotheses.h new file mode 100644 index 000000000..932226296 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.h @@ -0,0 +1,74 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : SMESHGUI_Hypotheses.h +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +#ifndef SMESHGUI_Hypotheses_HeaderFile +#define SMESHGUI_Hypotheses_HeaderFile + +#include CORBA_SERVER_HEADER(SMESH_Hypothesis) + +// QT Includes +#include +#include + +//================================================================================= +// class : SMESHGUI_GenericHypothesisCreator +// purpose : +//================================================================================= +class SMESHGUI_GenericHypothesisCreator +{ + public: + virtual void CreateHypothesis (const bool isAlgo, QWidget* parent) = 0; + virtual void EditHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp) = 0; +}; + +//================================================================================= +// class : HypothesisData +// purpose : +//================================================================================= +class HypothesisData +{ + public: + HypothesisData (const QString& aPluginName, + const QString& aServerLibName, + const QString& aClientLibName, + const QString& aLabel, + const QString& anIconId) : + PluginName(aPluginName), + ServerLibName(aServerLibName), + ClientLibName(aClientLibName), + Label(aLabel), + IconId(anIconId) + {}; + + QString PluginName; + QString ServerLibName; + QString ClientLibName; + QString Label; + QString IconId; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx new file mode 100644 index 000000000..1f041af2e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx @@ -0,0 +1,307 @@ +// 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.org +// +// +// +// File : SMESHGUI_Preferences_SelectionDlg.cxx +// Author : Natalia KOPNOVA +// Module : SMESH +// $Header$ + +using namespace std; +#include "SMESHGUI_Preferences_SelectionDlg.h" +#include "SMESHGUI.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : SMESHGUI_LineEdit +// purpose : +//================================================================================= +SMESHGUI_LineEdit::SMESHGUI_LineEdit(QWidget* parent, const char *name) + : QLineEdit(parent, name) +{ +} + +SMESHGUI_LineEdit::SMESHGUI_LineEdit(const QString& text, QWidget* parent, const char *name) + : QLineEdit(text, parent, name) +{ +} + +void SMESHGUI_LineEdit::focusOutEvent(QFocusEvent* e) +{ + const QValidator* aVal = validator(); + QString aText = text(); + int aCurPos = cursorPosition(); + if (aVal && aVal->validate(aText, aCurPos) != QValidator::Acceptable) { + QString aValid = aText; + aVal->fixup(aValid); + if (aText != aValid) { + setText(aValid); + update(); + return; + } + } + QLineEdit::focusOutEvent(e); +} + + +//================================================================================= +// class : SMESHGUI_DoubleValidator +// purpose : +//================================================================================= +SMESHGUI_DoubleValidator::SMESHGUI_DoubleValidator(QObject * parent, const char *name) + : QDoubleValidator(parent, name) +{ +} + +SMESHGUI_DoubleValidator::SMESHGUI_DoubleValidator(double bottom, double top, int decimals, + QObject * parent, const char *name) + : QDoubleValidator(bottom, top, decimals, parent, name) +{ +} + +void SMESHGUI_DoubleValidator::fixup(QString& theText) const +{ + bool ok; + double aValue = theText.toDouble(&ok); + if (ok) { + if (aValue < bottom()) + theText = QString::number(bottom(), 'g', decimals()); + if (aValue > top()) + theText = QString::number(top(), 'g', decimals()); + } +} + + +//================================================================================= +// class : SMESHGUI_Preferences_SelectionDlg() +// purpose : +//================================================================================= +SMESHGUI_Preferences_SelectionDlg::SMESHGUI_Preferences_SelectionDlg( QWidget* parent, const char* name ) + : QDialog( parent, name, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + if ( !name ) setName( "SMESHGUI_Preferences_SelectionDlg" ); + setCaption( tr( "SMESH_PREF_SELECTION" ) ); + + QVBoxLayout* aMainLayout = new QVBoxLayout(this, 11, 6); + QLabel* aLabel; + + /***************************************************************/ + QGroupBox* aSelectBox = new QGroupBox(4, Qt::Horizontal, this, "selection"); + aSelectBox->setTitle(tr("SMESH_SELECTION")); + + aLabel = new QLabel(aSelectBox, "selection color label"); + aLabel->setText(tr("SMESH_OUTLINE_COLOR")); + myColor[2] = new QPushButton(aSelectBox, "outline color"); + myColor[2]->setFixedSize(QSize(25, 25)); + + aSelectBox->addSpace(0); + aSelectBox->addSpace(0); + + aLabel = new QLabel(aSelectBox, "selection color label"); + aLabel->setText(tr("SMESH_ELEMENTS_COLOR")); + myColor[1] = new QPushButton(aSelectBox, "elements color"); + myColor[1]->setFixedSize(QSize(25, 25)); + + aLabel = new QLabel(aSelectBox, "selection width label"); + aLabel->setText(tr("SMESH_WIDTH")); + myWidth[1] = new QSpinBox(0, 5, 1, aSelectBox, "selection width"); + myWidth[1]->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + myWidth[1]->setButtonSymbols(QSpinBox::PlusMinus); + myWidth[1]->setMinimumWidth(50); + + /***************************************************************/ + QGroupBox* aPreSelectBox = new QGroupBox(1, Qt::Vertical, this, "preselection"); + aPreSelectBox->setTitle(tr("SMESH_PRESELECTION")); + + aLabel = new QLabel(aPreSelectBox, "preselection color label"); + aLabel->setText(tr("SMESH_HILIGHT_COLOR")); + myColor[0] = new QPushButton(aPreSelectBox, "preselection color"); + myColor[0]->setFixedSize(QSize(25, 25)); + + aLabel = new QLabel(aPreSelectBox, "preselection width label"); + aLabel->setText(tr("SMESH_WIDTH")); + myWidth[0] = new QSpinBox(0, 5, 1, aPreSelectBox, "preselection width"); + myWidth[0]->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + myWidth[0]->setButtonSymbols(QSpinBox::PlusMinus); + myWidth[0]->setMinimumWidth(50); + + /***************************************************************/ + QGroupBox* aPrecisionBox = new QGroupBox(1, Qt::Vertical, this, "preselection"); + aPrecisionBox->setTitle(tr("SMESH_PRECISION")); + QDoubleValidator* aValidator = new SMESHGUI_DoubleValidator(aPrecisionBox); + aValidator->setBottom(0.001); + aValidator->setDecimals(6); + + aLabel = new QLabel(aPrecisionBox, "node tol label"); + aLabel->setText(tr("SMESH_NODES")); + myPrecision[0] = new SMESHGUI_LineEdit(aPrecisionBox, "node precision"); + myPrecision[0]->setValidator(aValidator); + + aLabel = new QLabel(aPrecisionBox, "item tol label"); + aLabel->setText(tr("SMESH_ELEMENTS")); + myPrecision[1] = new SMESHGUI_LineEdit(aPrecisionBox, "item precision"); + myPrecision[1]->setValidator(aValidator); + + /***************************************************************/ + QFrame* aButtons = new QFrame(this, "button box"); + aButtons->setFrameStyle(QFrame::Box | QFrame::Sunken); + QHBoxLayout* aBtnLayout = new QHBoxLayout(aButtons, 11, 6); + aBtnLayout->setAutoAdd(false); + + QPushButton* aOKBtn = new QPushButton(aButtons, "ok"); + aOKBtn->setText(tr("SMESH_BUT_OK")); + aOKBtn->setAutoDefault(true); + aOKBtn->setDefault(true); + QPushButton* aCloseBtn = new QPushButton(aButtons, "close"); + aCloseBtn->setText(tr("SMESH_BUT_CLOSE")); + aCloseBtn->setAutoDefault(true); + + aBtnLayout->addWidget(aOKBtn); + aBtnLayout->addStretch(); + aBtnLayout->addWidget(aCloseBtn); + + /***************************************************************/ + aMainLayout->addWidget(aSelectBox); + aMainLayout->addWidget(aPreSelectBox); + aMainLayout->addWidget(aPrecisionBox); + aMainLayout->addWidget(aButtons); + + for (int i = 0; i < 3; i++) + connect(myColor[i], SIGNAL(clicked()), this, SLOT(onSelectColor())); + + connect(aOKBtn, SIGNAL(clicked()), this, SLOT(accept())); + connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject())); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + SMESHGUI::GetSMESHGUI()->DefineDlgPosition(this, x, y); + this->move(x, y); +} + +//================================================================================= +// function : ~SMESHGUI_Preferences_SelectionDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_Preferences_SelectionDlg::~SMESHGUI_Preferences_SelectionDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_SelectionDlg::closeEvent( QCloseEvent* e ) +{ + reject(); +} + +//================================================================================= +// function : onSelectColor() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_SelectionDlg::onSelectColor() +{ + QPushButton* aSender = (QPushButton*)sender(); + QColor aColor = aSender->palette().active().button(); + aColor = QColorDialog::getColor(aColor, this); + if (aColor.isValid()) { + QPalette aPal = aSender->palette(); + aPal.setColor(QColorGroup::Button, aColor); + aSender->setPalette(aPal); + } +} + +//================================================================================= +// function : SetColor() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_SelectionDlg::SetColor(int type, QColor color) +{ + if (type > 0 && type <= 3) { + QPalette aPal = myColor[type-1]->palette(); + aPal.setColor(QColorGroup::Button, color); + myColor[type-1]->setPalette(aPal); + } +} + +//================================================================================= +// function : GetColor() +// purpose : +//================================================================================= +QColor SMESHGUI_Preferences_SelectionDlg::GetColor(int type) +{ + QColor aColor; + if (type > 0 && type <= 3) + aColor = myColor[type-1]->palette().active().button(); + return aColor; +} + +//================================================================================= +// function : SetWidth() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_SelectionDlg::SetWidth(int type, int value) +{ + if (type > 0 && type <= 2) + myWidth[type-1]->setValue(value); +} + +//================================================================================= +// function : GetWidth() +// purpose : +//================================================================================= +int SMESHGUI_Preferences_SelectionDlg::GetWidth(int type) +{ + if (type > 0 && type <= 2) + return myWidth[type-1]->value(); + return 0; +} + +//================================================================================= +// function : SetPrecision() +// purpose : +//================================================================================= +void SMESHGUI_Preferences_SelectionDlg::SetPrecision(int type, double value) +{ + if (type > 0 && type <= 2) + myPrecision[type-1]->setText(QString::number(value)); +} + +//================================================================================= +// function : GetPrecision() +// purpose : +//================================================================================= +double SMESHGUI_Preferences_SelectionDlg::GetPrecision(int type) +{ + if (type > 0 && type <= 2) + return myPrecision[type-1]->text().toDouble(); +} diff --git a/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.h new file mode 100644 index 000000000..a4edd3865 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.h @@ -0,0 +1,97 @@ +// 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-platorm.org or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_Preferences_SelectionDlg.h +// Author : Natalia KOPNOVA +// Module : SMESH +// $Header$ + +#ifndef SMESHGUI_PREFERENCES_SELECTIONDLG_H +#define SMESHGUI_PREFERENCES_SELECTIONDLG_H + + +// QT Includes +#include +#include +#include + +class QPushButton; +class QSpinBox; +class QColor; + +class SMESHGUI_LineEdit : public QLineEdit +{ + Q_OBJECT + + public: + SMESHGUI_LineEdit(QWidget* parent, const char* name = 0); + SMESHGUI_LineEdit(const QString& text, QWidget* parent, const char* name = 0); + + ~SMESHGUI_LineEdit() {}; + + protected: + void focusOutEvent(QFocusEvent* e); +}; + +class SMESHGUI_DoubleValidator : public QDoubleValidator +{ + Q_OBJECT + + public: + SMESHGUI_DoubleValidator(QObject* parent, const char* name = 0); + SMESHGUI_DoubleValidator(double bottom, double top, int decimals, + QObject* parent, const char* name = 0); + + ~SMESHGUI_DoubleValidator() {}; + + void fixup(QString& text) const; +}; + +class SMESHGUI_Preferences_SelectionDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_Preferences_SelectionDlg( QWidget* parent = 0, const char* name = 0 ); + ~SMESHGUI_Preferences_SelectionDlg(); + + void SetColor(int type, QColor color); + QColor GetColor(int type); + void SetWidth(int type, int value); + int GetWidth(int type); + void SetPrecision(int type, double value); + double GetPrecision(int type); + +private: + void closeEvent( QCloseEvent* e ) ; + +private slots: + void onSelectColor(); + +private: + QPushButton* myColor[3]; + QSpinBox* myWidth[2]; + QLineEdit* myPrecision[2]; +}; + +#endif // SMESHGUI_PREFERENCES_SELECTIONDLG_H diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx new file mode 100644 index 000000000..ee42768b1 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx @@ -0,0 +1,187 @@ +// SMESH SMESHGUI : reading of xml file with list of available hypotheses and algorithms +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : SMESHGUI_XmlHandler.cxx +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +using namespace std; +#define INCLUDE_MENUITEM_DEF + +#include "SMESHGUI_XmlHandler.h" + +// QT Include +//#include +#include + +/*! + Constructor +*/ +SMESHGUI_XmlHandler::SMESHGUI_XmlHandler() +{ +} + +/*! + Destructor +*/ +SMESHGUI_XmlHandler::~SMESHGUI_XmlHandler() +{ +} + +/*! + Starts parsing of document. Does some initialization + + Reimplemented from QXmlDefaultHandler. +*/ +bool SMESHGUI_XmlHandler::startDocument() +{ + myErrorProt = ""; + return TRUE; +} + +/*! + Does different actions depending on the name of the tag and the + state you are in document. + + Reimplemented from QXmlDefaultHandler. +*/ +bool SMESHGUI_XmlHandler::startElement (const QString&, const QString&, + const QString& qName, + const QXmlAttributes& atts) +{ + if (qName == "meshers") + { + myHypothesesMap.clear(); + myAlgorithmsMap.clear(); + } + else if (qName == "meshers-group") // group of hypotheses and algorithms + { +// if (atts.value("server-lib") != "") + { + myPluginName = atts.value("name"); + myServerLib = atts.value("server-lib"); + myClientLib = atts.value("gui-lib"); + + QString aResName = atts.value("resources"); + if (aResName != "") + { + MESSAGE("Loading Resources " << aResName); + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + QString msg; + if (!resMgr->loadResources(aResName, msg)) + MESSAGE(msg); + } + } + } + else if (qName == "hypotheses") // group of hypotheses + { + } + else if (qName == "algorithms") // group of algorithms + { + } + else if (qName == "hypothesis" || qName == "algorithm") // hypothesis or algorithm + { + if (atts.value("type") != "") + { + QString aHypAlType = atts.value("type"); + QString aLabel = atts.value("label-id"); + QString anIcon = atts.value("icon-id"); + HypothesisData* aHypLibNames = + new HypothesisData (myPluginName, myServerLib, myClientLib, + aLabel, anIcon); + + if (qName == "algorithm") + { + myAlgorithmsMap[(char*)aHypAlType.latin1()] = aHypLibNames; + } + else + { + myHypothesesMap[(char*)aHypAlType.latin1()] = aHypLibNames; + } + } + } + else + { + // error + return FALSE; + } + return TRUE; +} + + +/*! + Reimplemented from QXmlDefaultHandler. +*/ +bool SMESHGUI_XmlHandler::endElement (const QString&, const QString&, const QString&) +{ + return TRUE; +} + + +/*! + Reimplemented from QXmlDefaultHandler. +*/ +bool SMESHGUI_XmlHandler::characters (const QString& ch) +{ + // we are not interested in whitespaces + QString ch_simplified = ch.simplifyWhiteSpace(); + if ( ch_simplified.isEmpty() ) + return TRUE; + return TRUE; +} + + +/*! + Returns the default error string. + + Reimplemented from QXmlDefaultHandler. +*/ +QString SMESHGUI_XmlHandler::errorString() +{ + return "the document is not in the quote file format"; +} + +/*! + Returns the error protocol if parsing failed + + Reimplemented from QXmlDefaultHandler. +*/ +QString SMESHGUI_XmlHandler::errorProtocol() +{ + return myErrorProt; +} + +/*! + Returns exception + + Reimplemented from QXmlDefaultHandler. +*/ +bool SMESHGUI_XmlHandler::fatalError (const QXmlParseException& exception) +{ + myErrorProt += QString("fatal parsing error: %1 in line %2, column %3\n") + .arg(exception.message()) + .arg(exception.lineNumber()) + .arg(exception.columnNumber()); + + return QXmlDefaultHandler::fatalError( exception ); +} diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.h b/src/SMESHGUI/SMESHGUI_XmlHandler.h new file mode 100644 index 000000000..363d9830c --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.h @@ -0,0 +1,58 @@ +// SMESH SMESHGUI : reading of xml file with list of available hypotheses and algorithms +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : SMESHGUI_XmlHandler.cxx +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +#include "SMESHGUI.h" + +#include +#include + +class SMESHGUI_XmlHandler : public QXmlDefaultHandler +{ + public: + SMESHGUI_XmlHandler(); + virtual ~SMESHGUI_XmlHandler(); + + bool startDocument(); + bool startElement( const QString& namespaceURI, const QString& localName, + const QString& qName, const QXmlAttributes& atts ); + bool endElement( const QString& namespaceURI, const QString& localName, const QString& qName ); + bool characters( const QString& ch ); + + QString errorString(); + QString errorProtocol(); + bool fatalError (const QXmlParseException& exception); + + public: + map myHypothesesMap; + map myAlgorithmsMap; + + private: + QString myErrorProt; + QString myPluginName; + QString myServerLib; + QString myClientLib; +}; diff --git a/src/SMESH_I/SMESHEngine.cxx b/src/SMESH_I/SMESHEngine.cxx new file mode 100644 index 000000000..fc1bd440b --- /dev/null +++ b/src/SMESH_I/SMESHEngine.cxx @@ -0,0 +1,23 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +int main(int argc, char** argv) +{ + return 1; +} diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx new file mode 100644 index 000000000..724d602dd --- /dev/null +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -0,0 +1,914 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Filter_i.cxx +// Author : Alexey Petrov, OCC +// Module : SMESH + + +#include "SMESH_Filter_i.hxx" + +#include "SMDS_Iterator.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDSAbs_ElementType.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESHDS_Mesh.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + AUXILIARY METHODS +*/ + +static inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 ) +{ + return gp_Vec( P1 - P2 ).Angle( gp_Vec( P3 - P2 ) ); +} + +static inline double getArea( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 ) +{ + gp_Vec aVec1( P2 - P1 ); + gp_Vec aVec2( P3 - P1 ); + return ( aVec1 ^ aVec2 ).Magnitude() * 0.5; +} + +static inline double getArea( const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3 ) +{ + return getArea( P1.XYZ(), P2.XYZ(), P3.XYZ() ); +} + +static inline double getDistance( const gp_XYZ& P1, const gp_XYZ& P2 ) +{ + double aDist = gp_Pnt( P1 ).Distance( gp_Pnt( P2 ) ); + return aDist; +} + +static int getNbMultiConnection( SMESHDS_Mesh* theMesh, const int theId ) +{ + if ( theMesh == 0 ) + return 0; + + const SMDS_MeshElement* anEdge = theMesh->FindElement( theId ); + if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge || anEdge->NbNodes() != 2 ) + return 0; + + TColStd_MapOfInteger aMap; + + int aResult = 0; + SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator(); + if ( anIter != 0 ) + { + while( anIter->more() ) + { + const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); + if ( aNode == 0 ) + return 0; + SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator(); + while( anElemIter->more() ) + { + const SMDS_MeshElement* anElem = anElemIter->next(); + if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge ) + { + int anId = anElem->GetID(); + + if ( anIter->more() ) // i.e. first node + aMap.Add( anId ); + else if ( aMap.Contains( anId ) ) + aResult++; + } + } +// delete anElemIter; + } +// delete anIter; + } + + return aResult; +} + +using namespace std; +using namespace SMESH; + +/* + FUNCTORS +*/ + +/* + Class : NumericalFunctor_i + Description : Base class for numerical functors +*/ + +NumericalFunctor_i::NumericalFunctor_i() +: SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) +{ + myMesh = 0; + SMESH_Gen_i::GetPOA()->activate_object( this ); +} + +void NumericalFunctor_i::SetMesh( SMESH_Mesh_ptr theMesh ) +{ + SMESH_Mesh_i* anImplPtr = + dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); + myMesh = anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0; +} + +bool NumericalFunctor_i::getPoints( const int theId, + TColgp_SequenceOfXYZ& theRes ) const +{ + theRes.Clear(); + + if ( myMesh == 0 ) + return false; + + // Get nodes of the face + const SMDS_MeshElement* anElem = myMesh->FindElement( theId ); + if ( anElem == 0 || anElem->GetType() != GetType() ) + return false; + + int nbNodes = anElem->NbNodes(); + + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); + if ( anIter != 0 ) + { + while( anIter->more() ) + { + const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); + if ( aNode != 0 ) + theRes.Append( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) ); + } + +// delete anIter; + } + + return true; +} + + +/* + Class : SMESH_MinimumAngleFunct + Description : Functor for calculation of minimum angle +*/ + +CORBA::Double MinimumAngle_i::GetValue( CORBA::Long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) + return 0; + + double aMin; + + if ( P.Length() == 3 ) + { + double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) ); + double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); + double A2 = getAngle( P( 2 ), P( 3 ), P( 1 ) ); + + aMin = Min( A0, Min( A1, A2 ) ); + } + else + { + double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) ); + double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); + double A2 = getAngle( P( 2 ), P( 3 ), P( 4 ) ); + double A3 = getAngle( P( 3 ), P( 4 ), P( 1 ) ); + + aMin = Min( Min( A0, A1 ), Min( A2, A3 ) ); + } + + return aMin * 180 / PI; +} + +int MinimumAngle_i::GetType() const +{ + return SMDSAbs_Face; +} + +/* + Class : AspectRatio_i + Description : Functor for calculating aspect ratio +*/ + +CORBA::Double AspectRatio_i::GetValue( CORBA::Long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) + return 0; + + int nbNodes = P.Length(); + + // Compute lengths of the sides + + double aLen[ nbNodes ]; + for ( int i = 0; i < nbNodes - 1; i++ ) + aLen[ i ] = getDistance( P( i + 1 ), P( i + 2 ) ); + aLen[ nbNodes - 1 ] = getDistance( P( 1 ), P( nbNodes ) ); + + // Compute aspect ratio + + if ( nbNodes == 3 ) + { + double aMaxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) ); + double anArea = getArea( P( 1 ), P( 2 ), P( 3 ) ); + static double aCoef = sqrt( 3. ) / 4; + + return anArea != 0 ? aCoef * aMaxLen * aMaxLen / anArea : 0; + } + else + { + double aMaxLen = Max( Max( aLen[ 0 ], aLen[ 1 ] ), Max( aLen[ 2 ], aLen[ 3 ] ) ); + double aMinLen = Min( Min( aLen[ 0 ], aLen[ 1 ] ), Min( aLen[ 2 ], aLen[ 3 ] ) ); + + return aMinLen != 0 ? aMaxLen / aMinLen : 0; + } +} + +int AspectRatio_i::GetType() const +{ + return SMDSAbs_Face; +} + +/* + Class : Warping_i + Description : Functor for calculating warping +*/ + +CORBA::Double Warping_i::GetValue( CORBA::Long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 4 ) + return 0; + + gp_XYZ G = ( P( 1 ) + P( 2 ) + P( 3 ) + P( 4 ) ) / 4; + + double A1 = ComputeA( P( 1 ), P( 2 ), P( 3 ), G ); + double A2 = ComputeA( P( 2 ), P( 3 ), P( 4 ), G ); + double A3 = ComputeA( P( 3 ), P( 4 ), P( 1 ), G ); + double A4 = ComputeA( P( 4 ), P( 1 ), P( 2 ), G ); + + return Max( Max( A1, A2 ), Max( A3, A4 ) ); +} + +double Warping_i::ComputeA( const gp_XYZ& thePnt1, + const gp_XYZ& thePnt2, + const gp_XYZ& thePnt3, + const gp_XYZ& theG ) const +{ + double aLen1 = gp_Pnt( thePnt1 ).Distance( gp_Pnt( thePnt2 ) ); + double aLen2 = gp_Pnt( thePnt2 ).Distance( gp_Pnt( thePnt3 ) ); + double L = Min( aLen1, aLen2 ) * 0.5; + + gp_XYZ GI = ( thePnt2 - thePnt1 ) / 2. - theG; + gp_XYZ GJ = ( thePnt3 - thePnt2 ) / 2. - theG; + gp_XYZ N = GI.Crossed( GJ ); + N.Normalize(); + + double H = gp_Vec( thePnt2 - theG ).Dot( gp_Vec( N ) ); + return asin( fabs( H / L ) ) * 180 / PI; +} + +int Warping_i::GetType() const +{ + return SMDSAbs_Face; +} + +/* + Class : Taper_i + Description : Functor for calculating taper +*/ + +CORBA::Double Taper_i::GetValue( CORBA::Long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 4 ) + return 0; + + // Compute taper + double J1 = getArea( P( 4 ), P( 1 ), P( 2 ) ) / 2; + double J2 = getArea( P( 3 ), P( 1 ), P( 2 ) ) / 2; + double J3 = getArea( P( 2 ), P( 3 ), P( 4 ) ) / 2; + double J4 = getArea( P( 3 ), P( 4 ), P( 1 ) ) / 2; + + double JA = 0.25 * ( J1 + J2 + J3 + J4 ); + + double T1 = fabs( ( J1 - JA ) / JA ); + double T2 = fabs( ( J2 - JA ) / JA ); + double T3 = fabs( ( J3 - JA ) / JA ); + double T4 = fabs( ( J4 - JA ) / JA ); + + return Max( Max( T1, T2 ), Max( T3, T4 ) ); +} + +int Taper_i::GetType() const +{ + return SMDSAbs_Face; +} + +/* + Class : Skew_i + Description : Functor for calculating skew in degrees +*/ + +static inline double skewAngle( const gp_XYZ& p1, const gp_XYZ& p2, const gp_XYZ& p3 ) +{ + gp_XYZ p12 = ( p2 + p1 ) / 2; + gp_XYZ p23 = ( p3 + p2 ) / 2; + gp_XYZ p31 = ( p3 + p1 ) / 2; + + return gp_Vec( p31 - p2 ).Angle( p12 - p23 ); +} + +CORBA::Double Skew_i::GetValue( CORBA::Long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) + return 0; + + // Compute skew + static double PI2 = PI / 2; + if ( P.Length() == 3 ) + { + double A0 = fabs( PI2 - skewAngle( P( 3 ), P( 1 ), P( 2 ) ) ); + double A1 = fabs( PI2 - skewAngle( P( 1 ), P( 2 ), P( 3 ) ) ); + double A2 = fabs( PI2 - skewAngle( P( 2 ), P( 3 ), P( 1 ) ) ); + + return Max( A0, Max( A1, A2 ) ) * 180 / PI; + } + else + { + gp_XYZ p12 = ( P( 1 ) + P( 2 ) ) / 2; + gp_XYZ p23 = ( P( 2 ) + P( 3 ) ) / 2; + gp_XYZ p34 = ( P( 3 ) + P( 4 ) ) / 2; + gp_XYZ p41 = ( P( 4 ) + P( 1 ) ) / 2; + + double A = fabs( PI2 - gp_Vec( p34 - p12 ).Angle( p23 - p41 ) ); + + return A * 180 / PI; + } +} + +int Skew_i::GetType() const +{ + return SMDSAbs_Face; +} + +/* + Class : Area_i + Description : Functor for calculating area +*/ + +CORBA::Double Area_i::GetValue( CORBA::Long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) + return 0; + + if ( P.Length() == 3 ) + return getArea( P( 1 ), P( 2 ), P( 3 ) ); + else + return getArea( P( 1 ), P( 2 ), P( 3 ) ) + getArea( P( 1 ), P( 3 ), P( 4 ) ); +} + +int Area_i::GetType() const +{ + return SMDSAbs_Face; +} + +/* + Class : Length_i + Description : Functor for calculating length off edge +*/ + +CORBA::Double Length_i::GetValue( CORBA::Long theId ) +{ + TColgp_SequenceOfXYZ P; + return getPoints( theId, P ) && P.Length() == 2 ? getDistance( P( 1 ), P( 2 ) ) : 0; +} + +int Length_i::GetType() const +{ + return SMDSAbs_Edge; +} + +/* + Class : MultiConnection_i + Description : Functor for calculating number of faces conneted to the edge +*/ + +CORBA::Double MultiConnection_i::GetValue( CORBA::Long theId ) +{ + return getNbMultiConnection( myMesh, theId ); +} + +int MultiConnection_i::GetType() const +{ + return SMDSAbs_Edge; +} + +/* + PREDICATES +*/ + +/* + Class : Predicate_i + Description : Base class for all predicates +*/ +Predicate_i::Predicate_i() +: SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) +{ + SMESH_Gen_i::GetPOA()->activate_object( this ); +} + + +/* + Class : FreeBorders_i + Description : Predicate for free borders +*/ + +FreeBorders_i::FreeBorders_i() +{ + myMesh = 0; +} + +void FreeBorders_i::SetMesh( SMESH_Mesh_ptr theMesh ) +{ + SMESH_Mesh_i* anImplPtr = + dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); + myMesh = anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0; +} + +CORBA::Boolean FreeBorders_i::IsSatisfy( CORBA::Long theId ) +{ + return getNbMultiConnection( myMesh, theId ) == 1; +} + +int FreeBorders_i::GetType() const +{ + return SMDSAbs_Edge; +} + +/* + Class : Comparator_i + Description : Base class for comparators +*/ + +Comparator_i::Comparator_i() +{ + myMargin = 0; + myFunctor = 0; +} + +Comparator_i::~Comparator_i() +{ + if ( myFunctor != 0 ) + myFunctor->Destroy(); +} + +void Comparator_i::SetMesh( SMESH_Mesh_ptr theMesh ) +{ + if ( myFunctor != 0 ) + myFunctor->SetMesh( theMesh ); +} + +void Comparator_i::SetMargin( CORBA::Double theValue ) +{ + myMargin = theValue; +} + +void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct ) +{ + if ( myFunctor != 0 ) + myFunctor->Destroy(); + + myFunctor = dynamic_cast( SMESH_Gen_i::GetServant( theFunct ).in() ); + + if ( myFunctor != 0 ) + myFunctor->Register(); +} + +int Comparator_i::GetType() const +{ + return myFunctor != 0 ? myFunctor->GetType() : SMDSAbs_All; +} + +/* + Class : LessThan_i + Description : Comparator "<" +*/ + +CORBA::Boolean LessThan_i::IsSatisfy( CORBA::Long theId ) +{ + return myFunctor != 0 && myFunctor->GetValue( theId ) < myMargin; +} + +/* + Class : MoreThan_i + Description : Comparator ">" +*/ + +CORBA::Boolean MoreThan_i::IsSatisfy( CORBA::Long theId ) +{ + return myFunctor != 0 && myFunctor->GetValue( theId ) > myMargin; +} + +/* + Class : EqualTo_i + Description : Comparator "=" +*/ +EqualTo_i::EqualTo_i() +{ + myToler = Precision::Confusion(); +} + +CORBA::Boolean EqualTo_i::IsSatisfy( CORBA::Long theId ) +{ + return myFunctor != 0 && fabs( myFunctor->GetValue( theId ) - myMargin ) < myToler; +} + +void EqualTo_i::SetTolerance( CORBA::Double theToler ) +{ + myToler = theToler; +} + + +/* + Class : LogicalNOT_i + Description : Logical NOT predicate +*/ + +LogicalNOT_i::LogicalNOT_i() +{ + myPredicate = 0; +} + +LogicalNOT_i::~LogicalNOT_i() +{ + if ( myPredicate ) + myPredicate->Destroy(); +} + +CORBA::Boolean LogicalNOT_i::IsSatisfy( CORBA::Long theId ) +{ + return myPredicate !=0 && !myPredicate->IsSatisfy( theId ); +} + +void LogicalNOT_i::SetMesh( SMESH_Mesh_ptr theMesh ) +{ + if ( myPredicate != 0 ) + myPredicate->SetMesh( theMesh ); +} + +void LogicalNOT_i::SetPredicate( Predicate_ptr thePred ) +{ + if ( myPredicate != 0 ) + myPredicate->Destroy(); + + myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePred ).in() ); + + if ( myPredicate != 0 ) + myPredicate->Register(); +} + +int LogicalNOT_i::GetType() const +{ + return myPredicate != 0 ? myPredicate->GetType() : SMDSAbs_All; +} + + +/* + Class : LogicalBinary_i + Description : Base class for binary logical predicate +*/ + +LogicalBinary_i::LogicalBinary_i() +{ + myPredicate1 = 0; + myPredicate2 = 0; +} +LogicalBinary_i::~LogicalBinary_i() +{ + if ( myPredicate1 != 0 ) + myPredicate1->Destroy(); + + if ( myPredicate2 != 0 ) + myPredicate2->Destroy(); +} + +void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh ) +{ + if ( myPredicate1 != 0 ) + myPredicate1->SetMesh( theMesh ); + + if ( myPredicate2 != 0 ) + myPredicate2->SetMesh( theMesh ); +} + +void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate ) +{ + if ( myPredicate1 != 0 ) + myPredicate1->Destroy(); + + myPredicate1 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + + if ( myPredicate1 != 0 ) + myPredicate1->Register(); +} + +void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate ) +{ + if ( myPredicate2 != 0 ) + myPredicate2->Destroy(); + + myPredicate2 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + + if ( myPredicate2 != 0 ) + myPredicate2->Register(); +} + +int LogicalBinary_i::GetType() const +{ + if ( myPredicate1 == 0 || myPredicate2 == 0 ) + return SMDSAbs_All; + + int aType1 = myPredicate1->GetType(); + int aType2 = myPredicate2->GetType(); + + return aType1 == aType2 ? aType1 : SMDSAbs_All; +} + +/* + Class : LogicalAND_i + Description : Logical AND +*/ + +CORBA::Boolean LogicalAND_i::IsSatisfy( CORBA::Long theId ) +{ + return myPredicate1 != 0 && + myPredicate2 != 0 && + myPredicate1->IsSatisfy( theId ) && myPredicate2->IsSatisfy( theId );; +} + +/* + Class : LogicalOR_i + Description : Logical OR +*/ + +CORBA::Boolean LogicalOR_i::IsSatisfy( CORBA::Long theId ) +{ + return myPredicate1 != 0 && + myPredicate2 != 0 && + myPredicate1->IsSatisfy( theId ) || myPredicate2->IsSatisfy( theId ); +} + + +/* + FILTER +*/ + +Filter_i::Filter_i() +{ + myPredicate = 0; +} + +Filter_i::~Filter_i() +{ + if ( myPredicate != 0 ) + myPredicate->Destroy(); +} + +void Filter_i::SetPredicate( Predicate_ptr thePredicate ) +{ + if ( myPredicate != 0 ) + myPredicate->Destroy(); + + myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + + if ( myPredicate != 0 ) + myPredicate->Register(); +} + +void Filter_i::SetMesh( SMESH_Mesh_ptr theMesh ) +{ + if ( myPredicate != 0 ) + myPredicate->SetMesh( theMesh ); +} + +SMESH::long_array* Filter_i::GetElementsId( SMESH_Mesh_ptr theMesh ) +{ + + SetMesh( theMesh ); + + SMESH_Mesh_i* anImplPtr = + dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); + + TColStd_ListOfInteger aList; + + if ( anImplPtr != 0 ) + { + SMESHDS_Mesh* aMesh = anImplPtr->GetImpl().GetMeshDS(); + + if ( myPredicate != 0 ) + { + int aType = myPredicate->GetType(); + + if ( aType == SMDSAbs_Edge ) + { + SMDS_EdgeIteratorPtr anIter = aMesh->edgesIterator(); + if ( anIter != 0 ) + { + while( anIter->more() ) + { + const SMDS_MeshElement* anElem = anIter->next(); + if ( myPredicate->IsSatisfy( anElem->GetID() ) ) + aList.Append( anElem->GetID() ); + } + } +// delete anIter; + } + else if ( aType == SMDSAbs_Face ) + { + SMDS_FaceIteratorPtr anIter = aMesh->facesIterator(); + if ( anIter != 0 ) + { + while( anIter->more() ) + { + const SMDS_MeshElement* anElem = anIter->next(); + if ( myPredicate->IsSatisfy( anElem->GetID() ) ) + aList.Append( anElem->GetID() ); + } + } +// delete anIter; + } + } + } + + SMESH::long_array_var anArray = new SMESH::long_array; + + anArray->length( aList.Extent() ); + TColStd_ListIteratorOfListOfInteger anIter( aList ); + int i = 0; + for( ; anIter.More(); anIter.Next() ) + anArray[ i++ ] = anIter.Value(); + + return anArray._retn(); +} + +/* + FILTER MANAGER +*/ + +FilterManager_i::FilterManager_i() +: SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) +{ + SMESH_Gen_i::GetPOA()->activate_object( this ); +} + +MinimumAngle_ptr FilterManager_i::CreateMinimumAngle() +{ + SMESH::MinimumAngle_i* aServant = new SMESH::MinimumAngle_i(); + SMESH::MinimumAngle_var anObj = aServant->_this(); + return anObj._retn(); +} + + +AspectRatio_ptr FilterManager_i::CreateAspectRatio() +{ + SMESH::AspectRatio_i* aServant = new SMESH::AspectRatio_i(); + SMESH::AspectRatio_var anObj = aServant->_this(); + return anObj._retn(); +} + + +Warping_ptr FilterManager_i::CreateWarping() +{ + SMESH::Warping_i* aServant = new SMESH::Warping_i(); + SMESH::Warping_var anObj = aServant->_this(); + return anObj._retn(); +} + + +Taper_ptr FilterManager_i::CreateTaper() +{ + SMESH::Taper_i* aServant = new SMESH::Taper_i(); + SMESH::Taper_var anObj = aServant->_this(); + return anObj._retn(); +} + + +Skew_ptr FilterManager_i::CreateSkew() +{ + SMESH::Skew_i* aServant = new SMESH::Skew_i(); + SMESH::Skew_var anObj = aServant->_this(); + return anObj._retn(); +} + + +Area_ptr FilterManager_i::CreateArea() +{ + SMESH::Area_i* aServant = new SMESH::Area_i(); + SMESH::Area_var anObj = aServant->_this(); + return anObj._retn(); +} + + +Length_ptr FilterManager_i::CreateLength() +{ + SMESH::Length_i* aServant = new SMESH::Length_i(); + SMESH::Length_var anObj = aServant->_this(); + return anObj._retn(); +} + + +MultiConnection_ptr FilterManager_i::CreateMultiConnection() +{ + SMESH::MultiConnection_i* aServant = new SMESH::MultiConnection_i(); + SMESH::MultiConnection_var anObj = aServant->_this(); + return anObj._retn(); +} + + +FreeBorders_ptr FilterManager_i::CreateFreeBorders() +{ + SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i(); + SMESH::FreeBorders_var anObj = aServant->_this(); + return anObj._retn(); +} + +LessThan_ptr FilterManager_i::CreateLessThan() +{ + SMESH::LessThan_i* aServant = new SMESH::LessThan_i(); + SMESH::LessThan_var anObj = aServant->_this(); + return anObj._retn(); +} + + +MoreThan_ptr FilterManager_i::CreateMoreThan() +{ + SMESH::MoreThan_i* aServant = new SMESH::MoreThan_i(); + SMESH::MoreThan_var anObj = aServant->_this(); + return anObj._retn(); +} + +EqualTo_ptr FilterManager_i::CreateEqualTo() +{ + SMESH::EqualTo_i* aServant = new SMESH::EqualTo_i(); + SMESH::EqualTo_var anObj = aServant->_this(); + return anObj._retn(); +} + + +LogicalNOT_ptr FilterManager_i::CreateLogicalNOT() +{ + SMESH::LogicalNOT_i* aServant = new SMESH::LogicalNOT_i(); + SMESH::LogicalNOT_var anObj = aServant->_this(); + return anObj._retn(); +} + + +LogicalAND_ptr FilterManager_i::CreateLogicalAND() +{ + SMESH::LogicalAND_i* aServant = new SMESH::LogicalAND_i(); + SMESH::LogicalAND_var anObj = aServant->_this(); + return anObj._retn(); +} + + +LogicalOR_ptr FilterManager_i::CreateLogicalOR() +{ + SMESH::LogicalOR_i* aServant = new SMESH::LogicalOR_i(); + SMESH::LogicalOR_var anObj = aServant->_this(); + return anObj._retn(); +} + +Filter_ptr FilterManager_i::CreateFilter() +{ + SMESH::Filter_i* aServant = new SMESH::Filter_i(); + SMESH::Filter_var anObj = aServant->_this(); + return anObj._retn(); +} diff --git a/src/SMESH_I/SMESH_Filter_i.hxx b/src/SMESH_I/SMESH_Filter_i.hxx new file mode 100644 index 000000000..26edd5b72 --- /dev/null +++ b/src/SMESH_I/SMESH_Filter_i.hxx @@ -0,0 +1,417 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Filter_i.hxx +// Author : Alexey Petrov, OCC +// Module : SMESH + +#ifndef _SMESH_FILTER_I_HXX_ +#define _SMESH_FILTER_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_Filter) +#include "SALOME_GenericObj_i.hh" + +class SMESHDS_Mesh; +class gp_Pnt; +class gp_XYZ; +class TColgp_SequenceOfXYZ; + +namespace SMESH{ + +/* + FUNCTORS +*/ + +/* + Class : NumericalFunctor_i + Description : Base class for numerical functors + + PortableServer::POA_ptr thePOA + +*/ + +class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor, + public virtual SALOME::GenericObj_i +{ +public: + NumericalFunctor_i(); + void SetMesh( SMESH_Mesh_ptr theMesh ); + virtual int GetType() const = 0; + +protected: + bool getPoints( const int theId, + TColgp_SequenceOfXYZ& theRes ) const; +protected: + SMESHDS_Mesh* myMesh; +}; + +/* + Class : SMESH_MinimumAngleFunct + Description : Functor for calculation of minimum angle +*/ + +class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle, + public virtual NumericalFunctor_i +{ +public: + CORBA::Double GetValue( CORBA::Long theElementId ); + virtual int GetType() const; +}; + +/* + Class : AspectRatio_i + Description : Functor for calculating aspect ratio +*/ + +class AspectRatio_i: public virtual POA_SMESH::AspectRatio, + public virtual NumericalFunctor_i +{ +public: + CORBA::Double GetValue(CORBA::Long theElementId); + virtual int GetType() const; +}; + +/* + Class : Warping_i + Description : Functor for calculating warping +*/ + +class Warping_i: public virtual POA_SMESH::Warping, + public virtual NumericalFunctor_i +{ +public: + CORBA::Double GetValue(CORBA::Long theElementId); + virtual int GetType() const; + +private: + double ComputeA( const gp_XYZ&, const gp_XYZ&, + const gp_XYZ&, const gp_XYZ& ) const; +}; + +/* + Class : Taper_i + Description : Functor for calculating taper +*/ + +class Taper_i: public virtual POA_SMESH::Taper, + public virtual NumericalFunctor_i +{ +public: + CORBA::Double GetValue( CORBA::Long theElementId ); + virtual int GetType() const; +}; + +/* + Class : Skew_i + Description : Functor for calculating skew in degrees +*/ + +class Skew_i: public virtual POA_SMESH::Skew, + public virtual NumericalFunctor_i +{ +public: + CORBA::Double GetValue( CORBA::Long theElementId ); + virtual int GetType() const; +}; + +/* + Class : Area_i + Description : Functor for calculating area +*/ + +class Area_i: public virtual POA_SMESH::Area, + public virtual NumericalFunctor_i +{ +public: + CORBA::Double GetValue( CORBA::Long theElementId ); + virtual int GetType() const; +}; + +/* + Class : Length_i + Description : Functor for calculating length of edge +*/ + +class Length_i: public virtual POA_SMESH::Length, + public virtual NumericalFunctor_i +{ +public: + CORBA::Double GetValue( CORBA::Long theElementId ); + virtual int GetType() const; +}; + +/* + Class : MultiConnection_i + Description : Functor for calculating number of faces conneted to the edge +*/ + +class MultiConnection_i: public virtual POA_SMESH::MultiConnection, + public virtual NumericalFunctor_i +{ +public: + CORBA::Double GetValue( CORBA::Long theElementId ); + virtual int GetType() const; +}; + + +/* + PREDICATES +*/ + +/* + Class : Predicate_i + Description : Base class for all predicates +*/ + +class Predicate_i: public virtual POA_SMESH::Predicate, + public virtual SALOME::GenericObj_i +{ +public: + Predicate_i(); + virtual int GetType() const = 0; +}; + + +/* + Class : FreeBorders_i + Description : Predicate for free borders +*/ + +class FreeBorders_i: public virtual POA_SMESH::FreeBorders, + public virtual Predicate_i +{ +public: + FreeBorders_i(); + void SetMesh( SMESH_Mesh_ptr theMesh ); + CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); + virtual int GetType() const; + +protected: + SMESHDS_Mesh* myMesh; +}; + +/* + Class : Comparator_i + Description : Base class for comparators +*/ + +class Comparator_i: public virtual POA_SMESH::Comparator, + public virtual Predicate_i +{ +public: + Comparator_i(); + virtual ~Comparator_i(); + + void SetMesh( SMESH_Mesh_ptr theMesh ); + void SetMargin( CORBA::Double ); + void SetNumFunctor( NumericalFunctor_ptr ); + + virtual int GetType() const; + +protected: + CORBA::Double myMargin; + NumericalFunctor_i* myFunctor; +}; + +/* + Class : LessThan_i + Description : Comparator "<" +*/ + +class LessThan_i: public virtual POA_SMESH::LessThan, + public virtual Comparator_i +{ +public: + CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); +}; + +/* + Class : MoreThan_i + Description : Comparator ">" +*/ +class MoreThan_i: public virtual POA_SMESH::MoreThan, + public virtual Comparator_i +{ +public: + CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); +}; + +/* + Class : EqualTo_i + Description : Comparator "=" +*/ +class EqualTo_i: public virtual POA_SMESH::EqualTo, + public virtual Comparator_i +{ +public: + EqualTo_i(); + + CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); + + void SetTolerance( CORBA::Double ); + +private: + CORBA::Double myToler; +}; + +/* + Class : Logical_i + Description : Base class for logical predicate +*/ + +class Logical_i: public virtual POA_SMESH::Logical, + public virtual Predicate_i + +{ +}; + +/* + Class : LogicalNOT_i + Description : Logical NOT predicate +*/ + +class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT, + public virtual Logical_i +{ +public: + LogicalNOT_i(); + virtual ~LogicalNOT_i(); + + CORBA::Boolean IsSatisfy( CORBA::Long ); + + void SetMesh( SMESH_Mesh_ptr ); + void SetPredicate( Predicate_ptr ); + + virtual int GetType() const; + +private: + Predicate_i* myPredicate; +}; + + +/* + Class : LogicalBinary_i + Description : Base class for binary logical predicate +*/ + +class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary, + public virtual Logical_i +{ +public: + LogicalBinary_i(); + virtual ~LogicalBinary_i(); + + void SetMesh( SMESH_Mesh_ptr ); + + void SetPredicate1( Predicate_ptr ); + void SetPredicate2( Predicate_ptr ); + + virtual int GetType() const; + +protected: + Predicate_i* myPredicate1; + Predicate_i* myPredicate2; +}; + +/* + Class : LogicalAND_i + Description : Logical AND +*/ + +class LogicalAND_i: public virtual POA_SMESH::LogicalAND, + public virtual LogicalBinary_i +{ +public: + CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); +}; + +/* + Class : LogicalOR_i + Description : Logical OR +*/ + +class LogicalOR_i: public virtual POA_SMESH::LogicalOR, + public virtual LogicalBinary_i +{ +public: + CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); +}; + + +/* + FILTER +*/ + +class Filter_i: public virtual POA_SMESH::Filter, + public virtual SALOME::GenericObj_i +{ +public: + Filter_i(); + virtual ~Filter_i(); + void SetPredicate(Predicate_ptr ); + long_array* GetElementsId(SMESH_Mesh_ptr ); + void SetMesh( SMESH_Mesh_ptr ); + +protected: + Predicate_i* myPredicate; +}; + + +/* + FILTER MANAGER +*/ + +class FilterManager_i: public virtual POA_SMESH::FilterManager, + public virtual SALOME::GenericObj_i +{ +public: + FilterManager_i(); + MinimumAngle_ptr CreateMinimumAngle(); + AspectRatio_ptr CreateAspectRatio(); + Warping_ptr CreateWarping(); + Taper_ptr CreateTaper(); + Skew_ptr CreateSkew(); + Area_ptr CreateArea(); + Length_ptr CreateLength(); + MultiConnection_ptr CreateMultiConnection(); + + FreeBorders_ptr CreateFreeBorders(); + + LessThan_ptr CreateLessThan(); + MoreThan_ptr CreateMoreThan(); + EqualTo_ptr CreateEqualTo(); + + LogicalNOT_ptr CreateLogicalNOT(); + LogicalAND_ptr CreateLogicalAND(); + LogicalOR_ptr CreateLogicalOR(); + + Filter_ptr CreateFilter(); +}; + + + +}; + + +#endif diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx new file mode 100644 index 000000000..81a495137 --- /dev/null +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -0,0 +1,358 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESH_Group_i.cxx +// Author : Sergey ANIKIN, OCC +// Module : SMESH +// $Header$ + +#include "SMESH_Group_i.hxx" +#include "SMESH_Mesh_i.hxx" +#include "SMESH_Gen_i.hxx" +#include +#include +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH_Group_i::SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID ) +: SALOME::GenericObj_i( thePOA ), + myMeshServant( theMeshServant ), + myLocalID( theLocalID ) +{ + thePOA->activate_object( this ); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH_Group_i::~SMESH_Group_i() +{ + MESSAGE("~SMESH_Group_i;" ); + if ( myMeshServant ) + myMeshServant->removeGroup(myLocalID); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +void SMESH_Group_i::SetName( const char* theName ) +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + aGroup->SetName(theName); + + // Update group name in a study + SALOMEDS::Study_var aStudy = myMeshServant->GetGen()->GetCurrentStudy(); + if ( !aStudy->_is_nil() ) { + SALOMEDS::SObject_var aGroupSO = aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ); + if ( !aGroupSO->_is_nil() ) { + SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); + aBuilder->SetName( aGroupSO, theName ); + } + } + return; + } + } + MESSAGE("can't set name of a vague group"); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +char* SMESH_Group_i::GetName() +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) + return CORBA::string_dup (aGroup->GetName()); + } + MESSAGE("get name of a vague group"); + return CORBA::string_dup( "NO_NAME" ); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH::ElementType SMESH_Group_i::GetType() +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + SMDSAbs_ElementType aSMDSType = aGroup->GetGroupDS()->GetType(); + SMESH::ElementType aType; + switch (aSMDSType) { + case SMDSAbs_Node: aType = SMESH::NODE; break; + case SMDSAbs_Edge: aType = SMESH::EDGE; break; + case SMDSAbs_Face: aType = SMESH::FACE; break; + case SMDSAbs_Volume: aType = SMESH::VOLUME; break; + default: aType = SMESH::ALL; break; + } + return aType; + } + } + MESSAGE("get type of a vague group"); + return SMESH::ALL; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Long SMESH_Group_i::Size() +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + int aSize = aGroup->GetGroupDS()->Extent(); + return aSize; + } + } + MESSAGE("get size of a vague group"); + return 0; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean SMESH_Group_i::IsEmpty() +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + bool isEmpty = aGroup->GetGroupDS()->IsEmpty(); + return isEmpty; + } + } + MESSAGE("checking IsEmpty of a vague group"); + return true; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +void SMESH_Group_i::Clear() +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + // a SMDS group forgets its type after clearing, so we must re-set it + SMDSAbs_ElementType aSMDSType = aGroup->GetGroupDS()->GetType(); + aGroup->GetGroupDS()->Clear(); + aGroup->GetGroupDS()->SetType(aSMDSType); + return; + } + } + MESSAGE("attempt to clear a vague group"); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean SMESH_Group_i::Contains( CORBA::Long theID ) +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + bool res = aGroup->GetGroupDS()->Contains(theID); + return res; + } + } + MESSAGE("attempt to check contents of a vague group"); + return false; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs ) +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + SMESHDS_Group* aGroupDS = aGroup->GetGroupDS(); + int nbAdd = 0; + for (int i = 0; i < theIDs.length(); i++) { + int anID = (int) theIDs[i]; + if (aGroupDS->Add(anID)) + nbAdd++; + } + return nbAdd; + } + } + MESSAGE("attempt to add elements to a vague group"); + return 0; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Long SMESH_Group_i::GetID( CORBA::Long theIndex ) +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + int anID = aGroup->GetGroupDS()->GetID(theIndex); + return anID; + } + } + MESSAGE("attempt to iterate on a vague group"); + return -1; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESH::long_array* SMESH_Group_i::GetListOfID() +{ + SMESH::long_array_var aRes = new SMESH::long_array(); + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + SMESHDS_Group* aGroupDS = aGroup->GetGroupDS(); + int aSize = aGroupDS->Extent(); + aRes->length(aSize); + for (int i = 0; i < aSize; i++) + aRes[i] = aGroupDS->GetID(i+1); + return aRes._retn(); + } + } + MESSAGE("get list of IDs of a vague group"); + return aRes._retn(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs ) +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); + if (aGroup) { + // a SMDS group forgets its type after clearing, so we must re-set it + // if the group becomes empty + SMDSAbs_ElementType aSMDSType = aGroup->GetGroupDS()->GetType(); + SMESHDS_Group* aGroupDS = aGroup->GetGroupDS(); + int nbDel = 0; + for (int i = 0; i < theIDs.length(); i++) { + int anID = (int) theIDs[i]; + if (aGroupDS->Remove(anID)) + nbDel++; + } + if (aGroupDS->IsEmpty()) + aGroupDS->SetType(aSMDSType); + return nbDel; + } + } + MESSAGE("attempt to remove elements from a vague group"); + return 0; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH::SMESH_Mesh_ptr SMESH_Group_i::GetMesh() +{ + MESSAGE("SMESH_Group_i::GetMesh(): mesh servant = " << myMeshServant ); + SMESH::SMESH_Mesh_var aMesh; + if ( myMeshServant ) + aMesh = SMESH::SMESH_Mesh::_narrow( myMeshServant->_this() ); + return aMesh._retn(); +} + + +//============================================================================= +/*! + * + */ +//============================================================================= +int SMESH_Group_i::GetLocalID() +{ + return myLocalID; +} diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx new file mode 100644 index 000000000..2c7c1d36f --- /dev/null +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -0,0 +1,82 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESH_Group_i.hxx +// Author : Sergey ANIKIN, OCC +// Module : SMESH +// $Header$ + +#ifndef SMESH_Group_i_HeaderFile +#define SMESH_Group_i_HeaderFile + +#include +#include CORBA_SERVER_HEADER(SMESH_Group) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +#include "SALOME_GenericObj_i.hh" + +class SMESH_Mesh_i; + +class SMESH_Group_i: + public virtual POA_SMESH::SMESH_Group, + public virtual SALOME::GenericObj_i +{ +public: + SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID ); + virtual ~SMESH_Group_i(); + + // CORBA interface implementation + void SetName( const char* theName ); + + char* GetName(); + + SMESH::ElementType GetType(); + + CORBA::Long Size(); + + CORBA::Boolean IsEmpty(); + + void Clear(); + + CORBA::Boolean Contains( CORBA::Long theID ); + + CORBA::Long Add( const SMESH::long_array& theIDs ); + + CORBA::Long GetID( CORBA::Long theIndex ); + + SMESH::long_array* GetListOfID(); + + CORBA::Long Remove( const SMESH::long_array& theIDs ); + + SMESH::SMESH_Mesh_ptr GetMesh(); + + // Internal C++ interface + int GetLocalID(); + + SMESH_Mesh_i* GetMeshServant() { return myMeshServant; } + +private: + SMESH_Mesh_i* myMeshServant; + int myLocalID; +}; + +#endif diff --git a/src/SMESH_SWIG/SMESH_controls.py b/src/SMESH_SWIG/SMESH_controls.py new file mode 100644 index 000000000..83c950178 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_controls.py @@ -0,0 +1,227 @@ +# Copyright (C) 2004 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : SMESH_control.py +# Author : Sergey LITONIN +# Module : SMESH + + +import SMESH +import SMESH_mechanic + +smesh = SMESH_mechanic.smesh +mesh = SMESH_mechanic.mesh +salome = SMESH_mechanic.salome + + +aFilterMgr = smesh.CreateFilterManager() + +# Criterion : AREA > 100 + +aFunctor = aFilterMgr.CreateArea() +aPredicate = aFilterMgr.CreateMoreThan() +aPredicate.SetNumFunctor( aFunctor ) +aPredicate.SetMargin( 100 ) + +aFilter = aFilterMgr.CreateFilter() +aFilter.SetPredicate( aPredicate ) + +anIds = aFilter.GetElementsId( mesh ) + +# print result +print "Criterion: Area > 100 Nb = ", len( anIds ) +#for i in range( len( anIds ) ): + #print anIds[ i ] + +# create group +aGroup = mesh.CreateGroup( SMESH.FACE, "Area > 100" ) +aGroup.Add( anIds ) + + +# Criterion : Taper > 3e-15 + +aFunctor = aFilterMgr.CreateTaper() +aPredicate = aFilterMgr.CreateMoreThan() +aPredicate.SetNumFunctor( aFunctor ) +aPredicate.SetMargin( 3e-15 ) + +aFilter = aFilterMgr.CreateFilter() +aFilter.SetPredicate( aPredicate ) + +anIds = aFilter.GetElementsId( mesh ) + +# print result +print "Criterion: Taper > 3e-15 Nb = ", len( anIds ) +#for i in range( len( anIds ) ): + #print anIds[ i ] + +# create group +aGroup = mesh.CreateGroup( SMESH.FACE, "Taper > 3e-15" ) +aGroup.Add( anIds ) + + +# Criterion : ASPECT RATIO > 1.3 + +aFunctor = aFilterMgr.CreateAspectRatio() +aPredicate = aFilterMgr.CreateMoreThan() +aPredicate.SetNumFunctor( aFunctor ) +aPredicate.SetMargin( 1.3 ) + +aFilter = aFilterMgr.CreateFilter() +aFilter.SetPredicate( aPredicate ) + +anIds = aFilter.GetElementsId( mesh ) + +# print result +print "Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds ) +#for i in range( len( anIds ) ): + #print anIds[ i ] + +# create group +aGroup = mesh.CreateGroup( SMESH.FACE, "Aspect Ratio > 1.3" ) +aGroup.Add( anIds ) + + +# Criterion : MINIMUM ANGLE < 30 + +aFunctor = aFilterMgr.CreateMinimumAngle() +aPredicate = aFilterMgr.CreateLessThan() +aPredicate.SetNumFunctor( aFunctor ) +aPredicate.SetMargin( 30 ) + +aFilter = aFilterMgr.CreateFilter() +aFilter.SetPredicate( aPredicate ) + +anIds = aFilter.GetElementsId( mesh ) + +# print result +print "Criterion: Minimum Angle < 30 Nb = ", len( anIds ) +#for i in range( len( anIds ) ): + #print anIds[ i ] + +# create group +aGroup = mesh.CreateGroup( SMESH.FACE, "Minimum Angle < 30" ) +aGroup.Add( anIds ) + +# Criterion : Warp > 2e-13 + +aFunctor = aFilterMgr.CreateWarping() +aPredicate = aFilterMgr.CreateMoreThan() +aPredicate.SetNumFunctor( aFunctor ) +aPredicate.SetMargin( 2e-13 ) + +aFilter = aFilterMgr.CreateFilter() +aFilter.SetPredicate( aPredicate ) + +anIds = aFilter.GetElementsId( mesh ) + +# print result +print "Criterion: Warp > 2e-13 Nb = ", len( anIds ) +#for i in range( len( anIds ) ): + #print anIds[ i ] + +# create group +aGroup = mesh.CreateGroup( SMESH.FACE, "Warp > 2e-13" ) +aGroup.Add( anIds ) + +# Criterion : Skew > 18 + +aFunctor = aFilterMgr.CreateSkew() +aPredicate = aFilterMgr.CreateMoreThan() +aPredicate.SetNumFunctor( aFunctor ) +aPredicate.SetMargin( 18 ) + +aFilter = aFilterMgr.CreateFilter() +aFilter.SetPredicate( aPredicate ) + +anIds = aFilter.GetElementsId( mesh ) + +# print result +print "Criterion: Skew > 18 Nb = ", len( anIds ) +#for i in range( len( anIds ) ): + #print anIds[ i ] + +# create group +aGroup = mesh.CreateGroup( SMESH.FACE, "Skew > 18" ) +aGroup.Add( anIds ) + +# Criterion : Length > 10 + +aFunctor = aFilterMgr.CreateLength() +aPredicate = aFilterMgr.CreateMoreThan() +aPredicate.SetNumFunctor( aFunctor ) +aPredicate.SetMargin( 10 ) + +aFilter = aFilterMgr.CreateFilter() +aFilter.SetPredicate( aPredicate ) + +anIds = aFilter.GetElementsId( mesh ) + +# print result +print "Criterion: Length > 10 Nb = ", len( anIds ) +#for i in range( len( anIds ) ): + #print anIds[ i ] + +# create group +aGroup = mesh.CreateGroup( SMESH.EDGE, "Length > 10" ) +aGroup.Add( anIds ) + +# Criterion : Borders at multi-connections = 2 + +aFunctor = aFilterMgr.CreateMultiConnection() +aPredicate = aFilterMgr.CreateEqualTo() +aPredicate.SetNumFunctor( aFunctor ) +aPredicate.SetMargin( 2 ) + +aFilter = aFilterMgr.CreateFilter() +aFilter.SetPredicate( aPredicate ) + +anIds = aFilter.GetElementsId( mesh ) + +# print result +print "Criterion: Borders at multi-connections = 2 Nb = ", len( anIds ) +#for i in range( len( anIds ) ): + #print anIds[ i ] + +# create group +aGroup = mesh.CreateGroup( SMESH.EDGE, "Borders at multi-connections = 2" ) +aGroup.Add( anIds ) + + +salome.sg.updateObjBrowser(1) + + + + + + + + + + + + + + + + + + diff --git a/src/SMESH_SWIG/SMESH_freebord.py b/src/SMESH_SWIG/SMESH_freebord.py new file mode 100644 index 000000000..d24e34070 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_freebord.py @@ -0,0 +1,78 @@ +import salome +from geompy import gg +import geompy +import SMESH + +import StdMeshers + +ShapeTypeCompSolid = 1 +ShapeTypeSolid = 2 +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeWire = 5 +ShapeTypeEdge = 6 +ShapeTypeVertex = 7 + +geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") + +geom.GetCurrentStudy(salome.myStudy._get_StudyId()) +smesh.SetCurrentStudy(salome.myStudy) + +# Create box without one plane + +box = geompy.MakeBox(0., 0., 0., 10., 20., 30.) +subShapeList = geompy.SubShapeAll(box,ShapeTypeFace) + +FaceList = [] +for i in range( 5 ): + FaceList.append( subShapeList[ i ]._get_Name() ) + +aBox = geompy.MakeSewing( FaceList, 1. ) +idbox = geompy.addToStudy( aBox, "box" ) + +aBox = salome.IDToObject( idbox ) + +# Create mesh + +hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hyp1.SetNumberOfSegments(5) +hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") +hyp2.SetMaxElementArea(20) +hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") +hyp3.SetMaxElementArea(50) + +algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") + +mesh = smesh.CreateMesh(aBox) +mesh.AddHypothesis(aBox,hyp1) +mesh.AddHypothesis(aBox,hyp2) +mesh.AddHypothesis(aBox,algo1) +mesh.AddHypothesis(aBox,algo2) + +smesh.Compute(mesh,aBox) + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId); +smeshgui.SetName( salome.ObjectToID( mesh ), "Mesh_freebord" ); + +# Criterion : Free edges +aFilterMgr = smesh.CreateFilterManager() +aPredicate = aFilterMgr.CreateFreeBorders() +aFilter = aFilterMgr.CreateFilter() +aFilter.SetPredicate( aPredicate ) + +anIds = aFilter.GetElementsId( mesh ) + +# print result +print "Criterion: Free edges Nb = ", len( anIds ) +for i in range( len( anIds ) ): + print anIds[ i ] + +# create group +aGroup = mesh.CreateGroup( SMESH.EDGE, "Free edges" ) +aGroup.Add( anIds ) + + +salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_test4.py b/src/SMESH_SWIG/SMESH_test4.py new file mode 100755 index 000000000..3a48db694 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_test4.py @@ -0,0 +1,65 @@ +import salome +from geompy import gg +import geompy +import SMESH + +import StdMeshers + +ShapeTypeCompSolid = 1 +ShapeTypeSolid = 2 +ShapeTypeShell = 3 +ShapeTypeFace = 4 +ShapeTypeWire = 5 +ShapeTypeEdge = 6 +ShapeTypeVertex = 7 + +geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") + +geom.GetCurrentStudy(salome.myStudy._get_StudyId()) +smesh.SetCurrentStudy(salome.myStudy) + +box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) +idbox = geompy.addToStudy(box,"box") + +subShapeList = geompy.SubShapeAll(box,ShapeTypeFace) +face = subShapeList[0] +name = geompy.SubShapeName( face._get_Name(), box._get_Name() ) +idface = geompy.addToStudyInFather(box,face,name) + +box = salome.IDToObject(idbox) +face = salome.IDToObject(idface) + +hyp1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hyp1.SetNumberOfSegments(10) +hyp2 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") +hyp2.SetMaxElementArea(10) +hyp3 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") +hyp3.SetMaxElementArea(100) + +algo1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +algo2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") + +mesh = smesh.CreateMesh(box) +mesh.AddHypothesis(box,hyp1) +mesh.AddHypothesis(box,hyp2) +mesh.AddHypothesis(box,algo1) +mesh.AddHypothesis(box,algo2) + +submesh = mesh.GetSubMesh(face, "SubMeshFace") +mesh.AddHypothesis(face,hyp1) +mesh.AddHypothesis(face,hyp3) +mesh.AddHypothesis(face,algo1) +mesh.AddHypothesis(face,algo2) + +smesh.Compute(mesh,box) + +faces = submesh.GetElementsByType(SMESH.FACE) +if len(faces) > 1: + print len(faces), len(faces)/2 + group1 = mesh.CreateGroup(SMESH.FACE,"Group of faces") + group2 = mesh.CreateGroup(SMESH.FACE,"Another group of faces") + group1.Add(faces[:int(len(faces)/2)]) + group2.Add(faces[int(len(faces)/2):]) + +salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_test5.py b/src/SMESH_SWIG/SMESH_test5.py new file mode 100644 index 000000000..301917ddd --- /dev/null +++ b/src/SMESH_SWIG/SMESH_test5.py @@ -0,0 +1,79 @@ +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : SMESH_test1.py +# Module : SMESH + +import salome +import SMESH +import SALOMEDS +import CORBA +import os +import os.path + +def SetSObjName(theSObj,theName) : + ok, anAttr = theSObj.FindAttribute("AttributeName") + if ok: + aName = anAttr._narrow(SALOMEDS.AttributeName) + #print aName.__dict__ + aName.SetValue(theName) + +def ConvertMED2UNV(thePath,theFile) : + anInitFileName = thePath + theFile + aMeshes,aResult = smesh.CreateMeshesFromMED(anInitFileName) + print aResult, aMeshes + + for iMesh in range(len(aMeshes)) : + aMesh = aMeshes[iMesh] + anSObj = salome.ObjectToSObject(aMesh) + print anSObj.GetName(), + aFileName = anInitFileName + aFileName = os.path.basename(aFileName) + SetSObjName(anSObj,aFileName) + print anSObj.GetName() + + aFileName = thePath + theFile + "." + str(iMesh) + ".unv" + aMesh.ExportUNV(aFileName) + aMesh = smesh.CreateMeshesFromUNV(aFileName) + anSObj = salome.ObjectToSObject(aMesh) + print anSObj.GetName(), + os.remove(aFileName) + aFileName = os.path.basename(aFileName) + SetSObjName(anSObj,aFileName) + print anSObj.GetName() + +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") +smesh.SetCurrentStudy(salome.myStudy) + +aPath = os.getenv('KERNEL_ROOT_DIR') + '/examples/' +aListDir = os.listdir(aPath) +print aListDir + +for iFile in range(len(aListDir)) : + aFileName = aListDir[iFile]; + aName,anExt = os.path.splitext(aFileName) + if anExt == ".med" : + aFileName = os.path.basename(aFileName) + print aFileName + ConvertMED2UNV(aPath,aFileName) + #break + +salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/batchmode_mefisto.py b/src/SMESH_SWIG/batchmode_mefisto.py new file mode 100644 index 000000000..6fa30717e --- /dev/null +++ b/src/SMESH_SWIG/batchmode_mefisto.py @@ -0,0 +1,150 @@ +import os +import re + +import batchmode_salome +import batchmode_geompy +import batchmode_smesh + +geom = batchmode_geompy.geom +smesh = batchmode_smesh.smesh + +geom.GetCurrentStudy(batchmode_salome.myStudyId) +smesh.SetCurrentStudy(batchmode_salome.myStudy) + +ShapeType = batchmode_smesh.ShapeType + +import StdMeshers + +def CreateMesh (theFileName, area, len = None, nbseg = None): + + if not(os.path.isfile(theFileName)) or re.search("\.brep$", theFileName) is None : + print "Incorrect file name !" + return + + if (len is None) and (nbseg is None): + print "Define length or number of segments !" + return + + if (len is not None) and (nbseg is not None): + print "Only one Hypothesis (from length and number of segments) can be defined !" + return + + + # ---- Import shape from BREP file and add it to the study + shape_mesh = geom.ImportBREP(theFileName) + Id_shape = batchmode_geompy.addToStudy( shape_mesh, "shape_mesh") + + + + # ---- SMESH + + # ---- create Hypothesis + + print "-------------------------- create Hypothesis" + if (len is not None): + print "-------------------------- LocalLength" + hypLength1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so") + hypLength1.SetLength(len) + print "Hypothesis type: ", hypLength1.GetName() + print "Hypothesis ID: ", hypLength1.GetId() + print "Hypothesis Value: ", hypLength1.GetLength() + + if (nbseg is not None): + print "-------------------------- NumberOfSegments" + hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") + hypNbSeg1.SetNumberOfSegments(nbseg) + print "Hypothesis type: ", hypNbSeg1.GetName() + print "Hypothesis ID: ", hypNbSeg1.GetId() + print "Hypothesis Value: ", hypNbSeg1.GetNumberOfSegments() + + + if (area == "LengthFromEdges"): + print "-------------------------- LengthFromEdges" + hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so") + hypLengthFromEdges.SetMode(1) + print "Hypothesis type: ", hypLengthFromEdges.GetName() + print "Hypothesis ID: ", hypLengthFromEdges.GetId() + print "LengthFromEdges Mode: ", hypLengthFromEdges.GetMode() + + else: + print "-------------------------- MaxElementArea" + hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") + hypArea1.SetMaxElementArea(area) + print "Hypothesis type: ", hypArea1.GetName() + print "Hypothesis ID: ", hypArea1.GetId() + print "Hypothesis Value: ", hypArea1.GetMaxElementArea() + + + + print "-------------------------- Regular_1D" + algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") + + listHyp = algoReg.GetCompatibleHypothesis() + for hyp in listHyp: + print hyp + + print "Algo name: ", algoReg.GetName() + print "Algo ID: ", algoReg.GetId() + + print "-------------------------- MEFISTO_2D" + algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") + + listHyp=algoMef.GetCompatibleHypothesis() + for hyp in listHyp: + print hyp + + print "Algo name: ", algoMef.GetName() + print "Algo ID: ", algoMef.GetId() + + + + # ---- add hypothesis to shape + + print "-------------------------- add hypothesis to shape" + mesh = smesh.CreateMesh(shape_mesh) + + ret = mesh.AddHypothesis(shape_mesh, algoReg) + print "Add Regular_1D algo .... ", + print ret + + if (nbseg is not None): + ret=mesh.AddHypothesis(shape_mesh, hypNbSeg1) + print "Add Number Of Segements algo .... ", + print ret + + if (len is not None): + ret=mesh.AddHypothesis(shape_mesh,hypLength1) + print "Add Local Length algo .... ", + print ret + + ret=mesh.AddHypothesis(shape_mesh, algoMef) + print "Add MEFISTO_2D algo....", + print ret + + if (area == "LengthFromEdges"): + ret = mesh.AddHypothesis( shape_mesh, hypLengthFromEdges) # length from edge + print "Add Length From Edges algo .... ", + print ret + else: + ret=mesh.AddHypothesis(shape_mesh, hypArea1) + print "Add Max Triangle Area algo .... ", + print ret + + # ---- compute mesh + + print "-------------------------- compute mesh" + ret=smesh.Compute(mesh,shape_mesh) + print "Compute Mesh .... ", + print ret + log=mesh.GetLog(0); # no erase trace + #for linelog in log: + # print linelog + + print "------------ INFORMATION ABOUT MESH ------------" + + print "Number of nodes: ", mesh.NbNodes() + print "Number of edges: ", mesh.NbEdges() + print "Number of faces: ", mesh.NbFaces() + print "Number of triangles: ", mesh.NbTriangles() + + return mesh diff --git a/src/StdMeshers/Makefile.in b/src/StdMeshers/Makefile.in new file mode 100644 index 000000000..b7d66f8d1 --- /dev/null +++ b/src/StdMeshers/Makefile.in @@ -0,0 +1,81 @@ +# SMESH StdMeshers : implementaion of SMESH idl descriptions +# +# Copyright (C) 2003 CEA +# +# 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.org +# +# +# +# File : Makefile.in +# Author : Julia DOROVSKIKH +# Module : SMESH +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl + + +@COMMENCE@ + +# header files +EXPORT_HEADERS = \ + StdMeshers_LengthFromEdges.hxx \ + StdMeshers_LocalLength.hxx \ + StdMeshers_NumberOfSegments.hxx \ + StdMeshers_MaxElementArea.hxx \ + StdMeshers_MaxElementVolume.hxx \ + StdMeshers_NotConformAllowed.hxx \ + StdMeshers_Regular_1D.hxx \ + StdMeshers_Quadrangle_2D.hxx \ + StdMeshers_MEFISTO_2D.hxx \ + StdMeshers_Hexa_3D.hxx + +EXPORT_PYSCRIPTS = + +# Libraries targets + +LIB = libStdMeshers.la + +LIB_SRC = \ + StdMeshers_LengthFromEdges.cxx \ + StdMeshers_LocalLength.cxx \ + StdMeshers_MaxElementArea.cxx \ + StdMeshers_MaxElementVolume.cxx \ + StdMeshers_NumberOfSegments.cxx \ + StdMeshers_NotConformAllowed.cxx \ + StdMeshers_Regular_1D.cxx \ + StdMeshers_Quadrangle_2D.cxx \ + StdMeshers_MEFISTO_2D.cxx \ + StdMeshers_Hexa_3D.cxx + +LIB_SERVER_IDL = + +LIB_CLIENT_IDL = + +# Executables targets +BIN = +BIN_SRC = + +# additionnal information to compil and link file +CPPFLAGS+= $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +CXXFLAGS+= $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS+= -lSMESHimpl -lMEFISTO2D -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/StdMeshers/StdMeshers_Hexa_3D.cxx b/src/StdMeshers/StdMeshers_Hexa_3D.cxx new file mode 100644 index 000000000..6c631d0db --- /dev/null +++ b/src/StdMeshers/StdMeshers_Hexa_3D.cxx @@ -0,0 +1,1004 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Hexa_3D.cxx +// Moved here from SMESH_Hexa_3D.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Hexa_3D.hxx" +#include "StdMeshers_Quadrangle_2D.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_Mesh.hxx" + +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_FacePosition.hxx" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include "utilities.h" +#include "Utils_ExceptHandlers.hxx" + + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Hexa_3D::StdMeshers_Hexa_3D(int hypId, int studyId, + SMESH_Gen * gen):SMESH_3D_Algo(hypId, studyId, gen) +{ + MESSAGE("StdMeshers_Hexa_3D::StdMeshers_Hexa_3D"); + _name = "Hexa_3D"; +// _shapeType = TopAbs_SOLID; + _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID); // 1 bit /shape type +// MESSAGE("_shapeType octal " << oct << _shapeType); + for (int i = 0; i < 6; i++) + _quads[i] = 0; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D() +{ + MESSAGE("StdMeshers_Hexa_3D::~StdMeshers_Hexa_3D"); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool StdMeshers_Hexa_3D::CheckHypothesis + (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + SMESH_Hypothesis::Hypothesis_Status& aStatus) +{ + MESSAGE("StdMeshers_Hexa_3D::CheckHypothesis"); + + bool isOk = true; + aStatus = SMESH_Hypothesis::HYP_OK; + + // nothing to check + + return isOk; +} + +//============================================================================= +/*! + * Hexahedron mesh on hexaedron like form + * -0. - shape and face mesh verification + * -1. - identify faces and vertices of the "cube" + * -2. - Algorithm from: + * "Application de l'interpolation transfinie à la création de maillages + * C0 ou G1 continus sur des triangles, quadrangles, tetraedres, pentaedres + * et hexaedres déformés." + * Alain PERONNET - 8 janvier 1999 + */ +//============================================================================= + +bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape)throw(SALOME_Exception) +{ + Unexpect aCatch(SalomeException); + MESSAGE("StdMeshers_Hexa_3D::Compute"); + + bool isOk = false; + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); + //const SMESHDS_SubMesh *& subMeshDS = theSubMesh->GetSubMeshDS(); + + // 0. - shape and face mesh verification + // 0.1 - shape must be a solid (or a shell) with 6 faces + MESSAGE("---"); + + vector < SMESH_subMesh * >meshFaces; + for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) + { + SMESH_subMesh *aSubMesh = aMesh.GetSubMeshContaining(exp.Current()); + ASSERT(aSubMesh); + meshFaces.push_back(aSubMesh); + } + if (meshFaces.size() != 6) + { + SCRUTE(meshFaces.size()); + ASSERT(0); + return false; + } + + // 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges) + MESSAGE("---"); + + for (int i = 0; i < 6; i++) + { + TopoDS_Shape aShape = meshFaces[i]->GetSubShape(); + SMESH_Algo *algo = _gen->GetAlgo(aMesh, aShape); + string algoName = algo->GetName(); + if (algoName != "Quadrangle_2D") + { + // *** delete _quads + SCRUTE(algoName); + ASSERT(0); + return false; + } + StdMeshers_Quadrangle_2D *quadAlgo = + dynamic_cast < StdMeshers_Quadrangle_2D * >(algo); + ASSERT(quadAlgo); + try + { + _quads[i] = quadAlgo->CheckAnd2Dcompute(aMesh, aShape); + // *** to delete after usage + } + catch(SALOME_Exception & S_ex) + { + // *** delete _quads + // *** throw exception + ASSERT(0); + } + } + + // 1. - identify faces and vertices of the "cube" + // 1.1 - ancestor maps vertex->edges in the cube + MESSAGE("---"); + + TopTools_IndexedDataMapOfShapeListOfShape MS; + TopExp::MapShapesAndAncestors(aShape, TopAbs_VERTEX, TopAbs_EDGE, MS); + + // 1.2 - first face is choosen as face Y=0 of the unit cube + MESSAGE("---"); + + const TopoDS_Shape & aFace = meshFaces[0]->GetSubShape(); + const TopoDS_Face & F = TopoDS::Face(aFace); + + // 1.3 - identify the 4 vertices of the face Y=0: V000, V100, V101, V001 + MESSAGE("---"); + + int i = 0; + TopoDS_Edge E = _quads[0]->edge[i]; //edge will be Y=0,Z=0 on unit cube + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + TopoDS_Vertex VFirst, VLast; + TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l + bool isForward = + (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0); + + if (isForward) + { + _cube.V000 = VFirst; // will be (0,0,0) on the unit cube + _cube.V100 = VLast; // will be (1,0,0) on the unit cube + } + else + { + _cube.V000 = VLast; + _cube.V100 = VFirst; + } + + i = 1; + E = _quads[0]->edge[i]; + C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + TopExp::Vertices(E, VFirst, VLast); + isForward = (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0); + if (isForward) + _cube.V101 = VLast; // will be (1,0,1) on the unit cube + else + _cube.V101 = VFirst; + + i = 2; + E = _quads[0]->edge[i]; + C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + TopExp::Vertices(E, VFirst, VLast); + isForward = (((l - f) * (_quads[0]->last[i] - _quads[0]->first[i])) > 0); + if (isForward) + _cube.V001 = VLast; // will be (0,0,1) on the unit cube + else + _cube.V001 = VFirst; + + // 1.4 - find edge X=0, Z=0 (ancestor of V000 not in face Y=0) + // - find edge X=1, Z=0 (ancestor of V100 not in face Y=0) + // - find edge X=1, Z=1 (ancestor of V101 not in face Y=0) + // - find edge X=0, Z=1 (ancestor of V001 not in face Y=0) + MESSAGE("---"); + + TopoDS_Edge E_0Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V000, MS); + ASSERT(!E_0Y0.IsNull()); + + TopoDS_Edge E_1Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V100, MS); + ASSERT(!E_1Y0.IsNull()); + + TopoDS_Edge E_1Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V101, MS); + ASSERT(!E_1Y1.IsNull()); + + TopoDS_Edge E_0Y1 = EdgeNotInFace(aMesh, aShape, F, _cube.V001, MS); + ASSERT(!E_0Y1.IsNull()); + + // 1.5 - identify the 4 vertices in face Y=1: V010, V110, V111, V011 + MESSAGE("---"); + + TopExp::Vertices(E_0Y0, VFirst, VLast); + if (VFirst.IsSame(_cube.V000)) + _cube.V010 = VLast; + else + _cube.V010 = VFirst; + + TopExp::Vertices(E_1Y0, VFirst, VLast); + if (VFirst.IsSame(_cube.V100)) + _cube.V110 = VLast; + else + _cube.V110 = VFirst; + + TopExp::Vertices(E_1Y1, VFirst, VLast); + if (VFirst.IsSame(_cube.V101)) + _cube.V111 = VLast; + else + _cube.V111 = VFirst; + + TopExp::Vertices(E_0Y1, VFirst, VLast); + if (VFirst.IsSame(_cube.V001)) + _cube.V011 = VLast; + else + _cube.V011 = VFirst; + + // 1.6 - find remaining faces given 4 vertices + MESSAGE("---"); + + _indY0 = 0; + _cube.quad_Y0 = _quads[_indY0]; + + _indY1 = GetFaceIndex(aMesh, aShape, meshFaces, + _cube.V010, _cube.V011, _cube.V110, _cube.V111); + _cube.quad_Y1 = _quads[_indY1]; + + _indZ0 = GetFaceIndex(aMesh, aShape, meshFaces, + _cube.V000, _cube.V010, _cube.V100, _cube.V110); + _cube.quad_Z0 = _quads[_indZ0]; + + _indZ1 = GetFaceIndex(aMesh, aShape, meshFaces, + _cube.V001, _cube.V011, _cube.V101, _cube.V111); + _cube.quad_Z1 = _quads[_indZ1]; + + _indX0 = GetFaceIndex(aMesh, aShape, meshFaces, + _cube.V000, _cube.V001, _cube.V010, _cube.V011); + _cube.quad_X0 = _quads[_indX0]; + + _indX1 = GetFaceIndex(aMesh, aShape, meshFaces, + _cube.V100, _cube.V101, _cube.V110, _cube.V111); + _cube.quad_X1 = _quads[_indX1]; + + MESSAGE("---"); + + // 1.7 - get convertion coefs from face 2D normalized to 3D normalized + + Conv2DStruct cx0; // for face X=0 + Conv2DStruct cx1; // for face X=1 + Conv2DStruct cy0; + Conv2DStruct cy1; + Conv2DStruct cz0; + Conv2DStruct cz1; + + GetConv2DCoefs(*_cube.quad_X0, meshFaces[_indX0]->GetSubShape(), + _cube.V000, _cube.V010, _cube.V011, _cube.V001, cx0); + GetConv2DCoefs(*_cube.quad_X1, meshFaces[_indX1]->GetSubShape(), + _cube.V100, _cube.V110, _cube.V111, _cube.V101, cx1); + GetConv2DCoefs(*_cube.quad_Y0, meshFaces[_indY0]->GetSubShape(), + _cube.V000, _cube.V100, _cube.V101, _cube.V001, cy0); + GetConv2DCoefs(*_cube.quad_Y1, meshFaces[_indY1]->GetSubShape(), + _cube.V010, _cube.V110, _cube.V111, _cube.V011, cy1); + GetConv2DCoefs(*_cube.quad_Z0, meshFaces[_indZ0]->GetSubShape(), + _cube.V000, _cube.V100, _cube.V110, _cube.V010, cz0); + GetConv2DCoefs(*_cube.quad_Z1, meshFaces[_indZ1]->GetSubShape(), + _cube.V001, _cube.V101, _cube.V111, _cube.V011, cz1); + + // 1.8 - create a 3D structure for normalized values + + MESSAGE("---"); + int nbx = _cube.quad_Y0->nbPts[0]; + int nby = _cube.quad_Y0->nbPts[1]; + int nbz; + if (cx0.a1 != 0) + nbz = _cube.quad_X0->nbPts[1]; + else + nbz = _cube.quad_X0->nbPts[0]; + //SCRUTE(nbx); + //SCRUTE(nby); + //SCRUTE(nbz); + int nbxyz = nbx * nby * nbz; + Point3DStruct *np = new Point3DStruct[nbxyz]; + + // 1.9 - store node indexes of faces + + { + const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX0]->GetSubShape()); + + faceQuadStruct *quad = _cube.quad_X0; + int i = 0; // j = x/face , k = y/face + int nbdown = quad->nbPts[0]; + int nbright = quad->nbPts[1]; + + + SMDS_NodeIteratorPtr itf= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes(); + + while(itf->more()) + { + const SMDS_MeshNode * node = itf->next(); + const SMDS_FacePosition* fpos = + static_cast(node->GetPosition().get()); + double ri = fpos->GetUParameter(); + double rj = fpos->GetVParameter(); + int i1 = int (ri); + int j1 = int (rj); + int ij1 = j1 * nbdown + i1; + quad->uv_grid[ij1].node = node; + } + + for (int i1 = 0; i1 < nbdown; i1++) + for (int j1 = 0; j1 < nbright; j1++) + { + int ij1 = j1 * nbdown + i1; + int j = cx0.ia * i1 + cx0.ib * j1 + cx0.ic; // j = x/face + int k = cx0.ja * i1 + cx0.jb * j1 + cx0.jc; // k = y/face + int ijk = k * nbx * nby + j * nbx + i; + //MESSAGE(" "<uv_grid[ij1].node; + //SCRUTE(np[ijk].nodeId); + } + } + + { + const TopoDS_Face & F = TopoDS::Face(meshFaces[_indX1]->GetSubShape()); + + SMDS_NodeIteratorPtr itf= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes(); + + faceQuadStruct *quad = _cube.quad_X1; + int i = nbx - 1; // j = x/face , k = y/face + int nbdown = quad->nbPts[0]; + int nbright = quad->nbPts[1]; + + while(itf->more()) + { + const SMDS_MeshNode * node = itf->next(); + const SMDS_FacePosition* fpos = + static_cast(node->GetPosition().get()); + double ri = fpos->GetUParameter(); + double rj = fpos->GetVParameter(); + int i1 = int (ri); + int j1 = int (rj); + int ij1 = j1 * nbdown + i1; + quad->uv_grid[ij1].node = node; + } + + for (int i1 = 0; i1 < nbdown; i1++) + for (int j1 = 0; j1 < nbright; j1++) + { + int ij1 = j1 * nbdown + i1; + int j = cx1.ia * i1 + cx1.ib * j1 + cx1.ic; // j = x/face + int k = cx1.ja * i1 + cx1.jb * j1 + cx1.jc; // k = y/face + int ijk = k * nbx * nby + j * nbx + i; + //MESSAGE(" "<uv_grid[ij1].node; + //SCRUTE(np[ijk].nodeId); + } + } + + { + const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY0]->GetSubShape()); + + SMDS_NodeIteratorPtr itf= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes(); + + faceQuadStruct *quad = _cube.quad_Y0; + int j = 0; // i = x/face , k = y/face + int nbdown = quad->nbPts[0]; + int nbright = quad->nbPts[1]; + + while(itf->more()) + { + const SMDS_MeshNode * node = itf->next(); + const SMDS_FacePosition * fpos = + static_cast(node->GetPosition().get()); + double ri = fpos->GetUParameter(); + double rj = fpos->GetVParameter(); + int i1 = int (ri); + int j1 = int (rj); + int ij1 = j1 * nbdown + i1; + quad->uv_grid[ij1].node = node; + } + + for (int i1 = 0; i1 < nbdown; i1++) + for (int j1 = 0; j1 < nbright; j1++) + { + int ij1 = j1 * nbdown + i1; + int i = cy0.ia * i1 + cy0.ib * j1 + cy0.ic; // i = x/face + int k = cy0.ja * i1 + cy0.jb * j1 + cy0.jc; // k = y/face + int ijk = k * nbx * nby + j * nbx + i; + //MESSAGE(" "<uv_grid[ij1].node; + //SCRUTE(np[ijk].nodeId); + } + } + + { + const TopoDS_Face & F = TopoDS::Face(meshFaces[_indY1]->GetSubShape()); + + SMDS_NodeIteratorPtr itf= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes(); + + faceQuadStruct *quad = _cube.quad_Y1; + int j = nby - 1; // i = x/face , k = y/face + int nbdown = quad->nbPts[0]; + int nbright = quad->nbPts[1]; + + while(itf->more()) + { + const SMDS_MeshNode * node = itf->next(); + const SMDS_FacePosition* fpos = + static_cast(node->GetPosition().get()); + double ri = fpos->GetUParameter(); + double rj = fpos->GetVParameter(); + int i1 = int (ri); + int j1 = int (rj); + int ij1 = j1 * nbdown + i1; + quad->uv_grid[ij1].node = node; + } + + for (int i1 = 0; i1 < nbdown; i1++) + for (int j1 = 0; j1 < nbright; j1++) + { + int ij1 = j1 * nbdown + i1; + int i = cy1.ia * i1 + cy1.ib * j1 + cy1.ic; // i = x/face + int k = cy1.ja * i1 + cy1.jb * j1 + cy1.jc; // k = y/face + int ijk = k * nbx * nby + j * nbx + i; + //MESSAGE(" "<uv_grid[ij1].node; + //SCRUTE(np[ijk].nodeId); + } + } + + { + const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ0]->GetSubShape()); + + SMDS_NodeIteratorPtr itf= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes(); + + faceQuadStruct *quad = _cube.quad_Z0; + int k = 0; // i = x/face , j = y/face + int nbdown = quad->nbPts[0]; + int nbright = quad->nbPts[1]; + + while(itf->more()) + { + const SMDS_MeshNode * node = itf->next(); + const SMDS_FacePosition * fpos = + static_cast(node->GetPosition().get()); + double ri = fpos->GetUParameter(); + double rj = fpos->GetVParameter(); + int i1 = int (ri); + int j1 = int (rj); + int ij1 = j1 * nbdown + i1; + quad->uv_grid[ij1].node = node; + } + + for (int i1 = 0; i1 < nbdown; i1++) + for (int j1 = 0; j1 < nbright; j1++) + { + int ij1 = j1 * nbdown + i1; + int i = cz0.ia * i1 + cz0.ib * j1 + cz0.ic; // i = x/face + int j = cz0.ja * i1 + cz0.jb * j1 + cz0.jc; // j = y/face + int ijk = k * nbx * nby + j * nbx + i; + //MESSAGE(" "<uv_grid[ij1].node; + //SCRUTE(np[ijk].nodeId); + } + } + + { + const TopoDS_Face & F = TopoDS::Face(meshFaces[_indZ1]->GetSubShape()); + + SMDS_NodeIteratorPtr itf= aMesh.GetSubMesh(F)->GetSubMeshDS()->GetNodes(); + + faceQuadStruct *quad = _cube.quad_Z1; + int k = nbz - 1; // i = x/face , j = y/face + int nbdown = quad->nbPts[0]; + int nbright = quad->nbPts[1]; + + while(itf->more()) + { + const SMDS_MeshNode * node = itf->next(); + const SMDS_FacePosition* fpos = + static_cast(node->GetPosition().get()); + double ri = fpos->GetUParameter(); + double rj = fpos->GetVParameter(); + int i1 = int (ri); + int j1 = int (rj); + int ij1 = j1 * nbdown + i1; + quad->uv_grid[ij1].node = node; + } + + for (int i1 = 0; i1 < nbdown; i1++) + for (int j1 = 0; j1 < nbright; j1++) + { + int ij1 = j1 * nbdown + i1; + int i = cz1.ia * i1 + cz1.ib * j1 + cz1.ic; // i = x/face + int j = cz1.ja * i1 + cz1.jb * j1 + cz1.jc; // j = y/face + int ijk = k * nbx * nby + j * nbx + i; + //MESSAGE(" "<uv_grid[ij1].node; + //SCRUTE(np[ijk].nodeId); + } + } + + // 2.0 - for each node of the cube: + // - get the 8 points 3D = 8 vertices of the cube + // - get the 12 points 3D on the 12 edges of the cube + // - get the 6 points 3D on the 6 faces with their ID + // - compute the point 3D + // - store the point 3D in SMESHDS, store its ID in 3D structure + + TopoDS_Shell aShell; + TopExp_Explorer exp(aShape, TopAbs_SHELL); + if (exp.More()) + { + aShell = TopoDS::Shell(exp.Current()); + } + else + { + MESSAGE("no shell..."); + ASSERT(0); + } + + Pt3 p000, p001, p010, p011, p100, p101, p110, p111; + Pt3 px00, px01, px10, px11; + Pt3 p0y0, p0y1, p1y0, p1y1; + Pt3 p00z, p01z, p10z, p11z; + Pt3 pxy0, pxy1, px0z, px1z, p0yz, p1yz; + + GetPoint(p000, 0, 0, 0, nbx, nby, nbz, np, meshDS); + GetPoint(p001, 0, 0, nbz - 1, nbx, nby, nbz, np, meshDS); + GetPoint(p010, 0, nby - 1, 0, nbx, nby, nbz, np, meshDS); + GetPoint(p011, 0, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS); + GetPoint(p100, nbx - 1, 0, 0, nbx, nby, nbz, np, meshDS); + GetPoint(p101, nbx - 1, 0, nbz - 1, nbx, nby, nbz, np, meshDS); + GetPoint(p110, nbx - 1, nby - 1, 0, nbx, nby, nbz, np, meshDS); + GetPoint(p111, nbx - 1, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS); + + for (int i = 1; i < nbx - 1; i++) + { + for (int j = 1; j < nby - 1; j++) + { + for (int k = 1; k < nbz - 1; k++) + { + // *** seulement maillage regulier + // 12 points on edges + GetPoint(px00, i, 0, 0, nbx, nby, nbz, np, meshDS); + GetPoint(px01, i, 0, nbz - 1, nbx, nby, nbz, np, meshDS); + GetPoint(px10, i, nby - 1, 0, nbx, nby, nbz, np, meshDS); + GetPoint(px11, i, nby - 1, nbz - 1, nbx, nby, nbz, np, meshDS); + + GetPoint(p0y0, 0, j, 0, nbx, nby, nbz, np, meshDS); + GetPoint(p0y1, 0, j, nbz - 1, nbx, nby, nbz, np, meshDS); + GetPoint(p1y0, nbx - 1, j, 0, nbx, nby, nbz, np, meshDS); + GetPoint(p1y1, nbx - 1, j, nbz - 1, nbx, nby, nbz, np, meshDS); + + GetPoint(p00z, 0, 0, k, nbx, nby, nbz, np, meshDS); + GetPoint(p01z, 0, nby - 1, k, nbx, nby, nbz, np, meshDS); + GetPoint(p10z, nbx - 1, 0, k, nbx, nby, nbz, np, meshDS); + GetPoint(p11z, nbx - 1, nby - 1, k, nbx, nby, nbz, np, meshDS); + + // 12 points on faces + GetPoint(pxy0, i, j, 0, nbx, nby, nbz, np, meshDS); + GetPoint(pxy1, i, j, nbz - 1, nbx, nby, nbz, np, meshDS); + GetPoint(px0z, i, 0, k, nbx, nby, nbz, np, meshDS); + GetPoint(px1z, i, nby - 1, k, nbx, nby, nbz, np, meshDS); + GetPoint(p0yz, 0, j, k, nbx, nby, nbz, np, meshDS); + GetPoint(p1yz, nbx - 1, j, k, nbx, nby, nbz, np, meshDS); + + int ijk = k * nbx * nby + j * nbx + i; + double x = double (i) / double (nbx - 1); // *** seulement + double y = double (j) / double (nby - 1); // *** maillage + double z = double (k) / double (nbz - 1); // *** regulier + + Pt3 X; + for (int i = 0; i < 3; i++) + { + X[i] = + (1 - x) * p0yz[i] + x * p1yz[i] + + (1 - y) * px0z[i] + y * px1z[i] + + (1 - z) * pxy0[i] + z * pxy1[i] + - (1 - x) * ((1 - y) * p00z[i] + y * p01z[i]) + - x * ((1 - y) * p10z[i] + y * p11z[i]) + - (1 - y) * ((1 - z) * px00[i] + z * px01[i]) + - y * ((1 - z) * px10[i] + z * px11[i]) + - (1 - z) * ((1 - x) * p0y0[i] + x * p1y0[i]) + - z * ((1 - x) * p0y1[i] + x * p1y1[i]) + + (1 - x) * ((1 - y) * ((1 - z) * p000[i] + z * p001[i]) + + y * ((1 - z) * p010[i] + z * p011[i])) + + x * ((1 - y) * ((1 - z) * p100[i] + z * p101[i]) + + y * ((1 - z) * p110[i] + z * p111[i])); + } + + SMDS_MeshNode * node = meshDS->AddNode(X[0], X[1], X[2]); + np[ijk].node = node; + //meshDS->SetNodeInVolume(node, TopoDS::Solid(aShape)); + meshDS->SetNodeInVolume(node, aShell); + } + } + } + + //2.1 - for each node of the cube (less 3 *1 Faces): + // - store hexahedron in SMESHDS + MESSAGE("Storing hexahedron into the DS"); + for (int i = 0; i < nbx - 1; i++) + for (int j = 0; j < nby - 1; j++) + for (int k = 0; k < nbz - 1; k++) + { + int n1 = k * nbx * nby + j * nbx + i; + int n2 = k * nbx * nby + j * nbx + i + 1; + int n3 = k * nbx * nby + (j + 1) * nbx + i + 1; + int n4 = k * nbx * nby + (j + 1) * nbx + i; + int n5 = (k + 1) * nbx * nby + j * nbx + i; + int n6 = (k + 1) * nbx * nby + j * nbx + i + 1; + int n7 = (k + 1) * nbx * nby + (j + 1) * nbx + i + 1; + int n8 = (k + 1) * nbx * nby + (j + 1) * nbx + i; + +// MESSAGE(" "<AddVolume(np[n1].node, + np[n2].node, + np[n3].node, + np[n4].node, + np[n5].node, + np[n6].node, + np[n7].node, + np[n8].node); + ; + meshDS->SetMeshElementOnShape(elt, aShell); + + // *** 5 tetrahedres ... verifier orientations, + // mettre en coherence &vec quadrangles-> triangles + // choisir afficher 1 parmi edges, face et volumes +// int tetra1 = meshDS->AddVolume(np[n1].nodeId, +// np[n2].nodeId, +// np[n4].nodeId, +// np[n5].nodeId); +// int tetra2 = meshDS->AddVolume(np[n2].nodeId, +// np[n3].nodeId, +// np[n4].nodeId, +// np[n7].nodeId); +// int tetra3 = meshDS->AddVolume(np[n5].nodeId, +// np[n6].nodeId, +// np[n7].nodeId, +// np[n2].nodeId); +// int tetra4 = meshDS->AddVolume(np[n5].nodeId, +// np[n7].nodeId, +// np[n8].nodeId, +// np[n4].nodeId); +// int tetra5 = meshDS->AddVolume(np[n5].nodeId, +// np[n7].nodeId, +// np[n2].nodeId, +// np[n4].nodeId); + + } + + MESSAGE("End of StdMeshers_Hexa_3D::Compute()"); + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_Hexa_3D::GetPoint(Pt3 p, int i, int j, int k, int nbx, int nby, + int nbz, Point3DStruct * np, const SMESHDS_Mesh * meshDS) +{ + int ijk = k * nbx * nby + j * nbx + i; + const SMDS_MeshNode * node = np[ijk].node; + p[0] = node->X(); + p[1] = node->Y(); + p[2] = node->Z(); + //MESSAGE(" "<&meshFaces, + const TopoDS_Vertex & V0, + const TopoDS_Vertex & V1, + const TopoDS_Vertex & V2, const TopoDS_Vertex & V3) +{ + MESSAGE("StdMeshers_Hexa_3D::GetFaceIndex"); + int faceIndex = -1; + for (int i = 1; i < 6; i++) + { + const TopoDS_Shape & aFace = meshFaces[i]->GetSubShape(); + //const TopoDS_Face& F = TopoDS::Face(aFace); + TopTools_IndexedMapOfShape M; + TopExp::MapShapes(aFace, TopAbs_VERTEX, M); + bool verticesInShape = false; + if (M.Contains(V0)) + if (M.Contains(V1)) + if (M.Contains(V2)) + if (M.Contains(V3)) + verticesInShape = true; + if (verticesInShape) + { + faceIndex = i; + break; + } + } + ASSERT(faceIndex > 0); + SCRUTE(faceIndex); + return faceIndex; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +TopoDS_Edge + StdMeshers_Hexa_3D::EdgeNotInFace(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape, + const TopoDS_Face & aFace, + const TopoDS_Vertex & aVertex, + const TopTools_IndexedDataMapOfShapeListOfShape & MS) +{ + MESSAGE("StdMeshers_Hexa_3D::EdgeNotInFace"); + TopTools_IndexedDataMapOfShapeListOfShape MF; + TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, MF); + const TopTools_ListOfShape & ancestorsInSolid = MS.FindFromKey(aVertex); + const TopTools_ListOfShape & ancestorsInFace = MF.FindFromKey(aVertex); + SCRUTE(ancestorsInSolid.Extent()); + SCRUTE(ancestorsInFace.Extent()); + ASSERT(ancestorsInSolid.Extent() == 6); // 6 (edges doublees) + ASSERT(ancestorsInFace.Extent() == 2); + + TopoDS_Edge E; + E.Nullify(); + TopTools_ListIteratorOfListOfShape its(ancestorsInSolid); + for (; its.More(); its.Next()) + { + TopoDS_Shape ancestor = its.Value(); + TopTools_ListIteratorOfListOfShape itf(ancestorsInFace); + bool isInFace = false; + for (; itf.More(); itf.Next()) + { + TopoDS_Shape ancestorInFace = itf.Value(); + if (ancestorInFace.IsSame(ancestor)) + { + isInFace = true; + break; + } + } + if (!isInFace) + { + E = TopoDS::Edge(ancestor); + break; + } + } + return E; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad, + const TopoDS_Shape & aShape, + const TopoDS_Vertex & V0, + const TopoDS_Vertex & V1, + const TopoDS_Vertex & V2, const TopoDS_Vertex & V3, Conv2DStruct & conv) +{ + MESSAGE("StdMeshers_Hexa_3D::GetConv2DCoefs"); + const TopoDS_Face & F = TopoDS::Face(aShape); + TopoDS_Edge E = quad.edge[0]; + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + TopoDS_Vertex VFirst, VLast; + TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l + bool isForward = (((l - f) * (quad.last[0] - quad.first[0])) > 0); + TopoDS_Vertex VA, VB; + if (isForward) + { + VA = VFirst; + VB = VLast; + } + else + { + VA = VLast; + VB = VFirst; + } + int a1, b1, c1, a2, b2, c2; + if (VA.IsSame(V0)) + if (VB.IsSame(V1)) + { + a1 = 1; + b1 = 0; + c1 = 0; // x + a2 = 0; + b2 = 1; + c2 = 0; // y + } + else + { + ASSERT(VB.IsSame(V3)); + a1 = 0; + b1 = 1; + c1 = 0; // y + a2 = 1; + b2 = 0; + c2 = 0; // x + } + if (VA.IsSame(V1)) + if (VB.IsSame(V2)) + { + a1 = 0; + b1 = -1; + c1 = 1; // 1-y + a2 = 1; + b2 = 0; + c2 = 0; // x + } + else + { + ASSERT(VB.IsSame(V0)); + a1 = -1; + b1 = 0; + c1 = 1; // 1-x + a2 = 0; + b2 = 1; + c2 = 0; // y + } + if (VA.IsSame(V2)) + if (VB.IsSame(V3)) + { + a1 = -1; + b1 = 0; + c1 = 1; // 1-x + a2 = 0; + b2 = -1; + c2 = 1; // 1-y + } + else + { + ASSERT(VB.IsSame(V1)); + a1 = 0; + b1 = -1; + c1 = 1; // 1-y + a2 = -1; + b2 = 0; + c2 = 1; // 1-x + } + if (VA.IsSame(V3)) + if (VB.IsSame(V0)) + { + a1 = 0; + b1 = 1; + c1 = 0; // y + a2 = -1; + b2 = 0; + c2 = 1; // 1-x + } + else + { + ASSERT(VB.IsSame(V2)); + a1 = 1; + b1 = 0; + c1 = 0; // x + a2 = 0; + b2 = -1; + c2 = 1; // 1-y + } + MESSAGE("X = " << c1 << "+ " << a1 << "*x + " << b1 << "*y"); + MESSAGE("Y = " << c2 << "+ " << a2 << "*x + " << b2 << "*y"); + conv.a1 = a1; + conv.b1 = b1; + conv.c1 = c1; + conv.a2 = a2; + conv.b2 = b2; + conv.c2 = c2; + + int nbdown = quad.nbPts[0]; + int nbright = quad.nbPts[1]; + conv.ia = int (a1); + conv.ib = int (b1); + conv.ic = + int (c1 * a1 * a1) * (nbdown - 1) + int (c1 * b1 * b1) * (nbright - 1); + conv.ja = int (a2); + conv.jb = int (b2); + conv.jc = + int (c2 * a2 * a2) * (nbdown - 1) + int (c2 * b2 * b2) * (nbright - 1); + MESSAGE("I " << conv.ia << " " << conv.ib << " " << conv.ic); + MESSAGE("J " << conv.ja << " " << conv.jb << " " << conv.jc); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_Hexa_3D::SaveTo(ostream & save) +{ + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_Hexa_3D::LoadFrom(istream & load) +{ + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_Hexa_3D & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_Hexa_3D & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/StdMeshers/StdMeshers_Hexa_3D.hxx b/src/StdMeshers/StdMeshers_Hexa_3D.hxx new file mode 100644 index 000000000..a9e20459c --- /dev/null +++ b/src/StdMeshers/StdMeshers_Hexa_3D.hxx @@ -0,0 +1,140 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Hexa_3D.hxx +// Moved here from SMESH_Hexa_3D.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_HEXA_3D_HXX_ +#define _SMESH_HEXA_3D_HXX_ + +#include "SMESH_3D_Algo.hxx" +#include "SMESH_Mesh.hxx" +#include "StdMeshers_Quadrangle_2D.hxx" +#include "Utils_SALOME_Exception.hxx" + +typedef struct point3Dstruct +{ + const SMDS_MeshNode * node; +} Point3DStruct; + +typedef double Pt3[3]; + +typedef struct conv2dstruct +{ + double a1; // X = a1*x + b1*y + c1 + double b1; // Y = a2*x + b2*y + c2 + double c1; // a1, b1 a2, b2 in {-1,0,1} + double a2; // c1, c2 in {0,1} + double b2; + double c2; + int ia; // I = ia*i + ib*j + ic + int ib; + int ic; + int ja; // J = ja*i + jb*j + jc + int jb; + int jc; +} Conv2DStruct; + +typedef struct cubeStruct +{ + TopoDS_Vertex V000; + TopoDS_Vertex V001; + TopoDS_Vertex V010; + TopoDS_Vertex V011; + TopoDS_Vertex V100; + TopoDS_Vertex V101; + TopoDS_Vertex V110; + TopoDS_Vertex V111; + faceQuadStruct* quad_X0; + faceQuadStruct* quad_X1; + faceQuadStruct* quad_Y0; + faceQuadStruct* quad_Y1; + faceQuadStruct* quad_Z0; + faceQuadStruct* quad_Z1; + Point3DStruct* np; // normalised 3D coordinates +} CubeStruct; + +class StdMeshers_Hexa_3D: + public SMESH_3D_Algo +{ +public: + StdMeshers_Hexa_3D(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_Hexa_3D(); + + 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) + throw (SALOME_Exception); + + ostream & SaveTo(ostream & save); + istream & LoadFrom(istream & load); + friend ostream & operator << (ostream & save, StdMeshers_Hexa_3D & hyp); + friend istream & operator >> (istream & load, StdMeshers_Hexa_3D & hyp); + +protected: + TopoDS_Edge + EdgeNotInFace(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + const TopoDS_Face& aFace, + const TopoDS_Vertex& aVertex, + const TopTools_IndexedDataMapOfShapeListOfShape& MS); + + int GetFaceIndex(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + const vector& meshFaces, + const TopoDS_Vertex& V0, + const TopoDS_Vertex& V1, + const TopoDS_Vertex& V2, + const TopoDS_Vertex& V3); + + void GetConv2DCoefs(const faceQuadStruct& quad, + const TopoDS_Shape& aShape, + const TopoDS_Vertex& V0, + const TopoDS_Vertex& V1, + const TopoDS_Vertex& V2, + const TopoDS_Vertex& V3, + Conv2DStruct& conv); + + void GetPoint(Pt3 p, + int i, int j, int k, + int nbx, int nby, int nbz, + Point3DStruct *np, + const SMESHDS_Mesh* meshDS); + + CubeStruct _cube; + FaceQuadStruct* _quads[6]; + int _indX0; + int _indX1; + int _indY0; + int _indY1; + int _indZ0; + int _indZ1; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_LengthFromEdges.cxx b/src/StdMeshers/StdMeshers_LengthFromEdges.cxx new file mode 100644 index 000000000..f21f199f5 --- /dev/null +++ b/src/StdMeshers/StdMeshers_LengthFromEdges.cxx @@ -0,0 +1,139 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_LengthFromEdges.cxx +// Moved here from SMESH_LengthFromEdges.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_LengthFromEdges.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_LengthFromEdges::StdMeshers_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_Hypothesis(hypId, studyId, gen) +{ + _mode =1; + _name = "LengthFromEdges"; +// SCRUTE(_name); +// SCRUTE(&_name); + _param_algo_dim = 2; // is used by SMESH_MEFISTO_2D +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_LengthFromEdges::~StdMeshers_LengthFromEdges() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_LengthFromEdges::SetMode(int mode) + throw (SALOME_Exception) +{ + int oldMode = _mode; + if (mode <= 0) + throw SALOME_Exception(LOCALIZED("mode must be positive")); + _mode = mode; + if (oldMode != _mode) + NotifySubMeshesHypothesisModification(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +int StdMeshers_LengthFromEdges::GetMode() +{ + return _mode; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_LengthFromEdges::SaveTo(ostream & save) +{ + save << this->_mode; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_LengthFromEdges::LoadFrom(istream & load) +{ + bool isOK = true; + int a; + isOK = (load >> a); + if (isOK) + this->_mode = a; + else + load.clear(ios::badbit | load.rdstate()); + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator << (ostream & save, StdMeshers_LengthFromEdges & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >> (istream & load, StdMeshers_LengthFromEdges & hyp) +{ + return hyp.LoadFrom( load ); +} + diff --git a/src/StdMeshers/StdMeshers_LengthFromEdges.hxx b/src/StdMeshers/StdMeshers_LengthFromEdges.hxx new file mode 100644 index 000000000..d514e7c94 --- /dev/null +++ b/src/StdMeshers/StdMeshers_LengthFromEdges.hxx @@ -0,0 +1,57 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_LengthFromEdges.hxx +// Moved here from SMESH_LengthFromEdges.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_LENGTHFROMEDGES_HXX_ +#define _SMESH_LENGTHFROMEDGES_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class StdMeshers_LengthFromEdges: + public SMESH_Hypothesis +{ +public: + StdMeshers_LengthFromEdges(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_LengthFromEdges(); + + void SetMode(int mode) + throw (SALOME_Exception); + + int GetMode(); + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream & operator << (ostream & save, StdMeshers_LengthFromEdges & hyp); + friend istream & operator >> (istream & load, StdMeshers_LengthFromEdges & hyp); + +protected: + int _mode; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_LocalLength.cxx b/src/StdMeshers/StdMeshers_LocalLength.cxx new file mode 100644 index 000000000..457d8d80c --- /dev/null +++ b/src/StdMeshers/StdMeshers_LocalLength.cxx @@ -0,0 +1,137 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_LocalLength.cxx +// Moved here from SMESH_LocalLength.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_LocalLength.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_LocalLength::StdMeshers_LocalLength(int hypId, int studyId, + SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen) +{ + _length = 1.; + _name = "LocalLength"; +// SCRUTE(_name); +// SCRUTE(&_name); + _param_algo_dim = 1; // is used by SMESH_Regular_1D +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_LocalLength::~StdMeshers_LocalLength() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_LocalLength::SetLength(double length) throw(SALOME_Exception) +{ + double oldLength = _length; + if (length <= 0) + throw SALOME_Exception(LOCALIZED("length must be positive")); + _length = length; + if (oldLength != _length) + NotifySubMeshesHypothesisModification(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_LocalLength::GetLength() const +{ + return _length; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_LocalLength::SaveTo(ostream & save) +{ + save << this->_length; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_LocalLength::LoadFrom(istream & load) +{ + bool isOK = true; + double a; + isOK = (load >> a); + if (isOK) + this->_length = a; + else + load.clear(ios::badbit | load.rdstate()); + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_LocalLength & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_LocalLength & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/StdMeshers/StdMeshers_LocalLength.hxx b/src/StdMeshers/StdMeshers_LocalLength.hxx new file mode 100644 index 000000000..aba58e51a --- /dev/null +++ b/src/StdMeshers/StdMeshers_LocalLength.hxx @@ -0,0 +1,55 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_LocalLength.hxx +// Moved here from SMESH_LocalLength.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_LOCALLENGTH_HXX_ +#define _SMESH_LOCALLENGTH_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class StdMeshers_LocalLength:public SMESH_Hypothesis +{ + public: + StdMeshers_LocalLength(int hypId, int studyId, SMESH_Gen * gen); + virtual ~ StdMeshers_LocalLength(); + + void SetLength(double length) throw(SALOME_Exception); + + double GetLength() const; + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream & operator <<(ostream & save, StdMeshers_LocalLength & hyp); + friend istream & operator >>(istream & load, StdMeshers_LocalLength & hyp); + + protected: + double _length; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx new file mode 100644 index 000000000..6229e4c6d --- /dev/null +++ b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx @@ -0,0 +1,643 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MEFISTO_2D.cxx +// Moved here from SMESH_MEFISTO_2D.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_MEFISTO_2D.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_Mesh.hxx" + +#include "StdMeshers_MaxElementArea.hxx" +#include "StdMeshers_LengthFromEdges.hxx" + +#include "Rn.h" +#include "aptrte.h" + +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_EdgePosition.hxx" +#include "SMDS_FacePosition.hxx" + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, int studyId, + SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen) +{ + MESSAGE("StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D"); + _name = "MEFISTO_2D"; +// _shapeType = TopAbs_FACE; + _shapeType = (1 << TopAbs_FACE); + _compatibleHypothesis.push_back("MaxElementArea"); + _compatibleHypothesis.push_back("LengthFromEdges"); + + _edgeLength = 0; + _maxElementArea = 0; + _hypMaxElementArea = NULL; + _hypLengthFromEdges = NULL; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_MEFISTO_2D::~StdMeshers_MEFISTO_2D() +{ + MESSAGE("StdMeshers_MEFISTO_2D::~StdMeshers_MEFISTO_2D"); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool StdMeshers_MEFISTO_2D::CheckHypothesis + (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + SMESH_Hypothesis::Hypothesis_Status& aStatus) +{ + //MESSAGE("StdMeshers_MEFISTO_2D::CheckHypothesis"); + + _hypMaxElementArea = NULL; + _hypLengthFromEdges = NULL; + + list ::const_iterator itl; + const SMESHDS_Hypothesis *theHyp; + + const list &hyps = GetUsedHypothesis(aMesh, aShape); + int nbHyp = hyps.size(); + if (!nbHyp) + { + aStatus = SMESH_Hypothesis::HYP_MISSING; + return false; // can't work with no hypothesis + } + + itl = hyps.begin(); + theHyp = (*itl); // use only the first hypothesis + + string hypName = theHyp->GetName(); + int hypId = theHyp->GetID(); + //SCRUTE(hypName); + + bool isOk = false; + + if (hypName == "MaxElementArea") + { + _hypMaxElementArea = static_cast(theHyp); + ASSERT(_hypMaxElementArea); + _maxElementArea = _hypMaxElementArea->GetMaxArea(); + _edgeLength = 0; + isOk = true; + aStatus = SMESH_Hypothesis::HYP_OK; + } + + else if (hypName == "LengthFromEdges") + { + _hypLengthFromEdges = static_cast(theHyp); + ASSERT(_hypLengthFromEdges); + _edgeLength = 0; + _maxElementArea = 0; + isOk = true; + aStatus = SMESH_Hypothesis::HYP_OK; + } + else + aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE; + + if (isOk) + { + isOk = false; + if (_maxElementArea > 0) + { + _edgeLength = 2 * sqrt(_maxElementArea); // triangles : minorant + isOk = true; + } + else + isOk = (_hypLengthFromEdges != NULL); // **** check mode + if (!isOk) + aStatus = SMESH_Hypothesis::HYP_BAD_PARAMETER; + } + + //SCRUTE(_edgeLength); + //SCRUTE(_maxElementArea); + return isOk; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) +{ + MESSAGE("StdMeshers_MEFISTO_2D::Compute"); + + if (_hypLengthFromEdges) + _edgeLength = ComputeEdgeElementLength(aMesh, aShape); + + bool isOk = false; + const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); + + const TopoDS_Face & FF = TopoDS::Face(aShape); + bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); + + Z nblf; //nombre de lignes fermees (enveloppe en tete) + Z *nudslf = NULL; //numero du dernier sommet de chaque ligne fermee + R2 *uvslf = NULL; + Z nbpti = 0; //nombre points internes futurs sommets de la triangulation + R2 *uvpti = NULL; + + Z nbst; + R2 *uvst = NULL; + Z nbt; + Z *nust = NULL; + Z ierr = 0; + + Z nutysu = 1; // 1: il existe un fonction areteideale_() + // Z nutysu=0; // 0: on utilise aretmx + R aretmx = _edgeLength; // longueur max aretes future triangulation + //SCRUTE(aretmx); + + nblf = NumberOfWires(F); + //SCRUTE(nblf); + + nudslf = new Z[1 + nblf]; + nudslf[0] = 0; + int iw = 1; + int nbpnt = 0; + + const TopoDS_Wire OW1 = BRepTools::OuterWire(F); + nbpnt += NumberOfPoints(aMesh, OW1); + nudslf[iw++] = nbpnt; + //SCRUTE(nbpnt); + + for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) + { + const TopoDS_Wire & W = TopoDS::Wire(exp.Current()); + if (!OW1.IsSame(W)) + { + nbpnt += NumberOfPoints(aMesh, W); + nudslf[iw++] = nbpnt; + //SCRUTE(nbpnt); + } + } + + uvslf = new R2[nudslf[nblf]]; + //SCRUTE(nudslf[nblf]); + int m = 0; + + map mefistoToDS; // correspondence mefisto index--> points IDNodes + TopoDS_Wire OW = BRepTools::OuterWire(F); + LoadPoints(aMesh, F, OW, uvslf, m, mefistoToDS); + //SCRUTE(m); + + for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) + { + const TopoDS_Wire & W = TopoDS::Wire(exp.Current()); + if (!OW.IsSame(W)) + { + LoadPoints(aMesh, F, W, uvslf, m, mefistoToDS); + //SCRUTE(m); + } + } +// SCRUTE(nudslf[nblf]); +// for (int i=0; i<=nblf; i++) +// { +// MESSAGE(" -+- " <&mefistoToDS) +{ + MESSAGE("StdMeshers_MEFISTO_2D::LoadPoints"); + + SMDS_Mesh * meshDS = aMesh.GetMeshDS(); + + double scalex; + double scaley; + TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); + ComputeScaleOnFace(aMesh, F, scalex, scaley); + + TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD)); + BRepTools_WireExplorer wexp(W, F); + for (wexp.Init(W, F); wexp.More(); wexp.Next()) + { + const TopoDS_Edge & E = wexp.Current(); + + // --- IDNodes of first and last Vertex + + TopoDS_Vertex VFirst, VLast; + TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l + + ASSERT(!VFirst.IsNull()); + SMDS_NodeIteratorPtr lid= + aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes(); + const SMDS_MeshNode* idFirst = lid->next(); + + ASSERT(!VLast.IsNull()); + lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); + const SMDS_MeshNode* idLast = lid->next(); + + // --- edge internal IDNodes (relies on good order storage, not checked) + + int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + //SCRUTE(nbPoints); + + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + + SMDS_NodeIteratorPtr ite= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); + + bool isForward = (E.Orientation() == TopAbs_FORWARD); + map params; + + while(ite->more()) + { + const SMDS_MeshNode * node = ite->next(); + const SMDS_EdgePosition* epos = + static_cast(node->GetPosition().get()); + double param = epos->GetUParameter(); + params[param] = node; + } + // --- load 2D values into MEFISTO structure, + // add IDNodes in mefistoToDS map + + if (E.Orientation() == TopAbs_FORWARD) + { + gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward + uvslf[m].x = scalex * p.X(); + uvslf[m].y = scaley * p.Y(); + mefistoToDS[m + 1] = idFirst; + //MESSAGE(" "<::iterator itp = params.begin(); + for (int i = 1; i <= nbPoints; i++) // nbPoints internal + { + double param = (*itp).first; + gp_Pnt2d p = C2d->Value(param); + uvslf[m].x = scalex * p.X(); + uvslf[m].y = scaley * p.Y(); + mefistoToDS[m + 1] = (*itp).second; +// MESSAGE(" "<Value(l); // last point = Vertex Reversed + uvslf[m].x = scalex * p.X(); + uvslf[m].y = scaley * p.Y(); + mefistoToDS[m + 1] = idLast; +// MESSAGE(" "<::reverse_iterator itp = params.rbegin(); + for (int i = nbPoints; i >= 1; i--) + { + double param = (*itp).first; + gp_Pnt2d p = C2d->Value(param); + uvslf[m].x = scalex * p.X(); + uvslf[m].y = scaley * p.Y(); + mefistoToDS[m + 1] = (*itp).second; +// MESSAGE(" "<Value(param); + if (p.X() < xmin) + xmin = p.X(); + if (p.X() > xmax) + xmax = p.X(); + if (p.Y() < ymin) + ymin = p.Y(); + if (p.Y() > ymax) + ymax = p.Y(); +// MESSAGE(" "<< f<<" "<Value(xmin, ymoy); + gp_Pnt PY0 = S->Value(xmoy, ymin); + for (int i = 1; i <= nbp; i++) + { + double x = xmin + (double (i) / double (nbp))*(xmax - xmin); + gp_Pnt PX = S->Value(x, ymoy); + double y = ymin + (double (i) / double (nbp))*(ymax - ymin); + gp_Pnt PY = S->Value(xmoy, y); + length_x += PX.Distance(PX0); + length_y += PY.Distance(PY0); + PX0.SetCoord(PX.X(), PX.Y(), PX.Z()); + PY0.SetCoord(PY.X(), PY.Y(), PY.Z()); + } +// SCRUTE(length_x); +// SCRUTE(length_y); + scalex = length_x / (xmax - xmin); + scaley = length_y / (ymax - ymin); +// SCRUTE(scalex); +// SCRUTE(scaley); + ASSERT(scalex); + ASSERT(scaley); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh, + Z nbst, R2 * uvst, Z nbt, Z * nust, + const TopoDS_Face & F, bool faceIsForward, + map&mefistoToDS) +{ + double scalex; + double scaley; + ComputeScaleOnFace(aMesh, F, scalex, scaley); + + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + + Z n, m; + Handle(Geom_Surface) S = BRep_Tool::Surface(F); + + for (n = 0; n < nbst; n++) + { + double u = uvst[n][0] / scalex; + double v = uvst[n][1] / scaley; + gp_Pnt P = S->Value(u, v); + + if (mefistoToDS.find(n + 1) == mefistoToDS.end()) + { + SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); + meshDS->SetNodeOnFace(node, F); + + //MESSAGE(nodeId<<" "<(node->GetPosition().get()); + fpos->SetUParameter(u); + fpos->SetVParameter(v); + } + } + + m = 0; + int mt = 0; + + //SCRUTE(faceIsForward); + for (n = 1; n <= nbt; n++) + { + int inode1 = nust[m++]; + int inode2 = nust[m++]; + int inode3 = nust[m++]; + + const SMDS_MeshNode *n1, *n2, *n3; + n1 = mefistoToDS[inode1]; + n2 = mefistoToDS[inode2]; + n3 = mefistoToDS[inode3]; + //MESSAGE("-- "<AddFace(n1, n2, n3); + else + elt = meshDS->AddFace(n1, n3, n2); + + meshDS->SetMeshElementOnShape(elt, F); + m++; + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape) +{ + MESSAGE("StdMeshers_MEFISTO_2D::ComputeEdgeElementLength"); + // **** a mettre dans SMESH_2D_Algo ? + + const TopoDS_Face & FF = TopoDS::Face(aShape); + bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); + + double meanElementLength = 100; + double wireLength = 0; + int wireElementsNumber = 0; + for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) + { + const TopoDS_Wire & W = TopoDS::Wire(exp.Current()); + for (TopExp_Explorer expe(W, TopAbs_EDGE); expe.More(); expe.Next()) + { + const TopoDS_Edge & E = TopoDS::Edge(expe.Current()); + int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + double length = EdgeLength(E); + wireLength += length; + wireElementsNumber += nb; + } + } + if (wireElementsNumber) + meanElementLength = wireLength / wireElementsNumber; + //SCRUTE(meanElementLength); + return meanElementLength; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_MEFISTO_2D::SaveTo(ostream & save) +{ + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_MEFISTO_2D::LoadFrom(istream & load) +{ + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_MEFISTO_2D & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_MEFISTO_2D & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx b/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx new file mode 100644 index 000000000..38753d6bd --- /dev/null +++ b/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx @@ -0,0 +1,88 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MEFISTO_2D.hxx +// Moved here from SMESH_MEFISTO_2D.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _StdMeshers_MEFISTO_2D_HXX_ +#define _StdMeshers_MEFISTO_2D_HXX_ + +#include "SMESH_2D_Algo.hxx" +#include "StdMeshers_MaxElementArea.hxx" +#include "StdMeshers_LengthFromEdges.hxx" +#include "Rn.h" + +class SMDS_MeshNode; +#include +#include + +class StdMeshers_MEFISTO_2D: + public SMESH_2D_Algo +{ +public: + StdMeshers_MEFISTO_2D(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_MEFISTO_2D(); + + 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); + + double ComputeEdgeElementLength(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape); + + void LoadPoints(SMESH_Mesh& aMesh, + const TopoDS_Face& F, + const TopoDS_Wire& W, + R2* uvslf, + int& m, + map& mefistoToDS); + + void ComputeScaleOnFace(SMESH_Mesh& aMesh, + const TopoDS_Face& aFace, + double& scalex, + double& scaley); + + void StoreResult (SMESH_Mesh& aMesh, + Z nbst, R2* uvst, Z nbt, Z* nust, + const TopoDS_Face& F, bool faceIsForward, + map& mefistoToDS); + + ostream & SaveTo(ostream & save); + istream & LoadFrom(istream & load); + friend ostream & operator << (ostream & save, StdMeshers_MEFISTO_2D & hyp); + friend istream & operator >> (istream & load, StdMeshers_MEFISTO_2D & hyp); + +protected: + double _edgeLength; + double _maxElementArea; + const StdMeshers_MaxElementArea* _hypMaxElementArea; + const StdMeshers_LengthFromEdges* _hypLengthFromEdges; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_MaxElementArea.cxx b/src/StdMeshers/StdMeshers_MaxElementArea.cxx new file mode 100644 index 000000000..c4a2d5e17 --- /dev/null +++ b/src/StdMeshers/StdMeshers_MaxElementArea.cxx @@ -0,0 +1,139 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MaxElementArea.cxx +// Moved here from SMESH_MaxElementArea.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_MaxElementArea.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_MaxElementArea::StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_Hypothesis(hypId, studyId, gen) +{ + _maxArea =1.; + _name = "MaxElementArea"; +// SCRUTE(_name); +// SCRUTE(&_name); + _param_algo_dim = 2; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_MaxElementArea::~StdMeshers_MaxElementArea() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_MaxElementArea::SetMaxArea(double maxArea) + throw (SALOME_Exception) +{ + double oldArea = _maxArea; + if (maxArea <= 0) + throw SALOME_Exception(LOCALIZED("maxArea must be positive")); + _maxArea = maxArea; + if (_maxArea != oldArea) + NotifySubMeshesHypothesisModification(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_MaxElementArea::GetMaxArea() const +{ + return _maxArea; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_MaxElementArea::SaveTo(ostream & save) +{ + save << this->_maxArea; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_MaxElementArea::LoadFrom(istream & load) +{ + bool isOK = true; + double a; + isOK = (load >> a); + if (isOK) + this->_maxArea = a; + else + load.clear(ios::badbit | load.rdstate()); + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator << (ostream & save, StdMeshers_MaxElementArea & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >> (istream & load, StdMeshers_MaxElementArea & hyp) +{ + return hyp.LoadFrom( load ); +} + diff --git a/src/StdMeshers/StdMeshers_MaxElementArea.hxx b/src/StdMeshers/StdMeshers_MaxElementArea.hxx new file mode 100644 index 000000000..52af887c8 --- /dev/null +++ b/src/StdMeshers/StdMeshers_MaxElementArea.hxx @@ -0,0 +1,55 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MaxElementArea.hxx +// Moved here from SMESH_MaxElementArea.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_MAXELEMENTAREA_HXX_ +#define _SMESH_MAXELEMENTAREA_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class StdMeshers_MaxElementArea:public SMESH_Hypothesis +{ + public: + StdMeshers_MaxElementArea(int hypId, int studyId, SMESH_Gen * gen); + virtual ~ StdMeshers_MaxElementArea(); + + void SetMaxArea(double maxArea) throw(SALOME_Exception); + + double GetMaxArea() const; + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream & operator <<(ostream & save, StdMeshers_MaxElementArea & hyp); + friend istream & operator >>(istream & load, StdMeshers_MaxElementArea & hyp); + + protected: + double _maxArea; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_MaxElementVolume.cxx b/src/StdMeshers/StdMeshers_MaxElementVolume.cxx new file mode 100644 index 000000000..f9f6b6322 --- /dev/null +++ b/src/StdMeshers/StdMeshers_MaxElementVolume.cxx @@ -0,0 +1,141 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MaxElementVolume.cxx +// Moved here from SMESH_MaxElementVolume.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; + +#include "StdMeshers_MaxElementVolume.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_MaxElementVolume::StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_Hypothesis(hypId, studyId, gen) +{ + _maxVolume =1.; + _name = "MaxElementVolume"; +// SCRUTE(_name); + SCRUTE(&_name); + _param_algo_dim = 3; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_MaxElementVolume::~StdMeshers_MaxElementVolume() +{ + MESSAGE("StdMeshers_MaxElementVolume::~StdMeshers_MaxElementVolume"); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_MaxElementVolume::SetMaxVolume(double maxVolume) + throw (SALOME_Exception) +{ + double oldVolume = _maxVolume; + if (maxVolume <= 0) + throw SALOME_Exception(LOCALIZED("maxVolume must be positive")); + _maxVolume = maxVolume; + if (_maxVolume != oldVolume) + NotifySubMeshesHypothesisModification(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_MaxElementVolume::GetMaxVolume() const +{ + return _maxVolume; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_MaxElementVolume::SaveTo(ostream & save) +{ + save << this->_maxVolume; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_MaxElementVolume::LoadFrom(istream & load) +{ + bool isOK = true; + double a; + isOK = (load >> a); + if (isOK) + this->_maxVolume = a; + else + load.clear(ios::badbit | load.rdstate()); + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator << (ostream & save, StdMeshers_MaxElementVolume & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >> (istream & load, StdMeshers_MaxElementVolume & hyp) +{ + return hyp.LoadFrom( load ); +} + diff --git a/src/StdMeshers/StdMeshers_MaxElementVolume.hxx b/src/StdMeshers/StdMeshers_MaxElementVolume.hxx new file mode 100644 index 000000000..ee9986f1f --- /dev/null +++ b/src/StdMeshers/StdMeshers_MaxElementVolume.hxx @@ -0,0 +1,57 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MaxElementVolume.hxx +// Moved here from SMESH_MaxElementVolume.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_MAXELEMENTVOLUME_HXX_ +#define _SMESH_MAXELEMENTVOLUME_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class StdMeshers_MaxElementVolume: + public SMESH_Hypothesis +{ +public: + StdMeshers_MaxElementVolume(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_MaxElementVolume(); + + void SetMaxVolume(double maxVolume) + throw (SALOME_Exception); + + double GetMaxVolume() const; + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream & operator << (ostream & save, StdMeshers_MaxElementVolume & hyp); + friend istream & operator >> (istream & load, StdMeshers_MaxElementVolume & hyp); + +protected: + double _maxVolume; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_NotConformAllowed.cxx b/src/StdMeshers/StdMeshers_NotConformAllowed.cxx new file mode 100644 index 000000000..5c471b2a0 --- /dev/null +++ b/src/StdMeshers/StdMeshers_NotConformAllowed.cxx @@ -0,0 +1,98 @@ +// SMESH StdMeshers : 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_NotConformAllowed.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_NotConformAllowed.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_NotConformAllowed::StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen) + : SMESH_Hypothesis(hypId, studyId, gen) +{ + _name = "NotConformAllowed"; + _param_algo_dim = -1; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_NotConformAllowed::~StdMeshers_NotConformAllowed() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_NotConformAllowed::SaveTo(ostream & save) +{ + return save << this; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_NotConformAllowed::LoadFrom(istream & load) +{ + return load >> (*this); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator << (ostream & save, StdMeshers_NotConformAllowed & hyp) +{ + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp) +{ + return load; +} diff --git a/src/StdMeshers/StdMeshers_NotConformAllowed.hxx b/src/StdMeshers/StdMeshers_NotConformAllowed.hxx new file mode 100644 index 000000000..079742458 --- /dev/null +++ b/src/StdMeshers/StdMeshers_NotConformAllowed.hxx @@ -0,0 +1,48 @@ +// SMESH StdMeshers : 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_NotConformAllowed.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _StdMeshers_NotConformAllowed_HXX_ +#define _StdMeshers_NotConformAllowed_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class StdMeshers_NotConformAllowed: + public SMESH_Hypothesis +{ +public: + StdMeshers_NotConformAllowed(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_NotConformAllowed(); + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream & operator << (ostream & save, StdMeshers_NotConformAllowed & hyp); + friend istream & operator >> (istream & load, StdMeshers_NotConformAllowed & hyp); +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.cxx b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx new file mode 100644 index 000000000..c16c1373b --- /dev/null +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.cxx @@ -0,0 +1,171 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_NumberOfSegments.cxx +// Moved here from SMESH_NumberOfSegments.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_NumberOfSegments.hxx" + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_NumberOfSegments::StdMeshers_NumberOfSegments(int hypId, int studyId, + SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen) +{ + _numberOfSegments = 1; + _scaleFactor = 1.0; + _name = "NumberOfSegments"; + _param_algo_dim = 1; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_NumberOfSegments::~StdMeshers_NumberOfSegments() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_NumberOfSegments::SetNumberOfSegments(int segmentsNumber) +throw(SALOME_Exception) +{ + int oldNumberOfSegments = _numberOfSegments; + if (segmentsNumber <= 0) + throw + SALOME_Exception(LOCALIZED("number of segments must be positive")); + _numberOfSegments = segmentsNumber; + + if (oldNumberOfSegments != _numberOfSegments) + NotifySubMeshesHypothesisModification(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +int StdMeshers_NumberOfSegments::GetNumberOfSegments() const +{ + return _numberOfSegments; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_NumberOfSegments::SetScaleFactor(double scaleFactor) +throw(SALOME_Exception) +{ + if (scaleFactor < 0) + throw SALOME_Exception(LOCALIZED("scale factor must be positive")); + _scaleFactor = scaleFactor; + + NotifySubMeshesHypothesisModification(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_NumberOfSegments::GetScaleFactor() const +{ + return _scaleFactor; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_NumberOfSegments::SaveTo(ostream & save) +{ + save << this->_numberOfSegments << " " << this->_scaleFactor; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_NumberOfSegments::LoadFrom(istream & load) +{ + bool isOK = true; + int a; + isOK = (load >> a); + if (isOK) + this->_numberOfSegments = a; + else + load.clear(ios::badbit | load.rdstate()); + double b; + isOK = (load >> b); + if (isOK) + this->_scaleFactor = b; + else + load.clear(ios::badbit | load.rdstate()); + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_NumberOfSegments & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_NumberOfSegments & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/StdMeshers/StdMeshers_NumberOfSegments.hxx b/src/StdMeshers/StdMeshers_NumberOfSegments.hxx new file mode 100644 index 000000000..79147e1a2 --- /dev/null +++ b/src/StdMeshers/StdMeshers_NumberOfSegments.hxx @@ -0,0 +1,63 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_NumberOfSegments.hxx +// Moved here from SMESH_NumberOfSegments.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_NUMBEROFSEGMENTS_HXX_ +#define _SMESH_NUMBEROFSEGMENTS_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class StdMeshers_NumberOfSegments: + public SMESH_Hypothesis +{ +public: + StdMeshers_NumberOfSegments(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_NumberOfSegments(); + + void SetNumberOfSegments(int segmentsNumber) + throw (SALOME_Exception); + + int GetNumberOfSegments() const; + + void SetScaleFactor(double scaleFactor) + throw (SALOME_Exception); + + double GetScaleFactor() const; + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream& operator << (ostream & save, StdMeshers_NumberOfSegments & hyp); + friend istream& operator >> (istream & load, StdMeshers_NumberOfSegments & hyp); + +protected: + int _numberOfSegments; + double _scaleFactor; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx new file mode 100644 index 000000000..14815906d --- /dev/null +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -0,0 +1,644 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Quadrangle_2D.cxx +// Moved here from SMESH_Quadrangle_2D.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Quadrangle_2D.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_Mesh.hxx" + +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_EdgePosition.hxx" +#include "SMDS_FacePosition.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "utilities.h" +#include "Utils_ExceptHandlers.hxx" + + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D(int hypId, + int studyId, SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen) +{ + MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D"); + _name = "Quadrangle_2D"; + // _shapeType = TopAbs_FACE; + _shapeType = (1 << TopAbs_FACE); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D() +{ + MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D"); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool StdMeshers_Quadrangle_2D::CheckHypothesis + (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + SMESH_Hypothesis::Hypothesis_Status& aStatus) +{ + //MESSAGE("StdMeshers_Quadrangle_2D::CheckHypothesis"); + + bool isOk = true; + aStatus = SMESH_Hypothesis::HYP_OK; + + // nothing to check + + return isOk; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool StdMeshers_Quadrangle_2D::Compute(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape)throw(SALOME_Exception) +{ + Unexpect aCatch(SalomeException); + //MESSAGE("StdMeshers_Quadrangle_2D::Compute"); + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); + + FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape); + if (!quad) + return false; + + // --- compute 3D values on points, store points & quadrangles + + int nbdown = quad->nbPts[0]; + int nbright = quad->nbPts[1]; + int nbVertices = nbdown * nbright; + int nbQuad = (nbdown - 1) * (nbright - 1); + //SCRUTE(nbVertices); + //SCRUTE(nbQuad); + + // const TopoDS_Face& FF = TopoDS::Face(aShape); + // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); + const TopoDS_Face & F = TopoDS::Face(aShape); + bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); + Handle(Geom_Surface) S = BRep_Tool::Surface(F); + + for (int i = 1; i < nbdown - 1; i++) + for (int j = 1; j < nbright - 1; j++) // internal points + { + int ij = j * nbdown + i; + double u = quad->uv_grid[ij].u; + double v = quad->uv_grid[ij].v; + gp_Pnt P = S->Value(u, v); + SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); + meshDS->SetNodeOnFace(node, F); + quad->uv_grid[ij].node = node; +// Handle (SMDS_FacePosition) fpos +// = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v +// node->SetPosition(fpos); + SMDS_FacePosition* fpos = + dynamic_cast(node->GetPosition().get()); + fpos->SetUParameter(i); + fpos->SetVParameter(j); + } + + // bool isQuadForward = ( faceIsForward == quad->isEdgeForward[0]); + for (int i = 0; i < nbdown - 1; i++) + for (int j = 0; j < nbright - 1; j++) // faces + { + const SMDS_MeshNode *a, *b, *c, *d; + a = quad->uv_grid[j * nbdown + i].node; + b = quad->uv_grid[j * nbdown + i + 1].node; + c = quad->uv_grid[(j + 1) * nbdown + i + 1].node; + d = quad->uv_grid[(j + 1) * nbdown + i].node; + // if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d); + // else faceId = meshDS->AddFace(a,d,c,b); + SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d); + meshDS->SetMeshElementOnShape(face, F); + } + + QuadDelete(quad); + bool isOk = true; + return isOk; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape)throw(SALOME_Exception) +{ + Unexpect aCatch(SalomeException); + //MESSAGE("StdMeshers_Quadrangle_2D::ComputeWithoutStore"); + + SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); + + // const TopoDS_Face& FF = TopoDS::Face(aShape); + // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); + const TopoDS_Face & F = TopoDS::Face(aShape); + bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); + + // verify 1 wire only, with 4 edges, same number of points on opposite edges + + if (NumberOfWires(F) != 1) + { + MESSAGE("only 1 wire by face (quadrangles)"); + return 0; + //throw SALOME_Exception(LOCALIZED("only 1 wire by face (quadrangles)")); + } + // const TopoDS_Wire WW = BRepTools::OuterWire(F); + // TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD)); + const TopoDS_Wire & W = BRepTools::OuterWire(F); + BRepTools_WireExplorer wexp(W, F); + + FaceQuadStruct *quad = new FaceQuadStruct; + for (int i = 0; i < 4; i++) + quad->uv_edges[i] = 0; + quad->uv_grid = 0; + + int nbEdges = 0; + for (wexp.Init(W, F); wexp.More(); wexp.Next()) + { + // const TopoDS_Edge& EE = wexp.Current(); + // TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); + const TopoDS_Edge & E = wexp.Current(); + int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + if (nbEdges < 4) + { + quad->edge[nbEdges] = E; + quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema + } + nbEdges++; + } + + if (nbEdges != 4) + { + MESSAGE("face must have 4 edges /quadrangles"); + QuadDelete(quad); + return 0; + //throw SALOME_Exception(LOCALIZED("face must have 4 edges /quadrangles")); + } + + if (quad->nbPts[0] != quad->nbPts[2]) + { + MESSAGE("different point number-opposed edge"); + QuadDelete(quad); + return 0; + //throw SALOME_Exception(LOCALIZED("different point number-opposed edge")); + } + + if (quad->nbPts[1] != quad->nbPts[3]) + { + MESSAGE("different point number-opposed edge"); + QuadDelete(quad); + return 0; + //throw SALOME_Exception(LOCALIZED("different point number-opposed edge")); + } + + // set normalized grid on unit square in parametric domain + + SetNormalizedGrid(aMesh, F, quad); + + return quad; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_Quadrangle_2D::QuadDelete(FaceQuadStruct * quad) +{ + //MESSAGE("StdMeshers_Quadrangle_2D::QuadDelete"); + if (quad) + { + for (int i = 0; i < 4; i++) + { + if (quad->uv_edges[i]) + delete[]quad->uv_edges[i]; + quad->edge[i].Nullify(); + } + if (quad->uv_grid) + delete[]quad->uv_grid; + delete quad; + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh & aMesh, + const TopoDS_Shape & aShape, FaceQuadStruct * quad) throw(SALOME_Exception) +{ + Unexpect aCatch(SalomeException); + // Algorithme décrit dans "Génération automatique de maillages" + // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85 + // traitement dans le domaine paramétrique 2d u,v + // transport - projection sur le carré unité + + const TopoDS_Face & F = TopoDS::Face(aShape); + + // 1 --- find orientation of the 4 edges, by test on extrema + + // max min 0 x1 1 + // |<----north-2-------^ a3 -------------> a2 + // | | ^1 1^ + // west-3 east-1 =right | | + // | | ==> | | + // y0 | | y1 | | + // | | |0 0| + // v----south-0--------> a0 -------------> a1 + // min max 0 x0 1 + // =down + // + + Handle(Geom2d_Curve) c2d[4]; + gp_Pnt2d pf[4]; + gp_Pnt2d pl[4]; + for (int i = 0; i < 4; i++) + { + c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i], + F, quad->first[i], quad->last[i]); + pf[i] = c2d[i]->Value(quad->first[i]); + pl[i] = c2d[i]->Value(quad->last[i]); + quad->isEdgeForward[i] = false; + } + + double eps2d = 1.e-3; // *** utiliser plutot TopExp::CommonVertex, puis + // distances si piece fausse + int i = 0; + if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d)) + { + quad->isEdgeForward[0] = true; + } + else + { + double tmp = quad->first[0]; + quad->first[0] = quad->last[0]; + quad->last[0] = tmp; + pf[0] = c2d[0]->Value(quad->first[0]); + pl[0] = c2d[0]->Value(quad->last[0]); + } + for (int i = 1; i < 4; i++) + { + quad->isEdgeForward[i] = (pf[i].Distance(pl[i - 1]) < eps2d); + if (!quad->isEdgeForward[i]) + { + double tmp = quad->first[i]; + quad->first[i] = quad->last[i]; + quad->last[i] = tmp; + pf[i] = c2d[i]->Value(quad->first[i]); + pl[i] = c2d[i]->Value(quad->last[i]); + //SCRUTE(pf[i].Distance(pl[i-1])); + ASSERT(pf[i].Distance(pl[i - 1]) < eps2d); + } + } + //SCRUTE(pf[0].Distance(pl[3])); + ASSERT(pf[0].Distance(pl[3]) < eps2d); + +// for (int i=0; i<4; i++) +// { +// SCRUTE(quad->isEdgeForward[i]); +// MESSAGE(" -first "<uv_edges[i] = LoadEdgePoints(aMesh, F, + quad->edge[i], quad->first[i], quad->last[i]); + + // quad->isEdgeForward[i]); + } + for (int i = 2; i < 4; i++) + { + quad->uv_edges[i] = LoadEdgePoints(aMesh, F, + quad->edge[i], quad->last[i], quad->first[i]); + + // !quad->isEdgeForward[i]); + } + + // 3 --- 2D normalized values on unit square [0..1][0..1] + + int nbdown = quad->nbPts[0]; + int nbright = quad->nbPts[1]; + quad->uv_grid = new UVPtStruct[nbright * nbdown]; + + UVPtStruct *uv_grid = quad->uv_grid; + UVPtStruct *uv_e0 = quad->uv_edges[0]; + UVPtStruct *uv_e1 = quad->uv_edges[1]; + UVPtStruct *uv_e2 = quad->uv_edges[2]; + UVPtStruct *uv_e3 = quad->uv_edges[3]; + gp_Pnt2d a0 = pf[0]; + gp_Pnt2d a1 = pf[1]; + gp_Pnt2d a2 = pf[2]; + gp_Pnt2d a3 = pf[3]; + + // nodes Id on edges + + int j = 0; + for (int i = 0; i < nbdown; i++) + { + int ij = j * nbdown + i; + uv_grid[ij].node = uv_e0[i].node; + } + i = nbdown - 1; + for (int j = 0; j < nbright; j++) + { + int ij = j * nbdown + i; + uv_grid[ij].node = uv_e1[j].node; + } + j = nbright - 1; + for (int i = 0; i < nbdown; i++) + { + int ij = j * nbdown + i; + uv_grid[ij].node = uv_e2[i].node; + } + i = 0; + for (int j = 0; j < nbright; j++) + { + int ij = j * nbdown + i; + uv_grid[ij].node = uv_e3[j].node; + } + + // normalized 2d values on grid + + for (int i = 0; i < nbdown; i++) + for (int j = 0; j < nbright; j++) + { + int ij = j * nbdown + i; + // --- droite i cste : x = x0 + y(x1-x0) + double x0 = uv_e0[i].normParam; // bas - sud + double x1 = uv_e2[i].normParam; // haut - nord + // --- droite j cste : y = y0 + x(y1-y0) + double y0 = uv_e3[j].normParam; // gauche-ouest + double y1 = uv_e1[j].normParam; // droite - est + // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0) + double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0)); + double y = y0 + x * (y1 - y0); + uv_grid[ij].x = x; + uv_grid[ij].y = y; + //MESSAGE("-xy-01 "<Value(param_0); + gp_Pnt2d p1 = c2d[1]->Value(param_1); + gp_Pnt2d p2 = c2d[2]->Value(param_2); + gp_Pnt2d p3 = c2d[3]->Value(param_3); + + double u = + (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X(); + double v = + (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y(); + + u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() + + x * y * a2.X() + (1 - x) * y * a3.X(); + v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() + + x * y * a2.Y() + (1 - x) * y * a3.Y(); + + uv_grid[ij].u = u; + uv_grid[ij].v = v; + + //MESSAGE("-uv- "<GetSubMeshDS()->GetNodes(); + const SMDS_MeshNode * idFirst = lid->next(); + + ASSERT(!VLast.IsNull()); + lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); + const SMDS_MeshNode * idLast = lid->next(); + + // --- edge internal IDNodes (relies on good order storage, not checked) + + int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + //SCRUTE(nbPoints); + UVPtStruct *uvslf = new UVPtStruct[nbPoints + 2]; + + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + + map params; + SMDS_NodeIteratorPtr ite= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); + + while(ite->more()) + { + const SMDS_MeshNode * node = ite->next(); + const SMDS_EdgePosition* epos = + static_cast(node->GetPosition().get()); + double param = epos->GetUParameter(); + params[param] = node; + } + + bool isForward = (((l - f) * (last - first)) > 0); + double paramin = 0; + double paramax = 0; + if (isForward) + { + paramin = f; + paramax = l; + gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward + uvslf[0].x = p.X(); + uvslf[0].y = p.Y(); + uvslf[0].param = f; + uvslf[0].node = idFirst; + //MESSAGE("__ f "<::iterator itp = params.begin(); + for (int i = 1; i <= nbPoints; i++) // nbPoints internal + { + double param = (*itp).first; + gp_Pnt2d p = C2d->Value(param); + uvslf[i].x = p.X(); + uvslf[i].y = p.Y(); + uvslf[i].param = param; + uvslf[i].node = (*itp).second; + //MESSAGE("__ "<Value(l); // last point = Vertex Reversed + uvslf[nbPoints + 1].x = p.X(); + uvslf[nbPoints + 1].y = p.Y(); + uvslf[nbPoints + 1].param = l; + uvslf[nbPoints + 1].node = idLast; + //MESSAGE("__ l "<Value(l); // first point = Vertex Reversed + uvslf[0].x = p.X(); + uvslf[0].y = p.Y(); + uvslf[0].param = l; + uvslf[0].node = idLast; + //MESSAGE("__ l "<::reverse_iterator itp = params.rbegin(); + for (int j = nbPoints; j >= 1; j--) // nbPoints internal + { + double param = (*itp).first; + int i = nbPoints + 1 - j; + gp_Pnt2d p = C2d->Value(param); + uvslf[i].x = p.X(); + uvslf[i].y = p.Y(); + uvslf[i].param = param; + uvslf[i].node = (*itp).second; + //MESSAGE("__ "<Value(f); // last point = Vertex Forward + uvslf[nbPoints + 1].x = p.X(); + uvslf[nbPoints + 1].y = p.Y(); + uvslf[nbPoints + 1].param = f; + uvslf[nbPoints + 1].node = idFirst; + //MESSAGE("__ f "<>(istream & load, StdMeshers_Quadrangle_2D & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx new file mode 100644 index 000000000..afa3882f2 --- /dev/null +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx @@ -0,0 +1,102 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Quadrangle_2D.hxx +// Moved here from SMESH_Quadrangle_2D.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_QUADRANGLE_2D_HXX_ +#define _SMESH_QUADRANGLE_2D_HXX_ + +#include "SMESH_2D_Algo.hxx" +#include "SMESH_Mesh.hxx" +#include "Utils_SALOME_Exception.hxx" + +typedef struct uvPtStruct +{ + double param; + double normParam; + double u; // original 2d parameter + double v; + double x; // 2d parameter, normalized [0,1] + double y; + const SMDS_MeshNode * node; +} UVPtStruct; + +typedef struct faceQuadStruct +{ + int nbPts[4]; + TopoDS_Edge edge[4]; + double first[4]; + double last[4]; + bool isEdgeForward[4]; + UVPtStruct* uv_edges[4]; + UVPtStruct* uv_grid; +} FaceQuadStruct; + +class StdMeshers_Quadrangle_2D: + public SMESH_2D_Algo +{ +public: + StdMeshers_Quadrangle_2D(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_Quadrangle_2D(); + + 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) + throw (SALOME_Exception); + + FaceQuadStruct* CheckAnd2Dcompute(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape) + throw (SALOME_Exception); + + void QuadDelete(FaceQuadStruct* quad); + + ostream & SaveTo(ostream & save); + istream & LoadFrom(istream & load); + friend ostream & operator << (ostream & save, StdMeshers_Quadrangle_2D & hyp); + friend istream & operator >> (istream & load, StdMeshers_Quadrangle_2D & hyp); + +protected: + + void SetNormalizedGrid(SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + FaceQuadStruct* quad) + throw (SALOME_Exception); + + UVPtStruct* LoadEdgePoints(SMESH_Mesh& aMesh, + const TopoDS_Face& F, + const TopoDS_Edge& E, + double first, + double last); +// bool isForward); + +// FaceQuadStruct _quadDesc; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_Regular_1D.cxx b/src/StdMeshers/StdMeshers_Regular_1D.cxx new file mode 100644 index 000000000..aa069ff8c --- /dev/null +++ b/src/StdMeshers/StdMeshers_Regular_1D.cxx @@ -0,0 +1,331 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Regular_1D.cxx +// Moved here from SMESH_Regular_1D.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; + +#include "StdMeshers_Regular_1D.hxx" +#include "SMESH_Gen.hxx" +#include "SMESH_Mesh.hxx" + +#include "StdMeshers_LocalLength.hxx" +#include "StdMeshers_NumberOfSegments.hxx" + +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_EdgePosition.hxx" + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId, + SMESH_Gen * gen):SMESH_1D_Algo(hypId, studyId, gen) +{ + MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D"); + _name = "Regular_1D"; + // _shapeType = TopAbs_EDGE; + _shapeType = (1 << TopAbs_EDGE); + _compatibleHypothesis.push_back("LocalLength"); + _compatibleHypothesis.push_back("NumberOfSegments"); + + _localLength = 0; + _numberOfSegments = 0; + _hypLocalLength = NULL; + _hypNumberOfSegments = NULL; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Regular_1D::~StdMeshers_Regular_1D() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool StdMeshers_Regular_1D::CheckHypothesis + (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape, + SMESH_Hypothesis::Hypothesis_Status& aStatus) +{ + //MESSAGE("StdMeshers_Regular_1D::CheckHypothesis"); + + list ::const_iterator itl; + const SMESHDS_Hypothesis *theHyp; + + const list &hyps = GetUsedHypothesis(aMesh, aShape); + int nbHyp = hyps.size(); + if (!nbHyp) + { + aStatus = SMESH_Hypothesis::HYP_MISSING; + return false; // can't work with no hypothesis + } + + itl = hyps.begin(); + theHyp = (*itl); // use only the first hypothesis + + string hypName = theHyp->GetName(); + int hypId = theHyp->GetID(); + //SCRUTE(hypName); + + bool isOk = false; + + if (hypName == "LocalLength") + { + _hypLocalLength = dynamic_cast (theHyp); + ASSERT(_hypLocalLength); + _localLength = _hypLocalLength->GetLength(); + _numberOfSegments = 0; + isOk = true; + aStatus = SMESH_Hypothesis::HYP_OK; + } + + else if (hypName == "NumberOfSegments") + { + _hypNumberOfSegments = + dynamic_cast (theHyp); + ASSERT(_hypNumberOfSegments); + _numberOfSegments = _hypNumberOfSegments->GetNumberOfSegments(); + _scaleFactor = _hypNumberOfSegments->GetScaleFactor(); + _localLength = 0; + isOk = true; + aStatus = SMESH_Hypothesis::HYP_OK; + } + else + aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE; + + //SCRUTE(_localLength); + //SCRUTE(_numberOfSegments); + + return isOk; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) +{ + MESSAGE("StdMeshers_Regular_1D::Compute"); + + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); + + const TopoDS_Edge & EE = TopoDS::Edge(aShape); + TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); + + double f, l; + Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l); + + TopoDS_Vertex VFirst, VLast; + TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l + + double length = EdgeLength(E); + //SCRUTE(length); + + double eltSize = 1; +// if (_localLength > 0) eltSize = _localLength; + if (_localLength > 0) + { + double nbseg = ceil(length / _localLength); // integer sup + if (nbseg <= 0) + nbseg = 1; // degenerated edge + eltSize = length / nbseg; + } + else + { + ASSERT(_numberOfSegments > 0); + eltSize = length / _numberOfSegments; + } + + ASSERT(!VFirst.IsNull()); + SMDS_NodeIteratorPtr lid= aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes(); + const SMDS_MeshNode * idFirst = lid->next(); + + ASSERT(!VLast.IsNull()); + lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); + const SMDS_MeshNode * idLast = lid->next(); + + if (!Curve.IsNull()) + { + GeomAdaptor_Curve C3d(Curve); + GCPnts_UniformAbscissa Discret(C3d, eltSize, f, l); + int NbPoints = Discret.NbPoints(); + //MESSAGE("nb points on edge : "< 1) + { + double epsilon = 0.001; + if (fabs(_scaleFactor - 1.0) > epsilon) + { + double alpha = + pow(_scaleFactor, 1.0 / (_numberOfSegments - 1)); + double d = + length * (1 - pow(alpha, i - 1)) / (1 - pow(alpha, + _numberOfSegments)); + param = d; + } + } + + gp_Pnt P = Curve->Value(param); + + //Add the Node in the DataStructure + //MESSAGE("point "<AddNode(P.X(), P.Y(), P.Z()); + meshDS->SetNodeOnEdge(node, E); + + // **** edgePosition associe au point = param. + SMDS_EdgePosition* epos = + dynamic_cast(node->GetPosition().get()); + epos->SetUParameter(param); + + SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node); + meshDS->SetMeshElementOnShape(edge, E); + idPrev = node; + } + SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast); + meshDS->SetMeshElementOnShape(edge, E); + } + else + { +// MESSAGE ("Edge Degeneree non traitee --- arret"); +// ASSERT(0); + if (BRep_Tool::Degenerated(E)) + { + // Edge is a degenerated Edge : We put n = 5 points on the edge. + int NbPoints = 5; + BRep_Tool::Range(E, f, l); + double du = (l - f) / (NbPoints - 1); + MESSAGE("************* Degenerated edge! *****************"); + + TopoDS_Vertex V1, V2; + TopExp::Vertices(E, V1, V2); + gp_Pnt P = BRep_Tool::Pnt(V1); + + const SMDS_MeshNode * idPrev = idFirst; + for (int i = 2; i < NbPoints; i++) + { + double param = f + (i - 1) * du; + SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); + meshDS->SetNodeOnEdge(node, E); + +// Handle (SMDS_EdgePosition) epos +// = new SMDS_EdgePosition(theSubMesh->GetId(),param); +// node->SetPosition(epos); + SMDS_EdgePosition* epos = + dynamic_cast(node->GetPosition().get()); + epos->SetUParameter(param); + + SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node); + meshDS->SetMeshElementOnShape(edge, E); + idPrev = node; + } + SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast); + meshDS->SetMeshElementOnShape(edge, E); + } + else + ASSERT(0); + } + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_Regular_1D::SaveTo(ostream & save) +{ + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_Regular_1D::LoadFrom(istream & load) +{ + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_Regular_1D & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_Regular_1D & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/StdMeshers/StdMeshers_Regular_1D.hxx b/src/StdMeshers/StdMeshers_Regular_1D.hxx new file mode 100644 index 000000000..a68549268 --- /dev/null +++ b/src/StdMeshers/StdMeshers_Regular_1D.hxx @@ -0,0 +1,65 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Regular_1D.hxx +// Moved here from SMESH_Regular_1D.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_REGULAR_1D_HXX_ +#define _SMESH_REGULAR_1D_HXX_ + +#include "SMESH_1D_Algo.hxx" + +class StdMeshers_LocalLength; +class StdMeshers_NumberOfSegments; + +class StdMeshers_Regular_1D: + public SMESH_1D_Algo +{ +public: + StdMeshers_Regular_1D(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_Regular_1D(); + + 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); + + ostream & SaveTo(ostream & save); + istream & LoadFrom(istream & load); + friend ostream & operator << (ostream & save, StdMeshers_Regular_1D & hyp); + friend istream & operator >> (istream & load, StdMeshers_Regular_1D & hyp); + +protected: + double _localLength; + int _numberOfSegments; + double _scaleFactor; + const StdMeshers_LocalLength* _hypLocalLength; + const StdMeshers_NumberOfSegments* _hypNumberOfSegments; +}; + +#endif diff --git a/src/StdMeshersGUI/Makefile.in b/src/StdMeshersGUI/Makefile.in new file mode 100644 index 000000000..8c924a23f --- /dev/null +++ b/src/StdMeshersGUI/Makefile.in @@ -0,0 +1,78 @@ +# SMESH StdMeshersGUI : GUI for StdMeshers plugin +# +# Copyright (C) 2003 CEA +# +# 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.org +# +# +# +# File : Makefile.in +# Author : Julia DOROVSKIKH +# Module : SMESH +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/salome:${MED_ROOT_DIR}/idl/salome + + +@COMMENCE@ + +# .po files to transform in .qm + PO_FILES = \ + StdMeshers_icons.po \ + StdMeshers_msg_en.po + +# Libraries targets +LIB = libStdMeshersGUI.la +LIB_SRC = \ + StdMeshersGUI.cxx \ + StdMeshersGUI_LocalLengthDlg.cxx \ + StdMeshersGUI_NbSegmentsDlg.cxx \ + StdMeshersGUI_MaxElementAreaDlg.cxx \ + StdMeshersGUI_MaxElementVolumeDlg.cxx + +LIB_MOC = \ + StdMeshersGUI_LocalLengthDlg.h \ + StdMeshersGUI_NbSegmentsDlg.h \ + StdMeshersGUI_MaxElementAreaDlg.h \ + StdMeshersGUI_MaxElementVolumeDlg.h + +LIB_CLIENT_IDL = \ + SALOME_Exception.idl \ + SMESH_Gen.idl \ + SMESH_Mesh.idl \ + SMESH_Group.idl \ + SMESH_Filter.idl \ + SMESH_Hypothesis.idl \ + SMESH_BasicHypothesis.idl \ + MED.idl + +LIB_SERVER_IDL = + +# additionnal information to compil and link file + +CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \ + $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \ + $(BOOST_CPPFLAGS) +CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome +#$(OCC_CXXFLAGS) + +LDFLAGS += -lSMESHGUI $(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/StdMeshersGUI/StdMeshersGUI.cxx b/src/StdMeshersGUI/StdMeshersGUI.cxx new file mode 100644 index 000000000..e272665f8 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI.cxx @@ -0,0 +1,225 @@ +// SMESH StdMeshersGUI : GUI for plugged-in meshers +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : StdMeshersGUI.cxx +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +using namespace std; + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESHGUI.h" +#include "SMESHGUI_Hypotheses.h" + +#include "StdMeshersGUI_LocalLengthDlg.h" +#include "StdMeshersGUI_NbSegmentsDlg.h" +#include "StdMeshersGUI_MaxElementAreaDlg.h" +#include "StdMeshersGUI_MaxElementVolumeDlg.h" + +#include "QAD_Desktop.h" +#include "QAD_ResourceMgr.h" + +#include + +//============================================================================= +/*! class HypothesisCreator + * + */ +//============================================================================= +class StdMeshersGUI_HypothesisCreator : public SMESHGUI_GenericHypothesisCreator +{ + public: + StdMeshersGUI_HypothesisCreator (const QString& aHypType, + const QString& aServerLibName, + SMESHGUI* aSMESHGUI) + : myHypType(aHypType), + myServerLibName(aServerLibName), + mySMESHGUI(aSMESHGUI) {} + + virtual void CreateHypothesis (const bool isAlgo, QWidget* parent = 0); + virtual void EditHypothesis (SMESH::SMESH_Hypothesis_ptr theHyp); + + private: + QString myHypType; + QString myServerLibName; + SMESHGUI* mySMESHGUI; +}; + +//============================================================================= +/*! HypothesisCreator::CreateHypothesis + * + */ +//============================================================================= +void StdMeshersGUI_HypothesisCreator::CreateHypothesis + (bool isAlgo, QWidget* parent) +{ + MESSAGE("StdMeshersGUI_HypothesisCreator::CreateHypothesis"); + + // Get default name for hypothesis/algorithm creation + char* sHypType = (char*)myHypType.latin1(); + HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); + QString aHypName; + if (aHypData) + aHypName = aHypData->Label; + else + aHypName = myHypType; + + // Create hypothesis/algorithm + if (isAlgo) + { + mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); + } + else + { + // Show Dialog for hypothesis creation + if (myHypType == "LocalLength") + StdMeshersGUI_LocalLengthDlg *aDlg = new StdMeshersGUI_LocalLengthDlg(myHypType, parent, ""); + else if (myHypType == "NumberOfSegments") + StdMeshersGUI_NbSegmentsDlg *aDlg = new StdMeshersGUI_NbSegmentsDlg(myHypType, parent, ""); + else if (myHypType == "MaxElementArea") + StdMeshersGUI_MaxElementAreaDlg *aDlg = new StdMeshersGUI_MaxElementAreaDlg(myHypType, parent, ""); + else if (myHypType == "MaxElementVolume") + StdMeshersGUI_MaxElementVolumeDlg *aDlg = new StdMeshersGUI_MaxElementVolumeDlg(myHypType, parent, ""); + else if (myHypType == "LengthFromEdges") + mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI + else if (myHypType == "NotConformAllowed") + mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI + else ; + } +} + +//============================================================================= +/*! HypothesisCreator::EditHypothesis + * + */ +//============================================================================= +void StdMeshersGUI_HypothesisCreator::EditHypothesis + (SMESH::SMESH_Hypothesis_ptr theHyp) +{ + MESSAGE("StdMeshersGUI_HypothesisCreator::EditHypothesis"); + + Standard_Boolean res = Standard_True; + SALOMEDS::Study::ListOfSObject_var listSOmesh = + mySMESHGUI->GetMeshesUsingAlgoOrHypothesis(theHyp); + QString Name = theHyp->GetName(); + if (Name.compare("LocalLength") == 0) + { + StdMeshers::StdMeshers_LocalLength_var LL = + StdMeshers::StdMeshers_LocalLength::_narrow(theHyp); + double beforeLength = LL->GetLength() ; + double Length = mySMESHGUI->Parameter(res, + beforeLength, + QObject::tr("SMESH_LOCAL_LENGTH_HYPOTHESIS"), + QObject::tr("SMESH_VALUE"), + 1.0E-5, 1E6, 6); + if (res && Length != beforeLength) + { + LL->SetLength(Length); + for (int i=0; ilength(); i++) + { + mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false); + } + } + } + else if (Name.compare("NumberOfSegments") == 0) + { + StdMeshers::StdMeshers_NumberOfSegments_var NOS = + StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp); + int beforeNbSeg = NOS->GetNumberOfSegments() ; + int NbSeg = mySMESHGUI->Parameter(res, + beforeNbSeg, + QObject::tr("SMESH_NB_SEGMENTS_HYPOTHESIS"), + QObject::tr("SMESH_VALUE"), + 1, 1000000); + if (res && NbSeg != beforeNbSeg) + { + NOS->SetNumberOfSegments(NbSeg); + for (int i=0; ilength(); i++) + { + SALOMEDS::SObject_var SO = listSOmesh[i] ; + mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false); + } + } + } + else if (Name.compare("MaxElementArea") == 0) + { + StdMeshers::StdMeshers_MaxElementArea_var MEA = + StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp); + double beforeMaxArea = MEA->GetMaxElementArea(); + double MaxArea = mySMESHGUI->Parameter(res, + beforeMaxArea, + QObject::tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"), + QObject::tr("SMESH_VALUE"), + 1.0E-5, 1E6, 6); + if (res && MaxArea != beforeMaxArea) + { + MEA->SetMaxElementArea(MaxArea); + for (int i=0; ilength(); i++) + { + mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false); + } + } + } + else if (Name.compare("MaxElementVolume") == 0) + { + StdMeshers::StdMeshers_MaxElementVolume_var MEV = + StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp); + double beforeMaxVolume = MEV->GetMaxElementVolume() ; + double MaxVolume = mySMESHGUI->Parameter(res, + beforeMaxVolume, + QObject::tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"), + QObject::tr("SMESH_VALUE"), + 1.0E-5, 1E6, 6); + if (res && MaxVolume != beforeMaxVolume) + { + MEV->SetMaxElementVolume(MaxVolume); + for (int i=0; ilength(); i++) + { + mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false); + } + } + } +// else if (Name.compare("Regular_1D") == 0) +// {} +// else if (Name.compare("MEFISTO_2D") == 0) +// {} + else + {} +} + +//============================================================================= +/*! GetHypothesisCreator + * + */ +//============================================================================= +extern "C" +{ + SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator + (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI) + { + return new StdMeshersGUI_HypothesisCreator + (aHypType, aServerLibName, aSMESHGUI); + } +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.cxx new file mode 100644 index 000000000..60e1d42e6 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.cxx @@ -0,0 +1,289 @@ +// SMESH StdMeshersGUI : GUI for StdMeshers plugin +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_LocalLengthDlg.cxx +// Moved here from SMESHGUI_LocalLengthDlg.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshersGUI_LocalLengthDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "QAD_MessageBox.h" +#include "QAD_WaitCursor.h" + +// QT Includes +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : StdMeshersGUI_LocalLengthDlg() +// purpose : Constructs a StdMeshersGUI_LocalLengthDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +StdMeshersGUI_LocalLengthDlg::StdMeshersGUI_LocalLengthDlg (const QString& hypType, + QWidget* parent, + const char* name, + bool modal, + WFlags fl) + : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + myHypType(hypType) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_LOCAL_LENGTH"))); + + if ( !name ) + setName( "StdMeshersGUI_LocalLengthDlg" ); + setCaption( tr( "SMESH_LOCAL_LENGTH_TITLE" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* StdMeshersGUI_LocalLengthDlgLayout = new QGridLayout( this ); + StdMeshersGUI_LocalLengthDlgLayout->setSpacing( 6 ); + StdMeshersGUI_LocalLengthDlgLayout->setMargin( 11 ); + + /***************************************************************/ + iconLabel = new QLabel( this ); + iconLabel->setPixmap( image0 ); + iconLabel->setScaledContents( false ); + iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + typeLabel = new QLabel( this ); + typeLabel->setText( tr( "SMESH_LOCAL_LENGTH_HYPOTHESIS" ) ); + StdMeshersGUI_LocalLengthDlgLayout->addWidget( iconLabel, 0, 0 ); + StdMeshersGUI_LocalLengthDlgLayout->addWidget( typeLabel, 0, 1 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); + TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); + + LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); + GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); + + TextLabel_Length = new QLabel(GroupC1 , "TextLabel_Length" ); + TextLabel_Length->setText( tr( "SMESH_LENGTH" ) ); + GroupC1Layout->addWidget( TextLabel_Length, 1, 0 ); + + SpinBox_Length = new SMESHGUI_SpinBox( GroupC1, "SpinBox_Length" ); + GroupC1Layout->addWidget( SpinBox_Length, 1, 1 ); + + StdMeshersGUI_LocalLengthDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + StdMeshersGUI_LocalLengthDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 ); + + /***************************************************************/ + Init() ; +} + + +//================================================================================= +// function : ~StdMeshersGUI_LocalLengthDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +StdMeshersGUI_LocalLengthDlg::~StdMeshersGUI_LocalLengthDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void StdMeshersGUI_LocalLengthDlg::Init() +{ + /* min, max, step and decimals for spin boxes */ + SpinBox_Length->RangeStepAndValidator( 0.001, 999.999, 1.0, 3 ) ; + SpinBox_Length->SetValue( 1.0 ) ; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + + char* sHypType = (char*)myHypType.latin1(); + HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); + LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : "" ); + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); + connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ; + connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void StdMeshersGUI_LocalLengthDlg::ClickOnOk() +{ + if ( this->ClickOnApply() ) + this->ClickOnCancel() ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool StdMeshersGUI_LocalLengthDlg::ClickOnApply() +{ + QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); + if ( myHypName.isEmpty() ) { + QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); + return false; + } + + double myLength = SpinBox_Length->GetValue(); + + QAD_WaitCursor wc; + try { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow + (mySMESHGUI->CreateHypothesis(myHypType, + myHypName, + false)); // isAlgorithm + StdMeshers::StdMeshers_LocalLength_var LL = + StdMeshers::StdMeshers_LocalLength::_narrow(Hyp); + if (!LL->_is_nil()) + LL->SetLength(myLength); + } + catch (const SALOME::SALOME_Exception& S_ex) { + wc.stop(); + QtCatchCorbaException(S_ex); + return false; + } + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void StdMeshersGUI_LocalLengthDlg::ClickOnCancel() +{ + close(); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_LocalLengthDlg::DeactivateActiveDialog() +{ + iconLabel->setEnabled(false) ; + typeLabel->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_LocalLengthDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + iconLabel->setEnabled(true) ; + typeLabel->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_LocalLengthDlg::enterEvent(QEvent* e) +{ + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_LocalLengthDlg::closeEvent( QCloseEvent* e ) +{ + mySMESHGUI->ResetState(); + QDialog::closeEvent( e ); +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.h b/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.h new file mode 100644 index 000000000..8b3dda580 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.h @@ -0,0 +1,89 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_LocalLengthDlg.h +// Moved here from SMESHGUI_LocalLengthDlg.h +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#ifndef DIALOGBOX_LOCAL_LENGTH_H +#define DIALOGBOX_LOCAL_LENGTH_H + +// QT Includes +#include + +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class SMESHGUI; +class SMESHGUI_SpinBox; + +//================================================================================= +// class : StdMeshersGUI_LocalLengthDlg +// purpose : +//================================================================================= +class StdMeshersGUI_LocalLengthDlg : public QDialog +{ + Q_OBJECT + +public: + StdMeshersGUI_LocalLengthDlg (const QString& hypType, + QWidget* parent = 0, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); + ~StdMeshersGUI_LocalLengthDlg (); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + QString myHypType ; + + QLabel* iconLabel; + QLabel* typeLabel; + QGroupBox* GroupC1; + QLabel* TextLabel_NameHypothesis ; + QLineEdit* LineEdit_NameHypothesis ; + QLabel* TextLabel_Length ; + SMESHGUI_SpinBox* SpinBox_Length ; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonApply; + QPushButton* buttonCancel; + +private slots: + + void ClickOnOk(); + void ClickOnCancel(); + bool ClickOnApply(); + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; +}; + +#endif // DIALOGBOX_LOCAL_LENGTH_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.cxx new file mode 100644 index 000000000..ae99f6e26 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.cxx @@ -0,0 +1,291 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_MaxElementAreaDlg.cxx +// Moved here from SMESHGUI_MaxElementAreaDlg.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshersGUI_MaxElementAreaDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "QAD_MessageBox.h" +#include "QAD_WaitCursor.h" + +// QT Includes +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : StdMeshersGUI_MaxElementAreaDlg() +// purpose : Constructs a StdMeshersGUI_MaxElementAreaDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +StdMeshersGUI_MaxElementAreaDlg::StdMeshersGUI_MaxElementAreaDlg (const QString& hypType, + QWidget* parent, + const char* name, + bool modal, + WFlags fl) + : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + myHypType(hypType) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_MAX_ELEMENT_AREA"))); + + if ( !name ) + setName( "StdMeshersGUI_MaxElementAreaDlg" ); + setCaption( tr( "SMESH_MAX_ELEMENT_AREA_TITLE" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* StdMeshersGUI_MaxElementAreaDlgLayout = new QGridLayout( this ); + StdMeshersGUI_MaxElementAreaDlgLayout->setSpacing( 6 ); + StdMeshersGUI_MaxElementAreaDlgLayout->setMargin( 11 ); + + /***************************************************************/ + iconLabel = new QLabel( this ); + iconLabel->setPixmap( image0 ); + iconLabel->setScaledContents( false ); + iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + typeLabel = new QLabel( this ); + typeLabel->setText( tr( "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS" ) ); + StdMeshersGUI_MaxElementAreaDlgLayout->addWidget( iconLabel, 0, 0 ); + StdMeshersGUI_MaxElementAreaDlgLayout->addWidget( typeLabel, 0, 1 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); + TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); + + LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); + GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); + + TextLabel_MaxElementArea = new QLabel(GroupC1 , "TextLabel_MaxElementArea" ); + TextLabel_MaxElementArea->setText( tr( "SMESH_MAX_ELEMENT_AREA" ) ); + GroupC1Layout->addWidget( TextLabel_MaxElementArea, 1, 0 ); + + SpinBox_MaxElementArea = new SMESHGUI_SpinBox( GroupC1, "SpinBox_MaxElementArea" ) ; + GroupC1Layout->addWidget( SpinBox_MaxElementArea, 1, 1 ); + + StdMeshersGUI_MaxElementAreaDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + StdMeshersGUI_MaxElementAreaDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 ); + + /***************************************************************/ + Init() ; +} + + +//================================================================================= +// function : ~StdMeshersGUI_MaxElementAreaDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +StdMeshersGUI_MaxElementAreaDlg::~StdMeshersGUI_MaxElementAreaDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementAreaDlg::Init() +{ + /* min, max, step and decimals for spin boxes */ + SpinBox_MaxElementArea->setPrecision( 10 ); + SpinBox_MaxElementArea->RangeStepAndValidator( 0.001, 999999.999, 1.0, 3 ) ; + SpinBox_MaxElementArea->SetValue( 1.0 ) ; /* is myMaxElementArea */ + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + + char* sHypType = (char*)myHypType.latin1(); + HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); + LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : "" ); + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); + connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ; + connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementAreaDlg::ClickOnOk() +{ + if ( this->ClickOnApply() ) + this->ClickOnCancel() ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool StdMeshersGUI_MaxElementAreaDlg::ClickOnApply() +{ + QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); + if ( myHypName.isEmpty() ) { + QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); + return false; + } + + double myMaxElementArea = SpinBox_MaxElementArea->GetValue(); + + QAD_WaitCursor wc; + try { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow + (mySMESHGUI->CreateHypothesis(myHypType, + myHypName, + false)); // isAlgorithm + StdMeshers::StdMeshers_MaxElementArea_var MaxElArea = + StdMeshers::StdMeshers_MaxElementArea::_narrow(Hyp); + if (!MaxElArea->_is_nil()) + MaxElArea->SetMaxElementArea(myMaxElementArea); + } + catch (const SALOME::SALOME_Exception& S_ex) { + wc.stop(); + QtCatchCorbaException(S_ex); + return false; + } + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementAreaDlg::ClickOnCancel() +{ + close(); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementAreaDlg::DeactivateActiveDialog() +{ + iconLabel->setEnabled(false) ; + typeLabel->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementAreaDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + iconLabel->setEnabled(true) ; + typeLabel->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementAreaDlg::enterEvent(QEvent* e) +{ + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementAreaDlg::closeEvent( QCloseEvent* e ) +{ + mySMESHGUI->ResetState(); + QDialog::closeEvent( e ); +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.h b/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.h new file mode 100644 index 000000000..e95f3cb08 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.h @@ -0,0 +1,89 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_MaxElementAreaDlg.h +// Moved here from SMESHGUI_MaxElementAreaDlg.h +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#ifndef DIALOGBOX_MAX_ELEMENT_AREA_H +#define DIALOGBOX_MAX_ELEMENT_AREA_H + +// QT Includes +#include + +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class SMESHGUI; +class SMESHGUI_SpinBox; + +//================================================================================= +// class : StdMeshersGUI_MaxElementAreaDlg +// purpose : +//================================================================================= +class StdMeshersGUI_MaxElementAreaDlg : public QDialog +{ + Q_OBJECT + +public: + StdMeshersGUI_MaxElementAreaDlg (const QString& hypType, + QWidget* parent = 0, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0 ); + ~StdMeshersGUI_MaxElementAreaDlg (); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + QString myHypType ; + + QLabel* iconLabel; + QLabel* typeLabel; + QGroupBox* GroupC1; + QLabel* TextLabel_NameHypothesis ; + QLineEdit* LineEdit_NameHypothesis ; + QLabel* TextLabel_MaxElementArea ; + SMESHGUI_SpinBox* SpinBox_MaxElementArea ; + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ClickOnOk(); + void ClickOnCancel(); + bool ClickOnApply(); + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; +}; + +#endif // DIALOGBOX_MAX_ELEMENT_AREA_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.cxx new file mode 100644 index 000000000..c5a75ee13 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.cxx @@ -0,0 +1,290 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_MaxElementVolumeDlg.cxx +// Moved here from SMESHGUI_MaxElementVolumeDlg.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshersGUI_MaxElementVolumeDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "QAD_MessageBox.h" +#include "QAD_WaitCursor.h" + +// QT Includes +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : StdMeshersGUI_MaxElementVolumeDlg() +// purpose : Constructs a StdMeshersGUI_MaxElementVolumeDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +StdMeshersGUI_MaxElementVolumeDlg::StdMeshersGUI_MaxElementVolumeDlg (const QString& hypType, + QWidget* parent, + const char* name, + bool modal, WFlags fl) + : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + myHypType(hypType) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_MAX_ELEMENT_VOLUME"))); + + if ( !name ) + setName( "StdMeshersGUI_MaxElementVolumeDlg" ); + setCaption( tr( "SMESH_MAX_ELEMENT_VOLUME_TITLE" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* StdMeshersGUI_MaxElementVolumeDlgLayout = new QGridLayout( this ); + StdMeshersGUI_MaxElementVolumeDlgLayout->setSpacing( 6 ); + StdMeshersGUI_MaxElementVolumeDlgLayout->setMargin( 11 ); + + /***************************************************************/ + iconLabel = new QLabel( this ); + iconLabel->setPixmap( image0 ); + iconLabel->setScaledContents( false ); + iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + typeLabel = new QLabel( this ); + typeLabel->setText( tr( "SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS" ) ); + StdMeshersGUI_MaxElementVolumeDlgLayout->addWidget( iconLabel, 0, 0 ); + StdMeshersGUI_MaxElementVolumeDlgLayout->addWidget( typeLabel, 0, 1 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + StdMeshersGUI_MaxElementVolumeDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); + TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); + + LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); + GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); + + TextLabel_MaxElementVolume = new QLabel(GroupC1 , "TextLabel_MaxElementVolume" ); + TextLabel_MaxElementVolume->setText( tr( "SMESH_MAX_ELEMENT_VOLUME" ) ); + GroupC1Layout->addWidget( TextLabel_MaxElementVolume, 1, 0 ); + + SpinBox_MaxElementVolume = new SMESHGUI_SpinBox( GroupC1, "SpinBox_MaxElementVolume" ) ; + GroupC1Layout->addWidget( SpinBox_MaxElementVolume, 1, 1 ); + + StdMeshersGUI_MaxElementVolumeDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 ); + + /***************************************************************/ + Init() ; +} + + +//================================================================================= +// function : ~StdMeshersGUI_MaxElementVolumeDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +StdMeshersGUI_MaxElementVolumeDlg::~StdMeshersGUI_MaxElementVolumeDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementVolumeDlg::Init() +{ + /* min, max, step and decimals for spin boxes */ + SpinBox_MaxElementVolume->setPrecision( 10 ); + SpinBox_MaxElementVolume->RangeStepAndValidator( 0.001, 999999.999, 1.0, 3 ) ; + SpinBox_MaxElementVolume->SetValue( 1.0 ) ; /* is myMaxElementVolume */ + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + + char* sHypType = (char*)myHypType.latin1(); + HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); + LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : "" ); + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); + connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ; + connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementVolumeDlg::ClickOnOk() +{ + if ( this->ClickOnApply() ) + this->ClickOnCancel() ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool StdMeshersGUI_MaxElementVolumeDlg::ClickOnApply() +{ + QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); + if ( myHypName.isEmpty() ) { + QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); + return false; + } + + double myMaxElementVolume = SpinBox_MaxElementVolume->GetValue(); + + QAD_WaitCursor wc; + try { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow + (mySMESHGUI->CreateHypothesis(myHypType, + myHypName, + false)); // isAlgorithm + StdMeshers::StdMeshers_MaxElementVolume_var MaxElVolume = + StdMeshers::StdMeshers_MaxElementVolume::_narrow(Hyp); + if (!MaxElVolume->_is_nil()) + MaxElVolume->SetMaxElementVolume(myMaxElementVolume); + } + catch (const SALOME::SALOME_Exception& S_ex) { + wc.stop(); + QtCatchCorbaException(S_ex); + return false; + } + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementVolumeDlg::ClickOnCancel() +{ + close(); +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementVolumeDlg::DeactivateActiveDialog() +{ + iconLabel->setEnabled(false) ; + typeLabel->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementVolumeDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + iconLabel->setEnabled(true) ; + typeLabel->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementVolumeDlg::enterEvent(QEvent* e) +{ + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_MaxElementVolumeDlg::closeEvent( QCloseEvent* e ) +{ + mySMESHGUI->ResetState(); + QDialog::closeEvent( e ); +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.h b/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.h new file mode 100644 index 000000000..b31215777 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.h @@ -0,0 +1,89 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_MaxElementVolumeDlg.h +// Moved here from SMESHGUI_MaxElementVolumeDlg.h +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#ifndef DIALOGBOX_MAX_ELEMENT_VOLUME_H +#define DIALOGBOX_MAX_ELEMENT_VOLUME_H + +// QT Includes +#include + +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class SMESHGUI; +class SMESHGUI_SpinBox; + +//================================================================================= +// class : StdMeshersGUI_MaxElementVolumeDlg +// purpose : +//================================================================================= +class StdMeshersGUI_MaxElementVolumeDlg : public QDialog +{ + Q_OBJECT + +public: + StdMeshersGUI_MaxElementVolumeDlg (const QString& hypType, + QWidget* parent = 0, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0 ); + ~StdMeshersGUI_MaxElementVolumeDlg (); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + QString myHypType ; + + QLabel* iconLabel; + QLabel* typeLabel; + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QGroupBox* GroupC1; + QLabel* TextLabel_NameHypothesis ; + QLineEdit* LineEdit_NameHypothesis ; + QLabel* TextLabel_MaxElementVolume ; + SMESHGUI_SpinBox* SpinBox_MaxElementVolume ; + +private slots: + + void ClickOnOk(); + void ClickOnCancel(); + bool ClickOnApply(); + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; +}; + +#endif // DIALOGBOX_MAX_ELEMENT_VOLUME_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.cxx new file mode 100644 index 000000000..6798c381a --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.cxx @@ -0,0 +1,289 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_NbSegmentsDlg.cxx +// Moved here from SMESHGUI_NbSegmentsDlg.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshersGUI_NbSegmentsDlg.h" +#include "SMESHGUI.h" + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "QAD_MessageBox.h" +#include "QAD_WaitCursor.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include + +//================================================================================= +// class : StdMeshersGUI_NbSegmentsDlg() +// purpose : Constructs a StdMeshersGUI_NbSegmentsDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +StdMeshersGUI_NbSegmentsDlg::StdMeshersGUI_NbSegmentsDlg (const QString& hypType, + QWidget* parent, + const char* name, + bool modal, + WFlags fl) + : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), + myHypType(hypType) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_NB_SEGMENTS"))); + + if ( !name ) + setName( "StdMeshersGUI_NbSegmentsDlg" ); + setCaption( tr( "SMESH_NB_SEGMENTS_TITLE" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* StdMeshersGUI_NbSegmentsDlgLayout = new QGridLayout( this ); + StdMeshersGUI_NbSegmentsDlgLayout->setSpacing( 6 ); + StdMeshersGUI_NbSegmentsDlgLayout->setMargin( 11 ); + + /***************************************************************/ + iconLabel = new QLabel( this ); + iconLabel->setPixmap( image0 ); + iconLabel->setScaledContents( false ); + iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + typeLabel = new QLabel( this ); + typeLabel->setText( tr( "SMESH_NB_SEGMENTS_HYPOTHESIS" ) ); + StdMeshersGUI_NbSegmentsDlgLayout->addWidget( iconLabel, 0, 0 ); + StdMeshersGUI_NbSegmentsDlgLayout->addWidget( typeLabel, 0, 1 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); + GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); + + TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); + TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); + + TextLabel_NbSeg = new QLabel(GroupC1 , "TextLabel_NbSeg" ); + TextLabel_NbSeg->setText( tr( "SMESH_SEGMENTS" ) ); + GroupC1Layout->addWidget( TextLabel_NbSeg, 1, 0 ); + + SpinBox_NbSeg = new QSpinBox( GroupC1, "SpinBox_NbSeg" ); + GroupC1Layout->addWidget( SpinBox_NbSeg, 1, 1 ); + + StdMeshersGUI_NbSegmentsDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + StdMeshersGUI_NbSegmentsDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 ); + + /***************************************************************/ + Init() ; +} + + +//================================================================================= +// function : ~StdMeshersGUI_NbSegmentsDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +StdMeshersGUI_NbSegmentsDlg::~StdMeshersGUI_NbSegmentsDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void StdMeshersGUI_NbSegmentsDlg::Init() +{ + SpinBox_NbSeg->setMinValue( 1 ); + SpinBox_NbSeg->setMaxValue( 9999 ); + SpinBox_NbSeg->setValue(3) ; /* myNbSeg */ + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + + char* sHypType = (char*)myHypType.latin1(); + HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); + LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : "" ); + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + /* signals and slots connections */ + connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); + connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ; + connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void StdMeshersGUI_NbSegmentsDlg::ClickOnOk() +{ + if ( this->ClickOnApply() ) + this->ClickOnCancel() ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool StdMeshersGUI_NbSegmentsDlg::ClickOnApply() +{ + QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); + if ( myHypName.isEmpty() ) { + QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); + return false; + } + + long myNbSeg = SpinBox_NbSeg->value(); + + QAD_WaitCursor wc; + try { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow + (mySMESHGUI->CreateHypothesis(myHypType, + myHypName, + false)); // isAlgorithm + StdMeshers::StdMeshers_NumberOfSegments_var NbS = + StdMeshers::StdMeshers_NumberOfSegments::_narrow(Hyp); + if (!NbS->_is_nil()) + NbS->SetNumberOfSegments(myNbSeg); + } + catch (const SALOME::SALOME_Exception& S_ex) { + wc.stop(); + QtCatchCorbaException(S_ex); + return false; + } + return true; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void StdMeshersGUI_NbSegmentsDlg::ClickOnCancel() +{ + close(); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_NbSegmentsDlg::DeactivateActiveDialog() +{ + iconLabel->setEnabled(false) ; + typeLabel->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_NbSegmentsDlg::ActivateThisDialog() +{ + mySMESHGUI->EmitSignalDeactivateDialog() ; + iconLabel->setEnabled(true) ; + typeLabel->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_NbSegmentsDlg::enterEvent(QEvent* e) +{ + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_NbSegmentsDlg::closeEvent( QCloseEvent* e ) +{ + mySMESHGUI->ResetState(); + QDialog::closeEvent( e ); +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.h b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.h new file mode 100644 index 000000000..3594ac960 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.h @@ -0,0 +1,89 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_NbSegmentsDlg.h +// Moved here from SMESHGUI_NbSegmentsDlg.h +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#ifndef DIALOGBOX_NB_SEGMENTS_H +#define DIALOGBOX_NB_SEGMENTS_H + +// QT Includes +#include + +class QGroupBox; +class QLabel; +class QLineEdit; +class QSpinBox; +class QPushButton; +class SMESHGUI; + +//================================================================================= +// class : StdMeshersGUI_NbSegmentsDlg +// purpose : +//================================================================================= +class StdMeshersGUI_NbSegmentsDlg : public QDialog +{ + Q_OBJECT + +public: + StdMeshersGUI_NbSegmentsDlg (const QString& hypType, + QWidget* parent = 0, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); + ~StdMeshersGUI_NbSegmentsDlg (); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + + SMESHGUI* mySMESHGUI ; + QString myHypType ; + + QLabel* iconLabel; + QLabel* typeLabel; + QGroupBox* GroupC1; + QLabel* TextLabel_NameHypothesis ; + QLineEdit* LineEdit_NameHypothesis ; + QLabel* TextLabel_NbSeg ; + QSpinBox* SpinBox_NbSeg ; + QGroupBox* GroupButtons; + QPushButton* buttonApply; + QPushButton* buttonOk; + QPushButton* buttonCancel; + +private slots: + + void ClickOnOk(); + void ClickOnCancel(); + bool ClickOnApply(); + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; +}; + +#endif // DIALOGBOX_NB_SEGMENTS_H diff --git a/src/StdMeshersGUI/StdMeshers_icons.po b/src/StdMeshersGUI/StdMeshers_icons.po new file mode 100644 index 000000000..c021365cd --- /dev/null +++ b/src/StdMeshersGUI/StdMeshers_icons.po @@ -0,0 +1,81 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:57:43 AM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +#Select Icon +msgid "ICON_SELECT" +msgstr "select1.png" + + +#----------------------------------------------------------- +# Hypothesis +#----------------------------------------------------------- + +#Hypo Local Length +msgid "ICON_DLG_LOCAL_LENGTH" +msgstr "mesh_hypo_length.png" + +#Hypo Nb Segments +msgid "ICON_DLG_NB_SEGMENTS" +msgstr "mesh_hypo_segment.png" + +#Hypo Max Area +msgid "ICON_DLG_MAX_ELEMENT_AREA" +msgstr "mesh_hypo_area.png" + +#Hypo Max Volume +msgid "ICON_DLG_MAX_ELEMENT_VOLUME" +msgstr "mesh_hypo_volume.png" + + +#----------------------------------------------------------- +# ObjectBrowser +#----------------------------------------------------------- + +#mesh_tree_algo_regular +msgid "ICON_SMESH_TREE_ALGO_Regular_1D" +msgstr "mesh_tree_algo_regular.png" + +#mesh_tree_algo_hexa +msgid "ICON_SMESH_TREE_ALGO_Hexa_3D" +msgstr "mesh_tree_algo_hexa.png" + +#mesh_tree_algo_mefisto +msgid "ICON_SMESH_TREE_ALGO_MEFISTO_2D" +msgstr "mesh_tree_algo_mefisto.png" + +#mesh_tree_algo_quad +msgid "ICON_SMESH_TREE_ALGO_Quadrangle_2D" +msgstr "mesh_tree_algo_quad.png" + +#mesh_tree_hypo_area +msgid "ICON_SMESH_TREE_HYPO_MaxElementArea" +msgstr "mesh_tree_hypo_area.png" + +#mesh_tree_hypo_length +msgid "ICON_SMESH_TREE_HYPO_LocalLength" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_segment +msgid "ICON_SMESH_TREE_HYPO_NumberOfSegments" +msgstr "mesh_tree_hypo_segment.png" + +#mesh_tree_hypo_volume +msgid "ICON_SMESH_TREE_HYPO_MaxElementVolume" +msgstr "mesh_tree_hypo_volume.png" + +#mesh_tree_hypo_length +msgid "ICON_SMESH_TREE_HYPO_LengthFromEdges" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_nonconform +msgid "ICON_SMESH_TREE_HYPO_NotConformAllowed" +msgstr "mesh_tree_hypo_length.png" diff --git a/src/StdMeshersGUI/StdMeshers_msg_en.po b/src/StdMeshersGUI/StdMeshers_msg_en.po new file mode 100644 index 000000000..cc6173b71 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshers_msg_en.po @@ -0,0 +1,49 @@ +# This is a Qt message file in .po format. Each msgid starts with +# a scope. This scope should *NOT* be translated - eg. "Foo::Bar" +# would be translated to "Pub", not "Foo::Pub". +msgid "" +msgstr "" +"Project-Id-Version: PROJECT VERSION\n" +"POT-Creation-Date: 2002-05-28 10:46:48 AM CEST\n" +"PO-Revision-Date: YYYY-MM-DD\n" +"Last-Translator: FULLNAME \n" +"Content-Type: text/plain; charset=iso-8859-1\n" + + +# -------------- Local Length -------------- + +msgid "SMESH_LOCAL_LENGTH_HYPOTHESIS" +msgstr "Local Length" + +msgid "SMESH_LOCAL_LENGTH_TITLE" +msgstr "Hypothesis Construction" + +# ----------- Number of Segments ----------- + +msgid "SMESH_NB_SEGMENTS_HYPOTHESIS" +msgstr "Number of Segments" + +msgid "SMESH_NB_SEGMENTS_TITLE" +msgstr "Hypothesis Construction" + +# ----------- Max. Element Area ------------ + +msgid "SMESH_MAX_ELEMENT_AREA" +msgstr "Max. Area" + +msgid "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS" +msgstr "Max. Element Area" + +msgid "SMESH_MAX_ELEMENT_AREA_TITLE" +msgstr "Hypothesis Construction" + +# ---------- Max. Element Volume ----------- + +msgid "SMESH_MAX_ELEMENT_VOLUME" +msgstr "Max. Volume" + +msgid "SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS" +msgstr "Max. Element Volume" + +msgid "SMESH_MAX_ELEMENT_VOLUME_TITLE" +msgstr "Hypothesis Construction" diff --git a/src/StdMeshers_I/Makefile.in b/src/StdMeshers_I/Makefile.in new file mode 100644 index 000000000..5891f6e80 --- /dev/null +++ b/src/StdMeshers_I/Makefile.in @@ -0,0 +1,76 @@ +# SMESH StdMeshers_I : idl implementation based on 'StdMeshersPlugin' unit's classes +# +# Copyright (C) 2003 CEA +# +# 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.org +# +# +# +# File : Makefile.in +# Author : Julia DOROVSKIKH +# Module : SMESH +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl + + +@COMMENCE@ + +# EXPORT_PYSCRIPTS = smeshpy.py SMESH_test.py + +# Libraries targets + +LIB= libStdMeshersEngine.la + +LIB_SRC = \ + StdMeshers_i.cxx \ + StdMeshers_LocalLength_i.cxx \ + StdMeshers_LengthFromEdges_i.cxx \ + StdMeshers_MaxElementArea_i.cxx \ + StdMeshers_MaxElementVolume_i.cxx \ + StdMeshers_NumberOfSegments_i.cxx \ + StdMeshers_NotConformAllowed_i.cxx \ + StdMeshers_Regular_1D_i.cxx \ + StdMeshers_Quadrangle_2D_i.cxx \ + StdMeshers_MEFISTO_2D_i.cxx \ + StdMeshers_Hexa_3D_i.cxx + +LIB_SERVER_IDL = SMESH_BasicHypothesis.idl + +LIB_CLIENT_IDL = \ + SALOMEDS.idl SALOME_Exception.idl \ + GEOM_Gen.idl GEOM_Shape.idl MED.idl SALOMEDS_Attributes.idl \ + SMESH_Gen.idl SMESH_Hypothesis.idl SMESH_Group.idl + +# Executables targets +BIN = +BIN_SRC = + +# additionnal information to compil and link file +CPPFLAGS+= $(OCC_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \ + -I${GEOM_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +CXXFLAGS+= $(OCC_CXXFLAGS) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome + +#IDLCXXFLAGS+= -Wbtp + +#LDFLAGS+= $(HDF5_LIBS) -lStdMeshers -lSMESHEngine -lSalomeLifeCycleCORBA -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeGenericObj +LDFLAGS+= $(HDF5_LIBS) -lStdMeshers -lSMESHEngine -L${KERNEL_ROOT_DIR}/lib/salome + +@CONCLUDE@ diff --git a/src/StdMeshers_I/StdMeshers_Hexa_3D_i.cxx b/src/StdMeshers_I/StdMeshers_Hexa_3D_i.cxx new file mode 100644 index 000000000..0ca4839ba --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Hexa_3D_i.cxx @@ -0,0 +1,84 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Hexa_3D_i.cxx +// Moved here from SMESH_Hexa_3D_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Hexa_3D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_Hexa_3D_i::StdMeshers_Hexa_3D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_Hexa_3D_i::StdMeshers_Hexa_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ), + SMESH_Algo_i( thePOA ), + SMESH_3D_Algo_i( thePOA ) +{ + MESSAGE( "StdMeshers_Hexa_3D_i::StdMeshers_Hexa_3D_i" ); + myBaseImpl = new ::StdMeshers_Hexa_3D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_Hexa_3D_i::~StdMeshers_Hexa_3D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_Hexa_3D_i::~StdMeshers_Hexa_3D_i() +{ + MESSAGE( "StdMeshers_Hexa_3D_i::~StdMeshers_Hexa_3D_i" ); +} + +//============================================================================= +/*! + * StdMeshers_Hexa_3D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_Hexa_3D* StdMeshers_Hexa_3D_i::GetImpl() +{ + MESSAGE( "StdMeshers_Hexa_3D_i::GetImpl" ); + return ( ::StdMeshers_Hexa_3D* )myBaseImpl; +} diff --git a/src/StdMeshers_I/StdMeshers_Hexa_3D_i.hxx b/src/StdMeshers_I/StdMeshers_Hexa_3D_i.hxx new file mode 100644 index 000000000..91bcabdb8 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Hexa_3D_i.hxx @@ -0,0 +1,61 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Hexa_3D_i.hxx +// Moved here from SMESH_Hexa_3D_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_HEXA_3D_I_HXX_ +#define _SMESH_HEXA_3D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_3D_Algo_i.hxx" +#include "StdMeshers_Hexa_3D.hxx" + +class SMESH_Gen; + +// ====================================================== +// Hexaedron 3d algorithm +// ====================================================== +class StdMeshers_Hexa_3D_i: + public virtual POA_StdMeshers::StdMeshers_Hexa_3D, + public virtual SMESH_3D_Algo_i +{ +public: + // Constructor + StdMeshers_Hexa_3D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + + // Destructor + virtual ~StdMeshers_Hexa_3D_i(); + + // Get implementation + ::StdMeshers_Hexa_3D* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.cxx b/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.cxx new file mode 100644 index 000000000..afcd3b14b --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.cxx @@ -0,0 +1,121 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_LengthFromEdges_i.cxx +// Moved here from SMESH_LengthFromEdges_i.cxx +// Author : Nadir BOUHAMOU CEA/DEN, Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_LengthFromEdges_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_LengthFromEdges_i::StdMeshers_LengthFromEdges_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_LengthFromEdges_i::StdMeshers_LengthFromEdges_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_LengthFromEdges_i::StdMeshers_LengthFromEdges_i" ); + myBaseImpl = new ::StdMeshers_LengthFromEdges( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_LengthFromEdges_i::~StdMeshers_LengthFromEdges_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_LengthFromEdges_i::~StdMeshers_LengthFromEdges_i() +{ + MESSAGE( "StdMeshers_LengthFromEdges_i::~StdMeshers_LengthFromEdges_i" ); +} + +//============================================================================= +/*! + * StdMeshers_LengthFromEdges_i::SetMode + * + * Set mode + */ +//============================================================================= + +void StdMeshers_LengthFromEdges_i::SetMode( CORBA::Long theMode ) + throw (SALOME::SALOME_Exception) +{ + MESSAGE( "StdMeshers_LengthFromEdges_i::SetMode" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetMode( theMode ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_LengthFromEdges_i::GetMode + * + * Get mode + */ +//============================================================================= + +CORBA::Long StdMeshers_LengthFromEdges_i::GetMode() +{ + MESSAGE( "StdMeshers_LengthFromEdges_i::GetMode" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetMode(); +} + + +//============================================================================= +/*! + * StdMeshers_LengthFromEdges_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_LengthFromEdges* StdMeshers_LengthFromEdges_i::GetImpl() +{ + MESSAGE( "StdMeshers_LengthFromEdges_i::GetImpl" ); + return ( ::StdMeshers_LengthFromEdges* )myBaseImpl; +} + diff --git a/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.hxx b/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.hxx new file mode 100644 index 000000000..2c988a1f0 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_LengthFromEdges_i.hxx @@ -0,0 +1,65 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_LengthFromEdges_i.hxx +// Moved here from SMESH_LengthFromEdges_i.hxx +// Author : Nadir BOUHAMOU CEA/DEN, Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_LENGTHFROMEDGES_I_HXX_ +#define _SMESH_LENGTHFROMEDGES_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_LengthFromEdges.hxx" + +// ====================================================== +// Length from edges hypothesis +// ====================================================== +class StdMeshers_LengthFromEdges_i: + public virtual POA_StdMeshers::StdMeshers_LengthFromEdges, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_LengthFromEdges_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_LengthFromEdges_i(); + + // Set mode + void SetMode( CORBA::Long theMode ) + throw ( SALOME::SALOME_Exception ); + // Get mode + CORBA::Long GetMode(); + + // Get implementation + ::StdMeshers_LengthFromEdges* GetImpl(); +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_LocalLength_i.cxx b/src/StdMeshers_I/StdMeshers_LocalLength_i.cxx new file mode 100644 index 000000000..15b3eb79f --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_LocalLength_i.cxx @@ -0,0 +1,119 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_LocalLength_i.cxx +// Moved here from SMESH_LocalLength_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_LocalLength_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_LocalLength_i::StdMeshers_LocalLength_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_LocalLength_i::StdMeshers_LocalLength_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_LocalLength_i::StdMeshers_LocalLength_i" ); + myBaseImpl = new ::StdMeshers_LocalLength( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_LocalLength_i::~StdMeshers_LocalLength_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_LocalLength_i::~StdMeshers_LocalLength_i() +{ + MESSAGE( "StdMeshers_LocalLength_i::~StdMeshers_LocalLength_i" ); +} + +//============================================================================= +/*! + * StdMeshers_LocalLength_i::SetLength + * + * Set length + */ +//============================================================================= + +void StdMeshers_LocalLength_i::SetLength( CORBA::Double theLength ) + throw ( SALOME::SALOME_Exception ) +{ + MESSAGE( "StdMeshers_LocalLength_i::SetLength" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetLength( theLength ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_LocalLength_i::GetLength + * + * Get length + */ +//============================================================================= + +CORBA::Double StdMeshers_LocalLength_i::GetLength() +{ + MESSAGE( "StdMeshers_LocalLength_i::GetLength" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetLength(); +} + +//============================================================================= +/*! + * StdMeshers_LocalLength_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_LocalLength* StdMeshers_LocalLength_i::GetImpl() +{ + MESSAGE( "StdMeshers_LocalLength_i::GetImpl" ); + return ( ::StdMeshers_LocalLength* )myBaseImpl; +} diff --git a/src/StdMeshers_I/StdMeshers_LocalLength_i.hxx b/src/StdMeshers_I/StdMeshers_LocalLength_i.hxx new file mode 100644 index 000000000..6b0b1dbf2 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_LocalLength_i.hxx @@ -0,0 +1,67 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_LocalLength_i.hxx +// Moved here from SMESH_LocalLength_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_LOCALLENGTH_I_HXX_ +#define _SMESH_LOCALLENGTH_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_LocalLength.hxx" + +class SMESH_Gen; + +// ====================================================== +// Local Length hypothesis +// ====================================================== +class StdMeshers_LocalLength_i: + public virtual POA_StdMeshers::StdMeshers_LocalLength, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_LocalLength_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_LocalLength_i(); + + // Set length + void SetLength( CORBA::Double theLength ) + throw ( SALOME::SALOME_Exception ); + // Get length + CORBA::Double GetLength(); + + // Get implementation + ::StdMeshers_LocalLength* GetImpl(); +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.cxx b/src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.cxx new file mode 100644 index 000000000..efcc37c5c --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.cxx @@ -0,0 +1,85 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MEFISTO_2D_i.cxx +// Moved here from SMESH_MEFISTO_2D_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_MEFISTO_2D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_MEFISTO_2D_i::StdMeshers_MEFISTO_2D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_MEFISTO_2D_i::StdMeshers_MEFISTO_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_MEFISTO_2D_i::StdMeshers_MEFISTO_2D_i" ); + myBaseImpl = new ::StdMeshers_MEFISTO_2D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_MEFISTO_2D_i::~StdMeshers_MEFISTO_2D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_MEFISTO_2D_i::~StdMeshers_MEFISTO_2D_i() +{ + MESSAGE( "StdMeshers_MEFISTO_2D_i::~StdMeshers_MEFISTO_2D_i" ); +} + +//============================================================================= +/*! + * StdMeshers_MEFISTO_2D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_MEFISTO_2D* StdMeshers_MEFISTO_2D_i::GetImpl() +{ + MESSAGE( "StdMeshers_MEFISTO_2D_i::GetImpl" ); + return ( ::StdMeshers_MEFISTO_2D* )myBaseImpl; +} + diff --git a/src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.hxx b/src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.hxx new file mode 100644 index 000000000..d7021df8a --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_MEFISTO_2D_i.hxx @@ -0,0 +1,61 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MEFISTO_2D_i.hxx +// Moved here from SMESH_MEFISTO_2D_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _StdMeshers_MEFISTO_2D_I_HXX_ +#define _StdMeshers_MEFISTO_2D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_2D_Algo_i.hxx" +#include "StdMeshers_MEFISTO_2D.hxx" + +class SMESH_Gen; + +// ====================================================== +// Triangle (MEFISTO) 2d algorithm +// ====================================================== +class StdMeshers_MEFISTO_2D_i: + public virtual POA_StdMeshers::StdMeshers_MEFISTO_2D, + public virtual SMESH_2D_Algo_i +{ +public: + // Constructor + StdMeshers_MEFISTO_2D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + + // Destructor + virtual ~StdMeshers_MEFISTO_2D_i(); + + // Get implementation + ::StdMeshers_MEFISTO_2D* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_MaxElementArea_i.cxx b/src/StdMeshers_I/StdMeshers_MaxElementArea_i.cxx new file mode 100644 index 000000000..51810e0a7 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_MaxElementArea_i.cxx @@ -0,0 +1,119 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MaxElementArea_i.cxx +// Moved here from SMESH_MaxElementArea_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_MaxElementArea_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_MaxElementArea_i::StdMeshers_MaxElementArea_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_MaxElementArea_i::StdMeshers_MaxElementArea_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_MaxElementArea_i::StdMeshers_MaxElementArea_i" ); + myBaseImpl = new ::StdMeshers_MaxElementArea( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_MaxElementArea_i::~StdMeshers_MaxElementArea_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_MaxElementArea_i::~StdMeshers_MaxElementArea_i() +{ + MESSAGE( "StdMeshers_MaxElementArea_i::~StdMeshers_MaxElementArea_i" ); +} + +//============================================================================= +/*! + * StdMeshers_MaxElementArea_i::SetMaxElementArea + * + * Set maximum element area + */ +//============================================================================= + +void StdMeshers_MaxElementArea_i::SetMaxElementArea( CORBA::Double theArea ) + throw ( SALOME::SALOME_Exception ) +{ + MESSAGE( "StdMeshers_MaxElementArea_i::SetMaxElementArea" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetMaxArea( theArea ); + } + catch (SALOME_Exception& S_ex) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_MaxElementArea_i::GetMaxElementArea + * + * Get maximum element area + */ +//============================================================================= + +CORBA::Double StdMeshers_MaxElementArea_i::GetMaxElementArea() +{ + MESSAGE( "StdMeshers_MaxElementArea_i::GetMaxElementArea" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetMaxArea(); +} + +//============================================================================= +/*! + * StdMeshers_MaxElementArea_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_MaxElementArea* StdMeshers_MaxElementArea_i::GetImpl() +{ + MESSAGE( "StdMeshers_MaxElementArea_i::GetImpl" ); + return ( ::StdMeshers_MaxElementArea* )myBaseImpl; +} diff --git a/src/StdMeshers_I/StdMeshers_MaxElementArea_i.hxx b/src/StdMeshers_I/StdMeshers_MaxElementArea_i.hxx new file mode 100644 index 000000000..da21f809c --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_MaxElementArea_i.hxx @@ -0,0 +1,64 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MaxElementArea_i.hxx +// Moved here from SMESH_MaxElementArea_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_MAXELEMENTAREA_I_HXX_ +#define _SMESH_MAXELEMENTAREA_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_MaxElementArea.hxx" + +// ====================================================== +// Maximum Element Area hypothesis +// ====================================================== +class StdMeshers_MaxElementArea_i: + public virtual POA_StdMeshers::StdMeshers_MaxElementArea, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_MaxElementArea_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_MaxElementArea_i(); + + // Set maximum element area + void SetMaxElementArea( CORBA::Double theArea ) + throw ( SALOME::SALOME_Exception ); + // Get maximum element area + CORBA::Double GetMaxElementArea(); + + // Get implementation + ::StdMeshers_MaxElementArea* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.cxx b/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.cxx new file mode 100644 index 000000000..eb071b664 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.cxx @@ -0,0 +1,120 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MaxElementVolume_i.cxx +// Moved here from SMESH_MaxElementVolume_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_MaxElementVolume_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_MaxElementVolume_i::StdMeshers_MaxElementVolume_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_MaxElementVolume_i::StdMeshers_MaxElementVolume_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_MaxElementVolume_i::StdMeshers_MaxElementVolume_i" ); + myBaseImpl = new ::StdMeshers_MaxElementVolume( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_MaxElementVolume_i::~StdMeshers_MaxElementVolume_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_MaxElementVolume_i::~StdMeshers_MaxElementVolume_i() +{ + MESSAGE( "StdMeshers_MaxElementVolume_i::~StdMeshers_MaxElementVolume_i()" ); +} + +//============================================================================= +/*! + * StdMeshers_MaxElementVolume_i::SetMaxElementVolume + * + * Set maximum element volume + */ +//============================================================================= + +void StdMeshers_MaxElementVolume_i::SetMaxElementVolume( CORBA::Double theVolume ) + throw ( SALOME::SALOME_Exception ) +{ + MESSAGE( "StdMeshers_MaxElementVolume_i::SetMaxElementVolume" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetMaxVolume( theVolume ); + } + catch (SALOME_Exception& S_ex) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_MaxElementVolume_i::GetMaxElementVolume + * + * Get maximum element volume + */ +//============================================================================= + +CORBA::Double StdMeshers_MaxElementVolume_i::GetMaxElementVolume() +{ + MESSAGE( "StdMeshers_MaxElementVolume_i::GetMaxElementVolume" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetMaxVolume(); +} + +//============================================================================= +/*! + * StdMeshers_MaxElementVolume_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_MaxElementVolume* StdMeshers_MaxElementVolume_i::GetImpl() +{ + MESSAGE( "StdMeshers_MaxElementVolume_i::GetImpl" ); + return ( ::StdMeshers_MaxElementVolume* )myBaseImpl; +} + diff --git a/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.hxx b/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.hxx new file mode 100644 index 000000000..328b4af87 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_MaxElementVolume_i.hxx @@ -0,0 +1,64 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_MaxElementVolume_i.hxx +// Moved here from SMESH_MaxElementVolume_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_MAXELEMENTVOLUME_I_HXX_ +#define _SMESH_MAXELEMENTVOLUME_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_MaxElementVolume.hxx" + +// ====================================================== +// Maximum Element Volume hypothesis +// ====================================================== +class StdMeshers_MaxElementVolume_i: + public virtual POA_StdMeshers::StdMeshers_MaxElementVolume, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_MaxElementVolume_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_MaxElementVolume_i(); + + // Set maximum element volume + void SetMaxElementVolume( CORBA::Double theVolume ) + throw (SALOME::SALOME_Exception); + // Get maximum element volume + CORBA::Double GetMaxElementVolume(); + + // Get implementation + ::StdMeshers_MaxElementVolume* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.cxx b/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.cxx new file mode 100644 index 000000000..e2fad1e67 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.cxx @@ -0,0 +1,64 @@ +// SMESH StdMeshers_I : idl implementation based on 'SMESH' unit's classes +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_NotConformAllowed_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +using namespace std; +#include "StdMeshers_NotConformAllowed_i.hxx" +#include "SMESH_Gen.hxx" + +#include "utilities.h" + +//============================================================================= +/*! + * Constructor: + * _name is related to the class name: prefix = SMESH_ ; suffix = _i . + */ +//============================================================================= + +StdMeshers_NotConformAllowed_i::StdMeshers_NotConformAllowed_i + (PortableServer::POA_ptr thePOA, + int studyId, + ::SMESH_Gen* genImpl) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE("StdMeshers_NotConformAllowed_i::StdMeshers_NotConformAllowed_i"); + myBaseImpl = new ::StdMeshers_NotConformAllowed(genImpl->GetANewId(), + studyId, + genImpl); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_NotConformAllowed_i::~StdMeshers_NotConformAllowed_i() +{ +} diff --git a/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.hxx b/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.hxx new file mode 100644 index 000000000..a9151d34c --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_NotConformAllowed_i.hxx @@ -0,0 +1,54 @@ +// SMESH StdMeshers_I : idl implementation based on 'SMESH' unit's classes +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_NotConformAllowed_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _StdMeshers_NotConformAllowed_I_HXX_ +#define _StdMeshers_NotConformAllowed_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" + +#include "StdMeshers_NotConformAllowed.hxx" + +class StdMeshers_NotConformAllowed_i: + public POA_StdMeshers::StdMeshers_NotConformAllowed, + public SMESH_Hypothesis_i +{ +public: + StdMeshers_NotConformAllowed_i(PortableServer::POA_ptr thePOA, + int studyId, + ::SMESH_Gen* genImpl); + virtual ~StdMeshers_NotConformAllowed_i(); + +protected: + ::StdMeshers_NotConformAllowed* _impl; +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx new file mode 100644 index 000000000..bf326bdf3 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.cxx @@ -0,0 +1,157 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_NumberOfSegments_i.cxx +// Moved here from SMESH_NumberOfSegments_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_NumberOfSegments_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::StdMeshers_NumberOfSegments_i" ); + myBaseImpl = new ::StdMeshers_NumberOfSegments( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i() +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::~StdMeshers_NumberOfSegments_i" ); +} + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::SetNumberOfSegments + * + * Set number of segments + */ +//============================================================================= + +void StdMeshers_NumberOfSegments_i::SetNumberOfSegments( CORBA::Long theSegmentsNumber ) + throw ( SALOME::SALOME_Exception ) +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::SetNumberOfSegments" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetNumberOfSegments( theSegmentsNumber ); + } + catch (SALOME_Exception& S_ex) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::GetNumberOfSegments + * + * Get number of segments + */ +//============================================================================= + +CORBA::Long StdMeshers_NumberOfSegments_i::GetNumberOfSegments() +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::GetNumberOfSegments" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetNumberOfSegments(); +} + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::SetScaleFactor + * + * Set scalar factor + */ +//============================================================================= + +void StdMeshers_NumberOfSegments_i::SetScaleFactor( CORBA::Double theScaleFactor ) + throw ( SALOME::SALOME_Exception ) +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::SetScaleFactor" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetScaleFactor( theScaleFactor ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::GetScaleFactor + * + * Get scalar factor + */ +//============================================================================= + +CORBA::Double StdMeshers_NumberOfSegments_i::GetScaleFactor() +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::GetScaleFactor" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetScaleFactor(); +} + +//============================================================================= +/*! + * StdMeshers_NumberOfSegments_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_NumberOfSegments* StdMeshers_NumberOfSegments_i::GetImpl() +{ + MESSAGE( "StdMeshers_NumberOfSegments_i::GetImpl" ); + return ( ::StdMeshers_NumberOfSegments* )myBaseImpl; +} + diff --git a/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx new file mode 100644 index 000000000..e8a5030b1 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_NumberOfSegments_i.hxx @@ -0,0 +1,70 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_NumberOfSegments_i.hxx +// Moved here from SMESH_NumberOfSegments_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_NUMBEROFSEGMENTS_I_HXX_ +#define _SMESH_NUMBEROFSEGMENTS_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_NumberOfSegments.hxx" + +// ====================================================== +// Number of segments hypothesis +// ====================================================== +class StdMeshers_NumberOfSegments_i: + public virtual POA_StdMeshers::StdMeshers_NumberOfSegments, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_NumberOfSegments_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_NumberOfSegments_i(); + + // Set number of segments + void SetNumberOfSegments( CORBA::Long theSegmentsNumber ) + throw ( SALOME::SALOME_Exception ); + // Get number of segments + CORBA::Long GetNumberOfSegments(); + + // Set scalar factor + void SetScaleFactor( CORBA::Double theScaleFactor ) + throw ( SALOME::SALOME_Exception ); + // Get scalar factor + CORBA::Double GetScaleFactor(); + + // Get implementation + ::StdMeshers_NumberOfSegments* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.cxx b/src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.cxx new file mode 100644 index 000000000..059eac91f --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.cxx @@ -0,0 +1,86 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Quadrangle_2D_i.cxx +// Moved here from SMESH_Quadrangle_2D_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Quadrangle_2D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_Quadrangle_2D_i::StdMeshers_Quadrangle_2D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_Quadrangle_2D_i::StdMeshers_Quadrangle_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_Quadrangle_2D_i::StdMeshers_Quadrangle_2D_i" ); + myBaseImpl = new ::StdMeshers_Quadrangle_2D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_Quadrangle_2D_i::~StdMeshers_Quadrangle_2D_i + * + * Destructor + * + */ +//============================================================================= + +StdMeshers_Quadrangle_2D_i::~StdMeshers_Quadrangle_2D_i() +{ + MESSAGE( "StdMeshers_Quadrangle_2D_i::~StdMeshers_Quadrangle_2D_i" ); +} + +//============================================================================= +/*! + * StdMeshers_Quadrangle_2D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_Quadrangle_2D* StdMeshers_Quadrangle_2D_i::GetImpl() +{ + MESSAGE( "StdMeshers_Quadrangle_2D_i::GetImpl" ); + return ( ::StdMeshers_Quadrangle_2D* )myBaseImpl; +} + diff --git a/src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.hxx b/src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.hxx new file mode 100644 index 000000000..a8c1e281f --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Quadrangle_2D_i.hxx @@ -0,0 +1,61 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Quadrangle_2D_i.hxx +// Moved here from SMESH_Quadrangle_2D_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_QUADRANGLE_2D_I_HXX_ +#define _SMESH_QUADRANGLE_2D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_2D_Algo_i.hxx" +#include "StdMeshers_Quadrangle_2D.hxx" + +class SMESH_Gen; + +// ====================================================== +// Quadrangle (Mapping) 2d algorithm +// ====================================================== +class StdMeshers_Quadrangle_2D_i: + public virtual POA_StdMeshers::StdMeshers_Quadrangle_2D, + public virtual SMESH_2D_Algo_i +{ +public: + // Constructor + StdMeshers_Quadrangle_2D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + + // Destructor + virtual ~StdMeshers_Quadrangle_2D_i(); + + // Get implementation + ::StdMeshers_Quadrangle_2D* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_Regular_1D_i.cxx b/src/StdMeshers_I/StdMeshers_Regular_1D_i.cxx new file mode 100644 index 000000000..24f322c58 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Regular_1D_i.cxx @@ -0,0 +1,85 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Regular_1D_i.cxx +// Moved here from SMESH_Regular_1D_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Regular_1D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_Regular_1D_i::StdMeshers_Regular_1D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_Regular_1D_i::StdMeshers_Regular_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_Regular_1D_i::StdMeshers_Regular_1D_i" ); + myBaseImpl = new ::StdMeshers_Regular_1D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_Regular_1D_i::~StdMeshers_Regular_1D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_Regular_1D_i::~StdMeshers_Regular_1D_i() +{ + MESSAGE( "StdMeshers_Regular_1D_i::~StdMeshers_Regular_1D_i" ); +} + +//============================================================================= +/*! + * StdMeshers_Regular_1D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_Regular_1D* StdMeshers_Regular_1D_i::GetImpl() +{ + MESSAGE( "StdMeshers_Regular_1D_i::GetImpl" ); + return ( ::StdMeshers_Regular_1D* )myBaseImpl; +} + diff --git a/src/StdMeshers_I/StdMeshers_Regular_1D_i.hxx b/src/StdMeshers_I/StdMeshers_Regular_1D_i.hxx new file mode 100644 index 000000000..3231532fd --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Regular_1D_i.hxx @@ -0,0 +1,58 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Regular_1D_i.hxx +// Moved here from SMESH_Regular_1D_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_REGULAR_1D_I_HXX_ +#define _SMESH_REGULAR_1D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_1D_Algo_i.hxx" +#include "StdMeshers_Regular_1D.hxx" + +// ====================================================== +// Wire Discretization 1d algorithm +// ====================================================== +class StdMeshers_Regular_1D_i: + public virtual POA_StdMeshers::StdMeshers_Regular_1D, + public virtual SMESH_1D_Algo_i +{ +public: + // Constructor + StdMeshers_Regular_1D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_Regular_1D_i(); + + // Get implementation + ::StdMeshers_Regular_1D* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_i.cxx b/src/StdMeshers_I/StdMeshers_i.cxx new file mode 100644 index 000000000..c24606d6b --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_i.cxx @@ -0,0 +1,86 @@ +// SMESH StdMeshers : implementaion of SMESH idl descriptions +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : StdMeshers_i.cxx +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +using namespace std; +#include "SMESH_Gen_i.hxx" + +#include "utilities.h" + +#include "StdMeshers_LocalLength_i.hxx" +#include "StdMeshers_LengthFromEdges_i.hxx" +#include "StdMeshers_NotConformAllowed_i.hxx" +#include "StdMeshers_NumberOfSegments_i.hxx" +#include "StdMeshers_MaxElementArea_i.hxx" +#include "StdMeshers_MaxElementVolume_i.hxx" + +#include "StdMeshers_Regular_1D_i.hxx" +#include "StdMeshers_MEFISTO_2D_i.hxx" +#include "StdMeshers_Quadrangle_2D_i.hxx" +#include "StdMeshers_Hexa_3D_i.hxx" + +//============================================================================= +/*! + * + */ +//============================================================================= + +extern "C" +{ + GenericHypothesisCreator_i* GetHypothesisCreator (const char* aHypName) + { + MESSAGE("Get HypothesisCreator for " << aHypName); + + GenericHypothesisCreator_i* aCreator = 0; + + // Hypotheses + if (strcmp(aHypName, "LocalLength") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "NumberOfSegments") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "LengthFromEdges") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "NotConformAllowed") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "MaxElementArea") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "MaxElementVolume") == 0) + aCreator = new HypothesisCreator_i; + + // Algorithms + else if (strcmp(aHypName, "Regular_1D") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "MEFISTO_2D") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "Quadrangle_2D") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "Hexa_3D") == 0) + aCreator = new HypothesisCreator_i; + else ; + + return aCreator; + } +} -- 2.39.2