Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

subdivideSurface.cpp 2.5 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include "subdivideSurface.h"

#include "mapHandler.h"

#include "Algo/Modelisation/subdivision.h"

bool SubdivideSurfacePlugin::enable()
{
	m_subdivideSurfaceDialog = new SubdivideSurfaceDialog(m_window);

	m_subdivideSurfaceAction = new QAction("Subdivide surface", this);

	addMenuAction("Surface;Subdivide", m_subdivideSurfaceAction);

15
	connect(m_subdivideSurfaceAction, SIGNAL(triggered()), this, SLOT(openSubdivideSurfaceDialog()));
16

17
18
	connect(m_subdivideSurfaceDialog, SIGNAL(accepted()), this, SLOT(subdivideSurface()));
	connect(m_subdivideSurfaceDialog->button_apply, SIGNAL(clicked()), this, SLOT(subdivideSurface()));
19
20
21
22

	return true;
}

23
void SubdivideSurfacePlugin::openSubdivideSurfaceDialog()
24
25
26
27
{
	m_subdivideSurfaceDialog->show();
}

28
void SubdivideSurfacePlugin::subdivideSurface()
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
	QList<QListWidgetItem*> currentItems = m_subdivideSurfaceDialog->mapList->selectedItems();
	if(!currentItems.empty())
	{
		const QString& mapname = currentItems[0]->text();
		MapHandler<PFP2>* mh = static_cast<MapHandler<PFP2>*>(m_window->getMap(mapname));
		PFP2::MAP* map = mh->getMap();

		std::string positionName = m_subdivideSurfaceDialog->combo_positionAttribute->currentText().toUtf8().constData();
		VertexAttribute<PFP2::VEC3> position = map->getAttribute<PFP2::VEC3, VERTEX>(positionName);

		if(m_subdivideSurfaceDialog->radio_Loop->isChecked())
			loopSubdivision(map, position);
		else if(m_subdivideSurfaceDialog->radio_CC->isChecked())
			CCSubdivision(map, position);
		else if(m_subdivideSurfaceDialog->radio_trianguleFaces->isChecked())
			trianguleFaces(map, position);

47
48
49
50
		mh->setPrimitiveDirty(Algo::Render::GL2::POINTS);
		mh->setPrimitiveDirty(Algo::Render::GL2::LINES);
		mh->setPrimitiveDirty(Algo::Render::GL2::TRIANGLES);

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
		mh->updateVBO(position);

		QList<View*> views = mh->getLinkedViews();
		foreach(View* view, views)
			view->updateGL();
	}
}

void SubdivideSurfacePlugin::loopSubdivision(PFP2::MAP* map, VertexAttribute<PFP2::VEC3>& position)
{
	Algo::Surface::Modelisation::LoopSubdivision<PFP2>(*map, position);
}

void SubdivideSurfacePlugin::CCSubdivision(PFP2::MAP* map, VertexAttribute<PFP2::VEC3>& position)
{
	Algo::Surface::Modelisation::CatmullClarkSubdivision<PFP2>(*map, position);
}

void SubdivideSurfacePlugin::trianguleFaces(PFP2::MAP* map, VertexAttribute<PFP2::VEC3>& position)
{
	Algo::Surface::Modelisation::trianguleFaces<PFP2>(*map, position);
}

#ifndef DEBUG
Q_EXPORT_PLUGIN2(SubdivideSurfacePlugin, SubdivideSurfacePlugin)
#else
Q_EXPORT_PLUGIN2(SubdivideSurfacePluginD, SubdivideSurfacePlugin)
#endif