Salome HOME
17.12.2013. Added Partition algorithm (draft version).
[modules/hydro.git] / src / HYDROData / HYDROData_Stream.cxx
index e49b2b795583bbe69d612a933165b53a64748f63..63e983ec1d35109f89a4b77de997c7387b09dbf7 100644 (file)
@@ -145,7 +145,7 @@ void HYDROData_Stream::Update()
 
   Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
   HYDROData_SequenceOfObjects aRefProfiles = GetProfiles();
-  if ( aHydAxis.IsNull() || aRefProfiles.IsEmpty() )
+  if ( aHydAxis.IsNull() || aRefProfiles.Length() < 2 )
     return; 
  
   bool anIsFirst = true;
@@ -165,7 +165,7 @@ void HYDROData_Stream::Update()
       continue;        
        const TopoDS_Shape& aProf3d = aProfile->GetShape3D();
     gp_XY aPnt1, aPnt2;
-    if ( !aProfile->GetFirstPoint( aPnt1 ) || !aProfile->GetLastPoint( aPnt2 ) )
+    if ( !aProfile->GetLeftPoint( aPnt1 ) || !aProfile->GetRightPoint( aPnt2 ) )
       continue;
        anArrOfProfiles.SetValue(i,aProfile->GetShape3D());//aProfile->GetTopShape();
        anArrOf2DProfiles.SetValue(i,aProfile->GetTopShape());
@@ -354,14 +354,15 @@ void HYDROData_Stream::RemoveHydraulicAxis()
   SetToUpdate( true );
 }
 
-bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
-                                                                          Standard_Real& outPar ) const
+bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_PolylineXY)& theHydAxis, 
+                                        const Handle(HYDROData_Profile)& theProfile, 
+                                        const TopoDS_Face& thePlane,
+                                                                                                         Standard_Real& outPar)
 {
-  Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
-  if ( theProfile.IsNull() || aHydAxis.IsNull() )
+  if ( theProfile.IsNull() || theHydAxis.IsNull() )
     return false; 
 
-  TopoDS_Wire aHydraulicWire = TopoDS::Wire( aHydAxis->GetShape() ); //guide line
+  TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() ); //guide line
   TopoDS_Wire aProfileWire = TopoDS::Wire( theProfile->GetTopShape() );
   if ( aHydraulicWire.IsNull() || aProfileWire.IsNull() )
     return false;
@@ -455,6 +456,14 @@ bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_Profile)& theProf
   return false;
 }
 
+bool HYDROData_Stream::HasIntersection( const Handle(HYDROData_Profile)& theProfile, const TopoDS_Face& thePlane,
+                                                                          Standard_Real& outPar ) const
+{
+  Handle(HYDROData_PolylineXY) aHydAxis = GetHydraulicAxis();
+
+  return HasIntersection( aHydAxis, theProfile, thePlane, outPar );
+}
+
 
 bool HYDROData_Stream::AddProfile( const Handle(HYDROData_Profile)& theProfile )
 {
@@ -761,6 +770,12 @@ void HYDROData_Stream::removeParameter( const int& theIndex )
   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 )