ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvFacet.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 "ecvHObject.h"
13 
14 namespace cloudViewer {
15 class GenericIndexedCloudPersist;
16 }
17 
18 class ccMesh;
19 class ccPolyline;
20 class ccPointCloud;
21 
23 
26 public:
28 
31  ccFacet(PointCoordinateType maxEdgeLength = 0,
32  QString name = QString("Facet"));
33 
35  virtual ~ccFacet() override;
36 
38 
47  PointCoordinateType maxEdgeLength = 0,
48  bool transferOwnership = false,
49  const PointCoordinateType* planeEquation = nullptr);
50 
52  virtual CV_CLASS_ENUM getClassID() const override {
53  return CV_TYPES::FACET;
54  }
55  virtual bool isSerializable() const override { return true; }
56 
58 
60  void setColor(const ecvColor::Rgb& rgb);
61 
62  // inherited from ccPlanarEntityInterface
63  inline CCVector3 getNormal() const override {
64  return CCVector3(m_planeEquation);
65  }
66 
68  inline double getRMS() const { return m_rms; }
70  inline double getSurface() const { return m_surface; }
72  inline const PointCoordinateType* getPlaneEquation() const {
73  return m_planeEquation;
74  }
76  void invertNormal();
78  inline const CCVector3& getCenter() const { return m_center; }
79 
81  inline ccMesh* getPolygon() { return m_polygonMesh; }
83  inline const ccMesh* getPolygon() const { return m_polygonMesh; }
84 
86  inline ccPolyline* getContour() { return m_contourPolyline; }
88  inline const ccPolyline* getContour() const { return m_contourPolyline; }
89 
91  inline ccPointCloud* getContourVertices() { return m_contourVertices; }
93  inline const ccPointCloud* getContourVertices() const {
94  return m_contourVertices;
95  }
96 
98  inline ccPointCloud* getOriginPoints() { return m_originPoints; }
100  inline const ccPointCloud* getOriginPoints() const {
101  return m_originPoints;
102  }
103 
105  inline void setPolygon(ccMesh* mesh) { m_polygonMesh = mesh; }
107  inline void setContour(ccPolyline* poly) { m_contourPolyline = poly; }
109  inline void setContourVertices(ccPointCloud* cloud) {
110  m_contourVertices = cloud;
111  }
113  inline void setOriginPoints(ccPointCloud* cloud) { m_originPoints = cloud; }
114 
116  std::shared_ptr<ccMesh> getNormalVectorMesh(bool update = false);
117 
119  ccFacet* clone() const;
120  bool clone(ccFacet* facet) const;
121 
122  virtual bool IsEmpty() const override;
123  virtual Eigen::Vector3d GetMinBound() const override;
124  virtual Eigen::Vector3d GetMaxBound() const override;
125  virtual Eigen::Vector3d GetCenter() const override;
126  virtual ccBBox GetAxisAlignedBoundingBox() const override;
127  virtual ecvOrientedBBox GetOrientedBoundingBox() const override;
128  virtual ccFacet& Transform(const Eigen::Matrix4d& transformation) override;
129  virtual ccFacet& Translate(const Eigen::Vector3d& translation,
130  bool relative = true) override;
131  virtual ccFacet& Scale(const double s,
132  const Eigen::Vector3d& center) override;
133  virtual ccFacet& Rotate(const Eigen::Matrix3d& R,
134  const Eigen::Vector3d& center) override;
135 
137 
139  ccFacet(const ccFacet& poly);
140 
141  ccFacet& operator+=(const ccFacet& polyline);
142  ccFacet& operator=(const ccFacet& polyline);
143  ccFacet operator+(const ccFacet& polyline) const;
144 
148  ccFacet& PaintUniformColor(const Eigen::Vector3d& color) {
150  return (*this);
151  }
152 
153 protected:
154  // inherited from ccDrawable
155  virtual void drawMeOnly(CC_DRAW_CONTEXT& context) override;
156 
158  bool createInternalRepresentation(
160  const PointCoordinateType* planeEquation = nullptr);
161 
163  std::shared_ptr<ccMesh> m_arrow;
164 
173 
175  PointCoordinateType m_planeEquation[4];
176 
179 
181  double m_rms;
182 
184  double m_surface;
185 
188 
189  // inherited from ccHObject
190  bool toFile_MeOnly(QFile& out, short dataVersion) const override;
191  short minimumFileVersion_MeOnly() const override;
192  bool fromFile_MeOnly(QFile& in,
193  short dataVersion,
194  int flags,
195  LoadedIDMap& oldToNewIDMap) override;
196 
197  // ccHObject interface
198  virtual void applyGLTransformation(const ccGLMatrix& trans) override;
199 };
Vector3Tpl< PointCoordinateType > CCVector3
Default 3D Vector.
Definition: CVGeom.h:798
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
std::string name
int points
math::float4 color
Bounding box structure.
Definition: ecvBBox.h:25
Facet.
Definition: ecvFacet.h:25
ccFacet * clone() const
Clones this facet.
ccMesh * getPolygon()
Returns polygon mesh (if any)
Definition: ecvFacet.h:81
short minimumFileVersion_MeOnly() const override
double getSurface() const
Returns associated surface area.
Definition: ecvFacet.h:70
virtual Eigen::Vector3d GetMaxBound() const override
Returns max bounds for geometry coordinates.
virtual ccBBox GetAxisAlignedBoundingBox() const override
Returns an axis-aligned bounding box of the geometry.
virtual void drawMeOnly(CC_DRAW_CONTEXT &context) override
Draws the entity only (not its children)
virtual ccFacet & Translate(const Eigen::Vector3d &translation, bool relative=true) override
Apply translation to the geometry coordinates.
ccFacet & operator+=(const ccFacet &polyline)
bool clone(ccFacet *facet) const
const ccPointCloud * getContourVertices() const
Returns contour vertices (if any)
Definition: ecvFacet.h:93
virtual Eigen::Vector3d GetMinBound() const override
Returns min bounds for geometry coordinates.
ccFacet operator+(const ccFacet &polyline) const
const PointCoordinateType * getPlaneEquation() const
Returns plane equation.
Definition: ecvFacet.h:72
ccPolyline * getContour()
Returns contour polyline (if any)
Definition: ecvFacet.h:86
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
double m_rms
RMS (relatively to m_associatedPoints)
Definition: ecvFacet.h:181
ccFacet(PointCoordinateType maxEdgeLength=0, QString name=QString("Facet"))
Default constructor.
const ccMesh * getPolygon() const
Returns polygon mesh (if any)
Definition: ecvFacet.h:83
ccMesh * m_polygonMesh
Facet.
Definition: ecvFacet.h:166
virtual bool isSerializable() const override
Returns whether object is serializable of not.
Definition: ecvFacet.h:55
double m_surface
Surface (m_polygon)
Definition: ecvFacet.h:184
ccPointCloud * m_originPoints
Origin points.
Definition: ecvFacet.h:172
virtual void applyGLTransformation(const ccGLMatrix &trans) override
Applies a GL transformation to the entity.
virtual ecvOrientedBBox GetOrientedBoundingBox() const override
CCVector3 getNormal() const override
Returns the entity normal.
Definition: ecvFacet.h:63
PointCoordinateType m_maxEdgeLength
Max length.
Definition: ecvFacet.h:187
void invertNormal()
Inverts the facet normal.
void setContour(ccPolyline *poly)
Sets contour polyline.
Definition: ecvFacet.h:107
virtual Eigen::Vector3d GetCenter() const override
Returns the center of the geometry coordinates.
virtual bool IsEmpty() const override
ccPolyline * m_contourPolyline
Facet contour.
Definition: ecvFacet.h:168
double getRMS() const
Returns associated RMS.
Definition: ecvFacet.h:68
const ccPolyline * getContour() const
Returns contour polyline (if any)
Definition: ecvFacet.h:88
virtual CV_CLASS_ENUM getClassID() const override
Returns class ID.
Definition: ecvFacet.h:52
ccFacet & operator=(const ccFacet &polyline)
void setColor(const ecvColor::Rgb &rgb)
Sets the facet unique color.
std::shared_ptr< ccMesh > m_arrow
for python interface use
Definition: ecvFacet.h:163
void setContourVertices(ccPointCloud *cloud)
Sets contour vertices.
Definition: ecvFacet.h:109
static ccFacet * Create(cloudViewer::GenericIndexedCloudPersist *cloud, PointCoordinateType maxEdgeLength=0, bool transferOwnership=false, const PointCoordinateType *planeEquation=nullptr)
Creates a facet from a set of points.
ccFacet & PaintUniformColor(const Eigen::Vector3d &color)
Assigns each line in the LineSet the same color.
Definition: ecvFacet.h:148
CCVector3 m_center
Facet centroid.
Definition: ecvFacet.h:178
virtual ccFacet & Rotate(const Eigen::Matrix3d &R, const Eigen::Vector3d &center) override
Apply rotation to the geometry coordinates and normals. Given a rotation matrix , and center ,...
ccFacet(const ccFacet &poly)
Copy constructor.
const CCVector3 & getCenter() const
Returns the facet center.
Definition: ecvFacet.h:78
virtual ccFacet & Transform(const Eigen::Matrix4d &transformation) override
Apply transformation (4x4 matrix) to the geometry coordinates.
ccPointCloud * getContourVertices()
Returns contour vertices (if any)
Definition: ecvFacet.h:91
const ccPointCloud * getOriginPoints() const
Returns origin points (if any)
Definition: ecvFacet.h:100
void setPolygon(ccMesh *mesh)
Sets polygon mesh.
Definition: ecvFacet.h:105
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
ccPointCloud * m_contourVertices
Shared vertices (between polygon and contour)
Definition: ecvFacet.h:170
std::shared_ptr< ccMesh > getNormalVectorMesh(bool update=false)
Gets normal vector mesh.
virtual ~ccFacet() override
Destructor.
void setOriginPoints(ccPointCloud *cloud)
Sets origin points.
Definition: ecvFacet.h:113
ccPointCloud * getOriginPoints()
Returns origin points (if any)
Definition: ecvFacet.h:98
virtual ccFacet & Scale(const double s, const Eigen::Vector3d &center) override
Apply scaling to the geometry coordinates. Given a scaling factor , and center , a given point is tr...
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
Triangular mesh.
Definition: ecvMesh.h:35
Interface for a planar entity.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Colored polyline.
Definition: ecvPolyline.h:24
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
A generic 3D point cloud with index-based and presistent access to points.
RGB color structure.
Definition: ecvColorTypes.h:49
constexpr static RgbTpl FromEigen(const Eigen::Vector3d &t)
Definition: ecvColorTypes.h:86
ImGuiContext * context
Definition: Window.cpp:76
@ FACET
Definition: CVTypes.h:109
bool setColor(ccHObject::Container selectedEntities, bool colorize, QWidget *parent)
Generic file read and write utility for python interface.
Display context.