Introduction

Getting Started

Programming Guides

API Reference

Additional Resources

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 
265  OOC_API bool GetEnv (HC_KEY ooc_root, Env & out_env);
266 
272  OOC_API HC_KEY GetRoot (Env env);
273 
284  OOC_API void Destroy (Env env);
285 
298  OOC_API void Release (Env env);
299 
309  OOC_API bool GetNodeHandle (Env env, HC_KEY node_segment_key, NodeHandle & out_node_handle);
310 
317  OOC_API HC_KEY GetSegmentKey (Env env, NodeHandle const & node_handle);
318 
328  OOC_API HC_KEY GetShellKey (Env env, NodeHandle const & node_handle);
329 
341 
348  OOC_API int Configure (char const * in, char * out);
349 
350 
351  namespace delta
352  {
354 
356  enum SyncResult {
358  };
359 
374  OOC_API SyncResult SynchronizeWith (Env, std::function<void(SyncToken const &)>);
375 
377  friend SyncResult SynchronizeWith (Env, std::function<void(SyncToken const &)>);
378 
379  private:
382 
383  PointCloudWorld & GetWorld () const;
384 
385  private:
386  void operator= (InternalSynchronizer const &);
387 
388  private:
389  PointCloudWorld & pcw;
390  };
391 
401  };
402 
411  OOC_API ModifyResult DeleteNode (SyncToken const & sync_token, NodeHandle const & node_handle);
412 
431  OOC_API ModifyResult DeleteSpecificPoints (SyncToken const & sync_token, NodeHandle const & node_handle, int32_t const point_indices[], size_t count);
432 
437  };
438 
441  public:
442  // Currently there are no config options.
443 
444  public:
445  bool operator== (OptimizeConfig const & other) const;
446  bool operator!= (OptimizeConfig const & other) const;
447  };
448 
449  OOC_API OptimizeResult OptimizeDeltas (SyncToken const & sync_token, OptimizeConfig const & config);
450 
458  friend SyncResult SynchronizeWith (Env, std::function<void(SyncToken const &)>);
459  friend ModifyResult DeleteNode (SyncToken const &, NodeHandle const &);
460  friend ModifyResult DeleteSpecificPoints (SyncToken const &, NodeHandle const &, int32_t const[], size_t);
461 
473  friend OptimizeResult OptimizeDeltas (SyncToken const & sync_token, OptimizeConfig const & config);
474 
475  public:
476  Env GetEnv () const;
477 
478  private:
479  SyncToken (Env env, PointCloudWorld & pcw);
480  PointCloudWorld & GetWorld () const;
481 
482  private:
483  SyncToken (SyncToken const &); // disable
484  SyncToken (SyncToken &&); // disable
485  void operator= (SyncToken const &); // disable
486  void operator= (SyncToken &&); // disable
487 
488 #ifndef SPRK_OOC
489  void operator& () const; // disable
490 #endif
491  private:
492  Env env;
493  PointCloudWorld & pcw;
494  };
495 
496 
497  // NOTE: Because std::function is in the API, this function must be defined in the header to avoid ABI problems.
498  inline OOC_API SyncResult SynchronizeWith (Env env, std::function<void(SyncToken const &)> func)
499  {
500  InternalSynchronizer synchronizer(env);
501  PointCloudWorld & pcw = synchronizer.GetWorld();
502  SyncToken const sync_token(env, pcw);
503  func(sync_token);
504  return SyncResult_Success;
505  }
506  }
507 
508 
509  namespace io
510  {
512  enum IOResult {
523  };
524 
541  OOC_API IOResult FileInputByKey (wchar_t const * file_name, HC_KEY segment_key, HInputHandlerOptions const & options);
542  OOC_API IOResult FileInputByKey (char * buffer, int buffer_size, wchar_t const * file_name, HC_KEY segment_key, HInputHandlerOptions const & options);
543 
572  OOC_API IOResult CommitDeltasToFile (Env env, H_UTF8 * out_generated_file_name = 0);
573  OOC_API IOResult CommitDeltasToFile (char * buffer, int buffer_size, Env env, H_UTF8 * out_generated_file_name = 0);
574 
578  OOC_API IOResult CommitDeltasToFile (Env env, H_UTF8 const & file_name);
579  OOC_API IOResult CommitDeltasToFile (char * buffer, int buffer_size, Env env, H_UTF8 const & file_name);
580 
590  OOC_API bool HasUncommittedDeltas (Env env);
591  }
592 
593 
594  namespace query
595  {
596 
597  class QueryIterator;
598 
600  enum Storage {
603  };
604 
606  class OOC_API Filter {
607  friend class QueryIterator;
608 
609  public:
610  Filter () {}
611  virtual ~Filter () {}
612 
617  virtual bool RejectPointsInMemory () = 0;
618 
623  virtual bool RejectPointsOnDisk () = 0;
624 
630  virtual bool RejectNode (NodeHandle const & node_handle) = 0;
631 
638  virtual bool RejectBounding (Point const & min_bound, Point const & max_bound) = 0;
639 
645  virtual bool AcceptPoint (Point const & point, size_t point_index) = 0;
646  };
647 
651  friend class QueryIterator;
652 
653  private:
654  QueryResult ();
655 
656  public:
661  NodeHandle const & GetNodeHandle () const;
662 
667  RGBColor const & GetNodePointColor () const;
668 
673  Point const & GetNodePoint () const;
674 
679  size_t GetNodePointIndex () const;
680 
685  Storage GetStorage () const;
686 
687  private:
688  NodeHandle node_handle;
689  RGBColor node_point_color;
690  Point node_point;
691  size_t node_point_index;
692  Storage storage;
693  };
694 
702  OOC_API QueryIterator QueryPoints (Env env, Filter & filter);
703 
710  OOC_API int PointCount (Env env, NodeHandle const & handle);
711 
714  friend QueryIterator QueryPoints (Env, Filter &);
715 
716  public:
717  enum Status {
725  };
726 
727  private:
728  QueryIterator (Filter & filter, Status status);
729  QueryIterator (Env env, Filter & filter, NodeHandle const & node_handle);
730 
731  public:
735  QueryIterator ();
736 
740  QueryIterator (QueryIterator && other);
741  ~QueryIterator ();
742 
747  QueryResult const & operator* () const;
748 
753  QueryResult const * operator-> () const;
754 
759  Status GetStatus () const;
760 
763  void Advance ();
764 
765  private:
766  void InvalidateWith (Status status);
767 
768  enum HookStatus {
769  HookStatus_Success_Hooked,
770  HookStatus_Success_Skipped,
771  HookStatus_Error_Unknown_Failure,
772  HookStatus_Error_File_System_Failure,
773  HookStatus_Error_Deserialization_Failure,
774  HookStatus_Error_Corrupt_Node,
775  };
776 
777  void Hook ();
778  HookStatus HookNode (NodeHandle const & node_handle, HC_KEY const node_segment_key);
779  HookStatus HookNodePoints (HC_KEY const node_segment_key);
780  HookStatus HookNodePointsAgainstShell (HC_KEY const node_shell_key);
781  HookStatus HookNodePointsAgainstDisk (HC_KEY const node_segment_key);
782 
783  private:
784  QueryIterator (QueryIterator const &); // disable
785  void operator= (QueryIterator const &); // disable
786  void operator= (QueryIterator &&); // disable
787 
788  private:
789  void * typeless_pending_node_keys;
790  void * typeless_point_buffer;
791  void * typeless_color_buffer;
792  size_t point_buffer_idx;
793  Filter & filter;
794  Env const env;
795  QueryResult query_result;
796  Status status;
797  };
798  }
799 
800 
801  namespace preprocess
802  {
803 
811  };
812 
813 
815  public:
816 #ifndef SPRK_OOC
817  Preprocessor (wchar_t const * output_file_name);
818  ~Preprocessor ();
819 
820  PreprocessStatus Run ();
821 
822  void SetLogFile (wchar_t const * log_file);
823  void AddPointCloudFile (wchar_t const * point_cloud_file);
824  void SetMaxShellSize (int shell_size);
825  void SetMaxMemoryUsage (size_t max_memory_usage);
826  void SetSubSamplePercentage (double percentage);
827  void SetCullingBoundingBox (Point const & min, Point const & max);
828  void OverwriteExistingFiles (bool overwrite);
829  void SetDoublePrecision (bool doubled);
830  void SetUseLASZIP (bool doubled);
831 
832  private:
833  void * opaque_point_cloud;
834 #endif
835  };
836 
837  }
838 
839 
840 }
841 
Definition: PointCloudAPI.h:522
Definition: PointCloudAPI.h:393
Definition: PointCloudAPI.h:515
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:357
Definition: PointCloudAPI.h:513
PreprocessStatus
Definition: PointCloudAPI.h:804
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:376
OOC_API bool PollNodesLoadingOrHaveBeenLoaded(Env env)
Status
Definition: PointCloudAPI.h:717
float g
Definition: PointCloudAPI.h:105
Point(float x, float y, float z)
Definition: PointCloudAPI.h:126
virtual ~Filter()
Definition: PointCloudAPI.h:611
Definition: PointCloudAPI.h:805
OOC_API HC_KEY GetShellKey(Env env, NodeHandle const &node_handle)
#define HC_KEY
OOC_API bool IsRoot(HC_KEY ooc_root)
OOC_API ModifyResult DeleteNode(SyncToken const &sync_token, NodeHandle const &node_handle)
SyncResult
Definition: PointCloudAPI.h:356
OOC_API void Destroy(Env env)
float x
Definition: PointCloudAPI.h:169
Filter()
Definition: PointCloudAPI.h:610
Definition: PointCloudAPI.h:713
Definition: PointCloudAPI.h:394
Definition: PointCloudAPI.h:514
Definition: PointCloudAPI.h:82
OOC_API SyncResult SynchronizeWith(Env, std::function< void(SyncToken const &)>)
Definition: PointCloudAPI.h:498
Definition: PointCloudAPI.h:176
OOC_API HC_KEY GetRoot(Env env)
Definition: PointCloudAPI.h:602
Definition: PointCloudAPI.h:457
OptimizeResult
Definition: PointCloudAPI.h:434
Definition: PointCloudAPI.h:718
float z
Definition: PointCloudAPI.h:171
Definition: PointCloudAPI.h:650
Storage
Definition: PointCloudAPI.h:600
Definition: PointCloudAPI.h:440
OOC_API IOResult FileInputByKey(wchar_t const *file_name, HC_KEY segment_key, HInputHandlerOptions const &options)
Definition: PointCloudAPI.h:814
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:353
Definition: PointCloudAPI.h:62
bool IsValid() const
Definition: PointCloudAPI.h:99
Definition: PointCloudAPI.h:601
Definition: PointCloudAPI.h:517
Point()
Definition: PointCloudAPI.h:114
float y
Definition: PointCloudAPI.h:170
Definition: PointCloudAPI.h:519
RGBColor()
Definition: PointCloudAPI.h:85
Definition: PointCloudAPI.h:719
IOResult
Definition: PointCloudAPI.h:512
Definition: PointCloudAPI.h:399
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:520
OOC_API int PointCount(Env env, NodeHandle const &handle)
Definition: PointCloudAPI.h:606
ModifyResult
Definition: PointCloudAPI.h:392
Definition: PointCloudAPI.h:435