]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
6.12.2013. Stream3d presentation is added.
authorszy <szy@opencascade.com>
Fri, 6 Dec 2013 14:30:18 +0000 (14:30 +0000)
committerszy <szy@opencascade.com>
Fri, 6 Dec 2013 14:30:18 +0000 (14:30 +0000)
src/HYDROData/HYDROData_Stream.cxx

index 6a95bd0a69a94f730c791e599f126da3344d1cc4..c1ecbdf4ac8e550900b656d184c156456a88f14f 100644 (file)
@@ -42,6 +42,11 @@ typedef NCollection_DataMap<Standard_Real, Handle(HYDROData_Profile)> HYDROData_
 #include <TColStd_ListIteratorOfListOfReal.hxx>
 #include <TCollection_CompareOfReal.hxx>
 #include <SortTools_QuickSortOfReal.hxx>
+#include <TColgp_Array1OfPnt.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <GeomAPI_Interpolate.hxx>
+#include <Geom_BSplineCurve.hxx>
+#include <TopTools_Array1OfShape.hxx>
 //#define DEB_HASINT 1
 #ifdef DEB_HASINT
 #include <BRepTools.hxx>
@@ -104,7 +109,6 @@ TopoDS_Shape HYDROData_Stream::GetTopShape() const
 {
   return getTopShape();
 }
-
 TopoDS_Shape HYDROData_Stream::GetShape3D() const
 {
   return getShape3D();
@@ -125,23 +129,39 @@ void HYDROData_Stream::Update()
 
   bool anIsFirst = true;
   gp_Pnt aPrevFirstPoint, aPrevLastPoint;
-  
+  Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, aRefProfiles.Length());
+  Handle(TColgp_HArray1OfPnt) anArrayOfLPnt = new TColgp_HArray1OfPnt(1, aRefProfiles.Length());  
+  TopTools_Array1OfShape anArrOfProfiles(1, aRefProfiles.Length());
   // Construct the top presentation
   HYDROData_SequenceOfObjects::Iterator anIter( aRefProfiles );
-  for ( ; anIter.More(); anIter.Next() )
+  for (int i=1 ; anIter.More(); anIter.Next(),i++ )
   {
     Handle(HYDROData_Profile) aProfile =
       Handle(HYDROData_Profile)::DownCast( anIter.Value() );
     if ( aProfile.IsNull() )
-      continue;
-
+      continue;        
+       const TopoDS_Shape& aProf3d = aProfile->GetShape3D();
     gp_XY aPnt1, aPnt2;
     if ( !aProfile->GetFirstPoint( aPnt1 ) || !aProfile->GetLastPoint( aPnt2 ) )
       continue;
-    
-    gp_Pnt aCurFirstPoint( aPnt1.X(), aPnt1.Y(), 0 );
-    gp_Pnt aCurLastPoint(  aPnt2.X(), aPnt2.Y(), 0 );
-
+       anArrOfProfiles.SetValue(i,aProfile->GetShape3D());
+
+    gp_Pnt aCurFirstPoint( aPnt1.X(), aPnt1.Y(), 0 ), aCurFP;
+    gp_Pnt aCurLastPoint(  aPnt2.X(), aPnt2.Y(), 0 ), 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);
     if ( anIsFirst )
     {
       aPrevFirstPoint = aCurFirstPoint;
@@ -174,7 +194,40 @@ void HYDROData_Stream::Update()
   SetTopShape( a2dShell );
 
   // Construct the 3D presentation
-  /// TODO
+  Handle(Geom_BSplineCurve) aBSpline;
+  GeomAPI_Interpolate anInterpolator (anArrayOfFPnt, Standard_False, 1.0e-5); 
+  anInterpolator.Perform() ;
+  if (anInterpolator.IsDone()) 
+         aBSpline = anInterpolator.Curve();
+  else 
+   return;
+  if(aBSpline.IsNull())
+         return;
+  TopoDS_Edge anEdgLeft, anEdgRight;
+  BRepBuilderAPI_MakeEdge aMakeEdge(aBSpline);
+  if(aMakeEdge.IsDone()) 
+         anEdgLeft = aMakeEdge.Edge();
+  GeomAPI_Interpolate anInterpolator2 (anArrayOfLPnt, Standard_False, 1.0e-5); 
+  anInterpolator2.Perform() ;
+  if (anInterpolator2.IsDone()) 
+         aBSpline = anInterpolator2.Curve();
+  else 
+   return;
+  if(aBSpline.IsNull())
+    return; 
+  aMakeEdge.Init(aBSpline);
+  if(aMakeEdge.IsDone()) 
+         anEdgRight = aMakeEdge.Edge();
+  BRep_Builder aBB;
+  TopoDS_Compound aCmp;
+  aBB.MakeCompound(aCmp);
+  anIter.Init( aRefProfiles );
+  for (int i=1 ; i < anArrOfProfiles.Length() +1; i++ )  
+    aBB.Add(aCmp, anArrOfProfiles.Value(i));
+  aBB.Add(aCmp,anEdgLeft);
+  aBB.Add(aCmp,anEdgRight);
+  SetShape3D(aCmp);
+  //BRepTools::Write(aCmp, "str3d.brep");
 }
 
 bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )