Boost logo

Boost-Commit :

From: huseyinakcan_at_[hidden]
Date: 2007-07-28 00:40:37


Author: huseyinakcan
Date: 2007-07-28 00:40:35 EDT (Sat, 28 Jul 2007)
New Revision: 7570
URL: http://svn.boost.org/trac/boost/changeset/7570

Log:
rest of the functions for vertex and facet selectors,
except the delete functions

Text files modified:
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.hpp | 61 ++++++++++++++++++++-
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/facet_selectors.t.cpp | 16 +++++
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.hpp | 111 +++++++++++++++++++++++++++++++++++++--
   sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.t.cpp | 17 ++++++
   4 files changed, 193 insertions(+), 12 deletions(-)

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-28 00:40:35 EDT (Sat, 28 Jul 2007)
@@ -195,6 +195,8 @@
     Base m_base;
 
     // CREATORS
+ stored_facet() {}
+
     stored_facet(Base const& base, HalfedgeDescriptor facetLink = 0)
     : m_facetLink(facetLink)
     , m_base(base) {}
@@ -217,6 +219,8 @@
     Base m_base;
 
     // CREATORS
+ stored_facet() {}
+
     stored_facet(Base const& base, HalfedgeDescriptor = 0)
     : m_base(base) {}
 
@@ -237,6 +241,8 @@
     HalfedgeDescriptor m_facetLink;
 
     // CREATORS
+ stored_facet() {}
+
     stored_facet(HalfedgeDescriptor facetLink)
     : m_facetLink(facetLink) {}
 };
@@ -299,10 +305,16 @@
         // The actual container for the facets, from which facets can be obtained.
 };
 
+ // ====================
+ // FacetListHDS Concept
+ // ====================
+
 // FREE FUNCTIONS
 template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
 typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_iterator
 facets_begin(facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds)
+ // Returns a facet iterator to the beginning of the container member of 'hds'. The value type
+ // of the facet iterator is a facet descriptor.
 {
     typedef typename facet_gen<FacetS,
                                HalfedgeDescriptor,
@@ -313,6 +325,8 @@
 template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
 typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_iterator
 facets_end(facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds)
+ // Returns a facet iterator to the end of the container member of 'hds'. The value type
+ // of the facet iterator is a facet descriptor.
 {
     typedef typename facet_gen<FacetS,
                                HalfedgeDescriptor,
@@ -323,21 +337,60 @@
 template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
 typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::size_type
 num_facets(facet_gen<FacetS, HalfedgeDescriptor, FacetBase> const& hds)
+ // Returns the number of facets in the 'hds'. Return type is the size type specific to
+ // the container used, specified in container selectors.
 {
     return hds.m_container.size();
 }
 
+ // =======================
+ // FacetHDS Concept
+ // =======================
+
 template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
 HalfedgeDescriptor
-halfedge(typename facet_gen<FacetS,
- HalfedgeDescriptor,
- FacetBase>::facet_descriptor const& f,
- facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds)
+halfedge(typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_descriptor const& f,
+ facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds)
+ // Returns a halfedge descriptor to one of the halfedges around this facet in the 'hds'.
 {
     return facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::ContainerGen
                                        ::value(f, hds.m_container).m_facetLink;
 }
 
+template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
+typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_descriptor
+facet(HalfedgeDescriptor h, facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds)
+ // Returns a facet descriptor to the facet left of the halfedge given by the descriptor 'h' in the 'hds'.
+{
+ return facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::ContainerGen
+ ::value(h, hds.m_container).m_facet;
+}
+
+ // =======================
+ // MutableFacetHDS Concept
+ // =======================
+
+template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
+void
+set_facet(HalfedgeDescriptor h, typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_descriptor f,
+ facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds)
+ // Sets the facet specified by 'f' as the facet on the left for halfedge specified by 'h' in the 'hds'.
+{
+ facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::ContainerGen::value(h, hds.m_container).m_facet = f;
+}
+
+template <typename FacetS, typename HalfedgeDescriptor, typename FacetBase>
+typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_descriptor
+new_facet(facet_gen<FacetS, HalfedgeDescriptor, FacetBase>& hds)
+ // Create a new facet, add it to the 'hds' and return the descriptor of this new facet.
+{
+ typedef typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::ContainerGen ContainerGen;
+ typedef typename facet_gen<FacetS, HalfedgeDescriptor, FacetBase>::facet_type facet_type;
+
+ facet_type facet_f;
+ return *ContainerGen::container_add(facet_f, hds.m_container);
+}
+
 } // 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-28 00:40:35 EDT (Sat, 28 Jul 2007)
@@ -71,6 +71,10 @@
     FacetGen facetGen;
     facetGen.m_container = temp_con;
     BOOST_CHECK(( num_facets(facetGen) == 4 ));
+
+ facet_descriptor fn = new_facet(facetGen);
+ (void) fn;
+ BOOST_CHECK(( num_facets(facetGen) == 5 ));
     return true;
 }
 
@@ -103,6 +107,12 @@
 
     BOOST_CHECK(( halfedge(*facets_begin(facetGen), facetGen) == 1 ));
     BOOST_CHECK(( halfedge(*--facets_end(facetGen), facetGen) == 4 ));
+
+ facet_descriptor fn = new_facet(facetGen);
+ (void) fn;
+ BOOST_CHECK(( num_facets(facetGen) == 5 ));
+
+
     return true;
 }
 
@@ -131,6 +141,9 @@
     BOOST_CHECK(( facets_begin(facetGen)->base() == 1 ));
     BOOST_CHECK(( (--facets_end(facetGen))->base() == 4 ));
 
+ facet_descriptor fn = new_facet(facetGen);
+ (void) fn;
+ BOOST_CHECK(( num_facets(facetGen) == 5 ));
 
     return true;
 }
@@ -166,6 +179,9 @@
     BOOST_CHECK(( facets_begin(facetGen)->base() == 1 ));
     BOOST_CHECK(( (--facets_end(facetGen))->base() == 4 ));
 
+ facet_descriptor fn = new_facet(facetGen);
+ (void) fn;
+ BOOST_CHECK(( num_facets(facetGen) == 5 ));
     return true;
 }
 

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-28 00:40:35 EDT (Sat, 28 Jul 2007)
@@ -273,6 +273,8 @@
     Base m_base;
 
     //CREATORS
+ stored_vertex() {}
+
     stored_vertex(Base const& base, HalfedgeDescriptor vertexLink)
     : m_vertexLink(vertexLink)
     , m_base(base){}
@@ -295,6 +297,8 @@
     Base m_base;
 
     // CREATORS
+ stored_vertex() {}
+
     stored_vertex(Base const& base, HalfedgeDescriptor = 0)
     : m_base(base) {}
 
@@ -315,6 +319,8 @@
     HalfedgeDescriptor m_vertexLink;
 
     // CREATORS
+ stored_vertex() {}
+
     stored_vertex(HalfedgeDescriptor vertexLink)
     : m_vertexLink(vertexLink) {}
 };
@@ -380,11 +386,18 @@
         // The actual container for the vertices from which vertices can be
         // obtained.
 };
+
+ // =====================
+ // VertexListHDS Concept
+ // =====================
 
 // FREE FUNCTIONS
 template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
 typename vertex_gen<VertexS, HalfedgeDescriptor,VertexBase>::vertex_iterator
-vertices_begin(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds) {
+vertices_begin(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds)
+ // Returns a vertex iterator to the beginning of the container member of 'hds'. The value type
+ // of the vertex iterator is a vertex descriptor.
+{
     typedef typename vertex_gen<VertexS, HalfedgeDescriptor,
                                         VertexBase>::ContainerGen ContainerGen;
     return ContainerGen::container_begin(hds.m_container);
@@ -392,7 +405,10 @@
 
 template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
 typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::vertex_iterator
-vertices_end(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds) {
+vertices_end(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds)
+ // Returns a vertex iterator to the end of the container member of 'hds'. The value type
+ // of the vertex iterator is a vertex descriptor.
+{
     typedef typename vertex_gen<VertexS, HalfedgeDescriptor,
                                         VertexBase>::ContainerGen ContainerGen;
     return ContainerGen::container_end(hds.m_container);
@@ -400,19 +416,98 @@
 
 template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
 typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::size_type
-num_vertices(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds) {
+num_vertices(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds)
+ // Returns the number of vertexs in the 'hds'. Return type is the size type specific to
+ // the container used, specified in container selectors.
+{
     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>& hds) {
- return vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>
- ::ContainerGen::value(v, hds.m_container).m_vertexLink;
+halfedge(typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::vertex_descriptor const& v,
+ vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds)
+ // Returns a halfedge descriptor to one of the halfedges around this vertex in the 'hds'.
+{
+ return vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::ContainerGen
+ ::value(v, hds.m_container).m_vertexLink;
+}
+
+ // =======================
+ // VertexHDS Concept
+ // =======================
+
+template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
+typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::vertex_descriptor
+source(HalfedgeDescriptor h, vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds)
+ // Returns a vertex descriptor to the source vertex of the halfedge given by the descriptor 'h' in the 'hds'.
+{
+ return vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::ContainerGen
+ ::value(h, hds.m_container).m_source;
+}
+
+template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
+typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::vertex_descriptor
+target(HalfedgeDescriptor h, vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds)
+ // Returns a vertex descriptor to the target vertex of the halfedge given by the descriptor 'h' in the 'hds'.
+{
+ return vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::ContainerGen
+ ::value(h, hds.m_container).m_target;
 }
+
+ // ========================
+ // MutableVertexHDS Concept
+ // ========================
+
+namespace detail {
+
+template <typename HalfedgeDescriptor, typename VertexDescriptor, typename VertexGen, bool IsSource>
+struct set_vertex_helper
+ // Helper function for setting the vertex 'v' as the source vertex for halfedge 'h' in 'hds'.
+{
+ static void
+ set_vertex(HalfedgeDescriptor h, VertexDescriptor v, VertexGen& hds)
+ {
+ VertexGen::ContainerGen::value(h, hds.m_container).m_source = v;
+ }
+};
+
+template <typename HalfedgeDescriptor, typename VertexDescriptor, typename VertexGen>
+struct set_vertex_helper<HalfedgeDescriptor, VertexDescriptor, VertexGen, false>
+ // Helper function for setting the vertex 'v' as the target vertex for halfedge 'h' in 'hds'.
+{
+ static void
+ set_vertex(HalfedgeDescriptor h, VertexDescriptor v, VertexGen& hds)
+ {
+ VertexGen::ContainerGen::value(h, hds.m_container).m_target = v;
+ }
+};
+
+} // end namespace detail
 
+template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
+void
+set_vertex(HalfedgeDescriptor h, typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::vertex_descriptor v,
+ vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds)
+ // Sets the vertex specified by 'v' as the source or target vertex of the halfedge specified by 'h' in the 'hds'.
+ // The selection is based on the VertexS::is_source selector.
+{
+ typedef vertex_gen<VertexS, HalfedgeDescriptor, VertexBase> VertexGen;
+ typedef typename VertexGen::vertex_descriptor vertex_descriptor;
+ detail::set_vertex_helper<HalfedgeDescriptor, vertex_descriptor, VertexGen, VertexS::is_source>::set_vertex(h,v,hds);
+}
+
+template <typename VertexS, typename HalfedgeDescriptor, typename VertexBase>
+typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::vertex_descriptor
+new_vertex(vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>& hds)
+ // Create a new vertex, add it to the 'hds' and return the descriptor of this new vertex.
+{
+ typedef typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::ContainerGen ContainerGen;
+ typedef typename vertex_gen<VertexS, HalfedgeDescriptor, VertexBase>::vertex_type vertex_type;
+
+ vertex_type vertex_f;
+ return *ContainerGen::container_add(vertex_f, hds.m_container);
+}
 
 } // namespace hdstl
 } // namespace boost

Modified: sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.t.cpp
==============================================================================
--- sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.t.cpp (original)
+++ sandbox/SOC/2007/geometry/libs/hdstl/dev/halfedge_ds/vertex_selectors.t.cpp 2007-07-28 00:40:35 EDT (Sat, 28 Jul 2007)
@@ -81,6 +81,10 @@
     VertexGen vertexGen;
     vertexGen.m_container = temp_con;
     BOOST_CHECK(( num_vertices(vertexGen) == 4 ));
+
+ vertex_descriptor vn = new_vertex(vertexGen);
+ (void) vn;
+ BOOST_CHECK(( num_vertices(vertexGen) == 5 ));
     return true;
 }
 
@@ -113,6 +117,11 @@
 
     BOOST_CHECK(( halfedge(*vertices_begin(vertexGen), vertexGen) == 1 ));
     BOOST_CHECK(( halfedge(*(--vertices_end(vertexGen)), vertexGen) == 4 ));
+
+ vertex_descriptor vn = new_vertex(vertexGen);
+ (void) vn;
+ BOOST_CHECK(( num_vertices(vertexGen) == 5 ));
+
     return true;
 }
 
@@ -142,6 +151,10 @@
     BOOST_CHECK(( vertices_begin(vertexGen)->base() == 1 ));
     BOOST_CHECK(( (--vertices_end(vertexGen))->base() == 4 ));
 
+
+ vertex_descriptor vn = new_vertex(vertexGen);
+ (void) vn;
+ BOOST_CHECK(( num_vertices(vertexGen) == 5 ));
 
     return true;
 }
@@ -177,6 +190,10 @@
     BOOST_CHECK(( vertices_begin(vertexGen)->base() == 1 ));
     BOOST_CHECK(( (--vertices_end(vertexGen))->base() == 4 ));
 
+
+ vertex_descriptor vn = new_vertex(vertexGen);
+ (void) vn;
+ BOOST_CHECK(( num_vertices(vertexGen) == 5 ));
     return true;
 }
 


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