1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#pragma once

#include "SurfaceMeshPlugins.h"
#include "SurfaceMeshHelper.h"
#include "RichParameterSet.h"
#include "StarlabDrawArea.h"

#include "NURBSCurve.h"
#include "NURBSRectangle.h"
#include "NurbsDraw.h"

#include "nurbstools.h"

#include "OBB_Volume.h"

#include "../CustomDrawObjects.h"

namespace Structure{
	struct Graph;
}

class nurbs_plugin : public SurfaceMeshModePlugin{
    Q_OBJECT
    Q_INTERFACES(ModePlugin)

public:
	nurbs_plugin() { widget = NULL; }
    QIcon icon(){ return QIcon(":/images/nurbs_icon.png"); }

    /// Functions part of the EditPlugin system
    void create();
    void destroy(){}

    void decorate();

    std::vector<NURBS::NURBSCurved> curves;
    std::vector<NURBS::NURBSRectangled> rects;
	Structure::Graph * graph;

    NURBSTools * widget;

    Vector3VertexProperty points;

	OBB_Volume mesh_obb;

	SurfaceMesh::SurfaceMeshModel * entireMesh;
	Vector3VertexProperty entirePoints;

	PolygonSoup ps;

	NURBS::NURBSCurved curveFit( SurfaceMeshModel * part );
	NURBS::NURBSRectangled surfaceFit( SurfaceMeshModel * part );

	bool keyPressEvent( QKeyEvent* event );

	// Selection
    void drawWithNames();
    bool postSelection( const QPoint& point );

	// Groups
	QMap< QString, QVector<int> > groupFaces;
	QMap< int, QString > faceGroup;
	void loadGroupsFromOBJ();
	
	SurfaceMeshModel * extractMesh( QString gid );
	Vector3d pole( Vector3d center, double radius, SurfaceMeshModel * part );
	std::vector<Vector3d> sampleEdgeTri( Vector3d a, Vector3d b, Vector3d c );
	double minAngle(Face f, SurfaceMeshModel * ofMesh);
	std::vector<Vertex> collectRings(SurfaceMeshModel * part, Vertex v, size_t min_nb);

	void selectGroup(QString gid);

public slots:
	void clearAll();
	void saveAll();
	void loadGraph();

	void buildSamples();

	void prepareSkeletonize();
	void stepSkeletonizeMesh();

	void convertToCurve();
	void convertToSheet();

	void updateDrawArea();

	void experiment();
};