|
Boost-Commit : |
From: huseyinakcan_at_[hidden]
Date: 2007-07-15 02:19:50
Author: huseyinakcan
Date: 2007-07-15 02:19:49 EDT (Sun, 15 Jul 2007)
New Revision: 7432
URL: http://svn.boost.org/trac/boost/changeset/7432
Log:
updates and added doc for facet and vertex selector
Added:
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/boost/
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/boost/hdstl (contents, props changed)
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.cpp
Text files modified:
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/Makefile | 10
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/container_selectors.hpp | 17 +
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.hpp | 34 ++-
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.t.cpp | 81 +++-----
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.hpp | 360 +++++++++++++++++++++++++++++++++++----
5 files changed, 385 insertions(+), 117 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-15 02:19:49 EDT (Sun, 15 Jul 2007)
@@ -6,11 +6,11 @@
TARGET=dbg_exc_mt
-PACKAGE_OBJECTS=container_selectors.o
+PACKAGE_OBJECTS=container_selectors.o facet_selectors.o
PACKAGE_LIBRARY=libhalfedge_ds.a
-TEST_DRIVERS=container_selectors.t
+TEST_DRIVERS=container_selectors.t facet_selectors.t
.SUFFIXES:
.SUFFIXES: ${TARGET}.o .o .cpp .hpp
@@ -28,6 +28,8 @@
container_selectors.o:
+facet_selectors.o:
+
### BUILDING TEST DRIVERS AND DEPENDENCIES OF TEST DRIVER
@@ -39,11 +41,15 @@
container_selectors.t.o:
+facet_selectors.t.o:
+
%.t.o: %.t.cpp %.hpp
${CXX} ${CXXFLAGS} ${CXXINCLUDES} -c -o $*.t.o $<
container_selectors.t:
+facet_selectors.t:
+
## UTILITIES
Added: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/boost/hdstl
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/boost/hdstl 2007-07-15 02:19:49 EDT (Sun, 15 Jul 2007)
@@ -0,0 +1 @@
+link ../../
\ No newline at end of file
Modified: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/container_selectors.hpp
==============================================================================
--- sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/container_selectors.hpp (original)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/container_selectors.hpp 2007-07-15 02:19:49 EDT (Sun, 15 Jul 2007)
@@ -143,12 +143,6 @@
namespace boost {
namespace hdstl {
-template <typename Selector, typename ValueType>
-struct container_gen {
- // This 'struct', properly specialized for the specified 'Selector', gives
- // various traits of the container of the specified 'ValueType' suitable by
- // the 'halfedge_ds' implementation.
-};
/*
struct hashS {
@@ -180,6 +174,14 @@
// specialization that uses the 'std::vector' container.
};
+
+template <typename Selector, typename ValueType>
+struct container_gen {
+ // This 'struct', properly specialized for the specified 'Selector', gives
+ // various traits of the container of the specified 'ValueType' suitable by
+ // the 'halfedge_ds' implementation.
+};
+
// SPECIALIZATIONS
#if 0
template <typename ValueType>
@@ -260,7 +262,6 @@
}
};
#endif
-
template <typename ValueType>
struct container_gen<listS, ValueType> {
// This specialization of 'container_gen' selects the 'std::list'
@@ -382,7 +383,7 @@
// TYPES
typedef std::vector<ValueType> type;
- // The container type, here a 'std::list'.
+ // The container type, here a 'std::vector'.
typedef typename std::vector<ValueType>::size_type descriptor;
// Type used to describe an element in the collection of elements
Modified: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.hpp
==============================================================================
--- sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.hpp (original)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.hpp 2007-07-15 02:19:49 EDT (Sun, 15 Jul 2007)
@@ -148,6 +148,8 @@
#ifndef BOOST_HDSTL_FACET_SELECTORS_HPP
#define BOOST_HDSTL_FACET_SELECTORS_HPP 1
+#include <boost/hdstl/halfedge_ds/container_selectors.hpp>
+
namespace boost {
namespace hdstl {
@@ -174,7 +176,7 @@
enum { has_facet_links = HasFacetLink };
// A boolean enumeration that tells whether the stored halfedge should
- // contain a link to one of the halfedges in its fact cycle or not.
+ // contain a link to one of the halfedges in its facet cycle or not.
};
// ------------------
@@ -214,36 +216,36 @@
// class facet_gen
// ---------------
-template <typename HalfedgeDescriptor, typename FacetBase>
+template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
struct facet_gen {
// This 'struct' implements a facet generator. The general definition does
// nothing.
};
// SPECIALIZATIONS
-template <typename FacetS, typename HalfedgeDescriptor = void, typename FacetBase = void>
-struct facet_gen<facetS<ContainerS, HasFacetLink>, HalfedgeDescriptor, FacetBase> {
+template <typename ContainerS, bool HasFacetLink,
+ typename HalfedgeDescriptor, typename FacetBase>
+struct facet_gen<facetS<ContainerS,HasFacetLink>, HalfedgeDescriptor, FacetBase> {
// This specialization of a facet generator for 'facetS' takes a facet selector
// and a halfedge descriptor, and uses the 'container_selectors' component
// to define a suitable base for the 'halfedge_ds_gen' that implements all
// the functionality of the 'halfedge_ds' related to the facets.
// TYPES
- typedef container_gen<ContainerS> ContainerGen;
- // The container generator for this facet generator.
-
- typedef stored_facet<FacetBase, HasfacetLink, HalfedgeDescriptor>
+ typedef stored_facet<FacetBase, HasFacetLink, HalfedgeDescriptor>
facet_type;
// The stored facet type for this facet generator.
+
+ typedef container_gen<ContainerS, facet_type> ContainerGen;
+ // The container generator for this facet generator.
- typedef typename container_gen<ContainerS, facet_type>::type
- container_type;
+ typedef typename ContainerGen::type container_type;
// The facet container type for this facet generator.
- typedef typename container_type::descriptor facet_descriptor;
+ typedef typename ContainerGen::descriptor facet_descriptor;
// The facet descriptor type for this facet generator.
- typedef typename container_type::iterator facet_iterator;
+ typedef typename ContainerGen::iterator facet_iterator;
// The facet iterator type for this facet generator.
// DATA
@@ -257,7 +259,7 @@
facets_begin(facet_gen<FacetS, HalfedgeDescriptor, FacetBase> const& hds) {
typedef typename facet_gen<FacetS,
HalfedgeDescriptor,
- FacetBase>::container_gen_type ContainerGen;
+ FacetBase>::ContainerGen ContainerGen;
return ContainerGen::container_begin(hds.m_container);
}
@@ -266,13 +268,13 @@
facets_end(facet_gen<FacetS, HalfedgeDescriptor, FacetBase> const& hds) {
typedef typename facet_gen<FacetS,
HalfedgeDescriptor,
- FacetBase>::container_gen_type ContainerGen;
+ FacetBase>::ContainerGen ContainerGen;
return ContainerGen::container_end(hds.m_container);
}
template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
-typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::size_type;
-facets_end(facet_gen<FacetS, HalfedgeDescriptor, FacetBase> const& hds) {
+typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::size_type
+num_facets(facet_gen<FacetS, HalfedgeDescriptor, FacetBase> const& hds) {
return hds.m_container.size();
}
Modified: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.t.cpp
==============================================================================
--- sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.t.cpp (original)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.t.cpp 2007-07-15 02:19:49 EDT (Sun, 15 Jul 2007)
@@ -11,7 +11,7 @@
// signatures. Finally, verify that the usage example compiles and executes
// without errors, when assert is replaced by BOOST_CHECK.
-#include <boost/hdstl/halfedge_ds/container_selectors.hpp>
+#include <boost/hdstl/halfedge_ds/facet_selectors.hpp>
#include <boost/test/minimal.hpp>
@@ -23,65 +23,50 @@
using namespace std;
// ===========================================================================
-// SELECTOR CLASSES
+// SELECTION CLASSES
// ===========================================================================
template <typename FacetS>
-bool selector_requirements(FacetS const&) {
+bool selection_requirements(FacetS const&) {
return false;
}
-bool selector_requirements(noFacetS const&) {
+bool selection_requirements(noFacetS const&) {
return true;
}
-template <typename Base, typename HalfedgeDescriptor>
-bool selector_requirements(facetS<Base, false, HalfedgeDescriptor> const&) {
+template <typename Base>
+bool selection_requirements(facetS<Base, false> const&) {
return true;
}
-template <typename Base, typename HalfedgeDescriptor>
-bool selector_requirements(facetS<Base, true, HalfedgeDescriptor> const&) {
+template <typename Base>
+bool selection_requirements(facetS<Base, true> const&) {
return true;
}
// ===========================================================================
-// CLASS CONTAINER_GEN
+// CLASS FACET_GEN
// ===========================================================================
-template <typename FacetS>
-bool selection_requirements(FacetS const&) {
- return false;
-}
-
-template <typename Base, typename HalfedgeDescriptor>
-bool selector_requirements(facetS<Base, false, HalfedgeDescriptor> const&f) {
- return true;
-}
-
-template <typename Base, typename HalfedgeDescriptor>
-bool selector_requirements(facetS<Base, true, HalfedgeDescriptor> const&) {
- return true;
-}
-
-template <class ContainerGen, typename ValueType, typename FacetS>
-bool container_gen_requirements() {
- ValueType array[] = { 0, 1, 2, 3 };
- typename ContainerGen::type container(array, array + 4);
+template <typename FacetGen>
+bool facet_gen_requirements() {
- BOOST_CHECK(( selection_requirements(FacetS(), container) ));
-
// Types must exist.
- typedef typename ContainerGen::descriptor descriptor;
- typedef typename ContainerGen::iterator iterator;
+ typedef typename FacetGen::facet_descriptor facet_descriptor;
+ typedef typename FacetGen::facet_iterator facet_iterator;
+ typedef typename FacetGen::facet_type facet_type;
+ typedef typename FacetGen::container_type container_type;
+ facet_type array[] = { 0, 1, 2, 3 };
+ container_type container(array, array + 4);
+
// Value type of iterator must be a descriptor.
- iterator begin = ContainerGen::container_begin(container);
- descriptor theBegin = *begin;
+ facet_iterator begin = ContainerGen.container_begin(container);
+ facet_descriptor theBegin = *begin;
return true;
}
-
// ===========================================================================
// USAGE EXAMPLE
// ===========================================================================
@@ -154,6 +139,8 @@
// individual elements:
//..
bool usageExample() {
+
+
Element george(632, "Harrison", +78);
Element john (834, "Lennon", +255);
Element paul (932, "McCartney", +126);
@@ -195,21 +182,15 @@
int test_main(int, char **)
{
- #if 0
- BOOST_CHECK(( selector_requirements(hashS()) ));
- #endif
- BOOST_CHECK(( selector_requirements(listS()) ));
- BOOST_CHECK(( selector_requirements(setS()) ));
- BOOST_CHECK(( selector_requirements(vecS()) ));
-
- #if 0
- BOOST_CHECK(( selection_requirements<container_gen<hashS, int>, hashS>() ));
- #endif
- BOOST_CHECK(( container_gen_requirements<container_gen<listS, int>, int, listS>() ));
- BOOST_CHECK(( container_gen_requirements<container_gen<setS, int>, int, setS>() ));
- BOOST_CHECK(( container_gen_requirements<container_gen<vecS, int>, int, vecS>() ));
-
- BOOST_CHECK(( usageExample() ));
+ BOOST_CHECK(( selection_requirements(noFacetS()) ));
+ BOOST_CHECK(( selection_requirements(facetS<listS,true>()) ));
+ BOOST_CHECK(( selection_requirements(facetS<listS,false>()) ));
+
+ BOOST_CHECK(( selection_requirements(facetS<vecS,true>()) ));
+ BOOST_CHECK(( selection_requirements(facetS<vecS,false>()) ));
+ //BOOST_CHECK(( facet_gen_requirements<facet_gen<facetS<vecS,false>, int, void> >() ));
+
+ //BOOST_CHECK(( usageExample() ));
return 0;
}
Added: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.cpp
==============================================================================
--- (empty file)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.cpp 2007-07-15 02:19:49 EDT (Sun, 15 Jul 2007)
@@ -0,0 +1,3 @@
+//vertex_selectors.cpp -*- C++ -*-
+
+#include <boost/hdstl/halfedge_ds/vertex_selectors.hpp>
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-15 02:19:49 EDT (Sun, 15 Jul 2007)
@@ -3,73 +3,351 @@
//@PURPOSE: Provide selector classes for 'VertexS'.
//
//@CLASSES:
-// 'vertexS': defines configuration options for vertex access
-// 'noVertexS' defines that vertices are not supported by the 'HDS'
-// 'vertexLinkS' reverse links from vertices to a halfedge is defined
-// 'noVertexLinkS' reverse links from vertices to halfedges not defined
-// 'sourceS' default vertex access method for halfedges is set to source
-// 'targetS' default vertex access method for halfedges is set to target
-// 'base_vertex' base class to select the method of access between source and
-// target
-//
+// 'vertexS': defines configuration options for vertex storage and access
+// 'stored_vertex': defines the storage for a given vertex configuration
+// 'vertex_gen': defines the stored type and accessors for a vertex
+// configuration
+//
//@SEE_ALSO: {hds_concepts.hpp, halfedge_ds.hpp}
//
-//@DESCRIPTION: This file provides the vertexS selector class for
-//configurations related to vertex properties. Uses the 'noVertexS',
-//'vertexLinkS', 'noVertexLinkS', 'sourceS', 'targetS', and 'base_vertex'
-//selector classes to configure options based on the vertex access type.
+//@DESCRIPTION: This file provides the 'vertexS' selector class for
+//configurations related to vertex properties. These selector types are
+//suitable to use for the 'VertexS' template parameter to the 'halfedge_ds'
+//class tempalte. Currently there are two vertex selectors:
+//
+// - 'noVertexS': means that there should be no facets in the corresponding
+// 'hafedge_ds' data structure.
+//
+// - 'vertexS<ContainerS, HasVertexLink, VertexType>': (where 'ContainerS' can
+// be any of the types defined by the 'container_selectors' component, such
+// as 'listS', 'vecS', 'setS' or 'hashS') means that there should be
+// vertices stored in that kind of containers within the 'halfedge_ds' data
+// structure, and whether the vertices must have a link to one of the
+// halfedges in their vertex cycles defined by 'VertexType' or not.
+//
+// - 'sourceS': default vertex access method for halfedges is set to source
+//
+// - 'targetS': default vertex access method for halfedges is set to target
+//
+// - 'base_vertex': base class to select the method of access between source
+// and target
+//
+// As a consequence, a 'halfedge_ds<..., ..., vertexS<...> >' data structure
+// (where the actual selectors used in '...' do not matter) will model the
+// 'VertexListHDS' concept.
+//
+///Usage
+///-----
+// Supposed we want to design a stored vertex from a vertex selector. A stored
+// vertex needs to know:
+// - whether halfedge_ds should store a link to source or target vertex.
+// - whether it stores a vertex link or not.
+// - the halfedge descriptor: in order to store the vertex link. Since it is
+// not needed when the vertex stores no vertex link, we make it integer in
+// that case.
+// - any extra properties that need to get contained by the vertex as member. We
+// make this a parameterized base class.
+//
+// We therefore have the following general implementation.
+//..
+// template <bool HasVertexLink = false, typename HalfedgeDescriptor = int>
+// struct stored_vertex {
+// // This struct implements a stored vertex with a vertex link if
+// // 'HasVertexLink' is true
+
+// //DATA
+// HalfedgeDescriptor m_vertexLink;
+
+// //CREATORS
+// stored_vertex(HalfedgeDescriptor vertexLink) : m_vertexLink(vertexLink){
+// }
+// };
+//..
+// Since the vertexLink is stored or not, we encapsulate this in a
+// specialization.
+//..
+// template <typename HalfedgeDescriptor>
+// struct stored_vertex<false, HalfedgeDescriptor> {
+// // This partial specialization implements a stored vertex without storing
+// // a vertex link although its constuctoe accepts a null vertex link for
+// // uniformity of the interface with the general definition.
+//
+// // CREATORS
+// stored_vertex(HalfedgeDescriptor = 0) {
+// }
+// };
+//..
+// We use base_vertexS to select the vertex access method. Base class defines
+// nothing.
+//..
+// template <typename VertexType>
+// struct base_vertexS {
+// // A selector that specializes whether source or target vertices are stored.
+// };
+//..
+// We specialize with sourceS to tell the halfedge_ds that it should keep
+// links to source vertices.
+//..
+// template<>
+// struct base_vertexS<sourceS>{
+// // A specialized selector that tells the 'halfedge_ds' that source vertices
+// // should be stored.
+//
+// // TYPES
+// enum { type = true };
+// enum { is_source = true };
+// enum { is_target = false };
+// };
+//..
+// or we specialize with targetS to tell the halfedge_ds that it should keep
+// links to target vertices.
+//..
+//
+// template<>
+// struct base_vertexS<targetS>{
+// // A specialized selector that tells the 'halfedge_ds' that target vertices
+// // should be stored.
+//
+// // TYPES
+// enum { type = false };
+// enum { is_source = false };
+// enum { is_target = true };
+// };
+//..
+// Now, we can further define the vertex generator: it takes a vertex selector
+// and a halfedge descriptor, and uses the 'container_selectors' component to
+// define a suitable base for the 'halfedge_ds_gen' that implements all the
+// functionality of the 'halfedge_ds' related to the vertices.
+//..
+// template <typename VertexS, typename HalfedgeDescriptor>
+// struct vertex_gen {
+// // This struct implements a vertex generator. The generel definition does
+// // nothing.
+// };
+//..
+// The proper vertex generator is defined only when 'VertexS' is of the form
+// 'vertexS<...>':
+//..
+//
+// //SPECIALIZATIONS
+// template <typename ContainerS, bool HasVertexLink, typename VertexType,
+// typename HalfedgeDescriptor>
+// struct vertex_gen<vertexS<ContainerS, HasVertexLink, VertexType>,
+// HalfedgeDescriptor> {
+// // This specialization is a vertex generator for 'vertexS' that takes a
+// // vertex selector, vertex type selector , halfedge descriptor and uses
+// // the container_selectors compenent to define a suitable base for the
+// // 'halfedge_ds_gen' that implements all the functionality of the
+// // 'halfedge_ds' related to vertices.
+//
+// // TYPES
+// typedef stored_vertex<HasVertexLink, HalfedgeDescriptor> vertex_type;
+// // The stored vertex type for this vertex generator.
+//
+// typedef container_gen<ContainerS, vertex_type> ContainerGen;
+// // The container generator for this vertex generator.
+//
+// typedef typename ContainerGen::type container_type;
+// // The vertex container type for this vertex generator.
+//
+// typedef typename ContainerGen::descriptor vertex_descriptor;
+// // The vertex descriptor type for this vertex generator.
+//
+// typedef typename ContainerGen::iterator vertex_iterator;
+// // The vertex iterator type for this vertex generator.
+//
+// // DATA
+// container_type m_container;
+// // The actual container for the vertices from which vertices can be
+// // obtained.
+// };
+//..
+// and the supporting functions, required by the 'VertexListHDS' concept, are:
+//..
+// // FREE FUNCTIONS
+// template <typename VertexS, typename HalfedgeDescriptor>
+// typename vertex_gen<VertexS, HalfedgeDescriptor>::iterator
+// vertices_begin(vertex_gen<VertexS, HalfedgeDescriptor> const& hds) {
+// typedef typename vertex_gen<VertexS,
+// HalfedgeDescriptor>::ContainerGen ContainerGen;
+// return ContainerGen::container_begin(hds.m_container);
+// }
+//
+// template <typename VertexS, typename HalfedgeDescriptor>
+// typename vertex_gen<VertexS, HalfedgeDescriptor>::iterator
+// vertices_end(vertex_gen<VertexS, HalfedgeDescriptor> const& hds) {
+// typedef typename vertex_gen<VertexS,
+// HalfedgeDescriptor>::ContainerGen ContainerGen;
+// return ContainerGen::container_end(hds.m_container);
+// }
+//
+// template <typename VertexS, typename HalfedgeDescriptor>
+// typename vertex_gen<VertexS, HalfedgeDescriptor>::size_type
+// num_vertices(vertex_gen<VertexS, HalfedgeDescriptor> const& hds) {
+// return hds.m_container.size();
+// }
+//..
#ifndef BOOST_HDSTL_VERTEX_SELECTORS_HPP
#define BOOST_HDSTL_VERTEX_SELECTORS_HPP 1
-namespace boost;
-namespace hdstl;
+#include <boost/hdstl/halfedge_ds/container_selectors.hpp>
-struct noVertexS { };
+namespace boost {
+namespace hdstl {
-struct vertexLinkS { };
-
-struct noVertexLinkS { };
+struct sourceS {
+ // A selector that tells the 'halfedge_ds' that each halfedge should keep
+ // a pointer to its source vertex.
+};
-struct sourceS { };
+struct targetS {
+ // A selector that tells the 'halfedge_ds' that each halfedge should keep
+ // a pointer to its target vertex.
+};
-struct targetS { };
+struct noVertexS {
+ // A selector that tells the 'halfedge_ds' that it should not store vertices.
+};
template <typename VertexType>
-struct base_vertexS {};
+struct base_vertexS {
+ // A selector that specializes whether source or target vertices are stored.
+};
template<>
struct base_vertexS<sourceS>{
- typedef true_type type;
- typedef true_type is_source;
- typedef false_type is_target;
-}
+ // A specialized selector that tells the 'halfedge_ds' that source vertices
+ // should be stored.
+
+ // TYPES
+ enum { type = true };
+ enum { is_source = true };
+ enum { is_target = false };
+};
template<>
struct base_vertexS<targetS>{
- typedef false_type type;
- typedef false_type is_source;
- typedef true_type is_target;
-}
+ // A specialized selector that tells the 'halfedge_ds' that target vertices
+ // should be stored.
-template <typename Selector, VertexLinkType, VertexType>
-struct vertexS
-: base_vertexS<VertexType>
-{
+ // TYPES
+ enum { type = false };
+ enum { is_source = false };
+ enum { is_target = true };
};
-template<typename Selector, VertexType>
-struct vertexS<Selector, vertexLinkS, VertexType>
+template <typename ContainerS, bool HasVertexLink=false,
+ typename VertexType=sourceS>
+struct vertexS
: base_vertexS<VertexType> {
- typedef true_type has_vertex_links;
+ // A selector that tells 'halfedge_ds' that it should store vertices
+ // specified by the 'base_vertexS', which is either source or target,
+ // and if 'HasVertexLink' is true, a link should be kept to one of the
+ // halfedges in the 'source' or 'target' cycle.
+
+ //TYPES
+ typedef ContainerS container_selector;
+ // A selector (see the compenent 'container_selector') for the type of
+ // container that will be used to store the vertices.
+
+ enum { has_vertex_links = HasVertexLink };
};
-template<typename Selector, VertexType>
-struct vertexS<Selector, noVertexLinkS, VertexType>
-: base_vertexS<VertexType> {
- typedef false_type has_vertex_links;
+
+ // ------------------
+ // class stored_facet
+ // ------------------
+
+template <bool HasVertexLink = false, typename HalfedgeDescriptor = int>
+struct stored_vertex {
+ // This struct implements a stored vertex with a vertex link if
+ // 'HasVertexLink' is true
+
+ //DATA
+ HalfedgeDescriptor m_vertexLink;
+
+ //CREATORS
+ stored_vertex(HalfedgeDescriptor vertexLink) : m_vertexLink(vertexLink){
+ }
};
+template <typename HalfedgeDescriptor>
+struct stored_vertex<false, HalfedgeDescriptor> {
+ // This partial specialization implements a stored vertex without storing
+ // a vertex link although its constuctoe accepts a null vertex link for
+ // uniformity of the interface with the general definition.
+
+ // CREATORS
+ stored_vertex(HalfedgeDescriptor = 0) {
+ }
+};
+ // ---------------
+ // class vertex_gen
+ // ---------------
+
+template <typename VertexS, typename HalfedgeDescriptor>
+struct vertex_gen {
+ // This struct implements a vertex generator. The generel definition does
+ // nothing.
+};
+
+//SPECIALIZATIONS
+template <typename ContainerS, bool HasVertexLink, typename VertexType,
+ typename HalfedgeDescriptor>
+struct vertex_gen<vertexS<ContainerS, HasVertexLink, VertexType>,
+ HalfedgeDescriptor> {
+ // This specialization is a vertex generator for 'vertexS' that takes a
+ // vertex selector, vertex type selector , halfedge descriptor and uses
+ // the container_selectors compenent to define a suitable base for the
+ // 'halfedge_ds_gen' that implements all the functionality of the
+ // 'halfedge_ds' related to vertices.
+
+ // TYPES
+ typedef stored_vertex<HasVertexLink, HalfedgeDescriptor> vertex_type;
+ // The stored vertex type for this vertex generator.
+
+ typedef container_gen<ContainerS, vertex_type> ContainerGen;
+ // The container generator for this vertex generator.
+
+ typedef typename ContainerGen::type container_type;
+ // The vertex container type for this vertex generator.
+
+ typedef typename ContainerGen::descriptor vertex_descriptor;
+ // The vertex descriptor type for this vertex generator.
+
+ typedef typename ContainerGen::iterator vertex_iterator;
+ // The vertex iterator type for this vertex generator.
+
+ // DATA
+ container_type m_container;
+ // The actual container for the vertices from which vertices can be
+ // obtained.
+};
+
+// FREE FUNCTIONS
+template <typename VertexS, typename HalfedgeDescriptor>
+typename vertex_gen<VertexS, HalfedgeDescriptor>::iterator
+vertices_begin(vertex_gen<VertexS, HalfedgeDescriptor> const& hds) {
+ typedef typename vertex_gen<VertexS,
+ HalfedgeDescriptor>::ContainerGen ContainerGen;
+ return ContainerGen::container_begin(hds.m_container);
+}
+
+template <typename VertexS, typename HalfedgeDescriptor>
+typename vertex_gen<VertexS, HalfedgeDescriptor>::iterator
+vertices_end(vertex_gen<VertexS, HalfedgeDescriptor> const& hds) {
+ typedef typename vertex_gen<VertexS,
+ HalfedgeDescriptor>::ContainerGen ContainerGen;
+ return ContainerGen::container_end(hds.m_container);
+}
+
+template <typename VertexS, typename HalfedgeDescriptor>
+typename vertex_gen<VertexS, HalfedgeDescriptor>::size_type
+num_vertices(vertex_gen<VertexS, HalfedgeDescriptor> const& hds) {
+ return hds.m_container.size();
+}
+
} // namespace hdstl
} // namespace boost
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