diff --git a/Packages/Interval_skip_list/changes.txt b/Packages/Interval_skip_list/changes.txt new file mode 100644 index 00000000000..8f6cfa5dd3d --- /dev/null +++ b/Packages/Interval_skip_list/changes.txt @@ -0,0 +1,2 @@ +- Added a destructor for Interval_skip_list as the constructor calls new +- Added function clear() \ No newline at end of file diff --git a/Packages/Interval_skip_list/doc_tex/Interval_skip_list/main.tex b/Packages/Interval_skip_list/doc_tex/Interval_skip_list/main.tex new file mode 100644 index 00000000000..3f6850656cf --- /dev/null +++ b/Packages/Interval_skip_list/doc_tex/Interval_skip_list/main.tex @@ -0,0 +1,60 @@ + +\RCSdef{\IntervalskiplistRev}{$Revision$} +\RCSdefDate{\IntervalskiplistDate}{$Date$} +% +------------------------------------------------------------------------+ + +\ccParDims + +\chapter{Interval Skiplist} +\label{chapter_Interval_skip_list} +\ccChapterRelease{\IntervalskiplistRev. \ \IntervalskiplistDate}\\ +\ccChapterAuthor{Andreas Fabri} + + + + +% +========================================================================+ +\section{Definition} +% +========================================================================+ + +An interval skiplist is a data strucure for finding all intervals +that overlap a point. The implementation we provide is dynamic, that +is the user can insert and remove intervals. + +% +========================================================================+ +\section{Example Programs} +% +========================================================================+ +\label{sectionIntervalskiplistExamples} + +We give two examples. The first one uses a basic interval class. +The second one stores face handles to faces of a Delaunay +triangulation of 3D points representing a terrain model. + +% +-------------------------------------------------------------+ +\subsection{First Example with Simple Interval} + +The first example reads two numbers \ccc{n} and \ccc{d} from \ccc{std::cin}. +It creates n intervals of length \ccc{d} with the left endpoint at \ccc{n}. +It then reads out the intervals for at the 1-dimensional point with +coordinate $0 ... n+d$. + +\ccIncludeExampleCode{../../examples/Interval_skip_list/intervals.C} + +% +-------------------------------------------------------------+ +\subsection{Example with Faces of a Triangulated Terrain} + +This example creates an interval skiplist for the faces of a terrains. +We read the points from a file, and we write all faces to \ccc{std::cout} +that intersect the plane parallel to the \ccc{xy}-plane and with \ccc{z} +coordinate 50. + +\ccIncludeExampleCode{../../examples/Interval_skip_list/terrain.C} + + +% +--------------------------------------------------------+ + +\input{Interval_skip_list_ref/main} + +% EOF + + diff --git a/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Face_interval.tex b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Face_interval.tex new file mode 100644 index 00000000000..89161fd600d --- /dev/null +++ b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Face_interval.tex @@ -0,0 +1,96 @@ +% ====================================================================== +% +% Copyright (c) 2003 GeometryFactory +% +% This software and related documentation is part of the +% Computational Geometry Algorithms Library (CGAL). +% +% Every use of CGAL requires a license. Licenses come in three kinds: +% +% - For academic research and teaching purposes, permission to use and +% copy the software and its documentation is hereby granted free of +% charge, provided that +% (1) it is not a component of a commercial product, and +% (2) this notice appears in all copies of the software and +% related documentation. +% - Development licenses grant access to the source code of the library +% to develop programs. These programs may be sold to other parties as +% executable code. To obtain a development license, please contact +% the GALIA Consortium (at cgal@cs.uu.nl). +% - Commercialization licenses grant access to the source code and the +% right to sell development licenses. To obtain a commercialization +% license, please contact the GALIA Consortium (at cgal@cs.uu.nl). +% +% This software and documentation is provided "as-is" and without +% warranty of any kind. In no event shall the CGAL Consortium be +% liable for any damage of any kind. +% +% The GALIA Consortium consists of Utrecht University (The Netherlands), +% ETH Zurich (Switzerland), Free University of Berlin (Germany), +% INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg +% (Germany), Max-Planck-Institute Saarbrucken (Germany), +% and Tel-Aviv University (Israel). +% +% ---------------------------------------------------------------------- +% +% package : Interval_skip_list +% author(s) : Andreas Fabri +% +% coordinator : GeometryFactory () +% +% ====================================================================== + +\RCSdef{\FaceIntervalRevision}{$Revision$} +\RCSdefDate{\FaceIntervalDate}{$Date$} + +%---------------------------------------------------------------------- + +\begin{ccRefClass} {Face_interval} + +\ccDefinition + +The class \ccClassTemplateName\ represents intervals for the minimum and +maximum value of the \ccc{z}-coordinate of a face of a triangulation. + +{\it Remark: Here we will exploit that the face type knows the vertex type, +who knows the point type, who is known by the kernel traits who knows the FT, +which will become the type Value.} + +\ccInclude{CGAL/Face_interval.h} + +\ccTypes +\ccSetThreeColumns{Oriented_side}{}{\hspace*{10cm}} +\ccThreeToTwo + + + +\ccCreation +\ccCreationVariable{i} + +\ccConstructor{Face_interval();} +{Default constructor.} + +\ccConstructor{Face_interval(FaceHandle fh);} +{Constructs the interval with smallest and largest \ccc{z} coordinate of the points +stored in the vertices of the face..} + +\ccOperations + +\ccMethod{Value inf() const;} +{returns the infimum.} + +\ccMethod{Value sup() const;} +{returns the supremum.} + +\ccMethod{FaceHandle face_handle();} +{returns the face handle.} + +\ccHeading{I/O} + +\ccFunction{ostream& operator<<(ostream& os, + const Face_interval& i);} +{Inserts the interval \ccc{i} into the stream \ccc{os}. +\ccPrecond The output operator for \ccc{*Face_handle} is defined.} + +\end{ccRefClass} + diff --git a/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval.tex b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval.tex new file mode 100644 index 00000000000..de9b0eb7bf5 --- /dev/null +++ b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval.tex @@ -0,0 +1,71 @@ +% +------------------------------------------------------------------------+ +% | Reference manual page: Interval.tex +% +------------------------------------------------------------------------+ +% | 11.04.2000 Author +% | Package: Package +% | +\RCSdef{\RCSIntervalRev}{$Revision$} +\RCSdefDate{\RCSIntervalDate}{$Date$} +% | +%%RefPage: end of header, begin of main body +% +------------------------------------------------------------------------+ + + +\begin{ccRefConcept}{Interval} + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[concept]{} %% add further index entries + +\ccDefinition + +The concept \ccRefName\ describes the requirements for the +interval class of a \ccc{Interval_skip_list}. + + + +\ccCreation +\ccCreationVariable{in} %% choose variable name + +\ccConstructor{Interval();}{default constructor.} +\ccTypes + +\ccNestedType{Value}{The type of infimum and supremum of the interval.} + + +\ccAccessFunctions +\ccMethod{Value inf() const;} +{returns the infimum.} +\ccGlue +\ccMethod{Value sup() const;}{returns the supremum.} + + +\ccMethod{bool contains(const Value& v) const;} +{returns \ccc{true}, iff \ccc{in} contains \ccc{v}.} + +\ccMethod{bool contains_interval(const Value& i, const Value& s) const;} +{returns \ccc{true}, iff \ccc{in} contains \ccc{(i,s)}.} + +\ccMethod{bool operator==(const Interval& I) const;} +{Equality test.} + +\ccMethod{bool operator!=(const Interval& I) const;} +{Unequality test.} + +\ccHasModels + +\ccc{CGAL::Interval_skip_list_interval}\\ +\ccc{CGAL::Face_interval} + + +\ccSeeAlso + +\ccc{Interval_skip_list} + + +\end{ccRefConcept} + +% +------------------------------------------------------------------------+ +%%RefPage: end of main body, begin of footer +% EOF +% +------------------------------------------------------------------------+ + diff --git a/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval_skip_list.tex b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval_skip_list.tex index 088af273621..7165566e0ad 100644 --- a/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval_skip_list.tex +++ b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval_skip_list.tex @@ -49,17 +49,19 @@ \ccDefinition -The class \ccClassTemplateName\ represents . +The class \ccClassTemplateName\ is a dynamic datastructure that implements a +1-dimensional segment tree, that is it allows to find all members of a set of +intervals that overlap a point. +\ccInclude{CGAL/Interval_skip_list.h} \ccTypes -\ccSetThreeColumns{Oriented_side}{}{\hspace*{10cm}} +\ccSetThreeColumns{typedef Interval::Value }{}{\hspace*{10cm}} \ccThreeToTwo \ccTypedef{typedef Interval::Value Value;}{the type of inf and sup of the interval.} -\ccNestedType{const_iterator}{An iterator that allows to enumerate all intervals in the -interval skip list.} +\ccNestedType{const_iterator}{An iterator over all intervals.} @@ -85,7 +87,7 @@ interval skip list.} InputIterator first, InputIterator last);} {Inserts the iterator range \ccc{[first, last)} in the interval skip list, and returns -the number of inserted intervals.\\ +the number of inserted intervals. \ccPrecond The \ccc{value_type} of \ccc{first} and \ccc{last} is \ccc{Interval}.} @@ -102,18 +104,19 @@ the number of inserted intervals.\\ int find_intervals( const Value& v, OutputIterator out);} -{Writes the intervals \ccc{i} with \ccc{i.inf()} $<=$ \ccc{v} $<=$ \ccc{i.sup} in \ccc{out}.\\ +{Writes the intervals \ccc{i} with \ccc{i.inf()} $\leq$ \ccc{v} $\leq$ \ccc{i.sup} to the +output iterator \ccc{out}. \ccPrecond The \ccc{value_type} of \ccc{out} is \ccc{Interval}.} \ccMethod{void clear();} -{Clears the structure.} +{Removes all intervals from the interval skip list.} \ccMethod{const_iterator begin() const;} -{Returns the .} +{Returns an iterator over all intervals.} \ccMethod{const_iterator end() const;} {Returns the past the end iterator.} @@ -121,15 +124,19 @@ the number of inserted intervals.\\ \ccHeading{I/O} -The output operator is defined for \ccc{std::ostream} \ccFunction{ostream& operator<<(ostream& os, const Interval_skip_list& isl);} {Inserts the interval skip list \ccc{isl} into the stream \ccc{os}. -\ccPrecond The insert operator must be defined for \ccc{Interval}.} +\ccPrecond The output operator must be defined for \ccc{Interval}.} \ccImplementation -The +The insertion and deletion of a segment in the interval skiplist +takes expected time $O(\log^2 n)$, if the segment endpoints are +chosen from a continuous distribution. A stabbing query takes expected +time $O(\log n)$. + +The implementation is based on the code developed by Eric N.~Hansen. \end{ccRefClass} diff --git a/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval_skip_list_interval.tex b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval_skip_list_interval.tex index 56620962351..cdc37a55521 100644 --- a/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval_skip_list_interval.tex +++ b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/Interval_skip_list_interval.tex @@ -49,10 +49,11 @@ \ccDefinition -The class \ccClassTemplateName\ represents . +The class \ccClassTemplateName\ represents intervals with infimum +and supremum of type \ccc{Value}, and which can be open or closed. +\ccInclude{CGAL/Interval_skip_list_interval.h} -\ccTypes \ccSetThreeColumns{Oriented_side}{}{\hspace*{10cm}} \ccThreeToTwo @@ -64,23 +65,35 @@ The class \ccClassTemplateName\ represents . \ccConstructor{Interval_skip_list_interval();} {Default constructor.} +\ccConstructor{Interval_skip_list_interval(char lb, + const Value& i, + const Value& s, + char rb);} +{Constructs the interval with infimum \ccc{i} and supremum \ccc{s}. +The arguments \ccc{lb} and \ccc{rb} can be \ccc{,} and \ccc{,} respectively.} \ccOperations -\ccMethod{(Value inf() const;} +\ccMethod{Value inf() const;} {returns the infimum.} -\ccMethod{(Value sup() const;} +\ccMethod{Value sup() const;} {returns the supremum.} +\ccMethod{char lbound() const;} +{returns the left bound.} + +\ccMethod{char rbound() const;} +{returns the right bound.} + \ccHeading{I/O} -The output operator is defined for \ccc{std::ostream} +The output operator is defined for \ccc{std::ostream}. \ccFunction{ostream& operator<<(ostream& os, const Interval_skip_list_interval& i);} -{Inserts the interval \ccc{i} into the stream \ccc{os}.} - +{Inserts the interval \ccc{i} into the stream \ccc{os}.\\ +\ccPrecond The output operator for \ccc{Value} is defined.} \end{ccRefClass} diff --git a/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/intro.tex b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/intro.tex index f76decaf4dc..e572b6a9d3e 100644 --- a/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/intro.tex +++ b/Packages/Interval_skip_list/doc_tex/Interval_skip_list_ref/intro.tex @@ -50,8 +50,8 @@ \chapter{Interval Skiplist} -This chapter presents the Interval Skiplist. The description is based on -the articles \cite{}. +This chapter presents the interval skiplist as it is described in +the article \cite{}. \subsection*{Concepts} @@ -62,3 +62,4 @@ the articles \cite{}. \ccRefIdfierPage{CGAL::Interval_skip_list}\\ \ccRefIdfierPage{CGAL::Interval_skip_list_interval}\\ +\ccRefIdfierPage{CGAL::Face_interval}\\ diff --git a/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list/main.tex b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list/main.tex new file mode 100644 index 00000000000..3f6850656cf --- /dev/null +++ b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list/main.tex @@ -0,0 +1,60 @@ + +\RCSdef{\IntervalskiplistRev}{$Revision$} +\RCSdefDate{\IntervalskiplistDate}{$Date$} +% +------------------------------------------------------------------------+ + +\ccParDims + +\chapter{Interval Skiplist} +\label{chapter_Interval_skip_list} +\ccChapterRelease{\IntervalskiplistRev. \ \IntervalskiplistDate}\\ +\ccChapterAuthor{Andreas Fabri} + + + + +% +========================================================================+ +\section{Definition} +% +========================================================================+ + +An interval skiplist is a data strucure for finding all intervals +that overlap a point. The implementation we provide is dynamic, that +is the user can insert and remove intervals. + +% +========================================================================+ +\section{Example Programs} +% +========================================================================+ +\label{sectionIntervalskiplistExamples} + +We give two examples. The first one uses a basic interval class. +The second one stores face handles to faces of a Delaunay +triangulation of 3D points representing a terrain model. + +% +-------------------------------------------------------------+ +\subsection{First Example with Simple Interval} + +The first example reads two numbers \ccc{n} and \ccc{d} from \ccc{std::cin}. +It creates n intervals of length \ccc{d} with the left endpoint at \ccc{n}. +It then reads out the intervals for at the 1-dimensional point with +coordinate $0 ... n+d$. + +\ccIncludeExampleCode{../../examples/Interval_skip_list/intervals.C} + +% +-------------------------------------------------------------+ +\subsection{Example with Faces of a Triangulated Terrain} + +This example creates an interval skiplist for the faces of a terrains. +We read the points from a file, and we write all faces to \ccc{std::cout} +that intersect the plane parallel to the \ccc{xy}-plane and with \ccc{z} +coordinate 50. + +\ccIncludeExampleCode{../../examples/Interval_skip_list/terrain.C} + + +% +--------------------------------------------------------+ + +\input{Interval_skip_list_ref/main} + +% EOF + + diff --git a/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Face_interval.tex b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Face_interval.tex new file mode 100644 index 00000000000..89161fd600d --- /dev/null +++ b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Face_interval.tex @@ -0,0 +1,96 @@ +% ====================================================================== +% +% Copyright (c) 2003 GeometryFactory +% +% This software and related documentation is part of the +% Computational Geometry Algorithms Library (CGAL). +% +% Every use of CGAL requires a license. Licenses come in three kinds: +% +% - For academic research and teaching purposes, permission to use and +% copy the software and its documentation is hereby granted free of +% charge, provided that +% (1) it is not a component of a commercial product, and +% (2) this notice appears in all copies of the software and +% related documentation. +% - Development licenses grant access to the source code of the library +% to develop programs. These programs may be sold to other parties as +% executable code. To obtain a development license, please contact +% the GALIA Consortium (at cgal@cs.uu.nl). +% - Commercialization licenses grant access to the source code and the +% right to sell development licenses. To obtain a commercialization +% license, please contact the GALIA Consortium (at cgal@cs.uu.nl). +% +% This software and documentation is provided "as-is" and without +% warranty of any kind. In no event shall the CGAL Consortium be +% liable for any damage of any kind. +% +% The GALIA Consortium consists of Utrecht University (The Netherlands), +% ETH Zurich (Switzerland), Free University of Berlin (Germany), +% INRIA Sophia-Antipolis (France), Martin-Luther-University Halle-Wittenberg +% (Germany), Max-Planck-Institute Saarbrucken (Germany), +% and Tel-Aviv University (Israel). +% +% ---------------------------------------------------------------------- +% +% package : Interval_skip_list +% author(s) : Andreas Fabri +% +% coordinator : GeometryFactory () +% +% ====================================================================== + +\RCSdef{\FaceIntervalRevision}{$Revision$} +\RCSdefDate{\FaceIntervalDate}{$Date$} + +%---------------------------------------------------------------------- + +\begin{ccRefClass} {Face_interval} + +\ccDefinition + +The class \ccClassTemplateName\ represents intervals for the minimum and +maximum value of the \ccc{z}-coordinate of a face of a triangulation. + +{\it Remark: Here we will exploit that the face type knows the vertex type, +who knows the point type, who is known by the kernel traits who knows the FT, +which will become the type Value.} + +\ccInclude{CGAL/Face_interval.h} + +\ccTypes +\ccSetThreeColumns{Oriented_side}{}{\hspace*{10cm}} +\ccThreeToTwo + + + +\ccCreation +\ccCreationVariable{i} + +\ccConstructor{Face_interval();} +{Default constructor.} + +\ccConstructor{Face_interval(FaceHandle fh);} +{Constructs the interval with smallest and largest \ccc{z} coordinate of the points +stored in the vertices of the face..} + +\ccOperations + +\ccMethod{Value inf() const;} +{returns the infimum.} + +\ccMethod{Value sup() const;} +{returns the supremum.} + +\ccMethod{FaceHandle face_handle();} +{returns the face handle.} + +\ccHeading{I/O} + +\ccFunction{ostream& operator<<(ostream& os, + const Face_interval& i);} +{Inserts the interval \ccc{i} into the stream \ccc{os}. +\ccPrecond The output operator for \ccc{*Face_handle} is defined.} + +\end{ccRefClass} + diff --git a/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval.tex b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval.tex new file mode 100644 index 00000000000..de9b0eb7bf5 --- /dev/null +++ b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval.tex @@ -0,0 +1,71 @@ +% +------------------------------------------------------------------------+ +% | Reference manual page: Interval.tex +% +------------------------------------------------------------------------+ +% | 11.04.2000 Author +% | Package: Package +% | +\RCSdef{\RCSIntervalRev}{$Revision$} +\RCSdefDate{\RCSIntervalDate}{$Date$} +% | +%%RefPage: end of header, begin of main body +% +------------------------------------------------------------------------+ + + +\begin{ccRefConcept}{Interval} + +%% \ccHtmlCrossLink{} %% add further rules for cross referencing links +%% \ccHtmlIndexC[concept]{} %% add further index entries + +\ccDefinition + +The concept \ccRefName\ describes the requirements for the +interval class of a \ccc{Interval_skip_list}. + + + +\ccCreation +\ccCreationVariable{in} %% choose variable name + +\ccConstructor{Interval();}{default constructor.} +\ccTypes + +\ccNestedType{Value}{The type of infimum and supremum of the interval.} + + +\ccAccessFunctions +\ccMethod{Value inf() const;} +{returns the infimum.} +\ccGlue +\ccMethod{Value sup() const;}{returns the supremum.} + + +\ccMethod{bool contains(const Value& v) const;} +{returns \ccc{true}, iff \ccc{in} contains \ccc{v}.} + +\ccMethod{bool contains_interval(const Value& i, const Value& s) const;} +{returns \ccc{true}, iff \ccc{in} contains \ccc{(i,s)}.} + +\ccMethod{bool operator==(const Interval& I) const;} +{Equality test.} + +\ccMethod{bool operator!=(const Interval& I) const;} +{Unequality test.} + +\ccHasModels + +\ccc{CGAL::Interval_skip_list_interval}\\ +\ccc{CGAL::Face_interval} + + +\ccSeeAlso + +\ccc{Interval_skip_list} + + +\end{ccRefConcept} + +% +------------------------------------------------------------------------+ +%%RefPage: end of main body, begin of footer +% EOF +% +------------------------------------------------------------------------+ + diff --git a/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval_skip_list.tex b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval_skip_list.tex index 088af273621..7165566e0ad 100644 --- a/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval_skip_list.tex +++ b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval_skip_list.tex @@ -49,17 +49,19 @@ \ccDefinition -The class \ccClassTemplateName\ represents . +The class \ccClassTemplateName\ is a dynamic datastructure that implements a +1-dimensional segment tree, that is it allows to find all members of a set of +intervals that overlap a point. +\ccInclude{CGAL/Interval_skip_list.h} \ccTypes -\ccSetThreeColumns{Oriented_side}{}{\hspace*{10cm}} +\ccSetThreeColumns{typedef Interval::Value }{}{\hspace*{10cm}} \ccThreeToTwo \ccTypedef{typedef Interval::Value Value;}{the type of inf and sup of the interval.} -\ccNestedType{const_iterator}{An iterator that allows to enumerate all intervals in the -interval skip list.} +\ccNestedType{const_iterator}{An iterator over all intervals.} @@ -85,7 +87,7 @@ interval skip list.} InputIterator first, InputIterator last);} {Inserts the iterator range \ccc{[first, last)} in the interval skip list, and returns -the number of inserted intervals.\\ +the number of inserted intervals. \ccPrecond The \ccc{value_type} of \ccc{first} and \ccc{last} is \ccc{Interval}.} @@ -102,18 +104,19 @@ the number of inserted intervals.\\ int find_intervals( const Value& v, OutputIterator out);} -{Writes the intervals \ccc{i} with \ccc{i.inf()} $<=$ \ccc{v} $<=$ \ccc{i.sup} in \ccc{out}.\\ +{Writes the intervals \ccc{i} with \ccc{i.inf()} $\leq$ \ccc{v} $\leq$ \ccc{i.sup} to the +output iterator \ccc{out}. \ccPrecond The \ccc{value_type} of \ccc{out} is \ccc{Interval}.} \ccMethod{void clear();} -{Clears the structure.} +{Removes all intervals from the interval skip list.} \ccMethod{const_iterator begin() const;} -{Returns the .} +{Returns an iterator over all intervals.} \ccMethod{const_iterator end() const;} {Returns the past the end iterator.} @@ -121,15 +124,19 @@ the number of inserted intervals.\\ \ccHeading{I/O} -The output operator is defined for \ccc{std::ostream} \ccFunction{ostream& operator<<(ostream& os, const Interval_skip_list& isl);} {Inserts the interval skip list \ccc{isl} into the stream \ccc{os}. -\ccPrecond The insert operator must be defined for \ccc{Interval}.} +\ccPrecond The output operator must be defined for \ccc{Interval}.} \ccImplementation -The +The insertion and deletion of a segment in the interval skiplist +takes expected time $O(\log^2 n)$, if the segment endpoints are +chosen from a continuous distribution. A stabbing query takes expected +time $O(\log n)$. + +The implementation is based on the code developed by Eric N.~Hansen. \end{ccRefClass} diff --git a/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval_skip_list_interval.tex b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval_skip_list_interval.tex index 56620962351..cdc37a55521 100644 --- a/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval_skip_list_interval.tex +++ b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/Interval_skip_list_interval.tex @@ -49,10 +49,11 @@ \ccDefinition -The class \ccClassTemplateName\ represents . +The class \ccClassTemplateName\ represents intervals with infimum +and supremum of type \ccc{Value}, and which can be open or closed. +\ccInclude{CGAL/Interval_skip_list_interval.h} -\ccTypes \ccSetThreeColumns{Oriented_side}{}{\hspace*{10cm}} \ccThreeToTwo @@ -64,23 +65,35 @@ The class \ccClassTemplateName\ represents . \ccConstructor{Interval_skip_list_interval();} {Default constructor.} +\ccConstructor{Interval_skip_list_interval(char lb, + const Value& i, + const Value& s, + char rb);} +{Constructs the interval with infimum \ccc{i} and supremum \ccc{s}. +The arguments \ccc{lb} and \ccc{rb} can be \ccc{,} and \ccc{,} respectively.} \ccOperations -\ccMethod{(Value inf() const;} +\ccMethod{Value inf() const;} {returns the infimum.} -\ccMethod{(Value sup() const;} +\ccMethod{Value sup() const;} {returns the supremum.} +\ccMethod{char lbound() const;} +{returns the left bound.} + +\ccMethod{char rbound() const;} +{returns the right bound.} + \ccHeading{I/O} -The output operator is defined for \ccc{std::ostream} +The output operator is defined for \ccc{std::ostream}. \ccFunction{ostream& operator<<(ostream& os, const Interval_skip_list_interval& i);} -{Inserts the interval \ccc{i} into the stream \ccc{os}.} - +{Inserts the interval \ccc{i} into the stream \ccc{os}.\\ +\ccPrecond The output operator for \ccc{Value} is defined.} \end{ccRefClass} diff --git a/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/intro.tex b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/intro.tex index f76decaf4dc..e572b6a9d3e 100644 --- a/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/intro.tex +++ b/Packages/Interval_skip_list/doc_tex/basic/Interval_skip_list_ref/intro.tex @@ -50,8 +50,8 @@ \chapter{Interval Skiplist} -This chapter presents the Interval Skiplist. The description is based on -the articles \cite{}. +This chapter presents the interval skiplist as it is described in +the article \cite{}. \subsection*{Concepts} @@ -62,3 +62,4 @@ the articles \cite{}. \ccRefIdfierPage{CGAL::Interval_skip_list}\\ \ccRefIdfierPage{CGAL::Interval_skip_list_interval}\\ +\ccRefIdfierPage{CGAL::Face_interval}\\ diff --git a/Packages/Interval_skip_list/examples/Interval_skip_list/intervals.C b/Packages/Interval_skip_list/examples/Interval_skip_list/intervals.C new file mode 100644 index 00000000000..dea52a0e5d3 --- /dev/null +++ b/Packages/Interval_skip_list/examples/Interval_skip_list/intervals.C @@ -0,0 +1,39 @@ +#include +#include +#include +#include + +typedef CGAL::Interval_skip_list_interval Interval; +typedef CGAL::Interval_skip_list Interval_skip_list; + +int main() +{ + Interval_skip_list isl; + int i, n, d; + + std::cin >> n >> d; + std::vector intervals(n); + for(i = 0; i < n; i++) { + intervals[i] = Interval('[', i, i+d, ']'); + } + std::random_shuffle(intervals.begin(), intervals.end()); + + isl.insert(intervals.begin(), intervals.end()); + + for(i = 0; i < n+d; i++) { + std::list L; + isl.find_intervals(i, std::back_inserter(L)); + for(std::list::iterator it = L.begin(); it != L.end(); it++){ + std::cout << *it; + } + std::cout << std::endl; + } + + for(i = 0; i < n; i++) { + isl.remove(intervals[i]); + } + return 0; + +} + + diff --git a/Packages/Interval_skip_list/examples/Interval_skip_list/terrain.C b/Packages/Interval_skip_list/examples/Interval_skip_list/terrain.C new file mode 100644 index 00000000000..ae29a53be05 --- /dev/null +++ b/Packages/Interval_skip_list/examples/Interval_skip_list/terrain.C @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include +#include +#include + +typedef CGAL::Simple_cartesian SC; +typedef SC::Point_3 Point_3; +typedef CGAL::Triangulation_euclidean_traits_xy_3 K; +typedef CGAL::Delaunay_triangulation_2 Delaunay; +typedef Delaunay::Face_handle Face_handle; +typedef Delaunay::Finite_faces_iterator Finite_faces_iterator; +typedef CGAL::Face_interval Interval; +typedef CGAL::Interval_skip_list Interval_skip_list; + +int main() +{ + std::ifstream fin("terrain.pts"); // elevation ranges from 0 to 100 + Delaunay dt; + + dt.insert(std::istream_iterator(fin), + std::istream_iterator()); + + Interval_skip_list isl; + for(Finite_faces_iterator fh = dt.finite_faces_begin(); + fh != dt.finite_faces_end(); + ++fh){ + isl.insert(Interval(fh)); + } + std::list level; + isl.find_intervals(50, std::back_inserter(level)); + for(std::list::iterator it = level.begin(); + it != level.end(); + ++it){ + std::cout << dt.triangle(it->face_handle()) << std::endl; + } + return 0; +} diff --git a/Packages/Interval_skip_list/include/CGAL/Face_interval.h b/Packages/Interval_skip_list/include/CGAL/Face_interval.h new file mode 100644 index 00000000000..390dd7dfaa2 --- /dev/null +++ b/Packages/Interval_skip_list/include/CGAL/Face_interval.h @@ -0,0 +1,126 @@ +// ====================================================================== +// +// Copyright (c) 2003 GeometryFactory +// +// This software and related documentation is part of an INTERNAL release +// of the Computational Geometry Algorithms Library (CGAL). It is not +// intended for general use. +// +// ---------------------------------------------------------------------- +// +// release : +// release_date : +// +// file : include/CGAL/Face_interval.h +// package : Interval_skip_list +// revision : $Revision$ +// revision_date : $Date$ +// author(s) : Andreas Fabri +// +// coordinator : GeometryFactory () +// +// ====================================================================== + +#ifndef CGAL_FACE_INTERVAL_H +#define CGAL_FACE_INTERVAL_H + +#include + + +namespace CGAL { + + template + class Face_interval + { + public: + // TODO: derive type from Ft of coordinates of points in vertex + typedef double Value; + + private: + FaceHandle fh_; + Value inf_; + Value sup_; // left and right boundary values + public: + + Face_interval(){} + Face_interval(FaceHandle fh); + const Value& inf() const {return inf_;} + const Value& sup() const {return sup_;} + FaceHandle face_handle() const { return fh_;} + bool contains(const Value& V) const; + + // true iff this contains (l,r) + bool contains_interval(const Value& l, const Value& r) const; + + bool operator==(const Face_interval& I) const + { + return ( (inf() == I.inf()) && (sup() == I.sup()) && + (face_handle() == I.face_handle()) ); + } + + bool operator!=(const Face_interval& I) const + { + return ! (*this == I); + } + }; + + + + template + std::ostream& operator<<(std::ostream& os, + const Face_interval& i) + { + os << i.face_handle()->vertex(0)->point() << ", " << + i.face_handle()->vertex(1)->point() << ", " << + i.face_handle()->vertex(2)->point() << std::endl; + return os; + } + + + template + Face_interval::Face_interval(FaceHandle fh) + : fh_(fh), inf_(fh->vertex(0)->point().z()), sup_(inf_) + { + double z = fh->vertex(1)->point().z(); + sup_= (z>sup_)? z : sup_; + inf_ = (zvertex(2)->point().z(); + sup_ = (z>sup_)? z : sup_; + inf_ = (z + bool + Face_interval::contains_interval(const Value& i, + const Value& s) const + // true iff this contains (l,r) + { + return( (inf() <= i) && (sup() >= s) ); + } + + + template + bool + Face_interval::contains(const Value& v) const + { + // return true if this contains V, false otherwise + if((v >= inf()) && (v <= sup())) + return true; + else + return false; + } + + + + +} // namespace CGAL + +#endif // CGAL_FACE_INTERVAL_H + + + + + + + diff --git a/Packages/Interval_skip_list/include/CGAL/Interval_skip_list_interval.h b/Packages/Interval_skip_list/include/CGAL/Interval_skip_list_interval.h index 2893acf555a..af3c9e6ffe3 100644 --- a/Packages/Interval_skip_list/include/CGAL/Interval_skip_list_interval.h +++ b/Packages/Interval_skip_list/include/CGAL/Interval_skip_list_interval.h @@ -24,11 +24,7 @@ #ifndef CGAL_INTERVAL_SKIP_LIST_INTERVAL_H #define CGAL_INTERVAL_SKIP_LIST_INTERVAL_H -#include -#include #include -#include -#include namespace CGAL { diff --git a/Packages/Interval_skip_list/test/basic/Interval_skip_list/main.C b/Packages/Interval_skip_list/test/basic/Interval_skip_list/main.C index a982a5f5684..41e9fad4e30 100644 --- a/Packages/Interval_skip_list/test/basic/Interval_skip_list/main.C +++ b/Packages/Interval_skip_list/test/basic/Interval_skip_list/main.C @@ -54,4 +54,4 @@ main() } - +