31 #include "SmootherPlugin.hh" 39 SmootherPlugin::SmootherPlugin() :
45 void SmootherPlugin::initializePlugin()
48 QWidget* toolBox =
new QWidget();
50 QPushButton* smoothButton =
new QPushButton(
"&Smooth", toolBox);
52 iterationsSpinbox_ =
new QSpinBox(toolBox);
53 iterationsSpinbox_->setMinimum(1);
54 iterationsSpinbox_->setMaximum(1000);
55 iterationsSpinbox_->setSingleStep(1);
57 QLabel* label =
new QLabel(
"Iterations:");
59 QGridLayout* layout =
new QGridLayout(toolBox);
61 layout->addWidget(label, 0, 0);
62 layout->addWidget(smoothButton, 1, 1);
63 layout->addWidget(iterationsSpinbox_, 0, 1);
65 layout->addItem(
new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Expanding), 2, 0, 1, 2);
67 connect(smoothButton, SIGNAL(clicked()),
this, SLOT(simpleLaplace()));
69 emit addToolbox(tr(
"Smoother"), toolBox);
90 mesh->add_property(origPositions,
"SmootherPlugin_Original_Positions");
92 for (
int i = 0; i < iterationsSpinbox_->value(); ++i) {
95 TriMesh::VertexIter v_it, v_end = mesh->vertices_end();
96 for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
97 mesh->property(origPositions, v_it) = mesh->point(v_it);
101 for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
103 TriMesh::Point point = TriMesh::Point(0.0, 0.0, 0.0);
109 TriMesh::VertexOHalfedgeIter voh_it(*mesh, v_it);
111 for (; voh_it; ++voh_it) {
114 point += mesh->property(origPositions, mesh->to_vertex_handle(voh_it));
118 if (mesh->is_boundary(*voh_it)) {
125 point /= mesh->valence(v_it);
129 mesh->point(v_it) = point;
136 mesh->remove_property(origPositions);
138 mesh->update_normals();
151 mesh->add_property(origPositions,
"SmootherPlugin_Original_Positions");
153 for (
int i = 0; i < iterationsSpinbox_->value(); ++i) {
156 PolyMesh::VertexIter v_it, v_end = mesh->vertices_end();
157 for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
158 mesh->property(origPositions, v_it) = mesh->point(v_it);
162 for (v_it = mesh->vertices_begin(); v_it != v_end; ++v_it) {
164 PolyMesh::Point point = PolyMesh::Point(0.0, 0.0, 0.0);
170 PolyMesh::VertexOHalfedgeIter voh_it(*mesh, v_it);
171 for (; voh_it; ++voh_it) {
173 point += mesh->property(origPositions, mesh->to_vertex_handle(voh_it));
177 if (mesh->is_boundary(*voh_it)) {
185 point /= mesh->valence(v_it);
189 mesh->point(v_it) = point;
196 mesh->remove_property(origPositions);
198 mesh->update_normals();
204 emit log(
LOGERR,
"Data type not supported.");
const QStringList TARGET_OBJECTS("target")
Iterable object range.
virtual void updatedObject(int _objectId)
An object has been changed or added by this plugin.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
#define DATA_TRIANGLE_MESH
void simpleLaplace()
simpleLaplace