#include "HYDROData_Profile.h"
#include "HYDROData_ShapesGroup.h"
#include "HYDROData_ShapesTool.h"
+#include "HYDROData_IAltitudeObject.h"
#include <TDataStd_RealArray.hxx>
}
void HYDROData_Stream::Update()
+{
+ updateProfilesOrder();
+ UpdatePrs();
+}
+
+void HYDROData_Stream::UpdatePrs()
{
HYDROData_NaturalObject::Update();
// Create the stream groups
createGroupObjects();
+
+ // This peace of code is for testing of functionality of altitude,
+ // will be removed by adv when testing will be finished
+ Handle(HYDROData_IAltitudeObject) anAltObj = GetAltitudeObject();
+ gp_XY aTestPnt( 5, 0 );
+ anAltObj->GetAltitudeForPoint( aTestPnt );
+ // End of test code
+
}
QColor HYDROData_Stream::DefaultFillingColor()
return QColor( Qt::transparent );
}
+bool HYDROData_Stream::IsValidAsAxis( const Handle(HYDROData_PolylineXY)& theHydAxis )
+{
+ if ( theHydAxis.IsNull() )
+ return false;
+
+ TopoDS_Shape aHydraulicShape = theHydAxis->GetShape();
+ if ( aHydraulicShape.IsNull() ||
+ aHydraulicShape.ShapeType() != TopAbs_WIRE ||
+ BRep_Tool::IsClosed( aHydraulicShape ) )
+ return false; // The polyline must be a single not closed wire
+
+ return true;
+}
+
+TopoDS_Shape getShapeFromGroup( const HYDROData_SequenceOfObjects& theGroups,
+ const int theGroupId )
+{
+ TopoDS_Shape aResShape;
+ if ( theGroups.Length() != 4 )
+ return aResShape;
+
+ Handle(HYDROData_ShapesGroup) aGroup =
+ Handle(HYDROData_ShapesGroup)::DownCast( theGroups.Value( theGroupId ) );
+ if ( aGroup.IsNull() )
+ return aResShape;
+
+ TopTools_SequenceOfShape aGroupShapes;
+ aGroup->GetShapes( aGroupShapes );
+
+ if ( !aGroupShapes.IsEmpty() )
+ aResShape = aGroupShapes.First();
+
+ return aResShape;
+}
+
+TopoDS_Shape HYDROData_Stream::GetLeftShape() const
+{
+ HYDROData_SequenceOfObjects aGroups = GetGroups();
+ return getShapeFromGroup( aGroups, 1 );
+}
+
+TopoDS_Shape HYDROData_Stream::GetRightShape() const
+{
+ HYDROData_SequenceOfObjects aGroups = GetGroups();
+ return getShapeFromGroup( aGroups, 2 );
+}
+
+TopoDS_Shape HYDROData_Stream::GetInletShape() const
+{
+ HYDROData_SequenceOfObjects aGroups = GetGroups();
+ return getShapeFromGroup( aGroups, 3 );
+}
+
+TopoDS_Shape HYDROData_Stream::GetOutletShape() const
+{
+ HYDROData_SequenceOfObjects aGroups = GetGroups();
+ return getShapeFromGroup( aGroups, 4 );
+}
+
QColor HYDROData_Stream::getDefaultFillingColor() const
{
return DefaultFillingColor();
bool HYDROData_Stream::SetHydraulicAxis( const Handle(HYDROData_PolylineXY)& theAxis )
{
- Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis();
-
- if ( theAxis.IsNull() )
- {
- RemoveHydraulicAxis();
- return !aPrevAxis.IsNull();
- }
-
- if ( IsEqual( aPrevAxis, theAxis ) )
+ if ( !IsValidAsAxis( theAxis ) )
return false;
- TopoDS_Wire aHydraulicWire = TopoDS::Wire( theAxis->GetShape() );
- if ( aHydraulicWire.IsNull() )
- return false; // The polyline must be a single wire
+ Handle(HYDROData_PolylineXY) aPrevAxis = GetHydraulicAxis();
+ if ( IsEqual( aPrevAxis, theAxis ) )
+ return true;
SetReferenceObject( theAxis, DataTag_HydraulicAxis );
const TopoDS_Face& thePlane,
Standard_Real& outPar)
{
- if ( theProfile.IsNull() || theHydAxis.IsNull() )
+ if ( theProfile.IsNull() || !IsValidAsAxis( theHydAxis ) )
return false;
TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() ); //guide line
InsertReferenceObject( theProfile, DataTag_Profile, theBeforeIndex );
}
-bool HYDROData_Stream::BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis, TopoDS_Face& thePlane) const
+bool HYDROData_Stream::BuildFace( const Handle(HYDROData_PolylineXY)& theHydAxis,
+ TopoDS_Face& thePlane ) const
{
- if ( theHydAxis.IsNull() ) return false;
+ if ( !IsValidAsAxis( theHydAxis ) )
+ return false;
+
TopoDS_Wire aHydraulicWire = TopoDS::Wire( theHydAxis->GetShape() );
- if(aHydraulicWire.IsNull()) return false;
+
gp_Ax2 aX2(gp::XOY());
gp_Ax3 aX3(aX2);
gp_Pln aPln(aX3);