9
9
#include " domain/segmentset.h"
10
10
#include " domain/cartesiangrid.h"
11
11
#include " domain/segmentset.h"
12
+ #include " domain/geogrid.h"
12
13
#include " spatialindex/spatialindex.h"
13
14
#include " geostats/searchannulus.h"
14
15
#include " geostats/searchwasher.h"
15
16
#include " geostats/searchverticaldumbbell.h"
16
17
#include " geostats/searchstrategy.h"
17
- #include " geostats/searchhollowsphere .h"
18
+ #include " geostats/searchsphericalshell .h"
18
19
#include " geostats/pointsetcell.h"
19
20
#include " geostats/gridcell.h"
20
21
#include " geostats/segmentsetcell.h"
@@ -175,35 +176,40 @@ DataCellPtrMultiset ContactAnalysis::getSamplesFromInputDataSet(const DataCell &
175
176
for ( ; it != samplesIndexes.end (); ++it ){
176
177
switch ( m_inputDataType ) {
177
178
case InputDataSetType::POINTSET:
178
- {
179
+ {
179
180
DataCellPtr p (new PointSetCell ( static_cast <PointSet*>( m_inputDataFile ), m_attributeGrade->getAttributeGEOEASgivenIndex ()-1 , *it ));
180
181
p->computeCartesianDistance ( sample );
181
182
result.insert ( p );
182
- }
183
+ }
183
184
break ;
184
185
case InputDataSetType::CARTESIANGRID:
185
- {
186
+ {
186
187
CartesianGrid* cg = static_cast <CartesianGrid*>( m_inputDataFile );
187
188
uint i, j, k;
188
189
cg->indexToIJK ( *it, i, j, k );
189
190
DataCellPtr p (new GridCell ( cg, m_attributeGrade->getAttributeGEOEASgivenIndex ()-1 , i, j, k ));
190
191
p->computeCartesianDistance ( sample );
191
192
result.insert ( p );
192
- }
193
+ }
193
194
break ;
194
195
case InputDataSetType::GEOGRID:
195
- {
196
- Application::instance ()->logError ( " ContactAnalysis::getSamplesFromInputDataSet(): GeoGrids cannot be used as input data yet."
197
- " It is necessary to create a class like GeoGridCell inheriting from DataCell." );
198
- return result;
199
- }
196
+ {
197
+ GeoGrid* ggAspect = dynamic_cast <GeoGrid*>(m_inputDataFile);
198
+ uint i, j, k;
199
+ ggAspect->indexToIJK ( *it, i, j, k );
200
+ DataCellPtr p ( new GridCell ( ggAspect,
201
+ m_attributeGrade->getAttributeGEOEASgivenIndex ()-1 ,
202
+ i, j, k ) );
203
+ p->computeCartesianDistance ( sample );
204
+ result.insert ( p );
205
+ }
200
206
break ;
201
207
case InputDataSetType::SEGMENTSET:
202
- {
208
+ {
203
209
DataCellPtr p (new SegmentSetCell ( static_cast <SegmentSet*>( m_inputDataFile ), m_attributeGrade->getAttributeGEOEASgivenIndex ()-1 , *it ));
204
210
p->computeCartesianDistance ( sample );
205
211
result.insert ( p );
206
- }
212
+ }
207
213
break ;
208
214
default :
209
215
Application::instance ()->logError ( " ContactAnalysis::getSamplesFromInputDataSet(): Input data file type not recognized or undefined." );
@@ -284,6 +290,9 @@ bool ContactAnalysis::run()
284
290
} else if ( m_inputDataFile->getFileType () == " CARTESIANGRID" ) {
285
291
CartesianGrid* cgAspect = dynamic_cast <CartesianGrid*>( m_inputDataFile );
286
292
spatialIndex.fill ( cgAspect );
293
+ } else if ( m_inputDataFile->getFileType () == " GEOGRID" ) {
294
+ GeoGrid* ggAspect = dynamic_cast <GeoGrid*>( m_inputDataFile );
295
+ spatialIndex.fillWithCenters ( ggAspect, 0.0001 );
287
296
} else {
288
297
m_lastError = " Internal error building spatial index: input data of type " + m_inputDataFile->getFileType () + " are not currently supported." ;
289
298
return false ;
@@ -349,8 +358,30 @@ bool ContactAnalysis::run()
349
358
m_lastError = " Cannot perform vertical contact analysis on a 2D dataset." ;
350
359
return false ;
351
360
} else { // if data set is 3D
352
- if ( ! m_inputDataFile->isGridded () || m_inputDataType == InputDataSetType::CARTESIANGRID ) {
353
- searchNeighborhood.reset ( new SearchVerticalDumbbell ( m_lagSize, 2 *current_lag, m_lagSize ) );
361
+ if ( ! m_inputDataFile->isGridded () ) {
362
+ searchNeighborhood.reset ( new SearchVerticalDumbbell ( m_lagSize, 2 *(current_lag-m_lagSize), m_lagSize ) );
363
+ } else if ( m_inputDataType == InputDataSetType::CARTESIANGRID ) {
364
+ CartesianGrid* cg = dynamic_cast < CartesianGrid* >( m_inputDataFile );
365
+ const double dx = cg->getDX ();
366
+ const double dy = cg->getDY ();
367
+ double radius = std::sqrt ( dx*dx + dy*dy ) / 2 ;
368
+ searchNeighborhood.reset ( new SearchVerticalDumbbell ( m_lagSize, 2 *(current_lag-m_lagSize), radius ) );
369
+ } else if ( m_inputDataType == InputDataSetType::GEOGRID ) {
370
+ GeoGrid* gg = dynamic_cast < GeoGrid* >( m_inputDataFile );
371
+ double bbMinX, bbMinY, bbMinZ; // BB == Bounding Box
372
+ double bbMaxX, bbMaxY, bbMaxZ;
373
+ double maxBBdX = -std::numeric_limits<double >::max ();
374
+ double maxBBdY = -std::numeric_limits<double >::max ();
375
+ uint maxIndex = gg->getDataLineCount ();
376
+ for ( uint i = 0 ; i < maxIndex; i++ ){
377
+ gg->getBoundingBox ( i, bbMinX, bbMinY, bbMinZ, bbMaxX, bbMaxY, bbMaxZ );
378
+ double bbDx = bbMaxX - bbMinX;
379
+ double bbDy = bbMaxY - bbMinY;
380
+ if ( bbDx > maxBBdX ) maxBBdX = bbDx;
381
+ if ( bbDy > maxBBdY ) maxBBdY = bbDy;
382
+ }
383
+ double radius = std::sqrt ( maxBBdX*maxBBdX + maxBBdY*maxBBdY ) / 2 ;
384
+ searchNeighborhood.reset ( new SearchVerticalDumbbell ( m_lagSize, 2 *(current_lag-m_lagSize), radius ) );
354
385
} else {
355
386
m_lastError = " Internal error: no search neighborhood is available "
356
387
" for vertical contact analysis with datasets of type " + m_inputDataFile->getFileType () + " ." ;
@@ -362,13 +393,7 @@ bool ContactAnalysis::run()
362
393
m_lastError = " Cannot perform omnidirectional contact analysis on a 2D dataset." ;
363
394
return false ;
364
395
} else { // if data set is 3D
365
- if ( ! m_inputDataFile->isGridded () || m_inputDataType == InputDataSetType::CARTESIANGRID ) {
366
- searchNeighborhood.reset ( new SearchHollowSphere ( current_lag - m_lagSize, current_lag ) );
367
- } else {
368
- m_lastError = " Internal error: no search neighborhood is available "
369
- " for omnidirectional contact analysis with datasets of type " + m_inputDataFile->getFileType () + " ." ;
370
- return false ;
371
- }
396
+ searchNeighborhood.reset ( new SearchSphericalShell ( current_lag - m_lagSize, current_lag ) );
372
397
}
373
398
}
374
399
}
@@ -412,8 +437,15 @@ bool ContactAnalysis::run()
412
437
}
413
438
break ;
414
439
case InputDataSetType::GEOGRID:
415
- m_lastError = " Internal error: geogrids are not currently supported in contact analysis." ;
416
- return false ;
440
+ {
441
+ GeoGrid* ggAspect = dynamic_cast <GeoGrid*>(m_inputDataFile);
442
+ uint i, j, k;
443
+ ggAspect->indexToIJK ( iCurrentSample, i, j, k );
444
+ currentSampleCell.reset ( new GridCell ( ggAspect,
445
+ m_attributeGrade->getAttributeGEOEASgivenIndex ()-1 ,
446
+ i, j, k ) );
447
+ }
448
+ break ;
417
449
case InputDataSetType::SEGMENTSET:
418
450
currentSampleCell.reset ( new SegmentSetCell ( dynamic_cast <SegmentSet*>(m_inputDataFile),
419
451
m_attributeGrade->getAttributeGEOEASgivenIndex ()-1 ,
0 commit comments