Exemplo n.º 1
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);
    }
}
Exemplo n.º 2
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());
        }
Exemplo n.º 3
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());
        }
Exemplo n.º 4
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());
 }