PointCloudAPI.h
Go to the documentation of this file.
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 #pragma once
11 
12 #ifdef SPRK_OOC
13 
14 #include "ooci_api_shim.h"
15 
16 #else
17 #include "hc.h"
18 #include "HTools.h"
19 #include "HGlobals.h"
20 
21 #ifdef _WIN32
22 # define OOC_API __declspec(dllexport)
23 #else
24 # define OOC_API
25 #endif
26 
27 #endif
28 
29 #include <stdint.h>
30 #include <functional>
31 
33 
34 
36 class PointCloudWorld;
37 class NodeData;
38 
39 
40 namespace ooc
41 {
42  namespace delta
43  {
44  namespace on_disk
45  {
46  class NodeHandleSerializer;
47  class NodeHandleDeserializer;
48  }
49  }
50 }
51 
52 
54 
55 
56 namespace ooc
57 {
58  class ReifiedEnv;
59 
60 
62  class OOC_API Env {
63  friend class ReifiedEnv;
64 
65  public:
70  Env ();
71 
72  bool operator== (Env const & other) const;
73  bool operator!= (Env const & other) const;
74 
75  private:
76  void * opaque;
77  uintptr_t key;
78  };
79 
80 
82  class OOC_API RGBColor {
83  public:
86  : r(-1.0f)
87  , g(-1.0f)
88  , b(-1.0f)
89  {}
90 
92  RGBColor(float r, float g, float b)
93  : r(r)
94  , g(g)
95  , b(b)
96  {}
97 
99  bool IsValid () const {
100  return r >= 0.0f && g >= 0.0f && b >= 0.0f;
101  }
102 
103  public:
104  float r;
105  float g;
106  float b;
107  };
108 
109 
111  class OOC_API Point {
112  public:
114  Point ()
115  : x(0.0f)
116  , y(0.0f)
117  , z(0.0f)
118  {}
119 
126  Point (float x, float y, float z)
127  : x(x)
128  , y(y)
129  , z(z)
130  {}
131 
136  Point operator+ (Point const & other) const
137  {
138  return Point(x + other.x, y + other.y, z + other.z);
139  }
140 
145  Point operator- (Point const & other) const
146  {
147  return Point(x - other.x, y - other.y, z - other.z);
148  }
149 
154  Point operator* (float scale) const
155  {
156  return Point(x * scale, y * scale, z * scale);
157  }
158 
163  Point operator/ (float scale) const
164  {
165  return Point(x / scale, y / scale, z / scale);
166  }
167 
168  public:
169  float x;
170  float y;
171  float z;
172  };
173 
177  friend class delta::on_disk::NodeHandleSerializer;
178  friend class delta::on_disk::NodeHandleDeserializer;
179 
180  private:
181  NodeHandle (uint32_t node_file_id, uint32_t node_file_offset);
182 
183  public:
186 
190  NodeHandle (NodeData const & node_data);
191 
197  static NodeHandle Invalid ();
198 
199  /* Returns a hash code for a given node handle. Provides a means to hash the
200  value of an ooc::NodeHandle.
201 
202  A node handle will always return the same hash value in a given run of a
203  program. That being said, this function may return different values between
204  different runs of the program. In other words, the generated hash code is
205  not persistent between different program executions.
206  */
207  size_t Hash () const;
208 
214  bool operator== (NodeHandle const & other) const
215  {
216  return node_file_id == other.node_file_id && node_file_offset == other.node_file_offset;
217  }
218 
224  bool operator!= (NodeHandle const & other) const
225  {
226  return !(*this == other);
227  }
228 
234  bool operator< (NodeHandle const & other) const
235  {
236  if (node_file_id < other.node_file_id) {
237  return true;
238  }
239  if (node_file_id > other.node_file_id) {
240  return false;
241  }
242  return node_file_offset < other.node_file_offset;
243  }
244 
245  private:
246  uint32_t node_file_id;
247  uint32_t node_file_offset;
248  };
249 
250 
256  OOC_API bool IsRoot (HC_KEY ooc_root);
257 
266  OOC_API bool GetEnv (HC_KEY ooc_root, Env & out_env);
267 
278  OOC_API size_t GetEnvs(HC_KEY ooc_root, Env * out_envs, size_t count);
279 
286  OOC_API size_t GetEnvCount(HC_KEY ooc_root);
287 
293  OOC_API HC_KEY GetRoot (Env env);
294 
305  OOC_API void Destroy (Env env);
306 
319  OOC_API void Release (Env env);
320 
330  OOC_API bool GetNodeHandle (Env env, HC_KEY node_segment_key, NodeHandle & out_node_handle);
331 
338  OOC_API HC_KEY GetSegmentKey (Env env, NodeHandle const & node_handle);
339 
349  OOC_API HC_KEY GetShellKey (Env env, NodeHandle const & node_handle);
350 
362 
363 
370  OOC_API void GetTranslate(Env env, double & x, double & y, double & z);
371 
378  OOC_API int Configure (char const * in, char * out);
379 
380 
381  namespace delta
382  {
384 
386  enum SyncResult {
388  };
389 
404  OOC_API SyncResult SynchronizeWith (Env, std::function<void(SyncToken const &)>);
405 
407  friend SyncResult SynchronizeWith (Env, std::function<void(SyncToken const &)>);
408 
409  private:
412 
413  PointCloudWorld & GetWorld () const;
414 
415  private:
416  void operator= (InternalSynchronizer const &);
417 
418  private:
419  PointCloudWorld & pcw;
420  };
421 
431  };
432 
441  OOC_API ModifyResult DeleteNode (SyncToken const & sync_token, NodeHandle const & node_handle);
442 
461  OOC_API ModifyResult DeleteSpecificPoints (SyncToken const & sync_token, NodeHandle const & node_handle, int32_t const point_indices[], size_t count);
462 
467  };
468 
471  public:
472  // Currently there are no config options.
473 
474  public:
475  bool operator== (OptimizeConfig const & other) const;
476  bool operator!= (OptimizeConfig const & other) const;
477  };
478 
479  OOC_API OptimizeResult OptimizeDeltas (SyncToken const & sync_token, OptimizeConfig const & config);
480 
488  friend SyncResult SynchronizeWith (Env, std::function<void(SyncToken const &)>);
489  friend ModifyResult DeleteNode (SyncToken const &, NodeHandle const &);
490  friend ModifyResult DeleteSpecificPoints (SyncToken const &, NodeHandle const &, int32_t const[], size_t);
491 
503  friend OptimizeResult OptimizeDeltas (SyncToken const & sync_token, OptimizeConfig const & config);
504 
505  public:
506  Env GetEnv () const;
507 
508  private:
509  SyncToken (Env env, PointCloudWorld & pcw);
510  PointCloudWorld & GetWorld () const;
511 
512  private:
513  SyncToken (SyncToken const &); // disable
514  SyncToken (SyncToken &&); // disable
515  void operator= (SyncToken const &); // disable
516  void operator= (SyncToken &&); // disable
517 
518 #ifndef SPRK_OOC
519  void operator& () const; // disable
520 #endif
521  private:
522  Env env;
523  PointCloudWorld & pcw;
524  };
525 
526 
527  // NOTE: Because std::function is in the API, this function must be defined in the header to avoid ABI problems.
528  inline OOC_API SyncResult SynchronizeWith (Env env, std::function<void(SyncToken const &)> func)
529  {
530  InternalSynchronizer synchronizer(env);
531  PointCloudWorld & pcw = synchronizer.GetWorld();
532  SyncToken const sync_token(env, pcw);
533  func(sync_token);
534  return SyncResult_Success;
535  }
536  }
537 
538 
539  namespace io
540  {
542  enum IOResult {
553  };
554 
571  OOC_API IOResult FileInputByKey (wchar_t const * file_name, HC_KEY segment_key, HInputHandlerOptions const & options);
572  OOC_API IOResult FileInputByKey (char * buffer, int buffer_size, wchar_t const * file_name, HC_KEY segment_key, HInputHandlerOptions const & options);
573 
602  OOC_API IOResult CommitDeltasToFile (Env env, H_UTF8 * out_generated_file_name = 0);
603  OOC_API IOResult CommitDeltasToFile (char * buffer, int buffer_size, Env env, H_UTF8 * out_generated_file_name = 0);
604 
608  OOC_API IOResult CommitDeltasToFile (Env env, H_UTF8 const & file_name);
609  OOC_API IOResult CommitDeltasToFile (char * buffer, int buffer_size, Env env, H_UTF8 const & file_name);
610 
620  OOC_API bool HasUncommittedDeltas (Env env);
621  }
622 
623 
624  namespace query
625  {
626 
627  class QueryIterator;
628 
630  enum Storage {
633  };
634 
636  class OOC_API Filter {
637  friend class QueryIterator;
638 
639  public:
640  Filter () {}
641  virtual ~Filter () {}
642 
647  virtual bool RejectPointsInMemory () = 0;
648 
653  virtual bool RejectPointsOnDisk () = 0;
654 
660  virtual bool RejectNode (NodeHandle const & node_handle) = 0;
661 
668  virtual bool RejectBounding (Point const & min_bound, Point const & max_bound) = 0;
669 
675  virtual bool AcceptPoint (Point const & point, size_t point_index) = 0;
676  };
677 
681  friend class QueryIterator;
682 
683  private:
684  QueryResult ();
685 
686  public:
691  NodeHandle const & GetNodeHandle () const;
692 
697  RGBColor const & GetNodePointColor () const;
698 
703  Point const & GetNodePoint () const;
704 
709  size_t GetNodePointIndex () const;
710 
715  Storage GetStorage () const;
716 
717  private:
718  NodeHandle node_handle;
719  RGBColor node_point_color;
720  Point node_point;
721  size_t node_point_index;
722  Storage storage;
723  };
724 
732  OOC_API QueryIterator QueryPoints (Env env, Filter & filter);
733 
740  OOC_API int PointCount (Env env, NodeHandle const & handle);
741 
744  friend QueryIterator QueryPoints (Env, Filter &);
745 
746  public:
747  enum Status {
755  };
756 
757  private:
758  QueryIterator (Filter & filter, Status status);
759  QueryIterator (Env env, Filter & filter, NodeHandle const & node_handle);
760 
761  public:
765  QueryIterator ();
766 
770  QueryIterator (QueryIterator && other);
771  ~QueryIterator ();
772 
777  QueryResult const & operator* () const;
778 
783  QueryResult const * operator-> () const;
784 
789  Status GetStatus () const;
790 
793  void Advance ();
794 
795  private:
796  void InvalidateWith (Status status);
797 
798  enum HookStatus {
799  HookStatus_Success_Hooked,
800  HookStatus_Success_Skipped,
801  HookStatus_Error_Unknown_Failure,
802  HookStatus_Error_File_System_Failure,
803  HookStatus_Error_Deserialization_Failure,
804  HookStatus_Error_Corrupt_Node,
805  };
806 
807  void Hook ();
808  HookStatus HookNode (NodeHandle const & node_handle, HC_KEY const node_segment_key);
809  HookStatus HookNodePoints (HC_KEY const node_segment_key);
810  HookStatus HookNodePointsAgainstShell (HC_KEY const node_shell_key);
811  HookStatus HookNodePointsAgainstDisk (HC_KEY const node_segment_key);
812 
813  private:
814  QueryIterator (QueryIterator const &); // disable
815  void operator= (QueryIterator const &); // disable
816  void operator= (QueryIterator &&); // disable
817 
818  private:
819  void * typeless_pending_node_keys;
820  void * typeless_point_buffer;
821  void * typeless_color_buffer;
822  size_t point_buffer_idx;
823  Filter & filter;
824  Env const env;
825  QueryResult query_result;
826  Status status;
827  };
828  }
829 
830 
831  namespace preprocess
832  {
833 
841  };
842 
843 
845  public:
846 #ifndef SPRK_OOC
847  Preprocessor (wchar_t const * output_file_name);
848  ~Preprocessor ();
849 
850  PreprocessStatus Run ();
851 
852  void SetLogFile (wchar_t const * log_file);
853  void AddPointCloudFile (wchar_t const * point_cloud_file);
854  void SetMaxShellSize (int shell_size);
855  void SetMaxMemoryUsage (size_t max_memory_usage);
856  void SetSubSamplePercentage (double percentage);
857  void SetCullingBoundingBox (Point const & min, Point const & max);
858  void OverwriteExistingFiles (bool overwrite);
859  void SetDoublePrecision (bool doubled);
860  void SetUseLASZIP (bool doubled);
861 
862  private:
863  void * opaque_point_cloud;
864 #endif
865  };
866 
867  }
868 
869 
870 }
871 
Definition: PointCloudAPI.h:552
Definition: PointCloudAPI.h:423
Definition: PointCloudAPI.h:545
float r
Definition: PointCloudAPI.h:104
OOC_API bool GetEnv(HC_KEY ooc_root, Env &out_env)
OOC_API QueryIterator QueryPoints(Env env, Filter &filter)
float b
Definition: PointCloudAPI.h:106
Definition: PointCloudAPI.h:387
Definition: PointCloudAPI.h:543
PreprocessStatus
Definition: PointCloudAPI.h:834
OOC_API ModifyResult DeleteSpecificPoints(SyncToken const &sync_token, NodeHandle const &node_handle, int32_t const point_indices[], size_t count)
OOC_API int Configure(char const *in, char *out)
Definition: PointCloudAPI.h:406
OOC_API bool PollNodesLoadingOrHaveBeenLoaded(Env env)
Status
Definition: PointCloudAPI.h:747
float g
Definition: PointCloudAPI.h:105
Definition: PointCloudAPI.h:40
Point(float x, float y, float z)
Definition: PointCloudAPI.h:126
virtual ~Filter()
Definition: PointCloudAPI.h:641
Definition: PointCloudAPI.h:835
OOC_API size_t GetEnvCount(HC_KEY ooc_root)
OOC_API HC_KEY GetShellKey(Env env, NodeHandle const &node_handle)
OOC_API bool IsRoot(HC_KEY ooc_root)
OOC_API ModifyResult DeleteNode(SyncToken const &sync_token, NodeHandle const &node_handle)
SyncResult
Definition: PointCloudAPI.h:386
OOC_API void Destroy(Env env)
float x
Definition: PointCloudAPI.h:169
Filter()
Definition: PointCloudAPI.h:640
Definition: PointCloudAPI.h:743
Definition: PointCloudAPI.h:424
Definition: PointCloudAPI.h:544
Definition: PointCloudAPI.h:82
OOC_API SyncResult SynchronizeWith(Env, std::function< void(SyncToken const &)>)
Definition: PointCloudAPI.h:528
Definition: PointCloudAPI.h:176
OOC_API HC_KEY GetRoot(Env env)
Definition: PointCloudAPI.h:632
Definition: PointCloudAPI.h:487
OptimizeResult
Definition: PointCloudAPI.h:464
Definition: PointCloudAPI.h:748
float z
Definition: PointCloudAPI.h:171
Definition: PointCloudAPI.h:680
Storage
Definition: PointCloudAPI.h:630
Definition: PointCloudAPI.h:470
OOC_API IOResult FileInputByKey(wchar_t const *file_name, HC_KEY segment_key, HInputHandlerOptions const &options)
OOC_API size_t GetEnvs(HC_KEY ooc_root, Env *out_envs, size_t count)
Definition: PointCloudAPI.h:844
OOC_API void GetTranslate(Env env, double &x, double &y, double &z)
OOC_API OptimizeResult OptimizeDeltas(SyncToken const &sync_token, OptimizeConfig const &config)
NodeHandle()
Definition: PointCloudAPI.h:185
OOC_API HC_KEY GetSegmentKey(Env env, NodeHandle const &node_handle)
OOC_API bool GetNodeHandle(Env env, HC_KEY node_segment_key, NodeHandle &out_node_handle)
OOC_API void Release(Env env)
class OOC_API SyncToken
Definition: PointCloudAPI.h:383
Definition: PointCloudAPI.h:62
Definition: PointCloudAPI.h:631
Definition: PointCloudAPI.h:547
Point()
Definition: PointCloudAPI.h:114
float y
Definition: PointCloudAPI.h:170
Definition: PointCloudAPI.h:549
RGBColor()
Definition: PointCloudAPI.h:85
Definition: PointCloudAPI.h:749
bool IsValid() const
Definition: PointCloudAPI.h:99
IOResult
Definition: PointCloudAPI.h:542
Definition: PointCloudAPI.h:429
RGBColor(float r, float g, float b)
Definition: PointCloudAPI.h:92
Definition: PointCloudAPI.h:111
OOC_API IOResult CommitDeltasToFile(Env env, H_UTF8 *out_generated_file_name=0)
#define OOC_API
Definition: PointCloudAPI.h:24
OOC_API bool HasUncommittedDeltas(Env env)
Definition: PointCloudAPI.h:550
OOC_API int PointCount(Env env, NodeHandle const &handle)
Definition: PointCloudAPI.h:636
ModifyResult
Definition: PointCloudAPI.h:422
Definition: PointCloudAPI.h:465