Commit 691f92c8 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge cgogn:~jund/CGoGN

Conflicts:
	Apps/Examples/simpleGMap2.cpp
parents 6c01192e ed50e279
......@@ -54,6 +54,16 @@ add_executable( texturesExampleD ../texturesExample.cpp ${texturesExample_moc} )
target_link_libraries( texturesExampleD
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(simpleGMap2_moc ../simpleGMap2.h)
add_executable( simpleGMap2D ../simpleGMap2.cpp ${simpleGMap2_moc} )
target_link_libraries( simpleGMap2D
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(simpleGMap3_moc ../simpleGMap3.h)
add_executable( simpleGMap3D ../simpleGMap3.cpp ${simpleGMap3_moc} )
target_link_libraries( simpleGMap3D
${CGoGN_LIBS_D} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(extrusionView_moc ../extrusionView.h)
add_executable( extrusionViewD ../extrusionView.cpp ${extrusionView_moc})
target_link_libraries( extrusionViewD
......
......@@ -55,6 +55,16 @@ add_executable( texturesExample ../texturesExample.cpp ${texturesExample_moc} )
target_link_libraries( texturesExample
${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(simpleGMap2_moc ../simpleGMap2.h)
add_executable( simpleGMap2 ../simpleGMap2.cpp ${simpleGMap2_moc} )
target_link_libraries( simpleGMap2
${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(simpleGMap3_moc ../simpleGMap3.h)
add_executable( simpleGMap3 ../simpleGMap3.cpp ${simpleGMap3_moc} )
target_link_libraries( simpleGMap3
${CGoGN_LIBS_R} ${COMMON_LIBS} ${QT_LIBRARIES} )
QT4_WRAP_CPP(extrusionView_moc ../extrusionView.h)
add_executable( extrusionView ../extrusionView.cpp ${extrusionView_moc})
target_link_libraries( extrusionView
......
This diff is collapsed.
/*******************************************************************************
* 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 <iostream>
#include "Utils/qtSimple.h"
#include "Topology/generic/parameters.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Geometry/vector_gen.h"
#include "Algo/Render/GL1/topo_render.h"
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedGMap2 MAP ;
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
class SimpleGMap2 : public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MAP myMap ;
SelectorTrue allDarts ;
PFP::TVEC3 position ;
SimpleGMap2() ;
void initGUI() ;
void cb_initGL() ;
void cb_redraw() ;
};
/*******************************************************************************
* 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 "simpleGMap3.h"
#include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/primitives3d.h"
SimpleGMap3::SimpleGMap3()
{
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
Algo::Modelisation::Primitive3D<PFP> prim(myMap,position);
Dart d = prim.hexaGrid_topo(2,2,1);
prim.embedHexaGrid(1,1,1);
Dart d1 = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d)))));
VEC3 mid0 = (position[d1]+position[myMap.phi1(d1)])/2.0f;
myMap.cutEdge(d1);
position[myMap.phi1(d1)] = mid0;
VEC3 mid1 = (position[d]+position[myMap.phi1(d)])/2.0f;
myMap.cutEdge(d);
position[myMap.phi1(d)] = mid1;
d = myMap.phi1(myMap.phi1(myMap.phi2(myMap.phi1(myMap.phi1(d)))));
VEC3 mid = (position[d]+position[myMap.phi1(d)])/2.0f;
myMap.cutEdge(d);
position[myMap.phi1(d)] = mid;
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(2,0,0);
Algo::Modelisation::Primitive3D<PFP> prim2(myMap,position);
d = prim2.hexaGrid_topo(2,1,1);
prim2.embedHexaGrid(1,1,1);
d = myMap.phi2(myMap.phi1(myMap.phi1(myMap.phi2(d))));
myMap.unsewVolumes(d);
}
void SimpleGMap3::initGUI()
{
}
void SimpleGMap3::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(1) ;
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
VEC3 gPosObj = bb.center() ;
float tailleX = bb.size(0) ;
float tailleY = bb.size(1) ;
float tailleZ = bb.size(2) ;
float gWidthObj = std::max<float>(std::max<float>(tailleX, tailleY), tailleZ) ;
setParamObject(gWidthObj, gPosObj.data());
}
void SimpleGMap3::cb_redraw()
{
glDisable(GL_LIGHTING);
glLineWidth(1.0f);
Algo::Render::GL1::renderTopoGMD3<PFP>(myMap, position, true, true, true, true, 0.9f, 0.9f, 0.9f, 0.9f);
}
/**********************************************************************************************
* MAIN FUNCTION *
**********************************************************************************************/
int main(int argc, char **argv)
{
QApplication app(argc, argv) ;
SimpleGMap3 sqt ;
sqt.setGeometry(0, 0, 1000, 800) ;
sqt.show() ;
sqt.initGUI() ;
return app.exec() ;
}
/*******************************************************************************
* 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 <iostream>
#include "Utils/qtSimple.h"
#include "Topology/generic/parameters.h"
#include "Topology/gmap/embeddedGMap3.h"
#include "Geometry/vector_gen.h"
#include "Algo/Render/GL1/topo_render.h"
using namespace CGoGN ;
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedGMap3 MAP ;
};
typedef PFP::MAP MAP ;
typedef PFP::VEC3 VEC3 ;
class SimpleGMap3 : public Utils::QT::SimpleQT
{
Q_OBJECT
public:
MAP myMap ;
SelectorTrue allDarts ;
PFP::TVEC3 position ;
SimpleGMap3() ;
void initGUI() ;
void cb_initGL() ;
void cb_redraw() ;
};
......@@ -31,6 +31,7 @@
#include "Topology/generic/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Algo/Import/import.h"
#include "Algo/Geometry/boundingbox.h"
......
......@@ -144,8 +144,8 @@ int main(int argc, char **argv)
/// on reprend la carte de tuto1
Dart d2 = myMap.newOrientedFace(3);
Dart d3 = myMap.newOrientedFace(4);
Dart d2 = myMap.newFace(3);
Dart d3 = myMap.newFace(4);
myMap.sewFaces(d2, d3);
position = myMap.addAttribute<Geom::Vec3f>(VERTEX, "position");
......
......@@ -109,8 +109,8 @@ int main(int argc, char **argv)
PFP::TVEC3 normal ;
AttributeHandler<Geom::Vec3f> color ;
Dart d2 = myMap.newOrientedFace(3);
Dart d3 = myMap.newOrientedFace(4);
Dart d2 = myMap.newFace(3);
Dart d3 = myMap.newFace(4);
myMap.sewFaces(d2,d3);
position = myMap.addAttribute<PFP::VEC3>(VERTEX, "position");
......@@ -203,7 +203,7 @@ int main(int argc, char **argv)
PFP::TVEC3 position2 ;
AttributeHandler<Geom::Vec3f> color2 ;
Dart dx = myMap2.newOrientedFace(4);
Dart dx = myMap2.newFace(4);
position2 = myMap2.addAttribute<PFP::VEC3>(VERTEX, "position");
color2 = myMap2.addAttribute<PFP::VEC3>(VERTEX, "couleur");
......
......@@ -64,7 +64,7 @@ bool isPointInVolume(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3&
* @param the point
*/
template <typename PFP>
bool isPointInConvexVolume(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& point, bool CCW);
bool isPointInConvexVolume(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& positions, const typename PFP::VEC3& point, bool CCW=true);
/**
* test if a point is inside a face in a plane
......
......@@ -274,6 +274,10 @@ public:
*/
bool neighborhoodLevelDiffersByOne(Dart d);
/**
* wired !!!
*/
bool coarsenNeighborhoodLevelDiffersByOne(Dart d);
} ;
template <typename T>
......
......@@ -244,7 +244,7 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_vertex(Dart d, FunctorType
bool found = false; // Last functor return value
std::vector<Dart> darts_list; //Darts that are traversed
darts_list.reserve(50);
darts_list.reserve(512);
darts_list.push_back(d); //Start with the dart d
mv.mark(d);
......@@ -288,11 +288,8 @@ inline bool ImplicitHierarchicalMap3::foreach_dart_of_edge(Dart d, FunctorType&
if (f(dNext))
return true;
Dart d2 = phi2(dNext);
if (d2 != dNext)
return f(d2);
else
return false;
if (f(phi2(dNext)))
return true;
dNext = alpha2(dNext);
} while (dNext != d);
......
......@@ -41,11 +41,15 @@ enum SubdivideType
S_QUAD
} ;
/***********************************************************************************
* Subdivision *
***********************************************************************************/
template <typename PFP>
void subdivideEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position) ;
template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
void subdivideFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType = S_TRI);
template <typename PFP>
Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
......@@ -54,16 +58,18 @@ template <typename PFP>
Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
Dart subdivideVolumeOld(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
//template <typename PFP>
//void subdivideLoop(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/***********************************************************************************
* Simplification *
***********************************************************************************/
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType = S_TRI);
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
......@@ -77,27 +83,7 @@ void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
template <typename PFP>
void splitVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/*******************************************************
*
*/
template <typename PFP>
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType);
template <typename PFP>
Dart subdivideFaceTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void subdivideVolumeTri(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void macCrackenJoy(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void bajaj(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
typename PFP::VEC3 bajajMask(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
} //namespace IHM
......
......@@ -60,6 +60,16 @@ enum { NONE,GRID, CUBE, CYLINDER, CONE, SPHERE, TORE, COMPOSED };
// template <typename PFP>
// Dart triangleFan_topo(typename PFP::MAP& the_map, int n);
/**
* Unsex the Umbrella aroud a vertex, close the hole and then
* create a symetric to construct a polyedron
* @param d a dart from the vertex
*/
template <typename PFP>
void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 position);
/**
* class of geometric Polyhedron
* It alloaw the creation of:
......
......@@ -31,6 +31,92 @@ namespace Algo
namespace Modelisation
{
template <typename PFP>
void explodPolyhedron(typename PFP::MAP& map, Dart d, typename PFP::TVEC3 position)
{
map.unsewVertexUmbrella(d);
unsigned int newFaceDegree = map.closeHole(map.phi1(d));
if(newFaceDegree != 3)
{
//chercher le brin ou demarer
std::multimap<Dart, int> edges ;
typename std::multimap<Dart, int>::iterator it ;
Dart d12 = map.phi2(map.phi1(d));
Dart fit = d12;
int i;
do
{
i = map.faceDegree(map.phi2(fit));
std::cout << "edge(" << fit << "," << i << ")" << std::endl;
edges.insert(std::make_pair(fit, i));
fit = map.phi1(fit);
}
while(fit != d12);
do
{
//44 44
if(edges.find(fit)->second == 4 && edges.find(map.phi1(fit))->second == 4
&& !map.sameFace(map.phi2(fit), map.phi2(map.phi1(fit))))
{
map.splitFace(fit, map.phi1(map.phi1(fit)));
fit = map.phi2(map.phi_1(fit));
int i = map.faceDegree(fit);
edges.insert(std::make_pair(fit, i));
// Dart fit2 = map.phi2(fit) ;
// typename PFP::VEC3 p1 = position[fit] ;
// typename PFP::VEC3 p2 = position[fit2] ;
//
// map.cutEdge(fit) ;
// position[map.phi1(fit)] = typename PFP::REAL(0.5) * (p1 + p2);
std::cout << "flip cas quad quad " << std::endl;
}
//3 3
if(edges.find(fit)->second == 3 && edges.find(map.phi1(fit))->second == 3
&& !map.sameFace(map.phi2(fit), map.phi2(map.phi1(fit))))
{
map.splitFace(fit, map.phi1(fit));
fit = map.phi2(map.phi_1(fit));
int i = map.faceDegree(fit);
edges.insert(std::make_pair(fit, i));
std::cout << "flip cas tri tri" << std::endl;
}
//3 44 ou 44 3
if( ((edges.find(fit)->second == 4 && edges.find(map.phi1(fit))->second == 3)
|| (edges.find(fit)->second == 3 && edges.find(map.phi1(fit))->second == 4))
&& !map.sameFace(map.phi2(fit), map.phi2(map.phi1(fit))))
{
map.splitFace(fit, map.phi1(map.phi1(fit)));
fit = map.phi2(map.phi_1(fit));
int i = map.faceDegree(fit);
edges.insert(std::make_pair(fit, i));
std::cout << "flip cas quad tri" << std::endl;
}
fit = map.phi1(fit);
}
while(map.faceDegree(fit) > 4 && fit != d12);
}
}
template <typename PFP>
Polyhedron<PFP>::Polyhedron(const Polyhedron<PFP>& p1, const Polyhedron<PFP>& p2):
m_map(p1.m_map),
......
/*******************************************************************************
* 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 __SUBDIVISION3MAP_H__
#define __SUBDIVISION3MAP_H__
#include <math.h>
#include <vector>
namespace CGoGN
{
namespace Algo
{
namespace Modelisation
{
/**
* Cut a 3D ear from a mesh : the ear is sewn by phi3 to the rest of the volume
* @param d dart of the point of the ear
* @return a dart from the new face connecting the ear and the rest of the volume
*/
template <typename PFP>
Dart cut3Ear(typename PFP::MAP& map, Dart d);
/**
* subdivide a hexahedron into 5 tetrahedron
* @param d dart of the hexahedron
*/
template <typename PFP>
void hexahedronToTetrahedron(typename PFP::MAP& map, Dart d);
/**
* catmull clark volumic : do not move the original vertices
* @param map the map
* @param attributs geometric attributes of the vertices
* @param selected a functor to select volumes to subdivide
* TODO : test if it works for the functorselect
*/
template <typename PFP, typename EMBV, typename EMB>
void catmullClarkVol(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected= SelectorTrue());
template <typename PFP>
void catmullClarkVol(typename PFP::MAP& map, typename PFP::TVEC3& position, const FunctorSelect& selected= SelectorTrue())
{
catmullClarkVol<PFP,typename PFP::TVEC3, typename PFP::VEC3>(map, position, selected);
}
} // namespace Modelisation
} // namespace Algo
} // namespace CGoGN
#include "Algo/Modelisation/subdivision3map.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 *
* *
*******************************************************************************/
#include "Algo/Geometry/centroid.h"
#include "Algo/Modelisation/subdivision.h"
#include "Algo/Modelisation/extrusion.h"
namespace CGoGN
{
namespace Algo
{
namespace Modelisation
{
template <typename PFP>
Dart cut3Ear(typename PFP::MAP& map, Dart d)
{
Dart e=d;
int nb=0;
Dart dNew;
Dart dRing;
Dart dRing2;
//count the valence of the vertex
do
{
nb++;
e=map.phi1(map.phi2(e));
} while (e!=d);
if(nb<3)
{
CGoGNout << "Warning : cannot cut 2 volumes without creating a degenerated face " << CGoGNendl;
return d;
}
else
{
//triangulate around the vertex
do
{
Dart dN = map.phi1(map.phi2(e));
if(map.template phi<111>(e)!=e)
map.splitFace(map.phi_1(e), map.phi1(e));
dRing = map.phi1(e);