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 )
47 class HYDROData_Object;
48 class HYDROData_Region;
50 class HYDROData_PolylineXY;
51 class HYDROData_ShapesGroup;
52 class HYDROData_SplitShapesGroup;
53 class HYDROData_Document;
54 class HYDROData_StricklerTable;
55 class HYDROData_LandCoverMap;
57 /**\class HYDROData_CalculationCase
58 * \brief Calculation case is defined by selection of Geometry objects with or without �Zone of water�.
61 class HYDROData_CalculationCase : public HYDROData_Entity
65 enum PointClassification
67 POINT_OUT, ///< point is out of zone face
68 POINT_IN, ///< point is inside of zone face
69 POINT_ON ///< point is on the edge of zone face
81 * Enumeration of tags corresponding to the persistent object parameters.
85 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
86 DataTag_GeometryObject, ///< reference geometry objects
87 DataTag_ChildRegion, ///< child regions
88 DataTag_Region, ///< reference regions
89 DataTag_Polyline, ///< reference boundary polyline
90 DataTag_GeometryGroup, ///< reference geometry groups
91 DataTag_SplitGroups, ///< reference split groups
92 DataTag_CustomRules, ///< custom rules
93 DataTag_AssignmentMode, ///< assignment mode
94 DataTag_StricklerTable, ///< reference Strickler table
96 DataTag_LandCover_Obsolete, ///< reference land covers
97 DataTag_CustomLandCoverRules_Obsolete, ///< custom rules for land covers priority
98 DataTag_AssignmentLandCoverMode_Obsolete, ///< assignment mode of land covers priority
99 DataTag_ChildLandCoverRegion_Obsolete, ///< child land cover regions
100 DataTag_LandCoverRegion_Obsolete, ///< reference land cover regions
102 DataTag_LandCoverMap, ///< reference to land cover map
106 DEFINE_STANDARD_RTTIEXT(HYDROData_CalculationCase, HYDROData_Entity);
109 * Returns the kind of this object. Must be redefined in all objects of known type.
111 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
114 * Updates the name of this object.
115 * Reimplemented to update the names of regions, zones and split groups.
117 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
120 * Dump Calculation object to Python script representation.
122 HYDRODATA_EXPORT virtual QStringList DumpToPython( const QString& thePyScriptPath,
123 MapOfTreatedObjects& theTreatedObjects ) const;
126 * Update the calcualtion case object.
127 * Call this method whenever you made changes for object data.
129 HYDRODATA_EXPORT virtual void Update();
132 * Returns the list of all reference objects of this object.
134 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
137 // Public methods to work with Calculation
140 * Add new one reference geometry object for calculation case.
142 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
145 * Returns all reference geometry objects of calculation case.
147 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
150 * Removes reference geometry object from calculation case.
151 * \param theObject the object to remove
153 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
156 * Removes all reference geometry objects from calculation case.
158 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
162 * Add new one reference geometry group for calculation case.
163 * \param theGroup the group to add
165 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
168 * Returns all reference geometry groups of calculation case.
170 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
173 * Removes reference geometry group from calculation case.
174 * \param theGroup the group to remove
176 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
179 * Removes all reference geometry groups from calculation case.
181 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
185 * Sets reference boundary polyline object for calculation case.
187 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
190 * Returns reference boundary polyline object of calculation case.
192 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
195 * Remove reference boundary polyline object from calculation case.
197 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
201 * Sets reference Strickler table for calculation case.
203 HYDRODATA_EXPORT virtual void SetStricklerTable( const Handle(HYDROData_StricklerTable)& theStricklerTable );
206 * Returns reference Strickler table of calculation case.
208 HYDRODATA_EXPORT virtual Handle(HYDROData_StricklerTable) GetStricklerTable() const;
211 * Remove reference Strickler table from calculation case.
213 HYDRODATA_EXPORT virtual void RemoveStricklerTable();
216 * Returns reference Land Cover Map of calculation case.
217 * \return the referenced Land Cover Map
219 HYDRODATA_EXPORT Handle(HYDROData_LandCoverMap) GetLandCoverMap() const;
221 HYDRODATA_EXPORT void SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& );
224 * Add new one child region for calculation case.
225 * The new region is added into the list of reference regions.
226 * The label of theZone is changed during this operation
227 * because of new region becomes the new parent for this zone.
228 * \return the created region
230 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
234 * Add new one reference region for calculation case.
235 * The label of theRegion is changed in case if old parent is not this calculation.
236 * \return true in case of success
238 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
241 * Returns all reference regions of calculation case.
242 * \return the list of reference regions
244 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
247 * Updates names of regions to correct order.
249 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
252 * Removes reference region from calculation case.
253 * \param theRegion the region to remove
255 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
258 * Removes all reference regions from calculation case.
260 HYDRODATA_EXPORT virtual void RemoveRegions();
263 * Returns all reference geometry groups of calculation case.
265 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplitGroups() const;
268 * Removes all reference geometry groups from calculation case.
270 HYDRODATA_EXPORT virtual void RemoveSplitGroups();
273 * Exports the calculation case data (shell and groups) to GEOM module.
274 * \param theStudyId the id of the study where the GEOM module should be used for export
275 * \return the entry of the GEOM object (empty string in the case of error)
277 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
280 * Exports the calculation case data (shell and groups) to GEOM module.
281 * \param theGeomEngine GEOM module engine
282 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
283 * \param theGeomObjEntry the published GEOM object entry
284 * \param theErrorMsg the error message
285 * \return true in case of success
288 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
289 SALOMEDS::Study_ptr theStudy,
290 QString& theGeomObjEntry,
291 QString& theErrorMsg ) const;
295 // Public methods to work with Calculation services
298 * Returns altitude for given point.
299 * \param thePoint the point to examine
300 * \return result altitude value
302 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
305 * Returns altitude for given point on given region.
306 * \param thePoint the point to examine
307 * \param theRegion reference region to check
308 * \return result altitude value
310 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
311 const Handle(HYDROData_Region)& theRegion,
312 int theMethod = 0) const;
315 * Returns altitude for given point on given zone.
316 * \param thePoint the point to examine
317 * \param theZone reference zone to check
318 * \return result altitude value
320 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
321 const Handle(HYDROData_Zone)& theZone,
322 int theMethod = 0) const;
325 * Returns strickler coefficient for given point.
326 * \param thePoint the point to examine
327 * \return result strickler coefficient
329 HYDRODATA_EXPORT double GetStricklerCoefficientForPoint( const gp_XY& thePoint ) const;
332 * Returns altitudes for given points on given region.
333 * \param thePoints the points to examine
334 * \param theRegion reference region to check
335 * \return result altitude value
337 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
338 const NCollection_Sequence<gp_XY>& thePoints,
339 const Handle(HYDROData_Region)& theRegion,
340 int theMethod = 0) const;
343 * Returns altitudes for given points on given zone.
344 * \param thePoints the points to examine
345 * \param theZone reference zone to check
346 * \return result altitude value
348 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
349 const NCollection_Sequence<gp_XY>& thePoints,
350 const Handle(HYDROData_Zone)& theZone,
351 int theMethod = 0) const;
354 * Returns region to which the point is belongs.
355 * \param thePoint the point to examine
356 * if it is needed to search Land Cover region
357 * \return result region
359 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
362 * Returns zone to which the point is belongs.
363 * \param thePoint the point to examine
364 * if it is needed to search Land Cover zone
365 * \return result zone
367 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
370 * Returns classification of point for given zone.
371 * \param thePoint the point to examine
372 * \param theZone the zone to examine
373 * \return result classification
375 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
376 const gp_XY& thePoint,
377 const Handle(HYDROData_Zone)& theZone ) const;
379 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
380 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
382 HYDRODATA_EXPORT void ClearRules( HYDROData_CalculationCase::DataTag theDataTag,
383 const bool theIsSetToUpdate = true );
384 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Entity)& theObject1,
385 HYDROData_PriorityType thePriority,
386 const Handle(HYDROData_Entity)& theObject2,
387 HYDROData_Zone::MergeType theMergeType,
388 HYDROData_CalculationCase::DataTag theDataTag );
389 HYDRODATA_EXPORT bool GetRule( int theIndex,
390 Handle(HYDROData_Entity)& theObject1,
391 HYDROData_PriorityType& thePriority,
392 Handle(HYDROData_Entity)& theObject2,
393 HYDROData_Zone::MergeType& theMergeType,
394 HYDROData_CalculationCase::DataTag& theDataTag ) const;
396 HYDRODATA_EXPORT QString DumpRules() const;
398 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
403 * Add new one region for calculation case.
404 * The new region is added into the list of reference regions.
406 Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
407 const QString& thePrefixOrName,
408 bool isPrefix = true );
411 * Add new one split edges group for calculation case.
413 Handle(HYDROData_SplitShapesGroup) addNewSplitGroup( const QString& theName );
416 * Exports the given faces as shell and the given groups to GEOM module.
417 * \param theGeomEngine GEOM module engine
418 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
419 * \param theFaces the list of faces to make shell
420 * \param theSplitGroups the list of groups
421 * \return true in case of success
424 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
425 SALOMEDS::Study_ptr theStudy,
426 const TopTools_ListOfShape& theFaces,
427 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
428 QString& theGeomObjEntry ) const;
431 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
432 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
433 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
434 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
436 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
437 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
439 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
441 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
443 void UpdateRegionsNames( const HYDROData_SequenceOfObjects& theRegions,
444 const QString& theOldCaseName,
445 const QString& theName );
447 void DumpRegionsToPython( QStringList& theResList,
448 const QString& thePyScriptPath,
449 MapOfTreatedObjects& theTreatedObjects,
450 const HYDROData_SequenceOfObjects& theRegions ) const;
453 friend class HYDROData_Iterator;
456 * Creates new object in the internal data structure. Use higher level objects
457 * to create objects with real content.
459 HYDRODATA_EXPORT HYDROData_CalculationCase();
462 * Destructs properties of the object and object itself, removes it from the document.
464 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
466 void DumpSampleMeshing( QStringList& theScript,
467 const QString& theStudyName,
468 const QString& theGeomShapeName,
469 const QString& theMeshName ) const;
472 HYDROData_Warning myLastWarning;