SetRightPoint( aPnt, false );
}
+HYDROData_Profile::ProfilePoint HYDROData_Profile::GetBottomPoint() const
+{
+ ProfilePoint aBottom;
+
+ // Get parametric points
+ HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints();
+ if ( aParametricPoints.Length() < 1 ) {
+ return aBottom;
+ }
+
+ // Calculate midvalue for U parameter
+ Standard_Real anUMidValue = aParametricPoints.First().X();
+ Standard_Real anUMinValue = anUMidValue;
+ Standard_Real anUMaxValue = anUMidValue;
+
+ for ( int i = 2, aNbPoints = aParametricPoints.Size(); i <= aNbPoints; i++ ) {
+ const HYDROData_IPolyline::Point& aParPoint = aParametricPoints.Value( i );
+ Standard_Real anU = aParPoint.X();
+
+ if ( anU < anUMinValue ) {
+ anUMinValue = anU;
+ } else if ( anU > anUMaxValue ) {
+ anUMaxValue = anU;
+ }
+ }
+
+ anUMidValue = ( anUMinValue + anUMaxValue ) / 2;
+
+ // Find index of the parametric point with minimal Z value
+ int aBottomIndex = 1;
+ HYDROData_IPolyline::Point aParBottom = aParametricPoints.First();
+
+ for ( int i = 2, aNbPoints = aParametricPoints.Size(); i <= aNbPoints; i++ ) {
+ const HYDROData_IPolyline::Point& aParPoint = aParametricPoints.Value( i );
+ if ( aParPoint.Y() < aParBottom.Y() ) {
+ aBottomIndex = i;
+ aParBottom = aParPoint;
+ } else if ( aParPoint.Y() == aParBottom.Y() ) {
+ // Check which point is neares to the U = 0.5
+ if ( fabs( aParPoint.X() - anUMidValue ) < fabs( aParBottom.X() - anUMidValue ) ) {
+ aBottomIndex = i;
+ aParBottom = aParPoint;
+ }
+ }
+ }
+
+ // Find the corresponding profile point
+ ProfilePoints aProfilePoints = GetProfilePoints( false );
+ if ( aBottomIndex >= 1 && aBottomIndex <= aProfilePoints.Length() ) {
+ aBottom = aProfilePoints.Value( aBottomIndex );
+ }
+
+ return aBottom;
+}
#include "HYDROData_Document.h"
#include "HYDROData_PolylineXY.h"
+#include "HYDROData_Polyline3D.h"
#include "HYDROData_Profile.h"
#include "HYDROData_ShapesGroup.h"
#include "HYDROData_ShapesTool.h"
#include "HYDROData_IAltitudeObject.h"
+#include "HYDROData_Tool.h"
#include <TDataStd_RealArray.hxx>
setPythonReferenceObject( theTreatedObjects, aResList, aProfile, "AddProfile" );
}
+ // Create bottom polyline if exists
+ const Handle(HYDROData_Polyline3D) aBottomPolyline = GetBottomPolyline();
+ if ( !aBottomPolyline.IsNull() ) {
+ aResList << QString( "%1.GenerateBottomPolyline();" ).arg( aName );
+ }
+
aResList << QString( "" );
aResList << QString( "%1.Update();" ).arg( aName );
aResList << QString( "" );
void HYDROData_Stream::Update()
{
updateProfilesOrder();
+
+ // Update bottom polyline if exists
+ const Handle(HYDROData_Polyline3D) aBottomPolyline = GetBottomPolyline();
+ if ( !aBottomPolyline.IsNull() ) {
+ if ( GenerateBottomPolyline() ) {
+ Handle(HYDROData_PolylineXY) aPolylineXY = aBottomPolyline->GetPolylineXY();
+ if ( !aPolylineXY.IsNull() ) {
+ aPolylineXY->Update();
+ }
+ aBottomPolyline->Update();
+ }
+ }
+
UpdatePrs();
}
anInGroup->AddShape( aResultPrs.myInlet );
QString anOutGroupName = GetName() + "_Outlet";
-
+
Handle(HYDROData_ShapesGroup) anOutGroup = createGroupObject();
anOutGroup->SetName( anOutGroupName );
anOutGroup->AddShape( aResultPrs.myOutlet );
setParametersArray( aNewArr );
}
+
+bool HYDROData_Stream::GenerateBottomPolyline()
+{
+ // Get the document
+ Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+ if ( aDocument.IsNull() ) {
+ return false;
+ }
+
+ // Collect bottom points ( one bottom point from each profile of the stream )
+ HYDROData_Profile::ProfilePoints aBottomPoints;
+
+ HYDROData_SequenceOfObjects aSeqOfProfiles = GetProfiles();
+ for ( int i = 1, aNb = aSeqOfProfiles.Size(); i <= aNb; i++ ) {
+ const Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aSeqOfProfiles.Value( i ) );
+ if ( aProfile.IsNull() ) {
+ continue;
+ }
+
+ aBottomPoints.Append( aProfile->GetBottomPoint() );
+ }
+
+ int aNbBottomPoints = aBottomPoints.Size();
+
+ if ( aNbBottomPoints < 2 ) {
+ return false;
+ }
+
+ // Create bottom polyline object if the stream doesn't contain it yet
+ Handle(HYDROData_Polyline3D) aBottom = GetBottomPolyline();
+ if ( aBottom.IsNull() ) {
+ aBottom = Handle(HYDROData_Polyline3D)::DownCast( aDocument->CreateObject( KIND_POLYLINE ) );
+ QString aBaseName = GetName() + "_bottom";
+ QString aName = HYDROData_Tool::GenerateObjectName( aDocument, aBaseName, QStringList(), true );
+ aBottom->SetName( aName );
+
+ SetReferenceObject( aBottom, DataTag_BottomPolyline );
+ }
+
+ // Create 2D polyline if the bottom polyline doesn't contain it yet
+ Handle(HYDROData_PolylineXY) aPolylineXY = aBottom->GetPolylineXY();
+ if ( aPolylineXY.IsNull() ) {
+ aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( aDocument->CreateObject( KIND_POLYLINEXY ) );
+ QString aBaseName = GetName() + "_bottom_2d";
+ QString aName = HYDROData_Tool::GenerateObjectName( aDocument, aBaseName, QStringList(), true );
+ aPolylineXY->SetName( aName );
+ aBottom->SetPolylineXY( aPolylineXY, false );
+ }
+
+ aPolylineXY->RemoveSections();
+ aPolylineXY->AddSection( "", HYDROData_PolylineXY::SECTION_SPLINE, false );
+
+ // Create profile if the bottom polyline doesn't contain it yet
+ Handle(HYDROData_ProfileUZ) aProfileUZ = aBottom->GetProfileUZ();
+ if ( aProfileUZ.IsNull() ) {
+ Handle(HYDROData_Profile) aProfile =
+ Handle(HYDROData_Profile)::DownCast( aDocument->CreateObject( KIND_PROFILE ) );
+ QString aBaseName = GetName() + "_bottom_profile";
+ QString aName = HYDROData_Tool::GenerateObjectName( aDocument, aBaseName, QStringList(), true );
+ aProfile->SetName( aName );
+ aProfileUZ = aProfile->GetProfileUZ( true );
+ aBottom->SetProfileUZ( aProfileUZ );
+ }
+
+ aProfileUZ->RemoveSection( 0 );
+
+ // Fill 2D polyline
+ for ( int i = 1; i <= aNbBottomPoints; i++ ) {
+ const HYDROData_Profile::ProfilePoint& aBottomPoint = aBottomPoints.Value( i );
+ aPolylineXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
+ }
+
+ // Calculate profile UZ points
+
+ // First point
+ const HYDROData_Profile::ProfilePoint& aFirstBottomPoint = aBottomPoints.First();
+ aProfileUZ->AddPoint( 0, HYDROData_ProfileUZ::Point( 0, aFirstBottomPoint.Z() ) );
+
+ // Intermediate points
+ double aPolylineCommonDist = aPolylineXY->GetDistance( 0, aPolylineXY->NbPoints( 0 ) - 1 );
+
+ for ( int i = 2, aNbPoints = aBottomPoints.Size(); i < aNbPoints; i++ ) {
+ const HYDROData_Profile::ProfilePoint& aBottomPoint = aBottomPoints.Value( i );
+
+ double aDistance = aPolylineXY->GetDistance( 0, i - 1 );
+
+ Standard_Real anU = aDistance; // = ( aDistance / aPolylineCommonDist ) * aPolylineCommonDist;
+ aProfileUZ->AddPoint( 0, HYDROData_ProfileUZ::Point( anU, aBottomPoint.Z() ) );
+ }
+
+ // Last point
+ const HYDROData_Profile::ProfilePoint& aLastBottomPoint = aBottomPoints.Last();
+ aProfileUZ->AddPoint( 0, HYDROData_ProfileUZ::Point( aPolylineCommonDist, aLastBottomPoint.Z() ) );
+
+ return true;
+}
+
+Handle(HYDROData_Polyline3D) HYDROData_Stream::GetBottomPolyline() const
+{
+ return Handle(HYDROData_Polyline3D)::DownCast(
+ GetReferenceObject( DataTag_BottomPolyline ) );
+}
DEFINE_STANDARD_HANDLE(HYDROData_Stream, HYDROData_NaturalObject)
class Handle(HYDROData_PolylineXY);
+class Handle(HYDROData_Polyline3D);
class Handle(HYDROData_Profile);
class TColStd_Array1OfReal;
DataTag_First = HYDROData_NaturalObject::DataTag_First + 100, ///< first tag, to reserve
DataTag_HydraulicAxis, ///< reference hydraulic axis
DataTag_Profile, ///< reference profiles
- DataTag_ParamsArray ///< parameters array
+ DataTag_ParamsArray, ///< parameters array
+ DataTag_BottomPolyline ///< reference bottom polyline
};
public:
* Removes all reference profile objects from stream.
*/
HYDRODATA_EXPORT virtual void RemoveProfiles();
+
+ /**
+ * Generates bottom polyline for stream or update the existing bottom polyline.
+ * \return true in case of success
+ */
+ HYDRODATA_EXPORT virtual bool GenerateBottomPolyline();
+
+ /**
+ * Returns reference bottom polyline object of stream.
+ */
+ HYDRODATA_EXPORT virtual Handle(HYDROData_Polyline3D) GetBottomPolyline() const;
protected: