Debian Codegraph @

vcg/wrap/gl/pos.h

raw symbols SCIP
1 /****************************************************************************
2 * VCGLib o o *
3 * Visual and Computer Graphics Library o o *
4 * _ O _ *
5 * Copyright(C) 2004 \/)\/ *
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: pos.h,v $
27 Revision 1.2 2007/05/08 18:55:14 ganovelli
28 adde vf iterator
29
30 Revision 1.1 2006/12/10 19:59:28 ganovelli
31 first draft of the class the draw a Pos
32
33
34
35 ****************************************************************************/
36
37 #ifndef VCG_GL_POS_H
38 #define VCG_GL_POS_H
39
40 // Please note that this file assume that you have already included your
41 // gl-extension wrapping utility, and that therefore all the extension symbol are already defined.
42
43 #include <vcg/simplex/face/pos.h>
44 #include <vcg/space/triangle3.h>
45
46 namespace vcg {
47
48 template<class PosType>
49 struct GlPos{
50 typedef typename PosType::ScalarType S;
51 static void Draw(PosType & p){
52 Point3<S> bc = Barycenter(*(p.f));
53 Point3<S> mid = (p.f->P(p.z)+p.f->P(((p.z+1)%3)))*0.5f;
54 Point3<S> up = ((bc- p.v->P()) ^ (mid- p.f->P(p.z) )).Normalize();
55 Point3<S> ax = ( up ^ (mid-p.f->P(p.z)) ) .Normalize();
56 S proj = (bc-mid)*(ax)*0.5;
57 Point3<S> bc1 = mid+ (ax)*proj;
58
59
60 glBegin(GL_TRIANGLES);
61 glVertex(p.v->P());
62 if( p.v == p.f->V(p.z))
63 { glVertex(mid); glVertex(bc1);}
64 else
65 {glVertex(bc1); glVertex(mid);}
66 glEnd();
67 }
68 };
69
70 template<class VfIteType>
71 struct GlVfIterator{
72 typedef typename VfIteType::ScalarType S;
73 static void Draw(VfIteType & v){
74 Point3<S> p = v.F()->P(v.I());// anchor
75 Point3<S> c[3];
76 for(int i = 0; i < 3;++i)
77 {
78 c[i] = v.F()->P(i)*0.9 + v.F()->P1(i)*0.05 + v.F()->P2(i)*0.05;
79 if(v.F()->VFp(i) != NULL)
80 {
81 glBegin(GL_LINES);
82 glVertex(c[i]);
83 glVertex( vcg::Barycenter(*(v.F()->VFp(i))));
84 glEnd();
85 }
86 }
87 }
88 };
89
90 }//namespace
91 #endif