2023-11-30 19:43:41 +01:00
|
|
|
#include "Eigen/Dense"
|
|
|
|
|
|
2023-12-22 00:26:28 +01:00
|
|
|
#include <ccOctree.h>
|
2025-01-31 08:11:12 +01:00
|
|
|
#include <ccScalarField.h>
|
2023-12-22 00:26:28 +01:00
|
|
|
|
2023-12-01 17:54:25 +01:00
|
|
|
#include <vector>
|
|
|
|
|
|
2023-12-22 00:26:28 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
|
2023-12-22 10:56:59 +01:00
|
|
|
#include <G3PointDialog.h>
|
2023-12-22 00:26:28 +01:00
|
|
|
|
2024-03-19 11:21:37 +01:00
|
|
|
#include <GrainsAsEllipsoids.h>
|
|
|
|
|
|
2025-02-28 15:14:18 +01:00
|
|
|
#include <AnglesCustomPlot.h>
|
|
|
|
|
|
|
|
|
|
#include <G3PointPlots.h>
|
|
|
|
|
|
2023-11-22 12:56:31 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
class ccMainAppInterface;
|
2023-12-01 17:54:25 +01:00
|
|
|
class ccPointCloud;
|
2023-11-22 12:56:31 +01:00
|
|
|
|
|
|
|
|
namespace G3Point
|
|
|
|
|
{
|
2023-12-22 00:26:28 +01:00
|
|
|
class G3PointAction : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
2024-02-28 23:14:33 +01:00
|
|
|
typedef Eigen::Array<bool, Eigen::Dynamic, Eigen::Dynamic> XXb;
|
2024-02-29 16:46:34 +01:00
|
|
|
typedef Eigen::Array<bool, Eigen::Dynamic, Eigen::Dynamic> Xb;
|
2024-02-28 23:14:33 +01:00
|
|
|
|
2023-12-22 00:26:28 +01:00
|
|
|
public:
|
2024-02-22 00:14:35 +01:00
|
|
|
explicit G3PointAction(ccPointCloud *cloud, ccMainAppInterface *app=nullptr);
|
2024-02-23 17:34:34 +01:00
|
|
|
~G3PointAction();
|
2023-12-22 00:26:28 +01:00
|
|
|
static void createAction(ccMainAppInterface *appInterface);
|
2024-02-23 17:34:34 +01:00
|
|
|
static void GetG3PointAction(ccPointCloud *cloud, ccMainAppInterface *app=nullptr);
|
|
|
|
|
void segment();
|
2024-04-16 16:30:25 +02:00
|
|
|
void clusterAndOrClean();
|
2024-02-29 16:46:34 +01:00
|
|
|
void getBorders();
|
2024-04-23 16:46:48 +02:00
|
|
|
bool cluster();
|
2024-03-26 17:24:03 +01:00
|
|
|
void fit();
|
2024-05-13 16:29:42 +02:00
|
|
|
void exportResults();
|
2025-02-28 15:14:18 +01:00
|
|
|
void plots();
|
2025-03-07 09:11:09 +01:00
|
|
|
void showWolman(const Eigen::ArrayXf& d_sample, const Eigen::Array3d &dq_final, const Eigen::Array3d &edq);
|
2025-01-31 08:11:12 +01:00
|
|
|
bool wolman();
|
2025-02-24 17:31:45 +01:00
|
|
|
bool angles();
|
2024-04-23 16:46:48 +02:00
|
|
|
bool processNewStacks(std::vector<std::vector<int>>& newStacks, int pointCount);
|
2025-01-31 08:11:12 +01:00
|
|
|
bool buildStacksFromG3PointLabelSF(CCCoreLib::ScalarField *g3PointLabel);
|
2024-02-29 16:46:34 +01:00
|
|
|
bool merge(XXb& condition);
|
2024-03-01 16:48:09 +01:00
|
|
|
bool keep(Xb& condition);
|
2024-02-29 16:46:34 +01:00
|
|
|
bool cleanLabels();
|
2024-02-23 17:34:34 +01:00
|
|
|
void clean();
|
2023-12-22 00:26:28 +01:00
|
|
|
|
2024-06-04 16:36:37 +02:00
|
|
|
template<typename T> static bool EigenArrayToFile(QString name, T array);
|
|
|
|
|
|
2023-12-22 00:26:28 +01:00
|
|
|
private:
|
|
|
|
|
bool sfConvertToRandomRGB(const ccHObject::Container &selectedEntities, QWidget* parent);
|
2024-03-13 11:12:50 +01:00
|
|
|
void addToStack(int index, const Eigen::ArrayXi& n_donors, const Eigen::ArrayXXi& donors, std::vector<int>& stack);
|
|
|
|
|
int segmentLabels(bool useParallelStrategy=true);
|
|
|
|
|
double angleRot2VecMat(const Eigen::Vector3d &a, const Eigen::Vector3d &b);
|
2024-03-01 16:48:09 +01:00
|
|
|
Eigen::ArrayXXd computeMeanAngleBetweenNormalsAtBorders();
|
2024-04-23 16:46:48 +02:00
|
|
|
bool exportLocalMaximaAsCloud(const Eigen::ArrayXi &localMaximumIndexes);
|
2024-02-29 16:46:34 +01:00
|
|
|
bool updateLocalMaximumIndexes();
|
|
|
|
|
bool updateLabelsAndColors();
|
|
|
|
|
bool checkStacks(const std::vector<std::vector<int>>& stacks, int count);
|
2025-09-18 10:26:16 +02:00
|
|
|
void addToStackBraunWillett(int index, const Eigen::ArrayXi& delta, const Eigen::ArrayXi& Di, std::vector<int>& stack, int local_maximum);
|
2025-03-26 10:52:15 +01:00
|
|
|
int segmentLabelsBraunWillett();
|
2025-09-18 10:26:16 +02:00
|
|
|
void getNeighborsDistancesSlopes(unsigned index, std::vector<char>& duplicates);
|
2024-03-13 11:12:50 +01:00
|
|
|
void computeNodeSurfaces();
|
|
|
|
|
bool computeNormalsAndOrientThemWithCloudCompare();
|
|
|
|
|
void orientNormals(const Eigen::Vector3d &sensorCenter);
|
|
|
|
|
bool computeNormalsWithOpen3D();
|
|
|
|
|
bool queryNeighbors(ccPointCloud* cloud, ccMainAppInterface* appInterface, bool useParallelStrategy=true);
|
2024-02-22 00:14:35 +01:00
|
|
|
void init();
|
|
|
|
|
void showDlg();
|
2024-02-23 17:34:34 +01:00
|
|
|
void resetDlg();
|
2024-05-24 10:36:09 +02:00
|
|
|
bool setCloud(ccPointCloud *cloud);
|
2024-06-06 11:58:08 +02:00
|
|
|
void setKNN();
|
2023-12-22 00:26:28 +01:00
|
|
|
|
2024-02-07 08:32:31 +01:00
|
|
|
int m_kNN = 20;
|
2024-02-20 17:18:50 +01:00
|
|
|
double m_radiusFactor = 0.6;
|
|
|
|
|
double m_maxAngle1 = 60;
|
2024-02-29 16:46:34 +01:00
|
|
|
double m_maxAngle2 = 10;
|
|
|
|
|
int m_nMin = 50;
|
|
|
|
|
double m_minFlatness = 0.1;
|
2024-02-07 08:32:31 +01:00
|
|
|
|
2024-02-22 00:14:35 +01:00
|
|
|
ccPointCloud* m_cloud;
|
|
|
|
|
ccMainAppInterface *m_app;
|
|
|
|
|
G3PointDialog* m_dlg;
|
2024-03-01 16:48:09 +01:00
|
|
|
|
|
|
|
|
Eigen::ArrayXXi m_neighborsIndexes;
|
2024-03-13 11:12:50 +01:00
|
|
|
Eigen::ArrayXXd m_neighborsDistances;
|
|
|
|
|
Eigen::ArrayXXd m_neighborsSlopes;
|
2024-02-20 17:18:50 +01:00
|
|
|
Eigen::ArrayXXd m_normals;
|
2024-02-22 00:14:35 +01:00
|
|
|
|
2024-04-16 16:30:25 +02:00
|
|
|
Eigen::ArrayXi m_initial_labels;
|
|
|
|
|
Eigen::ArrayXi m_initial_labelsnpoint;
|
|
|
|
|
Eigen::ArrayXi m_initial_localMaximumIndexes;
|
2024-04-23 16:46:48 +02:00
|
|
|
Eigen::ArrayXi m_labels;
|
|
|
|
|
Eigen::ArrayXi m_labelsnpoint;
|
|
|
|
|
Eigen::ArrayXi m_localMaximumIndexes;
|
2024-02-07 08:32:31 +01:00
|
|
|
Eigen::ArrayXi m_ndon;
|
2024-02-22 00:14:35 +01:00
|
|
|
Eigen::ArrayXd m_area;
|
|
|
|
|
|
2024-03-19 11:21:37 +01:00
|
|
|
QSharedPointer<RGBAColorsTableType> m_grainColors;
|
|
|
|
|
|
2024-04-23 16:46:48 +02:00
|
|
|
std::vector<std::vector<int>> m_initialStacks;
|
2024-02-22 00:14:35 +01:00
|
|
|
std::vector<std::vector<int>> m_stacks;
|
|
|
|
|
|
|
|
|
|
ccOctree::Shared m_octree;
|
|
|
|
|
unsigned char m_bestOctreeLevel = 0;
|
|
|
|
|
CCCoreLib::DgmOctree::NearestNeighboursSearchStruct m_nNSS;
|
2023-12-22 00:26:28 +01:00
|
|
|
|
2025-02-02 22:24:38 +01:00
|
|
|
static std::shared_ptr<G3PointAction> s_g3PointAction;
|
2024-03-19 11:21:37 +01:00
|
|
|
|
2025-03-04 16:31:58 +01:00
|
|
|
static QPointer<G3PointPlots> s_g3PointPlots;
|
2025-02-28 15:14:18 +01:00
|
|
|
|
|
|
|
|
GrainsAsEllipsoids* m_grainsAsEllipsoids;
|
2025-03-04 16:31:58 +01:00
|
|
|
|
|
|
|
|
int m_currentNumberOfSteps;
|
2023-12-22 00:26:28 +01:00
|
|
|
};
|
2023-11-22 12:56:31 +01:00
|
|
|
}
|