diff --git a/.gitattributes b/.gitattributes index e2ce293612a..1ba077abf5f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -393,6 +393,7 @@ BGL/doc_tex/BGL_ref/HalfedgeDS_halfedge_max_base_with_id.tex -text BGL/doc_tex/BGL_ref/HalfedgeDS_vertex_max_base_with_id.tex -text BGL/doc_tex/BGL_ref/HalfedgeGraph.tex -text BGL/doc_tex/BGL_ref/Polyhedron_edge_is_border_map.tex -text +BGL/doc_tex/BGL_ref/Polyhedron_items_with_id_3.tex -text BGL/doc_tex/BGL_ref/Polyhedron_vertex_is_border_map.tex -text BGL/doc_tex/BGL_ref/Polyhedron_vertex_point_const_map.tex -text BGL/doc_tex/BGL_ref/Polyhedron_vertex_point_map.tex -text @@ -403,6 +404,7 @@ BGL/doc_tex/BGL_ref/graph_traits_Polyhedron_3.tex -text BGL/doc_tex/BGL_ref/halfedge_graph_traits_Polyhedron_3.tex -text BGL/doc_tex/BGL_ref/intro.tex -text BGL/doc_tex/BGL_ref/main.tex -text +BGL/examples/BGL/Polyhedron_3/kruskal_with_stored_id.cpp -text BGL/include/CGAL/boost/graph/BGL_properties.h -text BGL/include/CGAL/boost/graph/Embedded_graph_traits.h -text BGL/include/CGAL/boost/graph/HalfedgeDS_graph_traits_aux.h -text diff --git a/BGL/doc_tex/BGL_ref/HalfedgeDS_face_max_base_with_id.tex b/BGL/doc_tex/BGL_ref/HalfedgeDS_face_max_base_with_id.tex index 09592379e6a..2f3a2c70a61 100644 --- a/BGL/doc_tex/BGL_ref/HalfedgeDS_face_max_base_with_id.tex +++ b/BGL/doc_tex/BGL_ref/HalfedgeDS_face_max_base_with_id.tex @@ -26,6 +26,7 @@ It can be used for deriving own faces. Note that the user is in charge to set the index correctly before running a graph algorithm. + \ccInclude{CGAL/HalfedgeDS_face_max_base_with_id.h} \ccIsModel @@ -41,7 +42,7 @@ running a graph algorithm. {Returns the index.} \ccGlue \ccMethod{int& id();} -{Returns a reference to the index stored in the vertex.} +{Returns a reference to the index stored in the face.} \ccSeeAlso @@ -51,7 +52,10 @@ running a graph algorithm. \ccRefIdfierPage{CGAL::HalfedgeDS_min_items}\\ \ccRefIdfierPage{CGAL::HalfedgeDS_vertex_min_base}\\ \ccRefIdfierPage{CGAL::HalfedgeDS_halfedge_min_base}\\ -\ccRefIdfierPage{CGAL::HalfedgeDS_face_base} +\ccRefIdfierPage{CGAL::HalfedgeDS_face_base}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_vertex_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_halfedge_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::Polyhedron_items_with_id_3}\\ \end{ccRefClass} diff --git a/BGL/doc_tex/BGL_ref/HalfedgeDS_halfedge_max_base_with_id.tex b/BGL/doc_tex/BGL_ref/HalfedgeDS_halfedge_max_base_with_id.tex index f0cc18f6b02..465ef4ba2b5 100644 --- a/BGL/doc_tex/BGL_ref/HalfedgeDS_halfedge_max_base_with_id.tex +++ b/BGL/doc_tex/BGL_ref/HalfedgeDS_halfedge_max_base_with_id.tex @@ -28,6 +28,7 @@ It can be used for deriving own halfedges. Note that the user is in charge to set the index correctly before running a graph algorithm. + \ccInclude{CGAL/HalfedgeDS_halfedge_max_base_with_id.h} \ccIsModel @@ -43,7 +44,7 @@ running a graph algorithm. {Returns the index.} \ccGlue \ccMethod{int& id();} -{Returns a reference to the index stored in the vertex.} +{Returns a reference to the index stored in the halfedge.} \ccSeeAlso @@ -53,7 +54,10 @@ running a graph algorithm. \ccRefIdfierPage{CGAL::HalfedgeDS_min_items}\\ \ccRefIdfierPage{CGAL::HalfedgeDS_vertex_min_base}\\ \ccRefIdfierPage{CGAL::HalfedgeDS_face_min_base}\\ -\ccRefIdfierPage{CGAL::HalfedgeDS_halfedge_base} +\ccRefIdfierPage{CGAL::HalfedgeDS_halfedge_base}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_vertex_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_face_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::Polyhedron_items_with_id_3}\\ \end{ccRefClass} diff --git a/BGL/doc_tex/BGL_ref/HalfedgeDS_vertex_max_base_with_id.tex b/BGL/doc_tex/BGL_ref/HalfedgeDS_vertex_max_base_with_id.tex index 68aedf0bab1..dc0db68f25e 100644 --- a/BGL/doc_tex/BGL_ref/HalfedgeDS_vertex_max_base_with_id.tex +++ b/BGL/doc_tex/BGL_ref/HalfedgeDS_vertex_max_base_with_id.tex @@ -25,6 +25,7 @@ It can be used for deriving own vertices. Note that the user is in charge to set the index correctly before running a graph algorithm. + \ccInclude{CGAL/HalfedgeDS_vertex_max_base_with_id.h} \ccIsModel @@ -53,7 +54,10 @@ running a graph algorithm. \ccRefIdfierPage{CGAL::HalfedgeDS_min_items}\\ \ccRefIdfierPage{CGAL::HalfedgeDS_halfedge_min_base}\\ \ccRefIdfierPage{CGAL::HalfedgeDS_face_min_base}\\ -\ccRefIdfierPage{CGAL::HalfedgeDS_vertex_base} +\ccRefIdfierPage{CGAL::HalfedgeDS_vertex_base}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_halfedge_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_face_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::Polyhedron_items_with_id_3}\\ \end{ccRefClass} diff --git a/BGL/doc_tex/BGL_ref/Polyhedron_items_with_id_3.tex b/BGL/doc_tex/BGL_ref/Polyhedron_items_with_id_3.tex new file mode 100644 index 00000000000..285f18ed31d --- /dev/null +++ b/BGL/doc_tex/BGL_ref/Polyhedron_items_with_id_3.tex @@ -0,0 +1,99 @@ +% +------------------------------------------------------------------------+ +% | Reference manual page: Polyhedron_items_with_id_3.tex +% +------------------------------------------------------------------------+ +% | 17.03.1999 Lutz Kettner +% | Package: Polyhedron +% | +% +------------------------------------------------------------------------+ + +\ccRefPageBegin + +%%RefPage: end of header, begin of main body +% +------------------------------------------------------------------------+ + + +\begin{ccRefClass}{Polyhedron_items_with_id_3} + +\ccDefinition + +The class \ccRefName\ is a model of the \ccc{PolyhedronItems_3} +concept. It provides definitions for vertices with points, halfedges, +and faces with plane equations, all of them with an additional integer +field which can be used to index the items in a {\sc Bgl} algorithm. +The polyhedron traits class must provide the respective types for +the point and the plane equation. +Vertices and facets both contain a halfedge handle to an incident +halfedge. + +\ccInclude{CGAL/Polyhedron_items_with_id_3.h} + +\ccIsModel + +\ccRefIdfierPage{PolyhedronItems_3} + +\ccHeading{Types in + \ccc{Polyhedron_items_with_id_3::Vertex_wrapper::Vertex}} +\ccThree{CGAL::Polyhedron_items_with_id_3}{items;;;;}{} +\ccThreeToTwo +%%\ccTwo{CGAL::Polyhedron_items_with_id_3 items;;;}{} + +\ccTypedef{typedef Traits::Point_3 Point;}{} +\ccGlue +\ccTypedef{typedef CGAL::Tag_true Supports_vertex_point;}{} + + +\ccHeading{Types in \ccc{Polyhedron_items_with_id_3::Face_wrapper::Face}} + +\ccTypedef{typedef Traits::Plane_3 Plane;}{} +\ccGlue +\ccTypedef{typedef CGAL::Tag_true Supports_face_plane;}{} +% No longer required. +%\ccGlue +%\ccTypedef{typedef Traits::Normal Normal;}{} +%\ccGlue +%\ccTypedef{typedef CGAL::Tag_true Supports_face_normal;}{} + +\ccHeading{Additional methods in all three items.} + +\ccMethod{int id() const;} +{Returns the index.} +\ccGlue +\ccMethod{int& id();} +{Returns a reference to the index stored in the item.} + +\ccCreation +\ccCreationVariable{items} %% choose variable name + +\ccConstructor{Polyhedron_items_with_id_3();}{default constructor.} + +\ccOperations + +Supported as required by the \ccc{PolyhedronItems_3} concept. + +\ccSeeAlso + +\ccRefIdfierPage{CGAL::Polyhedron_3}\\ +\ccRefIdfierPage{CGAL::Polyhedron_min_items_3}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_min_items}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_items_2}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_vertex_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_halfedge_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_face_max_base_with_id}\\ + +\ccExample + +The following example program shows a call to the {\sc Bgl} +Kruskal's minimun spanning tree algorithm accesing the id() +field stored in a Polyhedron vertex.\\ +The main function illustrates the access to the id() field. + +\ccIncludeExampleCode{BGL/Polyhedron_3/kruskal_with_stored_id.cpp} + +\end{ccRefClass} + +% +------------------------------------------------------------------------+ +%%RefPage: end of main body, begin of footer +\ccRefPageEnd +% EOF +% +------------------------------------------------------------------------+ + diff --git a/BGL/doc_tex/BGL_ref/Triangulation_vertex_base_with_id_2.tex b/BGL/doc_tex/BGL_ref/Triangulation_vertex_base_with_id_2.tex index e04f367b352..d5992e6c00b 100644 --- a/BGL/doc_tex/BGL_ref/Triangulation_vertex_base_with_id_2.tex +++ b/BGL/doc_tex/BGL_ref/Triangulation_vertex_base_with_id_2.tex @@ -4,8 +4,6 @@ % | 10.12.2005 Andreas Fabri % | Package: boost % | -\RCSdef{\RCSTriangulationvertexbaseRev}{$Revision$} -\RCSdefDate{\RCSTriangulationvertexbaseDate}{$Date$} % | %%RefPage: end of header, begin of main body % +------------------------------------------------------------------------+ diff --git a/BGL/doc_tex/BGL_ref/intro.tex b/BGL/doc_tex/BGL_ref/intro.tex index de0224e45fc..2b13fcf7018 100644 --- a/BGL/doc_tex/BGL_ref/intro.tex +++ b/BGL/doc_tex/BGL_ref/intro.tex @@ -37,10 +37,11 @@ with the algorithms of the {\sc Bgl}, as well as a new graph concept. \ccRefIdfierPage{boost::graph_traits< CGAL::Polyhedron_3 > }\\ \ccRefIdfierPage{CGAL::halfedge_graph_traits< CGAL::Polyhedron_3 > }\\ \ccRefIdfierPage{boost::graph_traits< CGAL::Triangulation_2 >}\\ -\ccRefIdfierPage{CGAL::Triangulation_vertex_base_with_id_2} -\ccRefIdfierPage{CGAL::HalfedgeDS_vertex_max_base_with_id} -\ccRefIdfierPage{CGAL::HalfedgeDS_halfedge_max_base_with_id} -\ccRefIdfierPage{CGAL::HalfedgeDS_face_max_base_with_id} +\ccRefIdfierPage{CGAL::Triangulation_vertex_base_with_id_2}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_vertex_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_halfedge_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::HalfedgeDS_face_max_base_with_id}\\ +\ccRefIdfierPage{CGAL::Polyhedron_items_with_id_3} % +------------------------------------------------------------------------+ diff --git a/BGL/doc_tex/BGL_ref/main.tex b/BGL/doc_tex/BGL_ref/main.tex index ac9a5c9ea41..e07d7461388 100644 --- a/BGL/doc_tex/BGL_ref/main.tex +++ b/BGL/doc_tex/BGL_ref/main.tex @@ -10,6 +10,7 @@ \input{BGL_ref/HalfedgeDS_halfedge_max_base_with_id.tex} \input{BGL_ref/HalfedgeDS_face_max_base_with_id.tex} \input{BGL_ref/HalfedgeDS_vertex_max_base_with_id.tex} +\input{BGL_ref/Polyhedron_items_with_id_3.tex} \input{BGL_ref/Edge_index_t_enum.tex} \input{BGL_ref/Edge_is_border_t_enum.tex} \input{BGL_ref/Vertex_is_border_t_enum.tex} diff --git a/BGL/examples/BGL/Polyhedron_3/kruskal_with_stored_id.cpp b/BGL/examples/BGL/Polyhedron_3/kruskal_with_stored_id.cpp new file mode 100644 index 00000000000..41a6d40583e --- /dev/null +++ b/BGL/examples/BGL/Polyhedron_3/kruskal_with_stored_id.cpp @@ -0,0 +1,86 @@ +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + + +typedef CGAL::Cartesian Kernel; +typedef Kernel::Vector_3 Vector; +typedef Kernel::Point_3 Point; +typedef CGAL::Polyhedron_3 Polyhedron; + +typedef boost::graph_traits::vertex_descriptor vertex_descriptor; +typedef boost::graph_traits::vertex_iterator vertex_iterator; +typedef boost::graph_traits::edge_descriptor edge_descriptor; + + +void +kruskal(const Polyhedron& P) +{ + // associate indices to the vertices using the "id()" field of the vertex. + { + vertex_iterator vb, ve; + int index = 0; + + // boost::tie assigns the first and second element of the std::pair + // returned by boost::vertices to the variables vit and ve + for(boost::tie(vb,ve)=boost::vertices(P); vb!=ve; ++vb ){ + vertex_descriptor vd = *vb; + vd->id() = index++; + } + } + + // We use the default edge weight which is the squared length of the edge + // This property map is defined in graph_traits_Polyhedron_3.h + + // This function call requires a vertex_index_map named parameter which + // when ommitted defaults to "get(vertex_index,graph)". + // That default works here because the vertex type supports the "id()" + // field which is used by the vertex_index internal property. + std::list mst; + boost::kruskal_minimum_spanning_tree(P,std::back_inserter(mst)); + + vertex_iterator vb, ve; + + std::cout << "#VRML V2.0 utf8\n" + "Shape {\n" + "appearance Appearance {\n" + "material Material { emissiveColor 1 0 0}}\n" + "geometry\n" + "IndexedLineSet {\n" + "coord Coordinate {\n" + "point [ \n"; + + for(boost::tie(vb,ve) = boost::vertices(P); vb!=ve; ++vb){ + std::cout << (*vb)->point() << "\n"; + } + + std::cout << "]\n" + "}\n" + "coordIndex [\n"; + + for(std::list::iterator it = mst.begin(); it != mst.end(); ++it){ + std::cout << vertex_id_map[boost::source(*it,P)] + << ", " << boost::target(*it,P)->id() << ", -1\n"; + } + + std::cout << "]\n" + "}#IndexedLineSet\n" + "}# Shape\n"; +} + + +int main() { + Polyhedron P; + std::cin >> P; + + kruskal(P); + return 0; +}