/* Trivial.hxx * * Copyright (c) 2003, Tuomas J. Lukka * This file is part of LibVob. * * LibVob is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * LibVob is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General * Public License for more details. * * You should have received a copy of the GNU Lesser General * Public License along with LibVob; if not, write to the Free * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * */ /* * Written by Tuomas J. Lukka */ #ifndef VOB_VOBS_FILLET #define VOB_VOBS_FILLET #include #include #include #include #include #include #include #include #ifndef VOB_DEFINED #define VOB_DEFINED(t) #endif using namespace Vob::Geom; namespace Vob { namespace Vobs { using namespace Vob::VecGL; PREDBGVAR(dbg_vfillets); struct SortedConnections { enum { NTrans = -1 }; Vob3 *single; template void params(F &f) { f(single); } struct AngleInd { float angle; int ind; bool operator<(const AngleInd &b) const { return angle < b.angle; } }; void render(const Transform **t, int n) const { DBG(dbg_vfillets) << "Sortedconns: start "<transform(.5 * t[i]->getSqSize()); AngleInd a[n]; a[0].angle = -1000; a[0].ind = 0; for(int i=1; irender3(*t[0], *t[a[i].ind], *t[a[i+1].ind]); } single->render3(*t[0], *t[a[n-1].ind], *t[a[1].ind]); DBG(dbg_vfillets) << "Sortedconns final: " << a[n-1].ind << " " << a[1].ind <<"\n"; } }; VOB_DEFINED(SortedConnections); struct FilletSpan1 { enum { NTrans = 3 }; int ndice; template float crad(const T &t) const { return t.getSqSize().x; } template float th(const T &t0, const T &t1, float d) const { float r0 = crad(t0); float r1 = crad(t1); float rmax = r0 >? r1; float rmin = r0 void params(F &f) { f(ndice); } template void render(const T &t0, const T &t1, const T &t2) const { ZVec p0 = t0.transform(t0.getSqSize()); ZVec p1 = t1.transform(t1.getSqSize()) ; ZVec p2 = t2.transform(t2.getSqSize()) ; Vec ctr = p0; Vec v1 = p1 - ctr; Vec v2 = p2 - ctr; DBG(dbg_vfillets) << "FilletSpan "< .5; f-= 1.0 / ndice) { Vec p = sp.point(f, BlendSimply()); glVertex3f(p.x, p.y, lerp(p2.z, p0.z, 2*(1-f)) ); } glEnd(); } else { glBegin(GL_LINE_STRIP); for(float f = 0; f < 1; f+= 1.0 / ndice) { Vec p = sp.point(f, BlendSimply()); glVertex3f(p.x, p.y, (f < .5 ? lerp(p1.z, p0.z, 2*f) : lerp(p2.z, p0.z, 2*(1-f)) ) ); } glEnd(); } } }; VOB_DEFINED(FilletSpan1); } } #endif