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 2006/12/10 19:59:28 ganovelli 00028 first draft of the class the draw a Pos 00029 00030 00031 00032 ****************************************************************************/ 00033 00034 #ifndef VCG_GL_POS_H 00035 #define VCG_GL_POS_H 00036 00037 // Please note that this file assume that you have already included your 00038 // gl-extension wrapping utility, and that therefore all the extension symbol are already defined. 00039 00040 #include <vcg/simplex/face/pos.h> 00041 #include <vcg/space/triangle3.h> 00042 00043 namespace vcg { 00044 00045 template<class PosType> 00046 struct GlPos{ 00047 typedef typename PosType::ScalarType S; 00048 static void Draw(PosType & p){ 00049 Point3<S> bc = Barycenter(*(p.f)); 00050 Point3<S> mid = (p.f->P(p.z)+p.f->P(((p.z+1)%3)))*0.5f; 00051 Point3<S> up = ((bc- p.v->P()) ^ (mid- p.f->P(p.z) )).Normalize(); 00052 Point3<S> ax = ( up ^ (mid-p.f->P(p.z)) ) .Normalize(); 00053 S proj = (bc-mid)*(ax)*0.5; 00054 Point3<S> bc1 = mid+ (ax)*proj; 00055 00056 00057 glBegin(GL_TRIANGLES); 00058 glVertex(p.v->P()); 00059 if( p.v == p.f->V(p.z)) 00060 { glVertex(mid); glVertex(bc1);} 00061 else 00062 {glVertex(bc1); glVertex(mid);} 00063 glEnd(); 00064 } 00065 }; 00066 00067 template<class VfIteType> 00068 struct GlVfIterator{ 00069 typedef typename VfIteType::ScalarType S; 00070 static void Draw(VfIteType & v){ 00071 Point3<S> p = v.F()->P(v.I());// anchor 00072 Point3<S> c[3]; 00073 for(int i = 0; i < 3;++i) 00074 { 00075 c[i] = v.F()->P(i)*0.9 + v.F()->P1(i)*0.05 + v.F()->P2(i)*0.05; 00076 if(v.F()->VFp(i) != NULL) 00077 { 00078 glBegin(GL_LINES); 00079 glVertex(c[i]); 00080 glVertex( vcg::Barycenter(*(v.F()->VFp(i)))); 00081 glEnd(); 00082 } 00083 } 00084 } 00085 }; 00086 00087 }//namespace 00088 #endif