1 // Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef HYDROData_CalculationCase_HeaderFile
24 #define HYDROData_CalculationCase_HeaderFile
26 #include <HYDROData_ShapesGroup.h>
27 #include <HYDROData_SplitToZonesTool.h>
28 #include <HYDROData_PriorityQueue.h>
29 #include <HYDROData_Zone.h>
30 #include <HYDROData_Warning.h>
33 #include <SALOMEconfig.h>
34 #include CORBA_SERVER_HEADER(GEOM_Gen)
40 class TopTools_ListOfShape;
42 class Handle(HYDROData_Object);
43 class Handle(HYDROData_Region);
44 class Handle(HYDROData_Zone);
45 class Handle(HYDROData_PolylineXY);
46 class Handle(HYDROData_ShapesGroup);
47 class Handle(HYDROData_SplittedShapesGroup);
48 class Handle(HYDROData_Document);
50 DEFINE_STANDARD_HANDLE(HYDROData_CalculationCase, HYDROData_Entity)
53 /**\class HYDROData_CalculationCase
54 * \brief Calculation case is defined by selection of Geometry objects with or without
\93Zone of water
\94.
57 class HYDROData_CalculationCase : public HYDROData_Entity
61 enum PointClassification
63 POINT_OUT, ///< point is out of zone face
64 POINT_IN, ///< point is inside of zone face
65 POINT_ON ///< point is on the edge of zone face
77 * Enumeration of tags corresponding to the persistent object parameters.
81 DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
82 DataTag_GeometryObject, ///< reference geometry objects
83 DataTag_ChildRegion, ///< child regions
84 DataTag_Region, ///< reference regions
85 DataTag_Polyline, ///< reference boundary polyline
86 DataTag_GeometryGroup, ///< reference geometry groups
87 DataTag_SplittedGroups, ///< reference splitted groups
88 DataTag_CustomRules, ///< custom rules
89 DataTag_AssignmentMode, ///< assignment mode
94 DEFINE_STANDARD_RTTI(HYDROData_CalculationCase);
97 * Returns the kind of this object. Must be redefined in all objects of known type.
99 HYDRODATA_EXPORT virtual const ObjectKind GetKind() const { return KIND_CALCULATION; }
102 * Updates the name of this object.
103 * Reimplemented to update the names of regions, zones and splitted groups.
105 HYDRODATA_EXPORT virtual void SetName( const QString& theName );
108 * Dump Calculation object to Python script representation.
110 HYDRODATA_EXPORT virtual QStringList DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const;
113 * Update the calcualtion case object.
114 * Call this method whenever you made changes for object data.
116 HYDRODATA_EXPORT virtual void Update();
119 * Returns the list of all reference objects of this object.
121 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetAllReferenceObjects() const;
124 // Public methods to work with Calculation
127 * Add new one reference geometry object for calculation case.
129 HYDRODATA_EXPORT virtual bool AddGeometryObject( const Handle(HYDROData_Object)& theObject );
132 * Returns all reference geometry objects of calculation case.
134 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryObjects() const;
137 * Removes reference geometry object from calculation case.
139 HYDRODATA_EXPORT virtual void RemoveGeometryObject( const Handle(HYDROData_Object)& theObject );
142 * Removes all reference geometry objects from calculation case.
144 HYDRODATA_EXPORT virtual void RemoveGeometryObjects();
148 * Add new one reference geometry group for calculation case.
150 HYDRODATA_EXPORT virtual bool AddGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
153 * Returns all reference geometry groups of calculation case.
155 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetGeometryGroups() const;
158 * Removes reference geometry group from calculation case.
160 HYDRODATA_EXPORT virtual void RemoveGeometryGroup( const Handle(HYDROData_ShapesGroup)& theGroup );
163 * Removes all reference geometry groups from calculation case.
165 HYDRODATA_EXPORT virtual void RemoveGeometryGroups();
169 * Sets reference boundary polyline object for calculation case.
171 HYDRODATA_EXPORT virtual void SetBoundaryPolyline( const Handle(HYDROData_PolylineXY)& thePolyline );
174 * Returns reference boundary polyline object of calculation case.
176 HYDRODATA_EXPORT virtual Handle(HYDROData_PolylineXY) GetBoundaryPolyline() const;
179 * Remove reference boundary polyline object from calculation case.
181 HYDRODATA_EXPORT virtual void RemoveBoundaryPolyline();
185 * Add new one child region for calculation case.
186 * The new region is added into the list of reference regions.
187 * The label of theZone is changed during this operation
188 * because of new region becomes the new parent for this zone.
190 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) AddNewRegion( const Handle(HYDROData_Zone)& theZone );
194 * Add new one reference region for calculation case.
195 * The label of theRegion is changed in case if old parent is not this calculation.
197 HYDRODATA_EXPORT virtual bool AddRegion( const Handle(HYDROData_Region)& theRegion );
200 * Returns all reference regions of calculation case.
202 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetRegions() const;
205 * Updates names of regions to correct order.
207 HYDRODATA_EXPORT virtual void UpdateRegionsOrder();
210 * Removes reference region from calculation case.
212 HYDRODATA_EXPORT virtual void RemoveRegion( const Handle(HYDROData_Region)& theRegion );
215 * Removes all reference regions from calculation case.
217 HYDRODATA_EXPORT virtual void RemoveRegions();
221 * Returns all reference geometry groups of calculation case.
223 HYDRODATA_EXPORT virtual HYDROData_SequenceOfObjects GetSplittedGroups() const;
226 * Removes all reference geometry groups from calculation case.
228 HYDRODATA_EXPORT virtual void RemoveSplittedGroups();
231 * Exports the calculation case data (shell and groups) to GEOM module.
232 * \param theStudyId the id of the study where the GEOM module should be used for export
233 * \return the entry of the GEOM object (empty string in the case of error)
235 HYDRODATA_EXPORT virtual QString Export( int theStudyId ) const;
238 * Exports the calculation case data (shell and groups) to GEOM module.
239 * \param theGeomEngine GEOM module engine
240 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
241 * \return true in case of success
243 HYDRODATA_EXPORT virtual bool Export( GEOM::GEOM_Gen_var theGeomEngine,
244 SALOMEDS::Study_ptr theStudy,
245 QString& theGeomObjEntry ) const;
248 // Public methods to work with Calculation services
251 * Returns altitude for given point.
252 * \param thePoint the point to examine
253 * \return result altitude value
255 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint ) const;
258 * Returns altitude for given point on given region.
259 * \param thePoint the point to examine
260 * \param theRegion reference region to check
261 * \return result altitude value
263 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
264 const Handle(HYDROData_Region)& theRegion ) const;
267 * Returns altitude for given point on given zone.
268 * \param thePoint the point to examine
269 * \param theZone reference zone to check
270 * \return result altitude value
272 HYDRODATA_EXPORT virtual double GetAltitudeForPoint( const gp_XY& thePoint,
273 const Handle(HYDROData_Zone)& theZone ) const;
276 * Returns altitudes for given points on given region.
277 * \param thePoints the points to examine
278 * \param theRegion reference region to check
279 * \return result altitude value
281 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
282 const NCollection_Sequence<gp_XY>& thePoints,
283 const Handle(HYDROData_Region)& theRegion ) const;
286 * Returns altitudes for given points on given zone.
287 * \param thePoints the points to examine
288 * \param theZone reference zone to check
289 * \return result altitude value
291 HYDRODATA_EXPORT virtual NCollection_Sequence<double> GetAltitudesForPoints(
292 const NCollection_Sequence<gp_XY>& thePoints,
293 const Handle(HYDROData_Zone)& theZone ) const;
296 * Returns region to which the point is belongs.
297 * \param thePoint the point to examine
298 * \return result region
300 HYDRODATA_EXPORT virtual Handle(HYDROData_Region) GetRegionFromPoint( const gp_XY& thePoint ) const;
303 * Returns zone to which the point is belongs.
304 * \param thePoint the point to examine
305 * \return result zone
307 HYDRODATA_EXPORT virtual Handle(HYDROData_Zone) GetZoneFromPoint( const gp_XY& thePoint ) const;
310 * Returns classification of point for given zone.
311 * \param thePoint the point to examine
312 * \param theZone the zone to examine
313 * \return result classification
315 HYDRODATA_EXPORT virtual PointClassification GetPointClassification(
316 const gp_XY& thePoint,
317 const Handle(HYDROData_Zone)& theZone ) const;
319 HYDRODATA_EXPORT void SetAssignmentMode( AssignmentMode theMode );
320 HYDRODATA_EXPORT AssignmentMode GetAssignmentMode() const;
322 HYDRODATA_EXPORT void ClearRules( const bool theIsSetToUpdate = true );
323 HYDRODATA_EXPORT void AddRule( const Handle(HYDROData_Object)& theObject1,
324 HYDROData_PriorityType thePriority,
325 const Handle(HYDROData_Object)& theObject2,
326 HYDROData_Zone::MergeAltitudesType theMergeType );
327 HYDRODATA_EXPORT bool GetRule( int theIndex,
328 Handle(HYDROData_Object)& theObject1,
329 HYDROData_PriorityType& thePriority,
330 Handle(HYDROData_Object)& theObject2,
331 HYDROData_Zone::MergeAltitudesType& theMergeType ) const;
333 HYDRODATA_EXPORT QString DumpRules() const;
335 HYDRODATA_EXPORT HYDROData_Warning GetLastWarning() const;
340 * Add new one region for calculation case.
341 * The new region is added into the list of reference regions.
343 Handle(HYDROData_Region) addNewRegion( const Handle(HYDROData_Document)& theDoc,
344 const QString& thePrefixOrName,
345 bool isPrefix = true );
348 * Add new one splitted edges group for calculation case.
350 Handle(HYDROData_SplittedShapesGroup) addNewSplittedGroup( const QString& theName );
353 * Exports the given faces as shell and the given groups to GEOM module.
354 * \param theGeomEngine GEOM module engine
355 * \param theStudy SALOMEDS study, is used for publishing of GEOM objects
356 * \param theFaces the list of faces to make shell
357 * \param theSplittedGroups the list of groups
358 * \return true in case of success
360 bool Export( GEOM::GEOM_Gen_var theGeomEngine,
361 SALOMEDS::Study_ptr theStudy,
362 const TopTools_ListOfShape& theFaces,
363 const HYDROData_ShapesGroup::SeqOfGroupsDefs& theGroupsDefs,
364 QString& theGeomObjEntry ) const;
367 * Publish the given shape in GEOM as a GEOM object.
368 * \param theGeomEngine GEOM module engine
369 * \param theStudy SALOMEDS study, used for publishing of the shape
370 * \param theShape the shape to publish as a GEOM object
371 * \param theName the name of the published object
372 * \return the published GEOM object
374 GEOM::GEOM_Object_ptr publishShapeInGEOM( GEOM::GEOM_Gen_var theGeomEngine,
375 SALOMEDS::Study_ptr theStudy,
376 const TopoDS_Shape& theShape,
377 const QString& theName,
378 QString& theGeomObjEntry ) const;
380 void CreateRegionsDef( const Handle(HYDROData_Document)& theDoc,
381 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
382 void CreateRegionsAuto( const Handle(HYDROData_Document)& theDoc,
383 const HYDROData_SplitToZonesTool::SplitDataList& theZones );
385 void CreateEdgeGroupsDef( const Handle(HYDROData_Document)& theDoc,
386 const HYDROData_SplitToZonesTool::SplitDataList& theEdges );
388 void DumpRulesToPython( const QString& theCalcCaseName, QStringList& theScript ) const;
390 void SetWarning( HYDROData_WarningType theType = WARN_OK, const QString& theData = "" );
393 friend class HYDROData_Iterator;
396 * Creates new object in the internal data structure. Use higher level objects
397 * to create objects with real content.
399 HYDRODATA_EXPORT HYDROData_CalculationCase();
402 * Destructs properties of the object and object itself, removes it from the document.
404 HYDRODATA_EXPORT ~HYDROData_CalculationCase();
406 void DumpSampleMeshing( QStringList& theScript,
407 const QString& theStudyName,
408 const QString& theGeomShapeName,
409 const QString& theMeshName ) const;
412 HYDROData_Warning myLastWarning;