Update LCC examples

This commit is contained in:
Guillaume Damiand 2016-10-28 17:46:55 -04:00
parent e7687061c3
commit 5d0ce4fea4
12 changed files with 726 additions and 328 deletions

View File

@ -11,8 +11,8 @@ endif()
# If you want to visualize a linear cell complex, you can use the following viewer
# based on qt. Just uncomment the following two lines, plus the lines qt5_use_modules below
# find_package(CGAL COMPONENTS Qt5)
# include("CMakeLCCViewerQt.inc")
find_package(CGAL COMPONENTS Qt5)
include("CMakeLCCViewerQt.inc")
# If you don't want to visualize, use the following line (otherwise comment it)
find_package(CGAL QUIET)
@ -43,15 +43,21 @@ if ( CGAL_FOUND )
add_executable(voronoi_2 voronoi_2.cpp)
target_link_libraries(voronoi_2 ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}
${MAP_VIEWER_LIBRARIES})
# qt5_use_modules(voronoi_2 ${MAP_VIEWER_MODULES})
qt5_use_modules(voronoi_2 ${MAP_VIEWER_MODULES})
add_executable(voronoi_3 voronoi_3.cpp)
target_link_libraries(voronoi_3 ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}
${MAP_VIEWER_LIBRARIES})
# qt5_use_modules(voronoi_3 ${MAP_VIEWER_MODULES})
qt5_use_modules(voronoi_3 ${MAP_VIEWER_MODULES})
create_single_source_cgal_program( "gmap_linear_cell_complex_3.cpp" )
add_executable(linear_cell_complex_3_operations linear_cell_complex_3_operations.cpp)
target_link_libraries(linear_cell_complex_3_operations ${CGAL_LIBRARIES} ${CGAL_3RD_PARTY_LIBRARIES}
${MAP_VIEWER_LIBRARIES})
qt5_use_modules(linear_cell_complex_3_operations ${MAP_VIEWER_MODULES})
else()
message(STATUS "This program requires the CGAL library, "

View File

@ -1,5 +1,4 @@
#include <CGAL/Linear_cell_complex_for_generalized_map.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <iostream>
#include <algorithm>

View File

@ -1,5 +1,4 @@
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <iostream>
#include <algorithm>

View File

@ -1,5 +1,4 @@
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Linear_cell_complex_constructors.h>
#include <CGAL/Timer.h>
#include <iostream>

View File

@ -0,0 +1,90 @@
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Linear_cell_complex_for_generalized_map.h>
#include <vector>
/* If you want to use a viewer, you can use qglviewer. */
#ifdef CGAL_LCC_USE_QT
#include "linear_cell_complex_3_viewer_qt.h"
#endif
typedef CGAL::Linear_cell_complex_for_combinatorial_map<3> LCC_3_cmap;
typedef CGAL::Linear_cell_complex_for_generalized_map<3> LCC_3_gmap;
template<typename LCC,
typename Map=typename LCC::Combinatorial_data_structure>
struct Alpha1
{
static typename LCC::Dart_handle run(LCC&, typename LCC::Dart_handle dh)
{ return dh; }
};
template<typename LCC>
struct Alpha1<LCC, CGAL::Generalized_map_tag>
{
static typename LCC::Dart_handle run(LCC& lcc, typename LCC::Dart_handle dh)
{ return lcc.template alpha<1>(dh); }
};
template<typename LCC>
void run_test()
{
typedef typename LCC::Point Point;
typedef typename LCC::Dart_handle Dart_handle;
LCC lcc;
Dart_handle dh1 = lcc.
make_hexahedron(Point(0,0,0),Point(1,0,0),
Point(1,2,0),Point(0,2,0),
Point(0,3,4),Point(0,0,4),
Point(6,0,4),Point(6,3,4));
Dart_handle dh2 = lcc.
make_hexahedron(Point(0,-5,0),Point(2,-5,0),
Point(2,-2,0),Point(0,-2,0),
Point(1,-1,5),Point(1,-2,5),
Point(5,-2,5),Point(5,-2,5));
Dart_handle dh3 = lcc.
make_hexahedron(Point(1,0,5),Point(0,0,6),
Point(0,2,5),Point(1,2,6),
Point(1,3,8),Point(0,0,8),
Point(5,0,9),Point(7,3,9));
lcc.template sew<3>(dh1,lcc.other_orientation
(lcc.template opposite<2>
(lcc.next(lcc.next(lcc.template opposite<2>(dh2))))));
lcc.template sew<3>(lcc.template opposite<2>(lcc.next(dh1)),
lcc.other_orientation(lcc.template opposite<2>(lcc.previous(dh3))));
#ifdef CGAL_LCC_USE_VIEWER
display_lcc(lcc);
#endif // CGAL_LCC_USE_VIEWER
lcc.insert_cell_1_in_cell_2(lcc.next(dh1),
Alpha1<LCC>::run(lcc, lcc.previous(dh1)));
dh2=lcc.template opposite<2>(lcc.next(lcc.next
(lcc.template opposite<2>(dh1))));
lcc.insert_cell_1_in_cell_2(dh2, Alpha1<LCC>::run
(lcc, lcc.next(lcc.next(dh2))));
std::vector<Dart_handle> path;
path.push_back(lcc.next(dh1));
path.push_back(lcc.next(lcc.template opposite<2>(lcc.previous(dh1))));
path.push_back(lcc.previous(dh2));
path.push_back(lcc.next(lcc.template opposite<2>(dh2)));
lcc.insert_cell_2_in_cell_3(path.begin(),path.end());
lcc.display_characteristics(std::cout) << ", valid="
<< lcc.is_valid() << std::endl;
#ifdef CGAL_LCC_USE_VIEWER
display_lcc(lcc);
#endif // CGAL_LCC_USE_VIEWER
}
int main()
{
run_test<LCC_3_cmap>();
run_test<LCC_3_gmap>();
return EXIT_SUCCESS;
}

View File

@ -1,5 +1,4 @@
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <iostream>
#include <algorithm>

View File

@ -1,5 +1,4 @@
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <iostream>
#include <algorithm>

View File

@ -1,5 +1,4 @@
#include <CGAL/Linear_cell_complex_for_generalized_map.h>
#include <CGAL/Linear_cell_complex_constructors.h>
#include <iostream>
#include <vector>

View File

@ -1,4 +1,4 @@
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Linear_cell_complex_constructors.h>
#include <iostream>
#include <fstream>

View File

@ -1,6 +1,5 @@
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_constructors.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Linear_cell_complex_for_generalized_map.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_2_to_lcc.h>
@ -12,13 +11,9 @@
#include "linear_cell_complex_3_viewer_qt.h"
#endif
/* // If you want to use exact constructions.
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
typedef CGAL::Linear_cell_complex_for_combinatorial_map<2,2,
CGAL::Linear_cell_complex_traits<2, CGAL::Exact_predicates_exact_constructions_kernel> > LCC_2;
*/
typedef CGAL::Linear_cell_complex_for_combinatorial_map<2> LCC_2;
// This example works both with cmap and gmap as combinatorial data structure.
//typedef CGAL::Linear_cell_complex_for_combinatorial_map<2> LCC_2;
typedef CGAL::Linear_cell_complex_for_generalized_map<2> LCC_2;
typedef LCC_2::Dart_handle Dart_handle;
typedef LCC_2::Point Point;
@ -42,11 +37,11 @@ void display_voronoi(LCC_2& alcc, Dart_handle adart)
it=alcc.darts_of_cell<2>(adart).begin(),
itend=alcc.darts_of_cell<2>(adart).end(); it!=itend; ++it)
{
if ( !alcc.is_marked(alcc.beta(it,2), mark_toremove) )
if ( !alcc.is_marked(alcc.opposite<2>(it), mark_toremove) )
{
CGAL::mark_cell<LCC_2,2>(alcc, alcc.beta(it,2), mark_toremove);
toremove.push(alcc.beta(it,2));
}
CGAL::mark_cell<LCC_2,2>(alcc, alcc.opposite<2>(it), mark_toremove);
toremove.push(alcc.opposite<2>(it));
}
}
while( !toremove.empty() )

View File

@ -1,6 +1,4 @@
#include <CGAL/Linear_cell_complex.h>
#include <CGAL/Linear_cell_complex_constructors.h>
#include <CGAL/Linear_cell_complex_operations.h>
#include <CGAL/Linear_cell_complex_for_combinatorial_map.h>
#include <CGAL/Delaunay_triangulation_3.h>
#include <CGAL/Triangulation_3_to_lcc.h>