From: szy Date: Fri, 6 Dec 2013 14:30:18 +0000 (+0000) Subject: 6.12.2013. Stream3d presentation is added. X-Git-Tag: BR_hydro_v_0_5~37 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f603a9ac6b8db5ef3966bcb2dea2de26ed471de6;p=modules%2Fhydro.git 6.12.2013. Stream3d presentation is added. --- diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 6a95bd0a..c1ecbdf4 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -42,6 +42,11 @@ typedef NCollection_DataMap HYDROData_ #include #include #include +#include +#include +#include +#include +#include //#define DEB_HASINT 1 #ifdef DEB_HASINT #include @@ -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 )