+#ifdef DEB_HASINT
+ TopoDS_Wire aProfileWire = TopoDS::Wire( aProfile->GetTopShape() );
+ aBB.Add( aCmp, aProfileWire );
+#endif
+ if ( aProfile.IsNull() || !HasIntersection( aProfile, aPlane, aPar ) )
+ continue;
+
+ aDM.Bind( aPar, aProfile );
+ aList.Append( aPar );
+ }
+
+ if ( aList.IsEmpty() )
+ return;
+
+ TColStd_Array1OfReal anArr( 1, aList.Extent() );
+
+ TColStd_ListIteratorOfListOfReal it( aList );
+ for ( int j = 1; it.More(); it.Next(), j++ )
+ anArr( j ) = it.Value();
+
+ // sorting
+ if ( aList.Extent() > 1 )
+ {
+ TCollection_CompareOfReal Compar;
+ SortTools_QuickSortOfReal::Sort( anArr, Compar );
+
+ for (int j = 1; j <= anArr.Length(); j++) {
+ const Standard_Real aKey = anArr(j);
+ const Handle(HYDROData_Profile)& aProfile = aDM.Find(aKey);
+ insertProfileInToOrder( aProfile );
+ }
+ } else if ( aList.Extent() == 1 ) {
+ const Standard_Real aKey = aList.Last();
+ const Handle(HYDROData_Profile)& aProfile = aDM.Find(aKey);
+ insertProfileInToOrder( aProfile );
+ }
+
+ setParametersArray( anArr );
+
+#ifdef DEB_HASINT
+ TopoDS_Wire aHydraulicWire = TopoDS::Wire( aHydAxis->GetShape() );
+ BRepTools::Write(aHydraulicWire, "Path.brep");
+ BRepTools::Write(aCmp, "Prof.brep");
+#endif
+}
+
+ObjectKind HYDROData_Stream::getAltitudeObjectType() const
+{
+ return KIND_STREAM_ALTITUDE;
+}
+
+void HYDROData_Stream::setParametersArray( const TColStd_Array1OfReal& theArray )
+{
+ if ( theArray.Length() == 0 )
+ {
+ removeParametersArray();
+ return;
+ }
+
+ TDF_Label aLabel = myLab.FindChild( DataTag_ParamsArray );
+
+ Handle(TDataStd_RealArray) aParamsArray =
+ TDataStd_RealArray::Set( aLabel, theArray.Lower(), theArray.Upper() );
+
+ for ( int i = theArray.Lower(), n = theArray.Upper(); i <= n; ++i )
+ {
+ const Standard_Real& aParam = theArray( i );
+ aParamsArray->SetValue( i, aParam );
+ }
+}
+
+TColStd_Array1OfReal* HYDROData_Stream::getParametersArray() const
+{
+ TColStd_Array1OfReal* anArray = NULL;
+
+ TDF_Label aLabel = myLab.FindChild( DataTag_ParamsArray, false );
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_RealArray) aParamsArray;
+ if ( aLabel.FindAttribute( TDataStd_RealArray::GetID(), aParamsArray ) )
+ {
+ anArray = new TColStd_Array1OfReal( aParamsArray->Lower(), aParamsArray->Upper() );
+ for ( int i = aParamsArray->Lower(), n = aParamsArray->Upper(); i <= n; ++i )
+ {
+ const Standard_Real& aParam = aParamsArray->Value( i );
+ anArray->SetValue( i, aParam );
+ }
+ }
+ }
+
+ return anArray;
+}
+
+void HYDROData_Stream::removeParametersArray()
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_ParamsArray, false );
+ if ( !aLabel.IsNull() )
+ aLabel.ForgetAllAttributes();
+}
+
+int HYDROData_Stream::insertParameter( const Standard_Real& theParam )
+{
+ int aResIndex = -1;
+
+ TColStd_Array1OfReal* anArr = getParametersArray();
+ if ( anArr )
+ {
+ aResIndex = 0;
+
+ TColStd_Array1OfReal aNewArr( anArr->Lower(), anArr->Upper() + 1 );
+
+ bool isInserted = false;
+ for ( int i = anArr->Lower(), j = i, n = anArr->Upper(); i <= n; ++i, ++j )
+ {
+ const Standard_Real& aStoredParam = anArr->Value( i );
+ if ( !isInserted )
+ {
+ if ( theParam > aStoredParam )
+ {
+ aResIndex++;
+ }
+ else
+ {
+ aNewArr( j ) = theParam;
+ isInserted = true;
+ ++j;
+ }
+ }
+
+ aNewArr( j ) = aStoredParam;
+ }
+
+ if ( !isInserted )
+ {
+ aResIndex = -1;
+ aNewArr( aNewArr.Upper() ) = theParam;
+ }
+
+ setParametersArray( aNewArr );
+ delete anArr;
+ }
+ else
+ {
+ TColStd_Array1OfReal aNewArr( 1, 1 );
+ aNewArr.SetValue( 1, theParam );
+ setParametersArray( aNewArr );
+ }
+
+ return aResIndex;
+}
+
+void HYDROData_Stream::removeParameter( const int& theIndex )
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_ParamsArray, false );
+ if ( aLabel.IsNull() )
+ return;
+
+ Handle(TDataStd_RealArray) aParamsArray;
+ if ( !aLabel.FindAttribute( TDataStd_RealArray::GetID(), aParamsArray ) )
+ return;
+
+ if ( aParamsArray->Length() == 1 )
+ {
+ removeParametersArray();
+ return;
+ }
+
+ TColStd_Array1OfReal aNewArr( aParamsArray->Lower(), aParamsArray->Upper() - 1 );
+
+ for ( int i = aParamsArray->Lower(), j = i, k = 0, n = aParamsArray->Upper(); i <= n; ++i, ++k )
+ {
+ const Standard_Real& aStoredParam = aParamsArray->Value( i );
+ if ( k == theIndex )