X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Stream.cxx;h=6ffdd0ee43ec1d1110e89b351d5c97bcb11b6e30;hb=c7cf59e092fe050003d1e556715e3ac97acf6bd4;hp=656e1b02b63be1012b24b7a7dcd7b670eb001c20;hpb=5329000cef6285d57edc215edf771ce682ae9c6d;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 656e1b02..6ffdd0ee 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -29,6 +29,7 @@ #include "HYDROData_ShapesGroup.h" #include "HYDROData_ShapesTool.h" #include "HYDROData_IAltitudeObject.h" +#include "HYDROData_IProfilesInterpolator.h" #include "HYDROData_Tool.h" #include @@ -121,10 +122,10 @@ QStringList HYDROData_Stream::DumpToPython( MapOfTreatedObjects& theTreatedObjec setPythonReferenceObject( theTreatedObjects, aResList, aProfile, "AddProfile" ); } - // Create bottom polyline if exists + // Set bottom polyline if exists const Handle(HYDROData_Polyline3D) aBottomPolyline = GetBottomPolyline(); if ( !aBottomPolyline.IsNull() ) { - aResList << QString( "%1.GenerateBottomPolyline();" ).arg( aName ); + setPythonReferenceObject( theTreatedObjects, aResList, aBottomPolyline, "SetBottomPolyline" ); } aResList << QString( "" ); @@ -1121,3 +1122,94 @@ Handle(HYDROData_Polyline3D) HYDROData_Stream::GetBottomPolyline() const return Handle(HYDROData_Polyline3D)::DownCast( GetReferenceObject( DataTag_BottomPolyline ) ); } + +bool HYDROData_Stream::SetBottomPolyline( const Handle(HYDROData_Polyline3D)& theBottom ) +{ + if ( theBottom.IsNull() ) { + return false; + } + + SetReferenceObject( theBottom, DataTag_BottomPolyline ); + + return true; +} + +bool HYDROData_Stream::Interpolate( HYDROData_IProfilesInterpolator* theInterpolator ) +{ + // Get the document + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if ( aDocument.IsNull() ) { + return false; + } + + if ( theInterpolator->GetCalculatedProfilesNumber() < 1 ) { + theInterpolator->Calculate(); + } + + if ( theInterpolator->GetErrorCode() != OK ) { + return false; + } + + bool isOK = true; + + for ( int aProfileInd = 0; aProfileInd < theInterpolator->GetCalculatedProfilesNumber(); aProfileInd++ ) { + // Get calculated point coordinates + HYDROData_Profile::ProfilePoints aResultPoints = theInterpolator->GetResultProfilePoints( aProfileInd ); + if ( aResultPoints.IsEmpty() ) { + isOK = false; + continue; + } + + // Create profile object + Handle(HYDROData_Profile) aProfile = + Handle(HYDROData_Profile)::DownCast( aDocument->CreateObject( KIND_PROFILE ) ); + QString aBaseName = GetName() + "_interp_profile"; + QString aName = HYDROData_Tool::GenerateObjectName( aDocument, aBaseName ); + aProfile->SetName( aName ); + + // Fill the profile with points + aProfile->SetProfilePoints( aResultPoints ); + + // Add profile to the stream + bool isAdded = AddProfile( aProfile ); + if ( !isAdded ) { + aProfile->Remove(); + } + else + aProfile->Update(); + } + + if ( isOK ) + Update(); + + return isOK; +} + +void HYDROData_Stream::CopyTo( const Handle(HYDROData_Entity)& theDestination ) const +{ + // Get the document + Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab ); + if ( aDocument.IsNull() ) { + return; + } + + // Call base method + HYDROData_Entity::CopyTo( theDestination ); + + Handle(HYDROData_Stream) aStreamCopy = + Handle(HYDROData_Stream)::DownCast( theDestination ); + + // Copy bottom polyline if exists + if ( !aStreamCopy.IsNull() ) { + const Handle(HYDROData_Polyline3D) aBottom = GetBottomPolyline(); + if ( !aBottom.IsNull() ) { + aStreamCopy->ClearReferenceObjects( DataTag_BottomPolyline ); + aStreamCopy->GenerateBottomPolyline(); + const Handle(HYDROData_Polyline3D) aBottomCopy = aStreamCopy->GetBottomPolyline(); + if ( !aBottomCopy.IsNull() && !aBottomCopy->GetPolylineXY().IsNull() ) { + aBottomCopy->GetPolylineXY()->Update(); + aBottomCopy->Update(); + } + } + } +} \ No newline at end of file