API Documentation
Loading...
Searching...
No Matches
Deployment.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: Deployment
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Vector.h>
34#include <NDEVR/Buffer.h>
35#include <NDEVR/Model.h>
36#include <NDEVR/Geometry.h>
37#include <NDEVR/TimeSpan.h>
38#include <NDEVR/Angle.h>
39#if NDEVR_DEPLOYMENT
40namespace NDEVR
41{
42 struct Unit;
43 class DesignObjectLookup;
44 class Calibration;
45 class StationModel;
46
47 /**--------------------------------------------------------------------------------------------------
48 \brief A list of potential qualities a DeploymentRecord may have
49 **/
50 enum class DeploymentQualityFactor
51 {
52 e_none
53 , e_not_downloaded
54 , e_data_quality_good
55 , e_warning_quality
56 , e_warning_magnetometer
57 , e_invalid_reading
58 , e_data_quality_live
59 , e_out_of_bounds
60 };
61
62
63 NDEVR_DESIGN_T_API template class NDEVR_DESIGN_API StringStream<DeploymentQualityFactor>;
64
65 /**--------------------------------------------------------------------------------------------------
66 \brief Data for a single recorded measurement within a Deployment.
67 **/
68 struct DeploymentRecord
69 {
70 Vector<3, Angle<fltp08>> computed_orientation = Vector<3, Angle<fltp08>>(Angle<fltp08>(DEGREES, 0.0));
71 Vector<3, Angle<fltp08>> measured_orientation = Vector<3, Angle<fltp08>>(Angle<fltp08>(DEGREES, 0.0));
72 fltp08 total_length = 0.0;
73 fltp08 length = 0.0;
74 Time surveyed_time;
75 Vertex<3, fltp08> location = Constant<Vertex<3, fltp08>>::Invalid;
76 Ray<3, fltp08> direction = Constant<Vertex<3, fltp08>>::Invalid;
78 DeploymentQualityFactor quality_factor = DeploymentQualityFactor::e_none;
79 bool operator==(const DeploymentRecord& record) const
80 {
81 return memcmp(this, &record, sizeof(DeploymentRecord)) == 0;
82 }
83 bool operator!=(const DeploymentRecord& record) const
84 {
85 return memcmp(this, &record, sizeof(DeploymentRecord)) != 0;
86 }
87 };
88 /**--------------------------------------------------------------------------------------------------
89 \brief A Model which represents a series of measured locations relative to a starting location.
90 **/
91 class NDEVR_DESIGN_API Deployment : public Model
92 {
93 public:
94 Deployment();
95 explicit Deployment(const Model& root);
96 Model addSegment(const Vector<3, fltp08>& location, bool animate = false, bool calc_linework = true);
97 Model addSegment(fltp08 distance, Vector<3, Angle<sint04>> tilt, bool animate = false, bool calc_linework = true);
98 Model addSegment(fltp08 distance, Vector<3, Angle<sint04>> tilt, const Unit& unit, bool animate = false, bool calc_linework = true);
99 Model addSegment(fltp08 distance, Vector<3, Angle<fltp08>> tilt, bool animate = false, bool calc_linework = true);
100 Model addSegment(fltp08 distance, Vector<3, Angle<fltp08>> tilt, const Unit& unit, bool animate = false, bool calc_linework = true);
101 Model segment(uint04 index) const;
102 void setQualityFactor(uint04 segment, DeploymentQualityFactor is_valid);
103 static String QualityFactorIcon(DeploymentQualityFactor factor);
104 static DeploymentQualityFactor QualityFactorIcon(const String& factor);
105 void addSegments(const Buffer<Vertex<3, fltp08>>& locations, const Buffer<Time>& times = Buffer<Time>());
106 Model deploymentLayer();
107 DeploymentQualityFactor deploymentQuality() const;
108 static UUID DeploymentLayerUUID();
109 void ensureModelFormat(uint08 version);
110 Model plannedLayer();
111 static UUID PlannedLayerUUID();
112 Model& deploymentLinework() { return m_linework_model; }
113 Model& deploymentModels() { return m_boretrak_model; }
114 Model& visualModel() { return m_deployment; }
115 void removeSegment(uint04 segment_index, bool update_linework = true);
116 void removeAllSegments();
117 void straightenSegment(uint04 segment_index);
118 Vertex<3, fltp08> endPoint() const;
119 void updateEndpoint(const Vertex<3, fltp08>& end_point);
120 Vector<3, Angle<fltp08>> lastTilt() const;
121 const Buffer<DeploymentRecord>& records() const;
122 fltp08 deploymentLength() const;
123 fltp08 currentLocationLength() const;
124 Vertex<3, fltp08> currentLocation() const;
125 fltp08 addToLocationLengthAndReturnRemainder(fltp08 length);
126 void setCurrentLocationLength(fltp08 length);
127 uint04 recordCount() const;
128 void setUseTube(Geometry::ThicknessMode mode, fltp08 radius);
129 fltp08 tubeThickness() const;
130 void setUseModel();
131 void updateIconFromReadings();
132 fltp08 locationAt(const Vertex<3, fltp08>& location) const;
133 Vertex<3, fltp08> pointAtLength(fltp08 location) const;
134 StationModel getStation() const;
135 Calibration getCalibration() const;
136 Effect invalidSegmentEffect();
137 Effect growEffect() const;
138 bool isHorizontal() const;
139 bool isVertical() const;
140 void cancelGrowEffect();
141 bool hasMissingRecords() const;
142 void updateLineworkFromRecords(uint04 start_index = 0);
143 void updateModelsFromRecords(uint04 start_index = 0);
144
145 // ----------------------------------------------------------------------------
146 // Finds the closest record to given time (While not exceeding max_time),
147 // updates that record with the new angle, and returns the index of the updated record.
148 // Parameters:
149 // time - The time of angle reading. The closest segment in time will be chosen
150 // angle - The value of the angle in the units specified by type.
151 // ----------------------------------------------------------------------------
152 uint04 adjustTilt(const Time& time, const Vector<3, Angle<sint04>>& angle, TimeSpan max_time = TimeSpan(2.0));
153 uint04 adjustTilt(const Time& time, const Vector<3, Angle<fltp08>>& angle, TimeSpan max_time = TimeSpan(2.0));
154 void adjustLength(uint04 segment, fltp08 length);
155 void adjustTilt(uint04 segment, const Vector<3, Angle<fltp08>>& angle);
156 Polyline<3, fltp08> toPolyline() const;
157 void cleanup();
158 bool isPlanned() const;
159 void setIsPlanned(bool is_design);
160 void setupAsDefaultPlanned(bool add_segment);
161 Deployment getPlanned() const;
162 void setupInvalidEffect();
163 static Deployment GetAssociatedPlan(const Model& model);
164 static constexpr const char* TypeName() { return "deployment"; }
165 static constexpr const char* DecorationTypeName() { return "deployment_decoration"; }
166 static DynamicPointer<Model> s_deployment_model;
167 static void SetupMaterialToLayerDefaults(Material& mat);
168 protected:
169 UUID growTarget() const;
170 uint04 segmentCount() const;
171 void setupBoretrakModel();
172 void createSegmentChild();
173 void setupLineworkGeometry();
174 void calculateRecords(uint04 segment = 0) const;
175 void updateRecordLocations(uint04 segment = 0) const;
176 void setRecord(uint04 index, const DeploymentRecord& record) const;
177 void initialize();
178 void validateRecords() const;
179 void ensureRecordsCached() const;
180 protected:
181 bool m_is_init;
182 mutable Buffer<DeploymentRecord> m_cached_records;
183 mutable Time m_record_cache_time;
184 Model m_deployment;
185 Model m_boretrak_model;
186 Model m_linework_model;
187 };
188}
189#endif
190
191
192
#define NDEVR_DESIGN_API
Definition DLLInfo.h:55
#define NDEVR_DESIGN_T_API
Definition DLLInfo.h:56
Definition ACIColor.h:37
bool operator==(const char(&v1)[t_size], const String &v2)
Definition String.h:912
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Definition Vector.hpp:668
@ DEGREES
Definition Angle.h:58
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:149
static const t_type Invalid
Definition BaseValues.hpp:234