ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvAdvancedTypes.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // Local
11 #include "ecvArray.h"
12 #include "ecvBasicTypes.h"
13 #include "ecvColorTypes.h"
14 #include "ecvNormalCompressor.h"
15 
16 /***************************************************
17  Advanced CLOUDVIEWER types (containers)
18 ***************************************************/
19 
22  : public ccArray<CompressedNormType, 1, CompressedNormType> {
23 public:
26  ~NormsIndexesTableType() override = default;
27 
28  // inherited from ccArray/ccHObject
29  CV_CLASS_ENUM getClassID() const override {
31  }
32 
35  NormsIndexesTableType* cloneArray = new NormsIndexesTableType();
36  if (!copy(*cloneArray)) {
38  "[NormsIndexesTableType::clone] Failed to clone array (not "
39  "enough memory)");
40  cloneArray->release();
41  return nullptr;
42  }
43  cloneArray->setName(getName());
44  return cloneArray;
45  }
46 
47  // inherited from ccHObject/ccArray
49  short dataVersion,
50  int flags,
51  LoadedIDMap& oldToNewIDMap) override;
52 };
53 
55 class NormsTableType : public ccArray<CCVector3, 3, PointCoordinateType> {
56 public:
59  virtual ~NormsTableType() = default;
60 
61  // inherited from ccArray/ccHObject
62  CV_CLASS_ENUM getClassID() const override {
64  }
65 
67  NormsTableType* clone() override {
68  NormsTableType* cloneArray = new NormsTableType();
69  if (!copy(*cloneArray)) {
71  "[NormsTableType::clone] Failed to clone array (not enough "
72  "memory)");
73  cloneArray->release();
74  return nullptr;
75  }
76  cloneArray->setName(getName());
77  return cloneArray;
78  }
79 };
80 
82 class ColorsTableType : public ccArray<ecvColor::Rgb, 3, ColorCompType> {
83 public:
86  : ccArray<ecvColor::Rgb, 3, ColorCompType>("RGB colors") {}
87  virtual ~ColorsTableType() = default;
88 
89  // inherited from ccArray/ccHObject
90  CV_CLASS_ENUM getClassID() const override {
92  }
93 
95  ColorsTableType* clone() override {
96  ColorsTableType* cloneArray = new ColorsTableType();
97  if (!copy(*cloneArray)) {
99  "[ColorsTableType::clone] Failed to clone array (not "
100  "enough memory)");
101  cloneArray->release();
102  return nullptr;
103  }
104  cloneArray->setName(getName());
105  return cloneArray;
106  }
107 };
108 
110 class RGBAColorsTableType : public ccArray<ecvColor::Rgba, 4, ColorCompType> {
111 public:
114  : ccArray<ecvColor::Rgba, 4, ColorCompType>("RGBA colors") {}
115  virtual ~RGBAColorsTableType() = default;
116 
117  // inherited from ccArray/ccHObject
118  CV_CLASS_ENUM getClassID() const override {
120  }
121 
124  RGBAColorsTableType* cloneArray = new RGBAColorsTableType();
125  if (!copy(*cloneArray)) {
127  "[RGBAColorsTableType::clone] Failed to clone array (not "
128  "enough memory)");
129  cloneArray->release();
130  return nullptr;
131  }
132  cloneArray->setName(getName());
133  return cloneArray;
134  }
135 };
136 
138 struct TexCoords2D {
139  TexCoords2D() : tx(-1.0f), ty(-1.0f) {}
140  TexCoords2D(float x, float y) : tx(x), ty(y) {}
141 
142  union {
143  struct {
144  float tx, ty;
145  };
146  float t[2];
147  };
148 };
149 
151 class TextureCoordsContainer : public ccArray<TexCoords2D, 2, float> {
152 public:
155  : ccArray<TexCoords2D, 2, float>("Texture coordinates") {}
156  virtual ~TextureCoordsContainer() = default;
157 
158  // inherited from ccArray/ccHObject
159  CV_CLASS_ENUM getClassID() const override {
161  }
162 
166  if (!copy(*cloneArray)) {
168  "[TextureCoordsContainer::clone] Failed to clone array "
169  "(not enough memory)");
170  cloneArray->release();
171  return nullptr;
172  }
173  cloneArray->setName(getName());
174  return cloneArray;
175  }
176 };
float PointCoordinateType
Type of the coordinates of a (N-D) point.
Definition: CVTypes.h:16
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
Definition: CVTypes.h:97
#define CV_DB_LIB_API
Definition: CV_db.h:15
virtual void release()
Decrease counter and deletes object when 0.
Definition: CVShareable.cpp:35
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
Array of RGB colors for each point.
ColorsTableType()
Default constructor.
CV_CLASS_ENUM getClassID() const override
Returns class ID.
ColorsTableType * clone() override
Duplicates array (overloaded from ccArray::clone)
virtual ~ColorsTableType()=default
Array of compressed 3D normals (single index)
NormsIndexesTableType * clone() override
Duplicates array (overloaded from ccArray::clone)
CV_CLASS_ENUM getClassID() const override
Returns class ID.
~NormsIndexesTableType() override=default
NormsIndexesTableType()
Default constructor.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
Array of (uncompressed) 3D normals (Nx,Ny,Nz)
NormsTableType * clone() override
Duplicates array (overloaded from ccArray::clone)
NormsTableType()
Default constructor.
virtual ~NormsTableType()=default
CV_CLASS_ENUM getClassID() const override
Returns class ID.
Array of RGBA colors for each point.
CV_CLASS_ENUM getClassID() const override
Returns class ID.
RGBAColorsTableType * clone() override
Duplicates array (overloaded from ccArray::clone)
RGBAColorsTableType()
Default constructor.
virtual ~RGBAColorsTableType()=default
Array of 2D texture coordinates.
virtual ~TextureCoordsContainer()=default
TextureCoordsContainer()
Default constructor.
TextureCoordsContainer * clone() override
Duplicates array (overloaded from ccArray::clone)
CV_CLASS_ENUM getClassID() const override
Returns class ID.
Shareable array that can be properly inserted in the DB tree.
Definition: ecvArray.h:21
bool copy(Base &dest) const
Copies the content of this array in another one.
Definition: ecvArray.h:43
virtual QString getName() const
Returns object name.
Definition: ecvObject.h:72
virtual void setName(const QString &name)
Sets object name.
Definition: ecvObject.h:75
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
unsigned char ColorCompType
Default color components type (R,G and B)
Definition: ecvColorTypes.h:29
@ NORMAL_INDEXES_ARRAY
Definition: CVTypes.h:135
@ RGB_COLOR_ARRAY
Definition: CVTypes.h:137
@ RGBA_COLOR_ARRAY
Definition: CVTypes.h:138
@ TEX_COORDS_ARRAY
Definition: CVTypes.h:139
@ NORMALS_ARRAY
Definition: CVTypes.h:134
Colors namespace.
Definition: ecvColorTypes.h:32
RgbTpl< ColorCompType > Rgb
3 components, default type
RgbaTpl< ColorCompType > Rgba
4 components, default type
2D texture coordinates
TexCoords2D(float x, float y)