1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef HYDROData_CalculationCase_HeaderFile
20 #define HYDROData_CalculationCase_HeaderFile
22 #include <HYDROData_ShapesGroup.h>
23 #include <HYDROData_SplitToZonesTool.h>
24 #include <HYDROData_PriorityQueue.h>
25 #include <HYDROData_Zone.h>
26 #include <HYDROData_Warning.h>
29 #pragma warning ( disable: 4251 )
34 #include <SALOMEconfig.h>
35 #include CORBA_SERVER_HEADER(GEOM_Gen)
39 #pragma warning( default: 4251 )
46 class TopTools_ListOfShape;
48 class Handle(HYDROData_Object);
49 class Handle(HYDROData_Region);
50 class Handle(HYDROData_Zone);
51 class Handle(HYDROData_PolylineXY);
52 class Handle(HYDROData_ShapesGroup);
53 class Handle(HYDROData_SplitShapesGroup);
54 class Handle(HYDROData_Document);
55 class Handle(HYDROData_StricklerTable);
56 class Handle(HYDROData_LandCoverMap);
58 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
61 /**\class HYDROData_CalculationCase
62 * \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
65 class HYDROData_CalculationCase : public HYDROData_Entity
69 enum PointClassification
71 POINT_OUT, ///< point is out of zone face
72 POINT_IN, ///< point is inside of zone face
73 POINT_ON ///< point is on the edge of zone face
85 * Enumeration of tags corresponding to the persistent object parameters.
89 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
90 DataTag_GeometryObject, ///< reference geometry objects
91 DataTag_ChildRegion, ///< child regions
92 DataTag_Region, ///< reference regions
93 DataTag_Polyline, ///< reference boundary polyline
94 DataTag_GeometryGroup, ///< reference geometry groups
95 DataTag_SplitGroups, ///< reference split groups
96 DataTag_CustomRules, ///< custom rules
97 DataTag_AssignmentMode, ///< assignment mode
98 DataTag_StricklerTable, ///< reference Strickler table
99 DataTag_InterPoly, ///< intersection polyline
101 DataTag_LandCover_Obsolete, ///< reference land covers
102 DataTag_CustomLandCoverRules_Obsolete, ///< custom rules for land covers priority
103 DataTag_AssignmentLandCoverMode_Obsolete, ///< assignment mode of land covers priority
104 DataTag_ChildLandCoverRegion_Obsolete, ///< child land cover regions
105 DataTag_LandCoverRegion_Obsolete, ///< reference land cover regions
107 DataTag_LandCoverMap, ///< reference to land cover map
112 DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
115 * Returns the kind of this object. Must be redefined in all objects of known type.
117 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
120 * Updates the name of this object.
121 * Reimplemented to update the names of regions, zones and split groups.
123 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
126 * Dump Calculation object to Python script representation.
128 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
129 MapOfTreatedObjects& theTreatedObjects ) const;
132 * Update the calcualtion case object.
133 * Call this method whenever you made changes for object data.
135 HYDRODATA_EXPORT virtual void Update();
138 * Returns the list of all reference objects of this object.
140 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
143 // Public methods to work with Calculation
146 * Add new one reference geometry object for calculation case.
148 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
151 * Returns all reference geometry objects of calculation case.
153 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
156 * Removes reference geometry object from calculation case.
157 * \param theObject the object to remove
159 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
162 * Removes all reference geometry objects from calculation case.
164 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
168 * Add new one reference geometry group for calculation case.
169 * \param theGroup the group to add
171 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
174 * Returns all reference geometry groups of calculation case.
176 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
179 * Removes reference geometry group from calculation case.
180 * \param theGroup the group to remove
182 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
185 * Removes all reference geometry groups from calculation case.
187 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
191 * Sets reference boundary polyline object for calculation case.
193 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
196 * Returns reference boundary polyline object of calculation case.
198 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
201 * Remove reference boundary polyline object from calculation case.
203 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
207 * Sets reference Strickler table for calculation case.
209 HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
212 * Returns reference Strickler table of calculation case.
214 HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
217 * Remove reference Strickler table from calculation case.
219 HYDRODATA_EXPORT virtual void RemoveStricklerTable();
222 * Returns reference Land Cover Map of calculation case.
223 * \return the referenced Land Cover Map
225 HYDRODATA_EXPORT Handle(HYDROData_LandCoverMap) GetLandCoverMap() const;
227 HYDRODATA_EXPORT void SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& );
230 * Add new one child region for calculation case.
231 * The new region is added into the list of reference regions.
232 * The label of theZone is changed during this operation
233 * because of new region becomes the new parent for this zone.
234 * \return the created region
236 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
240 * Add new one reference region for calculation case.
241 * The label of theRegion is changed in case if old parent is not this calculation.
242 * \return true in case of success
244 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
247 * Returns all reference regions of calculation case.
248 * \return the list of reference regions
250 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
253 * Updates names of regions to correct order.
255 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
258 * Removes reference region from calculation case.
259 * \param theRegion the region to remove
261 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
264 * Removes all reference regions from calculation case.
266 HYDRODATA_EXPORT virtual void RemoveRegions();
269 * Returns all reference geometry groups of calculation case.
271 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplitGroups() const;
274 * Removes all reference geometry groups from calculation case.
276 HYDRODATA_EXPORT virtual void RemoveSplitGroups();
278 HYDRODATA_EXPORT virtual bool AddInterPoly( const Handle(HYDROData_PolylineXY)& theInterPolyline );
280 HYDRODATA_EXPORT virtual void RemoveInterPolyObject( const Handle(HYDROData_PolylineXY)& theInterPolyline );
282 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetInterPolyObjects() const;
285 * Exports the calculation case data (shell and groups) to GEOM module.
286 * \param theStudyId the id of the study where the GEOM module should be used for export
287 * \return the entry of the GEOM object (empty string in the case of error)
289 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
292 * Exports the calculation case data (shell and groups) to GEOM module.
293 * \param theGeomEngine GEOM module engine
294 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
295 * \param theGeomObjEntry the published GEOM object entry
296 * \param theErrorMsg the error message
297 * \return true in case of success
300 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
301 SALOMEDS::Study_ptr theStudy,
302 QString& theGeomObjEntry,
303 QString& theErrorMsg ) const;
307 // Public methods to work with Calculation services
310 * Returns altitude for given point.
311 * \param thePoint the point to examine
312 * \return result altitude value
314 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
317 * Returns altitude for given point on given region.
318 * \param thePoint the point to examine
319 * \param theRegion reference region to check
320 * \return result altitude value
322 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
323 const Handle(HYDROData_Region)& theRegion,
324 int theMethod = 0) const;
327 * Returns altitude for given point on given zone.
328 * \param thePoint the point to examine
329 * \param theZone reference zone to check
330 * \return result altitude value
332 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
333 const Handle(HYDROData_Zone)& theZone,
334 int theMethod = 0) const;
337 * Returns strickler coefficient for given point.
338 * \param thePoint the point to examine
339 * \return result strickler coefficient
341 HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
344 * Returns altitudes for given points on given region.
345 * \param thePoints the points to examine
346 * \param theRegion reference region to check
347 * \return result altitude value
349 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
350 const NCollection_Sequence<gp_XY>& thePoints,
351 const Handle(HYDROData_Region)& theRegion,
352 int theMethod = 0) const;
355 * Returns altitudes for given points on given zone.
356 * \param thePoints the points to examine
357 * \param theZone reference zone to check
358 * \return result altitude value
360 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
361 const NCollection_Sequence<gp_XY>& thePoints,
362 const Handle(HYDROData_Zone)& theZone,
363 int theMethod = 0) const;
366 * Returns region to which the point is belongs.
367 * \param thePoint the point to examine
368 * if it is needed to search Land Cover region
369 * \return result region
371 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
374 * Returns zone to which the point is belongs.
375 * \param thePoint the point to examine
376 * if it is needed to search Land Cover zone
377 * \return result zone
379 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
382 * Returns classification of point for given zone.
383 * \param thePoint the point to examine
384 * \param theZone the zone to examine
385 * \return result classification
387 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
388 const gp_XY& thePoint,
389 const Handle(HYDROData_Zone)& theZone ) const;
391 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
392 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
394 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
395 const bool theIsSetToUpdate = true );
396 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
397 HYDROData_PriorityType thePriority,
398 const Handle(HYDROData_Entity)& theObject2,
399 HYDROData_Zone::MergeType theMergeType,
400 HYDROData_CalculationCase::DataTag theDataTag );
401 HYDRODATA_EXPORT bool GetRule( int theIndex,
402 Handle(HYDROData_Entity)& theObject1,
403 HYDROData_PriorityType& thePriority,
404 Handle(HYDROData_Entity)& theObject2,
405 HYDROData_Zone::MergeType& theMergeType,
406 HYDROData_CalculationCase::DataTag& theDataTag ) const;
408 HYDRODATA_EXPORT QString DumpRules() const;
410 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
415 * Add new one region for calculation case.
416 * The new region is added into the list of reference regions.
418 Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
419 const QString& thePrefixOrName,
420 bool isPrefix = true );
423 * Add new one split edges group for calculation case.
425 Handle(HYDROData_SplitShapesGroup) addNewSplitGroup( const QString& theName );
428 * Exports the given faces as shell and the given groups to GEOM module.
429 * \param theGeomEngine GEOM module engine
430 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
431 * \param theFaces the list of faces to make shell
432 * \param theSplitGroups the list of groups
433 * \return true in case of success
436 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
437 SALOMEDS::Study_ptr theStudy,
438 const TopTools_ListOfShape& theFaces,
439 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
440 QString& theGeomObjEntry ) const;
443 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
444 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
445 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
446 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
448 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
449 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
451 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
453 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
455 void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
456 const QString& theOldCaseName,
457 const QString& theName );
459 void DumpRegionsToPython( QStringList& theResList,
460 const QString& thePyScriptPath,
461 MapOfTreatedObjects& theTreatedObjects,
462 const HYDROData_SequenceOfObjects& theRegions ) const;
465 friend class HYDROData_Iterator;
468 * Creates new object in the internal data structure. Use higher level objects
469 * to create objects with real content.
471 HYDRODATA_EXPORT HYDROData_CalculationCase();
474 * Destructs properties of the object and object itself, removes it from the document.
476 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
478 void DumpSampleMeshing( QStringList& theScript,
479 const QString& theStudyName,
480 const QString& theGeomShapeName,
481 const QString& theMeshName ) const;
484 HYDROData_Warning myLastWarning;