ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvGenericPrimitive.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 "ecvMesh.h"
12 
13 class ccPointCloud;
14 
17 public:
19 
26  ccGenericPrimitive(QString name = QString(),
27  const ccGLMatrix* transMat = nullptr);
28 
30  virtual QString getTypeName() const = 0;
31 
33  virtual ccGenericPrimitive* clone() const = 0;
34 
36  inline CV_CLASS_ENUM getClassID() const override {
37  return CV_TYPES::PRIMITIVE;
38  }
39 
41 
43  virtual void setColor(const ecvColor::Rgb& col);
44 
46 
50 
52  virtual inline bool hasDrawingPrecision() const { return false; }
53 
55 
57  static const int MIN_DRAWING_PRECISION = 4;
58 
60 
69  virtual bool setDrawingPrecision(unsigned steps);
70 
72  virtual inline unsigned getDrawingPrecision() const {
73  return m_drawPrecision;
74  }
75 
77  virtual inline ccGLMatrix& getTransformation() { return m_transformation; }
78 
81  virtual inline const ccGLMatrix& getTransformation() const {
82  return m_transformation;
83  }
84 
86  const ccGLMatrix& getGLTransformationHistory() const override;
87 
88  virtual void clearDrawings();
90 
91 protected:
93  void applyGLTransformation(const ccGLMatrix& trans) override;
94 
95  // inherited from ccMesh
96  bool toFile_MeOnly(QFile& out, short dataVersion) const override;
97  short minimumFileVersion_MeOnly() const override;
98  bool fromFile_MeOnly(QFile& in,
99  short dataVersion,
100  int flags,
101  LoadedIDMap& oldToNewIDMap) override;
102 
104 
107  virtual bool buildUp() = 0;
108 
110 
113  virtual bool updateRepresentation();
114 
116 
118  bool init(unsigned vertCount,
119  bool vertNormals,
120  unsigned faceCount,
121  unsigned faceNormCount);
122 
124 
127 
129 
133 
136 
138 
141 
143  unsigned m_drawPrecision;
144 };
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
std::string name
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
Generic primitive interface.
void applyTransformationToVertices()
Applies associated transformation to vertices.
bool init(unsigned vertCount, bool vertNormals, unsigned faceCount, unsigned faceNormCount)
Inits internal structures.
ccPointCloud * vertices()
Returns vertices.
virtual bool updateRepresentation()
Updates internal representation (as a mesh)
virtual QString getTypeName() const =0
Returns type name (sphere, cylinder, etc.)
virtual void clearDrawings()
virtual bool setDrawingPrecision(unsigned steps)
Sets drawing precision.
virtual void setColor(const ecvColor::Rgb &col)
Sets primitive color (shortcut)
unsigned m_drawPrecision
Drawing precision (for primitives that support this feature)
virtual void hideShowDrawings(CC_DRAW_CONTEXT &context)
virtual unsigned getDrawingPrecision() const
Returns drawing precision (or 0 if feature is not supported)
virtual bool hasDrawingPrecision() const
Whether drawing is dependent on 'precision' parameter.
void applyGLTransformation(const ccGLMatrix &trans) override
Inherited from ccGenericMesh.
CV_CLASS_ENUM getClassID() const override
Returns class ID.
virtual const ccGLMatrix & getTransformation() const
ccGenericPrimitive(QString name=QString(), const ccGLMatrix *transMat=nullptr)
Default constructor.
virtual ccGenericPrimitive * clone() const =0
Clones primitive.
ccGenericPrimitive * finishCloneJob(ccGenericPrimitive *primitive) const
Finished 'clone' job (vertices color, etc.)
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
virtual bool buildUp()=0
Builds primitive.
const ccGLMatrix & getGLTransformationHistory() const override
inherited methods (ccHObject)
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
const ccGenericPrimitive & operator+=(const ccGenericPrimitive &prim)
Add operator.
ccGLMatrix m_transformation
Associated transformation (applied to vertices)
short minimumFileVersion_MeOnly() const override
virtual ccGLMatrix & getTransformation()
Returns the transformation that is currently applied to the vertices.
Triangular mesh.
Definition: ecvMesh.h:35
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
RGB color structure.
Definition: ecvColorTypes.h:49
ImGuiContext * context
Definition: Window.cpp:76
@ PRIMITIVE
Definition: CVTypes.h:119
Display context.