本文整理汇总了C++中Polygon_2::edges_end方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon_2::edges_end方法的具体用法?C++ Polygon_2::edges_end怎么用?C++ Polygon_2::edges_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon_2
的用法示例。
在下文中一共展示了Polygon_2::edges_end方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boundaries_intersect
bool boundaries_intersect(const Polygon_2& P, const Polygon_2& Q, bool proper)
{
std::list<Segment_2> segments0, segments1;
segments0.insert(segments0.end(), P.edges_begin(), P.edges_end());
segments1.insert(segments1.end(), Q.edges_begin(), Q.edges_end());
bool intersects = has_intersection(segments0.begin(), segments0.end(),
segments1.begin(), segments1.end(),
true, true);
if (!intersects || !proper)
return intersects;
if (has_intersection(segments0.begin(), segments0.end(),
segments1.begin(), segments1.end(),
false, false))
return true;
typedef Polygon_2::Vertex_const_iterator Iter;
for (Iter it = P.vertices_begin(); it != P.vertices_end(); ++it) {
if (Q.has_on_bounded_side(*it))
return true;
}
for (Iter it = Q.vertices_begin(); it != Q.vertices_end(); ++it) {
if (P.has_on_bounded_side(*it))
return true;
}
return false;
}
示例2: main
// The main program:
int main(int argc, char* argv[])
{
Polygon_2 polygon;
const char* filename = (argc > 1) ? argv[1] : "polygon.dat";
std::ifstream input_file(filename);
if (! input_file.is_open()) {
std::cerr << "Failed to open the " << filename << std::endl;
return -1;
}
input_file >> polygon;
input_file.close();
// Example for is_pullout_direction_single_mold_translational_casting_2 that
// accepts the edge
size_t index(0);
for (auto e_it = polygon.edges_begin(); e_it != polygon.edges_end(); ++e_it,
++index)
{
auto orientation = polygon.orientation();
auto segment_outer_circle =
SMS::internal::get_segment_outer_circle<Kernel>(*e_it, orientation);
auto d = segment_outer_circle.first;
d = d.perpendicular(CGAL::CLOCKWISE);
auto res = casting::is_pullout_direction(polygon, e_it, d);
std::cout << "The polygon is " << (res ? "" : "not ")
<< "castable using edge "
<< index << " in vartical translation (" << d << ")" << std::endl;
}
std::cout << "-----------------------------------"<< std::endl;
// Example for is_pullout_direction_single_mold_translational_casting_2 that
// do not accepts the edge
{
Vector_2 v (Point_2(0,0), Point_2(1,0));
Direction_2 d(v);
auto res = casting::is_pullout_direction(polygon, d);
if (res != polygon.edges_end()) {
std::cout << "The polygon is castable in direction d (" << d
<< ") using edge "<< *res << std::endl;
}
else {
std::cout << "The polygon is not castable in direction d (" << d << ")"
<< std::endl;
}
}
return 0;
}
示例3: split_nonsimple
void split_nonsimple(const Polygon_2& P, Out_iter out)
{
static log4cplus::Logger logger = log4cplus::Logger::getInstance("split_nonsimple");
typedef CGAL::Direction_2<Kernel> Direction_2;
typedef CGAL::Vector_2<Kernel> Vector_2;
std::set<Segment_2> segments;
segments.insert(P.edges_begin(), P.edges_end());
// Compute the subsegments, such that there are no interior pairwise
// intersections between subsegments.
std::list<Segment_2> subsegments_list;
CGAL::compute_subcurves(segments.begin(), segments.end(), back_inserter(subsegments_list));
// Index the subsegments by their source and target points.
std::map<Point_2, set<Segment_2> > source2sub, target2sub;
std::set<Segment_2> subsegments;
BOOST_FOREACH (Segment_2 s, subsegments_list) {
// if (segments.find(s.opposite()) != segments.end()) {
// s = s.opposite();
// }
subsegments.insert(s);
source2sub[s.source()].insert(s);
target2sub[s.target()].insert(s);
}
示例4: intersects_boundary
bool intersects_boundary(const Polygon_2& P, const Segment_2& s, bool end_internal, bool end_end)
{
std::list<Segment_2> segments0, segments1;
segments0.insert(segments0.end(), P.edges_begin(), P.edges_end());
segments1.push_back(s);
return has_intersection(segments0.begin(), segments0.end(),
segments1.begin(), segments1.end(),
end_internal, end_end);
}
示例5: intersects_proper
/// Returns true if the segment crosses a boundary line of the polygon.
/// It is not enough for the segment to simply intersect the boundary
/// line -- it must cross it such that the segment extends to both inside
/// and outside of the boundary of the polygon.
bool intersects_proper(const Segment_2& segment, const Polygon_2& polygon)
{
static log4cplus::Logger logger = log4cplus::Logger::getInstance("tiler.intersects_proper");
Point_2 seg_pts[] = { segment.source(), segment.target() };
// Get intersection points between segment and polygon
LOG4CPLUS_TRACE(logger, "Doing a line sweep: " << pp(segment));
list<Segment_2> segments(polygon.edges_begin(), polygon.edges_end());
segments.push_back(segment);
list<Point_2> points;
get_intersection_points(segments.begin(), segments.end(), back_inserter(points), true, false);
CGAL::Bounded_side side1 = polygon.bounded_side(seg_pts[0]);
CGAL::Bounded_side side2 = polygon.bounded_side(seg_pts[1]);
LOG4CPLUS_TRACE(logger, "Checking with cross checker");
if (points.size() == 0)
return false;
Cross_checker checker;
checker.add(side1);
checker.add(side2);
if (checker.crosses())
return true;
if (points.size() == 1)
return false;
points.push_back(seg_pts[0]);
points.push_back(seg_pts[1]);
points.sort();
list<Point_2>::iterator it0 = points.begin();
list<Point_2>::iterator it1 = it0;
++it1;
while (it1 != points.end())
{
const Point_2& p0 = *it0;
const Point_2& p1 = *it1;
// find an intermediate point and test for where it is
Point_2 midpoint((p0.x()+p1.x())/2.0, (p0.y()+p1.y())/2.0);
checker.add(polygon.bounded_side(midpoint));
if (checker.crosses())
return true;
++it0;
++it1;
}
return false;
}