conic_section_clipper_impl.h revision 5738b9afc93525510fa01185f7609fd5cbb0ff1a
/**
* \file
* \brief Conic section clipping with respect to a rectangle
*
* Authors:
* Marco Cecchetti <mrcekets at gmail>
*
* Copyright 2009 authors
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*/
#include <list>
#include <map>
#ifdef CLIP_WITH_CAIRO_SUPPORT
#define CLIPPER_CLASS clipper_cr
#else
#define CLIPPER_CLASS clipper
#endif
//#define CLIPDBG
#ifdef CLIPDBG
if (cond) \
{ \
}
#else
#endif
{
{
#ifdef CLIP_WITH_CAIRO_SUPPORT
{
}
#else
{
}
#endif
bool found_any_isolated_point() const
{
return (single_points.size() != 0);
}
{
return single_points;
}
const Point & Q) const;
size_t k) const;
double length) const;
#ifdef CLIP_WITH_CAIRO_SUPPORT
#endif
const Rect & R;
};
/*
* Given two point "P", "Q" on the conic section the method computes
* a third point inner to the arc with end-point "P", "Q".
* The new point is found by intersecting the conic with the bisector line
* of the PQ line segment.
*/
inline
const Point & Q) const
{
DBGPRINT ("CLIP: find_inner_point_by_bisector_line: P = ", P)
DBGPRINT ("CLIP: find_inner_point_by_bisector_line: Q = ", Q)
double t;
{
THROW_LOGICALERROR ("clipper::find_inner_point_by_bisector_line: "
"no conic-bisector line intersection point");
}
{
// we suppose that the searched point is the nearest
// to the line segment PQ
}
else
{
t = rts[0];
}
}
/*
* Given two point "P", "Q" on the conic section the method computes
* a third point inner to the arc with end-point "P", "Q".
* The new point is found by intersecting the conic with the line
* passing through the middle point of the PQ line segment and
* the intersection point of the tangent lines at points P and Q.
*/
inline
{
Line l;
// in case we fail to find a crossing point we fall back to the bisector
// method
{
if (!oc)
{
return find_inner_point_by_bisector_line (P, Q);
}
}
{
return find_inner_point_by_bisector_line (P, Q);
}
double t;
{
return find_inner_point_by_bisector_line (P, Q);
}
// the line "l" origin is set to the tangent crossing point so in case
// we find two intersection points only the nearest belongs to the given arc
// pay attention: in case we are dealing with an hyperbola (remember that
// end points are on the same branch, because they are paired) the tangent
// crossing point belongs to the angle delimited by hyperbola asymptotes
// and containing the given hyperbola branch, so the previous statement is
// still true
{
}
else
{
t = rts[0];
}
return l.pointAt (t);
}
/*
* Given a list of points on the conic section, and given two consecutive
* points belonging to the list and passed by two list iterators, the method
* finds a new point that is inner to the conic arc which has the two passed
* points as initial and final point. This new point is inserted into the list
* between the two passed points and an iterator pointing to the new point
* is returned.
*/
inline
{
//std::cerr << "CLIP: split: [" << *sp << ", " << *ip << ", "
// << *fp << "]" << std::endl;
return ip;
}
/*
* Given a list of points on the conic section, and given two consecutive
* points belonging to the list and passed by two list iterators, the method
* recursively finds new points that are inner to the conic arc which has
* the two passed points as initial and final point. The recursion stop after
* "k" recursive calls. These new points are inserted into the list between
* the two passed points, and in the order we cross them going from
* the initial to the final arc point.
*/
inline
size_t k) const
{
if (k == 0)
{
//DBGINFO("CLIP: split: no further split")
return;
}
--k;
}
/*
* Given a list of points on the conic section, and given two consecutive
* points belonging to the list and passed by two list iterators, the method
* recursively finds new points that are inner to the conic arc which has
* the two passed points as initial and final point. The recursion stop when
* the max distance between the new computed inner point and the two passed
* arc end-points is less then the value specified by the "length" parameter.
* These new points are inserted into the list between the two passed points,
* and in the order we cross them going from the initial to the final arc point.
*/
inline
double length) const
{
{
//DBGINFO("CLIP: split: no further split")
return;
}
// they have to be called both to keep the number of points in the list
// in the form 2k+1 where k are the sub-arcs the initial arc is splitted in.
}
} // end namespace Geom
#endif // _2GEOM_CONIC_SECTION_CLIPPER_IMPL_H_
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :