34 #include "SmootherPlugin.hh" 42 SmootherPlugin::SmootherPlugin() :
48 void SmootherPlugin::initializePlugin()
51 QWidget* toolBox =
new QWidget();
53 QPushButton* smoothButton =
new QPushButton(
"&Smooth", toolBox);
55 iterationsSpinbox_ =
new QSpinBox(toolBox);
56 iterationsSpinbox_->setMinimum(1);
57 iterationsSpinbox_->setMaximum(1000);
58 iterationsSpinbox_->setSingleStep(1);
60 QLabel* label =
new QLabel(
"Iterations:");
62 QGridLayout* layout =
new QGridLayout(toolBox);
64 layout->addWidget(label, 0, 0);
65 layout->addWidget(smoothButton, 1, 1);
66 layout->addWidget(iterationsSpinbox_, 0, 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");
95 for (
int i = 0; i < iterationsSpinbox_->value(); ++i) {
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) {
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);
154 mesh->add_property(origPositions,
"SmootherPlugin_Original_Positions");
156 for (
int i = 0; i < iterationsSpinbox_->value(); ++i) {
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.");
virtual void updatedObject(int _objectId)
An object has been changed or added by this plugin.
void update_normals()
Compute normals for all primitives.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
Kernel::VertexOHalfedgeIter VertexOHalfedgeIter
Circulator.
Kernel::Point Point
Coordinate type.
#define DATA_TRIANGLE_MESH
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
void simpleLaplace()
simpleLaplace