mirror of https://github.com/CGAL/cgal
additions to testsuite
This commit is contained in:
parent
8c07c434f1
commit
33fee92bdb
|
|
@ -360,9 +360,21 @@ BGL/include/CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h -text
|
|||
BGL/include/CGAL/boost/graph/named_function_params.h -text
|
||||
BGL/include/CGAL/boost/graph/properties.h -text
|
||||
BGL/include/CGAL/boost/graph/properties_Polyhedron_3.h -text
|
||||
BGL/test/BGL/data/7_faces_traingle.off -text
|
||||
BGL/test/BGL/data/genus3.off -text
|
||||
BGL/test/BGL/data/head.off -text
|
||||
BGL/test/BGL/data/hedra.off -text
|
||||
BGL/test/BGL/data/hedra_open.off -text
|
||||
BGL/test/BGL/data/open_cube.off -text
|
||||
BGL/test/BGL/data/rombus.off -text
|
||||
BGL/test/BGL/data/tetrahedron.off -text
|
||||
BGL/test/BGL/data/triangle.off -text
|
||||
BGL/test/BGL/data/triangular_hole.off -text
|
||||
BGL/test/BGL/halfedge_graph_traits_Polyhedron_3.cpp -text
|
||||
BGL/test/BGL/makefile -text
|
||||
BGL/test/BGL/properties_Polyhedron_3.cpp -text
|
||||
BGL/test/BGL/test_prefix_Polyhedron_3.cpp -text
|
||||
BGL/test/BGL/test_suffix_Polyhedron_3.cpp -text
|
||||
Benchmark/doc_tex/Benchmark/Conics_14_1.arr -text
|
||||
Benchmark/doc_tex/Benchmark/fig/Conics_14_1.eps -text svneol=unset#application/postscript
|
||||
Benchmark/doc_tex/Benchmark/fig/Conics_14_1.png -text svneol=unset#image/png
|
||||
|
|
|
|||
|
|
@ -9,24 +9,23 @@ template < class Refs, class Pln, class ID>
|
|||
class HalfedgeDS_face_max_base_with_id : public HalfedgeDS_face_base< Refs, Tag_true, Pln>
|
||||
{
|
||||
public:
|
||||
typedef HalfedgeDS_face_max_base_with_id< Refs, Pln, ID> Base;
|
||||
|
||||
typedef HalfedgeDS_face_base< Refs, Tag_true, Pln> Base_base ;
|
||||
typedef HalfedgeDS_face_base< Refs, Tag_true, Pln> Base ;
|
||||
|
||||
typedef ID size_type ;
|
||||
|
||||
private:
|
||||
|
||||
size_type id ;
|
||||
size_type mID ;
|
||||
|
||||
public:
|
||||
|
||||
HalfedgeDS_face_max_base_with_id() : id ( size_type(-1) ) {}
|
||||
HalfedgeDS_face_max_base_with_id( Pln const& p) : Base_base(p), id ( size_type(-1) ) {}
|
||||
HalfedgeDS_face_max_base_with_id( Pln const& p, size_type i ) : Base_base(p), id (i) {}
|
||||
HalfedgeDS_face_max_base_with_id() : mID ( size_type(-1) ) {}
|
||||
HalfedgeDS_face_max_base_with_id( Pln const& p) : Base(p), mID ( size_type(-1) ) {}
|
||||
HalfedgeDS_face_max_base_with_id( Pln const& p, size_type i ) : Base(p), mID (i) {}
|
||||
|
||||
size_type& id() { return id; }
|
||||
size_type const& id() const { return id; }
|
||||
size_type& id() { return mID; }
|
||||
size_type const& id() const { return mID; }
|
||||
};
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -9,22 +9,22 @@ template < class Refs, class ID>
|
|||
class HalfedgeDS_halfedge_max_base_with_id : public HalfedgeDS_halfedge_base< Refs, Tag_true, Tag_true, Tag_true >
|
||||
{
|
||||
public:
|
||||
typedef HalfedgeDS_halfedge_max_base_with_id< Refs, P, ID> Base;
|
||||
typedef HalfedgeDS_halfedge_base< Refs, Tag_true, Tag_true, Tag_true> Base ;
|
||||
|
||||
typedef HalfedgeDS_halfedge_base< Refs, Tag_true, Tag_true, Tag_true> Base_base ;
|
||||
typedef typename Base::Base_base Base_base ;
|
||||
|
||||
typedef ID size_type ;
|
||||
|
||||
private:
|
||||
|
||||
size_type id ;
|
||||
size_type mID ;
|
||||
|
||||
public:
|
||||
|
||||
HalfedgeDS_halfedge_max_base_with_id( size_type i = size_type(-1) ) : id(i) {}
|
||||
HalfedgeDS_halfedge_max_base_with_id( size_type i = size_type(-1) ) : mID(i) {}
|
||||
|
||||
size_type& id() { return id; }
|
||||
size_type const& id() const { return id; }
|
||||
size_type& id() { return mID; }
|
||||
size_type const& id() const { return mID; }
|
||||
};
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -9,24 +9,24 @@ template < class Refs, class P, class ID>
|
|||
class HalfedgeDS_vertex_max_base_with_id : public HalfedgeDS_vertex_base< Refs, Tag_true, P>
|
||||
{
|
||||
public:
|
||||
typedef HalfedgeDS_vertex_max_base_with_id< Refs, P, ID> Base;
|
||||
|
||||
typedef HalfedgeDS_vertex_base< Refs, Tag_true, P> Base_base ;
|
||||
typedef HalfedgeDS_vertex_base< Refs, Tag_true, P> Base ;
|
||||
|
||||
typedef ID size_type ;
|
||||
|
||||
typedef P Point ;
|
||||
|
||||
private:
|
||||
|
||||
size_type id ;
|
||||
size_type mID ;
|
||||
|
||||
public:
|
||||
|
||||
HalfedgeDS_vertex_max_base_with_id() : id ( size_type(-1) ) {}
|
||||
HalfedgeDS_vertex_max_base_with_id( Point const& p) : Base_base(p), id ( size_type(-1) ) {}
|
||||
HalfedgeDS_vertex_max_base_with_id( Point const& p, size_type i ) : Base_base(p), id(i) {}
|
||||
HalfedgeDS_vertex_max_base_with_id() : mID ( size_type(-1) ) {}
|
||||
HalfedgeDS_vertex_max_base_with_id( Point const& p) : Base(p), mID ( size_type(-1) ) {}
|
||||
HalfedgeDS_vertex_max_base_with_id( Point const& p, size_type i ) : Base(p), mID(i) {}
|
||||
|
||||
size_type& id() { return id; }
|
||||
size_type const& id() const { return id; }
|
||||
size_type& id() { return mID; }
|
||||
size_type const& id() const { return mID; }
|
||||
};
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -35,14 +35,41 @@ public:
|
|||
};
|
||||
template < class Refs, class Traits>
|
||||
struct Halfedge_wrapper {
|
||||
typedef HalfedgeDS_halfedge_max_base_with_id< Refs> Halfedge;
|
||||
typedef HalfedgeDS_halfedge_max_base_with_id<Refs, std::size_t> Halfedge;
|
||||
};
|
||||
template < class Refs, class Traits>
|
||||
struct Face_wrapper {
|
||||
typedef HalfedgeDS_face_max_base_with_id< Refs, Tag_false, std::std::size_t> Face;
|
||||
typedef HalfedgeDS_face_max_base_with_id< Refs, Tag_false, std::size_t> Face;
|
||||
};
|
||||
};
|
||||
|
||||
template<class HalfedgeDS_with_id>
|
||||
void set_halfedgeds_items_id ( HalfedgeDS_with_id& hds )
|
||||
{
|
||||
std::size_t vertex_id = 0 ;
|
||||
std::size_t halfedge_id = 0 ;
|
||||
std::size_t face_id = 0 ;
|
||||
|
||||
for ( typename HalfedgeDS_with_id::Vertex_iterator vit = hds.vertices_begin(), evit = hds.vertices_end()
|
||||
; vit != evit
|
||||
; ++ vit
|
||||
)
|
||||
vit->id() = vertex_id ++ ;
|
||||
|
||||
for ( typename HalfedgeDS_with_id::Halfedge_iterator hit = hds.halfedges_begin(), ehit = hds.halfedges_end()
|
||||
; hit != ehit
|
||||
; ++ hit
|
||||
)
|
||||
hit->id() = halfedge_id ++ ;
|
||||
|
||||
for ( typename HalfedgeDS_with_id::Face_iterator fit = hds.facets_begin(), efit = hds.facets_end()
|
||||
; fit != efit
|
||||
; ++ fit
|
||||
)
|
||||
fit->id() = face_id ++ ;
|
||||
}
|
||||
|
||||
CGAL_END_NAMESPACE
|
||||
|
||||
#endif // CGAL_POLYHEDRON_ITEMS_WITH_ID_3_H //
|
||||
// EOF //
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
OFF
|
||||
6 7 0
|
||||
|
||||
1 1 0
|
||||
3 1 0
|
||||
2 2 0
|
||||
2 3 0
|
||||
0 0 0
|
||||
4 0 0
|
||||
3 0 1 2
|
||||
3 0 2 3
|
||||
3 1 3 2
|
||||
3 0 4 1
|
||||
3 1 4 5
|
||||
3 1 5 3
|
||||
3 0 3 4
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,16 @@
|
|||
OFF
|
||||
6 8 0
|
||||
0.000000 1.686000 0.000000
|
||||
1.192000 0.000000 -1.192000
|
||||
-1.192000 0.000000 -1.192000
|
||||
-1.192000 0.000000 1.192000
|
||||
1.192000 0.000000 1.192000
|
||||
0.000000 -1.686000 0.000000
|
||||
3 0 4 1
|
||||
3 1 5 2
|
||||
3 2 3 0
|
||||
3 3 5 4
|
||||
3 1 2 0
|
||||
3 3 4 0
|
||||
3 4 5 1
|
||||
3 3 2 5
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
OFF
|
||||
6 6 0
|
||||
0.000000 1.686000 0.000000
|
||||
1.192000 0.000000 -1.192000
|
||||
-1.192000 0.000000 -1.192000
|
||||
-1.192000 0.000000 1.192000
|
||||
1.192000 0.000000 1.192000
|
||||
0.000000 -1.686000 0.000000
|
||||
3 0 4 1
|
||||
3 1 5 2
|
||||
3 2 3 0
|
||||
3 1 2 0
|
||||
3 3 4 0
|
||||
3 3 2 5
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
OFF
|
||||
8 10 0
|
||||
|
||||
0 0 0
|
||||
100 0 0
|
||||
100 100 0
|
||||
0 100 0
|
||||
100 0 100
|
||||
100 100 100
|
||||
0 100 100
|
||||
0 0 100
|
||||
3 0 1 2
|
||||
3 0 2 3
|
||||
3 1 4 2
|
||||
3 2 4 5
|
||||
3 2 5 6
|
||||
3 2 6 3
|
||||
3 5 4 7
|
||||
3 5 7 6
|
||||
3 6 7 3
|
||||
3 3 7 0
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
OFF
|
||||
4 2 0
|
||||
|
||||
0 0 0
|
||||
2 0 0
|
||||
1 1 0
|
||||
1 -1 0
|
||||
3 0 1 2
|
||||
3 0 3 1
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
OFF
|
||||
5 6 0
|
||||
|
||||
0 0 100
|
||||
100 0 0
|
||||
0 100 0
|
||||
0 0 0
|
||||
25 25 0
|
||||
3 3 4 1
|
||||
3 0 3 1
|
||||
3 0 2 3
|
||||
3 0 1 2
|
||||
3 2 4 3
|
||||
3 1 4 2
|
||||
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
OFF
|
||||
3 1 0
|
||||
|
||||
0 0 0
|
||||
2 0 0
|
||||
1 1 0
|
||||
3 1 0
|
||||
2 2 0
|
||||
3 0 1 2
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
OFF
|
||||
6 6 0
|
||||
|
||||
1 1 0
|
||||
3 1 0
|
||||
2 2 0
|
||||
2 3 0
|
||||
0 0 0
|
||||
4 0 0
|
||||
3 0 2 3
|
||||
3 1 3 2
|
||||
3 0 4 1
|
||||
3 1 4 5
|
||||
3 1 5 3
|
||||
3 0 3 4
|
||||
|
||||
|
|
@ -15,37 +15,10 @@
|
|||
//
|
||||
// Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar>
|
||||
//
|
||||
#define TEST_NAME "Polyhedron's Graph Traits"
|
||||
#define TEST_PROGRAM "halfedge_graph_traits_Polyhedron_3"
|
||||
|
||||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
|
||||
#include <CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/Unique_hash_map.h>
|
||||
|
||||
using namespace boost ;
|
||||
using namespace std ;
|
||||
using namespace CGAL ;
|
||||
|
||||
typedef Simple_cartesian<double> Kernel ;
|
||||
typedef Polyhedron_3<Kernel> Polyhedron ;
|
||||
|
||||
int sOK = 0 ;
|
||||
int sFailed = 0 ;
|
||||
|
||||
#define CHECK(pred) \
|
||||
if (!(pred)) \
|
||||
{ \
|
||||
cerr << "Assertion failure: " << #pred << endl \
|
||||
<< "File:" << __FILE__ << endl \
|
||||
<< "Line:" << __LINE__ << endl ; \
|
||||
throw 0 ; \
|
||||
}
|
||||
|
||||
#define CHECK_EQUAL(x,y) CHECK(((x)==(y)))
|
||||
#define CHECK_NOT_EQUAL(x,y) CHECK(((x)!=(y)))
|
||||
#include "test_prefix_Polyhedron_3.cpp"
|
||||
|
||||
template<class Graph>
|
||||
bool test_aux ( Graph& aG )
|
||||
|
|
@ -71,7 +44,7 @@ bool test_aux ( Graph& aG )
|
|||
CHECK_EQUAL( num_edges (aG), aG.size_of_halfedges() ) ;
|
||||
|
||||
// vtable is used to check that each vertex is reached only once by vertex_iterator
|
||||
Unique_hash_map<vertex_const_descriptor,bool> vtable(false,aG.size_of_vertices());
|
||||
vector<bool> vtable(aG.size_of_vertices());
|
||||
|
||||
// Check operations on vertices
|
||||
vertex_iterator vb,ve ;
|
||||
|
|
@ -80,7 +53,7 @@ bool test_aux ( Graph& aG )
|
|||
vertex_descriptor v = *vb ;
|
||||
|
||||
// Checks that 'v' has not been reached before
|
||||
CHECK_EQUAL(vtable[v],false); vtable[v] = true ;
|
||||
CHECK_EQUAL(vtable[v->id()],false); vtable[v->id()] = true ;
|
||||
|
||||
// Degree
|
||||
CHECK_EQUAL( degree (v,aG), v->vertex_degree() * 2) ;
|
||||
|
|
@ -140,10 +113,10 @@ bool test_aux ( Graph& aG )
|
|||
|
||||
// Now check that all the vertices in aG are contained in the range returned by the call to vertices()
|
||||
for ( typename Graph::Vertex_const_iterator vit = aG.vertices_begin() ; vit != aG.vertices_end() ; ++ vit )
|
||||
CHECK(vtable[vit]);
|
||||
CHECK(vtable[vit->id()]);
|
||||
|
||||
// 'etable' is used to check that each halfedge is reached only once by edge_iterator
|
||||
Unique_hash_map<edge_const_descriptor,bool> etable(false,aG.size_of_halfedges());
|
||||
vector<bool> etable(aG.size_of_halfedges());
|
||||
|
||||
// Check operations on halfedges
|
||||
size_t ec = 0 ;
|
||||
|
|
@ -158,7 +131,7 @@ bool test_aux ( Graph& aG )
|
|||
edge_descriptor cwe = next_edge_cw(e,aG);
|
||||
|
||||
// Checks that 'e' has not been reached before
|
||||
CHECK_EQUAL(etable[e],false); etable[e] = true ;
|
||||
CHECK_EQUAL(etable[e->id()],false); etable[e->id()] = true ;
|
||||
|
||||
// Checks neighbors are OK
|
||||
CHECK_EQUAL(oe,e->opposite());
|
||||
|
|
@ -190,21 +163,22 @@ bool test_aux ( Graph& aG )
|
|||
|
||||
// Now check that all the halfedges in aG are contained in the range returned by the call to edges()
|
||||
for ( typename Graph::Halfedge_const_iterator eit = aG.halfedges_begin() ; eit != aG.halfedges_end() ; ++ eit )
|
||||
CHECK(etable[eit]);
|
||||
CHECK(etable[eit->id()]);
|
||||
|
||||
// 'uetable' is used to check that only one halfedge out of each pair is reached by undirected_edge_iterator
|
||||
Unique_hash_map<edge_const_descriptor,bool> uetable(0,aG.size_of_halfedges());
|
||||
vector<bool> uetable(aG.size_of_halfedges());
|
||||
|
||||
size_t uec = 0 ;
|
||||
undirected_edge_iterator ueb,uee ;
|
||||
for ( tie(ueb,uee) = undirected_edges(aG) ; ueb != uee ; ++ ueb )
|
||||
{
|
||||
edge_descriptor ue = *eb ;
|
||||
edge_descriptor ue = *ueb ;
|
||||
edge_descriptor oe = opposite_edge(ue,aG);
|
||||
|
||||
// Checks that none of 'ue,oe' has been reached before
|
||||
CHECK_EQUAL(uetable[ue],false); uetable[ue] = true ;
|
||||
CHECK_EQUAL(uetable[oe],false); uetable[oe] = true ;
|
||||
// This also checks that 'ueb' iterates over just one halfedge in the opposing pair.
|
||||
CHECK_EQUAL(uetable[ue->id()],false); uetable[ue->id()] = true ;
|
||||
CHECK_EQUAL(uetable[oe->id()],false); uetable[oe->id()] = true ;
|
||||
|
||||
++ uec ;
|
||||
}
|
||||
|
|
@ -229,108 +203,6 @@ bool test ( Polyhedron& aG )
|
|||
return r ;
|
||||
}
|
||||
|
||||
bool test( string off_file )
|
||||
{
|
||||
bool rContinue = true ;
|
||||
|
||||
std::size_t extpos = off_file.find_last_of('.') ;
|
||||
if ( extpos != string::npos && off_file.substr(extpos) == ".off" )
|
||||
{
|
||||
ifstream is(off_file.c_str());
|
||||
if ( is )
|
||||
{
|
||||
Polyhedron lPoly ;
|
||||
is >> lPoly ;
|
||||
|
||||
bool ok = test(lPoly) ;
|
||||
|
||||
if ( ok )
|
||||
++ sOK ;
|
||||
else ++ sFailed ;
|
||||
|
||||
cout << ( ok ? "OK" : "FAILED!" ) << endl ;
|
||||
}
|
||||
else cerr << "Unable to load input .off file: " << off_file << endl ;
|
||||
}
|
||||
else cerr << "Input file must have .off extension: " << off_file << endl ;
|
||||
|
||||
return rContinue ;
|
||||
}
|
||||
|
||||
// This is here only to allow a breakpoint to be placed so I can trace back the problem.
|
||||
void error_handler ( char const* what, char const* expr, char const* file, int line, char const* msg )
|
||||
{
|
||||
cerr << "CGAL error: " << what << " violation!\n"
|
||||
<< "Expr: " << expr << endl
|
||||
<< "File: " << file << endl
|
||||
<< "Line: " << line << endl;
|
||||
if ( msg != 0)
|
||||
cerr << "Explanation:" << msg << endl;
|
||||
|
||||
// Avoid an abort()
|
||||
throw runtime_error(msg);
|
||||
}
|
||||
|
||||
int main( int argc, char const* argv[] )
|
||||
{
|
||||
cout << "Testing Polyhedron's Graph Traits\n";
|
||||
|
||||
CGAL::set_error_handler (error_handler);
|
||||
CGAL::set_warning_handler(error_handler);
|
||||
|
||||
bool print_usage = false ;
|
||||
bool nop = false ;
|
||||
|
||||
string folder = "" ;
|
||||
|
||||
for ( int i = 1 ; i < argc ; ++ i )
|
||||
{
|
||||
if ( argv[i][0] == '#' )
|
||||
{
|
||||
folder = string(&argv[i][1]);
|
||||
cout << "Input folder: " << folder << endl ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> samples ;
|
||||
|
||||
for ( int i = 1 ; i < argc ; ++ i )
|
||||
if ( argv[i][0] != '-' && argv[i][0] != '#' )
|
||||
samples.push_back(folder+ string(argv[i]));
|
||||
|
||||
if ( samples.size() > 0 )
|
||||
{
|
||||
for ( vector<string>::const_iterator it = samples.begin() ; it != samples.end() ; ++ it )
|
||||
{
|
||||
if ( !nop )
|
||||
{
|
||||
if (!test(*it) )
|
||||
break ;
|
||||
}
|
||||
else
|
||||
cout << *it << endl ;
|
||||
}
|
||||
|
||||
int lTotal = sOK + sFailed ;
|
||||
|
||||
if ( lTotal > 0 )
|
||||
{
|
||||
cout << "Total cases: " << lTotal << endl
|
||||
<< "Succeeded cases: " << sOK << endl
|
||||
<< "Failed cases: " << sFailed << endl
|
||||
<< "Failure ratio: " << ((double)sFailed/lTotal*100.0) << "%\n" ;
|
||||
}
|
||||
|
||||
}
|
||||
else print_usage = true ;
|
||||
|
||||
if ( print_usage )
|
||||
{
|
||||
cout << "USAGE: graph_traits_Polyhedron_3 #folder file0 file1 ... fileN\n"
|
||||
<< " If file is '*' then all files with extension .off in the current folder are loaded\n" ;
|
||||
}
|
||||
|
||||
return sFailed == 0 ? 0 : 1 ;
|
||||
}
|
||||
#include "test_suffix_Polyhedron_3.cpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -38,12 +38,17 @@ LDFLAGS = \
|
|||
|
||||
all: \
|
||||
halfedge_graph_traits_Polyhedron_3$(EXE_EXT) \
|
||||
properties_Polyhedron_3$(EXE_EXT) \
|
||||
|
||||
halfedge_graph_traits_Polyhedron_3$(EXE_EXT): halfedge_graph_traits_Polyhedron_3$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)halfedge_graph_traits_Polyhedron_3 halfedge_graph_traits_Polyhedron_3$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
properties_Polyhedron_3$(EXE_EXT): properties_Polyhedron_3$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(LIBPATH) $(EXE_OPT)properties_Polyhedron_3 properties_Polyhedron_3$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
clean: \
|
||||
halfedge_graph_traits_Polyhedron_3.clean \
|
||||
properties_Polyhedron_3.clean \
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# suffix rules
|
||||
|
|
|
|||
|
|
@ -0,0 +1,123 @@
|
|||
// Copyright (c) 2006 Fernando Luis Cacciola Carballal. All rights reserved.
|
||||
//
|
||||
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
||||
// the terms of the Q Public License version 1.0.
|
||||
// See the file LICENSE.QPL distributed with CGAL.
|
||||
//
|
||||
// Licensees holding a valid commercial license may use this file in
|
||||
// accordance with the commercial license agreement provided with the software.
|
||||
//
|
||||
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
||||
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// $URL: svn+ssh://fcacciola@scm.gforge.inria.fr/svn/cgal/trunk/Straight_skeleton_2/test/Straight_skeleton_2/test_sls_builder.cpp $
|
||||
// $Id: test_sls_builder.cpp 32700 2006-07-24 22:31:02Z fcacciola $
|
||||
//
|
||||
// Author(s) : Fernando Cacciola <fernando_cacciola@ciudad.com.ar>
|
||||
//
|
||||
#define TEST_NAME "Polyhedron's Graph Properties"
|
||||
#define TEST_PROGRAM "properties_Polyhedron_3"
|
||||
|
||||
#include "test_prefix_Polyhedron_3.cpp"
|
||||
|
||||
#include "CGAL/boost/graph/properties_Polyhedron_3.h"
|
||||
|
||||
template<class Graph>
|
||||
bool test_aux ( Graph& aG )
|
||||
{
|
||||
typedef typename graph_traits<Graph>::vertex_descriptor vertex_descriptor ;
|
||||
typedef typename graph_traits<Graph>::edge_descriptor edge_descriptor ;
|
||||
typedef typename graph_traits<Graph>::vertex_iterator vertex_iterator ;
|
||||
typedef typename graph_traits<Graph>::edge_iterator edge_iterator ;
|
||||
|
||||
typedef typename graph_traits<Graph const>::vertex_descriptor vertex_const_descriptor ;
|
||||
typedef typename graph_traits<Graph const>::edge_descriptor edge_const_descriptor ;
|
||||
|
||||
typedef typename halfedge_graph_traits<Graph>::undirected_edge_iterator undirected_edge_iterator ;
|
||||
typedef typename halfedge_graph_traits<Graph>::Point Point ;
|
||||
|
||||
bool result = false ;
|
||||
|
||||
try
|
||||
{
|
||||
//
|
||||
typedef typename property_map<Graph,vertex_external_index_t>::type external_vertex_index_pmap ;
|
||||
typedef typename property_map<Graph,edge_external_index_t>::type external_edge_index_pmap ;
|
||||
|
||||
external_vertex_index_pmap const& external_vidx_pmap = get(vertex_external_index,aG);
|
||||
external_edge_index_pmap const& external_eidx_pmap = get(edge_external_index,aG);
|
||||
|
||||
// Vertex propertiess
|
||||
vertex_iterator vb,ve ;
|
||||
for ( tie(vb,ve) = vertices(aG) ; vb != ve ; ++ vb )
|
||||
{
|
||||
vertex_descriptor v = *vb ;
|
||||
|
||||
//
|
||||
// vertex_point property
|
||||
//
|
||||
Point& oldp = get(vertex_point,aG,v) ;
|
||||
CHECK_EQUAL(oldp,v->point());
|
||||
Point newp = midpoint(oldp,Point(ORIGIN));
|
||||
put(vertex_point,aG,v,newp);
|
||||
CHECK_EQUAL(v->point(),newp);
|
||||
// Checks that the const version also works
|
||||
Point const& newp2 = get(vertex_point,static_cast<Graph const&>(aG),static_cast<vertex_const_descriptor>(v));
|
||||
CHECK_EQUAL(v->point(),newp2) ;
|
||||
|
||||
//
|
||||
// vertex_index property
|
||||
//
|
||||
CHECK_EQUAL(get(vertex_index,aG,v),v->id());
|
||||
|
||||
//
|
||||
// vertex_external_index property
|
||||
//
|
||||
CHECK_EQUAL(external_vidx_pmap[v],v->id());
|
||||
}
|
||||
|
||||
// Edge propertiess
|
||||
edge_iterator eb,ee ;
|
||||
for ( tie(eb,ee) = edges(aG) ; eb != ee ; ++ eb )
|
||||
{
|
||||
edge_descriptor e = *eb ;
|
||||
edge_descriptor oe = opposite_edge(e,aG);
|
||||
|
||||
//
|
||||
// edge_weight property
|
||||
//
|
||||
double property_w = get(edge_weight,aG,e);
|
||||
double expected_w = squared_distance(e->vertex()->point(), e->opposite()->vertex()->point());
|
||||
CHECK_EQUAL(property_w,expected_w);
|
||||
|
||||
//
|
||||
// edge_is_border property
|
||||
//
|
||||
CHECK_EQUAL(get(edge_is_border,aG,e),e->is_border());
|
||||
|
||||
//
|
||||
// edge_index property
|
||||
//
|
||||
CHECK_EQUAL(get(edge_index,aG,e),e->id());
|
||||
|
||||
//
|
||||
// edge_external_index property
|
||||
//
|
||||
CHECK_EQUAL(external_eidx_pmap[e],e->id());
|
||||
}
|
||||
|
||||
result = true ;
|
||||
}
|
||||
catch(...) {}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
bool test ( Polyhedron& aG )
|
||||
{
|
||||
return test_aux(aG);
|
||||
}
|
||||
|
||||
|
||||
#include "test_suffix_Polyhedron_3.cpp"
|
||||
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
#include <cstdio>
|
||||
#include <fstream>
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/boost/graph/graph_traits_Polyhedron_3.h>
|
||||
#include <CGAL/boost/graph/halfedge_graph_traits_Polyhedron_3.h>
|
||||
#include <CGAL/IO/Polyhedron_iostream.h>
|
||||
#include <CGAL/Polyhedron_items_with_id_3.h>
|
||||
|
||||
using namespace boost ;
|
||||
using namespace std ;
|
||||
using namespace CGAL ;
|
||||
|
||||
typedef Simple_cartesian<double> Kernel ;
|
||||
typedef Polyhedron_3<Kernel,Polyhedron_items_with_id_3> Polyhedron ;
|
||||
|
||||
int sOK = 0 ;
|
||||
int sFailed = 0 ;
|
||||
|
||||
#define CHECK(pred) \
|
||||
if (!(pred)) \
|
||||
{ \
|
||||
cerr << "Assertion failure: " << #pred << endl \
|
||||
<< "File:" << __FILE__ << endl \
|
||||
<< "Line:" << __LINE__ << endl ; \
|
||||
throw 0 ; \
|
||||
}
|
||||
|
||||
#define CHECK_EQUAL(x,y) CHECK(((x)==(y)))
|
||||
#define CHECK_NOT_EQUAL(x,y) CHECK(((x)!=(y)))
|
||||
|
||||
|
|
@ -0,0 +1,107 @@
|
|||
bool test( string off_file )
|
||||
{
|
||||
bool rContinue = true ;
|
||||
|
||||
std::size_t extpos = off_file.find_last_of('.') ;
|
||||
if ( extpos != string::npos && off_file.substr(extpos) == ".off" )
|
||||
{
|
||||
ifstream is(off_file.c_str());
|
||||
if ( is )
|
||||
{
|
||||
Polyhedron lPoly ;
|
||||
is >> lPoly ;
|
||||
|
||||
set_halfedgeds_items_id(lPoly);
|
||||
|
||||
bool ok = test(lPoly) ;
|
||||
|
||||
if ( ok )
|
||||
++ sOK ;
|
||||
else ++ sFailed ;
|
||||
|
||||
cout << ( ok ? "OK" : "FAILED!" ) << endl ;
|
||||
}
|
||||
else cerr << "Unable to load input .off file: " << off_file << endl ;
|
||||
}
|
||||
else cerr << "Input file must have .off extension: " << off_file << endl ;
|
||||
|
||||
return rContinue ;
|
||||
}
|
||||
|
||||
// This is here only to allow a breakpoint to be placed so I can trace back the problem.
|
||||
void error_handler ( char const* what, char const* expr, char const* file, int line, char const* msg )
|
||||
{
|
||||
cerr << "CGAL error: " << what << " violation!\n"
|
||||
<< "Expr: " << expr << endl
|
||||
<< "File: " << file << endl
|
||||
<< "Line: " << line << endl;
|
||||
if ( msg != 0)
|
||||
cerr << "Explanation:" << msg << endl;
|
||||
|
||||
// Avoid an abort()
|
||||
throw runtime_error(msg);
|
||||
}
|
||||
|
||||
int main( int argc, char const* argv[] )
|
||||
{
|
||||
cout << "Testing " << TEST_NAME << endl ;
|
||||
|
||||
CGAL::set_error_handler (error_handler);
|
||||
CGAL::set_warning_handler(error_handler);
|
||||
|
||||
bool print_usage = false ;
|
||||
bool nop = false ;
|
||||
|
||||
string folder = "" ;
|
||||
|
||||
for ( int i = 1 ; i < argc ; ++ i )
|
||||
{
|
||||
if ( argv[i][0] == '#' )
|
||||
{
|
||||
folder = string(&argv[i][1]);
|
||||
cout << "Input folder: " << folder << endl ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> samples ;
|
||||
|
||||
for ( int i = 1 ; i < argc ; ++ i )
|
||||
if ( argv[i][0] != '-' && argv[i][0] != '#' )
|
||||
samples.push_back(folder+ string(argv[i]));
|
||||
|
||||
if ( samples.size() > 0 )
|
||||
{
|
||||
for ( vector<string>::const_iterator it = samples.begin() ; it != samples.end() ; ++ it )
|
||||
{
|
||||
if ( !nop )
|
||||
{
|
||||
if (!test(*it) )
|
||||
break ;
|
||||
}
|
||||
else
|
||||
cout << *it << endl ;
|
||||
}
|
||||
|
||||
int lTotal = sOK + sFailed ;
|
||||
|
||||
if ( lTotal > 0 )
|
||||
{
|
||||
cout << "Total cases: " << lTotal << endl
|
||||
<< "Succeeded cases: " << sOK << endl
|
||||
<< "Failed cases: " << sFailed << endl
|
||||
<< "Failure ratio: " << ((double)sFailed/lTotal*100.0) << "%\n" ;
|
||||
}
|
||||
|
||||
}
|
||||
else print_usage = true ;
|
||||
|
||||
if ( print_usage )
|
||||
{
|
||||
cout << "USAGE: " << TEST_PROGRAM << " graph_traits_Polyhedron_3 #folder file0 file1 ... fileN\n"
|
||||
<< " If file is '*' then all files with extension .off in the current folder are loaded\n" ;
|
||||
}
|
||||
|
||||
return sFailed == 0 ? 0 : 1 ;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue