surface_differentialProperties.h 4.02 KB
Newer Older
1
2
#ifndef _SURFACE_DIFFERENTIALPROPERTIES_PLUGIN_H_
#define _SURFACE_DIFFERENTIALPROPERTIES_PLUGIN_H_
Pierre Kraemer's avatar
Pierre Kraemer committed
3

4
#include "plugin_processing.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
5

6
7
#include "dialog_computeNormal.h"
#include "dialog_computeCurvature.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
8

9
10
namespace CGoGN
{
Pierre Kraemer's avatar
Pierre Kraemer committed
11

12
13
namespace SCHNApps
{
Sylvain Thery's avatar
Sylvain Thery committed
14
15
16
17
18
/**
 * @brief Plugin that manage the computation of differential properties
 * - Normals
 * - Curvatures
 */
19
class Surface_DifferentialProperties_Plugin : public PluginProcessing
Pierre Kraemer's avatar
Pierre Kraemer committed
20
21
22
{
	Q_OBJECT
	Q_INTERFACES(CGoGN::SCHNApps::Plugin)
Sylvain Thery's avatar
Sylvain Thery committed
23
24
25
#if CGOGN_QT_DESIRED_VERSION == 5
	Q_PLUGIN_METADATA(IID "CGoGN.SCHNapps.Plugin")
#endif
Pierre Kraemer's avatar
Pierre Kraemer committed
26
public:
27
28
	Surface_DifferentialProperties_Plugin()
	{}
Pierre Kraemer's avatar
Pierre Kraemer committed
29

30
	~Surface_DifferentialProperties_Plugin()
Pierre Kraemer's avatar
Pierre Kraemer committed
31
32
33
	{}

	virtual bool enable();
34
	virtual void disable();
Pierre Kraemer's avatar
Pierre Kraemer committed
35

36
private slots:
Pierre Kraemer's avatar
Pierre Kraemer committed
37
38
39
40
41
42
43
44
45
46
	void mapAdded(MapHandlerGen* map);
	void mapRemoved(MapHandlerGen* map);
	void attributeModified(unsigned int orbit, QString nameAttr);

	void openComputeNormalDialog();
	void openComputeCurvatureDialog();

	void computeNormalFromDialog();
	void computeCurvatureFromDialog();

47
	void schnappsClosing();
Sylvain Thery's avatar
Sylvain Thery committed
48

49
public slots:
Sylvain Thery's avatar
Sylvain Thery committed
50
	/**
Sylvain Thery's avatar
Sylvain Thery committed
51
	 * @brief [PYTHON] compute the normals of a mesh
Sylvain Thery's avatar
Sylvain Thery committed
52
53
54
55
56
	 * @param mapName name of the 2d map (mesh)
	 * @param positionAttributeName name of position attribute used for computation
	 * @param normalAttributeName name of result attribute
	 * @param autoUpdate automatically update the normal attribute when position attribute change.
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
57
58
59
60
61
	void computeNormal(const QString& mapName,
		const QString& positionAttributeName = "position",
		const QString& normalAttributeName = "normal",
		bool autoUpdate = true);

Sylvain Thery's avatar
Sylvain Thery committed
62
	/**
Sylvain Thery's avatar
Sylvain Thery committed
63
	 * @brief [PYTHON] compute curvatures of a mesh
Sylvain Thery's avatar
Sylvain Thery committed
64
65
66
	 * @param mapName name of 2d map
	 * @param positionAttributeName name of input position attribute
	 * @param normalAttributeName name of input normal attributes
Sylvain Thery's avatar
Sylvain Thery committed
67
68
69
70
	 * @param KmaxAttributeName ?? result attribute name
	 * @param kmaxAttributeName ?? result attribute name
	 * @param KminAttributeName ?? result attribute name
	 * @param kminAttributeName ?? result attribute name
Sylvain Thery's avatar
Sylvain Thery committed
71
72
73
74
75
	 * @param KnormalAttributeName ?? result attribute aname
	 * @param compute_kmean compute the mean curvature
	 * @param compute_kgaussian compute the gaussian curvature
	 * @param autoUpdate automatically update the output attributes when input attribute change.
	 */
Pierre Kraemer's avatar
Pierre Kraemer committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
	void computeCurvature(
		const QString& mapName,
		const QString& positionAttributeName = "position",
		const QString& normalAttributeName = "normal",
		const QString& KmaxAttributeName = "Kmax",
		const QString& kmaxAttributeName = "kmax",
		const QString& KminAttributeName = "Kmin",
		const QString& kminAttributeName = "kmin",
		const QString& KnormalAttributeName = "Knormal",
		bool compute_kmean = true,
		bool compute_kgaussian = true,
		bool autoUpdate = true
	);

private:
91
92
	Dialog_ComputeNormal* m_computeNormalDialog;
	Dialog_ComputeCurvature* m_computeCurvatureDialog;
Pierre Kraemer's avatar
Pierre Kraemer committed
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

	QAction* m_computeNormalAction;
	QAction* m_computeCurvatureAction;

	struct ComputeNormalParameters
	{
		ComputeNormalParameters() {}
		ComputeNormalParameters(const QString& p, const QString& n, bool update) :
			positionName(p), normalName(n), autoUpdate(update)
		{}
		QString positionName;
		QString normalName;
		bool autoUpdate;
	};
	QHash<QString, ComputeNormalParameters> computeNormalLastParameters;

	struct ComputeCurvatureParameters
	{
		ComputeCurvatureParameters() {}
		ComputeCurvatureParameters(
			const QString& p, const QString& n,
			const QString& Kmax, const QString& kmax, const QString& Kmin, const QString& kmin, const QString& Knormal,
			bool kmean, bool kgaussian, bool update) :
			positionName(p), normalName(n),
			KmaxName(Kmax), kmaxName(kmax), KminName(Kmin), kminName(kmin), KnormalName(Knormal),
			compute_kmean(kmean), compute_kgaussian(kgaussian), autoUpdate(update)
		{}
		QString positionName;
		QString normalName;
		QString KmaxName;
		QString kmaxName;
		QString KminName;
		QString kminName;
		QString KnormalName;
		bool compute_kmean;
		bool compute_kgaussian;
		bool autoUpdate;
	};
	QHash<QString, ComputeCurvatureParameters> computeCurvatureLastParameters;
};

134
135
136
137
} // namespace SCHNApps

} // namespace CGoGN

Pierre Kraemer's avatar
Pierre Kraemer committed
138
#endif