-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
+// Copyright (C) 2014-2015 EDF-R&D
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
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( "" );
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
for ( int aProfileInd = 0; aProfileInd < theInterpolator->GetCalculatedProfilesNumber(); aProfileInd++ ) {
// Get calculated point coordinates
- std::vector<double> aResultCoords = theInterpolator->GetResultProfile( aProfileInd );
- div_t aDiv = std::div( aResultCoords.size(), 3 );
- if ( aDiv.rem != 0 ) {
+ 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 ) );
aProfile->SetName( aName );
// Fill the profile with points
- HYDROData_Profile::ProfilePoints aProfilePoints;
+ aProfile->SetProfilePoints( aResultPoints );
- int aPointsNb = aDiv.quot;
- for ( int aPointInd = 0; aPointInd <= aPointsNb - 1; aPointInd++ ) {
- int anXindex = aPointInd * 3;
- double anX = aResultCoords[ anXindex ];
- double anY = aResultCoords[ anXindex + 1 ];
- double aZ = aResultCoords[ anXindex + 2 ];
-
- aProfilePoints.Append( gp_XYZ( anX, anY, aZ ) );
+ // Add profile to the stream
+ bool isAdded = AddProfile( aProfile );
+ if ( !isAdded ) {
+ aProfile->Remove();
}
+ else
+ aProfile->Update();
+ }
- aProfile->SetProfilePoints( aProfilePoints );
+ if ( isOK )
+ Update();
- // Add profile to the stream
- isOK = AddProfile( aProfile ) && isOK;
+ 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;
}
- return isOK;
+ // 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