ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvMeshGroup.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 "ecvGenericMesh.h"
12 
15 
19 public:
21  ccMeshGroup() : ccGenericMesh("[Deprecated] Mesh Group") {}
22 
24  CV_CLASS_ENUM getClassID() const override { return CV_TYPES::MESH_GROUP; }
25 
26  // inherited methods (ccGenericMesh)
27  ccGenericPointCloud* getAssociatedCloud() const override { return 0; }
28  void refreshBB() override {}
29  bool interpolateNormals(unsigned triIndex,
30  const CCVector3& P,
31  CCVector3& N) override {
32  return false;
33  }
34  bool interpolateNormalsBC(unsigned triIndex,
35  const CCVector3d& w,
36  CCVector3& N) override {
37  return false;
38  }
39  bool interpolateColors(unsigned triIndex,
40  const CCVector3& P,
41  ecvColor::Rgb& rgb) override {
42  return false;
43  }
44  bool getColorFromMaterial(unsigned triIndex,
45  const CCVector3& P,
46  ecvColor::Rgb& rgb,
47  bool interpolateColorIfNoTexture) override {
48  return false;
49  }
50  bool getVertexColorFromMaterial(unsigned triIndex,
51  unsigned char vertIndex,
52  ecvColor::Rgb& rgb,
53  bool returnColorIfNoTexture) override {
54  return false;
55  }
56  bool hasMaterials() const override { return false; }
57  const ccMaterialSet* getMaterialSet() const override { return 0; }
58  int getTriangleMtlIndex(unsigned triangleIndex) const override {
59  return -1;
60  }
61  bool hasTextures() const override { return false; }
63  return 0;
64  }
65  void getTexCoordinates(unsigned index, TexCoords2D*& tx) const {}
66  void getTriangleTexCoordinates(unsigned triIndex,
67  TexCoords2D*& tx1,
68  TexCoords2D*& tx2,
69  TexCoords2D*& tx3) const override {
70  tx1 = tx2 = tx3 = nullptr;
71  }
72  bool hasPerTriangleTexCoordIndexes() const override { return false; }
73  void getTriangleTexCoordinatesIndexes(unsigned triangleIndex,
74  int& i1,
75  int& i2,
76  int& i3) const override {
77  i1 = i2 = i3 = -1;
78  }
79  bool hasTriNormals() const override { return false; }
80  void getTriangleNormalIndexes(unsigned triangleIndex,
81  int& i1,
82  int& i2,
83  int& i3) const override {
84  i1 = i2 = i3 = -1;
85  }
86  bool getTriangleNormals(unsigned triangleIndex,
87  CCVector3& Na,
88  CCVector3& Nb,
89  CCVector3& Nc) const override {
90  return false;
91  }
92  NormsIndexesTableType* getTriNormsTable() const override { return 0; }
93  unsigned capacity() const override { return 0; }
95  const CCVector2d& clickPos,
96  const ccGLCameraParameters& camera,
97  int& nearestTriIndex,
98  double& nearestSquareDist,
99  CCVector3d& nearestPoint,
100  CCVector3d* barycentricCoords = nullptr) const override {
101  return false;
102  }
103 
104  // inherited methods (ccHObject)
105  virtual bool isSerializable() const override { return true; }
106  bool toFile_MeOnly(QFile& out, short dataVersion) const override;
107  short minimumFileVersion_MeOnly() const override;
108  bool fromFile_MeOnly(QFile& in,
109  short dataVersion,
110  int flags,
111  LoadedIDMap& oldToNewIDMap) override;
112 
113  // inherited methods (GenericIndexedMesh)
114  virtual unsigned size() const override { return 0; }
115  virtual void forEach(genericTriangleAction action) override {}
116  virtual void placeIteratorAtBeginning() override {}
118  return 0;
119  }
121  unsigned index) override {
122  return 0;
123  }
125  override {
126  return 0;
127  }
129  unsigned triangleIndex) override {
130  return 0;
131  }
132  virtual void getTriangleVertices(unsigned triangleIndex,
133  CCVector3& A,
134  CCVector3& B,
135  CCVector3& C) const override {}
136  virtual void getTriangleVertices(unsigned triangleIndex,
137  double A[3],
138  double B[3],
139  double C[3]) const override {}
140  virtual void getBoundingBox(CCVector3& bbMin, CCVector3& bbMax) override {}
141 
142 protected:
143  // inherited from ccHObject
144  virtual void drawMeOnly(CC_DRAW_CONTEXT& context) override;
145 };
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
Array of compressed 3D normals (single index)
Array of 2D texture coordinates.
Generic mesh interface.
A 3D cloud interface with associated features (color, normals, octree, etc.)
Mesh (triangle) material.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
virtual void forEach(genericTriangleAction action) override
Fast iteration mechanism.
Definition: ecvMeshGroup.h:115
ccGenericPointCloud * getAssociatedCloud() const override
Returns the vertices cloud.
Definition: ecvMeshGroup.h:27
void getTriangleTexCoordinates(unsigned triIndex, TexCoords2D *&tx1, TexCoords2D *&tx2, TexCoords2D *&tx3) const override
Returns per-triangle texture coordinates (pointer to)
Definition: ecvMeshGroup.h:66
virtual cloudViewer::GenericTriangle * _getTriangle(unsigned index) override
Returns the ith triangle.
Definition: ecvMeshGroup.h:120
virtual cloudViewer::VerticesIndexes * getTriangleVertIndexes(unsigned triangleIndex) override
Returns the indexes of the vertices of a given triangle.
Definition: ecvMeshGroup.h:128
bool hasPerTriangleTexCoordIndexes() const override
Returns whether this mesh as per-triangle triplets of tex coords indexes.
Definition: ecvMeshGroup.h:72
virtual cloudViewer::GenericTriangle * _getNextTriangle() override
Returns the next triangle (relatively to the global iterator position)
Definition: ecvMeshGroup.h:117
bool interpolateNormals(unsigned triIndex, const CCVector3 &P, CCVector3 &N) override
Interpolates normal(s) inside a given triangle.
Definition: ecvMeshGroup.h:29
bool getTriangleNormals(unsigned triangleIndex, CCVector3 &Na, CCVector3 &Nb, CCVector3 &Nc) const override
Returns a given triangle normal.
Definition: ecvMeshGroup.h:86
virtual unsigned size() const override
Returns the number of triangles.
Definition: ecvMeshGroup.h:114
bool interpolateNormalsBC(unsigned triIndex, const CCVector3d &w, CCVector3 &N) override
Interpolates normal(s) inside a given triangle.
Definition: ecvMeshGroup.h:34
void getTriangleNormalIndexes(unsigned triangleIndex, int &i1, int &i2, int &i3) const override
Returns a triplet of normal indexes for a given triangle (if any)
Definition: ecvMeshGroup.h:80
ccMeshGroup()
Default constructor.
Definition: ecvMeshGroup.h:21
NormsIndexesTableType * getTriNormsTable() const override
Returns per-triangle normals shared array.
Definition: ecvMeshGroup.h:92
short minimumFileVersion_MeOnly() const override
bool getVertexColorFromMaterial(unsigned triIndex, unsigned char vertIndex, ecvColor::Rgb &rgb, bool returnColorIfNoTexture) override
Definition: ecvMeshGroup.h:50
virtual void getTriangleVertices(unsigned triangleIndex, double A[3], double B[3], double C[3]) const override
Definition: ecvMeshGroup.h:136
virtual void placeIteratorAtBeginning() override
Places the mesh iterator at the beginning.
Definition: ecvMeshGroup.h:116
TextureCoordsContainer * getTexCoordinatesTable() const override
Returns per-triangle texture coordinates array.
Definition: ecvMeshGroup.h:62
bool hasTextures() const override
Returns whether textures are available for this mesh.
Definition: ecvMeshGroup.h:61
virtual void getTriangleVertices(unsigned triangleIndex, CCVector3 &A, CCVector3 &B, CCVector3 &C) const override
Returns the vertices of a given triangle.
Definition: ecvMeshGroup.h:132
virtual void getBoundingBox(CCVector3 &bbMin, CCVector3 &bbMax) override
Returns the mesh bounding-box.
Definition: ecvMeshGroup.h:140
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
bool interpolateColors(unsigned triIndex, const CCVector3 &P, ecvColor::Rgb &rgb) override
Interpolates RGB colors inside a given triangle.
Definition: ecvMeshGroup.h:39
virtual bool isSerializable() const override
Returns whether object is serializable of not.
Definition: ecvMeshGroup.h:105
virtual cloudViewer::VerticesIndexes * getNextTriangleVertIndexes() override
Definition: ecvMeshGroup.h:124
bool hasTriNormals() const override
Returns whether the mesh has per-triangle normals.
Definition: ecvMeshGroup.h:79
bool trianglePicking(const CCVector2d &clickPos, const ccGLCameraParameters &camera, int &nearestTriIndex, double &nearestSquareDist, CCVector3d &nearestPoint, CCVector3d *barycentricCoords=nullptr) const override
Brute force triangle picking.
Definition: ecvMeshGroup.h:94
void refreshBB() override
Forces bounding-box update.
Definition: ecvMeshGroup.h:28
unsigned capacity() const override
Returns max capacity.
Definition: ecvMeshGroup.h:93
const ccMaterialSet * getMaterialSet() const override
Definition: ecvMeshGroup.h:57
void getTexCoordinates(unsigned index, TexCoords2D *&tx) const
Definition: ecvMeshGroup.h:65
int getTriangleMtlIndex(unsigned triangleIndex) const override
Returns a given triangle material indexes.
Definition: ecvMeshGroup.h:58
bool hasMaterials() const override
Definition: ecvMeshGroup.h:56
virtual void drawMeOnly(CC_DRAW_CONTEXT &context) override
Enables (OpenGL) stipple mask.
void getTriangleTexCoordinatesIndexes(unsigned triangleIndex, int &i1, int &i2, int &i3) const override
Returns the triplet of tex coords indexes for a given triangle.
Definition: ecvMeshGroup.h:73
CV_CLASS_ENUM getClassID() const override
Returns class ID.
Definition: ecvMeshGroup.h:24
bool getColorFromMaterial(unsigned triIndex, const CCVector3 &P, ecvColor::Rgb &rgb, bool interpolateColorIfNoTexture) override
Definition: ecvMeshGroup.h:44
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
std::function< void(GenericTriangle &)> genericTriangleAction
Generic function to apply to a triangle (used by foreach)
Definition: GenericMesh.h:53
A generic triangle interface.
RGB color structure.
Definition: ecvColorTypes.h:49
ImGuiContext * context
Definition: Window.cpp:76
@ MESH_GROUP
Definition: CVTypes.h:107
2D texture coordinates
OpenGL camera parameters.
Display context.
Triangle described by the indexes of its 3 vertices.