45 #include "LaplacePlugin.hh" 55 #define UNIFORM_LAPLACE_NAME "Uniform Laplace Length" 56 #define UNIFORM_LAPLACE_SQUARED_NAME "Uniform Laplace Squared Length" 58 void LaplaceLengthPlugin::pluginsInitialized()
60 emit addTexture( UNIFORM_LAPLACE_NAME ,
"laplace_length.png" , 1 );
61 emit setTextureMode(UNIFORM_LAPLACE_NAME,
"clamp=true,center=true,repeat=false,clamp_min=-20,clamp_max=20");
63 emit addTexture( UNIFORM_LAPLACE_SQUARED_NAME ,
"laplace_length.png" , 1 );
64 emit setTextureMode(UNIFORM_LAPLACE_SQUARED_NAME,
"clamp=true,center=true,repeat=false,clamp_min=-20,clamp_max=20");
67 void LaplaceLengthPlugin::slotUpdateTexture( QString _textureName ,
int _identifier )
69 if ( (_textureName != UNIFORM_LAPLACE_SQUARED_NAME) && (_textureName != UNIFORM_LAPLACE_NAME ) ) {
80 if ( _textureName == UNIFORM_LAPLACE_NAME ) {
81 computeLaplaceLength(mesh);
82 emit updatedTextures(UNIFORM_LAPLACE_NAME,_identifier);
84 if ( _textureName == UNIFORM_LAPLACE_SQUARED_NAME ) {
85 computeLaplaceSquaredLength(mesh);
86 emit updatedTextures(UNIFORM_LAPLACE_SQUARED_NAME,_identifier);
92 if ( _textureName == UNIFORM_LAPLACE_NAME ) {
93 computeLaplaceLength(mesh);
94 emit updatedTextures(UNIFORM_LAPLACE_NAME,_identifier);
96 if ( _textureName == UNIFORM_LAPLACE_SQUARED_NAME ) {
97 computeLaplaceSquaredLength(mesh);
98 emit updatedTextures(UNIFORM_LAPLACE_SQUARED_NAME,_identifier);
103 template<
typename MeshT >
104 void LaplaceLengthPlugin::computeLaplaceLength(MeshT* _mesh) {
108 if(!_mesh->get_property_handle( laplace_vector_property ,
"Laplace Vector" ))
109 _mesh->add_property( laplace_vector_property,
"Laplace Vector" );
111 if(!_mesh->get_property_handle( laplace_length_property , UNIFORM_LAPLACE_NAME ))
112 _mesh->add_property( laplace_length_property, UNIFORM_LAPLACE_NAME );
117 std::vector< typename MeshT::VertexHandle > handles;
118 handles.reserve(_mesh->n_vertices());
119 for (
typename MeshT::VertexIter v_it = _mesh->vertices_begin() ; v_it != _mesh->vertices_end(); ++v_it)
120 handles.push_back( *v_it );
123 #pragma omp parallel for 125 for (
int i = 0 ; i < (int)handles.size(); ++i ) {
126 const typename MeshT::VertexHandle handle = handles[i];
129 for (
typename MeshT::VertexVertexIter vv_it(*_mesh , handle) ; vv_it.is_valid() ; ++vv_it )
130 laplace += _mesh->point(*vv_it) - _mesh->point(handle);
132 laplace = 1.0 /(double)_mesh->valence(handle) * laplace;
133 _mesh->property(laplace_vector_property,handle) = laplace;
134 _mesh->property(laplace_length_property,handle) = laplace.norm();
145 template<
typename MeshT >
146 void LaplaceLengthPlugin::computeLaplaceSquaredLength(MeshT* _mesh) {
147 computeLaplaceLength(_mesh);
152 if(!_mesh->get_property_handle( laplace_property ,
"Laplace Vector" )) {
153 std::cerr <<
"LaplaceLengthPlugin : Unable to get Laplace Vector property" << std::endl;
157 if(!_mesh->get_property_handle( laplace_squared , UNIFORM_LAPLACE_SQUARED_NAME ))
158 _mesh->add_property( laplace_squared, UNIFORM_LAPLACE_SQUARED_NAME );
162 std::vector< typename MeshT::VertexHandle > handles;
163 handles.reserve(_mesh->n_vertices());
164 for (
typename MeshT::VertexIter v_it = _mesh->vertices_begin() ; v_it != _mesh->vertices_end(); ++v_it)
165 handles.push_back( *v_it );
168 #pragma omp parallel for 170 for (
int i = 0 ; i < (int)handles.size(); ++i ) {
171 const typename MeshT::VertexHandle handle = handles[i];
174 for (
typename MeshT::VertexVertexIter vv_it(*_mesh , handle) ; vv_it.is_valid() ; ++vv_it )
175 laplace += _mesh->property(laplace_property,*vv_it) - _mesh->property(laplace_property,handle);
176 laplace = 1.0 /(double)_mesh->valence(handle) * laplace;
177 _mesh->property(laplace_squared,handle) = laplace.norm();
bool dataType(DataType _type) const
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
#define DATA_TRIANGLE_MESH