45 #include "LaplacePlugin.hh" 51 #include <QElapsedTimer> 57 #define UNIFORM_LAPLACE_NAME "Uniform Laplace Length" 58 #define UNIFORM_LAPLACE_SQUARED_NAME "Uniform Laplace Squared Length" 60 void LaplaceLengthPlugin::pluginsInitialized()
62 emit addTexture( UNIFORM_LAPLACE_NAME ,
"laplace_length.png" , 1 );
63 emit setTextureMode(UNIFORM_LAPLACE_NAME,
"clamp=true,center=true,repeat=false,clamp_min=-20,clamp_max=20");
65 emit addTexture( UNIFORM_LAPLACE_SQUARED_NAME ,
"laplace_length.png" , 1 );
66 emit setTextureMode(UNIFORM_LAPLACE_SQUARED_NAME,
"clamp=true,center=true,repeat=false,clamp_min=-20,clamp_max=20");
69 void LaplaceLengthPlugin::slotUpdateTexture( QString _textureName ,
int _identifier )
71 if ( (_textureName != UNIFORM_LAPLACE_SQUARED_NAME) && (_textureName != UNIFORM_LAPLACE_NAME ) ) {
82 if ( _textureName == UNIFORM_LAPLACE_NAME ) {
83 computeLaplaceLength(mesh);
84 emit updatedTextures(UNIFORM_LAPLACE_NAME,_identifier);
86 if ( _textureName == UNIFORM_LAPLACE_SQUARED_NAME ) {
87 computeLaplaceSquaredLength(mesh);
88 emit updatedTextures(UNIFORM_LAPLACE_SQUARED_NAME,_identifier);
94 if ( _textureName == UNIFORM_LAPLACE_NAME ) {
95 computeLaplaceLength(mesh);
96 emit updatedTextures(UNIFORM_LAPLACE_NAME,_identifier);
98 if ( _textureName == UNIFORM_LAPLACE_SQUARED_NAME ) {
99 computeLaplaceSquaredLength(mesh);
100 emit updatedTextures(UNIFORM_LAPLACE_SQUARED_NAME,_identifier);
105 template<
typename MeshT >
106 void LaplaceLengthPlugin::computeLaplaceLength(MeshT* _mesh) {
110 if(!_mesh->get_property_handle( laplace_vector_property ,
"Laplace Vector" ))
111 _mesh->add_property( laplace_vector_property,
"Laplace Vector" );
113 if(!_mesh->get_property_handle( laplace_length_property , UNIFORM_LAPLACE_NAME ))
114 _mesh->add_property( laplace_length_property, UNIFORM_LAPLACE_NAME );
119 std::vector< typename MeshT::VertexHandle > handles;
120 handles.reserve(_mesh->n_vertices());
121 for (
typename MeshT::VertexIter v_it = _mesh->vertices_begin() ; v_it != _mesh->vertices_end(); ++v_it)
122 handles.push_back( *v_it );
125 #pragma omp parallel for 127 for (
int i = 0 ; i < (int)handles.size(); ++i ) {
128 const typename MeshT::VertexHandle handle = handles[i];
131 for (
typename MeshT::VertexVertexIter vv_it(*_mesh , handle) ; vv_it.is_valid() ; ++vv_it )
132 laplace += _mesh->point(*vv_it) - _mesh->point(handle);
134 laplace = 1.0 /(double)_mesh->valence(handle) * laplace;
135 _mesh->property(laplace_vector_property,handle) = laplace;
136 _mesh->property(laplace_length_property,handle) = laplace.norm();
147 template<
typename MeshT >
148 void LaplaceLengthPlugin::computeLaplaceSquaredLength(MeshT* _mesh) {
149 computeLaplaceLength(_mesh);
154 if(!_mesh->get_property_handle( laplace_property ,
"Laplace Vector" )) {
155 std::cerr <<
"LaplaceLengthPlugin : Unable to get Laplace Vector property" << std::endl;
159 if(!_mesh->get_property_handle( laplace_squared , UNIFORM_LAPLACE_SQUARED_NAME ))
160 _mesh->add_property( laplace_squared, UNIFORM_LAPLACE_SQUARED_NAME );
164 std::vector< typename MeshT::VertexHandle > handles;
165 handles.reserve(_mesh->n_vertices());
166 for (
typename MeshT::VertexIter v_it = _mesh->vertices_begin() ; v_it != _mesh->vertices_end(); ++v_it)
167 handles.push_back( *v_it );
170 #pragma omp parallel for 172 for (
int i = 0 ; i < (int)handles.size(); ++i ) {
173 const typename MeshT::VertexHandle handle = handles[i];
176 for (
typename MeshT::VertexVertexIter vv_it(*_mesh , handle) ; vv_it.is_valid() ; ++vv_it )
177 laplace += _mesh->property(laplace_property,*vv_it) - _mesh->property(laplace_property,handle);
178 laplace = 1.0 /(double)_mesh->valence(handle) * laplace;
179 _mesh->property(laplace_squared,handle) = laplace.norm();
#define DATA_TRIANGLE_MESH
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
bool dataType(DataType _type) const