当前位置: 首页>>代码示例>>C++>>正文


C++ ring_type类代码示例

本文整理汇总了C++中ring_type的典型用法代码示例。如果您正苦于以下问题:C++ ring_type类的具体用法?C++ ring_type怎么用?C++ ring_type使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ring_type类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: linear_draw_circular_aperture

void GerberImporter::linear_draw_circular_aperture(point_type startpoint, point_type endpoint,
                                    coordinate_type radius, unsigned int circle_points, ring_type& ring)
{
    const coordinate_type dx = endpoint.x() - startpoint.x();
    const coordinate_type dy = endpoint.y() - startpoint.y();
    double angle_step;
    double offset;
    
    if (circle_points % 2 == 0)
        ++circle_points;

    if (startpoint.x() > endpoint.x())
        swap(startpoint, endpoint);

    angle_step = 2 * bg::math::pi<double>() / circle_points;
    
    if (dx == 0)
        offset = bg::math::pi<double>();
    else
        offset = atan(dy / dx) + bg::math::pi<double>() / 2;
    
    for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
        ring.push_back(point_type(cos(angle_step * i + offset) * radius + startpoint.x(),
                               sin(angle_step * i + offset) * radius + startpoint.y()));

    offset += bg::math::pi<double>();

    for (unsigned int i = 0; i < circle_points / 2 + 1; i++)
        ring.push_back(point_type(cos(angle_step * i + offset) * radius + endpoint.x(),
                               sin(angle_step * i + offset) * radius + endpoint.y()));
    
    bg::correct(ring);
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:33,代码来源:gerberimporter.cpp

示例2: linear_draw_rectangular_aperture

void GerberImporter::linear_draw_rectangular_aperture(point_type startpoint, point_type endpoint, coordinate_type width,
                                coordinate_type height, ring_type& ring)
{
    if (startpoint.y() > endpoint.y())
        swap(startpoint, endpoint);
    
    if (startpoint.x() > endpoint.x())
    {
        ring.push_back(point_type(startpoint.x() + width / 2, startpoint.y() + height / 2));
        ring.push_back(point_type(startpoint.x() + width / 2, startpoint.y() - height / 2));
        ring.push_back(point_type(startpoint.x() - width / 2, startpoint.y() - height / 2));
        ring.push_back(point_type(endpoint.x() - width / 2, endpoint.y() - height / 2));
        ring.push_back(point_type(endpoint.x() - width / 2, endpoint.y() + height / 2));
        ring.push_back(point_type(endpoint.x() + width / 2, endpoint.y() + height / 2));
    }
    else
    {
        ring.push_back(point_type(startpoint.x() + width / 2, startpoint.y() - height / 2));
        ring.push_back(point_type(startpoint.x() - width / 2, startpoint.y() - height / 2));
        ring.push_back(point_type(startpoint.x() - width / 2, startpoint.y() + height / 2));
        ring.push_back(point_type(endpoint.x() - width / 2, endpoint.y() + height / 2));
        ring.push_back(point_type(endpoint.x() + width / 2, endpoint.y() + height / 2));
        ring.push_back(point_type(endpoint.x() + width / 2, endpoint.y() - height / 2));
    }

    bg::correct(ring);   
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:27,代码来源:gerberimporter.cpp

示例3: draw_regular_polygon

void GerberImporter::draw_regular_polygon(point_type center, coordinate_type diameter, unsigned int vertices,
                            coordinate_type offset, bool clockwise, ring_type& ring)
{
    double angle_step;
    
    if (clockwise)
        angle_step = -2 * bg::math::pi<double>() / vertices;
    else
        angle_step = 2 * bg::math::pi<double>() / vertices;

    offset *= bg::math::pi<double>() / 180.0;

    for (unsigned int i = 0; i < vertices; i++)
       ring.push_back(point_type(cos(angle_step * i + offset) * diameter / 2 + center.x(),
                        sin(angle_step * i + offset) * diameter / 2 + center.y()));

    ring.push_back(ring.front());
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:18,代码来源:gerberimporter.cpp

示例4: copy_ring

void Voronoi::copy_ring(const ring_type& ring, vector<segment_type_p> &segments)
{
    for (auto iter = ring.begin(); iter + 1 != ring.end(); iter++)
        segments.push_back(segment_type_p(point_type_p(iter->x(), iter->y()),
                                        point_type_p((iter + 1)->x(), (iter + 1)->y())));
}
开发者ID:chrysn-pull-requests,项目名称:pcb2gcode,代码行数:6,代码来源:voronoi.cpp

示例5: simplify_cutins

bool GerberImporter::simplify_cutins(ring_type& ring, polygon_type& polygon)
{
    for (int i = 0; i < int(ring.size()) - 2; i++)
    {
        for (int j = i + 1; j < int(ring.size()) - 1; j++)
        {
            if (bg::equals(ring.at(i), ring.at(j + 1)) &&
                bg::equals(ring.at(i + 1), ring.at(j)))
            {
                polygon.inners().resize(polygon.inners().size() + 1);
                polygon.inners().back().resize(j - i); 
                copy(ring.begin() + i + 1, ring.begin() + j + 1, polygon.inners().back().begin());
                ring.erase(ring.begin() + i + 1, ring.begin() + j + 2);
                break;
            }
        }
    }
    
    if (polygon.inners().size() > 0)
    {
        if (&ring != &(polygon.outer()))
        {
            polygon.outer().resize(ring.size());
            copy(ring.begin(), ring.end(), polygon.outer().begin());
        }
        bg::correct(polygon);

        return true;
    }
    else
        return false;
}
开发者ID:corna,项目名称:pcb2gcode,代码行数:32,代码来源:gerberimporter.cpp

示例6: multipolygon_add_location

 void multipolygon_add_location(const osmium::geom::Coordinates& xy) {
     assert(!!m_polygon);
     assert(!!m_ring);
     m_ring->addPoint(xy.x, xy.y);
 }
开发者ID:openstreetmap,项目名称:osm2pgsql,代码行数:5,代码来源:ogr.hpp

示例7: multipolygon_inner_ring_finish

 void multipolygon_inner_ring_finish() {
     assert(!!m_polygon);
     assert(!!m_ring);
     m_polygon->addRingDirectly(m_ring.release());
 }
开发者ID:openstreetmap,项目名称:osm2pgsql,代码行数:5,代码来源:ogr.hpp

示例8: multipolygon_inner_ring_start

 void multipolygon_inner_ring_start() {
     m_ring.reset(new OGRLinearRing{});
 }
开发者ID:openstreetmap,项目名称:osm2pgsql,代码行数:3,代码来源:ogr.hpp

示例9: polygon_finish

 polygon_type polygon_finish(size_t /* num_points */) {
     auto polygon = std::unique_ptr<OGRPolygon>{new OGRPolygon{}};
     polygon->addRingDirectly(m_ring.release());
     return polygon;
 }
开发者ID:openstreetmap,项目名称:osm2pgsql,代码行数:5,代码来源:ogr.hpp

示例10: polygon_start

 void polygon_start() {
     m_ring.reset(new OGRLinearRing{});
 }
开发者ID:openstreetmap,项目名称:osm2pgsql,代码行数:3,代码来源:ogr.hpp

示例11: multipolygon_outer_ring_start

 void multipolygon_outer_ring_start() {
     m_ring.reset(new OGRLinearRing());
 }
开发者ID:7ute,项目名称:osrm-backend,代码行数:3,代码来源:ogr.hpp


注:本文中的ring_type类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。