Cogs.Core
TrajectoryComponent.cpp
1#include <algorithm>
2#include "TrajectoryComponent.h"
3
4#include "Types.h"
5
6using namespace Cogs::Reflection;
7
9 int& ix1,
10 int& slices,
11 const float startDepth,
12 const float stopDepth)
13{
14 // Find index of first depth that is not less than start_depth.
15 ix0 = static_cast<int>(std::lower_bound(indexes.begin(), indexes.end(), startDepth) - indexes.begin());
16 ix0 = static_cast<int>(std::min(ix0, int(indexes.size()) - 2));
17
18 // Unless start depth matches the depth of the index, we start one segment
19 // before (and subsequently use linear interpolation).
20 if ((0 < ix0) && (startDepth + std::numeric_limits<float>::epsilon() < indexes[ix0])) {
21 ix0 = ix0 - 1;
22 }
23
24 // Find index of first depth that is not less than stop_depth.
25 ix1 = static_cast<int>(std::lower_bound(indexes.begin() + ix0, indexes.end(), stopDepth) - indexes.begin());
26 ix1 = static_cast<int>(std::min(ix1, int(indexes.size()) - 1));
27
28 // If stop depth is just barely larger than the previous index, we step back
29 // one segment
30 if ((0 < ix1) && (stopDepth < indexes[ix1 - 1] + std::numeric_limits<float>::epsilon())) {
31 // stop depth is barely passed previous index, step back to avoid almost duplicate rings.
32 ix1 = ix1 - 1;
33 }
34 ix1 = std::max(ix0, ix1);
35
36 slices = ix1 - ix0 + 1;
37}
38
39
40void Cogs::Core::TrajectoryComponent::registerType()
41{
42 Field fields[] = {
46 Field(Name("stopRadialAnchor"), &TrajectoryComponent::stopRadialAnchor),
48 };
49
50 TypeDatabase::createType<TrajectoryComponent>().setBase<Component>().setFields(fields);
51}
Field definition describing a single data member of a data structure.
Definition: Field.h:68
Contains reflection support.
Definition: Component.h:11
std::vector< float > indexes
Positive distances along trajectory. For wells Measured Depth (MD). Set same length of indexes and po...
COGSCORE_DLL_API void determineindices(int &ix0, int &ix1, int &slices, const float startDepth, const float stopDepth)
std::vector< glm::vec3 > positions
Trajectory positions. For wells the Z component is a measurement of True Vertical Depth (TVD)....
Represents an unique name.
Definition: Name.h:70