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