API Search || Global Search
sprk_ooc.h
1 // Copyright (c) Tech Soft 3D, Inc.
2 //
3 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc.,
4 // and considered a trade secret as defined under civil and criminal statutes.
5 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of
6 // unauthorized use or misappropriation of its trade secrets. Use of this information
7 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under
8 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use.
9 
10 #ifndef SPRK_OOC_H
11 #define SPRK_OOC_H
12 
13 #include "sprk.h"
14 
15 #ifdef _MSC_VER
16 #ifndef STATIC_APP
17 # ifdef SPRK_OOC
18 # define OOC_API __declspec (dllexport)
19 # else
20 # define OOC_API __declspec (dllimport)
21 # endif
22 #endif
23 #else
24 # include <stddef.h>
25 #endif
26 
27 #ifndef OOC_API
28 # define OOC_API
29 #endif
30 
31 #include <mutex>
32 
33 
34 class HBaseView;
35 
36 namespace HPS
37 {
39 class OOC_API OOC
40 {
41 public:
42 
44  class Area {
45  public:
46  Area() {}
47  Area(HPS::Rectangle const & in_rect,
48  HPS::MatrixKit const & in_world_to_window,
49  const char * in_name)
50  : window_min(in_rect.left, in_rect.bottom, 0),
51  window_max(in_rect.right, in_rect.top, 0),
52  world_to_window(in_world_to_window),
53  name(in_name)
54  {
55  }
56 
60  bool Intersects(HPS::SimpleCuboid const & world_space_bounding) const
61  {
62  HPS::Point world_bounds[8];
63  world_space_bounding.Generate_Cuboid_Points(world_bounds);
64 
65  auto window_bounds = world_to_window.Transform(8, world_bounds);
66 
67  HPS::Point window_min_bound = window_bounds[0];
68  for (HPS::Point const & window_bound : window_bounds) {
69  if (window_bound.x < window_min_bound.x)
70  window_min_bound.x = window_bound.x;
71  if (window_bound.y < window_min_bound.y)
72  window_min_bound.y = window_bound.y;
73  }
74 
75  HPS::Point window_max_bound = window_bounds[0];
76  for (HPS::Point const & window_bound : window_bounds) {
77  if (window_bound.x > window_max_bound.x)
78  window_max_bound.x = window_bound.x;
79  if (window_bound.y > window_max_bound.y)
80  window_max_bound.y = window_bound.y;
81  }
82 
83  if (window_max.x < window_min_bound.x)
84  return false;
85 
86  if (window_min.x > window_max_bound.x)
87  return false;
88 
89  if (window_max.y < window_min_bound.y)
90  return false;
91 
92  if (window_min.y > window_max_bound.y)
93  return false;
94 
95  return true;
96  }
97 
101  bool Intersects(HPS::Point const & world_space_point) const
102  {
103  HPS::Point window_point = world_to_window.Transform(world_space_point);
104 
105  if (window_point.x < window_min.x)
106  return false;
107 
108  if (window_point.y < window_min.y)
109  return false;
110 
111  if (window_point.x > window_max.x)
112  return false;
113 
114  if (window_point.y > window_max.y)
115  return false;
116 
117  return true;
118  }
119 
120  HPS::Point const & GetWindowMin() const { return window_min; }
121 
122  HPS::Point const & GetWindowMax() const { return window_max; }
123 
125  HPS::MatrixKit const & GetWorldToWindow() const { return world_to_window; }
126 
128  HPS::UTF8 const & GetName() const { return name; }
129 
130  protected:
131  HPS::Point window_min;
132  HPS::Point window_max;
133  HPS::MatrixKit world_to_window;
134  HPS::UTF8 name;
135  };
136 
137  typedef std::vector<Area, HPS::Allocator<Area>> AreaArray;
138 
139  class PointCloud;
140 
142  class OOC_API AreaHighlightTracker {
143 
144  public:
145  AreaHighlightTracker(HPS::Canvas const & in_canvas, HPS::SegmentKey const & in_area_cameras);
146 
147  virtual ~AreaHighlightTracker();
148 
149  virtual void Process(HPS::KeyArray const & shell_keys)
150  {
151  (void)shell_keys;
152  }
153 
155  void Clear();
156 
158  bool Empty() const;
159 
164  void AddArea(HPS::Rectangle const & in_rect, HPS::MatrixKit const & in_world_to_window, bool in_clear);
165 
166 
170  void AddPoint(HPS::WorldPoint const & in_point, bool in_clear);
171 
175  bool Intersects(HPS::SimpleCuboid const & world_space_bounding) const;
176 
180  bool Intersects(HPS::Point const & world_space_point) const;
181 
183  HPS::OOC::AreaArray const & GetAreas() const;
184 
186  HPS::Canvas const & GetCanvas() const;
187 
189  HPS::WindowKey const & GetWindowKey() const;
190 
192  HPS::SegmentKey const & GetAreaCameraSegment() const;
193 
194  bool GetInspecting() const;
195 
196  private:
197  friend class HBaseView;
198  friend class PointCloud;
199  void * opaque;
200  };
201 
203  class OOC_API ImportNotifier : public IONotifier
204  {
205  public:
207  ImportNotifier();
208 
211  ImportNotifier(ImportNotifier const & in_that);
212 
217  ImportNotifier(IONotifier const & in_that);
218 
222  ImportNotifier(ImportNotifier && in_that);
223 
227  ImportNotifier & operator=(ImportNotifier && in_that);
228 
229  virtual ~ImportNotifier();
230 
231  static const HPS::Type staticType = HPS::Type::OOCImportNotifier;
232  HPS::Type ObjectType() const { return staticType; };
233 
237  ImportNotifier & operator=(ImportNotifier const & in_that);
238 
241  void Assign(ImportNotifier const & in_that);
242 
246  HPS::Model & GetTarget() const;
247  };
248 
250  class OOC_API ImportOptionsKit : public HPS::Sprocket
251  {
252  public:
255 
258  ImportOptionsKit(ImportOptionsKit const & in_kit);
259 
264 
268  ImportOptionsKit & operator=(ImportOptionsKit && in_that);
269 
270  virtual ~ImportOptionsKit();
271 
272  static const HPS::Type staticType = HPS::Type::OOCImportOptionsKit;
273  HPS::Type ObjectType() const { return staticType; }
274 
278  static ImportOptionsKit GetDefault();
279 
282  void Set(ImportOptionsKit const & in_kit);
283 
286  void Show(ImportOptionsKit & out_kit) const;
287 
291  ImportOptionsKit & operator=(ImportOptionsKit const & in_kit);
292 
295  bool Empty() const;
296 
300  bool Equals(ImportOptionsKit const & in_kit) const;
301 
305  bool operator==(ImportOptionsKit const & in_kit) const;
306 
310  bool operator!=(ImportOptionsKit const & in_kit) const;
311 
315  ImportOptionsKit & SetTarget(HPS::Model const & in_target);
316 
321  bool ShowTarget(HPS::Model & out_model) const;
322 
325  ImportOptionsKit & UnsetTarget();
326 
330  ImportOptionsKit & SetManualUpdates(bool in_manual_updates);
331 
335  bool ShowManualUpdates(bool & out_manual_updates) const;
336 
339  ImportOptionsKit & UnsetManualUpdates();
340 
345  ImportOptionsKit & SetAreaHighlightTracker(HPS::OOC::AreaHighlightTracker & in_area_highlight_tracker);
346 
349  ImportOptionsKit & UnsetAreaHighlightTracker();
350 
353  ImportOptionsKit & UnsetEverything();
354 
355  };
356 
357 
359  class OOC_API File
360  {
361  public:
366  static ImportNotifier Import(char const * in_file_name, ImportOptionsKit const & in_options);
367 
368  private:
370  File();
371  };
372 
375 
376 
377  class OOC_API PointCloud;
378  class OOC_API SynchronizedActions;
379  class OOC_API QueryFilter;
380  class OOC_API QueryIterator;
381  class OOC_API QueryResult;
382  class FilterForwarder;
383 
384  class OOC_API NodeHandle {
385  public:
386  public:
387  NodeHandle(NodeHandle&& that);
388  ~NodeHandle();
389 
390  bool Equals(NodeHandle const & other) const;
391  bool operator== (NodeHandle const & other) const;
392  bool operator!= (NodeHandle const & other) const;
393 
396  bool Empty() const;
397 
400  HPS::SegmentKey GetSegment() const;
401 
404  HPS::ShellKey GetShell() const;
405 
406  private:
408  NodeHandle();
409  NodeHandle(void * in_opaque);
410  NodeHandle(NodeHandle const & that) = delete;
411 
412  void * opaque;
413 
414  friend class HPS::OOC::SynchronizedActions;
415  friend class HPS::OOC::PointCloud;
416  friend class HPS::OOC::FilterForwarder;
417  friend class HPS::OOC::QueryIterator;
418  };
419 
421  class OOC_API SynchronizedActions {
422  public:
423 
425  enum class Result {
426  Success,
427  ErrorInvalidNode,
428  ErrorInvalidPointCloud,
429  ErrorUnknownFailure,
430  ErrorInternalFailure,
431  ErrorCouldNotFindNode,
432  ErrorInputIndicesAreNotStrictlyIncreasing,
433  ErrorIllegalInputIndices,
434  ErrorCorruptNode,
435  ErrorFileSystemFailure,
436  };
437 
441  Result DeleteNode(NodeHandle const & node_handle) const;
442 
448  Result DeleteSpecificPoints(NodeHandle const & node_handle, int32_t const point_indices[], size_t count) const;
449 
454  Result DeleteSpecificPoints(NodeHandle const & node_handle, HPS::Int32Array const & point_indices) const;
455 
458  Result OptimizeDeltas() const;
459 
460  private:
461  friend class HPS::OOC::PointCloud;
464  void * opaque;
465  };
466 
467 
469  class OOC_API Synchronized {
470  public:
471 
472  Synchronized();
473 
474  virtual ~Synchronized();
475 
480  (void)actions;
481  return HPS::OOC::SynchronizedActions::Result::Success;
482  };
483  };
484 
485 
487  enum class IOResult {
488  Success,
489  ErrorInvalidPointCloud,
490  ErrorUnknownFailure,
491  ErrorNoOOCView,
492  ErrorCyclicFileDependencies,
493  ErrorSerializationFailure,
494  ErrorDeserializationFailure,
495  ErrorIllegalFileName,
496  ErrorFileSystemFailure,
497  ErrorOOCRootAlreadyExists,
498  ErrorInvalidBuffer,
499  };
500 
502  class OOC_API PointCloud {
503  public:
504  PointCloud(HPS::Model const & in_model);
505  PointCloud(PointCloud&& that);
506  ~PointCloud();
507 
508  bool Equals(PointCloud const & other) const;
509  bool operator== (PointCloud const & other) const;
510  bool operator!= (PointCloud const & other) const;
511 
514  bool Empty();
515 
518  HPS::SegmentKey GetSegment();
519 
521  void Destroy();
522 
524  void Release();
525 
529  NodeHandle GetNodeHandle(HPS::SegmentKey const & node_key);
530 
533  bool PollUpdateNeeded();
534 
538  HPS::OOC::SynchronizedActions::Result Synchronize(Synchronized & synchronized);
539 
543  OOC::QueryIterator QueryPoints(QueryFilter & filter);
544 
568  IOResult CommitDeltasToFile();
569 
570  /* Saves to disk any changes made to the point cloud.
571  \param delta_file_name The generated file name of the written delta will be returned.
572  \return an IOResult return code.
573  */
574  IOResult CommitDeltasToFile(HPS::UTF8 & out_delta_file_name);
575 
579  bool HasUncommittedDeltas();
580 
584  bool DeleteFromPointCloud(HPS::OOC::AreaHighlightTracker & tracker);
585 
586  private:
588  PointCloud();
589  PointCloud(void * in_opaque);
590  PointCloud(PointCloud const & that) = delete;
591  void * opaque;
592  };
593 
596  class OOC_API QueryFilter {
597  friend class QueryIterator;
598 
599  public:
600  QueryFilter() {}
601  virtual ~QueryFilter() {}
602 
605  virtual bool RejectPointsInMemory()
606  {
607  return false;
608  }
609 
612  virtual bool RejectPointsOnDisk()
613  {
614  return false;
615  }
616 
620  virtual bool RejectNode(NodeHandle const & node_handle)
621  {
622  (void)node_handle;
623  return false;
624  }
625 
630  virtual bool RejectBounding(Point const & min_bound, Point const & max_bound)
631  {
632  (void)min_bound; (void)max_bound;
633  return false;
634  }
635 
640  virtual bool AcceptPoint(Point const & point, size_t point_index)
641  {
642  (void)point; (void)point_index;
643  return true;
644  }
645  };
646 
647 
649  class OOC_API QueryIterator {
650 
651  public:
653  enum class Status {
654  Alive,
655  Dead,
656  ErrorUnknownFailure,
657  ErrorFileSystemFailure,
658  ErrorDeserializationFailure,
659  ErrorCouldNotFindNode,
660  ErrorCorruptNode,
661  };
662 
665  QueryIterator();
666 
669  QueryIterator(QueryIterator && other);
670 
671  ~QueryIterator();
672 
675  Status GetStatus() const;
676 
678  enum class Storage {
679  Memory,
680  Disk,
681  };
682 
685  NodeHandle GetNodeHandle() const;
686 
689  RGBColor GetNodePointColor() const;
690 
693  Point GetNodePoint() const;
694 
697  size_t GetNodePointIndex() const;
698 
701  Storage GetStorage() const;
702 
705  void Next();
706 
707  private:
708  friend class HPS::OOC::PointCloud;
709  QueryIterator(void * in_opaque);
710  QueryIterator(QueryIterator const & other) = delete;
711  void * opaque;
712  };
713 
714 private:
716  OOC();
717 };
718 
719 }
720 
721 #endif
Definition: sprk_ooc.h:502
Definition: sprk_ooc.h:649
Definition: sprk.h:67
Definition: hps.h:48848
Definition: sprk.h:106
Result
Definition: sprk_ooc.h:425
virtual bool RejectPointsInMemory()
Definition: sprk_ooc.h:605
Definition: sprk_ooc.h:39
virtual HPS::OOC::SynchronizedActions::Result Actions(SynchronizedActions const &actions)
Definition: sprk_ooc.h:479
Definition: hps.h:7762
Definition: hps.h:3571
Status
Definition: sprk_ooc.h:653
virtual bool AcceptPoint(Point const &point, size_t point_index)
Definition: sprk_ooc.h:640
Definition: sprk_ooc.h:421
Definition: sprk_ooc.h:250
std::vector< int32_t, HPS::Allocator< int32_t > > Int32Array
Array of type int32_t.
Definition: hps.h:6737
bool Intersects(HPS::Point const &world_space_point) const
Definition: sprk_ooc.h:101
Definition: hps.h:33436
Definition: sprk_ooc.h:596
virtual bool RejectNode(NodeHandle const &node_handle)
Definition: sprk_ooc.h:620
Definition: hps.h:4478
Definition: hps.h:7133
Definition: sprk_ooc.h:359
virtual bool RejectBounding(Point const &min_bound, Point const &max_bound)
Definition: sprk_ooc.h:630
Definition: hps.h:6090
Definition: hps.h:15796
Definition: hps.h:48789
Definition: sprk_ooc.h:142
HPS::UTF8 const & GetName() const
Definition: sprk_ooc.h:128
Definition: sprk.h:487
HPS::MatrixKit const & GetWorldToWindow() const
Definition: sprk_ooc.h:125
IOResult
Definition: sprk_ooc.h:487
std::vector< Key, Allocator< Key > > KeyArray
Array of type HPS::Key.
Definition: hps.h:6694
Definition: sprk_ooc.h:469
Storage
Definition: sprk_ooc.h:678
Definition: sprk_ooc.h:203
Definition: hps.h:9164
HPS_INLINE void Generate_Cuboid_Points(Point_3D< F > *points) const
Definition: hps.h:4002
virtual bool RejectPointsOnDisk()
Definition: sprk_ooc.h:612
Definition: sprk_ooc.h:44
Definition: sprk_ooc.h:384
bool Intersects(HPS::SimpleCuboid const &world_space_bounding) const
Definition: sprk_ooc.h:60
Definition: hps.h:5763