ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvPlane.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 "ecvGenericPrimitive.h"
13 
15 
19 public:
21 
28  PointCoordinateType yWidth,
29  const ccGLMatrix* transMat = nullptr,
30  QString name = QString("Plane"));
31 
33 
35  ccPlane(QString name = QString("Plane"));
36 
38  virtual CV_CLASS_ENUM getClassID() const override {
39  return CV_TYPES::PLANE;
40  }
41 
42  // inherited from ccGenericPrimitive
43  virtual QString getTypeName() const override { return "Plane"; }
44  virtual ccGenericPrimitive* clone() const override;
45 
46  // inherited from ccHObject
47  virtual ccBBox getOwnFitBB(ccGLMatrix& trans) override;
48 
50  PointCoordinateType getXWidth() const { return m_xWidth; }
51 
53  PointCoordinateType getYWidth() const { return m_yWidth; }
54 
56  CCVector3 getCenter() const {
57  return m_transformation.getTranslationAsVec3D();
58  }
59 
61  void setXWidth(PointCoordinateType w, bool autoUpdate = true) {
62  m_xWidth = w;
63  if (autoUpdate) updateRepresentation();
64  }
65 
67  void setYWidth(PointCoordinateType h, bool autoUpdate = true) {
68  m_yWidth = h;
69  if (autoUpdate) updateRepresentation();
70  }
71 
72  // inherited from ccPlanarEntityInterface
73  CCVector3 getNormal() const override {
74  return m_transformation.getColumnAsVec3D(2);
75  }
76 
78  bool setAsTexture(QImage image, QString imageFilename = QString());
79 
81  static bool SetQuadTexture(ccMesh* quadMesh,
82  QImage image,
83  QString imageFilename = QString());
84 
86 
92  double* rms = 0);
93 
95 
99  void getEquation(CCVector3& N, PointCoordinateType& constVal) const;
100 
102 
107 
109  void flip();
110 
111 protected:
112  // inherited from ccDrawable
113  virtual void drawMeOnly(CC_DRAW_CONTEXT& context) override;
114 
115  // inherited from ccGenericPrimitive
116  bool toFile_MeOnly(QFile& out, short dataVersion) const override;
117  short minimumFileVersion_MeOnly() const override;
118  bool fromFile_MeOnly(QFile& in,
119  short dataVersion,
120  int flags,
121  LoadedIDMap& oldToNewIDMap) override;
122  virtual bool buildUp() override;
123 
126 
129 
130  // Array [a,b,c,d] such that ax+by+cz = d
131  PointCoordinateType m_PlaneEquation[4];
132 };
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::shared_ptr< core::Tensor > image
std::string name
Bounding box structure.
Definition: ecvBBox.h:25
Float version of ccGLMatrixTpl.
Definition: ecvGLMatrix.h:19
Generic primitive interface.
virtual bool updateRepresentation()
Updates internal representation (as a mesh)
Triangular mesh.
Definition: ecvMesh.h:35
Interface for a planar entity.
Plane (primitive)
Definition: ecvPlane.h:18
virtual ccGenericPrimitive * clone() const override
Clones primitive.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
PointCoordinateType m_yWidth
Width along 'Y' dimension.
Definition: ecvPlane.h:128
static ccPlane * Fit(cloudViewer::GenericIndexedCloudPersist *cloud, double *rms=0)
Fits a plane primitive on a cloud.
virtual bool buildUp() override
Builds primitive.
CCVector3 getCenter() const
Returns the center.
Definition: ecvPlane.h:56
CCVector3 getNormal() const override
Returns the entity normal.
Definition: ecvPlane.h:73
ccPlane(PointCoordinateType xWidth, PointCoordinateType yWidth, const ccGLMatrix *transMat=nullptr, QString name=QString("Plane"))
Default constructor.
void flip()
Flips the plane.
virtual QString getTypeName() const override
Returns type name (sphere, cylinder, etc.)
Definition: ecvPlane.h:43
bool setAsTexture(QImage image, QString imageFilename=QString())
Sets an image as texture.
const PointCoordinateType * getEquation()
Returns the equation of the plane.
void setXWidth(PointCoordinateType w, bool autoUpdate=true)
Sets 'X' width.
Definition: ecvPlane.h:61
PointCoordinateType m_xWidth
Width along 'X' dimension.
Definition: ecvPlane.h:125
void getEquation(CCVector3 &N, PointCoordinateType &constVal) const
Returns the equation of the plane.
PointCoordinateType getXWidth() const
Returns 'X' width.
Definition: ecvPlane.h:50
virtual ccBBox getOwnFitBB(ccGLMatrix &trans) override
Returns best-fit bounding-box (if available)
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
short minimumFileVersion_MeOnly() const override
PointCoordinateType getYWidth() const
Returns 'Y' width.
Definition: ecvPlane.h:53
virtual void drawMeOnly(CC_DRAW_CONTEXT &context) override
Enables (OpenGL) stipple mask.
void setYWidth(PointCoordinateType h, bool autoUpdate=true)
Sets 'Y' width.
Definition: ecvPlane.h:67
ccPlane(QString name=QString("Plane"))
Simplified constructor.
virtual CV_CLASS_ENUM getClassID() const override
Returns class ID.
Definition: ecvPlane.h:38
static bool SetQuadTexture(ccMesh *quadMesh, QImage image, QString imageFilename=QString())
Sets an image as texture for a quad mesh.
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.
ImGuiContext * context
Definition: Window.cpp:76
@ PLANE
Definition: CVTypes.h:120
Display context.