]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
new presentation using DTM
authorasl <asl@opencascade.com>
Wed, 5 Oct 2016 14:23:42 +0000 (17:23 +0300)
committerasl <asl@opencascade.com>
Wed, 5 Oct 2016 14:23:54 +0000 (17:23 +0300)
src/HYDROData/HYDROData_Channel.cxx
src/HYDROData/HYDROData_DTM.cxx
src/HYDROData/HYDROData_DTM.h
src/HYDROData/HYDROData_Stream.cxx
src/HYDROData/HYDROData_Stream.h
src/HYDROGUI/HYDROGUI_StreamOp.cxx

index 14ac7fb6e94bda367fe9f2617240d7c84a0aadf7..79fd3d2564e24830b202419a2eb4579fc084c94a 100644 (file)
@@ -280,8 +280,9 @@ bool HYDROData_Channel::CreatePresentations( const Handle(HYDROData_Polyline3D)&
   // Create presentation
   HYDROData_Stream::PrsDefinition aPrs;
   Handle(TopTools_HArray1OfShape) anArrOf2DProfiles; // we don't need 2D profiles for channel/digue presentation
-  bool aRes = HYDROData_Stream::CreatePresentations( anArrayOfFPnt, anArrayOfLPnt,
-                                                     anArrOfProfiles, anArrOf2DProfiles, aPrs );
+  bool aRes = false;
+  /*TODO: HYDROData_Stream::CreatePresentations( anArrayOfFPnt, anArrayOfLPnt,
+                                                     anArrOfProfiles, anArrOf2DProfiles, aPrs );*/
   if ( aRes ) {
     thePrs.myPrs3D = aPrs.myPrs3D;
     thePrs.myPrs2D = TopoDS::Face( aPrs.myPrs2D );
index 579c09eb19386692d46980371ac2a602ff987db1..ff489634164f0b3d3be3ae119f519eb44fbc8b79 100644 (file)
@@ -97,7 +97,7 @@ void HYDROData_DTM::Bank::clear()
   myDirs.clear();
 }
 
-TopoDS_Edge HYDROData_DTM::Bank::createEdge( bool is3d ) const
+TopoDS_Edge HYDROData_DTM::Bank::createEdge3d() const
 {
   size_t n = myPoints.size();
   Handle_Geom_BSplineCurve aCurve;
@@ -109,11 +109,7 @@ TopoDS_Edge HYDROData_DTM::Bank::createEdge( bool is3d ) const
   for( size_t i = 1; i <= n; i++ )
   {
     gp_Pnt aPnt = myPoints[i-1];
-    if( !is3d )
-      aPnt.SetZ( 0.0 );
     gp_Vec aVec = myDirs[i-1];
-    if( !is3d )
-      aVec.SetZ( 0.0 );
     points->SetValue( (int)i, aPnt );
     tangents.SetValue( (int)i, aVec );
     flags->SetValue( (int)i, Standard_True );
@@ -671,3 +667,9 @@ HYDROData_Bathymetry::AltitudePoints HYDROData_DTM::Interpolate
   }
   return points;
 }
+
+void HYDROData_DTM::CreateBankShapes( TopoDS_Edge& theLeft, TopoDS_Edge& theRight ) const
+{
+  theLeft = myLeft.createEdge3d();
+  theRight = myRight.createEdge3d();
+}
index 717a9ed588850a5c21719710444d86b466335110..22bdcaa7dc6ea943c6a3951b7faa1a1006e91e9b 100644 (file)
@@ -63,6 +63,8 @@ public:
 
   HYDRODATA_EXPORT virtual void Update();
 
+  HYDRODATA_EXPORT void CreateBankShapes( TopoDS_Edge& theLeft, TopoDS_Edge& theRight ) const;
+
 public:
   struct PointUZ
   {
@@ -90,7 +92,7 @@ public:
     void reserve( int theNbPoints );
     void push_back( const gp_Pnt& thePnt, const gp_Dir& theTangent );
     void clear();
-    TopoDS_Edge createEdge( bool is3d ) const;
+    TopoDS_Edge createEdge3d() const;
 
   private:
     std::vector<gp_Pnt> myPoints;
index 9f166d7a45e63dafe520072f1bdb6dd07163aa17..33515d7d7640d2e311280b29032808e40ed4c4ce 100644 (file)
@@ -192,6 +192,7 @@ void HYDROData_Stream::Update()
     }
   }
 
+  DTM()->Update();
   UpdatePrs();
 }
 
@@ -200,64 +201,43 @@ bool HYDROData_Stream::IsHas2dPrs() const
   return true;
 }
 
-bool HYDROData_Stream::CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis,
-                                            const HYDROData_SequenceOfObjects&  theProfiles,
-                                            PrsDefinition&                      thePrs )
+bool HYDROData_Stream::CreatePresentations( const Handle_HYDROData_DTM& theDTM,
+                                            PrsDefinition&              thePrs )
 {
-  if ( theHydAxis.IsNull() || theProfiles.Length() < 2 )
+  if ( theDTM.IsNull() )
     return false;
 
-  Handle(TColgp_HArray1OfPnt) anArrayOfFPnt    = new TColgp_HArray1OfPnt(1, theProfiles.Length());
-  Handle(TColgp_HArray1OfPnt) anArrayOfLPnt    = new TColgp_HArray1OfPnt(1, theProfiles.Length());  
-  Handle(TopTools_HArray1OfShape) anArrOfProfiles = new TopTools_HArray1OfShape(1, theProfiles.Length());
-  Handle(TopTools_HArray1OfShape) anArrOf2DProfiles = new TopTools_HArray1OfShape(1, theProfiles.Length());
+  HYDROData_SequenceOfObjects profiles = theDTM->GetProfiles();
+  if( profiles.Length() < 2 )
+    return false;
+
+  TopTools_ListOfShape profiles3d;
 
   // Pre-processing
-  HYDROData_SequenceOfObjects::Iterator anIter( theProfiles );
+  HYDROData_SequenceOfObjects::Iterator anIter( profiles );
   for (int i=1 ; anIter.More(); anIter.Next(),i++ )
   {
     Handle(HYDROData_Profile) aProfile =
       Handle(HYDROData_Profile)::DownCast( anIter.Value() );
-    if ( aProfile.IsNull() )
-      continue;
 
-    const TopoDS_Shape& aProf3d = aProfile->GetShape3D();
-    gp_XY aPnt1, aPnt2;
-    if ( !aProfile->GetLeftPoint( aPnt1, false ) || !aProfile->GetRightPoint( aPnt2, false ) )
+    if ( aProfile.IsNull() )
       continue;
 
-    anArrOfProfiles->SetValue(i,aProfile->GetShape3D());//aProfile->GetTopShape();
-    anArrOf2DProfiles->SetValue(i,aProfile->GetTopShape());
-
-    gp_Pnt aCurFP, aCurLP;
-    TopoDS_Vertex aV1, aV2;
-    TopExp::Vertices(TopoDS::Wire(aProf3d), aV1, aV2);
-       gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
-    if(aP1.X() == aPnt1.X() && aP1.Y() == aPnt1.Y())
-      aCurFP = aP1;
-    else
-      aCurLP = aP1;
-    aP1 = BRep_Tool::Pnt(aV2);
-    if(aP1.X() == aPnt2.X() && aP1.Y() == aPnt2.Y())
-      aCurLP = aP1;
-    else
-      aCurFP = aP1;
-    anArrayOfFPnt->SetValue(i,aCurFP);
-    anArrayOfLPnt->SetValue(i,aCurLP);
+    const TopoDS_Shape& aProfileShape = aProfile->GetShape3D();
+    profiles3d.Append( aProfileShape );
   }
 
-  return CreatePresentations( anArrayOfFPnt, anArrayOfLPnt, anArrOfProfiles, anArrOf2DProfiles, thePrs );
+  TopoDS_Edge aLeftBank, aRightBank;
+  theDTM->CreateBankShapes( aLeftBank, aRightBank );
+  return CreatePresentations( aLeftBank, aRightBank, profiles3d, thePrs );
 }
 
 void HYDROData_Stream::UpdatePrs()
 {
   HYDROData_NaturalObject::Update();
 
-  Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
-  HYDROData_SequenceOfObjects aRefProfiles = GetProfiles();
-
   PrsDefinition aResultPrs;
-  if ( !CreatePresentations( aHydAxis, aRefProfiles, aResultPrs ) )
+  if ( !CreatePresentations( DTM(), aResultPrs ) )
     return;
 
   SetShape3D( aResultPrs.myPrs3D );
@@ -1064,13 +1044,13 @@ void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination,
   }
 }
 
-bool HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt)     theArrayOfFPnt,
-                                            const Handle(TColgp_HArray1OfPnt)     theArrayOfLPnt,
-                                            const Handle(TopTools_HArray1OfShape) theArrOfProfiles,
-                                            const Handle(TopTools_HArray1OfShape) theArrOf2DProfiles,
-                                            PrsDefinition&                        thePrs )
+bool HYDROData_Stream::CreatePresentations( const TopoDS_Edge&          theLeftBank,
+                                            const TopoDS_Edge&          theRightBank,
+                                            const TopTools_ListOfShape& theProfiles3d,
+                                            PrsDefinition&              thePrs )
 {
-  if ( theArrayOfFPnt.IsNull() || theArrayOfLPnt.IsNull() || theArrOfProfiles.IsNull() ) {
+  return true;
+  /*if ( theArrayOfFPnt.IsNull() || theArrayOfLPnt.IsNull() || theArrOfProfiles.IsNull() ) {
     return false;
   }
 
@@ -1213,5 +1193,5 @@ bool HYDROData_Stream::CreatePresentations( const Handle(TColgp_HArray1OfPnt)
   }
 #endif
 
-  return true;
+  return true;*/
 }
\ No newline at end of file
index 06dd511d19de35664cfa39f54484c6f705fc32ce..fdc74c6304afde74f41090a603d4318db92b1c07 100644 (file)
@@ -35,6 +35,7 @@ class HYDROData_IProfilesInterpolator;
 class TColStd_Array1OfReal;
 class Handle(TopTools_HArray1OfShape);
 class Handle_HYDROData_DTM;
+class TopTools_ListOfShape;
 
 
 /**\class HYDROData_Stream
@@ -49,10 +50,10 @@ public:
   {
     TopoDS_Shape myPrs3D;
     TopoDS_Shape myPrs2D;
-    TopoDS_Edge  myLeftBank;
-    TopoDS_Edge  myRightBank;
-    TopoDS_Edge  myInlet;
-    TopoDS_Edge  myOutlet;
+    TopoDS_Edge  myLeftBank;   // 3d curve of the left bank
+    TopoDS_Edge  myRightBank;  // 3d curve of the right bank
+    TopoDS_Edge  myInlet;      // first (inlet) 2d profile 
+    TopoDS_Edge  myOutlet;     // last (inlet) 2d profile 
   };
 
 protected:
@@ -77,19 +78,17 @@ public:
   /**
    * Creates the presentations(2D and 3D) by given hydraulic axis and profiles.
    */
-  HYDRODATA_EXPORT static bool CreatePresentations( const Handle(HYDROData_PolylineXY)& theHydAxis,
-                                                    const HYDROData_SequenceOfObjects&  theProfiles,
-                                                    PrsDefinition&                      thePrs );
+  HYDRODATA_EXPORT static bool CreatePresentations( const Handle_HYDROData_DTM& theDTM,
+                                                    PrsDefinition&              thePrs );
 
   /**
    * Creates the presentations(2D and 3D) by given first points, last points and profiles.
    * If 2D profiles is null - they will not used in the presentation.
    */
-  HYDRODATA_EXPORT static bool CreatePresentations( const Handle(TColgp_HArray1OfPnt)     theArrayOfFPnt,
-                                                    const Handle(TColgp_HArray1OfPnt)     theArrayOfLPnt,
-                                                    const Handle(TopTools_HArray1OfShape) theArrOfProfiles,
-                                                    const Handle(TopTools_HArray1OfShape) theArrOf2DProfiles,
-                                                    PrsDefinition&                        thePrs );
+  HYDRODATA_EXPORT static bool CreatePresentations( const TopoDS_Edge&          theLeftBank,
+                                                    const TopoDS_Edge&          theRightBank,
+                                                    const TopTools_ListOfShape& theProfiles3d,
+                                                    PrsDefinition&              thePrs );
 
 public:
 
index 7a66f2de568afb21224f13236c306e3575e0a3b2..0e7020de8ff5ec0caf0fe74e6d27accf4a714378 100755 (executable)
@@ -329,11 +329,11 @@ void HYDROGUI_StreamOp::createPreview()
   }
 
   HYDROData_Stream::PrsDefinition aPrsDef;
-  if ( !HYDROData_Stream::CreatePresentations( aHydAxis, aRefProfiles, aPrsDef ) )
+  /*TODO: if ( !HYDROData_Stream::CreatePresentations( aHydAxis, aRefProfiles, aPrsDef ) )
   {
     erasePreview();
     return;
-  }
+  }*/
 
   myPreviewPrs->setShape( aPrsDef.myPrs2D );
 }