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 #include <SALOMEconfig.h>
30 #include CORBA_SERVER_HEADER(GEOM_Gen)
36 class TopTools_ListOfShape;
38 class Handle(HYDROData_Object);
39 class Handle(HYDROData_Region);
40 class Handle(HYDROData_Zone);
41 class Handle(HYDROData_PolylineXY);
42 class Handle(HYDROData_ShapesGroup);
43 class Handle(HYDROData_SplittedShapesGroup);
44 class Handle(HYDROData_Document);
46 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
49 /**\class HYDROData_CalculationCase
50 * \brief Calculation case is defined by selection of Geometry objects with or without
\93Zone of water
\94.
53 class HYDROData_CalculationCase : public HYDROData_Entity
57 enum PointClassification
59 POINT_OUT, ///< point is out of zone face
60 POINT_IN, ///< point is inside of zone face
61 POINT_ON ///< point is on the edge of zone face
73 * Enumeration of tags corresponding to the persistent object parameters.
77 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
78 DataTag_GeometryObject, ///< reference geometry objects
79 DataTag_ChildRegion, ///< child regions
80 DataTag_Region, ///< reference regions
81 DataTag_Polyline, ///< reference boundary polyline
82 DataTag_GeometryGroup, ///< reference geometry groups
83 DataTag_SplittedGroups, ///< reference splitted groups
84 DataTag_CustomRules, ///< custom rules
85 DataTag_AssignmentMode, ///< assignment mode
90 DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
93 * Returns the kind of this object. Must be redefined in all objects of known type.
95 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
98 * Updates the name of this object.
99 * Reimplemented to update the names of regions, zones and splitted groups.
101 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
104 * Dump Calculation object to Python script representation.
106 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
109 * Update the calcualtion case object.
110 * Call this method whenever you made changes for object data.
112 HYDRODATA_EXPORT virtual void Update();
115 * Returns the list of all reference objects of this object.
117 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
120 // Public methods to work with Calculation
123 * Add new one reference geometry object for calculation case.
125 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
128 * Returns all reference geometry objects of calculation case.
130 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
133 * Removes reference geometry object from calculation case.
135 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
138 * Removes all reference geometry objects from calculation case.
140 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
144 * Add new one reference geometry group for calculation case.
146 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
149 * Returns all reference geometry groups of calculation case.
151 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
154 * Removes reference geometry group from calculation case.
156 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
159 * Removes all reference geometry groups from calculation case.
161 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
165 * Sets reference boundary polyline object for calculation case.
167 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
170 * Returns reference boundary polyline object of calculation case.
172 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
175 * Remove reference boundary polyline object from calculation case.
177 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
181 * Add new one child region for calculation case.
182 * The new region is added into the list of reference regions.
183 * The label of theZone is changed during this operation
184 * because of new region becomes the new parent for this zone.
186 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
190 * Add new one reference region for calculation case.
191 * The label of theRegion is changed in case if old parent is not this calculation.
193 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
196 * Returns all reference regions of calculation case.
198 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
201 * Updates names of regions to correct order.
203 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
206 * Removes reference region from calculation case.
208 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
211 * Removes all reference regions from calculation case.
213 HYDRODATA_EXPORT virtual void RemoveRegions();
217 * Returns all reference geometry groups of calculation case.
219 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
222 * Removes all reference geometry groups from calculation case.
224 HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
227 * Exports the calculation case data (shell and groups) to GEOM module.
228 * \param theStudyId the id of the study where the GEOM module should be used for export
229 * \return the entry of the GEOM object (empty string in the case of error)
231 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
234 * Exports the calculation case data (shell and groups) to GEOM module.
235 * \param theGeomEngine GEOM module engine
236 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
237 * \return true in case of success
239 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
240 SALOMEDS::Study_ptr theStudy,
241 QString& theGeomObjEntry ) const;
244 // Public methods to work with Calculation services
247 * Returns altitude for given point.
248 * \param thePoint the point to examine
249 * \return result altitude value
251 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
254 * Returns altitude for given point on given region.
255 * \param thePoint the point to examine
256 * \param theRegion reference region to check
257 * \return result altitude value
259 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
260 const Handle(HYDROData_Region)& theRegion ) const;
263 * Returns altitude for given point on given zone.
264 * \param thePoint the point to examine
265 * \param theZone reference zone to check
266 * \return result altitude value
268 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
269 const Handle(HYDROData_Zone)& theZone ) const;
272 * Returns altitudes for given points on given region.
273 * \param thePoints the points to examine
274 * \param theRegion reference region to check
275 * \return result altitude value
277 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
278 const NCollection_Sequence<gp_XY>& thePoints,
279 const Handle(HYDROData_Region)& theRegion ) const;
282 * Returns altitudes for given points on given zone.
283 * \param thePoints the points to examine
284 * \param theZone reference zone to check
285 * \return result altitude value
287 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
288 const NCollection_Sequence<gp_XY>& thePoints,
289 const Handle(HYDROData_Zone)& theZone ) const;
292 * Returns region to which the point is belongs.
293 * \param thePoint the point to examine
294 * \return result region
296 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
299 * Returns zone to which the point is belongs.
300 * \param thePoint the point to examine
301 * \return result zone
303 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
306 * Returns classification of point for given zone.
307 * \param thePoint the point to examine
308 * \param theZone the zone to examine
309 * \return result classification
311 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
312 const gp_XY& thePoint,
313 const Handle(HYDROData_Zone)& theZone ) const;
315 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
316 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
318 HYDRODATA_EXPORT void ClearRules( const bool theIsSetToUpdate = true );
319 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Object)& theObject1,
320 HYDROData_PriorityType thePriority,
321 const Handle(HYDROData_Object)& theObject2,
322 HYDROData_Zone::MergeAltitudesType theMergeType );
323 HYDRODATA_EXPORT bool GetRule( int theIndex,
324 Handle(HYDROData_Object)& theObject1,
325 HYDROData_PriorityType& thePriority,
326 Handle(HYDROData_Object)& theObject2,
327 HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
329 HYDRODATA_EXPORT QString DumpRules() const;
331 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
336 * Add new one region for calculation case.
337 * The new region is added into the list of reference regions.
339 Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
340 const QString& thePrefixOrName,
341 bool isPrefix = true );
344 * Add new one splitted edges group for calculation case.
346 Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup( const QString& theName );
349 * Exports the given faces as shell and the given groups to GEOM module.
350 * \param theGeomEngine GEOM module engine
351 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
352 * \param theFaces the list of faces to make shell
353 * \param theSplittedGroups the list of groups
354 * \return true in case of success
356 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
357 SALOMEDS::Study_ptr theStudy,
358 const TopTools_ListOfShape& theFaces,
359 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
360 QString& theGeomObjEntry ) const;
363 * Publish the given shape in GEOM as a GEOM object.
364 * \param theGeomEngine GEOM module engine
365 * \param theStudy SALOMEDS study, used for publishing of the shape
366 * \param theShape the shape to publish as a GEOM object
367 * \param theName the name of the published object
368 * \return the published GEOM object
370 GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var theGeomEngine,
371 SALOMEDS::Study_ptr theStudy,
372 const TopoDS_Shape& theShape,
373 const QString& theName,
374 QString& theGeomObjEntry ) const;
376 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
377 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
378 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
379 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
381 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
382 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
384 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
386 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
389 friend class HYDROData_Iterator;
392 * Creates new object in the internal data structure. Use higher level objects
393 * to create objects with real content.
395 HYDRODATA_EXPORT HYDROData_CalculationCase();
398 * Destructs properties of the object and object itself, removes it from the document.
400 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
402 void DumpSampleMeshing( QStringList& theScript,
403 const QString& theStudyName,
404 const QString& theGeomShapeName,
405 const QString& theMeshName ) const;
408 HYDROData_Warning myLastWarning;