+
+void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination,
+ bool isGenerateNewName ) const
+{
+ // Get the document
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( aDocument.IsNull() ) {
+ return;
+ }
+
+ // Call base method
+ HYDROData_Entity::CopyTo( theDestination, isGenerateNewName );
+
+ Handle(HYDROData_Stream) aStreamCopy =
+ Handle(HYDROData_Stream)::DownCast( theDestination );
+
+ // Copy bottom polyline if exists
+ if ( !aStreamCopy.IsNull() ) {
+ const Handle(HYDROData_Polyline3D) aBottom = GetBottomPolyline();
+ if ( !aBottom.IsNull() ) {
+ aStreamCopy->ClearReferenceObjects( DataTag_BottomPolyline );
+ aStreamCopy->GenerateBottomPolyline();
+ const Handle(HYDROData_Polyline3D) aBottomCopy = aStreamCopy->GetBottomPolyline();
+ if ( !aBottomCopy.IsNull() && !aBottomCopy->GetPolylineXY().IsNull() ) {
+ aBottomCopy->GetPolylineXY()->Update();
+ aBottomCopy->Update();
+ }
+ }
+ }
+}
+
+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 )
+{
+ if ( theArrayOfFPnt.IsNull() || theArrayOfLPnt.IsNull() || theArrOfProfiles.IsNull() ) {
+ return false;
+ }
+
+ if ( theArrayOfFPnt->Length() != theArrayOfLPnt->Length() ) {
+ return false;
+ }
+
+ // Construct of the 3D presentation
+ Handle(Geom_BSplineCurve) aBSpline = buildInterpolationCurve (theArrayOfFPnt);
+ if(aBSpline.IsNull())
+ return false;
+
+ TopoDS_Edge anEdgLeft, anEdgRight;
+
+ BRepBuilderAPI_MakeEdge aMakeEdge(aBSpline);
+ if(aMakeEdge.IsDone())
+ anEdgLeft = aMakeEdge.Edge();
+
+ if(anEdgLeft.IsNull())
+ return false;
+
+ aBSpline.Nullify();
+ aBSpline = buildInterpolationCurve (theArrayOfLPnt);
+ if(aBSpline.IsNull())
+ return false;
+
+ aMakeEdge.Init(aBSpline);
+ if(aMakeEdge.IsDone())
+ anEdgRight = aMakeEdge.Edge();
+
+ if(anEdgRight.IsNull())
+ return false;
+
+ BRep_Builder aBB;
+ TopoDS_Compound aCmp;
+ aBB.MakeCompound(aCmp);
+ for (int i=1 ; i < theArrOfProfiles->Length() +1; i++ )
+ aBB.Add(aCmp, theArrOfProfiles->Value(i));
+
+ aBB.Add(aCmp,anEdgLeft);
+ aBB.Add(aCmp,anEdgRight);
+ BRepCheck_Analyzer aCh(aCmp);
+ if(aCh.IsValid())
+ thePrs.myPrs3D = aCmp;
+#ifdef DEB_UPDATE
+ else {
+ BRepTools::Write(aCmp, "str3d.brep");
+ thePrs.myPrs3D = aCmp;
+ }
+#endif
+
+ // Construct the top presentation
+ int aNbPoints = theArrayOfFPnt->Length();
+ Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, aNbPoints);
+ Handle(TColgp_HArray1OfPnt) anArrayOfLPnt = new TColgp_HArray1OfPnt(1, aNbPoints);
+ for( int i=1; i <= aNbPoints; i++ ) {
+ gp_Pnt aPnt = theArrayOfFPnt->Value(i);
+ aPnt.SetZ(.0); // make 2d
+ anArrayOfFPnt->SetValue(i, aPnt);
+ aPnt = theArrayOfLPnt->Value(i);
+ aPnt.SetZ(.0);
+ anArrayOfLPnt->SetValue(i, aPnt);
+ }
+
+ aBSpline.Nullify();
+ aBSpline = buildInterpolationCurve (anArrayOfFPnt);
+ if(aBSpline.IsNull())
+ return false;
+
+ aMakeEdge.Init(aBSpline);
+ if(aMakeEdge.IsDone())
+ anEdgLeft = aMakeEdge.Edge();
+
+ aBSpline.Nullify();
+ aBSpline = buildInterpolationCurve (anArrayOfLPnt);
+ if(aBSpline.IsNull())
+ return false;
+
+ aMakeEdge.Init(aBSpline);
+ if(aMakeEdge.IsDone())
+ anEdgRight = aMakeEdge.Edge();
+ if(anEdgRight.IsNull())
+ return false;
+
+ BRepBuilderAPI_MakeEdge aMakeEdge2(anArrayOfFPnt->Value(1),anArrayOfLPnt->Value(1));
+ TopoDS_Edge aBotEdge, aTopEdge;
+ if(aMakeEdge2.IsDone())
+ aBotEdge = aMakeEdge2.Edge();
+
+ BRepBuilderAPI_MakeEdge aMakeEdge3(anArrayOfFPnt->Value(anArrayOfFPnt->Length()),anArrayOfLPnt->Value(anArrayOfLPnt->Length()));
+ if(aMakeEdge3.IsDone())
+ aTopEdge = aMakeEdge3.Edge();
+
+ // Make wire for 2D presentation with updating of corresponding edges
+ BRepBuilderAPI_MakeWire aMakeWire;
+
+ aMakeWire.Add( aBotEdge );
+ thePrs.myInlet = aMakeWire.Edge();
+
+ aMakeWire.Add( anEdgLeft );
+ thePrs.myLeftBank = aMakeWire.Edge();
+
+ aMakeWire.Add( aTopEdge );
+ thePrs.myOutlet = aMakeWire.Edge();
+
+ aMakeWire.Add( anEdgRight );
+ thePrs.myRightBank = aMakeWire.Edge();
+
+ TopoDS_Wire aSectProfileWire;
+ if(aMakeWire.IsDone())
+ aSectProfileWire = aMakeWire.Wire();
+
+ BRepBuilderAPI_MakeFace aMakeFace( aSectProfileWire, Standard_True );
+ TopoDS_Face aFace;
+ aMakeFace.Build();
+ if( aMakeFace.IsDone() )
+ aFace = aMakeFace.Face();
+
+ TopoDS_Shape aPrs2D;
+
+ if ( !theArrOf2DProfiles.IsNull() ) {
+ aCmp.Nullify();
+ aBB.MakeCompound(aCmp);
+ aBB.Add(aCmp,aFace);
+ for(int i=1;i <= theArrOf2DProfiles->Length(); i++)
+ aBB.Add(aCmp, theArrOf2DProfiles->Value(i));
+
+ aPrs2D = aCmp;
+ } else {
+ aPrs2D = aFace;
+ }
+
+ aCh.Init(aPrs2D);
+ if(aCh.IsValid())
+ thePrs.myPrs2D = aPrs2D;
+#ifdef DEB_UPDATE
+ else {
+ BRepTools::Write(aPrs2D, "str2d.brep");
+ thePrs.myPrs2D = aPrs2D;
+ }
+#endif
+
+ return true;
+}
\ No newline at end of file