Debian Codegraph @

plugins/core/Standard/qCanupo/include/classifier.h

raw
1 //##########################################################################
2 //# #
3 //# CLOUDCOMPARE PLUGIN: qCANUPO #
4 //# #
5 //# This program is free software; you can redistribute it and/or modify #
6 //# it under the terms of the GNU General Public License as published by #
7 //# the Free Software Foundation; version 2 or later of the License. #
8 //# #
9 //# This program is distributed in the hope that it will be useful, #
10 //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
11 //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
12 //# GNU General Public License for more details. #
13 //# #
14 //# COPYRIGHT: UEB (UNIVERSITE EUROPEENNE DE BRETAGNE) / CNRS #
15 //# #
16 //##########################################################################
17
18 /** This file is directly inspired of the equivalently named file in the
19 original CANUPO project, by N. Brodu and D. Lague.
20 **/
21
22 #ifndef QCANUPO_CLASSIFIER_HEADER
23 #define QCANUPO_CLASSIFIER_HEADER
24
25 //Local
26 #include "ccPointDescriptor.h"
27
28 //CCCoreLib
29 #include <CCGeom.h>
30
31 //Qt
32 #include <QString>
33
34 //system
35 #include <vector>
36
37 //! Classifier
38 class Classifier
39 {
40 public: //methods
41
42 //! 2D point
43 typedef Vector2Tpl<float> Point2D;
44
45 //! Default constructor
46 Classifier();
47
48 //! Checks the ref. points
49 /** Exchanges refPointPos and refPointNeg if necessary
50 as the user may have moved them.
51 **/
52 bool checkRefPoints();
53
54 //! Checks numerical condition
55 float classify2D_checkcondnum(const Point2D& P, const Point2D& R, float& condnumber) const;
56
57 //! Classification in the 2D space
58 float classify2D(const Point2D& P) const;
59
60 //! Projects a parameter vector in (2D) MSC space
61 Point2D project(const CorePointDesc& mscdata) const;
62
63 //! Classification in MSC space
64 float classify(const CorePointDesc& mscdata) const;
65
66 //! Classifier's file header info
67 struct FileHeader
68 {
69 unsigned classifierCount;
70 unsigned dimPerScale;
71 unsigned descID;
72 };
73
74 //! Loads a CANUPO's classifier file (.prm)
75 static bool Load( QString filename,
76 std::vector<Classifier>& classifiers,
77 std::vector<float>& scales,
78 QString& error,
79 FileHeader* header = nullptr,
80 bool headerOnly = false);
81
82 //! Saves classifier as a CANUPO's classifier file (.prm)
83 bool save( QString filename,
84 QString& error );
85
86 public: //members
87
88 int class1, class2;
89 std::vector<float> weightsAxis1, weightsAxis2;
90 std::vector<Point2D> path;
91 float absMaxXY, axisScaleRatio;
92 Point2D refPointPos, refPointNeg;
93
94 //! Associated descriptor ID (see ccPointDescriptor.h)
95 unsigned descriptorID;
96
97 //! Dimension (per-scale)
98 unsigned dimPerScale;
99
100 //! Associated scales
101 std::vector<float> scales;
102 };
103
104 #endif //QCANUPO_CLASSIFIER_HEADER