Salome HOME
change version number
[modules/hydro.git] / src / HYDROData / HYDROData_DTM.h
index 22bdcaa7dc6ea943c6a3951b7faa1a1006e91e9b..59d3cd6811e8a7f60c67620e63f6512661e8cc50 100644 (file)
 #define HYDROData_DTM_HeaderFile
 
 #include "HYDROData_Bathymetry.h"
-#include <vector>
+#include "HYDROData_Profile.h"
+
 #include <gp_Pnt2d.hxx>
 
-class Handle_HYDROData_Profile;
-class Handle_Geom2d_BSplineCurve;
-class Handle_Geom2d_Curve;
+#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 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
@@ -47,10 +58,16 @@ protected:
     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 );
 
   HYDRODATA_EXPORT HYDROData_SequenceOfObjects GetProfiles() const;
   HYDRODATA_EXPORT void SetProfiles( const HYDROData_SequenceOfObjects& );
@@ -63,8 +80,6 @@ public:
 
   HYDRODATA_EXPORT virtual void Update();
 
-  HYDRODATA_EXPORT void CreateBankShapes( TopoDS_Edge& theLeft, TopoDS_Edge& theRight ) const;
-
 public:
   struct PointUZ
   {
@@ -75,83 +90,139 @@ public:
   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;
-  };
-  class Bank
-  {
-  public:
-    void reserve( int theNbPoints );
-    void push_back( const gp_Pnt& thePnt, const gp_Dir& theTangent );
-    void clear();
-    TopoDS_Edge createEdge3d() const;
-
-  private:
-    std::vector<gp_Pnt> myPoints;
-    std::vector<gp_Dir> myDirs;
+    gp_Vec2d myProfileDir;
+    double myDeltaZ;
+    double myMaxZ;
   };
 
 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,
+  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 GetProperties( const Handle_HYDROData_Profile& theProfile,
+  static void GetProperties( const Handle(HYDROData_Profile)& theProfile,
                              gp_Pnt& theLowestPoint, gp_Vec2d& theDir,
-                             bool isNormalDir,
                              double& theZMin, double& theZMax );
 
-  static void ProfileDiscretization( const Handle_HYDROData_Profile& theProfile,
-                                     double theXCurv, double theMinZ, double theMaxZ, double theDDZ,
+  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 Handle_Geom2d_BSplineCurve& theHydraulicAxis,
+  static void CurveTo3D( const Handle(Geom2d_BSplineCurve)& theHydraulicAxis,
                          const CurveUZ& theMidCurve, const CurveUZ& theWidthCurve,
-                         AltitudePoints& thePoints,
-                         Bank* theLeftBank = 0,
-                         Bank* theRightBank = 0,
-                         double dz = 0 );
+                         AltitudePoints& thePoints );
   
   static void Interpolate( const CurveUZ& theCurveA, const CurveUZ& theCurveB, 
                            int theNbSteps, std::vector<CurveUZ>& theInterpolation,
                            bool isAddSecond );
 
-  static 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,
-                                     Bank* theLeftBank = 0,
-                                     Bank* theRightBank = 0 );
+  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,
+  static AltitudePoints Interpolate( const std::vector<Handle(HYDROData_Profile)>& theProfiles,
                                      double theDDZ, double theSpatialStep,
-                                     Bank* theLeftBank = 0,
-                                     Bank* theRightBank = 0 );
+                                     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:
 
-private:
-  Bank myLeft;
-  Bank myRight;
+  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