-// 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
//
#include "HYDROData_IProfilesInterpolator.h"
-
+#include <cstdlib>
+#include <gp_XYZ.hxx>
const int DEFAULT_RESULT_PROFILES_NB = 1; ///< default number of results profiles
{
}
-void HYDROData_IProfilesInterpolator::SetProfiles( const std::vector<double> theProfile1, const std::vector<double> theProfile2 )
+void HYDROData_IProfilesInterpolator::SetProfiles( const std::vector<double> theProfile1,
+ const std::vector<double> theProfile2 )
{
myProfile1 = theProfile1;
myProfile2 = theProfile2;
}
-void HYDROData_IProfilesInterpolator::SetParameter( const std::string& theName, const std::string& theValue )
+void HYDROData_IProfilesInterpolator::SetProfiles( const NCollection_Sequence<gp_XYZ>& theProfile1,
+ const NCollection_Sequence<gp_XYZ>& theProfile2 )
+{
+ // The first profile
+ for ( int i = theProfile1.Lower(); i <= theProfile1.Upper(); i++ ) {
+ const gp_XYZ& aPnt = theProfile1.Value( i );
+ myProfile1.push_back( aPnt.X() );
+ myProfile1.push_back( aPnt.Y() );
+ myProfile1.push_back( aPnt.Z() );
+ }
+
+ // The second profile
+ for ( int i = theProfile2.Lower(); i <= theProfile2.Upper(); i++ ) {
+ const gp_XYZ& aPnt = theProfile2.Value( i );
+ myProfile2.push_back( aPnt.X() );
+ myProfile2.push_back( aPnt.Y() );
+ myProfile2.push_back( aPnt.Z() );
+ }
+}
+
+void HYDROData_IProfilesInterpolator::SetParameter( const TCollection_AsciiString& theName,
+ const TCollection_AsciiString& theValue )
{
- myParameters[theName] = theValue;
+ myParameters[theName.ToCString()] = theValue.ToCString();
}
InterpolationError HYDROData_IProfilesInterpolator::GetErrorCode() const
myErrorCode = theError;
}
-std::string HYDROData_IProfilesInterpolator::GetErrorMessage() const
+TCollection_AsciiString HYDROData_IProfilesInterpolator::GetErrorMessage() const
{
- return myErrorMessage;
+ return TCollection_AsciiString(myErrorMessage.c_str());
}
void HYDROData_IProfilesInterpolator::SetErrorMessage( const std::string& theMessage )
myResultProfilesNumber = theNumber;
}
-std::vector<double> HYDROData_IProfilesInterpolator::GetResultProfile( const int theProfileIndex ) const
+int HYDROData_IProfilesInterpolator::GetCalculatedProfilesNumber() const
+{
+ return myResultProfiles.size();
+}
+
+std::vector<double> HYDROData_IProfilesInterpolator::GetResultProfileCoords( const int theProfileIndex ) const
{
std::vector<double> aResultProfile;
- if ( theProfileIndex > 0 && theProfileIndex < (int) myResultProfiles.size() ) {
+ if ( theProfileIndex >= 0 && theProfileIndex < (int) myResultProfiles.size() ) {
aResultProfile = myResultProfiles.at( theProfileIndex );
}
return aResultProfile;
}
+NCollection_Sequence<gp_XYZ> HYDROData_IProfilesInterpolator::GetResultProfilePoints( const int theProfileIndex ) const
+{
+ return GetPoints( GetResultProfileCoords( theProfileIndex ) );
+}
+
void HYDROData_IProfilesInterpolator::Reset()
{
+ // Reset input parameters
myProfile1.clear();
myProfile2.clear();
myParameters.clear();
SetResultProfilesNumber( DEFAULT_RESULT_PROFILES_NB );
+ // Reset result data
+ ClearResults();
+}
+
+std::vector<double> HYDROData_IProfilesInterpolator::GetFirstProfileCoords() const
+{
+ return myProfile1;
+}
+
+std::vector<double> HYDROData_IProfilesInterpolator::GetSecondProfileCoords() const
+{
+ return myProfile2;
+}
+
+void HYDROData_IProfilesInterpolator::ClearResults()
+{
+ // Clear result data
myResultProfiles.clear();
+ // Reset errors
SetErrorCode( OK );
SetErrorMessage( "" );
+}
+
+int HYDROData_IProfilesInterpolator::GetNbProfilesToCompute() const
+{
+ return myResultProfilesNumber;
+}
+
+void HYDROData_IProfilesInterpolator::InsertResultProfile( const std::vector<double>& theProfile )
+{
+ myResultProfiles.push_back( theProfile );
+}
+
+void HYDROData_IProfilesInterpolator::InsertResultProfile( const NCollection_Sequence<gp_XYZ>& theProfile )
+{
+ std::vector<double> aCoords;
+
+ for ( int i = theProfile.Lower(); i <= theProfile.Upper(); i++ ) {
+ const gp_XYZ& aPnt = theProfile.Value( i );
+ aCoords.push_back( aPnt.X() );
+ aCoords.push_back( aPnt.Y() );
+ aCoords.push_back( aPnt.Z() );
+ }
+
+ myResultProfiles.push_back( aCoords );
+}
+
+NCollection_Sequence<gp_XYZ> HYDROData_IProfilesInterpolator::GetFirstProfilePoints() const
+{
+ return GetPoints( GetFirstProfileCoords() );
+}
+
+NCollection_Sequence<gp_XYZ> HYDROData_IProfilesInterpolator::GetSecondProfilePoints() const
+{
+ return GetPoints( GetSecondProfileCoords() );
+}
+
+NCollection_Sequence<gp_XYZ> HYDROData_IProfilesInterpolator::GetPoints( const std::vector<double>& theCoords ) const
+{
+ NCollection_Sequence<gp_XYZ> aProfilePoints;
+
+ int aNbCoords = (int) theCoords.size();
+ div_t aDiv = std::div( aNbCoords, 3 );
+ if ( aDiv.rem == 0 ) {
+ for ( int i = 0; i < aNbCoords; i += 3 ) {
+ aProfilePoints.Append( gp_XYZ( theCoords[i], theCoords[i+1], theCoords[i+2] ) );
+ }
+ }
+
+ return aProfilePoints;
}
\ No newline at end of file