VCG Library
position.h
1 /****************************************************************************
2 * VCGLib o o *
3 * Visual and Computer Graphics Library o o *
4 * _ O _ *
5 * Copyright(C) 2004-2016 \/)\/ *
6 * Visual Computing Lab /\/| *
7 * ISTI - Italian National Research Council | *
8 * \ *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
20 * for more details. *
21 * *
22 ****************************************************************************/
23 /****************************************************************************
24  History
25 
26 $Log: not supported by cvs2svn $
27 Revision 1.1 2005/07/06 08:02:27 cignoni
28 Initial commit
29 
30 
31 ****************************************************************************/
32 #ifndef __VCG_TRI_UPDATE_POSITION
33 #define __VCG_TRI_UPDATE_POSITION
34 
35 #include "normal.h"
36 
37 namespace vcg {
38 namespace tri {
39 
41 
43 
45 template <class ComputeMeshType>
47 {
48 
49 public:
50 typedef ComputeMeshType MeshType;
51 typedef typename MeshType::ScalarType ScalarType;
52 typedef typename MeshType::VertexType VertexType;
53 typedef typename MeshType::VertexPointer VertexPointer;
54 typedef typename MeshType::VertexIterator VertexIterator;
55 typedef typename MeshType::FaceType FaceType;
56 typedef typename MeshType::FacePointer FacePointer;
57 typedef typename MeshType::FaceIterator FaceIterator;
58 
60 static void Matrix(ComputeMeshType &m, const Matrix44<ScalarType> &M, bool update_also_normals = true)
61 {
62  VertexIterator vi;
63  for(vi=m.vert.begin();vi!=m.vert.end();++vi)
64  if(!(*vi).IsD()) (*vi).P()=M*(*vi).cP();
65 
66  if(update_also_normals){
67  if(HasPerVertexNormal(m)){
69  }
70  if(HasPerFaceNormal(m)){
72  }
73  }
74 }
75 
76 static void Translate(ComputeMeshType &m, const Point3<ScalarType> &t)
77 {
78  VertexIterator vi;
79  for(vi=m.vert.begin();vi!=m.vert.end();++vi)
80  if(!(*vi).IsD()) (*vi).P()+=t;
81 }
82 
83 static void Scale(ComputeMeshType &m, const ScalarType s)
84 {
85  Scale(m,Point3<ScalarType>(s,s,s));
86 }
87 
88 static void Scale(ComputeMeshType &m, const Point3<ScalarType> &s)
89 {
90  VertexIterator vi;
91  for(vi=m.vert.begin();vi!=m.vert.end();++vi)
92  if(!(*vi).IsD()) {
93  (*vi).P()[0]*=s[0];
94  (*vi).P()[1]*=s[1];
95  (*vi).P()[2]*=s[2];
96  }
97 }
98 
99 }; // end class
100 
101 } // End namespace
102 } // End namespace
103 
104 
105 #endif