51 #include "LaplacePlugin.hh" 60 #if QT_VERSION >= 0x050000 65 #define UNIFORM_LAPLACE_NAME "Uniform Laplace Length" 66 #define UNIFORM_LAPLACE_SQUARED_NAME "Uniform Laplace Squared Length" 68 void LaplaceLengthPlugin::pluginsInitialized()
70 emit addTexture( UNIFORM_LAPLACE_NAME ,
"laplace_length.png" , 1 );
71 emit setTextureMode(UNIFORM_LAPLACE_NAME,
"clamp=true,center=true,repeat=false,clamp_min=-20,clamp_max=20");
73 emit addTexture( UNIFORM_LAPLACE_SQUARED_NAME ,
"laplace_length.png" , 1 );
74 emit setTextureMode(UNIFORM_LAPLACE_SQUARED_NAME,
"clamp=true,center=true,repeat=false,clamp_min=-20,clamp_max=20");
77 void LaplaceLengthPlugin::slotUpdateTexture( QString _textureName ,
int _identifier )
79 if ( (_textureName != UNIFORM_LAPLACE_SQUARED_NAME) && (_textureName != UNIFORM_LAPLACE_NAME ) ) {
90 if ( _textureName == UNIFORM_LAPLACE_NAME ) {
91 computeLaplaceLength(mesh);
92 emit updatedTextures(UNIFORM_LAPLACE_NAME,_identifier);
94 if ( _textureName == UNIFORM_LAPLACE_SQUARED_NAME ) {
95 computeLaplaceSquaredLength(mesh);
96 emit updatedTextures(UNIFORM_LAPLACE_SQUARED_NAME,_identifier);
102 if ( _textureName == UNIFORM_LAPLACE_NAME ) {
103 computeLaplaceLength(mesh);
104 emit updatedTextures(UNIFORM_LAPLACE_NAME,_identifier);
106 if ( _textureName == UNIFORM_LAPLACE_SQUARED_NAME ) {
107 computeLaplaceSquaredLength(mesh);
108 emit updatedTextures(UNIFORM_LAPLACE_SQUARED_NAME,_identifier);
113 template<
typename MeshT >
114 void LaplaceLengthPlugin::computeLaplaceLength(MeshT* _mesh) {
118 if(!_mesh->get_property_handle( laplace_vector_property ,
"Laplace Vector" ))
119 _mesh->add_property( laplace_vector_property,
"Laplace Vector" );
121 if(!_mesh->get_property_handle( laplace_length_property , UNIFORM_LAPLACE_NAME ))
122 _mesh->add_property( laplace_length_property, UNIFORM_LAPLACE_NAME );
127 std::vector< typename MeshT::VertexHandle > handles;
128 handles.reserve(_mesh->n_vertices());
129 for (
typename MeshT::VertexIter v_it = _mesh->vertices_begin() ; v_it != _mesh->vertices_end(); ++v_it)
130 handles.push_back( *v_it );
133 #pragma omp parallel for 135 for (
int i = 0 ; i < (int)handles.size(); ++i ) {
136 const typename MeshT::VertexHandle handle = handles[i];
139 for (
typename MeshT::VertexVertexIter vv_it(*_mesh , handle) ; vv_it.is_valid() ; ++vv_it )
140 laplace += _mesh->point(*vv_it) - _mesh->point(handle);
142 laplace = 1.0 /(double)_mesh->valence(handle) * laplace;
143 _mesh->property(laplace_vector_property,handle) = laplace;
144 _mesh->property(laplace_length_property,handle) = laplace.norm();
155 template<
typename MeshT >
156 void LaplaceLengthPlugin::computeLaplaceSquaredLength(MeshT* _mesh) {
157 computeLaplaceLength(_mesh);
162 if(!_mesh->get_property_handle( laplace_property ,
"Laplace Vector" )) {
163 std::cerr <<
"LaplaceLengthPlugin : Unable to get Laplace Vector property" << std::endl;
167 if(!_mesh->get_property_handle( laplace_squared , UNIFORM_LAPLACE_SQUARED_NAME ))
168 _mesh->add_property( laplace_squared, UNIFORM_LAPLACE_SQUARED_NAME );
172 std::vector< typename MeshT::VertexHandle > handles;
173 handles.reserve(_mesh->n_vertices());
174 for (
typename MeshT::VertexIter v_it = _mesh->vertices_begin() ; v_it != _mesh->vertices_end(); ++v_it)
175 handles.push_back( *v_it );
178 #pragma omp parallel for 180 for (
int i = 0 ; i < (int)handles.size(); ++i ) {
181 const typename MeshT::VertexHandle handle = handles[i];
184 for (
typename MeshT::VertexVertexIter vv_it(*_mesh , handle) ; vv_it.is_valid() ; ++vv_it )
185 laplace += _mesh->property(laplace_property,*vv_it) - _mesh->property(laplace_property,handle);
186 laplace = 1.0 /(double)_mesh->valence(handle) * laplace;
187 _mesh->property(laplace_squared,handle) = laplace.norm();
197 #if QT_VERSION < 0x050000
bool getObject(int _identifier, BSplineCurveObject *&_object)
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
bool dataType(DataType _type) const
#define DATA_TRIANGLE_MESH
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.