Esempio n. 1
0
 void operator()(const linestring_type& _a, const segment_type& _b, output_type& _out, JUNCTION _j)
 {
   if (_a.empty())
   {
     _out.push_back(_a.front());
     _out.push_back(_a.back());
     return;
   }
   _out.insert(_out.end(),_a.begin(),_a.end()-1);
   _j(_a,_b,_out);
   _out.push_back(_b.back());
 }
Esempio n. 2
0
void GerberImporter::circular_arc(point_type center, coordinate_type radius,
                    double angle1, double angle2, unsigned int circle_points,
                    linestring_type& linestring)
{
    const unsigned int steps = ceil((angle2 - angle1) / (2 * bg::math::pi<double>()) * circle_points);
    const double angle_step = (angle2 - angle1) / steps;
    
    for (unsigned int i = 0; i < steps; i++)
    {
        const double angle = angle1 + i * angle_step;

        linestring.push_back(point_type(cos(angle) * radius + center.x(),
                                        sin(angle) * radius + center.y()));
    }
    
    linestring.push_back(point_type(cos(angle2) * radius + center.x(),
                                    sin(angle2) * radius + center.y()));
}
Esempio n. 3
0
        void operator()(linestring_type& _a, const linestring_type& _b, JUNCTION _j)
        {
          if (_b.empty())
          {
            return;
          }
          if (_a.empty())
          {
            _a = _b;
            return;
          }

          _j(_a,_b,_a);
          _a.insert(_a.end(),_b.begin()+1,_b.end());
        }
Esempio n. 4
0
        void operator()(const linestring_type& _a, const linestring_type& _b, output_type& _output, JUNCTION _j)
        {
          if (_a.empty())
          {
            _output = _b;
            return;
          }
          if (_b.empty())
          {
            _output = _a;
            return;
          }

          _output.insert(_output.end(),_a.begin(),_a.end()-1);
          _j(_a,_b,_output);
          _output.insert(_output.end(),_b.begin()+1,_b.end());
        }
Esempio n. 5
0
void GerberImporter::merge_paths(multi_linestring_type &destination, const linestring_type& source)
{
    if (!destination.empty())
    {
        multi_linestring_type::reverse_iterator ls;

        for (ls = destination.rbegin(); ls != destination.rend(); ls++)
        {
            if (bg::equals(ls->back(), source.front()))
            {
                ls->insert(ls->end(), source.begin() + 1, source.end());
                break;
            }
            else if (bg::equals(ls->back(), source.back()))
            {
                ls->insert(ls->end(), source.rbegin() + 1, source.rend());
                break;
            }

            /*
             * The following two cases does not happen very often, and they
             * usually happen when the size of destination is small (often 2),
             * therefore there shouldn't be the need to replace a standard
             * linestring_type (std::vector) with a std::deque
             */
            else if (bg::equals(ls->front(), source.front()))
            {
                reverse(ls->begin(), ls->end());
                ls->insert(ls->end(), source.begin() + 1, source.end());
                break;
            }
            else if (bg::equals(ls->front(), source.back()))
            {
                reverse(ls->begin(), ls->end());
                ls->insert(ls->end(), source.rbegin() + 1, source.rend());
                break;
            }
        }

        if (ls == destination.rend())
        {
            destination.push_back(source);
        }
    }
    else
    {
        destination.push_back(source);
    }
}
Esempio n. 6
0
 void linestring_add_location(const osmium::geom::Coordinates& xy) {
     assert(!!m_linestring);
     m_linestring->addPoint(xy.x, xy.y);
 }
Esempio n. 7
0
 void linestring_start() {
     m_linestring.reset(new OGRLineString{});
 }