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"
60void 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");
69void 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);
105template<
typename MeshT >
106void 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 OpenMesh::SmartVertexHandle > handles;
121 for (
auto v_it : _mesh->vertices())
122 handles.push_back( v_it );
125 #pragma omp parallel for
127 for (
int i = 0 ; i < (int)handles.size(); ++i ) {
131 for (
auto vv_it : handle.vertices() )
132 laplace += _mesh->point(vv_it) - _mesh->point(handle);
134 laplace = 1.0 /(double)handle.
valence()* laplace;
135 _mesh->property(laplace_vector_property,handle) = laplace;
136 _mesh->property(laplace_length_property,handle) = laplace.norm();
147template<
typename MeshT >
148void 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 OpenMesh::SmartVertexHandle > handles;
166 for (
auto v_it : _mesh->vertices())
167 handles.push_back( v_it );
170 #pragma omp parallel for
172 for (
int i = 0 ; i < (int)handles.size(); ++i ) {
176 for (
auto vv_it : handle.vertices() )
177 laplace += _mesh->property(laplace_property,vv_it) - _mesh->property(laplace_property,handle);
178 laplace = 1.0 /(double)handle.
valence() * laplace;
179 _mesh->property(laplace_squared,handle) = laplace.norm();
#define DATA_TRIANGLE_MESH
bool dataType(DataType _type) const
size_t n_vertices() const override
Get number of vertices in mesh.
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.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
Smart version of VertexHandle contains a pointer to the corresponding mesh and allows easier access t...
uint valence() const
Returns valence of the vertex.