1 // Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_MeshOp.h
25 // Author : Sergey LITONIN, Open CASCADE S.A.S.
27 #ifndef SMESHGUI_MESHOP_H
28 #define SMESHGUI_MESHOP_H
31 #include "SMESH_SMESHGUI.hxx"
33 #include "SMESHGUI_SelectionOp.h"
36 #include <SALOMEconfig.h>
37 #include CORBA_CLIENT_HEADER(SMESH_Gen)
38 #include CORBA_CLIENT_HEADER(GEOM_Gen)
41 class SMESHGUI_MeshDlg;
42 class SMESHGUI_ShapeByMeshOp;
44 class SMESHGUI_GenericHypothesisCreator;
47 * \brief Operation for mech creation or editing
49 * This operation is used for mech creation or editing.
51 class SMESHGUI_EXPORT SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
56 enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
57 enum MeshType{ MT_ANY = 0, MT_TRIANGULAR, MT_QUADRILATERAL, MT_TETRAHEDRAL, MT_HEXAHEDRAL };
59 typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
60 typedef QList< THypItem > THypList;
63 typedef QMap< THypType, THypList > TType2HypList;
66 typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
69 SMESHGUI_MeshOp( const bool, const bool = true );
70 virtual ~SMESHGUI_MeshOp();
72 virtual LightApp_Dialog* dlg() const;
75 virtual void startOperation();
76 virtual void commitOperation();
77 virtual void selectionDone();
78 virtual SUIT_SelectionFilter* createFilter( const int ) const;
79 virtual bool isValid( SUIT_Operation* ) const;
82 virtual bool onApply();
83 void onCreateHyp( const int, const int );
84 void onEditHyp( const int, const int );
85 void onHypoSet( const QString& );
86 void onGeomSelectionByMesh( bool );
87 void onPublishShapeByMeshDlg( SUIT_Operation* );
88 void onCloseShapeByMeshDlg( SUIT_Operation* );
89 void onAlgoSelected( const int, const int = -1 );
90 void onHypoCreated( int );
91 void onHypoEdited( int );
92 void onAlgoSetByMeshType( const int, const int );
95 typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
96 typedef QMap<QString, bool> THypLabelIsAppMap; // typedef: map of hypothesis is applicable
98 bool isValid( QString& ) const;
99 bool isCompatibleToGeometry( HypothesisData* , const int);
100 bool isCompatibleToMeshType( HypothesisData* , const int);
101 void availableHyps( const int,
107 const QString& = "");
108 void existingHyps( const int,
113 HypothesisData* = 0 ) const;
114 HypothesisData* hypData( const int,
116 const int ); // access to myAvailableHypData
118 void createHypothesis( const int, const int,
121 bool createMesh( QString&, QStringList& );
122 bool createSubMesh( QString&, QStringList& );
123 bool editMeshOrSubMesh( QString& );
124 void createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr mesh,
125 GEOM::GEOM_Object_ptr mainShape );
126 bool checkSubMeshConcurrency( SMESH::SMESH_Mesh_ptr mesh,
127 SMESH::SMESH_subMesh_ptr submesh,
130 int currentHyp( const int, const int ) const;
131 bool isSelectedHyp( int, int, int ) const;
132 int nbDlgHypTypes( const int ) const;
133 bool isAccessibleDim( const int ) const;
134 void setCurrentHyp( const int, const int, const int, const bool=false);
135 void setDefaultName( const QString& prefix="" ) const;
136 SMESH::SMESH_Hypothesis_var getAlgo( const int );
138 QString name( _PTR(SObject) ) const;
139 int find( const SMESH::SMESH_Hypothesis_var&,
140 const THypList& ) const;
141 SMESH::SMESH_Hypothesis_var getInitParamsHypothesis( const QString&,
143 const SMESH::HypInitParams* prm=0) const;
144 void initHypCreator( SMESHGUI_GenericHypothesisCreator* aCreator );
145 bool getAverageSize( double & averageSize );
146 bool isSubshapeOk() const;
147 char* isSubmeshIgnored() const;
148 _PTR(SObject) getSubmeshByGeom() const;
149 void selectObject( _PTR(SObject) ) const;
150 void updateMeshTypeList();
151 void updateHypoSets();
152 void setFilteredAlgoData();
153 QStringList getHypoNames();
157 SMESHGUI_MeshDlg* myDlg;
158 SMESHGUI_ShapeByMeshOp* myShapeByMeshOp;
161 bool myIsOnGeometry; //!< TRUE if edited mesh is based on geometry
162 bool myHasConcurrentSubBefore;
163 bool myIsInvalidSubMesh; //!< "invalid sub-mesh" is edited
164 // The geometry of "invalid sub-mesh" is not a sub-shape of the main shape;
165 // it is created for the case where a valid sub-shape not found by CopyMeshWithGeom()
168 GEOM::GEOM_Object_var myGeom;
170 TDim2Type2HypList myExistingHyps; //!< all hypothesis of SMESH module
171 TDim2Type2HypList myObjHyps; //!< hypothesis assigned to the current
172 // edited mesh/sub-mesh
173 // hypdata corresponding to hypotheses present in myDlg
174 THypDataList myAvailableHypData[4][NbHypTypes];
175 QString myLastGeomEntry;
176 THypLabelIsAppMap myHypMapIsApplicable;
177 bool myIgnoreAlgoSelection;
178 int myDim, myType, myMaxShapeDim;
180 HypothesesSet* myHypoSet; // applied hypo-set
181 double myAverageSize; // entered at hypo-set processing
183 QString myObjectToSelect;
186 #endif // SMESHGUI_MESHOP_H