Helios++
Helios software for LiDAR simulations
SurveyCopyTest.h
1 #pragma once
2 
3 #include <BaseTest.h>
4 #include <Survey.h>
5 #include <OscillatingMirrorBeamDeflector.h>
6 #include <HelicopterPlatform.h>
7 #include <FullWaveformPulseDetector.h>
8 
9 namespace HeliosTests{
16 class SurveyCopyTest : public BaseTest{
17 public:
18  // *** CONSTRUCTOR *** //
19  // ********************* //
23  SurveyCopyTest() : BaseTest("Survey copy test"){}
24 
25  // *** R U N *** //
26  // *************** //
30  bool run() override;
31 };
32 
34  // Build base Survey
35  Survey *survey = new Survey();
36  survey->name = "MySurvey";
37  survey->numRuns = 1;
38  survey->simSpeedFactor = 1;
39  std::list<int> pulseFreqs;
40  pulseFreqs.push_back(100);
41  pulseFreqs.push_back(30);
42  pulseFreqs.push_back(70);
43  survey->scanner = std::make_shared<Scanner>(
44  0.1,
45  glm::dvec3(2.0, 3.0, 0.0),
46  Rotation(0.0, 0.0, 0.0, 0.0, true),
47  pulseFreqs,
48  4.0,
49  "MyScanner",
50  80.5,
51  3.0,
52  0.9,
53  0.7,
54  0.8,
55  100,
56  false,
57  false,
58  false,
59  true
60  );
61  survey->scanner->scannerHead = std::make_shared<ScannerHead>(
62  glm::dvec3(0.4, 0.7, 0.1), 0.067
63  );
64  survey->scanner->beamDeflector =
65  std::make_shared<OscillatingMirrorBeamDeflector>(
66  3.141592,
67  1400.5,
68  70.8,
69  1
70  );
71  survey->scanner->platform = std::make_shared<HelicopterPlatform>();
72  survey->scanner->detector = std::make_shared<FullWaveformPulseDetector>(
73  survey->scanner,
74  1.5,
75  0.1
76  );
77  survey->legs.push_back(std::make_shared<Leg>());
78  survey->legs[0]->mPlatformSettings = std::make_shared<PlatformSettings>();
79  survey->legs[0]->mPlatformSettings->onGround = false;
80  survey->scanner->platform->scene = std::make_shared<Scene>();
81  std::shared_ptr<Scene> baseScene = survey->scanner->platform->scene;
82  baseScene->primitives.push_back(new Triangle(
83  Vertex(), Vertex(), Vertex()
84  ));
85  baseScene->primitives[0]->part = std::make_shared<ScenePart>();
86  baseScene->primitives[0]->part->mPrimitives.push_back(
87  baseScene->primitives[0]);
88  baseScene->primitives[0]->part->onRayIntersectionMode = "TRANSMITTIVE";
89  baseScene->primitives.push_back(new DetailedVoxel(
90  glm::dvec3(0.0, 0.0, 0.5),
91  2.15,
92  std::vector<int>({1,2}),
93  std::vector<double>({0.1, 0.2, 0.3})
94  ));
95  baseScene->primitives[1]->material = std::make_shared<Material>();
96  baseScene->primitives[1]->material->ka[0] = 1.1;
97  baseScene->primitives[1]->material->ks[1] = 1.2;
98 
99  // Copy base Survey
100  Survey *copy = new Survey(*survey);
101 
102  // Do some changes on copy
103  copy->name = "CopiedSurvey";
104  copy->numRuns = 0;
105  copy->scanner->name = "CopiedScanner";
106  Rotation &copyMRA =
107  copy->scanner->scannerHead->getMountRelativeAttitudeByReference();
108  copyMRA.setQ3(copyMRA.getQ3() + 0.1);
109  copy->scanner->beamDeflector->cfg_device_scanFreqMax_Hz += 1.0;
110  copy->scanner->platform->cfg_device_relativeMountPosition.x += 0.01;
111  HelicopterPlatform *hp =
112  ((HelicopterPlatform *)copy->scanner->platform.get());
113  glm::dvec3 & speedXy = hp->getSpeedXyByReference();
114  speedXy.x += 0.1;
115  Rotation & r = hp->getRotationByReference();
116  r.setQ2(r.getQ2()+0.1);
117  copy->scanner->FWF_settings.minEchoWidth += 0.001;
118  copy->legs[0]->mPlatformSettings->onGround = true;
119  std::shared_ptr<Scene> copyScene = copy->scanner->platform->scene;
120  copyScene->primitives[0]->getVertices()[0].pos.x += 0.1;
121  copyScene->primitives[0]->part->onRayIntersectionArgument += 0.034;
122  copyScene->primitives[1]->material->ks[1] += 0.1;
123  DetailedVoxel *copyDv = (DetailedVoxel *) copyScene->primitives[1];
124  (*copyDv)[1] += 0.1;
125 
126  // Validate copy
127  if(copy->name == survey->name) return false;
128  if(copy->numRuns == survey->numRuns) return false;
129  if(copy->simSpeedFactor != survey->simSpeedFactor) return false;
130  if(copy->scanner->name == survey->scanner->name) return false;
131  if(copy->scanner->numTimeBins!=survey->scanner->numTimeBins) return false;
132  if(copy->scanner->isCalcEchowidth() != survey->scanner->isCalcEchowidth())
133  return false;
134  if(copy->scanner->FWF_settings.minEchoWidth ==
135  survey->scanner->FWF_settings.minEchoWidth)
136  return false;
137  if(copy->scanner->FWF_settings.apertureDiameter !=
138  survey->scanner->FWF_settings.apertureDiameter)
139  return false;
140  if(copy->scanner->scannerHead->getRotatePerSecMax() !=
141  survey->scanner->scannerHead->getRotatePerSecMax())
142  return false;
143  Rotation &baseMRA =
144  survey->scanner->scannerHead->getMountRelativeAttitudeByReference();
145  if(copyMRA.getQ0()!=baseMRA.getQ0() || copyMRA.getQ3()==baseMRA.getQ3())
146  return false;
147  if(copy->scanner->beamDeflector->cfg_device_scanFreqMin_Hz !=
148  survey->scanner->beamDeflector->cfg_device_scanFreqMin_Hz)
149  return false;
150  if(copy->scanner->beamDeflector->cfg_device_scanFreqMax_Hz ==
151  survey->scanner->beamDeflector->cfg_device_scanFreqMax_Hz)
152  return false;
153  if(copy->scanner->platform->cfg_device_relativeMountPosition.x ==
154  survey->scanner->platform->cfg_device_relativeMountPosition.x)
155  return false;
156  if(copy->scanner->platform->cfg_device_relativeMountPosition.y !=
157  survey->scanner->platform->cfg_device_relativeMountPosition.y)
158  return false;
159  HelicopterPlatform *copyHp =
160  (HelicopterPlatform *) copy->scanner->platform.get();
161  HelicopterPlatform *baseHp =
162  (HelicopterPlatform *) survey->scanner->platform.get();
163  glm::dvec3 &copySpeedXy = copyHp->getSpeedXyByReference();
164  glm::dvec3 &baseSpeedXy = baseHp->getSpeedXyByReference();
165  if(copySpeedXy.x == baseSpeedXy.x) return false;
166  if(copySpeedXy.y != baseSpeedXy.y) return false;
167  Rotation &copyRot = copyHp->getRotationByReference();
168  Rotation &baseRot = baseHp->getRotationByReference();
169  if(copyRot.getQ1() != baseRot.getQ1()) return false;
170  if(copyRot.getQ2() == baseRot.getQ2()) return false;
171  if(copy->legs[0]->mPlatformSettings->onGround ==
172  survey->legs[0]->mPlatformSettings->onGround)
173  return false;
174  if(copy->legs[0]->mPlatformSettings->stopAndTurn !=
175  survey->legs[0]->mPlatformSettings->stopAndTurn)
176  return false;
177  if(copyScene->primitives[0]->getVertices()[0].pos.x ==
178  baseScene->primitives[0]->getVertices()[0].pos.x)
179  return false;
180  if(copyScene->primitives[0]->getVertices()[0].pos.y !=
181  baseScene->primitives[0]->getVertices()[0].pos.y)
182  return false;
183  if(copyScene->primitives[0]->part->onRayIntersectionArgument ==
184  baseScene->primitives[0]->part->onRayIntersectionArgument)
185  return false;
186  if(copyScene->primitives[0]->part->onRayIntersectionMode !=
187  baseScene->primitives[0]->part->onRayIntersectionMode)
188  return false;
189  if(copyScene->primitives[1]->material->ka[0] !=
190  baseScene->primitives[1]->material->ka[0])
191  return false;
192  if(copyScene->primitives[1]->material->ks[1] ==
193  baseScene->primitives[1]->material->ks[1])
194  return false;
195  DetailedVoxel *baseDv = (DetailedVoxel *) baseScene->primitives[1];
196  copyDv = (DetailedVoxel *) copyScene->primitives[1];
197  if((*baseDv)[0] != (*copyDv)[0]) return false;
198  if((*baseDv)[1] == (*copyDv)[1]) return false;
199 
200 
201 
202  // Successfully reached end of test
203  return true;
204 }
205 
206 }
Test survey copy.
Definition: SurveyCopyTest.h:16
Definition: Rotation.h:80
double simSpeedFactor
Simulation speed factor for the survey.
Definition: Survey.h:31
double getQ0()
Get the scalar coordinate of the quaternion.
Definition: Rotation.h:115
std::string name
Survey name.
Definition: Survey.h:18
glm::dvec3 & getSpeedXyByReference()
Obtain xy speed vector by reference.
Definition: HelicopterPlatform.h:231
int numRuns
Number of runs for the survey.
Definition: Survey.h:22
double getQ3()
Get the third coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:137
BaseTest class.
Definition: BaseTest.h:19
std::shared_ptr< Scanner > scanner
Scanner used by the survey.
Definition: Survey.h:27
Class which extends Voxel to support AMAPVox format with extra features.
Definition: DetailedVoxel.h:12
Class representing a Helios++ survey.
Definition: Survey.h:11
SurveyCopyTest()
Survey copy test constructor.
Definition: SurveyCopyTest.h:23
bool run() override
Definition: SurveyCopyTest.h:33
double getQ1()
Get the first coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:122
Class representing triangle primitive.
Definition: Triangle.h:13
std::vector< std::shared_ptr< Leg > > legs
All legs belonging to the survey.
Definition: Survey.h:36
Rotation & getRotationByReference()
Obtain rotation assistance r by reference.
Definition: HelicopterPlatform.h:236
Definition: BaseTest.h:6
double getQ2()
Get the second coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:130
Class representing a helicopter platform.
Definition: HelicopterPlatform.h:12
Class representing a vertex.
Definition: Vertex.h:14