Commit 19872ac9 authored by Pierre Kraemer's avatar Pierre Kraemer

Merge branch 'develop' of cgogn:~thery/CGoGNMR into develop

Conflicts:
	include/Topology/map/map2.h
	include/Topology/map/map2.hpp
parents 9cb5f9c5 2f3a34b6
......@@ -37,3 +37,6 @@ add_subdirectory(Examples/Tests)
add_subdirectory(Tuto/Traversals)
add_subdirectory(Tuto/Attributes)
add_subdirectory(Tuto/Markers)
add_subdirectory(Tuto/Boundary)
add_subdirectory(Tuto/Modelling)
cmake_minimum_required(VERSION 2.8)
project(Tuto_Traversals)
SET (CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CGoGN_ROOT_DIR}/include
${CGoGN_EXT_INCLUDES}
)
# define libs path
IF(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/$(ConfigurationName)
${Boost_LIBRARY_DIRS})
ELSE(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/Release ${CGoGN_ROOT_DIR}/lib/Debug)
ENDIF(WIN32)
#define exec to compile
add_executable( boundaries boundaries.cpp)
target_link_libraries( boundaries ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
/*******************************************************************************
* 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Algo/Tiling/Surface/square.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 type of the map
typedef EmbeddedMap2 MAP;
};
// some typedef shortcuts
typedef PFP::MAP MAP ; // map type
typedef PFP::MAP::IMPL MAP_IMPL ; // map implementation
typedef PFP::VEC3 VEC3 ; // type of R³ vector
int main()
{
// declare a map to handle the mesh
MAP myMap;
// add position attribute on vertices and get handler on it
VertexAttribute<VEC3, MAP_IMPL> position = myMap.addAttribute<VEC3, VERTEX>("position");
// create a topo grid of 2x2 squares
Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, 3, 3, true);
// and embed it using position attribute
grid.embedIntoGrid(position, 1.,1.,0.);
// traverse all darts of map and test if they belong to the boundary
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (myMap.isBoundaryMarked<2>(d)) // 2 because myMap is Map2 (can use isBoundaryMarkedCurrent)
std::cout << "Dart of boundary" << std::endl;
}
std::cout << std::endl;
// traverse all vertices of mesh and test if they belong to the boundary
foreach_cell<VERTEX>(myMap,[&myMap](Vertex v) // for all edge e of map do
{
if (myMap.isBoundaryVertex(v))
std::cout << "vertex of boundary"<< std::endl;
else
std::cout << "normal vertex"<< std::endl;
});
std::cout << std::endl;
// traverse all edges of mesh and test if they belong to the boundary
foreach_cell<EDGE>(myMap,[&myMap](Edge e) // for all edge e of map do
{
if (myMap.isBoundaryEdge(e))
std::cout << "edge of boundary"<< std::endl;
else
std::cout << "normal edge"<< std::endl;
});
std::cout << std::endl;
//It does not work with FACE because foreach and Traversors do not traverse the boundary faces
foreach_cell<FACE>(myMap,[&myMap](Face v) // for all edge e of map do
{
if (myMap.isBoundaryMarked<2>(v.dart))
std::cout << "boundary face"<< std::endl;
else
std::cout << "normal face"<< std::endl;
});
std::cout << std::endl;
return 0;
}
cmake_minimum_required(VERSION 2.8)
project(Tuto_Traversals)
SET (CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CGoGN_ROOT_DIR}/include
${CGoGN_EXT_INCLUDES}
)
# define libs path
IF(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/$(ConfigurationName)
${Boost_LIBRARY_DIRS})
ELSE(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/Release ${CGoGN_ROOT_DIR}/lib/Debug)
ENDIF(WIN32)
#define exec to compile
add_executable( dartmarkers dartmarkers.cpp)
target_link_libraries( dartmarkers ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
add_executable( cellmarkers cellmarkers.cpp)
target_link_libraries( cellmarkers ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
/*******************************************************************************
* 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Algo/Tiling/Surface/square.h"
#include "Topology/generic/cellmarker.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 type of the map
typedef EmbeddedMap2 MAP;
};
// some typedef shortcuts
typedef PFP::MAP MAP ; // map type
typedef PFP::MAP::IMPL MAP_IMPL ; // map implementation
typedef PFP::VEC3 VEC3 ; // type of R³ vector
// example of cell marking with CellMarker for a simple traversal
template<unsigned int ORBIT>
void simpleTraversal(MAP& map) // NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
CellMarker<MAP,ORBIT> cm(map);
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!cm.isMarked(d)) // is the cell (of dart d) not marked ?
{
std::cout << orbitName(ORBIT)<< " of dart "<< d << std::endl;
cm.mark(d); // mark the cell
}
}
std::cout << std::endl;
// all cells are unmarked automatically during the destruction of the CellMarker
}
// example of cell marking with CellMarkerNoUnmark for a double traversal
template<unsigned int ORBIT>
void doubleTraversal(MAP& map) // NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
CellMarkerNoUnmark<MAP,ORBIT> cm(map);
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!cm.isMarked(d)) // is the cell (of dart d) not marked ?
{
std::cout << "First Pass" << orbitName(ORBIT)<< " of dart "<< d << std::endl;
cm.mark(d); // mark the cell
}
}
std::cout << std::endl;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (cm.isMarked(d)) // is the cell (of dart d) marked ?
{
std::cout << "second Pass" << orbitName(ORBIT)<< " of dart "<< d << std::endl;
cm.unmark(d); // unmark the cell
}
}
std::cout << std::endl;
// destructor does not clean the markers
// user MUST ensure that he has unmark all he has marked
}
// example of usage of CellMarkerStore
void negativePositions(MAP& map, VertexAttribute<VEC3,MAP_IMPL>& position) // NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
// if user knows that small numbers of cell will be marked
// it is more efficient to store them instead of traverse
// all darts for cleanning. CellMarkerStore do it for you.
CellMarkerStore<MAP,VERTEX> cms(map);
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!cms.isMarked(d) && (position[d][0]<= 0.0) && (position[d][1]<= 0.0))
{
std::cout << "position["<<d<<"] < (0,0)" << std::endl;
cms.mark(d);
}
}
std::cout << std::endl;
}
int main()
{
// declare a map to handle the mesh
MAP myMap;
// add position attribute on vertices and get handler on it
VertexAttribute<VEC3, MAP_IMPL> position = myMap.addAttribute<VEC3, VERTEX>("position");
// create a topo grid of 2x2 squares
Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, 2, 2, true);
// and embed it using position attribute
grid.embedIntoGrid(position, 1.,1.,0.);
simpleTraversal<VERTEX>(myMap);
doubleTraversal<FACE>(myMap);
negativePositions(myMap,position);
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 *
* 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Algo/Tiling/Surface/square.h"
#include "Topology/generic/dartmarker.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 type of the map
typedef EmbeddedMap2 MAP;
};
// some typedef shortcuts
typedef PFP::MAP MAP ; // map type
typedef PFP::MAP::IMPL MAP_IMPL ; // map implementation
typedef PFP::VEC3 VEC3 ; // type of R³ vector
// example of cell marking with CellMarker for a simple traversal
template<unsigned int ORBIT>
void simpleTraversal(MAP& map) // NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
DartMarker<MAP> dm(map);
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!dm.isMarked(d)) // is dart not marked ?
{
std::cout << orbitName(ORBIT)<< " of dart "<< d << std::endl;
dm.markOrbit<ORBIT>(d); // mark all darts of orbit
}
}
std::cout << std::endl;
// all darts are unmarked automatically during the destruction of the DartMarker
}
// example of cell marking with CellMarkerNoUnmark for a double traversal
template<unsigned int ORBIT>
void doubleTraversal(MAP& map) // NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
DartMarkerNoUnmark<MAP> dm(map);
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!dm.isMarked(d)) // is dart not marked ?
{
std::cout << "First Pass" << orbitName(ORBIT)<< " of dart "<< d << std::endl;
dm.markOrbit<ORBIT>(d); // mark the orbit
}
}
std::cout << std::endl;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (dm.isMarked(d)) // is marked ?
{
std::cout << "second Pass" << orbitName(ORBIT)<< " of dart "<< d << std::endl;
dm.unmarkOrbit<ORBIT>(d); // unmark the orbit
}
}
std::cout << std::endl;
// destructor does not clean the markers
// user MUST ensure that he has unmark all he has marked
}
// example of usage of CellMarkerStore
void negativePositions(MAP& map, VertexAttribute<VEC3,MAP_IMPL>& position) // NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
// if user knows that small numbers of cell will be marked
// it is more efficient to store them instead of traverse
// all darts for cleanning. CellMarkerStore do it for you.
DartMarkerStore<MAP> dms(map);
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!dms.isMarked(d) && (position[d][0]<= 0.0) && (position[d][1]<= 0.0))
{
std::cout << "position["<<d<<"] < (0,0)" << std::endl;
dms.markOrbit<VERTEX>(d);
}
}
std::cout << std::endl;
}
int main()
{
// declare a map to handle the mesh
MAP myMap;
// add position attribute on vertices and get handler on it
VertexAttribute<VEC3, MAP_IMPL> position = myMap.addAttribute<VEC3, VERTEX>("position");
// create a topo grid of 2x2 squares
Algo::Surface::Tilings::Square::Grid<PFP> grid(myMap, 2, 2, true);
// and embed it using position attribute
grid.embedIntoGrid(position, 1.,1.,0.);
simpleTraversal<VERTEX>(myMap);
doubleTraversal<FACE>(myMap);
negativePositions(myMap,position);
return 0;
}
cmake_minimum_required(VERSION 2.8)
project(Tuto_Traversals)
SET (CMAKE_BUILD_TYPE Debug)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOTOPOWARNING")
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CGoGN_ROOT_DIR}/include
${CGoGN_EXT_INCLUDES}
)
# define libs path
IF(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/$(ConfigurationName)
${Boost_LIBRARY_DIRS})
ELSE(WIN32)
link_directories(${CGoGN_ROOT_DIR}/lib/Release ${CGoGN_ROOT_DIR}/lib/Debug)
ENDIF(WIN32)
#define exec to compile
add_executable( basics basics.cpp)
target_link_libraries( basics ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
/*******************************************************************************
* 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Algo/Tiling/Surface/square.h"
#include "Topology/generic/cellmarker.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 type of the map
typedef EmbeddedMap2 MAP;
};
// some typedef shortcuts
typedef PFP::MAP MAP ; // map type
typedef PFP::MAP::IMPL MAP_IMPL ; // map implementation
typedef PFP::VEC3 VEC3 ; // type of R³ vector
// example of cell marking with CellMarker for a simple traversal
template<unsigned int ORBIT>
void simpleTraversal(MAP& map) // NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
CellMarker<MAP,ORBIT> cm(map);
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!cm.isMarked(d)) // is the cell (of dart d) not marked ?
{
std::cout << orbitName(ORBIT)<< " of dart "<< d << std::endl;
cm.mark(d); // mark the cell
}
}
std::cout << std::endl;
// all cells are unmarked automatically during the destruction of the CellMarker
}
// example of cell marking with CellMarkerNoUnmark for a double traversal
template<unsigned int ORBIT>
void doubleTraversal(MAP& map) // NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
CellMarkerNoUnmark<MAP,ORBIT> cm(map);
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!cm.isMarked(d)) // is the cell (of dart d) not marked ?
{
std::cout << "First Pass" << orbitName(ORBIT)<< " of dart "<< d << std::endl;
cm.mark(d); // mark the cell
}
}
std::cout << std::endl;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (cm.isMarked(d)) // is the cell (of dart d) marked ?
{
std::cout << "second Pass" << orbitName(ORBIT)<< " of dart "<< d << std::endl;
cm.unmark(d); // unmark the cell
}
}
std::cout << std::endl;
// destructor does not clean the markers
// user MUST ensure that he has unmark all he has marked
}
// example of usage of CellMarkerStore
void negativePositions(MAP& map, VertexAttribute<VEC3,MAP_IMPL>& position) // NEVER COPY THE MAP, ALWAYS USE REFERENCE !!
{
// if user knows that small numbers of cell will be marked
// it is more efficient to store them instead of traverse
// all darts for cleanning. CellMarkerStore do it for you.
CellMarkerStore<MAP,VERTEX> cms(map);
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (!cms.isMarked(d) && (position[d][0]<= 0.0) && (position[d][1]<= 0.0))
{
std::cout << "position["<<d<<"] < (0,0)" << std::endl;
cms.mark(d);
}
}
std::cout << std::endl;
}
int main()
{
// declare a map to handle the mesh
MAP myMap;
// add position attribute on vertices and get handler on it
VertexAttribute<VEC3, MAP_IMPL> position = myMap.addAttribute<VEC3, VERTEX>("position");
// create a triangle