#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>
{
return getTopShape();
}
-
TopoDS_Shape HYDROData_Stream::GetShape3D() const
{
return getShape3D();
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;
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 )