Commit c208a805 authored by Maire Nicolas's avatar Maire Nicolas

Merge branch 'master' of cgogn:~cgogn/CGoGN

parents 44fd6316 4040a77e
......@@ -25,6 +25,7 @@ include_directories(
${CGoGN_ROOT_DIR}/ThirdParty/AntTweakBar/include
${CGoGN_ROOT_DIR}/ThirdParty/OpenCTM
${CGoGN_ROOT_DIR}/ThirdParty/Assimp/include
${CGoGN_ROOT_DIR}/ThirdParty/glm
)
# define libs path
......@@ -46,3 +47,9 @@ target_link_libraries( Geom_inclusionD
add_executable( Geom_intersectionD ./Geom_intersection.cpp)
target_link_libraries( Geom_intersectionD
${CGoGN_LIBS_D} ${COMMON_LIBS} )
QT4_WRAP_CPP(concave_rendering_moc concave_rendering.h)
add_executable( concave_renderingD concave_rendering.cpp ${concave_rendering_moc})
target_link_libraries( concave_renderingD
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
This diff is collapsed.
/*******************************************************************************
* 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 _TUTO1_
#define _TUTO1_
#include <iostream>
#include "Utils/qtSimple.h"
#include "Utils/cgognStream.h"
// forward definitions (minimize includes)
namespace CGoGN { namespace Algo { namespace Render { namespace GL2 { class MapRender; } } } }
namespace CGoGN { namespace Utils { class VBO; } }
namespace CGoGN { namespace Utils { class ShaderSimpleColor; } }
using namespace CGoGN ;
/**
* A class for a little interface and rendering
*/
class MyQT : public Utils::QT::SimpleQT
{
Q_OBJECT
public:
// render
Algo::Render::GL2::MapRender* m_render;
// VBO
Utils::VBO* m_positionVBO;
// shader basic
Utils::ShaderSimpleColor* m_shader;
MyQT() : m_render(NULL), m_positionVBO(NULL), m_shader(NULL)
{}
// callbacks of simpleQT to overdefine:
void cb_initGL();
void cb_redraw();
void cb_keyPress(int code);
void cb_New() { CGoGNout << "New ..." << CGoGNendl; }
void cb_Save() { CGoGNout << "Rien a sauver ..." << CGoGNendl; }
// callbacks (slots) locally defined
public slots:
void menu_slot1() { CGoGNout << "Exemple de menu" << CGoGNendl; }
};
#endif
......@@ -522,7 +522,7 @@ void MyQT::cb_keyPress(int keycode)
if (!d_vertices.empty())
{
std::stringstream ss;
ss << "Sommet: dart: " << d_vertices[0].index << ": " << position[d_vertices[0]];
ss << "Sommet: dart: " << d_vertices[0].index << ": " << position[d_vertices[0]]<< "( id emb:"<< myMap.getEmbedding(VERTEX,d_vertices[0])<<")"<< std::endl; ;
statusMsg(ss.str().c_str());
updateGL();
......
......@@ -20,6 +20,7 @@ IF(WIN32)
add_subdirectory(gzstream/Build)
add_subdirectory(Numerical)
add_subdirectory(Assimp/code)
add_subdirectory(Tools)
# if(CMAKE_CONFIGURATION_TYPES)
# set(CMAKE_CONFIGURATION_TYPES Release)
# set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Use only Release configuration for ThirdParty" FORCE)
......@@ -34,5 +35,6 @@ ELSE(WIN32)
add_subdirectory(AntTweakBar)
add_subdirectory(Numerical)
add_subdirectory(Assimp)
add_subdirectory(Tools)
ENDIF(WIN32)
cmake_minimum_required(VERSION 2.6)
project(Tools)
SET (CMAKE_BUILD_TYPE Release)
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/ThirdParty/Tools)
add_executable( shader_to_h shader_to_h.cpp )
target_link_libraries( shader_to_h )
#include <iostream>
#include <fstream>
#include <sstream>
int main(int argc, char **argv)
{
char buffer[512];
for (int i=1; i< argc; ++i)
{
std::string filename(argv[i]);
std::ifstream fs(filename.c_str(), std::ios::in);
if (!fs.good())
{
std::cerr << "Unable to open file " << filename << std::endl;
return 1;
}
size_t last_slash = filename.rfind('/');
if (last_slash == std::string::npos)
{
last_slash = filename.rfind('\\');
if (last_slash == std::string::npos)
last_slash = 0;
else
++last_slash;
}
else
++last_slash;
std::string outName = filename.substr(last_slash,filename.size()-last_slash);
std::stringstream ssi;
std::stringstream sso;
std::ifstream fsi(outName.c_str(),std::ios::in);
if (fsi.good())
{
while (!fsi.eof())
{
fsi.getline(buffer,512);
if (!fsi.eof())
ssi << buffer << std::endl ;
}
fsi.close();
}
// fist line
fs.getline(buffer,512);
char *sub=buffer;
while ((*sub=='/') || (*sub==' '))
++sub;
sso << "std::string "<<sub<< " =";
// text of shader
unsigned int nbbl=0;
while (!fs.eof())
{
fs.getline(buffer,512);
//std::cout << buffer << std::endl;
if (*buffer!=0)
{
for (unsigned int i=0; i<nbbl;++i)
sso << std::endl <<"\"\\n\"";
nbbl=0;
sso << std::endl << "\"" << buffer <<"\\n\"";
}
else
nbbl++;
};
sso << ";"<< std::endl<< std::endl;
std::string ssostr = sso.str();
if (ssostr != ssi.str())
{
std::ofstream fso(outName.c_str(),std::ios::out);
fso << ssostr;
std::cout << "Shader_to_h: "<< outName << " copy"<< std::endl;
fso.close();
}
else
std::cout << "Shader_to_h: "<< outName << " ok"<< std::endl;
fs.close();
}
return 0;
}
......@@ -19,6 +19,7 @@ ADD_DEFINITIONS(${QT_DEFINITIONS})
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
/usr/include/libxml2
${CGoGN_ROOT_DIR}/include
${CGoGN_ROOT_DIR}/ThirdParty/Numerical
......@@ -66,17 +67,33 @@ add_library(
${files_algo}
)
#file(
# GLOB_RECURSE
# files_geometry
# ${CGoGN_ROOT_DIR}/src/Geometry/*.cpp
# ${CGoGN_ROOT_DIR}/include/Geometry/*.hpp
# ${CGoGN_ROOT_DIR}/include/Geometry/*.h
#)
#add_library(
# geometryD
# ${files_geometry}
#)
file(
GLOB_RECURSE
shaders_srcD
${CGoGN_ROOT_DIR}/include/Utils/*.frag
${CGoGN_ROOT_DIR}/include/Utils/*.vert
${CGoGN_ROOT_DIR}/include/Utils/*.geom
${CGoGN_ROOT_DIR}/include/Utils/Shaders*.frag
${CGoGN_ROOT_DIR}/include/Utils/Shaders*.vert
${CGoGN_ROOT_DIR}/include/Utils/Shaders*.geom
)
IF(WIN32)
add_custom_target(shader_targetD ${CGoGN_ROOT_DIR}/ThirdParty/Tools/Release/shader_to_h ${shaders_srcD}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${shaders_srcD}
)
ELSE(WIN32)
add_custom_target(shader_targetD ${CGoGN_ROOT_DIR}/ThirdParty/Tools/shader_to_h ${shaders_srcD}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${shaders_srcD}
)
ENDIF(WIN32)
file(
......@@ -102,4 +119,5 @@ add_library(
${files_utils_withQt}
)
add_dependencies(utilsD shader_targetD )
......@@ -21,6 +21,7 @@ ADD_DEFINITIONS(${QT_DEFINITIONS})
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
/usr/include/libxml2
${CGoGN_ROOT_DIR}/include
${CGoGN_ROOT_DIR}/ThirdParty/Numerical
......@@ -81,6 +82,33 @@ add_library(
#)
file(
GLOB_RECURSE
shaders_src
${CGoGN_ROOT_DIR}/include/Utils/*.frag
${CGoGN_ROOT_DIR}/include/Utils/*.vert
${CGoGN_ROOT_DIR}/include/Utils/*.geom
${CGoGN_ROOT_DIR}/include/Utils/Shaders*.frag
${CGoGN_ROOT_DIR}/include/Utils/Shaders*.vert
${CGoGN_ROOT_DIR}/include/Utils/Shaders*.geom
)
IF(WIN32)
add_custom_target(shader_target ${CGoGN_ROOT_DIR}/ThirdParty/Tools/Release/shader_to_h ${shaders_src}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${shaders_src}
)
ELSE(WIN32)
add_custom_target(shader_target ${CGoGN_ROOT_DIR}/ThirdParty/Tools/shader_to_h ${shaders_src}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
SOURCES ${shaders_src}
)
ENDIF(WIN32)
file(
GLOB_RECURSE
files_utils
......@@ -104,6 +132,7 @@ add_library(
${files_utils_withQt}
)
add_dependencies(utils shader_target )
......@@ -50,6 +50,27 @@ typename PFP::VEC3 triangleNormal(typename PFP::MAP& map, Dart d, const typename
return N ;
}
template<typename PFP>
typename PFP::VEC3 newellNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{
Dart e=d;
typename PFP::VEC3 normal(0);
do
{
const typename PFP::VEC3& P = position[e];
e = map.phi1(e);
const typename PFP::VEC3& Q = position[e];
normal[0] += (P[1]-Q[1])*(P[2]+Q[2]);
normal[1] += (P[2]-Q[2])*(P[0]+Q[0]);
normal[2] += (P[0]-Q[0])*(P[1]+Q[1]);
}while (e !=d);
normal.normalize();
return normal;
}
template <typename PFP>
typename PFP::VEC3 faceNormal(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{
......
......@@ -85,9 +85,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
++degree;
p += position[it] ;
if(!map.edgeIsSubdivided(it)) // first cut the edges (if they are not already)
{
Algo::IHM::subdivideEdge<PFP>(map, it, position) ; // and compute the degree of the face
}
it = map.phi1(it) ;
} while(it != old) ;
p /= typename PFP::REAL(degree) ;
......@@ -96,38 +94,38 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
Dart res;
// if(degree == 3 && sType == S_TRI) //subdiviser une face triangulaire
// {
// Dart dd = map.phi1(old) ;
// Dart e = map.phi1(map.phi1(dd)) ;
// map.splitFace(dd, e) ; // insert a new edge
// unsigned int id = map.getNewEdgeId() ;
// map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
//
// unsigned int idface = map.getFaceId(old);
// map.setFaceId(dd, idface, FACE) ;
// map.setFaceId(e, idface, FACE) ;
//
// dd = e ;
// e = map.phi1(map.phi1(dd)) ;
// map.splitFace(dd, e) ;
// id = map.getNewEdgeId() ;
// map.setEdgeId(map.phi_1(dd), id, EDGE) ;
//
// map.setFaceId(dd, idface, FACE) ;
// map.setFaceId(e, idface, FACE) ;
//
// dd = e ;
// e = map.phi1(map.phi1(dd)) ;
// map.splitFace(dd, e) ;
// id = map.getNewEdgeId() ;
// map.setEdgeId(map.phi_1(dd), id, EDGE) ;
//
// map.setFaceId(dd, idface, FACE) ;
// map.setFaceId(e, idface, FACE) ;
// }
// else
// {
if(degree == 3 && sType == S_TRI) //subdiviser une face triangulaire
{
Dart dd = map.phi1(old) ;
Dart e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ; // insert a new edge
unsigned int id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ; // set the edge id of the inserted edge to the next available id
unsigned int idface = map.getFaceId(old);
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
dd = e ;
e = map.phi1(map.phi1(dd)) ;
map.splitFace(dd, e) ;
id = map.getNewEdgeId() ;
map.setEdgeId(map.phi_1(dd), id, EDGE) ;
map.setFaceId(dd, idface, FACE) ;
map.setFaceId(e, idface, FACE) ;
}
else
{
Dart dd = map.phi1(old) ;
map.splitFace(dd, map.phi1(map.phi1(dd))) ;
......@@ -164,7 +162,7 @@ void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
dd = map.phi2(map.phi1(dd));
}
while(dd != ne);
// }
}
map.setCurrentLevel(cur) ;
}
......@@ -182,8 +180,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(vLevel);
std::cout << "vLevel = " << vLevel << std::endl;
/*
* au niveau du volume courant i
* stockage d'un brin de chaque face de celui-ci
......@@ -191,7 +187,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
*/
DartMarkerStore mf(map); // Lock a face marker to save one dart per face
//DartMarkerStore mv(map); // Lock a vertex marker to compute volume center
CellMarker mv(map, VERTEX);
typename PFP::VEC3 volCenter;
......@@ -217,7 +212,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
//compute volume centroid
if(!mv.isMarked(e))
{
//mv.markOrbit(VERTEX, e);
mv.mark(e);
volCenter += position[e];
++count;
......@@ -246,7 +240,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
std::vector<std::pair<Dart,Dart> > subdividedfaces;
subdividedfaces.reserve(25);
int i = 0;
//First step : subdivide edges and faces
//creates a i+1 edge level and i+1 face level
for (std::vector<Dart>::iterator face = visitedFaces.begin(); face != visitedFaces.end(); ++face)
......@@ -255,24 +248,12 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
//if needed subdivide face
if(!map.faceIsSubdivided(d))
{
++i;
Algo::IHM::subdivideFace<PFP>(map, d, position);
}
std::cout << "CHECK FACES " << std::endl;
map.check();
//save a dart from the subdivided face
unsigned int cur = map.getCurrentLevel() ;
map.setCurrentLevel(map.getMaxLevel());
Dart old = map.faceOldestDart(d);
std::cout << " Oldest dart Face = " << old << std::endl;
unsigned int fLevel = map.faceLevel(old); //puisque dans tous les cas, la face est subdivisee
std::cout << "FACE LEVEL = " << fLevel << std::endl;
unsigned int fLevel = map.faceLevel(d) + 1; //puisque dans tous les cas, la face est subdivisee
map.setCurrentLevel(fLevel) ;
......@@ -288,8 +269,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(cur);
}
map.setCurrentLevel(vLevel + 1) ; // go to the next level to perform volume subdivision
std::vector<Dart> newEdges; //save darts from inner edges
......@@ -301,33 +280,21 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
Dart e = *edge;
Dart f1 = map.phi1(*edge);
int i = 0;
do
{
std::cout << "corner #" << i << " degree = " << map.faceDegree(e) << std::endl;
if(map.phi2(map.phi1(map.phi1(e))) != map.phi1(map.phi1(e)))
map.unsewFaces(map.phi1(map.phi1(e)));
map.unsewFaces(map.phi1(map.phi1(e)));
//TODO utile ?
if(map.phi2(map.phi1(e)) != map.phi1(e))
//if(map.phi2(map.phi1(e)) != map.phi1(e))
map.unsewFaces(map.phi1(e));
++i;
e = map.phi2(map.phi_1(e));
}
while(e != *edge);
map.closeHole(f1);
std::cout << "CHECK CLOSE HOLE " << std::endl;
map.check();
std::cout << "corner degree = " << i << std::endl;
std::cout << "face degree = " << map.faceDegree(map.phi2(f1)) << std::endl;
// if(map.faceDegree(map.phi2(f1)) > 6)
// return Dart::nil();
Dart old = map.phi2(map.phi1(e));
Dart dd = map.phi1(map.phi1(old)) ;
map.splitFace(old,dd) ;
......@@ -395,8 +362,6 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
map.setCurrentLevel(cur) ;
std::cout << std::endl;
return subdividedfaces.begin()->first;
}
......
......@@ -28,6 +28,7 @@
#include <GL/glew.h>
#include <vector>
#include <list>
#include <set>
#include <utility>
#include "Topology/generic/dart.h"
......@@ -89,6 +90,50 @@ protected:
typedef std::pair<GLuint*, unsigned int> buffer_array;
// forward declaration
class VertexPoly;
// comparaison function for multiset
static bool cmpVP(VertexPoly* lhs, VertexPoly* rhs);
// multiset typedef for simple writing
typedef std::multiset< VertexPoly*,bool(*)(VertexPoly*,VertexPoly*)> VPMS;
class VertexPoly
{
public:
int id;
float value;
VertexPoly* prev;
VertexPoly* next;
VPMS::iterator ear;
VertexPoly(int i, float v, VertexPoly* p=NULL): id(i),value(v), prev(p), next(NULL)
{
if (prev!=NULL)
prev->next = this;
}
static void close(VertexPoly* first, VertexPoly* last)
{
last->next = first;
first->prev = last;
}
static VertexPoly* erase(VertexPoly* vp)
{
VertexPoly* tmp = vp->prev;
tmp->next = vp->next;
vp->next->prev = tmp;
vp->value = 20.0f; //??
delete vp;
return tmp;
}
};
public:
/**
* Constructor
......@@ -109,6 +154,7 @@ public:
buffer_array get_nb_index_buffer() { return std::