Commit 1176841a authored by Mike Kremer's avatar Mike Kremer

Added function for the transformation of all handle vertices.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13020 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 3ba863de
......@@ -63,6 +63,7 @@
#include <iostream>
#include <OpenMesh/Core/Geometry/MathDefs.hh>
#include <ObjectTypes/TriangleMesh/TriangleMesh.hh>
//== NAMESPACES ===============================================================
......@@ -243,11 +244,11 @@ void transformMesh(ACG::Matrix4x4d _matrix , MeshT& _mesh) {
_mesh.set_point(v_it, _matrix.transform_point(_mesh.point(v_it)));
// Transform the vertex normal
typename MeshT::Normal n = invTranspMat.transform_vector(_mesh.normal(v_it));
n.normalize();
_mesh.set_normal(v_it, n);
if(_mesh.has_vertex_normals()) {
typename MeshT::Normal n = invTranspMat.transform_vector(_mesh.normal(v_it));
n.normalize();
_mesh.set_normal(v_it, n);
}
}
typename MeshT::FaceIter f_it = _mesh.faces_begin();
......@@ -255,11 +256,44 @@ void transformMesh(ACG::Matrix4x4d _matrix , MeshT& _mesh) {
for (; f_it != f_end; ++f_it) {
// Transform the face normal
typename MeshT::Normal n = invTranspMat.transform_vector(_mesh.normal(f_it));
if(_mesh.has_face_normals()) {
typename MeshT::Normal n = invTranspMat.transform_vector(_mesh.normal(f_it));
n.normalize();
_mesh.set_normal(f_it, n);
}
}
}
template< typename MeshT >
void transformHandleVertices(ACG::Matrix4x4d _matrix , MeshT& _mesh) {
// Get the inverse matrix of the transformation for the normals
ACG::Matrix4x4d invTranspMat = _matrix;
// Build inverse transposed matrix of _matrix
invTranspMat.invert();
invTranspMat.transpose();
typename MeshT::VertexIter v_it = _mesh.vertices_begin();
typename MeshT::VertexIter v_end = _mesh.vertices_end();
for (; v_it != v_end; ++v_it) {
if(!_mesh.status(v_it).is_bit_set(HANDLEAREA)) continue;
n.normalize();
// Transform the mesh vertex
_mesh.set_point(v_it, _matrix.transform_point(_mesh.point(v_it)));
// Transform the vertex normal
if(_mesh.has_vertex_normals()) {
typename MeshT::Normal n = invTranspMat.transform_vector(_mesh.normal(v_it));
n.normalize();
_mesh.set_normal(v_it, n);
}
}
_mesh.set_normal(f_it, n);
// Transform the face normal
if(_mesh.has_face_normals()) {
_mesh.update_face_normals();
}
}
......
......@@ -157,6 +157,14 @@ calc_angle_around( const MeshT& _mesh , const typename MeshT::VertexHandle _vh);
template< typename MeshT >
void transformMesh(ACG::Matrix4x4d _matrix , MeshT& _mesh);
/**
* Transform handle vertices only
* @param _matrix The transformation matrix
* @param _mesh The mesh that is to be transformed
*/
template< typename MeshT >
void transformHandleVertices(ACG::Matrix4x4d _matrix , MeshT& _mesh);
//=============================================================================
} // MeshFunctions Namespace
//=============================================================================
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment