|
Boost-Commit : |
From: huseyinakcan_at_[hidden]
Date: 2007-07-16 21:13:21
Author: huseyinakcan
Date: 2007-07-16 21:13:20 EDT (Mon, 16 Jul 2007)
New Revision: 7453
URL: http://svn.boost.org/trac/boost/changeset/7453
Log:
more test cases added for facet_selector class
Text files modified:
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/container_selectors.hpp | 16 ++++
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.hpp | 26 ++++---
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.t.cpp | 138 +++++++++++++++++++++++++++++++++------
sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.hpp | 126 ++++++++++++++++++++++++++---------
4 files changed, 237 insertions(+), 69 deletions(-)
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-16 21:13:20 EDT (Mon, 16 Jul 2007)
@@ -199,6 +199,9 @@
// TYPES
typedef std::tr1::hash_set<ValueType> type;
// The container type, here a 'std::tr1::hash_set'.
+
+ typedef typename std::tr1::hash_set<ValueType>::size_type size_type;
+ // The container size type.
typedef ValueType* descriptor;
// Type used to describe an element in the collection of elements
@@ -286,6 +289,9 @@
// TYPES
typedef std::list<ValueType> type;
// The container type, here a 'std::list'.
+
+ typedef typename std::list<ValueType>::size_type size_type;
+ // The container size type.
typedef ValueType* descriptor;
// Type used to describe an element in the collection of elements
@@ -353,6 +359,9 @@
typedef std::set<ValueType> type;
// The container type, here a 'std::set'.
+ typedef typename std::set<ValueType>::size_type size_type;
+ // The container size type.
+
typedef const ValueType* descriptor;
// Type used to describe an element in the collection of elements
// present in a given container.
@@ -375,14 +384,14 @@
// Return the descriptor of the element pointed to by this
// iterator.
{
- return &(*base_type());
+ return &(*base_type(*this));
}
// ACCESSORS
const ValueType* operator*() const
// Return the descriptor of the element pointed to by this
// iterator.
{
- return &(*base_type());
+ return &(*base_type(*this));
}
};
@@ -417,6 +426,9 @@
typedef std::vector<ValueType> type;
// The container type, here a 'std::vector'.
+ typedef typename std::vector<ValueType>::size_type size_type;
+ // The container size type.
+
typedef typename std::vector<ValueType>::size_type descriptor;
// Type used to describe an element in the collection of elements
// present in a given container.
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-16 21:13:20 EDT (Mon, 16 Jul 2007)
@@ -187,9 +187,8 @@
bool HasFacetLink = false,
typename HalfedgeDescriptor = int>
struct stored_facet {
- // This 'struct' implements a stored facet, from the
- // parameterized 'Base' (if not void), and adding a facet link if 'HasFacetLink' is
- // true.
+ // This 'struct' implements a stored facet, from the parameterized 'Base'
+ // (if not void), and adding a facet link if 'HasFacetLink' is true.
// DATA
HalfedgeDescriptor m_facetLink;
@@ -244,8 +243,8 @@
template <typename HalfedgeDescriptor>
struct stored_facet<void, false, HalfedgeDescriptor> {
- // This partial specialization implements a stored facet, deriving from the
- // parameterized 'Base', but without storing a facet link although its
+ // This partial specialization implements a stored facet, with a 'void'
+ // base, but without storing a facet link although its
// constructor accepts a null facet link for uniformity of the
// interface with the general definition.
@@ -286,6 +285,9 @@
typedef typename ContainerGen::type container_type;
// The facet container type for this facet generator.
+ typedef typename ContainerGen::size_type size_type;
+ // The facet container size type for this facet generator.
+
typedef typename ContainerGen::descriptor facet_descriptor;
// The facet descriptor type for this facet generator.
@@ -299,8 +301,8 @@
// FREE FUNCTIONS
template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
-typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::iterator
-facets_begin(facet_gen<FacetS, HalfedgeDescriptor, FacetBase> const& hds) {
+typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_iterator
+facets_begin(facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds) {
typedef typename facet_gen<FacetS,
HalfedgeDescriptor,
FacetBase>::ContainerGen ContainerGen;
@@ -308,8 +310,8 @@
}
template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
-typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::iterator
-facets_end(facet_gen<FacetS, HalfedgeDescriptor, FacetBase> const& hds) {
+typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_iterator
+facets_end(facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds) {
typedef typename facet_gen<FacetS,
HalfedgeDescriptor,
FacetBase>::ContainerGen ContainerGen;
@@ -324,12 +326,14 @@
template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
HalfedgeDescriptor
-halfedge(typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_descriptor const& f,
- facet_gen<FacetS, HalfedgeDescriptor, FacetBase> const& hds) {
+halfedge(typename facet_gen<FacetS, HalfedgeDescriptor,
+ FacetBase>::facet_descriptor const& f,
+ facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds) {
return facet_gen<FacetS, HalfedgeDescriptor, FacetBase>
::ContainerGen::value(f, hds.m_container).m_facetLink;
}
+
} // namespace hdstl
} // namespace boost
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-16 21:13:20 EDT (Mon, 16 Jul 2007)
@@ -35,13 +35,13 @@
return true;
}
-template <typename Base>
-bool selection_requirements(facetS<Base, false> const&) {
+template <typename Selector>
+bool selection_requirements(facetS<Selector, false> const&) {
return true;
}
-template <typename Base>
-bool selection_requirements(facetS<Base, true> const&) {
+template <typename Selector>
+bool selection_requirements(facetS<Selector, true> const&) {
return true;
}
@@ -49,6 +49,33 @@
// CLASS FACET_GEN
// ===========================================================================
+template<typename FacetGen>
+bool facet_gen_requirements_void_noFacetLink() {
+
+ // Types must exist.
+ typedef typename FacetGen::facet_selector facet_selector;
+ 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 fa;
+ facet_type fb;
+ facet_type fc;
+ facet_type fd;
+ facet_type array[] = { fa, fb, fc, fd };
+
+ // Construct a facet_gen object whose container contains array.
+ // Verify that facets_begin(), facets_end(), and num_facets() work.
+ // Access the facets and, if the has_facet_links is set, check that the
+ // halfedge() works.
+ container_type temp_con(array,array+4);
+ FacetGen facetGen;
+ facetGen.m_container = temp_con;
+ BOOST_CHECK(( num_facets(facetGen) == 4 ));
+ return true;
+}
+
template <typename FacetGen>
bool facet_gen_requirements_void() {
@@ -63,13 +90,51 @@
facet_type fb(2);
facet_type fc(3);
facet_type fd(4);
- facet_type array[] = { fa, fb, fc, fd }; (void) array;
+ facet_type array[] = { fa, fb, fc, fd };
- // Contruct a facet_gen object whose container contains array.
- // Verify that halfedges_begin(), halfedges_end(), and num_facets() work.
+ // Construct a facet_gen object whose container contains array.
+ // Verify that facets_begin(), facets_end(), and num_facets() work.
// Access the facets and, if the has_facet_links is set, check that the
// halfedge() works.
// ... TODO
+ container_type temp_con(array,array+4);
+ FacetGen facetGen;
+ facetGen.m_container = temp_con;
+ BOOST_CHECK(( num_facets(facetGen) == 4 ));
+ BOOST_CHECK(( facets_begin(facetGen)->m_facetLink == 1 ));
+ BOOST_CHECK(( (--facets_end(facetGen))->m_facetLink == 4 ));
+
+ //BOOST_CHECK(( halfedge(*facets_begin(facetGen), facetGen) == 1 ));
+ //BOOST_CHECK(( halfedge(*(--facets_end(facetGen)), facetGen) == 4 ));
+ return true;
+}
+
+template <typename FacetGen, typename Base>
+bool facet_gen_requirements_noFacetLink() {
+
+ typedef typename FacetGen::facet_selector facet_selector;
+ 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 fa(Base(1));
+ facet_type fb(Base(2));
+ facet_type fc(Base(3));
+ facet_type fd(Base(4));
+ facet_type array[] = { fa, fb, fc, fd }; (void) array;
+
+ // Same checks as before:
+ //BOOST_CHECK(( facet_gen_requirements_void_noFacetLink<FacetGen>() ));
+ container_type temp_con(array,array+4);
+ FacetGen facetGen;
+ facetGen.m_container = temp_con;
+ BOOST_CHECK(( num_facets(facetGen) == 4 ));
+
+ // Plus: get the base back from the facets and making sure it matches.
+ BOOST_CHECK(( facets_begin(facetGen)->base() == 1 ));
+ BOOST_CHECK(( (--facets_end(facetGen))->base() == 4 ));
+
return true;
}
@@ -90,10 +155,21 @@
facet_type array[] = { fa, fb, fc, fd }; (void) array;
// Same checks as before:
- BOOST_CHECK(( facet_gen_requirements_void<FacetGen>() ));
+ //BOOST_CHECK(( facet_gen_requirements_void<FacetGen>() ));
+ container_type temp_con(array,array+4);
+ FacetGen facetGen;
+ facetGen.m_container = temp_con;
+ BOOST_CHECK(( num_facets(facetGen) == 4 ));
+
+ BOOST_CHECK(( facets_begin(facetGen)->m_facetLink == 1 ));
+ BOOST_CHECK(( (--facets_end(facetGen))->m_facetLink == 4 ));
+ //BOOST_CHECK(( halfedge(*facets_begin(facetGen), facetGen) == 1 ));
+ //BOOST_CHECK(( halfedge(*(--facets_end(facetGen)), facetGen) == 4 ));
+
// Plus: get the base back from the facets and making sure it matches.
- // ... TODO
+ BOOST_CHECK(( facets_begin(facetGen)->base() == 1 ));
+ BOOST_CHECK(( (--facets_end(facetGen))->base() == 4 ));
return true;
}
@@ -113,22 +189,40 @@
BOOST_CHECK(( selection_requirements(noFacetS()) ));
BOOST_CHECK(( selection_requirements(facetS<listS,true>()) ));
BOOST_CHECK(( selection_requirements(facetS<listS,false>()) ));
- BOOST_CHECK(( facet_gen_requirements_void<facet_gen<facetS<listS,false>, int, void> >() ));
- BOOST_CHECK(( facet_gen_requirements<facet_gen<facetS<listS,false>, int, int>, int >() ));
- // BOOST_CHECK(( facet_gen_requirements<facet_gen<facetS<listS,false>, int, custom_facet_base> >() ));
- BOOST_CHECK(( facet_gen_requirements_void<facet_gen<facetS<listS,true>, int, void> >() ));
- BOOST_CHECK(( facet_gen_requirements<facet_gen<facetS<listS,true>, int, int>, int >() ));
- // BOOST_CHECK(( facet_gen_requirements<facet_gen<facetS<listS,true>, int, custom_facet_base> >() ));
+
+ BOOST_CHECK(( facet_gen_requirements_void_noFacetLink<
+ facet_gen<facetS<listS,false>, int, void> >() ));
+ BOOST_CHECK(( facet_gen_requirements_void<
+ facet_gen<facetS<listS,true>, int, void> >() ));
+
+ BOOST_CHECK(( facet_gen_requirements_noFacetLink<
+ facet_gen<facetS<listS,false>, int, int>, int >() ));
+ BOOST_CHECK(( facet_gen_requirements<
+ facet_gen<facetS<listS,true>, int, int>, int >() ));
+
+ // BOOST_CHECK(( facet_gen_requirements<
+ // facet_gen<facetS<listS,false>, int, custom_facet_base> >() ));
+
+ // BOOST_CHECK(( facet_gen_requirements<
+ // facet_gen<facetS<listS,true>, int, custom_facet_base> >() ));
BOOST_CHECK(( selection_requirements(facetS<vecS,true>()) ));
BOOST_CHECK(( selection_requirements(facetS<vecS,false>()) ));
- BOOST_CHECK(( facet_gen_requirements_void<facet_gen<facetS<vecS,false>, int, void> >() ));
- BOOST_CHECK(( facet_gen_requirements<facet_gen<facetS<vecS,false>, int, int>, int >() ));
- // BOOST_CHECK(( facet_gen_requirements<facet_gen<facetS<vecS,false>, int, custom_facet_base> >() ));
- BOOST_CHECK(( facet_gen_requirements_void<facet_gen<facetS<vecS,true>, int, void> >() ));
- BOOST_CHECK(( facet_gen_requirements<facet_gen<facetS<vecS,true>, int, int>, int >() ));
- // BOOST_CHECK(( facet_gen_requirements<facet_gen<facetS<vecS,true>, int, custom_facet_base> >() ));
-
+
+ BOOST_CHECK(( facet_gen_requirements_void_noFacetLink<
+ facet_gen<facetS<vecS,false>, int, void> >() ));
+ BOOST_CHECK(( facet_gen_requirements_void<
+ facet_gen<facetS<vecS,true>, int, void> >() ));
+
+ BOOST_CHECK(( facet_gen_requirements_noFacetLink<
+ facet_gen<facetS<vecS,false>, int, int>, int >() ));
+ BOOST_CHECK(( facet_gen_requirements<
+ facet_gen<facetS<vecS,true>, int, int>, int >() ));
+
+ // BOOST_CHECK(( facet_gen_requirements<
+ // facet_gen<facetS<vecS,false>, int, custom_facet_base> >() ));
+ // BOOST_CHECK(( facet_gen_requirements<
+ // facet_gen<facetS<vecS,true>, int, custom_facet_base> >() ));
//BOOST_CHECK(( usageExample() ));
return 0;
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-16 21:13:20 EDT (Mon, 16 Jul 2007)
@@ -226,7 +226,7 @@
// TYPES
enum { type = true };
enum { is_source = true };
- enum { is_target = false };
+ enum { is_target = !is_source };
};
template<>
@@ -236,8 +236,8 @@
// TYPES
enum { type = false };
- enum { is_source = false };
enum { is_target = true };
+ enum { is_source = !is_target };
};
template <typename ContainerS, bool HasVertexLink=false,
@@ -257,38 +257,85 @@
enum { has_vertex_links = HasVertexLink };
};
- // ==================
- // class stored_facet
- // ==================
-
-template <bool HasVertexLink = false, typename HalfedgeDescriptor = int>
+ // ===================
+ // class stored_vertex
+ // ===================
+
+template <typename Base,
+ bool HasVertexLink = false,
+ typename HalfedgeDescriptor = int>
struct stored_vertex {
- // This struct implements a stored vertex with a vertex link if
- // 'HasVertexLink' is true
+ // This struct implements a stored vertex from the parameterized 'Base'
+ // (if not void), and adds a vertex link if 'HasVertexLink' is true
//DATA
HalfedgeDescriptor m_vertexLink;
+ Base m_base;
//CREATORS
- stored_vertex(HalfedgeDescriptor vertexLink) : m_vertexLink(vertexLink){
- }
+ stored_vertex(Base const& base, HalfedgeDescriptor vertexLink)
+ : m_vertexLink(vertexLink),
+ , m_base(base){}
+
+ //MANIPULATORS
+ Base& base() { return m_base; }
+
+ //ACCESSORS
+ const Base& base() const { return m_base; }
+};
+
+template <typename Base, typename HalfedgeDescriptor>
+struct stored_vertex<Base, false, HalfedgeDescriptor> {
+ // This partial specialization implements a stored vertex, deriving from
+ // the parameterized 'Base', but without storing a vertex link although its
+ // constuctor accepts a null vertex link for uniformity of the interface
+ // with the general definition.
+
+ //DATA
+ Base m_base;
+
+ // CREATORS
+ stored_vertex(Base const& base, HalfedgeDescriptor = 0)
+ : m_base(base) {}
+
+ //MANIPULATORS
+ Base& base() { return m_base; }
+
+ //ACCESSORS
+ const Base& base() const { return m_base; }
+};
+
+template <bool HasVertexLink,
+ typename HalfedgeDescriptor>
+struct stored_vertex<void, HasVertexLink, HalfedgeDescriptor> {
+ // This 'struct' implements a stored vertex, with a 'void' base, adding 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.
+struct stored_vertex<void, false, HalfedgeDescriptor> {
+ // This partial specialization implements a stored vertex, with a 'void'
+ // base, but without storing a vertex link although its
+ // constructor accepts a null vertex link for uniformity of the
+ // interface with the general definition.
// CREATORS
- stored_vertex(HalfedgeDescriptor = 0) {
- }
+ stored_vertex(HalfedgeDescriptor = 0) {}
};
+
+
// ================
// class vertex_gen
// ================
-template <typename VertexS, typename HalfedgeDescriptor>
+template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
struct vertex_gen {
// This struct implements a vertex generator. The generel definition does
// nothing.
@@ -296,9 +343,9 @@
//SPECIALIZATIONS
template <typename ContainerS, bool HasVertexLink, typename VertexType,
- typename HalfedgeDescriptor>
+ typename HalfedgeDescriptor, typename VertexBase>
struct vertex_gen<vertexS<ContainerS, HasVertexLink, VertexType>,
- HalfedgeDescriptor> {
+ HalfedgeDescriptor, VertexBase> {
// 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
@@ -306,7 +353,8 @@
// 'halfedge_ds' related to vertices.
// TYPES
- typedef stored_vertex<HasVertexLink, HalfedgeDescriptor> vertex_type;
+ typedef stored_vertex<VertexBase,HasVertexLink, HalfedgeDescriptor>
+ vertex_type;
// The stored vertex type for this vertex generator.
typedef container_gen<ContainerS, vertex_type> ContainerGen;
@@ -328,28 +376,38 @@
};
// 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;
+template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
+typename vertex_gen<VertexS, HalfedgeDescriptor,VertexBase>::iterator
+vertices_begin(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase> const& hds) {
+ typedef typename vertex_gen<VertexS, HalfedgeDescriptor,
+ VertexBase>::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;
+template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
+typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::iterator
+vertices_end(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase> const& hds) {
+ typedef typename vertex_gen<VertexS, HalfedgeDescriptor,
+ VertexBase>::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) {
+template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
+typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::size_type
+num_vertices(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase> const& hds) {
return hds.m_container.size();
}
+template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
+HalfedgeDescriptor
+halfedge(typename vertex_gen<VertexS, HalfedgeDescriptor,
+ VertexBase>::vertex_descriptor const& v,
+ vertex_gen<VertexS, HalfedgeDescriptor, VertexBase> const& hds) {
+ return vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>
+ ::ContainerGen::value(v, hds.m_container).m_vertexLink;
+}
+
+
} // 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