File: cuda_mesh_simple_deformation_modifier.cpp

package info (click to toggle)
k3d 0.8.0.2-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 40,692 kB
  • ctags: 39,695
  • sloc: cpp: 171,303; ansic: 24,129; xml: 6,995; python: 5,796; makefile: 726; sh: 22
file content (79 lines) | stat: -rw-r--r-- 3,021 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
79
// K-3D
// Copyright (c) 1995-2008, Timothy M. Shead
//
// Contact: tshead@k-3d.com
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

/** \file
	\author Timothy M. Shead (tshead@k-3d.com)
	\author Evan Lezar (evanlezar@gmail.com)
 */


#include "cuda_mesh_simple_deformation_modifier.h"

namespace k3d
{

cuda_mesh_simple_deformation_modifier::cuda_mesh_simple_deformation_modifier(iplugin_factory& Factory, idocument& Document) :
	base(Factory, Document),
	m_selection_changed(true),
	m_p_input_device_mesh(init_owner(*this) + init_name("input_device_mesh") + init_label(_("Input Device Mesh")) + init_description(_("Pointer to device mesh")) + init_value<cuda_device_mesh*>(0))
{
	m_mesh_selection.changed_signal().connect(sigc::mem_fun(*this, &cuda_mesh_simple_deformation_modifier::on_selection_changed));
	m_p_input_device_mesh.changed_signal().connect(make_reset_mesh_slot());
}

void cuda_mesh_simple_deformation_modifier::on_create_mesh(const mesh& Input, mesh& Output)
{
	k3d::log() << debug << "cuda_mesh_simple_deformation_modifier::on_create_mesh" << std::endl;

	k3d::log() << debug << "Device Pointer : " << m_p_input_device_mesh.internal_value() << std::endl;
	m_p_input_device_mesh.pipeline_value()->output_debug_info();

	//Output = Input;

	m_selection_changed = true; // make sure we merge selection after the mesh has been recreated
	k3d::log() << debug << "cuda_mesh_simple_deformation_modifier::on_create_mesh::DONE" << std::endl;
}

void cuda_mesh_simple_deformation_modifier::on_update_mesh(const mesh& Input, mesh& Output)
{
	k3d::log() << debug << "cuda_mesh_simple_deformation_modifier::on_update_mesh" << std::endl;

	m_p_input_device_mesh.pipeline_value()->output_debug_info();

	if(m_selection_changed)
	{
		// simply select all the points on the device mesh
		m_p_input_device_mesh.pipeline_value()->select_all_points();
		m_selection_changed = false;
	}

	on_deform_mesh(Output);

	k3d::log() << debug << "cuda_mesh_simple_deformation_modifier::on_update_mesh::DONE" << std::endl;
}

void cuda_mesh_simple_deformation_modifier::on_selection_changed(ihint* Hint)
{
	k3d::log() << debug << "cuda_mesh_simple_deformation_modifier::on_selection_changed" << std::endl;
	m_selection_changed = true;
	k3d::log() << debug << "cuda_mesh_simple_deformation_modifier::on_selection_changed::DONE" << std::endl;
}

} // namespace k3d