Salome HOME
refs #1330: basic implementation of the not zoomable polyline arrows
[modules/hydro.git] / src / HYDROData / HYDROData_DTM.h
index 2194c861b2658c39e40a54f758237e10a2b9b1ad..59d3cd6811e8a7f60c67620e63f6512661e8cc50 100644 (file)
 #define HYDROData_DTM_HeaderFile
 
 #include "HYDROData_Bathymetry.h"
+#include "HYDROData_Profile.h"
+
+#include <gp_Pnt2d.hxx>
+
+#include<Geom2d_BSplineCurve.hxx>
+#include<Geom2d_Curve.hxx>
+#include<Geom_Plane.hxx>
+
+#include <TopTools_DataMapOfShapeListOfShape.hxx>
+#include <TopTools_IndexedMapOfOrientedShape.hxx>
+#include <TopTools_SequenceOfShape.hxx>
+
 #include <vector>
+#include <set>
 
-class Handle_HYDROData_Profile;
-class Handle_Geom2d_BSplineCurve;
-class Handle_Geom2d_Curve;
+class gp_Pnt;
+class gp_Vec2d;
+class TopoDS_Edge;
+class TopoDS_Wire;
+class TopoDS_Face;
+class TopoDS_Compound;
 
-DEFINE_STANDARD_HANDLE( HYDROData_DTM, HYDROData_Bathymetry )
 
 /**\class HYDROData_DTM
  * \brief Class that represents the Digital Terrain Model
@@ -40,67 +55,174 @@ protected:
   enum DataTag
   {
     DataTag_First = HYDROData_Bathymetry::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_Profiles,
+    DataTag_DDZ,
+    DataTag_SpatialStep,
+    DataTag_LeftBankShape,
+    DataTag_RightBankShape,
+    DataTag_InletShape,
+    DataTag_OutletShape,
+    DataTag_3DShape,
+    DataTag_2DShape
   };
 
 public:
-  DEFINE_STANDARD_RTTI( HYDROData_DTM );
+  DEFINE_STANDARD_RTTIEXT( HYDROData_DTM, HYDROData_Bathymetry );
 
-protected:
-  friend class HYDROData_Iterator;
-  friend class test_HYDROData_DTM;
+  HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
+  HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
 
-  HYDRODATA_EXPORT HYDROData_DTM();
-  virtual HYDRODATA_EXPORT ~HYDROData_DTM();
+  HYDRODATA_EXPORT double GetDDZ() const;
+  HYDRODATA_EXPORT void SetDDZ( double );
+
+  HYDRODATA_EXPORT double GetSpatialStep() const;
+  HYDRODATA_EXPORT void SetSpatialStep( double );
 
+  HYDRODATA_EXPORT virtual void Update();
+
+public:
   struct PointUZ
   {
+    PointUZ( double u=0, double z=0 ) { U=u; Z=z; }
     double U;
     double Z;
   };
   class CurveUZ : public std::vector<PointUZ>
   {
   public:
-    CurveUZ( double theXcurv );
+    CurveUZ( double theXcurv, const gp_Vec2d& theProfileDir, double theDeltaZ, double theMaxZ );
     ~CurveUZ();
 
     double Xcurv() const;
+    gp_Vec2d ProfileDir() const;
+    double DeltaZ() const;
+    double MaxZ() const;
 
     CurveUZ operator + ( const CurveUZ& ) const;
     CurveUZ operator * ( double ) const;
 
   private:
     double myXcurv;
+    gp_Vec2d myProfileDir;
+    double myDeltaZ;
+    double myMaxZ;
   };
 
-  static Handle_Geom2d_BSplineCurve CreateHydraulicAxis( 
-    const std::vector<Handle_HYDROData_Profile>& theProfiles,
+protected:
+  friend class HYDROData_Stream;
+  friend class HYDROData_Iterator;
+  friend class test_HYDROData_DTM;
+
+  HYDRODATA_EXPORT HYDROData_DTM();
+  virtual HYDRODATA_EXPORT ~HYDROData_DTM();
+
+  static Handle(Geom2d_BSplineCurve) CreateHydraulicAxis( 
+    const std::vector<Handle(HYDROData_Profile)>& theProfiles,
     std::vector<double>& theDistances );
 
-  static std::vector<Handle_Geom2d_Curve> ProfileToParametric( const Handle_HYDROData_Profile& theProfile,
-                                                               double& theUMin, double& theUMax );
+  static std::vector<Handle(Geom2d_Curve)> ProfileToParametric( const Handle(HYDROData_Profile)& theProfile,
+                                                                double& theUMin, double& theUMax,
+                                                                gp_Vec2d& theDir );
 
-  static void ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
-                                     double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
+  static void GetProperties( const Handle(HYDROData_Profile)& theProfile,
+                             gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
+                             double& theZMin, double& theZMax );
+
+  static void ProfileDiscretization( const Handle(HYDROData_Profile)& theProfile,
+                                     double theXCurv, double theMinZ, double theMaxZ, double theTopZ, double theDDZ,
                                      CurveUZ& theMidPointCurve,
                                      CurveUZ& theWidthCurve,
+                                     int& intersection_nb,
                                      double theTolerance = 1E-6 );
 
-  static void CurveTo3d( const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
+  static void CurveTo3D( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
+                         const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
                          AltitudePoints& thePoints );
   
   static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, 
                            int theNbSteps, std::vector<CurveUZ>& theInterpolation,
                            bool isAddSecond );
 
-  static void Interpolate( const Handle_HYDROData_Profile& theProfileA,
-                           double theXCurvA,
-                           const Handle_HYDROData_Profile& theProfileB,
-                           double theXCurvB,
-                           double theDDZ, int theNbSteps, bool isAddSecond,
-                           AltitudePoints& thePoints );
+  static std::vector<AltitudePoints> Interpolate
+    ( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
+      const Handle(HYDROData_Profile)& theProfileA,
+      double theXCurvA,
+      const Handle(HYDROData_Profile)& theProfileB,
+      double theXCurvB,
+      double theDDZ, int theNbSteps, bool isAddSecond,
+      int& inter_nb_1, int& inter_nb_2 );
+
+  static AltitudePoints Interpolate( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+                                     double theDDZ, double theSpatialStep,
+                                     AltitudePoints& theLeft,
+                                     AltitudePoints& theRight,
+                                     std::vector<AltitudePoints>& theMainProfiles,
+                                     std::set<int>& invalInd );
+
+  static void PointsToWire(const AltitudePoints& pnts, TopoDS_Wire& W );
+
+  static void PointsToEdge(const AltitudePoints& pnts, TopoDS_Edge& E );
+
+  //static void ProjWireOnPlane(const TopoDS_Shape& inpWire, const Handle_Geom_Plane& RefPlane,
+    //TopTools_DataMapOfShapeListOfShape* E2PE);
+
+  static bool GetPlanarFaceFromBanks(const TopoDS_Edge& LB, const TopoDS_Edge& RB, TopoDS_Face& outF,
+    TopTools_SequenceOfShape* Boundr);
+
+  static TopTools_IndexedMapOfOrientedShape Create3DShape(const AltitudePoints& left,
+                                                          const AltitudePoints& right,
+                                                          const std::vector<AltitudePoints>& main_profiles);
+
+  static void CreateProfiles(const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+                             double theDDZ,
+                             double theSpatialStep,
+                             AltitudePoints& theOutLeft,
+                             AltitudePoints& theOutRight,
+                             AltitudePoints& theOutPoints,
+                             std::vector<AltitudePoints>& theOutMainProfiles,
+                             TopoDS_Shape& Out3dPres,
+                             TopoDS_Shape& Out2dPres,
+                             TopoDS_Shape& OutLeftB,
+                             TopoDS_Shape& OutRightB,
+                             TopoDS_Shape& OutInlet,
+                             TopoDS_Shape& OutOutlet,
+                             bool Create3dPres,
+                             bool Create2dPres,
+                             std::set<int>& InvInd,
+                             bool& ProjStat);
+
+  //static bool Get2dFaceFrom3dPres(const TopoDS_Compound& cmp, TopoDS_Face& outF, 
+    //TopTools_SequenceOfShape* Boundr = NULL, std::set<int> ind = std::set<int>() );
+  
+  static int EstimateNbPoints( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
+                               double theDDZ, double theSpatialStep );
+
+  void GetPresentationShapes( TopoDS_Shape& Out3dPres,
+                              TopoDS_Shape& Out2dPres,
+                              TopoDS_Shape& OutLeftB,
+                              TopoDS_Shape& OutRightB,
+                              TopoDS_Shape& OutInlet,
+                              TopoDS_Shape& OutOutlet );
+public:
 
-  static void Interpolate( const std::vector<Handle_HYDROData_Profile>& theProfiles,
-                           double theDDZ, double theSpatialStep, AltitudePoints& thePoints );
+  HYDRODATA_EXPORT static void CreateProfilesFromDTM ( const HYDROData_SequenceOfObjects& InpProfiles,
+                                                       double ddz,
+                                                       double step, 
+                                                       AltitudePoints& points,
+                                                       TopoDS_Shape& Out3dPres,
+                                                       TopoDS_Shape& Out2dPres,
+                                                       TopoDS_Shape& OutLeftB,
+                                                       TopoDS_Shape& OutRightB,
+                                                       TopoDS_Shape& OutInlet,
+                                                       TopoDS_Shape& OutOutlet,
+                                                       bool Create3dPres,
+                                                       bool Create2dPres,
+                                                       std::set<int>& InvInd,
+                                                       int thePntsLimit,
+                                                       bool& WireIntersections);
 };
 
+
+
+
 #endif