surface_differentialProperties.h 4.07 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 "dll.h"
5
#include "plugin_processing.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
6

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

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

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

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

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

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

	void openComputeNormalDialog();
	void openComputeCurvatureDialog();

	void computeNormalFromDialog();
	void computeCurvatureFromDialog();

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

50
public slots:
Sylvain Thery's avatar
Sylvain Thery committed
51
	/**
Sylvain Thery's avatar
Sylvain Thery committed
52
	 * @brief [PYTHON] compute the normals of a mesh
Sylvain Thery's avatar
Sylvain Thery committed
53
54
55
56
57
	 * @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
58
59
60
61
62
	void computeNormal(const QString& mapName,
		const QString& positionAttributeName = "position",
		const QString& normalAttributeName = "normal",
		bool autoUpdate = true);

Sylvain Thery's avatar
Sylvain Thery committed
63
	/**
Sylvain Thery's avatar
Sylvain Thery committed
64
	 * @brief [PYTHON] compute curvatures of a mesh
Sylvain Thery's avatar
Sylvain Thery committed
65
66
67
	 * @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
68
69
70
71
	 * @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
72
73
74
75
76
	 * @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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
	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:
92
93
	Dialog_ComputeNormal* m_computeNormalDialog;
	Dialog_ComputeCurvature* m_computeCurvatureDialog;
Pierre Kraemer's avatar
Pierre Kraemer committed
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
134

	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;
};

135
136
137
138
} // namespace SCHNApps

} // namespace CGoGN

Pierre Kraemer's avatar
Pierre Kraemer committed
139
#endif