Salome HOME
IPAL54529: Hexahedron(ijk) fails on a block with composite sides if Viscous Layers...
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_MeshOp.h
1 // Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File   : SMESHGUI_MeshOp.h
25 // Author : Sergey LITONIN, Open CASCADE S.A.S.
26 //
27 #ifndef SMESHGUI_MESHOP_H
28 #define SMESHGUI_MESHOP_H
29
30 // SMESH includes
31 #include "SMESH_SMESHGUI.hxx"
32
33 #include "SMESHGUI_SelectionOp.h"
34
35 // IDL includes
36 #include <SALOMEconfig.h>
37 #include CORBA_CLIENT_HEADER(SMESH_Gen)
38 #include CORBA_CLIENT_HEADER(GEOM_Gen)
39
40 class HypothesesSet;
41 class SMESHGUI_MeshDlg;
42 class SMESHGUI_ShapeByMeshOp;
43 class HypothesisData;
44 class SMESHGUI_GenericHypothesisCreator;
45
46 /*!
47  * \brief Operation for mech creation or editing
48  *
49  *  This operation is used for mech creation or editing. 
50 */
51 class SMESHGUI_EXPORT SMESHGUI_MeshOp : public SMESHGUI_SelectionOp
52
53   Q_OBJECT
54       
55 public:
56   enum HypType{ Algo = 0, MainHyp, AddHyp, NbHypTypes };
57   enum MeshType{ MT_ANY = 0, MT_TRIANGULAR, MT_QUADRILATERAL, MT_TETRAHEDRAL, MT_HEXAHEDRAL };
58
59   typedef std::pair<SMESH::SMESH_Hypothesis_var, QString> THypItem;
60   typedef QList< THypItem > THypList;
61
62   typedef int THypType;
63   typedef QMap< THypType, THypList > TType2HypList;
64
65   typedef int THypDim;
66   typedef QMap< THypDim, TType2HypList > TDim2Type2HypList;
67
68 public:
69   SMESHGUI_MeshOp( const bool, const bool = true );
70   virtual ~SMESHGUI_MeshOp();
71   
72   virtual LightApp_Dialog*       dlg() const;  
73
74 protected:
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;
80
81 protected slots:
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 );
93
94 private:
95   typedef QList<HypothesisData*> THypDataList; // typedef: list of hypothesis data
96   typedef QMap<QString, bool>    THypLabelIsAppMap; // typedef: map of hypothesis is applicable
97
98   bool                           isValid( QString& ) const;
99   bool                           isCompatibleToGeometry( HypothesisData* , const int);
100   bool                           isCompatibleToMeshType( HypothesisData* , const int);
101   void                           availableHyps( const int, 
102                                                 const int,
103                                                 QStringList&,
104                                                 THypDataList&,
105                                                 HypothesisData* = 0,
106                                                 HypothesisData* = 0,
107                                                 const QString& = "");
108   void                           existingHyps( const int, 
109                                                const int, 
110                                                _PTR(SObject),
111                                                QStringList&, 
112                                                THypList&,
113                                                HypothesisData* = 0 ) const;
114   HypothesisData*                hypData( const int,
115                                           const int,
116                                           const int ); // access to myAvailableHypData
117
118   void                           createHypothesis( const int, const int,
119                                                    const QString& );
120
121   bool                           createMesh( QString&, QStringList& );
122   bool                           createSubMesh( QString&, QStringList& );
123   bool                           editMeshOrSubMesh( QString& );
124   bool                           checkSubMeshConcurrency( SMESH::SMESH_Mesh_ptr    mesh,
125                                                           SMESH::SMESH_subMesh_ptr submesh,
126                                                           bool                     askUser=false);
127
128   int                            currentHyp( const int, const int ) const;
129   bool                           isSelectedHyp( int, int, int ) const;
130   int                            nbDlgHypTypes( const int ) const;
131   bool                           isAccessibleDim( const int ) const;
132   void                           setCurrentHyp( const int, const int, const int, const bool=false);
133   void                           setDefaultName( const QString& prefix="" ) const;
134   SMESH::SMESH_Hypothesis_var    getAlgo( const int );
135   void                           readMesh();
136   QString                        name( _PTR(SObject) ) const;
137   int                            find( const SMESH::SMESH_Hypothesis_var&,
138                                        const THypList& ) const;
139   SMESH::SMESH_Hypothesis_var    getInitParamsHypothesis( const QString&,
140                                                           const QString& ) const;
141   void                           initHypCreator( SMESHGUI_GenericHypothesisCreator* aCreator );
142   bool                           isSubshapeOk() const;
143   char*                          isSubmeshIgnored() const;
144   _PTR(SObject)                  getSubmeshByGeom() const;
145   void                           selectObject( _PTR(SObject) ) const;
146   void                           updateMeshTypeList();
147   void                           updateHypoSets();
148   void                           setFilteredAlgoData();
149
150 private:
151
152   SMESHGUI_MeshDlg*              myDlg;
153   SMESHGUI_ShapeByMeshOp*        myShapeByMeshOp;
154   bool                           myToCreate;
155   bool                           myIsMesh;
156   bool                           myIsOnGeometry; //!< TRUE if edited mesh is based on geometry
157   bool                           myHasConcurrentSubBefore;
158   bool                           myIsInvalidSubMesh; //!< "invalid sub-mesh" is edited
159   // The geometry of "invalid sub-mesh" is not a sub-shape of the main shape;
160   // it is created for the case where a valid sub-shape not found by CopyMeshWithGeom()
161
162   QString                        myGeomEntry;
163   GEOM::GEOM_Object_var          myGeom;
164
165   TDim2Type2HypList              myExistingHyps; //!< all hypothesis of SMESH module
166   TDim2Type2HypList              myObjHyps;      //!< hypothesis assigned to the current
167                                                  //   edited mesh/sub-mesh
168   // hypdata corresponding to hypotheses present in myDlg
169   THypDataList                   myAvailableHypData[4][NbHypTypes];
170   QString                        myLastGeomEntry;
171   THypLabelIsAppMap              myHypMapIsApplicable;
172   bool                           myIgnoreAlgoSelection;
173   int                            myDim, myType, myMaxShapeDim;
174
175   QString                        myObjectToSelect;
176 };
177
178 #endif // SMESHGUI_MESHOP_H