本文整理汇总了C++中Polygon_2::vertex方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon_2::vertex方法的具体用法?C++ Polygon_2::vertex怎么用?C++ Polygon_2::vertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polygon_2
的用法示例。
在下文中一共展示了Polygon_2::vertex方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _buildingWall
void _buildingWall( const Polygon_2& ring, const Kernel::FT& wallHeight, PolyhedralSurface& shell )
{
size_t npt = ring.size() ;
for ( size_t i = 0; i < npt; i++ ) {
const Point_2& a = ring.vertex( i ) ;
const Point_2& b = ring.vertex( ( i+1 ) % npt ) ;
LineString wallRing ;
wallRing.addPoint( new Point( a.x(), a.y(), Kernel::FT( 0 ) ) );
wallRing.addPoint( new Point( b.x(), b.y(), Kernel::FT( 0 ) ) );
wallRing.addPoint( new Point( b.x(), b.y(), wallHeight ) );
wallRing.addPoint( new Point( a.x(), a.y(), wallHeight ) );
wallRing.addPoint( new Point( a.x(), a.y(), Kernel::FT( 0 ) ) );
shell.addPolygon( Polygon( wallRing ) );
}
}
示例2: flip
Polygon_2 CollisionDetector::flip(const Polygon_2& robot)
{
m_translate_helper.resize(0);
for(int i = 0; i < robot.size(); ++i)
{
Vector_2 minus_p = CGAL::ORIGIN - robot.vertex(i);
m_translate_helper.push_back(Point_2(minus_p.x(),minus_p.y()));
}
return Polygon_2(m_translate_helper.begin(), m_translate_helper.end());
}
示例3: splitter
Pwh_list_2 GDALParceling::splitter(Polygon_2 &rect)
{
Pwh_list_2 ress;
Point_2 p1 = rect.vertex(0);
Point_2 p2 = rect.vertex(1);
Point_2 p3 = rect.vertex(2);
Point_2 p4 = rect.vertex(3);
Vector_2 v1 = (p2-p1)/2;
Vector_2 v2 = (p3-p2)/2;
bool v1_bigger = true;
if (v1.squared_length() < v2.squared_length()) {
v1_bigger = false;
}
//Left
if (v1_bigger && v1.squared_length() >= this->length*this->length) {
split_left(p3, ress, p2, p4, p1, v1);
return ress;
}
if (!v1_bigger && v2.squared_length() >= this->length*this->length) {
split_up(ress, p3, p1, p4, v2, p2);
return ress;
}
if (v1_bigger && v2.squared_length() >= this->width*this->width){
split_up(ress, p3, p1, p4, v2, p2);
return ress;
}
if (!v1_bigger && v1.squared_length() >= this->width*this->width){
split_left(p3, ress, p2, p4, p1, v1);
return ress;
}
return ress;
}
示例4: alpha_shape
int alpha_shape(vertex_t *vertices, size_t count, double alpha,
vertex_t **res, size_t *res_count, char **err_msg)
{
try {
std::list<Point> points;
{
std::vector<Point> pv;
for (std::size_t j = 0; j < count; ++j) {
Point p(vertices[j].x, vertices[j].y);
pv.push_back(p);
}
std::sort(pv.begin(), pv.end(),
[](const Point &e1, const Point &e2)->bool {
return e2.y() < e1.y();
});
std::stable_sort(pv.begin(), pv.end(),
[](const Point &e1, const Point &e2)->bool {
return e2.x() < e1.x();
});
pv.erase(std::unique(pv.begin(), pv.end()), pv.end());
if (pv.size() != count && pv.size() < 3) {
*err_msg = strdup("After eliminating duplicated points, less than 3 points remain!!. Alpha shape calculation needs at least 3 vertices.");
return -1;
}
points.insert(points.begin(), pv.begin(), pv.end());
}
Alpha_shape_2 A(points.begin(), points.end(),
coord_type(10000),
Alpha_shape_2::REGULARIZED);
std::vector<Segment> segments;
// std::vector<Segment> result;
// Alpha_shape_2::Alpha_shape_vertices_iterator vit;
// Alpha_shape_2::Vertex_handle vertex;
// Alpha_shape_2::Alpha_shape_edges_iterator eit;
// Alpha_shape_2::Edge edge;
// Alpha_shape_2::Face_iterator fit;
// Alpha_shape_2::Face_handle face;
if (alpha <= 0.0)
{
alpha = *A.find_optimal_alpha(1);
}
A.set_alpha(alpha);
alpha_edges( A, std::back_inserter(segments));
// Segment s = segments.at(0);
// find_next_edge(s, segments, result);
if (segments.empty())
{
*res = NULL;
*res_count = 0;
}
else
{
std::set<int> unusedIndexes;
for (unsigned int i = 0; i < segments.size(); i++)
{
unusedIndexes.insert(i);
}
std::vector<Polygon_2> rings;
Polygon_2 ring;
ring.push_back(segments.at(0).source());
rings.push_back(ring);
unusedIndexes.erase(0);
find_next_edge(segments.at(0), segments, unusedIndexes, rings);
size_t result_count = 0;
for (unsigned int i = 0; i < rings.size(); i++)
{
Polygon_2 ring = rings.at(i);
result_count += ring.size();
}
result_count += rings.size() - 1;
*res = (vertex_t *) malloc(sizeof(vertex_t) * result_count);
*res_count = result_count;
int idx = 0;
for (unsigned int i = 0; i < rings.size(); i++)
{
if (i > 0)
{
(*res)[idx].x = DBL_MAX;
(*res)[idx].y = DBL_MAX;
idx++;
}
Polygon_2 ring = rings.at(i);
for(unsigned int j = 0; j < ring.size(); j++)
{
Point point = ring.vertex(j);
(*res)[idx].x = point.x();
(*res)[idx].y = point.y();
idx++;
//.........这里部分代码省略.........