ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvScalarFieldArithmeticsDlg.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 #include <ui_sfArithmeticsDlg.h>
11 
12 class ccPointCloud;
13 
16 class ccScalarFieldArithmeticsDlg : public QDialog,
17  public Ui::SFArithmeticsDlg {
18  Q_OBJECT
19 
20 public:
22  ccScalarFieldArithmeticsDlg(ccPointCloud* cloud, QWidget* parent = 0);
23 
25  enum Operation { /* Operations requiring two SFs */
26  PLUS = 0,
27  MINUS = 1,
28  MULTIPLY = 2,
29  DIVIDE = 3,
30  /* Operations requiring only one SF */
31  SQRT = 4,
32  POW2 = 5,
33  POW3 = 6,
34  EXP = 7,
35  LOG = 8,
36  LOG10 = 9,
37  COS = 10,
38  SIN = 11,
39  TAN = 12,
40  ACOS = 13,
41  ASIN = 14,
42  ATAN = 15,
43  INT = 16,
44  INVERSE = 17,
45  /* Invalid enum. (always last) */
46  INVALID = 255
47  };
48 
50  Operation getOperation() const;
51 
53  static Operation GetOperationByName(QString name);
54 
56  static QString GetOperationName(Operation op,
57  QString sf1,
58  QString sf2 = QString());
59 
61 
66  bool apply(ccPointCloud* cloud);
67 
69  struct SF2 {
70  SF2() : isConstantValue(true), constantValue(0), sfIndex(-1) {}
71 
73  double constantValue;
74  int sfIndex;
75  };
76 
78 
86  static bool Apply(ccPointCloud* cloud,
87  Operation op,
88  int sf1Idx,
89  bool inplace,
90  SF2* sf2 = 0,
91  QWidget* parent = 0);
92 
93 protected slots:
94 
96  void onOperationIndexChanged(int index);
97 
99  void onSF2IndexChanged(int index);
100 
101 protected:
103  int getSF1Index();
105  int getSF2Index();
106 
108  QString getOperationName(QString sf1, QString sf2 = QString()) const;
109 };
ccPointCloud::addScalarField
int addScalarField(const char *uniqueName) override
Creates a new scalar field and registers it.
Definition: ecvPointCloud.cpp:4210
ccScalarFieldArithmeticsDlg::POW3
@ POW3
Definition: ecvScalarFieldArithmeticsDlg.h:33
ccPointCloud::deleteScalarField
void deleteScalarField(int index) override
Deletes a specific scalar field.
Definition: ecvPointCloud.cpp:3237
ccScalarFieldArithmeticsDlg::PLUS
@ PLUS
Definition: ecvScalarFieldArithmeticsDlg.h:26
s_previouslySelectedOperationIndex
static int s_previouslySelectedOperationIndex
Definition: ecvScalarFieldArithmeticsDlg.cpp:34
cloudViewer::ScalarField::computeMinAndMax
virtual void computeMinAndMax()
Determines the min and max values.
Definition: ScalarField.h:123
cloudViewer::ScalarField::getValue
ScalarType & getValue(std::size_t index)
Definition: ScalarField.h:92
ccScalarFieldArithmeticsDlg::LOG
@ LOG
Definition: ecvScalarFieldArithmeticsDlg.h:35
cloudViewer::PointCloudTpl::getNumberOfScalarFields
unsigned getNumberOfScalarFields() const
Returns the number of associated (and active) scalar fields.
Definition: PointCloudTpl.h:345
ccScalarFieldArithmeticsDlg::getOperationName
QString getOperationName(QString sf1, QString sf2=QString()) const
Returns selected operation name.
Definition: ecvScalarFieldArithmeticsDlg.cpp:109
s_applyInPlace
static bool s_applyInPlace
Definition: ecvScalarFieldArithmeticsDlg.cpp:35
ccPointCloud
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
Definition: ecvPointCloud.h:146
cloudViewer::ScalarField
A simple scalar field (to be associated to a point cloud)
Definition: ScalarField.h:25
ecvScalarFieldArithmeticsDlg.h
ccScalarFieldArithmeticsDlg::MINUS
@ MINUS
Definition: ecvScalarFieldArithmeticsDlg.h:27
ccScalarFieldArithmeticsDlg::GetOperationName
static QString GetOperationName(Operation op, QString sf1, QString sf2=QString())
Returns operation name.
Definition: ecvScalarFieldArithmeticsDlg.cpp:129
cloudViewer::PointCloudTpl::getScalarFieldIndexByName
int getScalarFieldIndexByName(const char *name) const
Returns the index of a scalar field represented by its name.
Definition: PointCloudTpl.h:375
s_previousConstValue
static double s_previousConstValue
Definition: ecvScalarFieldArithmeticsDlg.cpp:36
ccPointCloud::setCurrentDisplayedScalarField
void setCurrentDisplayedScalarField(int index)
Sets the currently displayed scalar field.
Definition: ecvPointCloud.cpp:3227
cloudViewer::PointCloudTpl::getScalarField
ScalarField * getScalarField(int index) const
Returns a pointer to a specific scalar field.
Definition: PointCloudTpl.h:354
ccScalarFieldArithmeticsDlg::COS
@ COS
Definition: ecvScalarFieldArithmeticsDlg.h:37
CVLog::Error
static bool Error(const char *format,...)
Display an error dialog with formatted message.
Definition: CVLog.cpp:143
ccScalarFieldArithmeticsDlg::INVALID
@ INVALID
Definition: ecvScalarFieldArithmeticsDlg.h:46
ccScalarFieldArithmeticsDlg::INVERSE
@ INVERSE
Definition: ecvScalarFieldArithmeticsDlg.h:44
slots
#define slots
Definition: PythonPlugin.cpp:25
ccScalarFieldArithmeticsDlg::getOperation
Operation getOperation() const
Returns selected operation.
Definition: ecvScalarFieldArithmeticsDlg.cpp:99
ccScalarFieldArithmeticsDlg::SF2::isConstantValue
bool isConstantValue
Definition: ecvScalarFieldArithmeticsDlg.h:72
cloudViewer::ScalarField::resizeSafe
bool resizeSafe(std::size_t count, bool initNewElements=false, ScalarType valueForNewElements=0)
Resizes memory (no exception thrown)
Definition: ScalarField.cpp:81
ccScalarFieldArithmeticsDlg::ATAN
@ ATAN
Definition: ecvScalarFieldArithmeticsDlg.h:42
cloudViewer::ScalarField::ValidValue
static bool ValidValue(ScalarType value)
Returns whether a scalar value is valid or not.
Definition: ScalarField.h:61
s_opCount
static const unsigned s_opCount
Definition: ecvScalarFieldArithmeticsDlg.cpp:26
cloudViewer::ScalarField::getName
const char * getName() const
Returns scalar field name.
Definition: ScalarField.h:43
ccScalarFieldArithmeticsDlg
Definition: ecvScalarFieldArithmeticsDlg.h:16
cloudViewer::GreaterThanEpsilon
bool GreaterThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
Definition: CVMath.h:37
ccScalarFieldArithmeticsDlg::apply
bool apply(ccPointCloud *cloud)
Applies operation on a given cloud.
Definition: ecvScalarFieldArithmeticsDlg.cpp:151
ccScalarFieldArithmeticsDlg::DIVIDE
@ DIVIDE
Definition: ecvScalarFieldArithmeticsDlg.h:29
Ui
Definition: sfEditDlg.h:16
ccScalarFieldArithmeticsDlg::getSF2Index
int getSF2Index()
Returns second selected SF index.
Definition: ecvScalarFieldArithmeticsDlg.cpp:94
ccScalarFieldArithmeticsDlg::SIN
@ SIN
Definition: ecvScalarFieldArithmeticsDlg.h:38
ccScalarFieldArithmeticsDlg::POW2
@ POW2
Definition: ecvScalarFieldArithmeticsDlg.h:32
s_opNames
static const char s_opNames[s_opCount][12]
Definition: ecvScalarFieldArithmeticsDlg.cpp:28
ccScalarFieldArithmeticsDlg::onOperationIndexChanged
void onOperationIndexChanged(int index)
Called when the operation combo-box is modified.
Definition: ecvScalarFieldArithmeticsDlg.cpp:79
ecvScalarField.h
ccScalarFieldArithmeticsDlg::ASIN
@ ASIN
Definition: ecvScalarFieldArithmeticsDlg.h:41
ccScalarFieldArithmeticsDlg::onSF2IndexChanged
void onSF2IndexChanged(int index)
Called when the SF2 combo-box is modified.
Definition: ecvScalarFieldArithmeticsDlg.cpp:84
ccScalarFieldArithmeticsDlg::GetOperationByName
static Operation GetOperationByName(QString name)
Returns the operation enumerator based on its name.
Definition: ecvScalarFieldArithmeticsDlg.cpp:116
ccPointCloud::hasScalarFields
bool hasScalarFields() const override
Returns whether one or more scalar fields are instantiated.
Definition: ecvPointCloud.cpp:1697
cloudViewer::PointCloudTpl::getScalarFieldName
const char * getScalarFieldName(int index) const
Returns the name of a specific scalar field.
Definition: PointCloudTpl.h:365
CVLog::Warning
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
ccScalarFieldArithmeticsDlg::LOG10
@ LOG10
Definition: ecvScalarFieldArithmeticsDlg.h:36
ccScalarFieldArithmeticsDlg::getSF1Index
int getSF1Index()
Returns first selected SF index.
Definition: ecvScalarFieldArithmeticsDlg.cpp:90
ccScalarFieldArithmeticsDlg::MULTIPLY
@ MULTIPLY
Definition: ecvScalarFieldArithmeticsDlg.h:28
ccScalarFieldArithmeticsDlg::SF2::constantValue
double constantValue
Definition: ecvScalarFieldArithmeticsDlg.h:73
NAN_VALUE
constexpr ScalarType NAN_VALUE
NaN as a ScalarType value.
Definition: CVConst.h:76
ccScalarFieldArithmeticsDlg::Operation
Operation
Arithmetic operations.
Definition: ecvScalarFieldArithmeticsDlg.h:25
ccScalarFieldArithmeticsDlg::SF2::sfIndex
int sfIndex
Definition: ecvScalarFieldArithmeticsDlg.h:74
ccScalarFieldArithmeticsDlg::TAN
@ TAN
Definition: ecvScalarFieldArithmeticsDlg.h:39
ccScalarFieldArithmeticsDlg::SF2::SF2
SF2()
Definition: ecvScalarFieldArithmeticsDlg.h:70
cloudViewer::ScalarField::setValue
void setValue(std::size_t index, ScalarType value)
Definition: ScalarField.h:96
ccScalarFieldArithmeticsDlg::SQRT
@ SQRT
Definition: ecvScalarFieldArithmeticsDlg.h:31
ccScalarFieldArithmeticsDlg::ccScalarFieldArithmeticsDlg
ccScalarFieldArithmeticsDlg(ccPointCloud *cloud, QWidget *parent=0)
Default constructor.
Definition: ecvScalarFieldArithmeticsDlg.cpp:38
ccScalarFieldArithmeticsDlg::ACOS
@ ACOS
Definition: ecvScalarFieldArithmeticsDlg.h:40
ccScalarFieldArithmeticsDlg::Apply
static bool Apply(ccPointCloud *cloud, Operation op, int sf1Idx, bool inplace, SF2 *sf2=0, QWidget *parent=0)
Applies operation on a given cloud.
Definition: ecvScalarFieldArithmeticsDlg.cpp:169
cloudViewer::LessThanEpsilon
bool LessThanEpsilon(float x)
Test a floating point number against our epsilon (a very small number).
Definition: CVMath.h:23
ecvPointCloud.h
cloudViewer::ScalarField::currentSize
unsigned currentSize() const
Definition: ScalarField.h:100
ccScalarFieldArithmeticsDlg::INT
@ INT
Definition: ecvScalarFieldArithmeticsDlg.h:43
ccScalarFieldArithmeticsDlg::SF2
Secondary SF descriptor.
Definition: ecvScalarFieldArithmeticsDlg.h:69
name
std::string name
Definition: FileIOFactory.cpp:129
ccScalarFieldArithmeticsDlg::EXP
@ EXP
Definition: ecvScalarFieldArithmeticsDlg.h:34