component_ep.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 #ifndef __VCG_TRI_UPDATE_EDGES
00024 #define __VCG_TRI_UPDATE_EDGES
00025 
00026 #include <vcg/space/plane3.h>
00027 
00028 namespace vcg {
00029 namespace tri {
00030 
00032 
00034         template <class ComputeMeshType>
00035         class UpdateComponentEP
00036         {
00037 
00038         public:
00039                 typedef ComputeMeshType MeshType; 
00040                 typedef typename MeshType::VertexType     VertexType;
00041                 typedef typename MeshType::VertexPointer  VertexPointer;
00042                 typedef typename MeshType::VertexIterator VertexIterator;
00043                 typedef typename MeshType::FaceType       FaceType;
00044                 typedef typename MeshType::FacePointer    FacePointer;
00045                 typedef typename MeshType::FaceIterator   FaceIterator;
00046           typedef typename MeshType::FaceType::CoordType::ScalarType     ScalarType;
00047 
00048                 static void ComputeEdgePlane(FaceType &f)
00049                 {
00050                         f.Flags() = f.Flags() & (~(FaceType::NORMX|FaceType::NORMY|FaceType::NORMZ));
00051                 
00052                         // Primo calcolo degli edges
00053                         f.Edge(0) = f.V(1)->P(); f.Edge(0) -= f.V(0)->P();
00054                         f.Edge(1) = f.V(2)->P(); f.Edge(1) -= f.V(1)->P();
00055                         f.Edge(2) = f.V(0)->P(); f.Edge(2) -= f.V(2)->P();
00056                         // Calcolo di plane
00057                         f.Plane().SetDirection(f.Edge(0)^f.Edge(1));
00058                         f.Plane().SetOffset(f.Plane().Direction().dot(f.V(0)->P()));
00059                         f.Plane().Normalize();
00060                         // Calcolo migliore proiezione
00061                         ScalarType nx = math::Abs(f.Plane().Direction()[0]);
00062                         ScalarType ny = math::Abs(f.Plane().Direction()[1]);
00063                         ScalarType nz = math::Abs(f.Plane().Direction()[2]);
00064                         ScalarType d;
00065                         if(nx>ny && nx>nz) { f.Flags() |= FaceType::NORMX; d = 1/f.Plane().Direction()[0]; }
00066                         else if(ny>nz)     { f.Flags() |= FaceType::NORMY; d = 1/f.Plane().Direction()[1]; }
00067                         else               { f.Flags() |= FaceType::NORMZ; d = 1/f.Plane().Direction()[2]; }
00068 
00069                         // Scalatura spigoli
00070                         f.Edge(0)*=d;
00071                         f.Edge(1)*=d;
00072                         f.Edge(2)*=d;
00073                 }
00074 
00075                 static void Set(ComputeMeshType &m)
00076                 {
00077                   if(!FaceType::HasEdgePlane()) throw vcg::MissingComponentException("PerFaceEdgePlane");
00078                         for(FaceIterator f = m.face.begin(); f!=m.face.end(); ++f)
00079                                 if(!(*f).IsD())
00080                                         ComputeEdgePlane(*f);
00081                 }
00082 
00083         }; // end class
00084 
00085 }       // End namespace
00086 }       // End namespace
00087 
00088 
00089 #endif


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