return aRes;
}
-bool HYDROData_Bathymetry::ImportFromFile( const TCollection_AsciiString& theFileName )
+bool HYDROData_Bathymetry::ImportFromFiles( const QStringList& theFileNames )
{
- // Try to open the file
- QFile aFile( theFileName.ToCString() );
- if ( !aFile.exists() || !aFile.open( QIODevice::ReadOnly ) )
- return false;
+ AltitudePoints AllPoints;
+ bool Stat = false;
- bool aRes = false;
+ foreach (QString theFileName, theFileNames)
+ {
+ // Try to open the file
+ QFile aFile( theFileName );
+ if ( !aFile.exists() || !aFile.open( QIODevice::ReadOnly ) )
+ continue;
- QString aFileSuf = QFileInfo( aFile ).suffix().toLower();
+ QString aFileSuf = QFileInfo( aFile ).suffix().toLower();
- AltitudePoints aPoints;
- HYDROData_Bathymetry::AltitudePoints aPoints;
++ HYDROData_Bathymetry::AltitudePoints aPoints;
- // Try to import the file
- if ( aFileSuf == "xyz" )
- aRes = importFromXYZFile( aFile, aPoints );
- else if ( aFileSuf == "asc" )
- aRes = importFromASCFile( aFile, aPoints );
+ // Try to import the file
+ if ( aFileSuf == "xyz" )
+ Stat = importFromXYZFile( aFile, aPoints );
+ else if ( aFileSuf == "asc" )
+ Stat = importFromASCFile( aFile, aPoints );
- // Close the file
- aFile.close();
-
+ if (!Stat)
+ continue; //ignore this points
+
+ // Close the file
+ aFile.close();
+
+ AllPoints.Append(aPoints);
+ }
// Convert from global to local CS
Handle_HYDROData_Document aDoc = HYDROData_Document::Document( myLab );
- AltitudePoints::Iterator anIter( AllPoints );
- for ( ; anIter.More(); anIter.Next() )
- HYDROData_Bathymetry::AltitudePoints::iterator anIter = aPoints.begin(), aLast = aPoints.end();
++ HYDROData_Bathymetry::AltitudePoints::iterator anIter = AllPoints.begin(), aLast = AllPoints.end();
+ for ( ; anIter!=aLast; ++anIter )
{
- AltitudePoint& aPoint = anIter.ChangeValue();
- aDoc->Transform( aPoint, true );
+ HYDROData_Bathymetry::AltitudePoint& aPoint = *anIter;
+ aDoc->Transform( aPoint.X, aPoint.Y, aPoint.Z, true );
}
- if ( aRes )
+ if ( Stat )
{
// Update file path and altitude points of this Bathymetry
- SetFilePath( theFileName );
- SetAltitudePoints( aPoints );
+ SetFilePaths (theFileNames );
+ SetAltitudePoints( AllPoints );
}
- return Stat && !AllPoints.IsEmpty();
- return aRes && !aPoints.empty();
++ return Stat && !AllPoints.empty();
}
bool HYDROData_Bathymetry::importFromXYZFile( QFile& theFile,
if ( !createTestFile( aFileName ) )
return; // No file has been created
- CPPUNIT_ASSERT( aBathymetry->ImportFromFile( aFileName.toStdString().c_str() ) );
+ CPPUNIT_ASSERT( aBathymetry->ImportFromFiles( QStringList(aFileName)) );
HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry->GetAltitudePoints();
- CPPUNIT_ASSERT_EQUAL( 2300, anAltitudePoints.Length() );
+ CPPUNIT_ASSERT_EQUAL( 2300, (int)anAltitudePoints.size() );
gp_XY aTestPoint( 1, 1 );
double anAltitude = aBathymetry->GetAltitudeForPoint( aTestPoint, 1 );
if ( anIsFileCreated )
{
- CPPUNIT_ASSERT( aBathymetry1->ImportFromFile( aFileName.toStdString().c_str() ) );
+ CPPUNIT_ASSERT( aBathymetry1->ImportFromFiles( QStringList(aFileName ) ) );
HYDROData_Bathymetry::AltitudePoints anAltitudePoints = aBathymetry1->GetAltitudePoints();
- CPPUNIT_ASSERT_EQUAL( 2300, anAltitudePoints.Length() );
+ CPPUNIT_ASSERT_EQUAL( 2300, (int)anAltitudePoints.size() );
}
Handle(HYDROData_Bathymetry) aBathymetry2 =