本文整理汇总了C++中VPoint::follower方法的典型用法代码示例。如果您正苦于以下问题:C++ VPoint::follower方法的具体用法?C++ VPoint::follower怎么用?C++ VPoint::follower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VPoint
的用法示例。
在下文中一共展示了VPoint::follower方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
pointlist* logicop::logic::hole2simple(const pointlist& outside, const pointlist& inside) {
segmentlist _segl0(outside,0);
segmentlist _segl1(inside,1);
EventQueue* _eq = new EventQueue(_segl0, _segl1); // create the event queue
SweepLine _sl;
BindCollection BC;
_eq->swipe4bind(_sl, BC);
BindSegment* sbc = BC.get_highest();
//insert 2 crossing points and link them
BPoint* cpsegA = _segl0.insertbindpoint(sbc->poly0seg(), sbc->poly0pnt());
BPoint* cpsegB = _segl1.insertbindpoint(sbc->poly1seg(), sbc->poly1pnt());
cpsegA->linkto(cpsegB);
cpsegB->linkto(cpsegA);
// normalize the segment lists
_segl0.normalize(outside);
_segl1.normalize(inside);
// dump the new polygons in VList terms
VPoint* outshape = _segl0.dump_points();
_segl1.dump_points();
// traverse and form the resulting shape
VPoint* centinel = outshape;
pointlist *shgen = new pointlist();
bool direction = true; /*next*/
VPoint* pickup = centinel;
VPoint* prev = centinel->prev();
bool modify = false;
do {
shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y()));
modify = (-1 == prev->visited());
prev = pickup;
pickup = pickup->follower(direction, modify);
} while (pickup != centinel);
// Validate the resulting polygon
laydata::valid_poly check(*shgen);
// delete shgen;
if (!check.valid()) {
std::ostringstream ost;
ost << ": Resulting shape is invalid - " << check.failtype();
tell_log(console::MT_ERROR, ost.str().c_str());
}
else {
if (laydata::shp_OK != check.status())
*shgen = check.get_validated();
}
return shgen;
}
示例2: if
/*!The method uses #_shape1 and #_shape2 structure as an input data and produces
one or more polygons representing the result of the logical AND between the
input polygons. Method returns false if no output shapes are generated, and
true otherwise*/
bool logicop::logic::AND(pcollection& plycol) {
bool result = false;
VPoint* centinel = NULL;
if (0 == _crossp) {
// If there are no crossing points found, this still does not mean
// that the operation will fail. Polygons might be fully overlapping...
// Check that a random point from poly1 is inside poly2 ...
if (_shape1->inside(_poly2)) centinel = _shape1;
// ... if not, check that a random point from poly2 is inside poly1 ...
else if (_shape2->inside(_poly1)) centinel = _shape2;
// ... if not - polygons does not have any common area
else return false;
// If we've got here means that one of the polygons is completely
// overlapped by the other one. So we need to return the inner one
pointlist *shgen = new pointlist();
VPoint* vpnt = centinel;
do {
shgen->push_back(TP(vpnt->cp()->x(), vpnt->cp()->y()));
vpnt = vpnt->next();
}while (centinel != vpnt);
plycol.push_back(shgen);
return true;
}
bool direction = true; /*next*/
//if crossing points exists, get first external and non crossing point
centinel = getFirstOutside(_poly2, _shape1);
if (NULL == centinel) centinel = getFirstOutside(_poly1, _shape2);
assert(centinel);
VPoint* collector = centinel;
do {
if (0 == collector->visited()) {
pointlist *shgen = new pointlist();
VPoint* pickup = collector;
do {
pickup = pickup->follower(direction);
shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y()));
} while (pickup != collector);
plycol.push_back(shgen);
result = true;
}
collector = collector->prev();
} while (collector != centinel);
return result;
}
示例3: getFirstOutside
/*!The method uses #_shape1 and #_shape2 structure as an input data and produces
one or more polygons representing the result of the logical ANDNOT between the
input polygons. Method returns false if no output shapes are generated, and
true otherwise*/
bool logicop::logic::ANDNOT(pcollection& plycol) {
bool result = false;
VPoint* centinel = NULL;
if (0 == _crossp) {
// If there are no crossing points found, this still does not mean
// that the operation will fail. Polygons might be overlapping...
// if poly1 is inside poly2, or both are non overlapping ->
// resulting shape is null
// if poly2 is inside poly1, then we have to generate a polygon
// combining both shapes
if (_shape2->inside(_poly1)) {
plycol.push_back(hole2simple(_poly1, _poly2));
return true;
}
else return false;
}
//if crossing points exists, get first external and non crossing point
bool direction;
centinel = getFirstOutside(_poly1, _shape2);
if (NULL == centinel) {
centinel = getFirstOutside(_poly2, _shape1);
direction = false; /*prev*/
}
else direction = true; /*next*/
assert(centinel);
//
VPoint* collector = centinel;
do {
if (0 == collector->visited()) {
pointlist *shgen = new pointlist();
VPoint* pickup = collector;
do {
pickup = pickup->follower(direction, true);
shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y()));
} while (pickup != collector);
plycol.push_back(shgen);
result = true;
}
collector = collector->prev();
} while (collector != centinel);
return result;
}