position.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 * VCGLib                                                            o o     *
00003 * Visual and Computer Graphics Library                            o     o   *
00004 *                                                                _   O  _   *
00005 * Copyright(C) 2004                                                \/)\/    *
00006 * Visual Computing Lab                                            /\/|      *
00007 * ISTI - Italian National Research Council                           |      *
00008 *                                                                    \      *
00009 * All rights reserved.                                                      *
00010 *                                                                           *
00011 * This program is free software; you can redistribute it and/or modify      *   
00012 * it under the terms of the GNU General Public License as published by      *
00013 * the Free Software Foundation; either version 2 of the License, or         *
00014 * (at your option) any later version.                                       *
00015 *                                                                           *
00016 * This program is distributed in the hope that it will be useful,           *
00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of            *
00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             *
00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)          *
00020 * for more details.                                                         *
00021 *                                                                           *
00022 ****************************************************************************/
00023 /****************************************************************************
00024   History
00025 
00026 $Log: not supported by cvs2svn $
00027 Revision 1.1  2005/07/06 08:02:27  cignoni
00028 Initial commit
00029 
00030 
00031 ****************************************************************************/
00032 #ifndef __VCG_TRI_UPDATE_POSITION
00033 #define __VCG_TRI_UPDATE_POSITION
00034 
00035 #include "normal.h"
00036 
00037 namespace vcg {
00038 namespace tri {
00039 
00041 
00043 
00045 template <class ComputeMeshType>
00046 class UpdatePosition
00047 {
00048 
00049 public:
00050 typedef ComputeMeshType MeshType; 
00051 typedef typename MeshType::ScalarType     ScalarType;
00052 typedef typename MeshType::VertexType     VertexType;
00053 typedef typename MeshType::VertexPointer  VertexPointer;
00054 typedef typename MeshType::VertexIterator VertexIterator;
00055 typedef typename MeshType::FaceType       FaceType;
00056 typedef typename MeshType::FacePointer    FacePointer;
00057 typedef typename MeshType::FaceIterator   FaceIterator;
00058 
00060 static void Matrix(ComputeMeshType &m, const Matrix44<ScalarType> &M, bool update_also_normals = true)
00061 {
00062         VertexIterator vi;
00063         for(vi=m.vert.begin();vi!=m.vert.end();++vi)
00064                 if(!(*vi).IsD()) (*vi).P()=M*(*vi).cP();
00065 
00066         if(update_also_normals){
00067                 if(HasPerVertexNormal(m)){
00068                         UpdateNormal<ComputeMeshType>::PerVertexMatrix(m,M);
00069                 }
00070                 if(HasPerFaceNormal(m)){
00071                         UpdateNormal<ComputeMeshType>::PerFaceMatrix(m,M);
00072                 }
00073         }
00074 }
00075 
00076 static void Translate(ComputeMeshType &m, const Point3<ScalarType> &t)
00077 {
00078   VertexIterator vi;
00079   for(vi=m.vert.begin();vi!=m.vert.end();++vi)
00080           if(!(*vi).IsD()) (*vi).P()+=t;
00081 }
00082 
00083 static void Scale(ComputeMeshType &m, const ScalarType s)
00084 {
00085   Scale(m,Point3<ScalarType>(s,s,s));
00086 }
00087 
00088 static void Scale(ComputeMeshType &m, const Point3<ScalarType> &s)
00089 {
00090   VertexIterator vi;
00091   for(vi=m.vert.begin();vi!=m.vert.end();++vi)
00092           if(!(*vi).IsD()) {
00093             (*vi).P()[0]*=s[0];
00094             (*vi).P()[1]*=s[1];
00095             (*vi).P()[2]*=s[2];
00096           }
00097 }
00098 
00099 }; // end class
00100 
00101 }       // End namespace
00102 }       // End namespace
00103 
00104 
00105 #endif


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:34:40