Commit 4df69175 authored by Kenneth Vanhoey's avatar Kenneth Vanhoey

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

parents 6144181d 74ad6e7b
......@@ -792,7 +792,7 @@ void Clipping::importMesh(std::string& filename)
if(extension == std::string(".tet"))
{
if(!Algo::Import::importTet<PFP>(myMap,filename.c_str(),attrNames))
if(!Algo::Volume::Import::importTet<PFP>(myMap,filename.c_str(),attrNames))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
......@@ -802,7 +802,7 @@ void Clipping::importMesh(std::string& filename)
}
else if(extension == std::string(".ts"))
{
if(!Algo::Import::importTs<PFP>(myMap,filename.c_str(),attrNames))
if(!Algo::Volume::Import::importTs<PFP>(myMap,filename.c_str(),attrNames))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
......@@ -1124,7 +1124,7 @@ int main(int argc, char** argv)
else
{
sqt.position = sqt.myMap.addAttribute<PFP::VEC3, VERTEX>("position");
Algo::Modelisation::Primitive3D<PFP> prim(sqt.myMap, sqt.position);
Algo::Volume::Modelisation::Primitive3D<PFP> prim(sqt.myMap, sqt.position);
prim.hexaGrid_topo(10,10,10);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
}
......
......@@ -213,7 +213,7 @@ void MyQT::cb_keyPress(int code)
case 't':
{
Algo::Modelisation::EarTriangulation<PFP> triangulation(myMap);
Algo::Surface::Modelisation::EarTriangulation<PFP> triangulation(myMap);
triangulation.triangule();
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
......
......@@ -133,7 +133,7 @@ int main(int argc, char **argv)
}
// extrusion
Algo::Modelisation::extrusion_scale<PFP>(myMap, position, objV, PFP::VEC3(0.0,0.0,0.0), PFP::VEC3(0.0,1.0,0.0),true, pathV, false, pathRadius);
Algo::Surface::Modelisation::extrusion_scale<PFP>(myMap, position, objV, PFP::VEC3(0.0,0.0,0.0), PFP::VEC3(0.0,1.0,0.0),true, pathV, false, pathRadius);
// bounding box
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
......
......@@ -133,9 +133,9 @@ void MCMesh::MC()
{
myMap.clear(false);
// elargir l'image pour le calcul de la courbure
Algo::MC::Image<DATATYPE>* myImgFr = myImg->addFrame(1);
SAlgo::MC::Image<DATATYPE>* myImgFr = myImg->addFrame(1);
Algo::MC::WindowingGreater<DATATYPE> myWindFunc;
SAlgo::MC::WindowingGreater<DATATYPE> myWindFunc;
myWindFunc.setIsoValue(DATATYPE(127));
position = myMap.getAttribute<VEC3, VERTEX>("position");
......@@ -143,7 +143,7 @@ void MCMesh::MC()
position = myMap.addAttribute<VEC3, VERTEX>("position");
// instanciation du mc
Algo::MC::MarchingCube<DATATYPE, Algo::MC::WindowingGreater,PFP> mc(myImgFr, &myMap, position, myWindFunc, false);
SAlgo::MC::MarchingCube<DATATYPE, SAlgo::MC::WindowingGreater,PFP> mc(myImgFr, &myMap, position, myWindFunc, false);
mc.simpleMeshing();
delete myImgFr;
......@@ -168,7 +168,7 @@ void MCMesh::updateRender()
void MCMesh::fromFile(char* fname)
{
myImg = new Algo::MC::Image<DATATYPE>();
myImg = new SAlgo::MC::Image<DATATYPE>();
myImg->loadInrgz(fname);
CGoGNout << "Image chargee"<<CGoGNendl;
CGoGNout << myImg->getWidthX() <<"x"<< myImg->getWidthY() <<"x"<< myImg->getWidthZ() << "voxels"<<CGoGNendl;
......@@ -193,7 +193,7 @@ void MCMesh::sphere()
}
}
myImg = new Algo::MC::Image<DATATYPE>(img,128,128,128,1.0f,1.0f,1.0f,false);
myImg = new SAlgo::MC::Image<DATATYPE>(img,128,128,128,1.0f,1.0f,1.0f,false);
}
......
......@@ -46,6 +46,8 @@
using namespace CGoGN ;
namespace SAlgo = ::CGoGN::Algo::Surface;
struct PFP: public PFP_STANDARD
{
// definition of the map
......@@ -83,7 +85,7 @@ public:
Utils::ShaderSimpleColor* m_simpleColorShader ;
DATATYPE valLabel;
Algo::MC::Image<DATATYPE>* myImg;
SAlgo::MC::Image<DATATYPE>* myImg;
MCMesh() ;
......
......@@ -31,7 +31,7 @@ SimpleGMap2::SimpleGMap2()
{
position = myMap.addAttribute<VEC3, VERTEX>("position");
Dart d = Algo::Modelisation::createTetrahedron<PFP>(myMap);
Dart d = Algo::Surface::Modelisation::createTetrahedron<PFP>(myMap);
position[d] = VEC3(0,0,0);
position[myMap.phi1(d)] = VEC3(10,0,15);
position[myMap.phi_1(d)] = VEC3(10,20,15);
......@@ -41,7 +41,7 @@ SimpleGMap2::SimpleGMap2()
myMap.cutEdge(d);
position[myMap.phi1(d)] = mid;
Algo::Modelisation::Polyhedron<PFP> poly(myMap, position);
Algo::Surface::Modelisation::Polyhedron<PFP> poly(myMap, position);
d = poly.cylinder_topo(5, 1, false, false);
......
......@@ -36,7 +36,7 @@ SimpleGMap3::SimpleGMap3()
CellMarker<EDGE> mE(myMap);
Algo::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(3,1,1);
primCat.embedHexaGrid(2,1,1);
myMap.check();
......@@ -56,14 +56,14 @@ SimpleGMap3::SimpleGMap3()
// Geom::Plane3D<PFP::REAL> pl(VEC3(0.5,0.14,0.5),VEC3(1.5,0.45,0.5),VEC3(0.5,0.15,1.5));
Geom::Plane3D<PFP::REAL> pl(VEC3(-1,-0.5,-0.5),VEC3(-1,-0.5,0.5),VEC3(1,0.5,0.5));
Algo::Modelisation::sliceConvexVolume<PFP>(myMap, position, d, pl);
Algo::Volume::Modelisation::sliceConvexVolume<PFP>(myMap, position, d, pl);
myMap.check();
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(2,0,0);
Algo::Modelisation::Primitive3D<PFP> prim(myMap, position);
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
d = prim.hexaGrid_topo(2,2,1);
prim.embedHexaGrid(1,1,1);
......@@ -88,7 +88,7 @@ SimpleGMap3::SimpleGMap3()
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(0,2,0);
Algo::Modelisation::Primitive3D<PFP> prim2(myMap,position);
Algo::Volume::Modelisation::Primitive3D<PFP> prim2(myMap,position);
d = prim2.hexaGrid_topo(2,1,1);
prim2.embedHexaGrid(1,1,1);
......
......@@ -32,7 +32,7 @@ SimpleMap3::SimpleMap3()
{
position = myMap.addAttribute<VEC3, VERTEX>("position");
Algo::Modelisation::Primitive3D<PFP> primCat(myMap, position);
Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap, position);
Dart d = primCat.hexaGrid_topo(2,1,1);
primCat.embedHexaGrid(1,1,1);
......
......@@ -232,7 +232,7 @@ int main(int argc, char**argv)
#define NB 96
Algo::Modelisation::Polyhedron<PFP> prim(m, position);
Algo::Surface::Modelisation::Polyhedron<PFP> prim(m, position);
prim.tore_topo(NB, NB);
prim.embedTore(40.0f,20.0f);
......
......@@ -188,7 +188,8 @@ void Viewer::cb_Save()
std::string filters("all (*.*);; map (*.map);; off (*.off);; ply (*.ply)") ;
std::string filename = selectFileSave("Save Mesh", "", filters) ;
exportMesh(filename) ;
if (!filename.empty())
exportMesh(filename) ;
}
void Viewer::cb_keyPress(int keycode)
......@@ -218,7 +219,7 @@ void Viewer::importMesh(std::string& filename)
else
{
std::vector<std::string> attrNames ;
if(!Algo::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
if(!Algo::Surface::Import::importMesh<PFP>(myMap, filename.c_str(), attrNames))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
......@@ -242,7 +243,7 @@ void Viewer::importMesh(std::string& filename)
if(!normal.isValid())
normal = myMap.addAttribute<VEC3, VERTEX>("normal") ;
Algo::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
m_positionVBO->updateData(position) ;
m_normalVBO->updateData(normal) ;
......@@ -257,7 +258,7 @@ void Viewer::exportMesh(std::string& filename, bool askExportMode)
std::string extension = filename.substr(pos) ;
if (extension == std::string(".off"))
Algo::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
Algo::Surface::Export::exportOFF<PFP>(myMap, position, filename.c_str(), allDarts) ;
else if (extension.compare(0, 4, std::string(".ply")) == 0)
{
int ascii = 0 ;
......@@ -266,7 +267,7 @@ void Viewer::exportMesh(std::string& filename, bool askExportMode)
std::vector<VertexAttribute<VEC3>*> attributes ;
attributes.push_back(&position) ;
Algo::Export::exportPLYnew<PFP>(myMap, attributes, filename.c_str(), !ascii, allDarts) ;
Algo::Surface::Export::exportPLYnew<PFP>(myMap, attributes, filename.c_str(), !ascii, allDarts) ;
}
else if (extension == std::string(".map"))
myMap.saveMapBin(filename) ;
......
......@@ -52,6 +52,7 @@
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Geometry/normal.h"
#include "Algo/Geometry/convexity.h"
using namespace CGoGN ;
......
......@@ -144,41 +144,28 @@ void MyQT::cb_Open()
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
if(extension == std::string(".tet"))
{
if(!Algo::Import::importTet<PFP>(myMap,filename,attrNames))
{
CGoGNerr << "could not import " << filename << CGoGNendl ;
return;
}
else
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
}
if(extension == std::string(".node"))
if(extension == std::string(".off"))
{
if(!Algo::Import::importMeshV<PFP>(myMap, filename, attrNames, Algo::Import::ImportVolumique::NODE))
if(!Algo::Volume::Import::importMeshToExtrude<PFP>(myMap, filename, attrNames))
{
std::cerr << "could not import " << filename << std::endl ;
return ;
}
else
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]) ;
{
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
myMap.closeMap();
}
}
if(extension == std::string(".off"))
else
{
if(!Algo::Import::importMeshToExtrude<PFP>(myMap, filename, attrNames))
if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
{
std::cerr << "could not import " << filename << std::endl ;
return ;
}
else
{
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
myMap.closeMap();
}
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]) ;
}
color = myMap.addAttribute<PFP::VEC3, VOLUME>("color");
......@@ -386,41 +373,28 @@ int main(int argc, char **argv)
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
if(extension == std::string(".tet"))
if(extension == std::string(".off"))
{
if(!Algo::Import::importTet<PFP>(myMap,argv[1],attrNames))
if(!Algo::Volume::Import::importMeshToExtrude<PFP>(myMap, filename, attrNames))
{
CGoGNerr << "could not import " << argv[1] << CGoGNendl ;
std::cerr << "could not import " << filename << std::endl ;
return 1;
}
else
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
}
if(extension == std::string(".node"))
{
if(!Algo::Import::importMeshV<PFP>(myMap, argv[1], attrNames, Algo::Import::ImportVolumique::NODE))
{
std::cerr << "could not import " << argv[1] << std::endl ;
return 1;
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
myMap.closeMap();
}
else
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]) ;
}
if(extension == std::string(".off"))
else
{
if(!Algo::Import::importMeshToExtrude<PFP>(myMap, argv[1], attrNames))
if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
{
std::cerr << "could not import " << std::endl ;
std::cerr << "could not import " << filename << std::endl ;
return 1;
}
else
{
position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]) ;
myMap.closeMap();
}
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]) ;
}
color = myMap.addAttribute<PFP::VEC3, VOLUME>("color");
......@@ -443,11 +417,17 @@ int main(int argc, char **argv)
else
{
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
Algo::Modelisation::Primitive3D<PFP> prim(myMap, position);
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
int nb = 8;
prim.hexaGrid_topo(nb,nb,nb);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
for (unsigned int i=position.begin(); i != position.end(); position.next(i))
{
PFP::VEC3 pert(float(double(rand())/RAND_MAX/20.0),float(double(rand())/RAND_MAX/20.0),float(double(rand())/RAND_MAX/20.0));
position[i]+= pert;
}
color = myMap.addAttribute<PFP::VEC3, VOLUME>("color");
TraversorW<PFP::MAP> tra(myMap);
for (Dart d = tra.begin(); d != tra.end(); d = tra.next())
......
......@@ -80,6 +80,14 @@ target_link_libraries( show_traversors
add_executable( tuto_subdivision tuto_subdivision.cpp)
target_link_libraries( tuto_subdivision
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
add_executable( tuto_dual2 tuto_dual2.cpp)
target_link_libraries( tuto_dual2
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
add_executable( tuto_dual3 tuto_dual3.cpp)
target_link_libraries( tuto_dual3
${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
#QT4_WRAP_CPP(tp_master_moc tp_master.h)
#add_executable( tp_master tp_master.cpp ${tp_master_moc})
......
......@@ -603,7 +603,7 @@ int main(int argc, char **argv)
{
position = myMap.addAttribute<VEC3, VERTEX>( "position");
Algo::Modelisation::Primitive3D<PFP> prim(myMap, position);
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
dglobal = prim.hexaGrid_topo(4,4,4);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
......
......@@ -110,7 +110,7 @@ void MyQT::createMap()
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
CGoGNout << "Dart "<< d;
if (myMap.isBoundaryMarked(d))
if (myMap.isBoundaryMarked<PFP::MAP::DIMENSION>(d))
CGoGNout << " is a boundary dart (implicitly added)"<< CGoGNendl;
else
{
......
......@@ -154,7 +154,7 @@ void MyQT::createMap()
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
Algo::Modelisation::Polyhedron<PFP> prim1(myMap, position);
Algo::Surface::Modelisation::Polyhedron<PFP> prim1(myMap, position);
prim1.cylinder_topo(256, 256, true, true); // topo of sphere is a closed cylinder
prim1.embedSphere(2.0f);
......@@ -167,7 +167,7 @@ void MyQT::createMap()
// d2 = PHI<211>(d2);
// position[d2] = PFP::VEC3(0, 1, 2);
Algo::Modelisation::Polyhedron<PFP> prim2(myMap, position);
Algo::Surface::Modelisation::Polyhedron<PFP> prim2(myMap, position);
prim2.cylinder_topo(256, 256, true, true); // topo of sphere is a closed cylinder
prim2.embedSphere(2.0f);
......
......@@ -119,7 +119,7 @@ void MyQT::traverseMap()
void MyQT::createMap()
{
Dart d1 = Algo::Modelisation::createHexahedron<PFP>(myMap);
Dart d1 = Algo::Surface::Modelisation::createHexahedron<PFP>(myMap);
Dart d2 = d1;
......
......@@ -259,7 +259,7 @@ void MyQT::cb_keyPress(int code)
if(code == 'c')
{
//SelectorDartNoBoundary<PFP::MAP> nb(myMap);
Algo::Modelisation::catmullClarkVol<PFP>(myMap, position);
Algo::Volume::Modelisation::catmullClarkVol<PFP>(myMap, position);
m_positionVBO->updateData(position);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
......@@ -277,7 +277,7 @@ int main(int argc, char **argv)
CGoGNout << 5.34 << " toto "<< Geom::Vec3f(2.5f, 2.2f, 4.3f) << CGoGNendl;
CGoGNout << 3 << " tutu "<< 4 << CGoGNendl;
Algo::Modelisation::Primitive3D<PFP> prim(myMap, position);
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
int nb=3;
if (argc>1)
nb = atoi(argv[1]);
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include <iostream>
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Algo/Import/import.h"
#include "Algo/Export/export.h"
#include <typeinfo>
#include "Algo/Modelisation/subdivision.h"
using namespace CGoGN ;
/**
* Struct that contains some informations about the types of the manipulated objects
* Mainly here to be used by the algorithms that are parameterized by it
*/
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2 MAP;
};
int main(int argc, char **argv)
{
if(argc != 2)
{
CGoGNout << "Usage : " << argv[0] << " filename" << CGoGNendl;
return 0;
}
std::string filename(argv[1]);
// declaration of the map
PFP::MAP myMap;
std::vector<std::string> attrNames ;
Algo::Surface::Import::importMesh<PFP>(myMap, argv[1], attrNames);
// get a handler to the 3D vector attribute created by the import
VertexAttribute<PFP::VEC3> position = myMap.getAttribute<PFP::VEC3, VERTEX>(attrNames[0]);
FaceAttribute<PFP::VEC3> positionF = myMap.getAttribute<PFP::VEC3, FACE>("position") ;
if(!positionF.isValid())
positionF = myMap.addAttribute<PFP::VEC3, FACE>("position") ;
Algo::Surface::Geometry::computeCentroidFaces<PFP>(myMap, position, positionF) ;
myMap.computeDual();
position = positionF ;
Algo::Surface::Export::exportOFF<PFP>(myMap, position, "result.off");
std::cout << "Exported" << std::endl;
return 0;
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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 *