/******************************************************************************* * CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps * * version 0.1 * * Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg * * * * This library 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.1 of the License, or (at your * * option) any later version. * * * * This library 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 this library; if not, write to the Free Software Foundation, * * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * * * * Web site: http://cgogn.u-strasbg.fr/ * * Contact information: cgogn@unistra.fr * * * *******************************************************************************/ namespace CGoGN { namespace Algo { namespace Render { template void drawerAddEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, float k) { const typename PFP::VEC3& P = positions[d]; Dart e = map.phi1(d); const typename PFP::VEC3& Q = positions[e]; typename PFP::VEC3 C = (P+Q)/ typename PFP::REAL(2.0); dr.vertex(C*(1.0f-k) + k*P); dr.vertex(C*(1.0f-k) + k*Q); } template void drawerAddEdgeShrink(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& C, float k) { const typename PFP::VEC3& P = positions[d]; Dart e = map.phi1(d); const typename PFP::VEC3& Q = positions[e]; dr.vertex(C*(1.0f-k) + k*P); dr.vertex(C*(1.0f-k) + k*Q); } template void drawerAddFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, float k) { typename PFP::VEC3 C = Algo::Geometry::faceCentroid(map,d,positions); Traversor2FE trav(map,d); for (Dart e=trav.begin(); e!=trav.end(); e=trav.next()) { drawerAddEdgeShrink(dr,map,e,positions,C,k); } } template void drawerAddVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k) { typename PFP::VEC3 C = Algo::Geometry::volumeCentroid(map,d,positions); Traversor3WE trav(map,d); for (Dart e=trav.begin(); e!=trav.end(); e=trav.next()) drawerAddEdgeShrink(dr,map,e,positions,C,k); } template void drawerVertices(Utils::Drawer& dr, typename PFP::MAP& map, std::vector& vd, const typename PFP::TVEC3& positions) { dr.begin(GL_POINTS); for (std::vector::iterator it = vd.begin(); it !=vd.end(); ++it) dr.vertex(positions[*it]); dr.end(); } template void drawerEdges(Utils::Drawer& dr, typename PFP::MAP& map, std::vector& vd, const typename PFP::TVEC3& positions,float k) { dr.begin(GL_LINES); for (std::vector::iterator it = vd.begin(); it !=vd.end(); ++it) drawerAddEdge(dr,map,*it,positions,k); dr.end(); } template void drawerFaces(Utils::Drawer& dr, typename PFP::MAP& map, std::vector& vd, const typename PFP::TVEC3& positions,float k) { dr.begin(GL_LINES); for (std::vector::iterator it = vd.begin(); it !=vd.end(); ++it) drawerAddFace(dr,map,*it,positions,k); dr.end(); } template void drawerVolumes(Utils::Drawer& dr, typename PFP::MAP& map, std::vector& vd, const typename PFP::TVEC3& positions,float k) { dr.begin(GL_LINES); for (std::vector::iterator it = vd.begin(); it !=vd.end(); ++it) drawerAddVolume(dr,map,*it,positions,k); dr.end(); } template void drawerVertex(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions) { dr.begin(GL_POINTS); dr.vertex(positions[d]); dr.end(); } template void drawerEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k) { dr.begin(GL_LINES); drawerAddEdge(dr,map,d,positions,k); dr.end(); } template void drawerFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k) { dr.begin(GL_LINES); drawerAddFace(dr,map,d,positions,k); dr.end(); } template void drawerVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k) { dr.begin(GL_LINES); drawerAddVolume(dr,map,d,positions,k); dr.end(); } } } }