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  HPS::Type ObjectType() const { return HPS::Type::OOCImportNotifier; };
232 
236  ImportNotifier & operator=(ImportNotifier const & in_that);
237 
240  void Assign(ImportNotifier const & in_that);
241 
245  HPS::Model & GetTarget() const;
246  };
247 
249  class OOC_API ImportOptionsKit : public HPS::Sprocket
250  {
251  public:
254 
257  ImportOptionsKit(ImportOptionsKit const & in_kit);
258 
263 
267  ImportOptionsKit & operator=(ImportOptionsKit && in_that);
268 
269  virtual ~ImportOptionsKit();
270 
271  HPS::Type ObjectType() const { return HPS::Type::OOCImportOptionsKit; }
272 
276  static ImportOptionsKit GetDefault();
277 
280  void Set(ImportOptionsKit const & in_kit);
281 
284  void Show(ImportOptionsKit & out_kit) const;
285 
289  ImportOptionsKit & operator=(ImportOptionsKit const & in_kit);
290 
293  bool Empty() const;
294 
298  bool Equals(ImportOptionsKit const & in_kit) const;
299 
303  bool operator==(ImportOptionsKit const & in_kit) const;
304 
308  bool operator!=(ImportOptionsKit const & in_kit) const;
309 
313  ImportOptionsKit & SetTarget(HPS::Model const & in_target);
314 
319  bool ShowTarget(HPS::Model & out_model) const;
320 
323  ImportOptionsKit & UnsetTarget();
324 
328  ImportOptionsKit & SetManualUpdates(bool in_manual_updates);
329 
333  bool ShowManualUpdates(bool & out_manual_updates) const;
334 
337  ImportOptionsKit & UnsetManualUpdates();
338 
343  ImportOptionsKit & SetAreaHighlightTracker(HPS::OOC::AreaHighlightTracker & in_area_highlight_tracker);
344 
347  ImportOptionsKit & UnsetAreaHighlightTracker();
348 
351  ImportOptionsKit & UnsetEverything();
352 
353  };
354 
355 
357  class OOC_API File
358  {
359  public:
364  static ImportNotifier Import(char const * in_file_name, ImportOptionsKit const & in_options);
365 
366  private:
368  File();
369  };
370 
373 
374 
375  class OOC_API PointCloud;
376  class OOC_API SynchronizedActions;
377  class OOC_API QueryFilter;
378  class OOC_API QueryIterator;
379  class OOC_API QueryResult;
380  class FilterForwarder;
381 
382  class OOC_API NodeHandle {
383  public:
384  public:
385  NodeHandle(NodeHandle&& that);
386  ~NodeHandle();
387 
388  bool Equals(NodeHandle const & other) const;
389  bool operator== (NodeHandle const & other) const;
390  bool operator!= (NodeHandle const & other) const;
391 
394  bool Empty() const;
395 
398  HPS::SegmentKey GetSegment() const;
399 
402  HPS::ShellKey GetShell() const;
403 
404  private:
406  NodeHandle();
407  NodeHandle(void * in_opaque);
408  NodeHandle(NodeHandle const & that) = delete;
409 
410  void * opaque;
411 
412  friend class HPS::OOC::SynchronizedActions;
413  friend class HPS::OOC::PointCloud;
414  friend class HPS::OOC::FilterForwarder;
415  friend class HPS::OOC::QueryIterator;
416  };
417 
419  class OOC_API SynchronizedActions {
420  public:
421 
423  enum class Result {
424  Success,
425  ErrorInvalidNode,
426  ErrorInvalidPointCloud,
427  ErrorUnknownFailure,
428  ErrorInternalFailure,
429  ErrorCouldNotFindNode,
430  ErrorInputIndicesAreNotStrictlyIncreasing,
431  ErrorIllegalInputIndices,
432  ErrorCorruptNode,
433  ErrorFileSystemFailure,
434  };
435 
439  Result DeleteNode(NodeHandle const & node_handle) const;
440 
446  Result DeleteSpecificPoints(NodeHandle const & node_handle, int32_t const point_indices[], size_t count) const;
447 
452  Result DeleteSpecificPoints(NodeHandle const & node_handle, HPS::Int32Array const & point_indices) const;
453 
456  Result OptimizeDeltas() const;
457 
458  private:
459  friend class HPS::OOC::PointCloud;
462  void * opaque;
463  };
464 
465 
467  class OOC_API Synchronized {
468  public:
469 
470  Synchronized();
471 
472  virtual ~Synchronized();
473 
478  (void)actions;
479  return HPS::OOC::SynchronizedActions::Result::Success;
480  };
481  };
482 
483 
485  enum class IOResult {
486  Success,
487  ErrorInvalidPointCloud,
488  ErrorUnknownFailure,
489  ErrorNoOOCView,
490  ErrorCyclicFileDependencies,
491  ErrorSerializationFailure,
492  ErrorDeserializationFailure,
493  ErrorIllegalFileName,
494  ErrorFileSystemFailure,
495  ErrorOOCRootAlreadyExists,
496  ErrorInvalidBuffer,
497  };
498 
500  class OOC_API PointCloud {
501  public:
502  PointCloud(HPS::Model const & in_model);
503  PointCloud(PointCloud&& that);
504  ~PointCloud();
505 
506  bool Equals(PointCloud const & other) const;
507  bool operator== (PointCloud const & other) const;
508  bool operator!= (PointCloud const & other) const;
509 
512  bool Empty();
513 
516  HPS::SegmentKey GetSegment();
517 
519  void Destroy();
520 
522  void Release();
523 
527  NodeHandle GetNodeHandle(HPS::SegmentKey const & node_key);
528 
531  bool PollUpdateNeeded();
532 
536  HPS::OOC::SynchronizedActions::Result Synchronize(Synchronized & synchronized);
537 
541  OOC::QueryIterator QueryPoints(QueryFilter & filter);
542 
566  IOResult CommitDeltasToFile();
567 
568  /* Saves to disk any changes made to the point cloud.
569  \param delta_file_name The generated file name of the written delta will be returned.
570  \return an IOResult return code.
571  */
572  IOResult CommitDeltasToFile(HPS::UTF8 & out_delta_file_name);
573 
577  bool HasUncommittedDeltas();
578 
582  bool DeleteFromPointCloud(HPS::OOC::AreaHighlightTracker & tracker);
583 
584  private:
586  PointCloud();
587  PointCloud(void * in_opaque);
588  PointCloud(PointCloud const & that) = delete;
589  void * opaque;
590  };
591 
594  class OOC_API QueryFilter {
595  friend class QueryIterator;
596 
597  public:
598  QueryFilter() {}
599  virtual ~QueryFilter() {}
600 
603  virtual bool RejectPointsInMemory()
604  {
605  return false;
606  }
607 
610  virtual bool RejectPointsOnDisk()
611  {
612  return false;
613  }
614 
618  virtual bool RejectNode(NodeHandle const & node_handle)
619  {
620  (void)node_handle;
621  return false;
622  }
623 
628  virtual bool RejectBounding(Point const & min_bound, Point const & max_bound)
629  {
630  (void)min_bound; (void)max_bound;
631  return false;
632  }
633 
638  virtual bool AcceptPoint(Point const & point, size_t point_index)
639  {
640  (void)point; (void)point_index;
641  return true;
642  }
643  };
644 
645 
647  class OOC_API QueryIterator {
648 
649  public:
651  enum class Status {
652  Alive,
653  Dead,
654  ErrorUnknownFailure,
655  ErrorFileSystemFailure,
656  ErrorDeserializationFailure,
657  ErrorCouldNotFindNode,
658  ErrorCorruptNode,
659  };
660 
663  QueryIterator();
664 
667  QueryIterator(QueryIterator && other);
668 
669  ~QueryIterator();
670 
673  Status GetStatus() const;
674 
676  enum class Storage {
677  Memory,
678  Disk,
679  };
680 
683  NodeHandle GetNodeHandle() const;
684 
687  RGBColor GetNodePointColor() const;
688 
691  Point GetNodePoint() const;
692 
695  size_t GetNodePointIndex() const;
696 
699  Storage GetStorage() const;
700 
703  void Next();
704 
705  private:
706  friend class HPS::OOC::PointCloud;
707  QueryIterator(void * in_opaque);
708  QueryIterator(QueryIterator const & other) = delete;
709  void * opaque;
710  };
711 
712 private:
714  OOC();
715 };
716 
717 }
718 
719 #endif
Definition: sprk_ooc.h:500
Definition: sprk_ooc.h:647
Definition: sprk.h:66
Definition: hps.h:47301
Definition: sprk.h:100
Result
Definition: sprk_ooc.h:423
virtual bool RejectPointsInMemory()
Definition: sprk_ooc.h:603
Definition: sprk_ooc.h:39
virtual HPS::OOC::SynchronizedActions::Result Actions(SynchronizedActions const &actions)
Definition: sprk_ooc.h:477
Definition: hps.h:7612
Definition: hps.h:3523
Status
Definition: sprk_ooc.h:651
virtual bool AcceptPoint(Point const &point, size_t point_index)
Definition: sprk_ooc.h:638
Definition: sprk_ooc.h:419
Definition: sprk_ooc.h:249
std::vector< int32_t, HPS::Allocator< int32_t > > Int32Array
Array of type int32_t.
Definition: hps.h:6593
bool Intersects(HPS::Point const &world_space_point) const
Definition: sprk_ooc.h:101
Definition: hps.h:32469
Definition: sprk_ooc.h:594
virtual bool RejectNode(NodeHandle const &node_handle)
Definition: sprk_ooc.h:618
Definition: hps.h:4363
Definition: hps.h:6985
Definition: sprk_ooc.h:357
virtual bool RejectBounding(Point const &min_bound, Point const &max_bound)
Definition: sprk_ooc.h:628
Definition: hps.h:5948
HPS::Type ObjectType() const
Definition: sprk_ooc.h:231
Definition: hps.h:15271
Definition: hps.h:47245
Definition: sprk_ooc.h:142
HPS::UTF8 const & GetName() const
Definition: sprk_ooc.h:128
Definition: sprk.h:473
HPS::MatrixKit const & GetWorldToWindow() const
Definition: sprk_ooc.h:125
IOResult
Definition: sprk_ooc.h:485
HPS::Type ObjectType() const
Definition: sprk_ooc.h:271
std::vector< Key, Allocator< Key > > KeyArray
Array of type HPS::Key.
Definition: hps.h:6550
Definition: sprk_ooc.h:467
Storage
Definition: sprk_ooc.h:676
Definition: sprk_ooc.h:203
Definition: hps.h:8969
HPS_INLINE void Generate_Cuboid_Points(Point_3D< F > *points) const
Definition: hps.h:3937
virtual bool RejectPointsOnDisk()
Definition: sprk_ooc.h:610
Definition: sprk_ooc.h:44
Definition: sprk_ooc.h:382
bool Intersects(HPS::SimpleCuboid const &world_space_bounding) const
Definition: sprk_ooc.h:60
Definition: hps.h:5630