6 #ifndef COGS_POINT_CLOUD_H 7 #define COGS_POINT_CLOUD_H 10 #include <unordered_map> 14 #include <glm/glm.hpp> 15 #include <Utils/GeometryStructures.h> 16 #include <Utils/SpaceAndUnits.h> 18 #include <COGS/DataType.h> 19 #include <COGS/PointCloudProperty.h> 64 virtual
bool Import(const std::
string &filename);
66 virtual
bool Export(const std::
string &filename) const;
69 virtual
bool Resize(uint32_t new_size);
71 [[nodiscard]] virtual uint32_t GetSize() const;
73 virtual
void Reserve(uint32_t new_capacity);
75 [[nodiscard]] uint32_t GetCapacity() const;
77 virtual
void ShrinkToFit();
96 virtual
bool Erase(std::vector<uint32_t> indices_to_erase, std::vector<
int> *replacement_map =
nullptr);
113 virtual
bool Erase(const
PointNormalPredicate &Predicate, std::vector<
int> *replacement_map =
nullptr);
131 [[nodiscard]] glm::vec3 *GetPositions();
139 [[nodiscard]] const glm::vec3 *GetPositions() const;
147 [[nodiscard]]
bool HasNormals() const;
155 [[nodiscard]] glm::vec3 *GetNormals();
163 [[nodiscard]] const glm::vec3 *GetNormals() const;
179 [[nodiscard]]
bool HasColors() const;
187 [[nodiscard]] struct
Color3f *GetColors();
195 [[nodiscard]] const struct
Color3f *GetColors() const;
211 [[nodiscard]]
bool HasIntensities() const;
219 [[nodiscard]]
float *GetIntensities();
227 [[nodiscard]] const
float *GetIntensities() const;
282 template <typename T> [[nodiscard]] const T *GetData(const
PointCloudProperty::Key &key) const;
290 const glm::mat4 &transformation,
291 const std::optional<utils::SpaceDefinition> &resulting_space = std::nullopt);
294 bool HasSpace() const;
296 const std::optional<utils::SpaceDefinition> &GetSpace() const;
298 std::
string GetSpaceId() const;
300 void SetSpace(const std::optional<utils::SpaceDefinition> &new_space);
302 bool TransformToSpace(const utils::SpaceDefinition &new_space);
317 virtual void ExecuteCopyCommands(
const std::vector<CopyCommand> ©_info);
319 virtual void TruncateSize(
size_t delta_size);
328 Chunk(uint32_t first, uint32_t last);
330 [[nodiscard]]
bool IsValid()
const;
332 [[nodiscard]] uint32_t GetSize()
const;
337 std::vector<PointCloudProperty> properties_;
338 std::unordered_map<PointCloudProperty::Key, size_t> property_map_;
339 std::optional<utils::SpaceDefinition> space_definition_;
344 const std::variant<DataType, size_t> type_or_size);
346 [[nodiscard]] std::vector<Chunk> IndicesToChunks(
const std::vector<uint32_t> &indices)
const;
348 [[nodiscard]] std::vector<CopyCommand> CreateEraseCopyCommands(std::vector<Chunk> chunks_to_erases)
const;
353 template <
typename T>
356 return reinterpret_cast<const T *
>(GetVoidData(key));
359 template <
typename T>
362 return reinterpret_cast<T *
>(GetVoidData(key));
365 [[nodiscard]] COGS_API geom::Aabb3 GetPointCloudAabb(
const PointCloud &cloud);
366 COGS_API
void ErasePointsOutsideAabb(
const geom::Aabb3 &aabb,
PointCloud &cloud);
static const cogs::PointCloudProperty::Key INTENSITIES
Common identifier for point intensities.
Definition: PointCloud.h:47
Namespace of "Computer Graphic Structures" library, which implement many core classes and structures...
Definition: AabbHierarchy.h:8
A command for copying points.
Definition: PointCloud.h:307
Holds three color channels in float format in range 0-1.
Definition: Color.h:57
uint32_t length
Number of sequential points to copy.
Definition: PointCloud.h:311
Management class for a set of data points in a 3D space.
Definition: PointCloud.h:32
std::function< bool(const glm::vec3 &, const glm::vec3 &)> PointNormalPredicate
A predicate over points and normals. A function that returns true or false.
Definition: PointCloud.h:36
uint32_t target
Index of the first point that should be replaced.
Definition: PointCloud.h:310
uint32_t source
Index of the first point that should be copied.
Definition: PointCloud.h:309
static const cogs::PointCloudProperty::Key POSITIONS
Common identifier for point positions.
Definition: PointCloud.h:39
static const cogs::PointCloudProperty::Key UVS
Common identifier for point texture coordinates.
Definition: PointCloud.h:45
Type used to store information about property.
Definition: PointCloudProperty.h:14
static const cogs::PointCloudProperty::Key COLORS
Common identifier for point colors.
Definition: PointCloud.h:43
std::string Key
Type used to identify cloud property record.
Definition: PointCloudProperty.h:17
T * GetData(const PointCloudProperty::Key &key)
When property exists, returns the pointer to data of a template type, nullptr otherwise.
Definition: PointCloud.h:360
DataType
Identifier of data types.
Definition: DataType.h:11
static const cogs::PointCloudProperty::Key NORMALS
Common identifier for point normals.
Definition: PointCloud.h:41