\begin{ccRefFunction}{intersection}
\ccInclude{CGAL/intersections_d.h}

\ccFunction{result_of<Kernel::Intersect_d(Type1<K>, Type2<K>) >::type
  intersection(Type1<R> f1, Type2<R> f2);} { returns the intersection
  result of $f1$ and $f2$.
  \ccPrecond The objects are of the same dimension.}

The same functionality is also available through the functor \ccc{Kernel::Intersect_d}.

The possible value for types \ccStyle{Type1} and \ccStyle{Type2} and
the value for T\ldots in \ccStyle{boost::optional< boost::variant< T\ldots > >} are the following:

\begin{ccTexOnly}
\begin{longtable}[c]{|l|l|l|}
%\caption{All available intersection computations}\\
\multicolumn{3}{l}{\sl \ \ }
\endfirsthead
\multicolumn{3}{l}{\sl continued}
\endhead
\hline
Type1 & Type2 & \parbox{4 cm}{\vspace{1 mm}{T\ldots}} \\
\hline
\ccStyle{Line_d} & \ccStyle{Line_d} & \parbox{4 cm}{\vspace{1 mm}
    \ccStyle{Point_d}, \ccStyle{Line_d}
  \vspace{1 mm}} \\
\hline
\ccStyle{Segment_d} & \ccStyle{Line_d} & \parbox{4 cm}{\vspace{1 mm}
    \ccStyle{Point_d}, \ccStyle{Segment_d}
  \vspace{1 mm}} \\
\hline
\ccStyle{Segment_d} & \ccStyle{Segment_d} & \parbox{4 cm}{\vspace{1 mm}
    \ccStyle{Point_d}, \ccStyle{Segment_d}
  \vspace{1 mm}} \\
\hline
\ccStyle{Ray_d} & \ccStyle{Line_d} & \parbox{4 cm}{\vspace{1 mm}
    \ccStyle{Point_d}, \ccStyle{Ray_d}
  \vspace{1 mm}} \\
\hline
\ccStyle{Ray_d} & \ccStyle{Segment_d} & \parbox{4 cm}{\vspace{1 mm}
    \ccStyle{Point_d}, \ccStyle{Segment_d}
  \vspace{1 mm}} \\
\hline
\ccStyle{Ray_d} & \ccStyle{Ray_d} & \parbox{4 cm}{\vspace{1 mm}
    \ccStyle{Point_d}, \ccStyle{Segment_d}, \ccStyle{Ray_d}
  \vspace{1 mm}} \\
\hline
\ccStyle{Hyperplane_d} & \ccStyle{Line_d} & \parbox{4 cm}{\vspace{1 mm}
\ccStyle{Point_d}, \ccStyle{Line_d} 
\vspace{1 mm}} \\
\hline
\ccStyle{Hyperplane_d} & \ccStyle{Ray_d} & \parbox{4 cm}{\vspace{1 mm}
\ccStyle{Point_d}, \ccStyle{Ray_d}
\vspace{1 mm}}  \\
\hline
\ccStyle{Hyperplane_d} & \ccStyle{Segment_d} & \parbox{4 cm}{\vspace{1 mm}
\ccStyle{Point_d}, \ccStyle{Segment_d}
\vspace{1 mm}}  \\
\hline
\end{longtable}
\end{ccTexOnly}

\begin{ccHtmlOnly}
<DIV ALIGN="CENTER">
<TABLE CELLPADDING=3 BORDER="1">
<TR> <TH> Type1 </TH>
 <TH> Type2 </TH>
 <TH> T... </TH>
</TR>
<TR>
    <TD VALIGN="CENTER" > Line_d </TD>
    <TD VALIGN="CENTER" > Line_d </TD>
    <TD><TABLE>
        <TR><TD>Point_d</TD></TR>
        <TR><TD>Line_d</TD></TR>
        </TABLE></TD>
</TR>
<TR>
    <TD VALIGN="CENTER" > Segment_d </TD>
    <TD VALIGN="CENTER" > Line_d </TD>
    <TD><TABLE>
        <TR><TD>Point_d</TD></TR>
        <TR><TD>Segment_d</TD></TR>
      </TABLE></TD>
</TR>
<TR>
    <TD VALIGN="CENTER" > Segment_d </TD>
    <TD VALIGN="CENTER" > Segment_d </TD>
    <TD><TABLE>
        <TR><TD>Point_d</TD></TR>
        <TR><TD>Segment_d</TD></TR>
      </TABLE></TD>
</TR>
<TR>
    <TD VALIGN="CENTER" > Ray_d </TD>
    <TD VALIGN="CENTER" > Line_d </TD>
    <TD><TABLE>
        <TR><TD>Point_d</TD></TR>
        <TR><TD>Ray_d</TD></TR>
      </TABLE></TD>
</TR>
<TR>
    <TD VALIGN="CENTER" > Ray_d </TD>
    <TD VALIGN="CENTER" > Segment_d </TD>
    <TD><TABLE>
        <TR><TD>Point_d</TD></TR>
        <TR><TD>Segment_d</TD></TR>
      </TABLE></TD>
</TR>
<TR>
    <TD VALIGN="CENTER" > Ray_d </TD>
    <TD VALIGN="CENTER" > Ray_d </TD>
    <TD><TABLE>
        <TR><TD>Point_d</TD></TR>
        <TR><TD>Segment_d</TD></TR>
        <TR><TD>Ray_d</TD></TR>
      </TABLE></TD>
</TR>
<TR>
    <TD VALIGN="CENTER" > Hyperplane_d </TD>
    <TD VALIGN="CENTER" > Line_d </TD>
    <TD><TABLE>
        <TR><TD>Point_d</TD></TR>
        <TR><TD>Line_d</TD></TR>
        </TABLE></TD>
</TR>
<TR>
    <TD VALIGN="CENTER" > Hyperplane_d </TD>
    <TD VALIGN="CENTER" > Ray_d </TD>
    <TD><TABLE>
        <TR><TD>Point_d</TD></TR>
        <TR><TD>Ray_d</TD></TR>
        </TABLE></TD>
</TR>
<TR>
    <TD VALIGN="CENTER" > Hyperplane_d </TD>
    <TD VALIGN="CENTER" > Segment_d </TD>
    <TD><TABLE>
        <TR><TD>Point_d</TD></TR>
        <TR><TD>Segment_d</TD></TR>
        </TABLE></TD>
</TR>
</TABLE>
</DIV>
\end{ccHtmlOnly}

\ccExample

The following example demonstrates the most common use of 
\ccc{intersection} routines.
\ccHtmlLinksOff%
\begin{verbatim}
#include <CGAL/intersections_d.h>

template<typename R>
struct Intersection_visitor {
  typedef result_type void;
  void operator()(const Point_d<R>& p) const { /* handle point */ }
  void operator()(const Segment_d<R>& s) const { /* handle segment */ }
};

template <class R>
void foo(Segment_d<R> seg, Line_d<R> lin)
{
  // with C++11 support
  auto result = intersection(seg, lin);

  // without C++11 support
  // typename cpp11::result_of<R::Intersect_d(Segment_d<R>, Line_d<R>)>::type
  // result = intersection(seg, lin);

  if(result) { boost::apply_visitor(Intersection_visitor<R>(), *result); } 
  else { /* no intersection */ }
}
\end{verbatim}%
\ccHtmlLinksOn%

\ccSeeAlso 
\ccc{do_intersect}, \\
\ccc{Kernel::Intersect_d}, \\
\ccc{Kernel::Do_intersect_d}, \\ 
\ccAnchor{http://www.boost.org/doc/libs/release/libs/optional/index.html}{boost::optional}, \\
\ccAnchor{http://www.boost.org/doc/html/variant.html}{boost::variant} \\
\ccAnchor{http://www.boost.org/libs/utility/utility.htm#result_of}{boost::result\_of}

\end{ccRefFunction}

