本文整理汇总了C++中PathIterator类的典型用法代码示例。如果您正苦于以下问题:C++ PathIterator类的具体用法?C++ PathIterator怎么用?C++ PathIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PathIterator类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _is_segment
Path::Path(const Path &from_prefix, const Path &from_suffix)
: _is_segment(from_prefix._is_segment)
, _components(from_prefix._components)
{
//::std::cout << "\nCONCAT CONSTRUCT: " << from_prefix.toString() << " " << from_suffix.toString();
for (constPathIterator it = from_suffix.begin(); it != from_suffix.end(); ++it)
{
//::std::cout << "APPENDING: " << *it << "\n";
if (it->compare("..") == 0)
{
if (_components.size() > 0)
{
_components.pop_back();
}
else if (_is_segment)
{
_components.push_back(*it);
}
else
{
throw ::std::invalid_argument("Path segment \"" + from_suffix.toString() +
"\" cannot be appended to path \"" + from_prefix.toString() + "\".");
}
}
else if (it->compare(".") == 0)
{ /* skip */
}
else
{
_components.push_back(*it);
}
}
}
示例2: path_in_path
bool
path_in_path(PathIterator& a, const agg::trans_affine& atrans,
PathIterator& b, const agg::trans_affine& btrans)
{
typedef agg::conv_transform<PathIterator> transformed_path_t;
typedef PathNanRemover<transformed_path_t> no_nans_t;
typedef agg::conv_curve<no_nans_t> curve_t;
if (a.total_vertices() < 3)
return false;
transformed_path_t b_path_trans(b, btrans);
no_nans_t b_no_nans(b_path_trans, true, b.has_curves());
curve_t b_curved(b_no_nans);
double x, y;
b_curved.rewind(0);
while (b_curved.vertex(&x, &y) != agg::path_cmd_stop)
{
if (!::point_in_path(x, y, a, atrans))
return false;
}
return true;
}
示例3: _cleanup_path
void
_cleanup_path(PathIterator& path, const agg::trans_affine& trans,
bool remove_nans, bool do_clip,
const agg::rect_base<double>& rect,
e_snap_mode snap_mode, double stroke_width,
bool do_simplify, bool return_curves,
std::vector<double>& vertices,
std::vector<npy_uint8>& codes)
{
typedef agg::conv_transform<PathIterator> transformed_path_t;
typedef PathNanRemover<transformed_path_t> nan_removal_t;
typedef PathClipper<nan_removal_t> clipped_t;
typedef PathSnapper<clipped_t> snapped_t;
typedef PathSimplifier<snapped_t> simplify_t;
typedef agg::conv_curve<simplify_t> curve_t;
transformed_path_t tpath(path, trans);
nan_removal_t nan_removed(tpath, remove_nans, path.has_curves());
clipped_t clipped(nan_removed, do_clip, rect);
snapped_t snapped(clipped, snap_mode, path.total_vertices(), stroke_width);
simplify_t simplified(snapped, do_simplify, path.simplify_threshold());
vertices.reserve(path.total_vertices() * 2);
codes.reserve(path.total_vertices());
if (return_curves)
{
__cleanup_path(simplified, vertices, codes);
}
else
{
curve_t curve(simplified);
__cleanup_path(curve, vertices, codes);
}
}
示例4: path_intersects_path
bool path_intersects_path(PathIterator& p1, PathIterator& p2)
{
typedef agg::conv_curve<PathIterator> curve_t;
if (p1.total_vertices() < 2 || p2.total_vertices() < 2)
return false;
curve_t c1(p1);
curve_t c2(p2);
double x11, y11, x12, y12;
double x21, y21, x22, y22;
c1.vertex(&x11, &y11);
while (c1.vertex(&x12, &y12) != agg::path_cmd_stop)
{
c2.rewind(0);
c2.vertex(&x21, &y21);
while (c2.vertex(&x22, &y22) != agg::path_cmd_stop)
{
if (segments_intersect(x11, y11, x12, y12, x21, y21, x22, y22))
return true;
x21 = x22;
y21 = y22;
}
x11 = x12;
y11 = y12;
}
return false;
}
示例5: compareChunkPaths
ChunkPath::MatchResult ChunkController::compareChunkPaths(const ChunkPath& currentPath)
{
ChunkPath::MatchResult result = ChunkPath::kNoMatch;
for( PathIterator iter = mChunkPaths.begin(); ( result == ChunkPath::kNoMatch ) && ( iter != mChunkPaths.end() ); iter++ )
{
result = iter->match(currentPath);
}
return result;
}
示例6: isWildcard
bool Path::isWildcard() const
{
for (constPathIterator it = begin(); it != end(); ++it)
{
if ((it->compare("*") == 0) || (it->compare("**") == 0))
{
return true;
}
}
return false;
}
示例7: get_path_extents
void
get_path_extents(PathIterator& path, const agg::trans_affine& trans,
double* x0, double* y0, double* x1, double* y1,
double* xm, double* ym)
{
typedef agg::conv_transform<PathIterator> transformed_path_t;
typedef PathNanRemover<transformed_path_t> nan_removed_t;
typedef agg::conv_curve<nan_removed_t> curve_t;
double x, y;
unsigned code;
transformed_path_t tpath(path, trans);
nan_removed_t nan_removed(tpath, true, path.has_curves());
curve_t curved_path(nan_removed);
curved_path.rewind(0);
while ((code = curved_path.vertex(&x, &y)) != agg::path_cmd_stop)
{
if ((code & agg::path_cmd_end_poly) == agg::path_cmd_end_poly)
{
continue;
}
if (x < *x0) *x0 = x;
if (y < *y0) *y0 = y;
if (x > *x1) *x1 = x;
if (y > *y1) *y1 = y;
/* xm and ym are the minimum positive values in the data, used
by log scaling */
if (x > 0.0 && x < *xm) *xm = x;
if (y > 0.0 && y < *ym) *ym = y;
}
}
示例8: point_in_path
inline bool
point_in_path(double x, double y, PathIterator& path,
const agg::trans_affine& trans)
{
typedef agg::conv_transform<PathIterator> transformed_path_t;
typedef PathNanRemover<transformed_path_t> no_nans_t;
typedef agg::conv_curve<no_nans_t> curve_t;
if (path.total_vertices() < 3)
{
return false;
}
transformed_path_t trans_path(path, trans);
no_nans_t no_nans_path(trans_path, true, path.has_curves());
curve_t curved_path(no_nans_path);
return point_in_path_impl(x, y, curved_path);
}
示例9: point_in_path
inline bool point_in_path(double x, double y, PathIterator& path, const agg::trans_affine& trans)
{
typedef agg::conv_transform<PathIterator> transformed_path_t;
typedef agg::conv_curve<transformed_path_t> curve_t;
if (path.total_vertices() < 3)
return false;
transformed_path_t trans_path(path, trans);
curve_t curved_path(trans_path);
return point_in_path_impl(x, y, curved_path);
}
示例10: path_intersects_path
bool
path_intersects_path(PathIterator& p1, PathIterator& p2)
{
typedef PathNanRemover<PathIterator> no_nans_t;
typedef agg::conv_curve<no_nans_t> curve_t;
if (p1.total_vertices() < 2 || p2.total_vertices() < 2)
{
return false;
}
no_nans_t n1(p1, true, p1.has_curves());
no_nans_t n2(p2, true, p2.has_curves());
curve_t c1(n1);
curve_t c2(n2);
double x11, y11, x12, y12;
double x21, y21, x22, y22;
c1.vertex(&x11, &y11);
while (c1.vertex(&x12, &y12) != agg::path_cmd_stop)
{
c2.rewind(0);
c2.vertex(&x21, &y21);
while (c2.vertex(&x22, &y22) != agg::path_cmd_stop)
{
if (segments_intersect(x11, y11, x12, y12, x21, y21, x22, y22))
{
return true;
}
x21 = x22;
y21 = y22;
}
x11 = x12;
y11 = y12;
}
return false;
}
示例11: point_on_path
inline bool
point_on_path(double x, double y, double r, PathIterator& path,
const agg::trans_affine& trans)
{
typedef agg::conv_transform<PathIterator> transformed_path_t;
typedef PathNanRemover<transformed_path_t> no_nans_t;
typedef agg::conv_curve<no_nans_t> curve_t;
typedef agg::conv_stroke<curve_t> stroke_t;
transformed_path_t trans_path(path, trans);
no_nans_t nan_removed_path(trans_path, true, path.has_curves());
curve_t curved_path(nan_removed_path);
stroke_t stroked_path(curved_path);
stroked_path.width(r * 2.0);
return point_in_path_impl(x, y, stroked_path);
}
示例12: clip_to_rect
void
clip_to_rect(PathIterator& path,
double x0, double y0, double x1, double y1,
bool inside, std::vector<Polygon>& results)
{
double xmin, ymin, xmax, ymax;
if (x0 < x1)
{
xmin = x0;
xmax = x1;
}
else
{
xmin = x1;
xmax = x0;
}
if (y0 < y1)
{
ymin = y0;
ymax = y1;
}
else
{
ymin = y1;
ymax = y0;
}
if (!inside)
{
std::swap(xmin, xmax);
std::swap(ymin, ymax);
}
Polygon polygon1, polygon2;
double x = 0, y = 0;
unsigned code = 0;
path.rewind(0);
do
{
// Grab the next subpath and store it in polygon1
polygon1.clear();
do
{
if (code == agg::path_cmd_move_to)
{
polygon1.push_back(XY(x, y));
}
code = path.vertex(&x, &y);
if (code == agg::path_cmd_stop)
{
break;
}
if (code != agg::path_cmd_move_to)
{
polygon1.push_back(XY(x, y));
}
}
while ((code & agg::path_cmd_end_poly) != agg::path_cmd_end_poly);
// The result of each step is fed into the next (note the
// swapping of polygon1 and polygon2 at each step).
clip_to_rect_one_step(polygon1, polygon2, clip_to_rect_filters::xlt(xmax));
clip_to_rect_one_step(polygon2, polygon1, clip_to_rect_filters::xgt(xmin));
clip_to_rect_one_step(polygon1, polygon2, clip_to_rect_filters::ylt(ymax));
clip_to_rect_one_step(polygon2, polygon1, clip_to_rect_filters::ygt(ymin));
// Empty polygons aren't very useful, so skip them
if (polygon1.size())
{
results.push_back(polygon1);
}
}
while (code != agg::path_cmd_stop);
}
示例13: PathCleanupIterator
PathCleanupIterator(PyObject* path, agg::trans_affine trans,
bool remove_nans, bool do_clip,
const agg::rect_base<double>& rect,
e_snap_mode snap_mode, double stroke_width,
bool do_simplify) :
m_path_obj(path, true),
m_path_iter(m_path_obj),
m_transform(trans),
m_transformed(m_path_iter, m_transform),
m_nan_removed(m_transformed, remove_nans, m_path_iter.has_curves()),
m_clipped(m_nan_removed, do_clip, rect),
m_snapped(m_clipped, snap_mode, m_path_iter.total_vertices(),
stroke_width),
m_simplify(m_snapped, do_simplify && m_path_iter.should_simplify(),
m_path_iter.simplify_threshold())
{
Py_INCREF(path);
m_path_iter.rewind(0);
}