2 #include "HYDROData_Stream.h"
4 #include "HYDROData_Document.h"
5 #include "HYDROData_PolylineXY.h"
6 #include "HYDROData_Profile.h"
8 #include <TDataStd_RealArray.hxx>
10 #include <Precision.hxx>
12 #include <NCollection_DataMap.hxx>
14 #include <TColStd_Array1OfReal.hxx>
15 #include <TColStd_ListOfReal.hxx>
16 #include <TColStd_ListIteratorOfListOfReal.hxx>
17 #include <TCollection_CompareOfReal.hxx>
18 #include <TColgp_Array1OfPnt.hxx>
19 #include <TColgp_HArray1OfPnt.hxx>
22 #include <TopoDS_Wire.hxx>
23 #include <TopoDS_Shell.hxx>
24 #include <TopoDS_Face.hxx>
25 #include <TopoDS_Edge.hxx>
26 #include <TopoDS_Vertex.hxx>
28 #include <TopExp_Explorer.hxx>
30 #include <Bnd_Box.hxx>
32 #include <BRep_Builder.hxx>
33 #include <BRepBuilderAPI_MakeEdge.hxx>
34 #include <BRepBuilderAPI_MakeWire.hxx>
35 #include <BRepBuilderAPI_MakeFace.hxx>
37 #include <BRepBndLib.hxx>
38 #include <BRepProj_Projection.hxx>
39 #include <BRepExtrema_ExtCC.hxx>
40 #include <BRepCheck_Analyzer.hxx>
50 #include <GeomAPI_Interpolate.hxx>
51 #include <Geom_BSplineCurve.hxx>
53 #include <TopTools_Array1OfShape.hxx>
55 #include <SortTools_QuickSortOfReal.hxx>
58 #include <QStringList>
60 //#define DEB_STREAM 1
62 //#define DEB_HASINT 1
63 //#define DEB_UPDATE 1
64 #include <BRepTools.hxx>
65 #include <TCollection_AsciiString.hxx>
68 #define PYTHON_STREAM_ID "KIND_STREAM"
70 typedef NCollection_DataMap<Standard_Real, Handle(HYDROData_Profile)> HYDROData_DataMapOfRealOfHDProfile;
72 IMPLEMENT_STANDARD_HANDLE(HYDROData_Stream,HYDROData_NaturalObject)
73 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Stream,HYDROData_NaturalObject)
76 HYDROData_Stream::HYDROData_Stream()
77 : HYDROData_NaturalObject()
81 HYDROData_Stream::~HYDROData_Stream()
85 QStringList HYDROData_Stream::DumpToPython( MapOfTreatedObjects& theTreatedObjects ) const
89 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
90 if ( aDocument.IsNull() )
93 QString aDocName = aDocument->GetDocPyName();
94 QString aStreamName = GetName();
96 aResList << QString( "%1 = %2.CreateObject( %3 );" )
97 .arg( aStreamName ).arg( aDocName ).arg( PYTHON_STREAM_ID );
98 aResList << QString( "%1.SetName( \"%2\" );" )
99 .arg( aStreamName ).arg( aStreamName );
100 aResList << QString( "" );
107 HYDROData_SequenceOfObjects HYDROData_Stream::GetAllReferenceObjects() const
109 HYDROData_SequenceOfObjects aResSeq = HYDROData_Object::GetAllReferenceObjects();
111 Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
112 if ( !aHydAxis.IsNull() )
113 aResSeq.Append( aHydAxis );
115 HYDROData_SequenceOfObjects aSeqOfProfiles = GetProfiles();
116 aResSeq.Append( aSeqOfProfiles );
121 TopoDS_Shape HYDROData_Stream::GetTopShape() const
123 return getTopShape();
126 TopoDS_Shape HYDROData_Stream::GetShape3D() const
131 Handle(Geom_BSplineCurve) HYDROData_Stream::buildInterpolationCurve(
132 const Handle(TColgp_HArray1OfPnt)& theArrayOfPnt )
134 Handle(Geom_BSplineCurve) aBSpline;
135 GeomAPI_Interpolate anInterpolator (theArrayOfPnt, Standard_False, 1.0e-5);
136 anInterpolator.Perform() ;
137 if (anInterpolator.IsDone())
138 aBSpline = anInterpolator.Curve();
142 void HYDROData_Stream::Update()
144 HYDROData_NaturalObject::Update();
146 Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
147 HYDROData_SequenceOfObjects aRefProfiles = GetProfiles();
148 if ( aHydAxis.IsNull() || aRefProfiles.Length() < 2 )
151 bool anIsFirst = true;
152 gp_Pnt aPrevFirstPoint, aPrevLastPoint;
153 Handle(TColgp_HArray1OfPnt) anArrayOfFPnt = new TColgp_HArray1OfPnt(1, aRefProfiles.Length());
154 Handle(TColgp_HArray1OfPnt) anArrayOfLPnt = new TColgp_HArray1OfPnt(1, aRefProfiles.Length());
155 TopTools_Array1OfShape anArrOfProfiles(1, aRefProfiles.Length());
156 TopTools_Array1OfShape anArrOf2DProfiles(1, aRefProfiles.Length());
159 HYDROData_SequenceOfObjects::Iterator anIter( aRefProfiles );
160 for (int i=1 ; anIter.More(); anIter.Next(),i++ )
162 Handle(HYDROData_Profile) aProfile =
163 Handle(HYDROData_Profile)::DownCast( anIter.Value() );
164 if ( aProfile.IsNull() )
166 const TopoDS_Shape& aProf3d = aProfile->GetShape3D();
168 if ( !aProfile->GetLeftPoint( aPnt1 ) || !aProfile->GetRightPoint( aPnt2 ) )
170 anArrOfProfiles.SetValue(i,aProfile->GetShape3D());//aProfile->GetTopShape();
171 anArrOf2DProfiles.SetValue(i,aProfile->GetTopShape());
173 gp_Pnt aCurFirstPoint( aPnt1.X(), aPnt1.Y(), 0 ), aCurFP;
174 gp_Pnt aCurLastPoint( aPnt2.X(), aPnt2.Y(), 0 ), aCurLP;
175 TopoDS_Vertex aV1, aV2;
176 TopExp::Vertices(TopoDS::Wire(aProf3d), aV1, aV2);
177 gp_Pnt aP1 = BRep_Tool::Pnt(aV1);
178 if(aP1.X() == aPnt1.X() && aP1.Y() == aPnt1.Y())
182 aP1 = BRep_Tool::Pnt(aV2);
183 if(aP1.X() == aPnt2.X() && aP1.Y() == aPnt2.Y())
187 anArrayOfFPnt->SetValue(i,aCurFP);
188 anArrayOfLPnt->SetValue(i,aCurLP);
192 // Construct of the 3D presentation
193 Handle(Geom_BSplineCurve) aBSpline = buildInterpolationCurve (anArrayOfFPnt);
194 if(aBSpline.IsNull())
196 TopoDS_Edge anEdgLeft, anEdgRight;
197 BRepBuilderAPI_MakeEdge aMakeEdge(aBSpline);
198 if(aMakeEdge.IsDone())
199 anEdgLeft = aMakeEdge.Edge();
200 if(anEdgLeft.IsNull())
203 aBSpline = buildInterpolationCurve (anArrayOfLPnt);
204 if(aBSpline.IsNull())
206 aMakeEdge.Init(aBSpline);
207 if(aMakeEdge.IsDone())
208 anEdgRight = aMakeEdge.Edge();
209 if(anEdgRight.IsNull())
212 TopoDS_Compound aCmp;
213 aBB.MakeCompound(aCmp);
214 anIter.Init( aRefProfiles );
215 for (int i=1 ; i < anArrOfProfiles.Length() +1; i++ )
216 aBB.Add(aCmp, anArrOfProfiles.Value(i));
217 aBB.Add(aCmp,anEdgLeft);
218 aBB.Add(aCmp,anEdgRight);
219 BRepCheck_Analyzer aCh(aCmp);
224 BRepTools::Write(aCmp, "str3d.brep");
229 // Construct the top presentation
230 for(int i=1;i<= anArrayOfLPnt->Length();i++) {
231 gp_Pnt aPnt = anArrayOfFPnt->Value(i);
232 aPnt.SetZ(.0); // make 2d
233 anArrayOfFPnt->SetValue(i, aPnt);
234 aPnt = anArrayOfLPnt->Value(i);
236 anArrayOfLPnt->SetValue(i, aPnt);
239 aBSpline = buildInterpolationCurve (anArrayOfFPnt);
240 if(aBSpline.IsNull())
242 aMakeEdge.Init(aBSpline);
243 if(aMakeEdge.IsDone())
244 anEdgLeft = aMakeEdge.Edge();
246 aBSpline = buildInterpolationCurve (anArrayOfLPnt);
247 if(aBSpline.IsNull())
249 aMakeEdge.Init(aBSpline);
250 if(aMakeEdge.IsDone())
251 anEdgRight = aMakeEdge.Edge();
252 if(anEdgRight.IsNull())
254 BRepBuilderAPI_MakeEdge aMakeEdge2(anArrayOfFPnt->Value(1),anArrayOfLPnt->Value(1));
255 TopoDS_Edge aBotEdge, aTopEdge;
256 if(aMakeEdge2.IsDone())
257 aBotEdge = aMakeEdge2.Edge();
258 BRepBuilderAPI_MakeEdge aMakeEdge3(anArrayOfFPnt->Value(anArrayOfFPnt->Length()),anArrayOfLPnt->Value(anArrayOfLPnt->Length()));
259 if(aMakeEdge3.IsDone())
260 aTopEdge = aMakeEdge3.Edge();
262 BRepBuilderAPI_MakeWire aMakeWire( aBotEdge, anEdgLeft, aTopEdge,anEdgRight);
263 TopoDS_Wire aSectProfileWire;
264 if(aMakeWire.IsDone())
265 aSectProfileWire = aMakeWire.Wire();
266 BRepBuilderAPI_MakeFace aMakeFace( aSectProfileWire, Standard_True );
269 if( aMakeFace.IsDone() )
270 aFace = aMakeFace.Face();
272 aBB.MakeCompound(aCmp);
274 for(int i=1;i <= anArrOf2DProfiles.Length(); i++)
275 aBB.Add(aCmp,anArrOf2DProfiles.Value(i));
281 BRepTools::Write(aCmp, "str2d.brep");
288 QColor HYDROData_Stream::DefaultFillingColor()
290 return QColor( Qt::green );
293 QColor HYDROData_Stream::DefaultBorderColor()
295 return QColor( Qt::transparent );
298 QColor HYDROData_Stream::getDefaultFillingColor() const
300 return DefaultFillingColor();
303 QColor HYDROData_Stream::getDefaultBorderColor() const
305 return DefaultBorderColor();
308 bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )
310 Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis();
312 if ( theAxis.IsNull() )
314 RemoveHydraulicAxis();
315 return !aPrevAxis.IsNull();
318 if ( IsEqual( aPrevAxis, theAxis ) )
321 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theAxis->GetShape() );
322 if ( aHydraulicWire.IsNull() )
323 return false; // The polyline must be a single wire
325 SetReferenceObject( theAxis, DataTag_HydraulicAxis );
327 // Update the order of profiles
328 updateProfilesOrder();
330 // Indicate model of the need to update the stream presentation
336 Handle(HYDROData_PolylineXY) HYDROData_Stream::GetHydraulicAxis() const
338 return Handle(HYDROData_PolylineXY)::DownCast(
339 GetReferenceObject( DataTag_HydraulicAxis ) );
342 void HYDROData_Stream::RemoveHydraulicAxis()
344 Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis();
345 if ( aPrevAxis.IsNull() )
348 ClearReferenceObjects( DataTag_HydraulicAxis );
350 // We remove the reference profiles
353 // Indicate model of the need to update the stream presentation
357 bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis,
358 const Handle(HYDROData_Profile)& theProfile,
359 const TopoDS_Face& thePlane,
360 Standard_Real& outPar)
362 if ( theProfile.IsNull() || theHydAxis.IsNull() )
365 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() ); //guide line
366 TopoDS_Wire aProfileWire = TopoDS::Wire( theProfile->GetTopShape() );
367 if ( aHydraulicWire.IsNull() || aProfileWire.IsNull() )
370 BRepProj_Projection aProjector (aProfileWire, thePlane, gp::OZ().Direction());
371 if(!aProjector.IsDone())
373 TopoDS_Shape aPrjProfile = aProjector.Shape();
374 if(aPrjProfile.IsNull())
376 TopoDS_Vertex aV1, aV2;
377 if(aPrjProfile.ShapeType() == TopAbs_EDGE)
378 TopExp::Vertices(TopoDS::Edge(aPrjProfile), aV1, aV2);
379 else if(aPrjProfile.ShapeType() == TopAbs_WIRE)
380 TopExp::Vertices(TopoDS::Wire(aPrjProfile), aV1, aV2);
381 else if(aPrjProfile.ShapeType() == TopAbs_COMPOUND){
382 TopExp_Explorer anExp(aPrjProfile, TopAbs_WIRE);
384 TopExp::Vertices(TopoDS::Wire(anExp.Current()), aV1, aV2);
386 anExp.Init(aPrjProfile, TopAbs_EDGE);
388 TopExp::Vertices(TopoDS::Edge(anExp.Current()), aV1, aV2);
392 if(aV1.IsNull() || aV2.IsNull())
394 gp_Pnt aPnt1 = BRep_Tool::Pnt(aV1);
395 gp_Pnt aPnt2 = BRep_Tool::Pnt(aV2);
398 BRepBuilderAPI_MakeEdge aMk(aPnt1, aPnt2);
401 const TopoDS_Edge& anEdg2 = aMk.Edge();//Section edge
402 Standard_Integer aNum(0);
404 TopExp_Explorer anExplo(aHydraulicWire, TopAbs_EDGE);
405 for(;anExplo.More();anExplo.Next()) aNum++;
406 // check for self-intersection
407 const Standard_Real SquareTolerance = Precision::Confusion()*Precision::Confusion();
408 Standard_Boolean hasInt(false);
409 Standard_Real aSqDist(DBL_MAX);
410 Standard_Integer anIndx(0);
411 BRepExtrema_ExtCC aCC;
412 aCC.Initialize(anEdg2);
414 anExplo.Init(aHydraulicWire, TopAbs_EDGE);
415 for(Standard_Integer j=1;anExplo.More();anExplo.Next(),j++) {
416 const TopoDS_Edge& anEdg1 = TopoDS::Edge(anExplo.Current());
419 Standard_Boolean hasSol(false);
423 for(Standard_Integer i=1; i<= aCC.NbExt();i++)
424 if(aCC.SquareDistance(i) < aSqDist) {
425 aSqDist = aCC.SquareDistance(i);
431 if(aSqDist <= SquareTolerance) { // hasInt
432 const gp_Pnt& aPnt = aCC.PointOnE1(anIndx);
434 TopExp::Vertices(anEdg1, aV1, aV2, Standard_True);
435 outPar += BRep_Tool::Pnt(aV1).Distance(aPnt);
437 Standard_Real aPar = aCC.ParameterOnE1(anIndx);
445 TopExp::Vertices(anEdg1, aV1, aV2);
446 outPar += BRep_Tool::Pnt(aV1).Distance(BRep_Tool::Pnt(aV2));
449 } else if(aNum > 1) {
450 TopExp::Vertices(anEdg1, aV1, aV2);
451 outPar += BRep_Tool::Pnt(aV1).Distance(BRep_Tool::Pnt(aV2));
459 bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
460 Standard_Real& outPar ) const
462 Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
464 return HasIntersection( aHydAxis, theProfile, thePlane, outPar );
468 bool HYDROData_Stream::AddProfile( const Handle(HYDROData_Profile)& theProfile )
470 if ( theProfile.IsNull() )
473 Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
474 if ( aHydAxis.IsNull() )
478 if(!BuildFace(aHydAxis, aPlane))
481 Standard_Real aPar(.0);
482 if ( HasReference( theProfile, DataTag_Profile ) || !HasIntersection( theProfile, aPlane, aPar ) )
483 return false; // Object is already in reference list or it has no intersection
485 int aProfileIndex = insertParameter( aPar );
486 insertProfileInToOrder( theProfile, aProfileIndex );
488 // Indicate model of the need to update the stream presentation
494 HYDROData_SequenceOfObjects HYDROData_Stream::GetProfiles() const
496 return GetReferenceObjects( DataTag_Profile );
499 bool HYDROData_Stream::RemoveProfile( const Handle(HYDROData_Profile)& theProfile )
501 if ( theProfile.IsNull() )
504 int aProfileIndex = -1;
506 HYDROData_SequenceOfObjects aRefProfiles = GetProfiles();
507 HYDROData_SequenceOfObjects::Iterator anIter( aRefProfiles );
508 for ( int i = 0 ; anIter.More(); anIter.Next(), ++i )
510 Handle(HYDROData_Profile) aProfile =
511 Handle(HYDROData_Profile)::DownCast( anIter.Value() );
512 if ( aProfile.IsNull() )
515 if ( IsEqual( theProfile, aProfile ) )
522 if ( aProfileIndex == -1 )
525 RemoveReferenceObject( theProfile->Label(), DataTag_Profile );
527 // Remove parameter for removed profile
528 removeParameter( aProfileIndex );
530 // Indicate model of the need to update the stream presentation
536 void HYDROData_Stream::RemoveProfiles()
538 bool anIsToUpdate = IsMustBeUpdated() || NbReferenceObjects( DataTag_Profile ) > 0;
540 ClearReferenceObjects( DataTag_Profile );
542 // Remove the parameters array
543 removeParametersArray();
545 // Indicate model of the need to update the stream presentation
546 SetToUpdate( anIsToUpdate );
549 void HYDROData_Stream::insertProfileInToOrder( const Handle(HYDROData_Profile)& theProfile,
550 const int theBeforeIndex )
552 Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
553 if ( theProfile.IsNull() || aHydAxis.IsNull() )
556 TopoDS_Wire aHydraulicWire = TopoDS::Wire( aHydAxis->GetShape() );
557 TopoDS_Wire aProfileWire = TopoDS::Wire( theProfile->GetTopShape() );
558 if ( aHydraulicWire.IsNull() || aProfileWire.IsNull() )
561 if ( theBeforeIndex == -1 )
562 AddReferenceObject( theProfile, DataTag_Profile );
564 InsertReferenceObject( theProfile, DataTag_Profile, theBeforeIndex );
567 bool HYDROData_Stream::BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis, TopoDS_Face& thePlane) const
569 if ( theHydAxis.IsNull() ) return false;
570 TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() );
571 if(aHydraulicWire.IsNull()) return false;
572 gp_Ax2 aX2(gp::XOY());
576 BRepBndLib::Add(aHydraulicWire,B);
577 Standard_Real axmin,aymin,azmin,axmax,aymax,azmax;
578 B.Get(axmin,aymin,azmin,axmax,aymax,azmax);
579 BRepBuilderAPI_MakeFace aMkr(aPln, axmin-500., axmax+500., aymin-500., aymax+500.); // to be tuned later according max/ Profile deviation
580 if(!aMkr.IsDone() || aMkr.Shape().IsNull()) return false;
581 thePlane = TopoDS::Face(aMkr.Shape());
585 void HYDROData_Stream::updateProfilesOrder()
587 HYDROData_SequenceOfObjects aRefProfiles = GetProfiles();
588 if ( aRefProfiles.IsEmpty() )
591 // At first we remove all profiles from order
594 Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
595 if ( aHydAxis.IsNull() )
599 if ( !BuildFace( aHydAxis, aPlane ) )
602 Standard_Real aPar( .0 );
606 TopoDS_Compound aCmp;
607 aBB.MakeCompound(aCmp);
610 HYDROData_DataMapOfRealOfHDProfile aDM;
611 TColStd_ListOfReal aList;
612 HYDROData_SequenceOfObjects::Iterator anIter( aRefProfiles );
613 for (int i = 1 ; anIter.More(); anIter.Next(), i++ )
615 Handle(HYDROData_Profile) aProfile =
616 Handle(HYDROData_Profile)::DownCast( anIter.Value() );
618 TopoDS_Wire aProfileWire = TopoDS::Wire( aProfile->GetTopShape() );
619 aBB.Add( aCmp, aProfileWire );
621 if ( aProfile.IsNull() || !HasIntersection( aProfile, aPlane, aPar ) )
624 aDM.Bind( aPar, aProfile );
625 aList.Append( aPar );
628 if ( aList.IsEmpty() )
631 TColStd_Array1OfReal anArr( 1, aList.Extent() );
633 TColStd_ListIteratorOfListOfReal it( aList );
634 for ( int j = 1; it.More(); it.Next(), j++ )
635 anArr( j ) = it.Value();
638 if ( aList.Extent() > 1 )
640 TCollection_CompareOfReal Compar;
641 SortTools_QuickSortOfReal::Sort( anArr, Compar );
643 for (int j = 1; j <= anArr.Length(); j++) {
644 const Standard_Real aKey = anArr(j);
645 const Handle(HYDROData_Profile)& aProfile = aDM.Find(aKey);
646 insertProfileInToOrder( aProfile );
648 } else if ( aList.Extent() == 1 ) {
649 const Standard_Real aKey = aList.Last();
650 const Handle(HYDROData_Profile)& aProfile = aDM.Find(aKey);
651 insertProfileInToOrder( aProfile );
654 setParametersArray( anArr );
657 TopoDS_Wire aHydraulicWire = TopoDS::Wire( aHydAxis->GetShape() );
658 BRepTools::Write(aHydraulicWire, "Path.brep");
659 BRepTools::Write(aCmp, "Prof.brep");
663 void HYDROData_Stream::setParametersArray( const TColStd_Array1OfReal& theArray )
665 if ( theArray.Length() == 0 )
667 removeParametersArray();
671 TDF_Label aLabel = myLab.FindChild( DataTag_ParamsArray );
673 Handle(TDataStd_RealArray) aParamsArray =
674 TDataStd_RealArray::Set( aLabel, theArray.Lower(), theArray.Upper() );
676 for ( int i = theArray.Lower(), n = theArray.Upper(); i <= n; ++i )
678 const Standard_Real& aParam = theArray( i );
679 aParamsArray->SetValue( i, aParam );
683 TColStd_Array1OfReal* HYDROData_Stream::getParametersArray() const
685 TColStd_Array1OfReal* anArray = NULL;
687 TDF_Label aLabel = myLab.FindChild( DataTag_ParamsArray, false );
688 if ( !aLabel.IsNull() )
690 Handle(TDataStd_RealArray) aParamsArray;
691 if ( aLabel.FindAttribute( TDataStd_RealArray::GetID(), aParamsArray ) )
693 anArray = new TColStd_Array1OfReal( aParamsArray->Lower(), aParamsArray->Upper() );
694 for ( int i = aParamsArray->Lower(), n = aParamsArray->Upper(); i <= n; ++i )
696 const Standard_Real& aParam = aParamsArray->Value( i );
697 anArray->SetValue( i, aParam );
705 void HYDROData_Stream::removeParametersArray()
707 TDF_Label aLabel = myLab.FindChild( DataTag_ParamsArray, false );
708 if ( !aLabel.IsNull() )
709 aLabel.ForgetAllAttributes();
712 int HYDROData_Stream::insertParameter( const Standard_Real& theParam )
716 TColStd_Array1OfReal* anArr = getParametersArray();
721 TColStd_Array1OfReal aNewArr( anArr->Lower(), anArr->Upper() + 1 );
723 bool isInserted = false;
724 for ( int i = anArr->Lower(), j = i, n = anArr->Upper(); i <= n; ++i, ++j )
726 const Standard_Real& aStoredParam = anArr->Value( i );
729 if ( theParam > aStoredParam )
735 aNewArr( j ) = theParam;
741 aNewArr( j ) = aStoredParam;
747 aNewArr( aNewArr.Upper() ) = theParam;
750 setParametersArray( aNewArr );
755 TColStd_Array1OfReal aNewArr( 1, 1 );
756 aNewArr.SetValue( 1, theParam );
757 setParametersArray( aNewArr );
763 void HYDROData_Stream::removeParameter( const int& theIndex )
765 TDF_Label aLabel = myLab.FindChild( DataTag_ParamsArray, false );
766 if ( aLabel.IsNull() )
769 Handle(TDataStd_RealArray) aParamsArray;
770 if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), aParamsArray ) )
773 if ( aParamsArray->Length() == 1 )
775 removeParametersArray();
779 TColStd_Array1OfReal aNewArr( aParamsArray->Lower(), aParamsArray->Upper() - 1 );
781 for ( int i = aParamsArray->Lower(), j = i, k = 0, n = aParamsArray->Upper(); i <= n; ++i, ++k )
783 const Standard_Real& aStoredParam = aParamsArray->Value( i );
787 aNewArr.SetValue( j, aStoredParam );
791 setParametersArray( aNewArr );