NDEVR
API Documentation
Deployment.h
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;
44 class Calibration;
45 class StationModel;
46
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 NDEVR_DESIGN_T_API template class NDEVR_DESIGN_API StringStream<DeploymentQualityFactor>;
62
66 struct DeploymentRecord
67 {
70 fltp08 total_length = 0.0;
71 fltp08 length = 0.0;
72 Time surveyed_time;
74 Ray<3, fltp08> direction = Constant<Vertex<3, fltp08>>::Invalid;
75 UUID id = Constant<UUID>::Invalid;
76 DeploymentQualityFactor quality_factor = DeploymentQualityFactor::e_none;
77
83 bool operator==(const DeploymentRecord& record) const
84 {
85 return memcmp(this, &record, sizeof(DeploymentRecord)) == 0;
86 }
87
93 bool operator!=(const DeploymentRecord& record) const
94 {
95 return memcmp(this, &record, sizeof(DeploymentRecord)) != 0;
96 }
97 };
98
105 class NDEVR_DESIGN_API Deployment : public Model
106 {
107 public:
111 Deployment();
112
117 explicit Deployment(const Model& root);
118
126 Model addSegment(const Vector<3, fltp08>& location, bool animate = false, bool calc_linework = true);
127
136 Model addSegment(fltp08 distance, Vector<3, Angle<sint04>> tilt, bool animate = false, bool calc_linework = true);
137
147 Model addSegment(fltp08 distance, Vector<3, Angle<sint04>> tilt, const Unit& unit, bool animate = false, bool calc_linework = true);
148
157 Model addSegment(fltp08 distance, Vector<3, Angle<fltp08>> tilt, bool animate = false, bool calc_linework = true);
158
168 Model addSegment(fltp08 distance, Vector<3, Angle<fltp08>> tilt, const Unit& unit, bool animate = false, bool calc_linework = true);
169
175 Model segment(uint04 index) const;
176
182 void setQualityFactor(uint04 segment, DeploymentQualityFactor is_valid);
183
189 static StringView QualityFactorIcon(DeploymentQualityFactor factor);
190
196 static DeploymentQualityFactor QualityFactorIcon(const StringView& factor);
197
203 void addSegments(const Buffer<Vertex<3, fltp08>>& locations, const Buffer<Time>& times = Buffer<Time>());
204
209 Model deploymentLayer();
210
215 DeploymentQualityFactor deploymentQuality() const;
216
221 static UUID DeploymentLayerUUID();
222
227 void ensureModelFormat(uint08 version);
228
233 Model plannedLayer();
234
239 static UUID PlannedLayerUUID();
240
245 Model& deploymentLinework() { return m_linework_model; }
246
251 Model& deploymentModels() { return m_deployment_model; }
252
257 Model& visualModel() { return m_deployment; }
258
264 void removeSegment(uint04 segment_index, bool update_linework = true);
265
269 void removeAllSegments();
270
275 void straightenSegment(uint04 segment_index);
276
281 Vertex<3, fltp08> endPoint() const;
282
287 void updateEndpoint(const Vertex<3, fltp08>& end_point);
288
293 Vector<3, Angle<fltp08>> lastTilt() const;
294
299 const Buffer<DeploymentRecord>& records() const;
300
305 fltp08 deploymentLength() const;
306
311 fltp08 currentLocationLength() const;
312
317 Vertex<3, fltp08> currentLocation() const;
318
324 fltp08 addToLocationLengthAndReturnRemainder(fltp08 length);
325
330 void setCurrentLocationLength(fltp08 length);
331
336 uint04 recordCount() const;
337
343 void setUseTube(Geometry::ThicknessMode mode, fltp08 radius);
344
349 fltp08 tubeThickness() const;
350
354 void setUseModel();
355
359 void updateIconFromReadings();
360
366 fltp08 locationAt(const Vertex<3, fltp08>& location) const;
367
373 Vertex<3, fltp08> pointAtLength(fltp08 location) const;
374
379 StationModel getStation() const;
380
385 Calibration getCalibration() const;
386
391 Effect invalidSegmentEffect();
392
397 Effect growEffect() const;
398
403 bool isHorizontal() const;
404
409 bool isVertical() const;
410
414 void cancelGrowEffect();
415
420 bool hasMissingRecords() const;
421
426 void updateLineworkFromRecords(uint04 start_index = 0);
427
432 void updateModelsFromRecords(uint04 start_index = 0);
433
434 // ----------------------------------------------------------------------------
435 // Finds the closest record to given time (While not exceeding max_time),
436 // updates that record with the new angle, and returns the index of the updated record.
437 // Parameters:
438 // time - The time of angle reading. The closest segment in time will be chosen
439 // angle - The value of the angle in the units specified by type.
440 // ----------------------------------------------------------------------------
441
449 uint04 adjustTilt(const Time& time, const Vector<3, Angle<sint04>>& angle, TimeSpan max_time = TimeSpan(2.0));
450
458 uint04 adjustTilt(const Time& time, const Vector<3, Angle<fltp08>>& angle, TimeSpan max_time = TimeSpan(2.0));
459
465 void adjustLength(uint04 segment, fltp08 length);
466
472 void adjustTilt(uint04 segment, const Vector<3, Angle<fltp08>>& angle);
473
478 Polyline<3, fltp08> toPolyline() const;
479
483 void cleanup();
484
489 bool isPlanned() const;
490
495 void setIsPlanned(bool is_design);
496
501 void setupAsDefaultPlanned(bool add_segment);
502
507 Deployment getPlanned() const;
508
512 void setupInvalidEffect();
513
519 static Deployment GetAssociatedPlan(const Model& model);
520
525 static constexpr StringView TypeName() { return "deployment"; }
526
531 static constexpr StringView DecorationTypeName() { return "deployment_decoration"; }
532
533 static DynamicPointer<Model> s_deployment_model;
534
539 static void SetupMaterialToLayerDefaults(Material& mat);
540 private:
545 UUID growTarget() const;
546
551 uint04 segmentCount() const;
552
556 void setupDeploymentModel();
557
561 void createSegmentChild();
562
566 void setupLineworkGeometry();
567
572 void calculateRecords(uint04 segment = 0) const;
573
578 void updateRecordLocations(uint04 segment = 0) const;
579
585 void setRecord(uint04 index, const DeploymentRecord& record) const;
586
590 void initialize();
591
595 void validateRecords() const;
596
600 void ensureRecordsCached() const;
601 protected:
602 bool m_is_init;
603 mutable Buffer<DeploymentRecord> m_cached_records;
604 mutable Time m_record_cache_time;
605 Model m_deployment;
606 Model m_deployment_model;
607 Model m_linework_model;
608 };
609}
610#endif
611
612
613
Stores an angle in an optimized internal format with support for efficient trigonometric operations.
Definition Angle.h:83
A core class where all Design Objects including models, materials, and geometries are stored.
A core class that represents a node on model hierarchy.
Definition Model.h:292
Logic for reading or writing to a string or a user friendly, TranslatedString.
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
A point in N-dimensional space, used primarily for spatial location information.
Definition Vertex.hpp:44
The primary namespace for the NDEVR SDK.
constexpr bool operator!=(const Vector< t_dims, t_type > &vec_a, const Vector< t_dims, t_type > &vec_b)
Inequality operator.
Definition Vector.hpp:673
constexpr HSLColor Constant< HSLColor >::Invalid
The invalid HSLColor constant with all components set to invalid.
Definition HSLColor.h:264
@ e_none
No defined value type.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
@ DEGREES
Angle measured in degrees (0 to 360 for a full circle).
Definition Angle.h:58
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Defines a unit of measurement for converting and displaying data values.
Definition Unit.h:39