34 #include "SmootherPlugin.hh"
42 SmootherPlugin::SmootherPlugin() :
48 void SmootherPlugin::initializePlugin()
51 QWidget* toolBox =
new QWidget();
53 QPushButton* smoothButton =
new QPushButton(
"&Smooth", toolBox);
60 QLabel* label =
new QLabel(
"Iterations:");
62 QGridLayout* layout =
new QGridLayout(toolBox);
64 layout->addWidget(label, 0, 0);
65 layout->addWidget(smoothButton, 1, 1);
68 layout->addItem(
new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding), 2, 0, 1, 2);
70 connect(smoothButton, SIGNAL(clicked()),
this, SLOT(
simpleLaplace()));
72 emit addToolbox(tr(
"Smoother"), toolBox);
93 mesh->add_property(origPositions,
"SmootherPlugin_Original_Positions");
98 TriMesh::VertexIter v_it, v_end = mesh->vertices_end();
99 for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
100 mesh->property(origPositions, v_it) = mesh->point(v_it);
104 for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
106 TriMesh::Point point = TriMesh::Point(0.0, 0.0, 0.0);
112 TriMesh::VertexOHalfedgeIter voh_it(*mesh, v_it);
114 for (; voh_it; ++voh_it) {
117 point += mesh->property(origPositions, mesh->to_vertex_handle(voh_it));
121 if (mesh->is_boundary(*voh_it)) {
128 point /= mesh->valence(v_it);
132 mesh->point(v_it) = point;
139 mesh->remove_property(origPositions);
141 mesh->update_normals();
154 mesh->add_property(origPositions,
"SmootherPlugin_Original_Positions");
159 PolyMesh::VertexIter v_it, v_end = mesh->vertices_end();
160 for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
161 mesh->property(origPositions, v_it) = mesh->point(v_it);
165 for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
174 for (; voh_it; ++voh_it) {
176 point += mesh->property(origPositions, mesh->to_vertex_handle(voh_it));
180 if (mesh->is_boundary(*voh_it)) {
188 point /= mesh->valence(v_it);
192 mesh->point(v_it) = point;
199 mesh->remove_property(origPositions);
207 emit log(
LOGERR,
"Data type not supported.");
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
Kernel::Point Point
Coordinate type.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
void simpleLaplace()
simpleLaplace
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
void update_normals()
Compute normals for all primitives.
QSpinBox * iterationsSpinbox_
SpinBox for Number of iterations.
#define DATA_TRIANGLE_MESH