Commit 1318e8bc authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

maj

parents 33f4a9d1 84fe346d
......@@ -2,13 +2,14 @@ SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin)
SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream AntTweakBar openctm assimp)
SET(CGoGN_LIBS_D topologyD algoD containerD utilsD)
SET(CGoGN_LIBS_R topology algo container utils)
IF(WIN32)
SET(CGoGN_LIBS_D topology algo container utils) # libs have same name but in different place in Visual
add_subdirectory(Examples/Release)
add_subdirectory(Tuto)
ELSE(WIN32)
SET(CGoGN_LIBS_D topologyD algoD containerD utilsD)
add_subdirectory(Examples/Release)
add_subdirectory(Examples/Debug)
add_subdirectory(Examples/Tests)
......
......@@ -28,9 +28,12 @@ include_directories(
)
# define libs path
link_directories(
${CGoGN_ROOT_DIR}/lib/Release
)
IF(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/$(ConfigurationName) )
ELSE(WIN32)
link_directories( ${CGoGN_ROOT_DIR}/lib/Release )
ENDIF(WIN32)
#define exec to compile
......
......@@ -2,12 +2,8 @@ cmake_minimum_required(VERSION 2.6)
project(Tutos)
#SET (COMMON_LIBS ${GLUT_LIBRARY} ${OPENGL_LIBRARY} ${GLEW_LIBRARY} ${DEVIL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBXML2_LIBRARIES} gzstream AntTweakBar openctm)
SET (CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
# FOR Qt4
......@@ -28,9 +24,14 @@ include_directories(
${CGoGN_ROOT_DIR}/include
)
# define libs path
link_directories(${CGoGN_ROOT_DIR}/lib/Release ${CGoGN_ROOT_DIR}/lib/Debug)
IF(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/$(ConfigurationName))
ELSE(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/Release ${CGoGN_ROOT_DIR}/lib/Debug)
ENDIF(WIN32)
#define exec to compile
......
......@@ -22,8 +22,6 @@
* *
*******************************************************************************/
//#define GL3_PROTOTYPES
#include "tuto1.h"
#include <iostream>
......@@ -41,6 +39,9 @@
#include <glm/gtc/type_ptr.hpp>
#include "Algo/Render/SVG/mapSVGRender.h"
using namespace CGoGN ;
/**
......@@ -53,6 +54,11 @@ struct PFP: public PFP_STANDARD
typedef EmbeddedMap2<Map2> MAP;
};
// declaration of the map
PFP::MAP myMap;
// and attribute of position
AttributeHandler<PFP::VEC3> position;
void MyQT::cb_initGL()
{
// choose to use GL version 2
......@@ -99,12 +105,21 @@ void MyQT::cb_keyPress(int code)
if ((code >'0') && (code<='9'))
CGoGNout << " key num " << code-'0' << "pressed"<< CGoGNendl;
if (code == 's')
{
std::string filename = selectFileSave("Export SVG file ");
CGoGNout << "Exporting "<<filename<<CGoGNendl;
Algo::Render::SVG::SVGOut svg(filename,modelViewMatrix(),projectionMatrix());
svg.renderLinesToSVG<PFP>(myMap,position);
svg.setColor(Geom::Vec3f(0.7f,0.0f,0.4f));
svg.renderFacesToSVG<PFP>(myMap,position,0.8f);
//svg destruction close the file
}
}
int main(int argc, char **argv)
{
// declaration of the map
PFP::MAP myMap;
// creation of 2 new faces: 1 triangle and 1 square
Dart d1 = myMap.newFace(3);
......@@ -115,7 +130,7 @@ int main(int argc, char **argv)
// creation of a new attribute on vertices of type 3D vector
// a handler to this attribute is returned
AttributeHandler<PFP::VEC3> position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position");
position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position");
// affect a position to the vertices of the mesh
position[d1] = PFP::VEC3(0, 0, 0);
......
......@@ -49,6 +49,7 @@
#include "Utils/shaderVectorPerVertex.h"
#include "Utils/cgognStream.h"
#include "Algo/Render/SVG/mapSVGRender.h"
using namespace CGoGN ;
......@@ -68,24 +69,29 @@ void MyQT::balls_onoff(bool x)
{
render_balls = !render_balls;
updateGL();
CGoGNerr << " balls_onoff "<< CGoGNendl;
}
void MyQT::vectors_onoff(bool x)
{
render_vectors = !render_vectors;
updateGL();
CGoGNerr << " vectors_onoff "<< CGoGNflush;
}
void MyQT::text_onoff(bool x)
{
render_text = !render_text;
updateGL();
CGoGNerr << " text_onoff " << CGoGNflush;
}
void MyQT::topo_onoff(bool x)
{
render_topo = !render_topo;
updateGL();
CGoGNerr << " topo_onoff " << CGoGNflush;
}
void MyQT::slider_balls(int x)
......@@ -227,10 +233,6 @@ void MyQT::cb_mousePress(int button, int x, int y)
Dart d = m_render_topo->picking<PFP>(myMap, allDarts, x, getHeight() - y);
if (d != Dart::nil())
{
// std::stringstream ss;
// ss << "Dart "<< d << " clicked"<< CGoGNendl;
// statusMsg(ss.str().c_str());
CGoGNout << "Dart "<< d << " clicked" << CGoGNendl;
}
else
......@@ -240,6 +242,21 @@ void MyQT::cb_mousePress(int button, int x, int y)
}
}
void MyQT::cb_keyPress(int code)
{
if (code == 's')
{
std::string filename = selectFileSave("Export SVG file ");
CGoGNout << "Exporting "<<filename<<CGoGNendl;
Algo::Render::SVG::SVGOut svg(filename,modelViewMatrix(),projectionMatrix());
svg.renderLinesToSVG<PFP>(myMap,position);
svg.setColor(Geom::Vec3f(1.,0.,0.));
svg.renderFacesToSVG<PFP>(myMap,position,0.8f);
//svg destruction close the file
}
}
int main(int argc, char **argv)
{
position = myMap.addAttribute<PFP::VEC3>(VERTEX_ORBIT, "position");
......@@ -305,7 +322,8 @@ int main(int argc, char **argv)
CGoGNdbg2.toConsole(&sqt);
CGoGNerr.toConsole(&sqt);
CGoGNdbg2 << " TextureSize " << texSize << CGoGNendl;
CGoGNerr << " ERROR " << 5*7 << CGoGNendl;
CGoGNerr << " ERROR " << 5*7 << CGoGNflush;
// et on attend la fin.
return app.exec();
......
......@@ -97,8 +97,7 @@ protected:
void cb_mousePress(int button, int x, int y);
void cb_keyPress(int code)
{}
void cb_keyPress(int code);
// slots locaux
public slots:
......
......@@ -379,7 +379,7 @@ int main(int argc, char **argv)
{
using namespace CGoGN::Utils::QT;
inputValues( VarInt(0,20,xx, "Entier",
inputValues( VarInteger(0,20,xx, "Entier",
VarBool(zz, "Bool",
VarDbl(0.314,3.14,yy,"Double",
VarSlider(10,100,kk,"Slider",
......
Dépendences Linux:
installer les paquets suivants:
<<<<<<< HEAD
cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-dev libzip-dev libqt4-help qt4-designer qt4-dev-tools
=======
cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-dev lizip-dev libqt4-dev qt4-designer qt4-dev-tools
>>>>>>> 84fe346d20a65b08cb049bffc98c793c70f687f2
Pour compiler CGoGN:
......
......@@ -8,6 +8,7 @@ SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/..)
find_package(OpenGL)
find_package(GLUT)
IF (APPLE)
SET(CMAKE_OSX_ARCHITECTURES x86_64)
ENDIF(APPLE)
......@@ -19,10 +20,10 @@ IF(WIN32)
add_subdirectory(gzstream/Build)
add_subdirectory(Numerical)
add_subdirectory(Assimp/code)
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)
endif()
# 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)
# endif()
ELSE(WIN32)
SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/Release)
add_custom_target( FakeTargetOpenCTM ALL "make"
......
......@@ -36,10 +36,10 @@
#include <stdio.h>
#include <limits>
#include <cmath>
#ifndef PI_DEFINED
#define PI_DEFINED
const double M_PI = 3.14159265359;
#endif
//#ifndef PI_DEFINED
//#define PI_DEFINED
//double M_PI = 3.14159265359;
//#endif
#endif
......
......@@ -9,7 +9,8 @@ SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/..)
SET(CMAKE_MODULE_PATH " ${CMAKE_MODULE_PATH} ${CGoGN_ROOT_DIR}/cmake_modules/")
find_package(OpenGL)
find_package(OpenGL REQUIRED)
find_package(Qt4 REQUIRED)
find_package(GLUT)
# qq definition specifiques pour mac
......@@ -28,7 +29,6 @@ IF(WIN32)
SET(LIBXML2_LIBRARIES xml2)
INCLUDE_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/include/)
LINK_DIRECTORIES(${CGoGN_ROOT_DIR}/windows_dependencies/lib/)
# add_subdirectory(${CGoGN_ROOT_DIR}/ThirdParty ThirdParty)
add_subdirectory(Release)
add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
if (EXISTS "${CGoGN_ROOT_DIR}/Perso")
......@@ -37,7 +37,7 @@ IF(WIN32)
if(CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES Release Debug)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Use only Release configuration for ThirdParty" FORCE)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
endif()
ELSE(WIN32)
......@@ -51,7 +51,7 @@ ELSE(WIN32)
ELSE(IL_LIBRARIES)
SET(DEVIL_LIBRARIES ${IL_LIBRARY} ${ILU_LIBRARY} ${ILUT_LIBRARY})
ENDIF(IL_LIBRARIES)
# add_subdirectory(${CGoGN_ROOT_DIR}/ThirdParty ThirdParty)
add_subdirectory(Release)
add_subdirectory(Debug)
add_subdirectory(${CGoGN_ROOT_DIR}/Apps Apps)
......
......@@ -2,15 +2,17 @@ cmake_minimum_required(VERSION 2.6)
project(CGoGNDebug)
set(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/Debug)
#SET(BUILD_SHARED_LIBS,FALSE)
SET(CMAKE_BUILD_TYPE Debug)
IF(WIN32)
SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib)
ELSE(WIN32)
SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/Debug)
ENDIF(WIN32)
#SET(BUILD_SHARED_LIBS,FALSE)
# FOR Qt4
FIND_PACKAGE(Qt4 REQUIRED)
SET(QT_USE_QTOPENGL TRUE)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
......
......@@ -2,15 +2,19 @@ cmake_minimum_required(VERSION 2.6)
project(CGoGNRelease)
set(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/Release)
SET(CMAKE_BUILD_TYPE Release)
IF(WIN32)
SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib)
ELSE(WIN32)
SET(LIBRARY_OUTPUT_PATH ${CGoGN_ROOT_DIR}/lib/Release)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
ENDIF(WIN32)
#SET(BUILD_SHARED_LIBS,FALSE)
SET(CMAKE_BUILD_TYPE Release)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
# FOR Qt4
FIND_PACKAGE(Qt4 REQUIRED)
SET(QT_USE_QTOPENGL TRUE)
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
......
......@@ -136,12 +136,6 @@ public:
template <typename PFP>
void initPoints(typename PFP::MAP& map, const FunctorSelect& good,std::vector<GLuint>& tableIndices, unsigned int thread=0) ;
/**
* creation of VBO for flat faces rendering
*/
// template <typename PFP>
// void initFlatTriangles(typename PFP::MAP& map, const Utils::GL2& vboposition, const FunctorSelect& good=SelectorTrue() , unsigned int thread=0);
/**
* initialization of the VBO indices primitives
* computed by a traversal of the map
......
......@@ -24,6 +24,7 @@
#include "Topology/generic/dartmarker.h"
#include "Topology/generic/cellmarker.h"
#include "Utils/vbo.h"
namespace CGoGN
{
......@@ -210,60 +211,7 @@ void MapRender::initPoints(typename PFP::MAP& map, const FunctorSelect& good, st
}
}
//template<typename PFP>
//void MapRender::initFlatTriangles( typename PFP::MAP& map, const Utils::GL2& vbopos, const FunctorSelect& good, unsigned int thread)
//{
// std::vector<Geom::Vec3f> tableFlat;
// tableFlat.reserve(3*map.getNbDarts()); // 3 in case of polygonal faces (less chance of realloc, but bigger allocation)
//
// // map VBO of points for vertices positions
// glBindBufferARB(GL_ARRAY_BUFFER, vbopos.id());
// Geom::Vec3f* tablePos = reinterpret_cast<Geom::Vec3f*>(glMapBuffer(GL_ARRAY_BUFFER,GL_READ_ONLY));
//
// m_nbFlatElts=0;
// // traversal of map for creating buffers
// DartMarker m(map,thread);
// for(Dart dd = map.begin(); dd != map.end(); map.next(dd))
// {
// if(!m.isMarked(dd) && good(dd))
// {
// Dart a = dd;
// Dart b = map.phi1(a);
// Dart c = map.phi1(b);
//
// Geom::Vec3f& P = tablePos[map.getEmbedding(a, VERTEX_ORBIT)];
// Geom::Vec3f& Q = tablePos[map.getEmbedding(b, VERTEX_ORBIT)];
// Geom::Vec3f& R = tablePos[map.getEmbedding(c, VERTEX_ORBIT)];
//
// Geom::Vec3f U = Q-P;
// Geom::Vec3f V = R-P;
// Geom::Vec3f N = U^V;
// N.normalize();
//
// // loop to cut a polygon in triangle on the fly (works only with convex faces)
// do
// {
// tableFlat.push_back(tablePos[map.getEmbedding(a, VERTEX_ORBIT)]);
// tableFlat.push_back(N);
// tableFlat.push_back(tablePos[map.getEmbedding(b, VERTEX_ORBIT)]);
// tableFlat.push_back(N);
// tableFlat.push_back(tablePos[map.getEmbedding(c, VERTEX_ORBIT)]);
// tableFlat.push_back(N);
// b = c;
// c = map.phi1(b);
// } while (c != dd);
// m.markOrbit(FACE_ORBIT, dd);
// }
// }
// glUnmapBuffer(GL_ARRAY_BUFFER);
//
// m_nbFlatElts = tableFlat.size()/2;
//
// //creating VBO for flat
// glBindBufferARB(GL_ARRAY_BUFFER, m_VBOBuffers[FLAT_BUFFER]);
// glBufferDataARB(GL_ARRAY_BUFFER, tableFlat.size() * sizeof(Geom::Vec3f), (char*)(&(tableFlat[0])), GL_STREAM_DRAW);
//
//}
template<typename PFP>
void MapRender::initPrimitives(typename PFP::MAP& map, const FunctorSelect& good, int prim, bool optimized, unsigned int thread)
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef _MAP_SVG_RENDER
#define _MAP_SVG_RENDER
#include <vector>
#include <fstream>
#include <sstream>
#include "Geometry/vector_gen.h"
#include "Topology/generic/functor.h"
#include "Topology/generic/dartmarker.h"
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtc/type_precision.hpp"
#include "glm/glm.hpp"
#include "glm/gtc/matrix_projection.hpp"
#include "glm/gtc/matrix_transform.hpp"
/**
* A set of functions that allow the creation of rendering
* object using Vertex-Buffer-Object.
* Function are made for dual-2-map and can be used on
* any subset of a dual-N-map which is a 2-map
*/
namespace CGoGN
{
namespace Algo
{
namespace Render
{
namespace SVG
{
class SvgObj
{
protected:
Geom::Vec3f m_color;
public:
virtual void save(std::ofstream& out)=0;
};
class SvgPolyline: public SvgObj
{
protected:
std::vector<Geom::Vec3f> m_vertices;
float m_width;
public:
void addVertex(const Geom::Vec3f& v);
void close();
void setColor(const Geom::Vec3f& c) { m_color=c;}
void setWidth(float w) { m_width=w;}
void save(std::ofstream& out);
};
class Svg_Polygon: public SvgObj
{
protected:
std::vector<Geom::Vec3f> m_vertices;
public:
void addVertex(const Geom::Vec3f& v) {}
void close() {}
void save(std::ofstream& out) {}
};
class SVGOut
{
protected:
std::ofstream* m_out;
const glm::mat4& m_model;
const glm::mat4& m_proj;
glm::i32vec4 m_viewport;
Geom::Vec3f global_color;
float global_width;
std::vector<SvgObj*> m_objs;
public:
/**
* Object that allow the rendering/exporting in svg file
* @param filename file name ended by .svg
* @param model the modelview matrix
* @param proj the projection matrix
*/
SVGOut(const std::string& filename, const glm::mat4& model, const glm::mat4& proj);
/**
* destructor
* flush and close the file
*/
~SVGOut();
void setColor(const Geom::Vec3f& col);
void setWidth(float w);
void closeFile();
template <typename PFP>
void renderLinesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& good = SelectorTrue(), unsigned int thread=0);
template <typename PFP>
void renderFacesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, float shrink, const FunctorSelect& good = SelectorTrue(), unsigned int thread=0);
};
} // namespace SVG
} // namespace Render
} // namespace Algo
} // namespace CGoGN
#include "Algo/Render/SVG/mapSVGRender.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, 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: https://iggservis.u-strasbg.fr/CGoGN/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "GL/glew.h"
#include "Algo/Geometry/centroid.h"
namespace CGoGN
{
namespace Algo
{
namespace Render
{
namespace SVG
{
template <typename PFP>
void SVGOut::renderLinesToSVG(typename PFP::MAP& map, const typename PFP::TVEC3& position, const FunctorSelect& good, unsigned int thread)
{
glm::i32vec4 viewport;
glGetIntegerv(GL_VIEWPORT, &(viewport[0]));
DartMarker m(map, thread);
for(Dart d = map.begin(); d != map.end(); map.next(d))
{