Salome HOME
Selection for image presentation & updates for interpolated stream profiles and stream.
[modules/hydro.git] / src / HYDROData / HYDROData_CalculationCase.h
1 // Copyright (C) 2007-2015  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 #ifndef HYDROData_CalculationCase_HeaderFile
24 #define HYDROData_CalculationCase_HeaderFile
25
26 #include <HYDROData_ShapesGroup.h>
27 #include <HYDROData_SplitToZonesTool.h>
28 #include <HYDROData_PriorityQueue.h>
29 #include <HYDROData_Zone.h>
30 #include <HYDROData_Warning.h>
31
32 // IDL includes
33 #include <SALOMEconfig.h>
34 #include CORBA_SERVER_HEADER(GEOM_Gen)
35
36 class gp_XY;
37
38 class TopoDS_Shape;
39 class TopoDS_Shell;
40 class TopTools_ListOfShape;
41
42 class Handle(HYDROData_Object);
43 class Handle(HYDROData_Region);
44 class Handle(HYDROData_Zone);
45 class Handle(HYDROData_PolylineXY);
46 class Handle(HYDROData_ShapesGroup);
47 class Handle(HYDROData_SplittedShapesGroup);
48 class Handle(HYDROData_Document);
49
50 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
51
52
53 /**\class HYDROData_CalculationCase
54  * \brief Calculation case is defined by selection of Geometry objects with or without \93Zone of water\94.
55  *
56  */
57 class HYDROData_CalculationCase : public HYDROData_Entity
58 {
59 public:
60
61   enum PointClassification
62   {
63     POINT_OUT,  ///< point is out of zone face
64     POINT_IN,   ///< point is inside of zone face
65     POINT_ON    ///< point is on the edge of zone face
66   };
67
68   enum AssignmentMode
69   {
70     MANUAL = 0,
71     AUTOMATIC,
72   };
73
74 public:
75
76   /**
77    * Enumeration of tags corresponding to the persistent object parameters.
78    */
79   enum DataTag
80   {
81     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
82     DataTag_GeometryObject,   ///< reference geometry objects
83     DataTag_ChildRegion,      ///< child regions
84     DataTag_Region,           ///< reference regions
85     DataTag_Polyline,         ///< reference boundary polyline
86     DataTag_GeometryGroup,    ///< reference geometry groups
87     DataTag_SplittedGroups,   ///< reference splitted groups
88     DataTag_CustomRules,      ///< custom rules
89     DataTag_AssignmentMode,   ///< assignment mode
90   };
91
92 public:
93
94   DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
95
96   /**
97    * Returns the kind of this object. Must be redefined in all objects of known type.
98    */
99   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
100
101   /**
102    * Updates the name of this object.
103    * Reimplemented to update the names of regions, zones and splitted groups.
104    */
105   HYDRODATA_EXPORT virtual void SetName( const QString& theName );
106
107   /**
108    * Dump Calculation object to Python script representation.
109    */
110   HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
111
112   /**
113    * Update the calcualtion case object.
114    * Call this method whenever you made changes for object data.
115    */
116   HYDRODATA_EXPORT virtual void Update();
117
118   /**
119    * Returns the list of all reference objects of this object.
120    */
121   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
122
123 public:      
124   // Public methods to work with Calculation
125
126   /**
127    * Add new one reference geometry object for calculation case.
128    */
129   HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
130
131   /**
132    * Returns all reference geometry objects of calculation case.
133    */
134   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
135
136   /**
137    * Removes reference geometry object from calculation case.
138    */
139   HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
140
141   /**
142    * Removes all reference geometry objects from calculation case.
143    */
144   HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
145
146
147   /**
148    * Add new one reference geometry group for calculation case.
149    */
150   HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
151
152   /**
153    * Returns all reference geometry groups of calculation case.
154    */
155   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
156
157   /**
158    * Removes reference geometry group from calculation case.
159    */
160   HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
161
162   /**
163    * Removes all reference geometry groups from calculation case.
164    */
165   HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
166
167
168   /**
169    * Sets reference boundary polyline object for calculation case.
170    */
171   HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
172
173   /**
174    * Returns reference boundary polyline object of calculation case.
175    */
176   HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
177
178   /**
179    * Remove reference boundary polyline object from calculation case.
180    */
181   HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
182
183
184   /**
185    * Add new one child region for calculation case.
186    * The new region is added into the list of reference regions.
187    * The label of theZone is changed during this operation
188    * because of new region becomes the new parent for this zone.
189    */
190   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
191
192
193   /**
194    * Add new one reference region for calculation case.
195    * The label of theRegion is changed in case if old parent is not this calculation.
196    */
197   HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
198
199   /**
200    * Returns all reference regions of calculation case.
201    */
202   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
203
204   /**
205    * Updates names of regions to correct order.
206    */
207   HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
208
209   /**
210    * Removes reference region from calculation case.
211    */
212   HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
213
214   /**
215    * Removes all reference regions from calculation case.
216    */
217   HYDRODATA_EXPORT virtual void RemoveRegions();
218
219   
220   /**
221    * Returns all reference geometry groups of calculation case.
222    */
223   HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
224
225   /**
226    * Removes all reference geometry groups from calculation case.
227    */
228   HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
229
230   /**
231    * Exports the calculation case data (shell and groups) to GEOM module.
232    * \param theStudyId the id of the study where the GEOM module should be used for export
233    * \return the entry of the GEOM object (empty string in the case of error)
234    */
235   HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
236
237   /**
238    * Exports the calculation case data (shell and groups) to GEOM module.
239    * \param theGeomEngine GEOM module engine
240    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
241    * \return true in case of success
242    */
243   HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var  theGeomEngine,
244                                         SALOMEDS::Study_ptr theStudy,
245                                         QString& theGeomObjEntry ) const;
246
247 public:      
248   // Public methods to work with Calculation services
249
250   /**
251    * Returns altitude for given point.
252    * \param thePoint the point to examine
253    * \return result altitude value
254    */
255   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
256
257   /**
258    * Returns altitude for given point on given region.
259    * \param thePoint the point to examine
260    * \param theRegion reference region to check
261    * \return result altitude value
262    */
263   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                    thePoint,
264                                                        const Handle(HYDROData_Region)& theRegion ) const;
265
266   /**
267    * Returns altitude for given point on given zone.
268    * \param thePoint the point to examine
269    * \param theZone reference zone to check
270    * \return result altitude value
271    */
272   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                  thePoint,
273                                                        const Handle(HYDROData_Zone)& theZone ) const;
274
275   /**
276    * Returns altitudes for given points on given region.
277    * \param thePoints the points to examine
278    * \param theRegion reference region to check
279    * \return result altitude value
280    */
281   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
282     const NCollection_Sequence<gp_XY>& thePoints,
283     const Handle(HYDROData_Region)&    theRegion ) const;
284
285   /**
286    * Returns altitudes for given points on given zone.
287    * \param thePoints the points to examine
288    * \param theZone reference zone to check
289    * \return result altitude value
290    */
291   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
292     const NCollection_Sequence<gp_XY>& thePoints,
293     const Handle(HYDROData_Zone)&      theZone ) const;
294
295   /**
296    * Returns region to which the point is belongs.
297    * \param thePoint the point to examine
298    * \return result region
299    */
300   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
301
302   /**
303    * Returns zone to which the point is belongs.
304    * \param thePoint the point to examine
305    * \return result zone
306    */
307   HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
308
309   /**
310    * Returns classification of point for given zone.
311    * \param thePoint the point to examine
312    * \param theZone the zone to examine
313    * \return result classification
314    */
315   HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
316     const gp_XY&                  thePoint,
317     const Handle(HYDROData_Zone)& theZone ) const;
318
319   HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
320   HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
321
322   HYDRODATA_EXPORT void ClearRules( const bool theIsSetToUpdate = true );
323   HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Object)&    theObject1,
324                                  HYDROData_PriorityType             thePriority,
325                                  const Handle(HYDROData_Object)&    theObject2,
326                                  HYDROData_Zone::MergeAltitudesType theMergeType );
327   HYDRODATA_EXPORT bool GetRule( int theIndex, 
328                                  Handle(HYDROData_Object)&           theObject1,
329                                  HYDROData_PriorityType&             thePriority,
330                                  Handle(HYDROData_Object)&           theObject2,
331                                  HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
332
333   HYDRODATA_EXPORT QString DumpRules() const;
334
335   HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
336
337 private:
338
339   /**
340    * Add new one region for calculation case.
341    * The new region is added into the list of reference regions.
342    */
343   Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
344                                          const QString& thePrefixOrName,
345                                          bool isPrefix = true );
346
347   /**
348    * Add new one splitted edges group for calculation case.
349    */
350   Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup( const QString& theName );
351
352   /**
353    * Exports the given faces as shell and the given groups to GEOM module.
354    * \param theGeomEngine GEOM module engine
355    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
356    * \param theFaces the list of faces to make shell 
357    * \param theSplittedGroups the list of groups
358    * \return true in case of success
359    */
360   bool Export( GEOM::GEOM_Gen_var                            theGeomEngine,
361                SALOMEDS::Study_ptr                           theStudy,
362                const TopTools_ListOfShape&                   theFaces,
363                const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
364                QString& theGeomObjEntry ) const;
365
366   /**
367    * Publish the given shape in GEOM as a GEOM object.
368    * \param theGeomEngine GEOM module engine
369    * \param theStudy SALOMEDS study, used for publishing of the shape
370    * \param theShape the shape to publish as a GEOM object
371    * \param theName the name of the published object
372    * \return the published GEOM object
373    */
374   GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var  theGeomEngine,
375                                             SALOMEDS::Study_ptr theStudy,
376                                             const TopoDS_Shape& theShape, 
377                                             const QString&      theName,
378                                             QString& theGeomObjEntry ) const;
379
380   void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
381                          const HYDROData_SplitToZonesTool::SplitDataList& theZones );
382   void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
383                           const HYDROData_SplitToZonesTool::SplitDataList& theZones );
384
385   void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
386                             const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
387
388   void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
389
390   void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
391
392 protected:
393   friend class HYDROData_Iterator;
394
395   /**
396    * Creates new object in the internal data structure. Use higher level objects 
397    * to create objects with real content.
398    */
399   HYDRODATA_EXPORT HYDROData_CalculationCase();
400
401   /**
402    * Destructs properties of the object and object itself, removes it from the document.
403    */
404   HYDRODATA_EXPORT ~HYDROData_CalculationCase();
405
406   void DumpSampleMeshing( QStringList& theScript,
407                           const QString& theStudyName,
408                           const QString& theGeomShapeName,
409                           const QString& theMeshName ) const;
410
411 private:
412   HYDROData_Warning myLastWarning;
413 };
414
415 #endif