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 enum class DeploymentQualityFactor
48 {
49 e_none
50 , e_not_downloaded
51 , e_data_quality_good
52 , e_warning_quality
53 , e_warning_magnetometer
54 , e_invalid_reading
55 , e_data_quality_live
56 , e_out_of_bounds
57 };
58
59
60 NDEVR_DESIGN_T_API template class NDEVR_DESIGN_API StringStream<DeploymentQualityFactor>;
61
62 struct DeploymentRecord
63 {
64 Vector<3, Angle<fltp08>> computed_orientation = Vector<3, Angle<fltp08>>(Angle<fltp08>(DEGREES, 0.0));
65 Vector<3, Angle<fltp08>> measured_orientation = Vector<3, Angle<fltp08>>(Angle<fltp08>(DEGREES, 0.0));
66 fltp08 total_length = 0.0;
67 fltp08 length = 0.0;
68 Time surveyed_time;
69 Vertex<3, fltp08> location = Constant<Vertex<3, fltp08>>::NaN;
70 Ray<3, fltp08> direction = Constant<Vertex<3, fltp08>>::NaN;
71 UUID id = Constant<UUID>::NaN;
72 DeploymentQualityFactor quality_factor = DeploymentQualityFactor::e_none;
73 bool operator==(const DeploymentRecord& record) const
74 {
75 return memcmp(this, &record, sizeof(DeploymentRecord)) == 0;
76 }
77 bool operator!=(const DeploymentRecord& record) const
78 {
79 return memcmp(this, &record, sizeof(DeploymentRecord)) != 0;
80 }
81 };
82
83 class NDEVR_DESIGN_API Deployment : public Model
84 {
85 public:
86
87 Deployment();
88 explicit Deployment(const Model& root);
89
90 Model addSegment(const Vector<3, fltp08>& location, bool animate = false, bool calc_linework = true);
91 Model addSegment(fltp08 distance, Vector<3, Angle<sint04>> tilt, bool animate = false, bool calc_linework = true);
92 Model addSegment(fltp08 distance, Vector<3, Angle<sint04>> tilt, const Unit& unit, bool animate = false, bool calc_linework = true);
93 Model addSegment(fltp08 distance, Vector<3, Angle<fltp08>> tilt, bool animate = false, bool calc_linework = true);
94 Model addSegment(fltp08 distance, Vector<3, Angle<fltp08>> tilt, const Unit& unit, bool animate = false, bool calc_linework = true);
95 Model segment(uint04 index) const;
96 void setQualityFactor(uint04 segment, DeploymentQualityFactor is_valid);
97 static String QualityFactorIcon(DeploymentQualityFactor factor);
98 static DeploymentQualityFactor QualityFactorIcon(const String& factor);
99 void addSegments(const Buffer<Vertex<3, fltp08>>& locations, const Buffer<Time>& times = Buffer<Time>());
100 Model deploymentLayer();
101 DeploymentQualityFactor deploymentQuality() const;
102 static UUID DeploymentLayerUUID();
103 void ensureModelFormat(uint08 version);
104 Model plannedLayer();
105 static UUID PlannedLayerUUID();
106 Model& deploymentLinework() { return m_linework_model; }
107 Model& deploymentModels() { return m_boretrak_model; }
108 Model& visualModel() { return m_deployment; }
109 void removeSegment(uint04 segment_index, bool update_linework = true);
110 void removeAllSegments();
111 void straightenSegment(uint04 segment_index);
112 Vertex<3, fltp08> endPoint() const;
113 void updateEndpoint(const Vertex<3, fltp08>& end_point);
114 Vector<3, Angle<fltp08>> lastTilt() const;
115 const Buffer<DeploymentRecord>& records() const;
116 fltp08 deploymentLength() const;
117 fltp08 currentLocationLength() const;
118 Vertex<3, fltp08> currentLocation() const;
119 fltp08 addToLocationLengthAndReturnRemainder(fltp08 length);
120 void setCurrentLocationLength(fltp08 length);
121 uint04 recordCount() const;
122 void setUseTube(Geometry::ThicknessMode mode, fltp08 radius);
123 fltp08 tubeThickness() const;
124 void setUseModel();
125 void updateIconFromReadings();
126 fltp08 locationAt(const Vertex<3, fltp08>& location) const;
127 Vertex<3, fltp08> pointAtLength(fltp08 location) const;
128 StationModel getStation() const;
129 Calibration getCalibration() const;
130 //UUID calibrationID() const;
131 //void setCalibrationID(const UUID& id);
132 Effect invalidSegmentEffect();
133 Effect growEffect() const;
134 bool isHorizontal() const;
135 bool isVertical() const;
136 void cancelGrowEffect();
137 bool hasMissingRecords() const;
138 void updateLineworkFromRecords(uint04 start_index = 0);
139 void updateModelsFromRecords(uint04 start_index = 0);
140
141 // ----------------------------------------------------------------------------
142 // Finds the closest record to given time (While not exceeding max_time),
143 // updates that record with the new angle, and returns the index of the updated record.
144 // Parameters:
145 // time - The time of angle reading. The closest segment in time will be chosen
146 // angle - The value of the angle in the units specified by type.
147 // Returns:
148 //
149 // ----------------------------------------------------------------------------
150 uint04 adjustTilt(const Time& time, const Vector<3, Angle<sint04>>& angle, TimeSpan max_time = TimeSpan(2.0));
151 uint04 adjustTilt(const Time& time, const Vector<3, Angle<fltp08>>& angle, TimeSpan max_time = TimeSpan(2.0));
152 void adjustLength(uint04 segment, fltp08 length);
153 void adjustTilt(uint04 segment, const Vector<3, Angle<fltp08>>& angle);
154 Polyline<3, fltp08> toPolyline() const;
155 void cleanup();
156 bool isPlanned() const;
157 void setIsPlanned(bool is_design);
158 void setupAsDefaultPlanned(bool add_segment);
159 Deployment getPlanned() const;
160 void setupInvalidEffect();
161 static Deployment GetAssociatedPlan(const Model& model);
162 static constexpr const char* TypeName() { return "deployment"; }
163 static constexpr const char* DecorationTypeName() { return "deployment_decoration"; }
164 static DynamicPointer<Model> s_deployment_model;
165 static void SetupMaterialToLayerDefaults(Material& mat);
166 protected:
167 UUID growTarget() const;
168 uint04 segmentCount() const;
169 void setupBoretrakModel();
170 void createSegmentChild();
171 void setupLineworkGeometry();
172 void calculateRecords(uint04 segment = 0) const;
173 void updateRecordLocations(uint04 segment = 0) const;
174 void setRecord(uint04 index, const DeploymentRecord& record) const;
175 void initialize();
176 void validateRecords() const;
177 void ensureRecordsCached() const;
178 protected:
179 bool m_is_init;
180 mutable Buffer<DeploymentRecord> m_cached_records;
181 mutable Time m_record_cache_time;
182 Model m_deployment;
183 Model m_boretrak_model;
184 Model m_linework_model;
185
186 };
187}
188#endif
189
190
191
#define NDEVR_DESIGN_API
Definition DLLInfo.h:77
#define NDEVR_DESIGN_T_API
Definition DLLInfo.h:78
Definition ACIColor.h:37
bool operator==(const char(&v1)[t_size], const String &v2)
Definition String.h:437
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Definition Vector.hpp:724
@ DEGREES
Definition Angle.h:66
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120
double fltp08
Defines an alias representing an 8 byte floating-point number.
Definition BaseValues.hpp:181
static const t_type NaN
Definition BaseValues.hpp:274