cctw  0.2.1
Public Slots | Public Member Functions | Properties | Private Attributes | List of all members
CctwComparer Class Reference

#include <cctwcomparer.h>

Inheritance diagram for CctwComparer:
Inheritance graph
Collaboration diagram for CctwComparer:
Collaboration graph

Public Slots

void compareDatasets ()
 
void compareDatasetsRigorously ()
 
void compareDatasetsApproximately ()
 
- Public Slots inherited from CctwObject
virtual void printLine (QString line)
 
virtual void printMessage (QString msg, QDateTime dt=QDateTime::currentDateTime())
 
virtual QString settingsScript ()
 
QString scriptValueLiteral (QVariant v)
 

Public Member Functions

 CctwComparer (CctwApplication *application, QString name, QObject *parent=0)
 
virtual ~CctwComparer ()
 
- Public Member Functions inherited from CctwObject
 CctwObject (QString name, QObject *parent=0)
 
virtual void writeSettings (QSettings *set, QString section)
 
virtual void readSettings (QSettings *set, QString section)
 

Properties

QString filePath1
 
QString dataset1
 
QString filePath2
 
QString dataset2
 
bool compareRigorously
 
bool compareApproximately
 
- Properties inherited from CctwObject
QString name
 

Private Attributes

CctwApplicationm_Application
 

Detailed Description

Definition at line 8 of file cctwcomparer.h.

Constructor & Destructor Documentation

CctwComparer::CctwComparer ( CctwApplication application,
QString  name,
QObject *  parent = 0 
)
explicit

Definition at line 5 of file cctwcomparer.cpp.

5  :
6  CctwObject(name, parent),
7  m_Application(application),
8  m_FilePath1(m_Application->saver(), this, "filePath1", "", "Path to 1st file"),
9  m_Dataset1(m_Application->saver(), this, "dataset1", "data", "Name of dataset within 1st file"),
10  m_FilePath2(m_Application->saver(), this, "filePath2", "", "Path to 2nd file"),
11  m_Dataset2(m_Application->saver(), this, "dataset2", "data", "Name of dataset within 2nd file"),
12  m_CompareRigorously(m_Application->saver(), this, "compareRigorously", false, "Perform rigorous compare (every element) of imported data"),
13  m_CompareApproximately(m_Application->saver(), this, "compareApproximately", true, "Perform approximate compare (about 30 seconds) of imported data")
14 {
15 }
QString name
Definition: cctwobject.h:32
CctwApplication * m_Application
Definition: cctwcomparer.h:23
QcepSettingsSaverWPtr saver() const
CctwObject(QString name, QObject *parent=0)
Definition: cctwobject.cpp:7
CctwComparer::~CctwComparer ( )
virtual

Definition at line 17 of file cctwcomparer.cpp.

18 {
19 }

Member Function Documentation

void CctwComparer::compareDatasets ( )
slot

Definition at line 21 of file cctwcomparer.cpp.

References compareDatasetsApproximately(), compareDatasetsRigorously(), and CctwObject::printMessage().

Referenced by CctwqtSetupCompareDialog::accept().

22 {
23  printMessage("Compare datasets");
24 
25  if (get_CompareRigorously()) {
27  }
28 
29  if (get_CompareApproximately()) {
31  }
32 }
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime())
Definition: cctwobject.cpp:25
void compareDatasetsApproximately()
void compareDatasetsRigorously()
void CctwComparer::compareDatasetsApproximately ( )
slot

Definition at line 44 of file cctwcomparer.cpp.

References CctwInputDataH5::dimensions(), m_Application, CctwObject::printMessage(), randomIndex(), CctwInputDataH5::readChunk(), CctwVector3D< T >::toString(), CctwVector3D< T >::x(), CctwVector3D< T >::y(), and CctwVector3D< T >::z().

Referenced by compareDatasets().

45 {
46  printMessage("Compare datasets approximately");
47 
48  CctwInputDataH5 d1(get_FilePath1(), get_Dataset1(), "d1", this);
49  CctwInputDataH5 d2(get_FilePath2(), get_Dataset2(), "d2", this);
50 
51  CctwIntVector3D dim1 = d1.dimensions();
52  CctwIntVector3D dim2 = d2.dimensions();
53 
54  if (dim1 != dim2) {
55  printMessage(tr("Dataset dimensions are not the same (%1 vs %2)")
56  .arg(dim1.toString()).arg(dim2.toString()));
57 
58  return;
59  }
60 
61  QTime startAt;
62  startAt.start();
63  int n=0;
64 
65  while (startAt.elapsed() < 60*1000
66  && !m_Application->get_Halting()
67  && n < 100) {
68  int nx = randomIndex(12)+4;
69  int ny = randomIndex(12)+4;
70  int nz = randomIndex(12)+4;
71 
72  int ix = randomIndex(dim1.x()-nx);
73  int iy = randomIndex(dim1.y()-ny);
74  int iz = randomIndex(dim1.z()-nz);
75 
76  QVector<double> c1 = d1.readChunk(ix, iy, iz, nx, ny, nz);
77  QVector<double> c2 = d2.readChunk(ix, iy, iz, nx, ny, nz);
78 
79  if (c1.count() != c2.count()) {
80  n++;
81  printMessage(tr("Chunk data lengths are not the same for chunk %1 :: %2: (%3 vs %4)")
82  .arg(CctwIntVector3D(ix,iy,iz).toString())
83  .arg(CctwIntVector3D(nx,ny,nz).toString())
84  .arg(c1.count()).arg(c2.count()));
85  } else {
86  for (int i=0; i<c1.count(); i++) {
87  if (c1[i] != c2[i]) {
88  n++;
89  printMessage(tr("Chunk values differ in chunk %1 :: %2: at %3 (%4 vs %5)")
90  .arg(CctwIntVector3D(ix,iy,iz).toString())
91  .arg(CctwIntVector3D(nx,ny,nz).toString())
92  .arg(i).arg(c1[i]).arg(c2[i]));
93  break;
94  }
95  }
96  }
97  }
98 
99  printMessage(tr("Compare completed, %1 errors found").arg(n));
100 }
QString toString()
CctwApplication * m_Application
Definition: cctwcomparer.h:23
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime())
Definition: cctwobject.cpp:25
T x() const
Definition: cctwvector3d.h:17
T z() const
Definition: cctwvector3d.h:19
CctwVector3D< int > CctwIntVector3D
Definition: cctwvector3d.h:70
T y() const
Definition: cctwvector3d.h:18
static int randomIndex(int n)
void CctwComparer::compareDatasetsRigorously ( )
slot

Definition at line 34 of file cctwcomparer.cpp.

References CctwObject::printMessage().

Referenced by compareDatasets().

35 {
36  printMessage("Compare datasets rigorously");
37 }
virtual void printMessage(QString msg, QDateTime dt=QDateTime::currentDateTime())
Definition: cctwobject.cpp:25

Member Data Documentation

CctwApplication* CctwComparer::m_Application
private

Definition at line 23 of file cctwcomparer.h.

Referenced by compareDatasetsApproximately().

Property Documentation

bool CctwComparer::compareApproximately
readwrite

Definition at line 41 of file cctwcomparer.h.

bool CctwComparer::compareRigorously
readwrite

Definition at line 38 of file cctwcomparer.h.

QString CctwComparer::dataset1
readwrite

Definition at line 29 of file cctwcomparer.h.

QString CctwComparer::dataset2
readwrite

Definition at line 35 of file cctwcomparer.h.

QString CctwComparer::filePath1
readwrite

Definition at line 26 of file cctwcomparer.h.

QString CctwComparer::filePath2
readwrite

Definition at line 32 of file cctwcomparer.h.


The documentation for this class was generated from the following files: