Salome HOME
ec3f2976ae36b80df7c718b30bad87ac6d4ffbb2
[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   /**
212    * Exports the calculation case data (shell and groups) to GEOM module.
213    * \param theGeomEngine GEOM module engine
214    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
215    * \return true in case of success
216    */
217   HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var  theGeomEngine,
218                                         SALOMEDS::Study_ptr theStudy ) const;
219
220 public:      
221   // Public methods to work with Calculation services
222
223   /**
224    * Returns altitude for given point.
225    * \param thePoint the point to examine
226    * \return result altitude value
227    */
228   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
229
230   /**
231    * Returns altitude for given point on given region.
232    * \param thePoint the point to examine
233    * \param theRegion reference region to check
234    * \return result altitude value
235    */
236   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                    thePoint,
237                                                        const Handle(HYDROData_Region)& theRegion ) const;
238
239   /**
240    * Returns altitude for given point on given zone.
241    * \param thePoint the point to examine
242    * \param theZone reference zone to check
243    * \return result altitude value
244    */
245   HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY&                  thePoint,
246                                                        const Handle(HYDROData_Zone)& theZone ) const;
247
248   /**
249    * Returns altitudes for given points on given region.
250    * \param thePoints the points to examine
251    * \param theRegion reference region to check
252    * \return result altitude value
253    */
254   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
255     const NCollection_Sequence<gp_XY>& thePoints,
256     const Handle(HYDROData_Region)&    theRegion ) const;
257
258   /**
259    * Returns altitudes for given points on given zone.
260    * \param thePoints the points to examine
261    * \param theZone reference zone to check
262    * \return result altitude value
263    */
264   HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints( 
265     const NCollection_Sequence<gp_XY>& thePoints,
266     const Handle(HYDROData_Zone)&      theZone ) const;
267
268   /**
269    * Returns region to which the point is belongs.
270    * \param thePoint the point to examine
271    * \return result region
272    */
273   HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
274
275   /**
276    * Returns zone to which the point is belongs.
277    * \param thePoint the point to examine
278    * \return result zone
279    */
280   HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
281
282   /**
283    * Returns classification of point for given zone.
284    * \param thePoint the point to examine
285    * \param theZone the zone to examine
286    * \return result classification
287    */
288   HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
289     const gp_XY&                  thePoint,
290     const Handle(HYDROData_Zone)& theZone ) const;
291
292   HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
293   HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
294
295   HYDRODATA_EXPORT void ClearRules();
296   HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Object)&    theObject1,
297                                  HYDROData_PriorityType             thePriority,
298                                  const Handle(HYDROData_Object)&    theObject2,
299                                  HYDROData_Zone::MergeAltitudesType theMergeType );
300
301   HYDRODATA_EXPORT QString DumpRules() const;
302
303   HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
304
305 private:
306
307   /**
308    * Add new one region for calculation case.
309    * The new region is added into the list of reference regions.
310    */
311   Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
312                                          const QString& thePrefixOrName,
313                                          bool isPrefix = true );
314
315   /**
316    * Add new one splitted edges group for calculation case.
317    */
318   Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup( const QString& theName );
319
320   /**
321    * Exports the given faces as shell and the given groups to GEOM module.
322    * \param theGeomEngine GEOM module engine
323    * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
324    * \param theFaces the list of faces to make shell 
325    * \param theSplittedGroups the list of groups
326    * \return true in case of success
327    */
328   bool Export( GEOM::GEOM_Gen_var                            theGeomEngine,
329                SALOMEDS::Study_ptr                           theStudy,
330                const TopTools_ListOfShape&                   theFaces,
331                const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs ) const;
332
333   /**
334    * Publish the given shape in GEOM as a GEOM object.
335    * \param theGeomEngine GEOM module engine
336    * \param theStudy SALOMEDS study, used for publishing of the shape
337    * \param theShape the shape to publish as a GEOM object
338    * \param theName the name of the published object
339    * \return the published GEOM object
340    */
341   GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var  theGeomEngine,
342                                             SALOMEDS::Study_ptr theStudy,
343                                             const TopoDS_Shape& theShape, 
344                                             const QString&      theName ) const;
345
346   void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
347                          const HYDROData_SplitToZonesTool::SplitDataList& theZones );
348   void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
349                           const HYDROData_SplitToZonesTool::SplitDataList& theZones );
350
351   void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
352                             const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
353
354   void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
355
356   void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
357
358 protected:
359   friend class HYDROData_Iterator;
360
361   /**
362    * Creates new object in the internal data structure. Use higher level objects 
363    * to create objects with real content.
364    */
365   HYDRODATA_EXPORT HYDROData_CalculationCase();
366
367   /**
368    * Destructs properties of the object and object itself, removes it from the document.
369    */
370   HYDRODATA_EXPORT ~HYDROData_CalculationCase();
371
372 private:
373   HYDROData_Warning myLastWarning;
374 };
375
376 #endif