2
// Copyright (c) 1995-2004, Timothy M. Shead
4
// Contact: tshead@k-3d.com
6
// This program is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public
8
// License as published by the Free Software Foundation; either
9
// version 2 of the License, or (at your option) any later version.
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
16
// You should have received a copy of the GNU General Public
17
// License along with this program; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
\author Timothy M. Shead (tshead@k-3d.com)
22
\author Romain Behar (romainbehar@yahoo.com)
25
#include <k3dsdk/classes.h>
26
#include <k3dsdk/measurement.h>
27
#include <k3dsdk/object.h>
28
#include <k3dsdk/persistence.h>
29
#include <k3dsdk/mesh.h>
30
#include <k3dsdk/mesh_filter.h>
31
#include <k3dsdk/module.h>
32
#include <k3dsdk/plugins.h>
37
/////////////////////////////////////////////////////////////////////////////
38
// select_point_by_number_implementation
40
class select_point_by_number_implementation :
41
public k3d::mesh_filter<k3d::persistent<k3d::object> >
43
typedef k3d::mesh_filter<k3d::persistent<k3d::object> > base;
46
select_point_by_number_implementation(k3d::idocument& Document) :
48
m_index(k3d::init_name("index") + k3d::init_description("Point index [number]") + k3d::init_value(0UL) + k3d::init_precision(0) + k3d::init_step_increment(1) + k3d::init_units(typeid(k3d::measurement::scalar)) + k3d::init_document(Document))
50
register_property(m_index);
52
m_input_mesh.changed_signal().connect(SigC::slot(*this, &select_point_by_number_implementation::on_reset_geometry));
53
m_index.changed_signal().connect(SigC::slot(*this, &select_point_by_number_implementation::on_reset_geometry));
54
m_output_mesh.need_data_signal().connect(SigC::slot(*this, &select_point_by_number_implementation::on_create_geometry));
57
void on_reset_geometry()
59
m_output_mesh.reset();
62
k3d::mesh* on_create_geometry()
64
// Get the input geometry ...
65
k3d::mesh* const input = m_input_mesh.property_value();
69
// Create output geometry ...
70
k3d::mesh* const output = new k3d::mesh();
71
k3d::deep_copy(*input, *output);
73
const unsigned long index = m_index.property_value();
75
for(k3d::mesh::points_t::const_iterator point = output->points.begin(); point != output->points.end(); ++point)
76
k3d::deselect(document(), k3d::deep_selection(document().dag(), k3d::make_selection(**point)));
78
if(index < output->points.size())
79
k3d::select(document(), k3d::deep_selection(document().dag(), k3d::make_selection(*(output->points[index]))));
84
k3d::iplugin_factory& factory()
89
static k3d::iplugin_factory& get_factory()
91
static k3d::plugin_factory<
92
k3d::document_plugin<select_point_by_number_implementation>,
93
k3d::interface_list<k3d::imesh_source,
94
k3d::interface_list<k3d::imesh_sink > > > factory(
95
k3d::uuid(0xded6d3a7, 0x65fc4d6d, 0x8b7afff7, 0xdd0785ad),
96
"SelectPointByNumber",
97
"Selects a point from the input mesh by its index number",
99
k3d::iplugin_factory::EXPERIMENTAL);
105
k3d_measurement_property(unsigned long, k3d::immutable_name, k3d::change_signal, k3d::with_undo, k3d::local_storage, k3d::no_constraint) m_index;
108
/////////////////////////////////////////////////////////////////////////////
109
// select_point_by_number_factory
111
k3d::iplugin_factory& select_point_by_number_factory()
113
return select_point_by_number_implementation::get_factory();
116
} // namespace libk3dmesh