|
Boost-Commit : |
From: huseyinakcan_at_[hidden]
Date: 2007-07-17 00:07:31
Author: huseyinakcan
Date: 2007-07-17 00:07:30 EDT (Tue, 17 Jul 2007)
New Revision: 7454
URL: http://svn.boost.org/trac/boost/changeset/7454
Log:
test class added for vertex_selectors
Added:
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.t.cpp
Text files modified:
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/Makefile | 5 ++++-
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_selectors.hpp | 22 ++--------------------
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.hpp | 18 ++++++++++++------
3 files changed, 18 insertions(+), 27 deletions(-)
Modified: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/Makefile
==============================================================================
--- sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/Makefile (original)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/Makefile 2007-07-17 00:07:30 EDT (Tue, 17 Jul 2007)
@@ -11,7 +11,8 @@
PACKAGE_LIBRARY=libhalfedge_ds.a
-TEST_DRIVERS=container_selectors.t facet_selectors.t
+TEST_DRIVERS=container_selectors.t facet_selectors.t \
+ vertex_selectors.t
.SUFFIXES:
.SUFFIXES: ${TARGET}.o .o .cpp .hpp
@@ -47,6 +48,7 @@
facet_selectors.t.o:
+vertex_selectors.t.o:
%.t.o: %.t.cpp %.hpp
${CXX} ${CXXFLAGS} ${CXXINCLUDES} -c -o $*.t.o $<
@@ -55,6 +57,7 @@
facet_selectors.t:
+vertex_selectors.t:
## UTILITIES
Modified: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_selectors.hpp
==============================================================================
--- sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_selectors.hpp (original)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/halfedge_selectors.hpp 2007-07-17 00:07:30 EDT (Tue, 17 Jul 2007)
@@ -12,15 +12,8 @@
//@DESCRIPTION: This file provides the 'stored_halfedge',
// and the helper classes, which accepts many template parameters that can be
// used to govern its implementation. These parameters can be chosen using the
-// 'Config' class members (see 'halfedge_ds' component). Currently the
-// helper classes are as follows:
-//
-// - 'opposite_helper': class for configuring opposite access methods
-// - 'vertex_helper': class for configuring vertex access methods
-// - 'facet_helper': class for configuring facet access methods
-// - 'traversal_helper': class for configuring traversal methods
-//
-// and the selectors are as follows:
+// 'Config' class members (see 'halfedge_ds' component). Currently the
+// selectors are as follows:
//
// - 'forwardS': defines configuration options for forward access
// - 'backwardS': defines configuration options for backward access
@@ -32,17 +25,6 @@
// 'opposite_helper', 'vertex_helper', 'facet_helper', 'traversal_helper'.
// Based on the configurations of these classes, members are added or omited
// from 'stored_halfedge' for optimization purposes.
-// - 'vertex_helper' If vertices are supported in the 'halfedge_ds', this class
-// defines 'source' or 'target' members, based on the configuration
-// options. If vertices are not supported, this class does not define a
-// vertex access member.
-// - 'facet_helper' If facets are supported in the 'halfedge_ds', this class
-// defines facet members, based on the configuration
-// options. If facets are not supported, this class does not define a
-// facet access member.
-// - 'traversal_helper' Based on the traversal configuration, this class
-// defines 'm_next', 'm_prev' or both traversal access members.
-
#ifndef BOOST_HDSTL_HALFEDGE_SELECTORS_HPP
#define BOOST_HDSTL_HALFEDGE_SELECTORS_HPP 1
Modified: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.hpp
==============================================================================
--- sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.hpp (original)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.hpp 2007-07-17 00:07:30 EDT (Tue, 17 Jul 2007)
@@ -274,7 +274,7 @@
//CREATORS
stored_vertex(Base const& base, HalfedgeDescriptor vertexLink)
- : m_vertexLink(vertexLink),
+ : m_vertexLink(vertexLink)
, m_base(base){}
//MANIPULATORS
@@ -353,6 +353,9 @@
// 'halfedge_ds' related to vertices.
// TYPES
+ typedef vertexS<ContainerS,HasVertexLink> vertex_selector;
+ // The vertex selector.
+
typedef stored_vertex<VertexBase,HasVertexLink, HalfedgeDescriptor>
vertex_type;
// The stored vertex type for this vertex generator.
@@ -362,6 +365,9 @@
typedef typename ContainerGen::type container_type;
// The vertex container type for this vertex generator.
+
+ typedef typename ContainerGen::size_type size_type;
+ // The vertex container size type for this vertex generator.
typedef typename ContainerGen::descriptor vertex_descriptor;
// The vertex descriptor type for this vertex generator.
@@ -377,16 +383,16 @@
// FREE FUNCTIONS
template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
-typename vertex_gen<VertexS, HalfedgeDescriptor,VertexBase>::iterator
-vertices_begin(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase> const& hds) {
+typename vertex_gen<VertexS, HalfedgeDescriptor,VertexBase>::vertex_iterator
+vertices_begin(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds) {
typedef typename vertex_gen<VertexS, HalfedgeDescriptor,
VertexBase>::ContainerGen ContainerGen;
return ContainerGen::container_begin(hds.m_container);
}
template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
-typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::iterator
-vertices_end(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase> const& hds) {
+typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::vertex_iterator
+vertices_end(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds) {
typedef typename vertex_gen<VertexS, HalfedgeDescriptor,
VertexBase>::ContainerGen ContainerGen;
return ContainerGen::container_end(hds.m_container);
@@ -394,7 +400,7 @@
template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::size_type
-num_vertices(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase> const& hds) {
+num_vertices(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds) {
return hds.m_container.size();
}
Added: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.t.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.t.cpp 2007-07-17 00:07:30 EDT (Tue, 17 Jul 2007)
@@ -0,0 +1,262 @@
+//vertex_selectors.hpp -*- C++ -*-
+//
+//@OVERVIEW: The component under test is a selector class. We
+// must make sure that all selectors are suitably defined and that the
+// selection is done properly.
+//
+//@TEST_PLAN: First create an instance of all the selectors (to make sure they
+// exist, and verify that there are no more than tested). Then instantiate the
+// 'container_gen<VertexS,ValueType>' for a given value type and all
+// selectors, and verify that its members have the expected types and
+// signatures. Finally, verify that the usage example compiles and executes
+// without errors, when assert is replaced by BOOST_CHECK.
+
+#include <boost/hdstl/halfedge_ds/vertex_selectors.hpp>
+
+#include <boost/test/minimal.hpp>
+
+#include <set>
+#include <string>
+#include <vector>
+
+using namespace boost::hdstl;
+using namespace std;
+
+// ===========================================================================
+// SELECTION CLASSES
+// ===========================================================================
+
+template <typename VertexS>
+bool selection_requirements(VertexS const&) {
+ return false;
+}
+
+bool selection_requirements(noVertexS const&) {
+ return true;
+}
+
+template <typename Selector>
+bool selection_requirements(vertexS<Selector, false, sourceS> const&) {
+ return true;
+}
+
+template <typename Selector>
+bool selection_requirements(vertexS<Selector, false, targetS> const&) {
+ return true;
+}
+
+template <typename Selector>
+bool selection_requirements(vertexS<Selector, true, sourceS> const&) {
+ return true;
+}
+
+template <typename Selector>
+bool selection_requirements(vertexS<Selector, true, targetS> const&) {
+ return true;
+}
+
+// ===========================================================================
+// CLASS FACET_GEN
+// ===========================================================================
+
+template<typename VertexGen>
+bool vertex_gen_requirements_void_noVertexLink() {
+
+ // Types must exist.
+ typedef typename VertexGen::vertex_selector vertex_selector;
+ typedef typename VertexGen::vertex_descriptor vertex_descriptor;
+ typedef typename VertexGen::vertex_iterator vertex_iterator;
+ typedef typename VertexGen::vertex_type vertex_type;
+ typedef typename VertexGen::container_type container_type;
+
+ vertex_type fa;
+ vertex_type fb;
+ vertex_type fc;
+ vertex_type fd;
+ vertex_type array[] = { fa, fb, fc, fd };
+
+ // Construct a vertex_gen object whose container contains array.
+ // Verify that vertices_begin(), vertices_end(), and num_vertices() work.
+ // Access the vertices and, if the has_vertex_links is set, check that the
+ // halfedge() works.
+ container_type temp_con(array,array+4);
+ VertexGen vertexGen;
+ vertexGen.m_container = temp_con;
+ BOOST_CHECK(( num_vertices(vertexGen) == 4 ));
+ return true;
+}
+
+template <typename VertexGen>
+bool vertex_gen_requirements_void() {
+
+ // Types must exist.
+ typedef typename VertexGen::vertex_selector vertex_selector;
+ typedef typename VertexGen::vertex_descriptor vertex_descriptor;
+ typedef typename VertexGen::vertex_iterator vertex_iterator;
+ typedef typename VertexGen::vertex_type vertex_type;
+ typedef typename VertexGen::container_type container_type;
+
+ vertex_type fa(1);
+ vertex_type fb(2);
+ vertex_type fc(3);
+ vertex_type fd(4);
+ vertex_type array[] = { fa, fb, fc, fd };
+
+ // Construct a vertex_gen object whose container contains array.
+ // Verify that vertices_begin(), vertices_end(), and num_vertices() work.
+ // Access the vertices and, if the has_vertex_links is set, check that the
+ // halfedge() works.
+ // ... TODO
+ container_type temp_con(array,array+4);
+ VertexGen vertexGen;
+ vertexGen.m_container = temp_con;
+ BOOST_CHECK(( num_vertices(vertexGen) == 4 ));
+ BOOST_CHECK(( vertices_begin(vertexGen)->m_vertexLink == 1 ));
+ BOOST_CHECK(( (--vertices_end(vertexGen))->m_vertexLink == 4 ));
+
+ //BOOST_CHECK(( halfedge(*vertices_begin(vertexGen), vertexGen) == 1 ));
+ //BOOST_CHECK(( halfedge(*(--vertices_end(vertexGen)), vertexGen) == 4 ));
+ return true;
+}
+
+template <typename VertexGen, typename Base>
+bool vertex_gen_requirements_noVertexLink() {
+
+ typedef typename VertexGen::vertex_selector vertex_selector;
+ typedef typename VertexGen::vertex_descriptor vertex_descriptor;
+ typedef typename VertexGen::vertex_iterator vertex_iterator;
+ typedef typename VertexGen::vertex_type vertex_type;
+ typedef typename VertexGen::container_type container_type;
+
+ vertex_type fa(Base(1));
+ vertex_type fb(Base(2));
+ vertex_type fc(Base(3));
+ vertex_type fd(Base(4));
+ vertex_type array[] = { fa, fb, fc, fd }; (void) array;
+
+ // Same checks as before:
+ //BOOST_CHECK(( vertex_gen_requirements_void_noVertexLink<VertexGen>() ));
+ container_type temp_con(array,array+4);
+ VertexGen vertexGen;
+ vertexGen.m_container = temp_con;
+ BOOST_CHECK(( num_vertices(vertexGen) == 4 ));
+
+ // Plus: get the base back from the vertices and making sure it matches.
+ BOOST_CHECK(( vertices_begin(vertexGen)->base() == 1 ));
+ BOOST_CHECK(( (--vertices_end(vertexGen))->base() == 4 ));
+
+
+ return true;
+}
+
+template <typename VertexGen, typename Base>
+bool vertex_gen_requirements() {
+
+ typedef typename VertexGen::vertex_selector vertex_selector;
+ typedef typename VertexGen::vertex_descriptor vertex_descriptor;
+ typedef typename VertexGen::vertex_iterator vertex_iterator;
+ typedef typename VertexGen::vertex_type vertex_type;
+ typedef typename VertexGen::container_type container_type;
+
+ vertex_type fa(1, Base(1));
+ vertex_type fb(2, Base(2));
+ vertex_type fc(3, Base(3));
+ vertex_type fd(4, Base(4));
+ vertex_type array[] = { fa, fb, fc, fd }; (void) array;
+
+ // Same checks as before:
+ //BOOST_CHECK(( vertex_gen_requirements_void<VertexGen>() ));
+ container_type temp_con(array,array+4);
+ VertexGen vertexGen;
+ vertexGen.m_container = temp_con;
+ BOOST_CHECK(( num_vertices(vertexGen) == 4 ));
+
+ BOOST_CHECK(( vertices_begin(vertexGen)->m_vertexLink == 1 ));
+ BOOST_CHECK(( (--vertices_end(vertexGen))->m_vertexLink == 4 ));
+
+ //BOOST_CHECK(( halfedge(*vertices_begin(vertexGen), vertexGen) == 1 ));
+ //BOOST_CHECK(( halfedge(*(--vertices_end(vertexGen)), vertexGen) == 4 ));
+
+ // Plus: get the base back from the vertices and making sure it matches.
+ BOOST_CHECK(( vertices_begin(vertexGen)->base() == 1 ));
+ BOOST_CHECK(( (--vertices_end(vertexGen))->base() == 4 ));
+
+ return true;
+}
+
+// ===========================================================================
+// USAGE EXAMPLE
+// ===========================================================================
+
+// The usage example is the component itself.
+
+// ===========================================================================
+// BOOST TEST APPARATUS
+// ===========================================================================
+
+int test_main(int, char **)
+{
+ BOOST_CHECK(( selection_requirements(noVertexS()) ));
+
+ BOOST_CHECK(( selection_requirements(vertexS<listS,true, sourceS>()) ));
+ BOOST_CHECK(( selection_requirements(vertexS<listS,false, sourceS>()) ));
+ BOOST_CHECK(( selection_requirements(vertexS<listS,true, targetS>()) ));
+ BOOST_CHECK(( selection_requirements(vertexS<listS,false, targetS>()) ));
+
+ BOOST_CHECK(( vertex_gen_requirements_void_noVertexLink<
+ vertex_gen<vertexS<listS,false, sourceS>, int, void> >() ));
+ BOOST_CHECK(( vertex_gen_requirements_void_noVertexLink<
+ vertex_gen<vertexS<listS,false, targetS>, int, void> >() ));
+ BOOST_CHECK(( vertex_gen_requirements_void<
+ vertex_gen<vertexS<listS,true, sourceS>, int, void> >() ));
+ BOOST_CHECK(( vertex_gen_requirements_void<
+ vertex_gen<vertexS<listS,true, targetS>, int, void> >() ));
+
+ BOOST_CHECK(( vertex_gen_requirements_noVertexLink<
+ vertex_gen<vertexS<listS,false, sourceS>, int, int>, int >() ));
+ BOOST_CHECK(( vertex_gen_requirements_noVertexLink<
+ vertex_gen<vertexS<listS,false, targetS>, int, int>, int >() ));
+ BOOST_CHECK(( vertex_gen_requirements<
+ vertex_gen<vertexS<listS,true, sourceS>, int, int>, int >() ));
+ BOOST_CHECK(( vertex_gen_requirements<
+ vertex_gen<vertexS<listS,true, targetS>, int, int>, int >() ));
+
+ // BOOST_CHECK(( vertex_gen_requirements<
+ // vertex_gen<vertexS<listS,false>, int, custom_vertex_base> >() ));
+
+ // BOOST_CHECK(( vertex_gen_requirements<
+ // vertex_gen<vertexS<listS,true>, int, custom_vertex_base> >() ));
+
+ BOOST_CHECK(( selection_requirements(vertexS<vecS,true, sourceS>()) ));
+ BOOST_CHECK(( selection_requirements(vertexS<vecS,false, sourceS>()) ));
+ BOOST_CHECK(( selection_requirements(vertexS<vecS,true, targetS>()) ));
+ BOOST_CHECK(( selection_requirements(vertexS<vecS,false, targetS>()) ));
+
+ BOOST_CHECK(( vertex_gen_requirements_void_noVertexLink<
+ vertex_gen<vertexS<vecS,false, sourceS>, int, void> >() ));
+ BOOST_CHECK(( vertex_gen_requirements_void_noVertexLink<
+ vertex_gen<vertexS<vecS,false, targetS>, int, void> >() ));
+ BOOST_CHECK(( vertex_gen_requirements_void<
+ vertex_gen<vertexS<vecS,true, sourceS>, int, void> >() ));
+ BOOST_CHECK(( vertex_gen_requirements_void<
+ vertex_gen<vertexS<vecS,true, targetS>, int, void> >() ));
+
+ BOOST_CHECK(( vertex_gen_requirements_noVertexLink<
+ vertex_gen<vertexS<vecS,false, sourceS>, int, int>, int >() ));
+ BOOST_CHECK(( vertex_gen_requirements_noVertexLink<
+ vertex_gen<vertexS<vecS,false, targetS>, int, int>, int >() ));
+ BOOST_CHECK(( vertex_gen_requirements<
+ vertex_gen<vertexS<vecS,true, sourceS>, int, int>, int >() ));
+ BOOST_CHECK(( vertex_gen_requirements<
+ vertex_gen<vertexS<vecS,true, targetS>, int, int>, int >() ));
+
+ // BOOST_CHECK(( vertex_gen_requirements<
+ // vertex_gen<vertexS<vecS,false>, int, custom_vertex_base> >() ));
+
+ // BOOST_CHECK(( vertex_gen_requirements<
+ // vertex_gen<vertexS<vecS,true>, int, custom_vertex_base> >() ));
+ //BOOST_CHECK(( usageExample() ));
+
+ return 0;
+}
+
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk