Skip to content

Commit

Permalink
Merge pull request #209 from PauloCarvalhoRJ/GeoGrid
Browse files Browse the repository at this point in the history
GeoGrid
  • Loading branch information
PauloCarvalhoRJ authored Oct 28, 2018
2 parents 14d08fa + ea0b4d3 commit ecb3ca5
Show file tree
Hide file tree
Showing 46 changed files with 2,724 additions and 484 deletions.
22 changes: 19 additions & 3 deletions GammaRay.pro
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,16 @@ SOURCES += main.cpp\
geostats/searchellipsoid.cpp \
geostats/pointsetcell.cpp \
geostats/indexedspatiallocation.cpp \
domain/geogrid.cpp \
domain/gridfile.cpp \
domain/auxiliary/meshloader.cpp \
geometry/vector3d.cpp \
geometry/face3d.cpp \
dialogs/sisimdialog.cpp \
dialogs/variograminputdialog.cpp
dialogs/variograminputdialog.cpp \
geometry/hexahedron.cpp \
geometry/pyramid.cpp \
geometry/tetrahedron.cpp

HEADERS += mainwindow.h \
domain/project.h \
Expand Down Expand Up @@ -420,8 +428,16 @@ HEADERS += mainwindow.h \
geostats/searchellipsoid.h \
geostats/pointsetcell.h \
geostats/indexedspatiallocation.h \
domain/geogrid.h \
domain/gridfile.h \
domain/auxiliary/meshloader.h \
geometry/vector3d.h \
geometry/face3d.h \
dialogs/sisimdialog.h \
dialogs/variograminputdialog.h
dialogs/variograminputdialog.h \
geometry/hexahedron.h \
geometry/pyramid.h \
geometry/tetrahedron.h


FORMS += mainwindow.ui \
Expand Down Expand Up @@ -603,7 +619,7 @@ win32 {
# The application version
# Don't forget to update the Util::importSettingsFromPreviousVersion() method to
# enable the import of registry/user settings of previous versions.
VERSION = 4.9
VERSION = 5.0

# Define a preprocessor macro so we can get the application version in application code.
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
Expand Down
Binary file added art/iconsHD/geogrid32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added art/iconsHD/geogrid32n.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified art/logo.odp
100644 → 100755
Binary file not shown.
2 changes: 2 additions & 0 deletions calculator/icalcproperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ QString ICalcProperty::getScriptCompatibleName()
compatibleName = compatibleName.replace( '+', '_' );
compatibleName = compatibleName.replace( '>', '_' );
compatibleName = compatibleName.replace( '<', '_' );
compatibleName = compatibleName.replace( ':', '_' );
compatibleName = compatibleName.replace( '=', '_' );
return compatibleName;
}
Binary file modified docs/GammaRayManual.docx
Binary file not shown.
Binary file modified docs/figures.pptx
Binary file not shown.
109 changes: 109 additions & 0 deletions domain/auxiliary/meshloader.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#include "meshloader.h"

#include <QFileInfo>
#include <QTextStream>

#include "util.h"
#include "../application.h"


MeshLoader::MeshLoader(QFile & file, std::vector<VertexRecordPtr> & vertexes,
std::vector<CellDefRecordPtr> & cellDefs,
uint & data_line_count, QObject * parent) :
QObject(parent),
_file(file),
m_vertexes( vertexes ),
m_cellDefs( cellDefs ),
_data_line_count(data_line_count),
_finished(false)
{

}

void MeshLoader::doLoad()
{
QTextStream in(&_file);
long bytesReadSofar = 0;
QStringList valuesAsString;

bool isInVertexesSection = false;

bool isInCellDefsSection = false;

for (int i = 0; !in.atEnd(); ++i)
{
//read file line by line
QString line = in.readLine();

//Clear the list with the tokenized data values as string
valuesAsString.clear();

//updates the progress
bytesReadSofar += line.size() + 1; //account for line break char (in Windows may have 2, though.)

if( ! ( i % 100 ) ){ //update progress for each 100 lines to not impact performance much
// allows tracking progress of a file up to about 400GB
emit progress( (int)(bytesReadSofar / 100) );
}

if( i == 0 || i == 1 ){} //first and second lines are ignored
else { //parse lines containing data (must be within the target interval)

if( !isInVertexesSection && !isInCellDefsSection &&
line.startsWith( "VERTEX LOCATIONS", Qt::CaseInsensitive ) ){
isInVertexesSection = true;
continue; //move on to the next file line
}

if( isInVertexesSection && !isInCellDefsSection &&
line.startsWith( "CELL VERTEX INDEXES", Qt::CaseInsensitive ) ){
isInVertexesSection = false;
isInCellDefsSection = true;
continue; //move on to the next file line
}

//read line from the GSLib data file
Util::fastSplit( line, valuesAsString );

if( isInVertexesSection ){
if( valuesAsString.size() != 3 ){
Application::instance()->logError( QString("MeshLoader::doLoad(): vertex coordinate count different from 3 in line ").append(QString::number(i)) );
m_vertexes.push_back( VertexRecordPtr( new VertexRecord{ 0.0, 0.0, 0.0 } ) );
} else {
bool ok[] = {true, true, true};
double x = valuesAsString[0].toDouble( &ok[0] );
double y = valuesAsString[1].toDouble( &ok[1] );
double z = valuesAsString[2].toDouble( &ok[2] );
if( !ok[0] || !ok[1] || !ok[2] )
Application::instance()->logError( QString("MeshLoader::doLoad(): error in vertex section of mesh file (line ").
append(QString::number(i)).append("): could not convert a value to double.") );
m_vertexes.push_back( VertexRecordPtr( new VertexRecord{ x, y, z } ) ) ;
}
} else if( isInCellDefsSection ) {
if( valuesAsString.size() != 8 ){
Application::instance()->logError( QString("MeshLoader::doLoad(): vertex id count in cell definition different from 8 in line ").append(QString::number(i)) );
m_cellDefs.push_back( CellDefRecordPtr( new CellDefRecord{ {0, 0, 0, 0, 0, 0, 0, 0} } ) );
} else {
bool ok[] = {true, true, true, true, true, true, true, true};
int vId[8];
vId[0] = valuesAsString[0].toInt( &ok[0] );
vId[1] = valuesAsString[1].toInt( &ok[1] );
vId[2] = valuesAsString[2].toInt( &ok[2] );
vId[3] = valuesAsString[3].toInt( &ok[3] );
vId[4] = valuesAsString[4].toInt( &ok[4] );
vId[5] = valuesAsString[5].toInt( &ok[5] );
vId[6] = valuesAsString[6].toInt( &ok[6] );
vId[7] = valuesAsString[7].toInt( &ok[7] );
if( !ok[0] || !ok[1] || !ok[2] || !ok[3] || !ok[4] || !ok[5] || !ok[6] || !ok[7] )
Application::instance()->logError( QString("MeshLoader::doLoad(): error in cell definition section of mesh file (line ").
append(QString::number(i)).append("): could not convert a value to unsigned integer.") );
m_cellDefs.push_back( CellDefRecordPtr( new CellDefRecord{ { vId[0], vId[1], vId[2], vId[3], vId[4], vId[5], vId[6], vId[7] } } ) );
}
}

++_data_line_count;
}
}

_finished = true;
}
38 changes: 38 additions & 0 deletions domain/auxiliary/meshloader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef MESHLOADER_H
#define MESHLOADER_H

#include <QObject>
#include <QFile>
#include "../geogrid.h"

/** This is an auxiliary class used in GeoGrid::loadMesh() to enable the progress dialog.
* The file is read in a separate thread, so the progress bar updates.
*/
class MeshLoader : public QObject
{

Q_OBJECT

public:
explicit MeshLoader(QFile &file,
std::vector< VertexRecordPtr > &vertexes,
std::vector< CellDefRecordPtr > &cellDefs,
uint &data_line_count,
QObject *parent = 0);

bool isFinished(){ return _finished; }

public slots:
void doLoad( );
signals:
void progress(int);

private:
QFile &_file;
std::vector< VertexRecordPtr > &m_vertexes;
std::vector< CellDefRecordPtr > &m_cellDefs;
uint &_data_line_count;
bool _finished;
};

#endif // MESHLOADER_H
Loading

0 comments on commit ecb3ca5

Please sign in to comment.