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 
140  class OOC_API AreaHighlightTracker {
141 
142  public:
143  AreaHighlightTracker(HPS::Canvas const & in_canvas, HPS::SegmentKey const & in_area_cameras);
144 
145  virtual ~AreaHighlightTracker();
146 
147  virtual void Process(HPS::KeyArray const & shell_keys)
148  {
149  (void)shell_keys;
150  }
151 
153  void Clear();
154 
156  bool Empty() const;
157 
162  void AddArea(HPS::Rectangle const & in_rect, HPS::MatrixKit const & in_world_to_window, bool in_clear);
163 
167  bool Intersects(HPS::SimpleCuboid const & world_space_bounding) const;
168 
172  bool Intersects(HPS::Point const & world_space_point) const;
173 
175  HPS::OOC::AreaArray const & GetAreas() const;
176 
178  HPS::Canvas const & GetCanvas() const;
179 
181  HPS::WindowKey const & GetWindowKey() const;
182 
184  HPS::SegmentKey const & GetAreaCameraSegment() const;
185 
186  bool GetInspecting() const;
187  private:
188  friend class HBaseView;
189  void * opaque;
190  };
191 
193  class OOC_API ImportNotifier : public IONotifier
194  {
195  public:
197  ImportNotifier();
198 
201  ImportNotifier(ImportNotifier const & in_that);
202 
207  ImportNotifier(IONotifier const & in_that);
208 
212  ImportNotifier(ImportNotifier && in_that);
213 
217  ImportNotifier & operator=(ImportNotifier && in_that);
218 
219  virtual ~ImportNotifier();
220 
221  HPS::Type ObjectType() const { return HPS::Type::OOCImportNotifier; };
222 
226  ImportNotifier & operator=(ImportNotifier const & in_that);
227 
230  void Assign(ImportNotifier const & in_that);
231 
235  HPS::Model & GetTarget() const;
236  };
237 
239  class OOC_API ImportOptionsKit : public HPS::Sprocket
240  {
241  public:
244 
247  ImportOptionsKit(ImportOptionsKit const & in_kit);
248 
253 
257  ImportOptionsKit & operator=(ImportOptionsKit && in_that);
258 
259  virtual ~ImportOptionsKit();
260 
261  HPS::Type ObjectType() const { return HPS::Type::OOCImportOptionsKit; }
262 
266  static ImportOptionsKit GetDefault();
267 
270  void Set(ImportOptionsKit const & in_kit);
271 
274  void Show(ImportOptionsKit & out_kit) const;
275 
279  ImportOptionsKit & operator=(ImportOptionsKit const & in_kit);
280 
283  bool Empty() const;
284 
288  bool Equals(ImportOptionsKit const & in_kit) const;
289 
293  bool operator==(ImportOptionsKit const & in_kit) const;
294 
298  bool operator!=(ImportOptionsKit const & in_kit) const;
299 
303  ImportOptionsKit & SetTarget(HPS::Model const & in_target);
304 
309  bool ShowTarget(HPS::Model & out_model) const;
310 
313  ImportOptionsKit & UnsetTarget();
314 
318  ImportOptionsKit & SetManualUpdates(bool in_manual_updates);
319 
323  bool ShowManualUpdates(bool & out_manual_updates) const;
324 
327  ImportOptionsKit & UnsetManualUpdates();
328 
333  ImportOptionsKit & SetAreaHighlightTracker(HPS::OOC::AreaHighlightTracker & in_area_highlight_tracker);
334 
337  ImportOptionsKit & UnsetAreaHighlightTracker();
338 
341  ImportOptionsKit & UnsetEverything();
342 
343  };
344 
345 
347  class OOC_API File
348  {
349  public:
354  static ImportNotifier Import(char const * in_file_name, ImportOptionsKit const & in_options);
355 
356  private:
358  File();
359  };
360 
363 
364 
365  class OOC_API PointCloud;
366  class OOC_API SynchronizedActions;
367  class OOC_API QueryFilter;
368  class OOC_API QueryIterator;
369  class OOC_API QueryResult;
370  class FilterForwarder;
371 
372  class OOC_API NodeHandle {
373  public:
374  public:
375  NodeHandle(NodeHandle&& that);
376  ~NodeHandle();
377 
378  bool Equals(NodeHandle const & other) const;
379  bool operator== (NodeHandle const & other) const;
380  bool operator!= (NodeHandle const & other) const;
381 
384  bool Empty() const;
385 
388  HPS::SegmentKey GetSegment() const;
389 
392  HPS::ShellKey GetShell() const;
393 
394  private:
396  NodeHandle();
397  NodeHandle(void * in_opaque);
398  NodeHandle(NodeHandle const & that) = delete;
399 
400  void * opaque;
401 
402  friend class HPS::OOC::SynchronizedActions;
403  friend class HPS::OOC::PointCloud;
404  friend class HPS::OOC::FilterForwarder;
405  friend class HPS::OOC::QueryIterator;
406  };
407 
409  class OOC_API SynchronizedActions {
410  public:
411 
413  enum class Result {
414  Success,
415  ErrorInvalidNode,
416  ErrorInvalidPointCloud,
417  ErrorUnknownFailure,
418  ErrorInternalFailure,
419  ErrorCouldNotFindNode,
420  ErrorInputIndicesAreNotStrictlyIncreasing,
421  ErrorIllegalInputIndices,
422  ErrorCorruptNode,
423  ErrorFileSystemFailure,
424  };
425 
429  Result DeleteNode(NodeHandle const & node_handle) const;
430 
436  Result DeleteSpecificPoints(NodeHandle const & node_handle, int32_t const point_indices[], size_t count) const;
437 
442  Result DeleteSpecificPoints(NodeHandle const & node_handle, HPS::Int32Array const & point_indices) const;
443 
446  Result OptimizeDeltas() const;
447 
448  private:
449  friend class HPS::OOC::PointCloud;
452  void * opaque;
453  };
454 
455 
457  class OOC_API Synchronized {
458  public:
459 
460  Synchronized();
461 
462  virtual ~Synchronized();
463 
468  (void)actions;
469  return HPS::OOC::SynchronizedActions::Result::Success;
470  };
471  };
472 
473 
475  enum class IOResult {
476  Success,
477  ErrorInvalidPointCloud,
478  ErrorUnknownFailure,
479  ErrorNoOOCView,
480  ErrorCyclicFileDependencies,
481  ErrorSerializationFailure,
482  ErrorDeserializationFailure,
483  ErrorIllegalFileName,
484  ErrorFileSystemFailure,
485  ErrorOOCRootAlreadyExists,
486  ErrorInvalidBuffer,
487  };
488 
490  class OOC_API PointCloud {
491  public:
492  PointCloud(HPS::Model const & in_model);
493  PointCloud(PointCloud&& that);
494  ~PointCloud();
495 
496  bool Equals(PointCloud const & other) const;
497  bool operator== (PointCloud const & other) const;
498  bool operator!= (PointCloud const & other) const;
499 
502  bool Empty();
503 
506  HPS::SegmentKey GetSegment();
507 
509  void Destroy();
510 
512  void Release();
513 
517  NodeHandle GetNodeHandle(HPS::SegmentKey const & node_key);
518 
521  bool PollUpdateNeeded();
522 
526  HPS::OOC::SynchronizedActions::Result Synchronize(Synchronized & synchronized);
527 
531  OOC::QueryIterator QueryPoints(QueryFilter & filter);
532 
556  IOResult CommitDeltasToFile();
557 
558  /* Saves to disk any changes made to the point cloud.
559  \param delta_file_name The generated file name of the written delta will be returned.
560  \return an IOResult return code.
561  */
562  IOResult CommitDeltasToFile(HPS::UTF8 & out_delta_file_name);
563 
567  bool HasUncommittedDeltas();
568 
569  private:
571  PointCloud();
572  PointCloud(void * in_opaque);
573  PointCloud(PointCloud const & that) = delete;
574  void * opaque;
575  };
576 
579  class OOC_API QueryFilter {
580  friend class QueryIterator;
581 
582  public:
583  QueryFilter() {}
584  virtual ~QueryFilter() {}
585 
588  virtual bool RejectPointsInMemory()
589  {
590  return false;
591  }
592 
595  virtual bool RejectPointsOnDisk()
596  {
597  return false;
598  }
599 
603  virtual bool RejectNode(NodeHandle const & node_handle)
604  {
605  (void)node_handle;
606  return false;
607  }
608 
613  virtual bool RejectBounding(Point const & min_bound, Point const & max_bound)
614  {
615  (void)min_bound; (void)max_bound;
616  return false;
617  }
618 
623  virtual bool AcceptPoint(Point const & point, size_t point_index)
624  {
625  (void)point; (void)point_index;
626  return true;
627  }
628  };
629 
630 
632  class OOC_API QueryIterator {
633 
634  public:
636  enum class Status {
637  Alive,
638  Dead,
639  ErrorUnknownFailure,
640  ErrorFileSystemFailure,
641  ErrorDeserializationFailure,
642  ErrorCouldNotFindNode,
643  ErrorCorruptNode,
644  };
645 
648  QueryIterator();
649 
652  QueryIterator(QueryIterator && other);
653 
654  ~QueryIterator();
655 
658  Status GetStatus() const;
659 
661  enum class Storage {
662  Memory,
663  Disk,
664  };
665 
668  NodeHandle GetNodeHandle() const;
669 
672  RGBColor GetNodePointColor() const;
673 
676  Point GetNodePoint() const;
677 
680  size_t GetNodePointIndex() const;
681 
684  Storage GetStorage() const;
685 
688  void Next();
689 
690  private:
691  friend class HPS::OOC::PointCloud;
692  QueryIterator(void * in_opaque);
693  QueryIterator(QueryIterator const & other) = delete;
694  void * opaque;
695  };
696 
697 private:
699  OOC();
700 };
701 
702 }
703 
704 #endif
Definition: sprk_ooc.h:490
Definition: sprk_ooc.h:632
Definition: sprk.h:66
Definition: sprk.h:100
Result
Definition: sprk_ooc.h:413
virtual bool RejectPointsInMemory()
Definition: sprk_ooc.h:588
Definition: sprk_ooc.h:39
virtual HPS::OOC::SynchronizedActions::Result Actions(SynchronizedActions const &actions)
Definition: sprk_ooc.h:467
Definition: hps.h:7713
Definition: hps.h:3484
Status
Definition: sprk_ooc.h:636
virtual bool AcceptPoint(Point const &point, size_t point_index)
Definition: sprk_ooc.h:623
Definition: sprk_ooc.h:409
Definition: sprk_ooc.h:239
bool Intersects(HPS::Point const &world_space_point) const
Definition: sprk_ooc.h:101
Definition: hps.h:32326
Definition: sprk_ooc.h:579
virtual bool RejectNode(NodeHandle const &node_handle)
Definition: sprk_ooc.h:603
Definition: hps.h:4324
Definition: hps.h:7086
Definition: sprk_ooc.h:347
virtual bool RejectBounding(Point const &min_bound, Point const &max_bound)
Definition: sprk_ooc.h:613
HPS::Type ObjectType() const
Definition: sprk_ooc.h:221
Definition: hps.h:15321
Definition: hps.h:46622
Definition: sprk_ooc.h:140
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:475
HPS::Type ObjectType() const
Definition: sprk_ooc.h:261
Definition: sprk_ooc.h:457
Storage
Definition: sprk_ooc.h:661
Definition: sprk_ooc.h:193
Definition: hps.h:9025
HPS_INLINE void Generate_Cuboid_Points(Point_3D< F > *points) const
Definition: hps.h:3898
virtual bool RejectPointsOnDisk()
Definition: sprk_ooc.h:595
Definition: sprk_ooc.h:44
Definition: sprk_ooc.h:372
bool Intersects(HPS::SimpleCuboid const &world_space_bounding) const
Definition: sprk_ooc.h:60
Definition: hps.h:5583