Exemple #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);
    }
}
Exemple #2
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());
 }