Commit 6e88e219 authored by Sylvain Thery's avatar Sylvain Thery

add new rendering cells in drawer (for debug essentially

parent 756266e9
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#ifndef __DRAWER_CELLS__
#define __DRAWER_CELLS__
#include "Utils/drawer.h"
namespace CGoGN
{
namespace Algo
{
namespace Render
{
/**
* add a set of vertices to a drawer
* @param dr the drawer to use
* @param map the map
* @param vd the darts
* @param positions attribute of positions
*/
template<typename PFP>
void drawerVertices(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions);
/**
* add a set of edges to a drawer
* @param dr the drawer to use
* @param map the map
* @param vd the darts
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerEdges(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions,float k);
/**
* add a set of faces to a drawer
* @param dr the drawer to use
* @param map the map
* @param vd the darts
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerFaces(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions,float k);
/**
* add a set of volumes to a drawer
* @param dr the drawer to use
* @param map the map
* @param vd the darts
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerVolumes(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions,float k);
/**
* add a vertex to a drawer
* @param dr the drawer to use
* @param map the map
* @param d the dart
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerVertex(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions);
/**
* add an edge to a drawer
* @param dr the drawer to use
* @param map the map
* @param d the dart
* @param positions attribute of positions
*/
template<typename PFP>
void drawerEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k);
/**
* add a face to a drawer
* @param dr the drawer to use
* @param map the map
* @param d the dart
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k);
/**
* add a volume to a drawer
* @param dr the drawer to use
* @param map the map
* @param d the dart
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k);
/**
* add an edge to a drawer, use between begin / end
* @param dr the drawer to use
* @param map the map
* @param d the dart
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerAddEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, float k);
/**
* add an shrinked edge from center to a drawer, use between begin / end
* @param dr the drawer to use
* @param map the map
* @param d the dart
* @param positions attribute of positions
* @param C center of cell to draw
* @param k shrinking factor
*/
template<typename PFP>
void drawerAddEdgeShrink(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& C, float k);
/**
* add an face to a drawer, use between begin / end
* @param dr the drawer to use
* @param map the map
* @param d the dart
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerAddFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, float k);
/**
* add a volume to a drawer, use between begin / end
* @param dr the drawer to use
* @param map the map
* @param d the dart
* @param positions attribute of positions
* @param k shrinking factor
*/
template<typename PFP>
void drawerAddVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k);
}
}
}
#include "Algo/Render/GL2/drawerCells.hpp"
#endif
/*******************************************************************************
* 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<typename PFP>
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<typename PFP>
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<typename PFP>
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<PFP>(map,d,positions);
Traversor2FE<typename PFP::MAP> trav(map,d);
for (Dart e=trav.begin(); e!=trav.end(); e=trav.next())
{
drawerAddEdgeShrink<PFP>(dr,map,e,positions,C,k);
}
}
template<typename PFP>
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<PFP>(map,d,positions);
Traversor3WE<typename PFP::MAP> trav(map,d);
for (Dart e=trav.begin(); e!=trav.end(); e=trav.next())
drawerAddEdgeShrink<PFP>(dr,map,e,positions,C,k);
}
template<typename PFP>
void drawerVertices(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions)
{
dr.begin(GL_POINTS);
for (std::vector<Dart>::iterator it = vd.begin(); it !=vd.end(); ++it)
dr.vertex(positions[*it]);
dr.end();
}
template<typename PFP>
void drawerEdges(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions,float k)
{
dr.begin(GL_LINES);
for (std::vector<Dart>::iterator it = vd.begin(); it !=vd.end(); ++it)
drawerAddEdge<PFP>(dr,map,*it,positions,k);
dr.end();
}
template<typename PFP>
void drawerFaces(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions,float k)
{
dr.begin(GL_LINES);
for (std::vector<Dart>::iterator it = vd.begin(); it !=vd.end(); ++it)
drawerAddFace<PFP>(dr,map,*it,positions,k);
dr.end();
}
template<typename PFP>
void drawerVolumes(Utils::Drawer& dr, typename PFP::MAP& map, std::vector<Dart>& vd, const typename PFP::TVEC3& positions,float k)
{
dr.begin(GL_LINES);
for (std::vector<Dart>::iterator it = vd.begin(); it !=vd.end(); ++it)
drawerAddVolume<PFP>(dr,map,*it,positions,k);
dr.end();
}
template<typename PFP>
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<typename PFP>
void drawerEdge(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k)
{
dr.begin(GL_LINES);
drawerAddEdge<PFP>(dr,map,d,positions,k);
dr.end();
}
template<typename PFP>
void drawerFace(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k)
{
dr.begin(GL_LINES);
drawerAddFace<PFP>(dr,map,d,positions,k);
dr.end();
}
template<typename PFP>
void drawerVolume(Utils::Drawer& dr, typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions,float k)
{
dr.begin(GL_LINES);
drawerAddVolume<PFP>(dr,map,d,positions,k);
dr.end();
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment