本文整理汇总了C++中Polygon_2::vertices_end方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon_2::vertices_end方法的具体用法?C++ Polygon_2::vertices_end怎么用?C++ Polygon_2::vertices_end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon_2
的用法示例。
在下文中一共展示了Polygon_2::vertices_end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
int main()
{
CGAL::set_pretty_mode(cout);
// build a random convex 20-gon p
{
Polygon_2 p;
random_convex_set_2(20, back_inserter(p), Point_generator(1.0));
cout << "------------------------------\nInput:\n" << p << endl;
compute(p.vertices_begin(), p.vertices_end());
}
// try identical points
{
Polygon_2 p;
for (int i = 1; i < 3; ++i) {
cout << "------------------------------\nInput:\n" << p << endl;
compute(p.vertices_begin(), p.vertices_end());
p.push_back(Point_2(0,0));
}
}
return 0;
}
示例3: decomposePolygonCgal
void decomposePolygonCgal(geometry_msgs::Polygon& input, std::vector<geometry_msgs::Polygon>& output)
{
Polygon_list cgalOutputPolys;
Traits partitionTraits;
Validity_traits validityTraits;
// Convert from ROS-polygon to CGAL polygon
Polygon_2 cgalInput;
for (int i = 0; i < input.points.size(); i++)
{
cgalInput.push_back(Point_2(input.points[i].x, input.points[i].y));
}
// Make sure we have a COUNTERCLOCKWISE polygon
if (cgalInput.orientation() == CGAL::CLOCKWISE)
{
cgalInput.clear();
for (int i = input.points.size() - 1; i >= 0; i--)
{
cgalInput.push_back(Point_2(input.points[i].x, input.points[i].y));
}
}
// Do the decomposition using CGAL
CGAL::optimal_convex_partition_2(
cgalInput.vertices_begin(), cgalInput.vertices_end(), std::back_inserter(cgalOutputPolys), partitionTraits);
std::cout << "CHECK output data!" << std::endl;
assert(CGAL::partition_is_valid_2(cgalInput.vertices_begin(),
cgalInput.vertices_end(),
cgalOutputPolys.begin(),
cgalOutputPolys.end(),
validityTraits));
// Now walk through the result and convert to ROS
for (Polygon_iterator poly_it = cgalOutputPolys.begin(); poly_it != cgalOutputPolys.end(); poly_it++)
{
Polygon_2 p = *poly_it;
geometry_msgs::Polygon outputPoly;
// Iterate through the points for a polygon
for (Vertex_iterator vi = p.vertices_begin(); vi != p.vertices_end(); ++vi)
{
Point_2 v = *vi;
geometry_msgs::Point32 pt;
pt.x = v.x();
pt.y = v.y();
outputPoly.points.push_back(pt);
}
output.push_back(outputPoly);
}
}
示例4: insert_polygon
void insert_polygon( CDT& cdt, const Polygon_2& polygon ) {
if (polygon.is_empty())
return;
CDT::Vertex_handle v_prev = cdt.insert( *CGAL::cpp0x::prev( polygon.vertices_end() ) );
for (Polygon_2::Vertex_iterator vit = polygon.vertices_begin(); vit != polygon.vertices_end(); ++vit) {
CDT::Vertex_handle vh = cdt.insert(*vit);
cdt.insert_constraint(vh, v_prev);
v_prev = vh;
}
}
示例5: perturb
void perturb(Polygon_2& p, Number_type epsilon) {
Polygon_2::Vertex_iterator vit;
for (vit = p.vertices_begin(); vit != p.vertices_end(); ++vit) {
Point_2 pnt = *vit;
// Make sure we get a consistent perturbation with each point across runs
const static Number_type prime = 827;
srand((int)(pnt.x() + prime*(pnt.y() + prime*pnt.z())));
pnt = Point_25_<Kernel>(perturb(pnt.x(), epsilon), perturb(pnt.y(), epsilon), pnt.z(), pnt.id());
p.set(vit, pnt);
}
p = Polygon_2(p.vertices_begin(), unique(p.vertices_begin(), p.vertices_end()));
}
示例6: print_WKT_polygon_2
/**
\brief Prints a polygon in its WKT form (p1,p2,p3,....)
\note Does not add POLYGON text. It is used inside other printing functions
*/
void print_WKT_polygon_2(Polygon_2 plg) {
std::cout << "(";
std::vector<Point>::iterator v;
for ( v = plg.vertices_begin();
v != plg.vertices_end()-1;
++v) {
std::cout << *v << ",";
}
v = plg.vertices_end()-1; //last one with no comma
std::cout << *v << ")";
}
示例7: xz_swap_neg
Polygon_2 xz_swap_neg(const Polygon_2& p)
{
Polygon_2 ret;
for (Polygon_2::Vertex_iterator it = p.vertices_begin(); it != p.vertices_end(); ++it)
ret.push_back(xz_swap_neg(*it));
return ret;
}
示例8: main
int main()
{
Polygon_2 poly ;
poly.push_back( Point(-1,-1) ) ;
poly.push_back( Point(0,-12) ) ;
poly.push_back( Point(1,-1) ) ;
poly.push_back( Point(12,0) ) ;
poly.push_back( Point(1,1) ) ;
poly.push_back( Point(0,12) ) ;
poly.push_back( Point(-1,1) ) ;
poly.push_back( Point(-12,0) ) ;
// You can pass the polygon via an iterator pair
SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.vertices_begin(), poly.vertices_end());
// Or you can pass the polygon directly, as below.
// To create an exterior straight skeleton you need to specify a maximum offset.
double lMaxOffset = 5 ;
SsPtr oss = CGAL::create_exterior_straight_skeleton_2(lMaxOffset, poly);
print_straight_skeleton(*iss);
print_straight_skeleton(*oss);
return 0;
}
示例9: minkowskiSum
/*
* append gA+gB into the polygonSet
*/
void minkowskiSum( const Point& gA, const Polygon_2& gB, Polygon_set_2& polygonSet )
{
BOOST_ASSERT( gB.size() );
CGAL::Aff_transformation_2< Kernel > translate(
CGAL::TRANSLATION,
gA.toVector_2()
);
Polygon_2 sum ;
for ( Polygon_2::Vertex_const_iterator it = gB.vertices_begin();
it != gB.vertices_end(); ++it ) {
sum.push_back( translate.transform( *it ) );
}
if ( sum.is_clockwise_oriented() ) {
sum.reverse_orientation() ;
}
if ( polygonSet.is_empty() ) {
polygonSet.insert( sum );
}
else {
polygonSet.join( sum );
}
}
示例10: main
int main(int argc, char** argv)
{
//Reading polygon files
Polygon_2 poly;
QPolygonF poly_qt;
read_file("models/turtle_w.txt", poly, poly_qt);
//Compute straight skeleton
//*****This program now works for polygon WITHOUT HOLES.
SsPtr iss = CGAL::create_interior_straight_skeleton_2(poly.vertices_begin(), poly.vertices_end());
SsPtr ess = CGAL::create_exterior_straight_skeleton_2(EMaxOffset, poly);
//Constructing the graph combining the straight skeleton and polygon
std::vector<BridgingGraph> bg;
construct_bridging_graph(poly, *iss, *ess, bg);
//Compute perpendiculars
std::list<Perpendiculars> ppd;
generate_perpendiculars(*iss, *ess, bg, ppd);
deduplicate_perpendiculars<K>(ppd);
//Assign mountain and valley
std::list<Segment> mt;
std::list<Segment> vl;
MountainValley<K>(*iss, *ess, bg, ppd, mt, vl);
//Extracts skeleton from cgal and converts them to qt
std::list<QLineF> bis_qt;
convert_straight_skeleton(*iss, bis_qt);
convert_straight_skeleton(*ess, bis_qt);
std::list<QLineF> ppd_qt;
convert_perpendiculars<K>(ppd, ppd_qt);
std::list<QLineF> mt_qt, vl_qt;
convert_mountain_valley<K>(mt, mt_qt);
convert_mountain_valley<K>(vl, vl_qt);
//SETUP QT
//Create applicaiton
QApplication app(argc, argv);
//Create scene
QGraphicsScene scene;
createQTscene(scene, poly_qt, bis_qt, ppd_qt, mt_qt, vl_qt);
//Create view
QGraphicsView* view = new QGraphicsView(&scene);
CGAL::Qt::GraphicsViewNavigation nav;
view->installEventFilter(&nav);
view->viewport()->installEventFilter(&nav);
view->setRenderHint(QPainter::Antialiasing);
//view->keyPressEvent();
//Show view
view->show();
return app.exec();
}
示例11: centroid
Point_2 centroid(const Polygon_2& P)
{
Point_2 sum(0,0);
BOOST_FOREACH (const Point_2& p, make_pair(P.vertices_begin(), P.vertices_end())) {
sum = Point_2(sum.x() + p.x(), sum.y() + p.y());
}
return Point_2(sum.x()/P.size(), sum.y()/P.size());
}
示例12: process
// This class is mainly used for scaling all the polys to
// a certain bounding box!
void PreProcessor::process(double xmin_target, double ymin_target, double width_target, double height_target) {
auto it = ++tree->element_tree.begin();
auto it_end = tree->element_tree.end();
Bbox_2 bb_final;
Bbox_2 bb;
int i = 0;
for(; it != it_end; ++it) {
switch((*it)->get_type()) {
case EL_POLYGON: {
Polygon_2 * p = &(static_cast<PolygonElementPtr *>(*it)->element);
bb = CGAL::bounding_box(p->vertices_begin(), p->vertices_end()).bbox();
}
case EL_FILLED_POLYGON:{
Polygon_2 * p = &(static_cast<FilledPolygonElementPtr *>(*it)->element.outer_boundary());
bb = CGAL::bounding_box(p->vertices_begin(), p->vertices_end()).bbox();
}
case EL_POLYLINE: {
PolyLine_P * p = &(static_cast<PolyLineElementPtr *>(*it)->element);
bb = CGAL::bounding_box(p->begin(), p->end()).bbox();
}
}
if(i == 0) {
bb_final = bb;
} else {
bb_final = bb_final + bb;
}
i++;
}
double w = bb_final.xmax() - bb_final.xmin();
double h = bb_final.ymax() - bb_final.ymin();
cout << "BB: " << bb_final.xmax()<< " " << bb_final.xmin() << " " << bb_final.ymax() << " " << bb_final.ymin() << endl;
if(GlobalOptions::getInstance().field_offset) {
width_target -= 2 * GlobalOptions::getInstance().field_offset;
height_target -= 2 * GlobalOptions::getInstance().field_offset;
}
double ws = (double)width_target / (double)w;
double hs = (double)height_target / (double)h;
double s = (ws < hs) ? ws : hs;
cout << "Scale: " << s << endl;
this->process(s,
bb_final.xmin() - GlobalOptions::getInstance().field_offset * 1 / s,
bb_final.ymin() - GlobalOptions::getInstance().field_offset * 1 / s); // -bb_final.xmin() -bb_final.ymin();
}
示例13: gnuplot_print_polygon
void gnuplot_print_polygon(std::ostream& out, const Polygon_2& P)
{
int prec = out.precision();
out << std::setprecision(pp_precision);
Polygon_2::Vertex_const_iterator vit;
for (vit = P.vertices_begin(); vit != P.vertices_end(); ++vit)
vit->insert(out) << std::endl;//" " << vit->z() << std::endl;
P.vertices_begin()->insert(out) << std::endl;//" " << P.vertices_begin()->z() << std::endl;
out.precision(prec);
}
示例14:
VisiLibity::Polygon ConvertPolygonCGAL2Vis(Polygon_2 pgn)
{
VisiLibity::Polygon cPoly;
Polygon_2::Vertex_iterator cv ;
for (cv=pgn.vertices_begin();cv!=pgn.vertices_end();++cv)
{
cPoly.push_back(VisiLibity::Point(cv->x(),cv->y()));
};
return cPoly;
}
示例15: pp
std::string pp(const Polygon_2& P)
{
Polygon_2::Vertex_const_iterator vit;
std::stringstream out;
out << std::setprecision(pp_precision);
out << "[ " << P.size() << " vertices:";
for (vit = P.vertices_begin(); vit != P.vertices_end(); ++vit)
out << pp(*vit);
out << " ]";
return out.str();
}