Skip to content

InflatePath creates unwanted additional vertices #390

Description

@ccoustet

Hi everyone,
I stumbled on the following polygon, that when inflated, has new vertices that I cannot understand.

PathsD polyline, solution;
PointD coords[] = {
  {1427.13, 1415.78},
  {1423.51, 1416.30},
  {1419.52, 1416.89},
  {1402.45, 1419.34},
  {1403.26, 1429.07},
  {1403.63, 1433.62},
  {1421.66, 1430.96},
  {1422.90, 1430.86},
  {1423.08, 1430.76},
  {1423.88, 1438.85},
  {1429.36, 1438.44},
  {1429.45, 1438.95},
  {1441.12, 1437.52},
  {1439.33, 1414.04}
};
polyline.push_back(PathD(std::begin(coords), std::end(coords)));
std::cout << polyline[0].size() << std::endl;
std::cout << polyline[0];
std::cout << "----" << std::endl;
// offset polyline
solution = InflatePaths(polyline, -0.2, JoinType::Miter, EndType::Polygon, 2 , 6);
std::cout << solution[0].size() << std::endl;
std::cout << solution[0];
std::cout << "----" << std::endl;

14
1427.13,1415.78 , 1423.51,1416.3 , 1419.52,1416.89 , 1402.45,1419.34 , 1403.26,1429.07 , 1403.63,1433.62 , 1421.66,1430.96 , 1422.9,1430.86 , 1423.08,1430.76 , 1423.88,1438.85 , 1429.36,1438.44 , 1429.45,1438.95 , 1441.12,1437.52 , 1439.33,1414.04 
----
17
1439.15,1414.27 , 1427.16,1415.98 , 1427.16,1415.98 , 1423.54,1416.5 , 1419.55,1417.09 , 1419.55,1417.09 , 1402.66,1419.51 , 1403.46,1429.05 , 1403.46,1429.05 , 1403.81,1433.39 , 1421.64,1430.76 , 1422.84,1430.66 , 1423.25,1430.44 , 1424.06,1438.64 , 1429.53,1438.23 , 1429.61,1438.73 , 1440.91,1437.34 

With precision=2 the resulting polygon has 14 vertices, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions