X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROData%2FHYDROData_Stream.cxx;h=29b7aae65a1f1b64c81ff8b6cad78aaae1b6c208;hb=f9bd5128a1aed8c1974b1d1cfb87aff32191fa60;hp=6610c1fc0b8d9cc32853b18cc449877751d0623e;hpb=70c7074d98594928a559f402ed02db0e562f2553;p=modules%2Fhydro.git diff --git a/src/HYDROData/HYDROData_Stream.cxx b/src/HYDROData/HYDROData_Stream.cxx index 6610c1fc..29b7aae6 100644 --- a/src/HYDROData/HYDROData_Stream.cxx +++ b/src/HYDROData/HYDROData_Stream.cxx @@ -1,8 +1,4 @@ -// 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 @@ -122,10 +118,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( "" ); @@ -1123,6 +1119,17 @@ Handle(HYDROData_Polyline3D) HYDROData_Stream::GetBottomPolyline() const 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 @@ -1143,13 +1150,12 @@ bool HYDROData_Stream::Interpolate( HYDROData_IProfilesInterpolator* theInterpol for ( int aProfileInd = 0; aProfileInd < theInterpolator->GetCalculatedProfilesNumber(); aProfileInd++ ) { // Get calculated point coordinates - std::vector 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 ) ); @@ -1158,23 +1164,48 @@ bool HYDROData_Stream::Interpolate( HYDROData_IProfilesInterpolator* theInterpol 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