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

restore some files

parent e1e2bc45
......@@ -58,22 +58,15 @@ void TexView::cb_initGL()
m_texture = new Utils::Texture<2,Geom::Vec3uc>(GL_UNSIGNED_BYTE);
m_textureWP = new Utils::Texture<2,Geom::Vec3uc>(GL_UNSIGNED_BYTE);
if (m_texture->load(m_fileNameTex))
m_texture->update();
else
computeImage();
// CGoGNerr << "Problem loading image"<< CGoGNendl;
computeImage();
m_texture->setWrapping(GL_CLAMP_TO_EDGE);
m_texture->update();
computeImage();
m_textureWP->setWrapping(GL_CLAMP_TO_EDGE);
m_textureWP->update();
m_shader = new Utils::ShaderSimpleTexture();
m_shader->setAttributePosition(m_positionVBO);
m_shader->setAttributeTexCoord(m_texcoordVBO);
......@@ -92,12 +85,6 @@ void TexView::cb_initGL()
m_shader2->setSpecular(Geom::Vec4f(0.5));
registerShader(m_shader2);
m_shaderWP = new Utils::ShaderWallPaper();
m_shaderWP->setTextureUnit(GL_TEXTURE2);
m_shaderWP->setTexture(m_textureWP);
registerShader(m_shaderWP);
glEnable(GL_TEXTURE_2D);
if (!m_obj.hasNormals())
......@@ -117,8 +104,6 @@ void TexView::cb_redraw()
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
m_shaderWP->draw();
if (m_phong)
{
m_shader2->activeTexture();
......@@ -202,27 +187,16 @@ void TexView::computeImage()
colorTable.push_back(Geom::Vec3uc(0,255,255));
colorTable.push_back(Geom::Vec3uc(255,255,255));
// m_texture->create(Geom::Vec2ui(512,512));
m_textureWP->create(Geom::Vec2ui(512,512));
m_texture->create(Geom::Vec2ui(512,512));
#define WIDTHCHECKER 20
// for (unsigned int ki = 0; ki < m_texture->size()[0]; ++ki)
// {
// for (unsigned int kj = 0; kj < m_texture->size()[1]; ++kj)
// {
// unsigned int kc = ((kj/WIDTHCHECKER)*m_texture->size()[0] + (ki/WIDTHCHECKER))%7;
// (*m_texture)(ki,kj) =colorTable[kc];
// }
// }
for (unsigned int ki = 0; ki < m_textureWP->size()[0]; ++ki)
for (unsigned int ki = 0; ki < m_texture->size()[0]; ++ki)
{
for (unsigned int kj = 0; kj < m_textureWP->size()[1]; ++kj)
for (unsigned int kj = 0; kj < m_texture->size()[1]; ++kj)
{
unsigned int kc = ((kj/WIDTHCHECKER)*m_textureWP->size()[0] + (ki/WIDTHCHECKER))%7;
(*m_textureWP)(ki,kj) =colorTable[kc];
unsigned int kc = ((kj/WIDTHCHECKER)*m_texture->size()[0] + (ki/WIDTHCHECKER))%7;
(*m_texture)(ki,kj) =colorTable[kc];
}
}
#undef WIDTHCHECKER
......
......@@ -36,8 +36,6 @@
#include "Algo/Render/GL2/mapRender.h"
#include "Algo/Import/importObjTex.h"
#include "Utils/Shaders/shaderWallPaper.h"
// forward definitions (minimize includes)
namespace CGoGN { namespace Algo { namespace Render { namespace GL2 { class MapRender; }}}}
......@@ -76,13 +74,10 @@ public:
unsigned int m_nbIndices;
Utils::Texture<2,Geom::Vec3uc>* m_texture;
Utils::Texture<2,Geom::Vec3uc>* m_textureWP;
// shader simple texture
Utils::ShaderSimpleTexture* m_shader;
Utils::ShaderPhongTexture* m_shader2;
Utils::ShaderWallPaper* m_shaderWP;
bool m_phong;
......
......@@ -39,11 +39,12 @@ IF (WITH_QT)
QT4_WRAP_CPP(testPlaneCutting_moc testPlaneCutting.h)
add_executable(testPlaneCutting testPlaneCutting.cpp ${testPlaneCutting_ui} ${testPlaneCutting_moc})
target_link_libraries(testPlaneCutting ${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
ENDIF()
QT4_WRAP_CPP(wallPaper_moc wallPaper.h)
add_executable(wallPaper wallPaper.cpp ${wallPaper_moc})
target_link_libraries(wallPaper ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
QT4_WRAP_CPP(wallPaper_moc wallPaper.h)
add_executable(wallPaper wallPaper.cpp ${wallPaper_moc})
target_link_libraries(wallPaper ${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
ENDIF()
# Example with Qt
#
......
......@@ -28,8 +28,6 @@
#include "Topology/generic/traversor/traversorCell.h"
#include "Topology/generic/traversor/traversor2.h"
#include "Algo/Parallel/parallel_foreach.h"
#include <cmath>
namespace CGoGN
......@@ -47,6 +45,8 @@ namespace Geometry
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Face f, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typename V_ATT::DATA_TYPE N = Geom::triangleNormal(
position[f.dart],
position[map.phi1(f)],
......@@ -59,6 +59,8 @@ typename V_ATT::DATA_TYPE triangleNormal(typename PFP::MAP& map, Face f, const V
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE newellNormal(typename PFP::MAP& map, Face f, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typedef typename V_ATT::DATA_TYPE VEC3;
VEC3 N(0);
......@@ -78,6 +80,8 @@ typename V_ATT::DATA_TYPE newellNormal(typename PFP::MAP& map, Face f, const V_A
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE faceNormal(typename PFP::MAP& map, Face f, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
if(map.faceDegree(f) == 3)
return triangleNormal<PFP>(map, f, position) ;
else
......@@ -87,6 +91,8 @@ typename V_ATT::DATA_TYPE faceNormal(typename PFP::MAP& map, Face f, const V_ATT
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typedef typename V_ATT::DATA_TYPE VEC3 ;
VEC3 N(0) ;
......@@ -98,8 +104,12 @@ typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V
{
VEC3 v1 = vectorOutOfDart<PFP>(map, f.dart, position) ;
VEC3 v2 = vectorOutOfDart<PFP>(map, map.phi_1(f), position) ;
n *= convexFaceArea<PFP>(map, f, position) / (v1.norm2() * v2.norm2()) ;
N += n ;
typename VEC3::DATA_TYPE l = (v1.norm2() * v2.norm2());
if (l > (typename VEC3::DATA_TYPE(0.0)) )
{
n *= convexFaceArea<PFP>(map, f, position) / l ;
N += n ;
}
}
});
......@@ -110,6 +120,7 @@ typename V_ATT::DATA_TYPE vertexNormal(typename PFP::MAP& map, Vertex v, const V
template<typename PFP, typename V_ATT>
typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Vertex v, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
assert(map.dimension() == 3);
typedef typename V_ATT::DATA_TYPE VEC3 ;
......@@ -145,39 +156,43 @@ typename V_ATT::DATA_TYPE vertexBorderNormal(typename PFP::MAP& map, Vertex v, c
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& face_normal, unsigned int thread)
{
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(F_ATT, FACE);
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread == 0))
{
Parallel::computeNormalFaces<PFP,V_ATT,F_ATT>(map,position,face_normal);
Parallel::computeNormalFaces<PFP,V_ATT,F_ATT>(map, position, face_normal);
return;
}
foreach_cell<FACE>(map, [&] (Face f)
{
face_normal[f] = faceNormal<PFP>(map, f, position) ;
},
AUTO, thread);
}, AUTO, thread);
}
template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal, unsigned int thread)
{
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread == 0))
{
Parallel::computeNormalVertices<PFP,V_ATT>(map,position,normal);
Parallel::computeNormalVertices<PFP,V_ATT>(map, position, normal);
return;
}
foreach_cell<VERTEX>(map, [&] (Vertex v)
{
normal[v] = vertexNormal<PFP>(map, v, position) ;
},
FORCE_CELL_MARKING, thread);
}, FORCE_CELL_MARKING, thread);
}
template <typename PFP, typename V_ATT>
typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge e, const V_ATT& position)
{
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
typedef typename V_ATT::DATA_TYPE VEC3 ;
if(map.isBoundaryEdge(e))
......@@ -211,50 +226,58 @@ typename PFP::REAL computeAngleBetweenNormalsOnEdge(typename PFP::MAP& map, Edge
template <typename PFP, typename V_ATT, typename E_ATT>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles, unsigned int thread)
{
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread==0))
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(E_ATT, EDGE);
if ((CGoGN::Parallel::NumberOfThreads > 1) && (thread == 0))
{
Parallel::computeAnglesBetweenNormalsOnEdges<PFP,V_ATT,E_ATT>(map,position,angles);
Parallel::computeAnglesBetweenNormalsOnEdges<PFP,V_ATT,E_ATT>(map, position, angles);
return;
}
foreach_cell<EDGE>(map, [&] (Edge e)
{
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
},
AUTO, thread);
}, AUTO, thread);
}
namespace Parallel
{
template <typename PFP, typename V_ATT>
void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& normal)
{
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int /*thr*/)
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CGoGN::Parallel::foreach_cell<VERTEX>(map, [&] (Vertex v, unsigned int /*thr*/)
{
normal[v] = vertexNormal<PFP>(map, v, position) ;
},true,FORCE_CELL_MARKING);
}, FORCE_CELL_MARKING);
}
template <typename PFP, typename V_ATT, typename F_ATT>
void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& normal)
{
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(F_ATT, FACE);
CGoGN::Parallel::foreach_cell<FACE>(map, [&] (Face f, unsigned int /*thr*/)
{
normal[f] = faceNormal<PFP>(map, f, position) ;
},true,AUTO);
});
}
template <typename PFP, typename V_ATT, typename E_ATT>
void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& position, E_ATT& angles)
{
CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int thr)
CHECK_ATTRIBUTEHANDLER_ORBIT(V_ATT, VERTEX);
CHECK_ATTRIBUTEHANDLER_ORBIT(E_ATT, EDGE);
CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int /*thr*/)
{
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
},true,AUTO);
});
}
} // namespace Parallel
......
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