Example #1
0
void PlaneExt::ConcaveHullJoinCurrent(pcl::PointCloud<pcl::PointXYZ>::Ptr &plane_hull, tVertices &polygon_indices)
{
	// Join new polygon with current
	ClipperLib::ExPolygons newPoly = PolygonizeConcaveHull(plane_hull, polygon_indices);

	ClipperLib::Clipper clipper;
	// insert all existing polygons
	for (unsigned int i = 0; i < planePolygonsClipper.size(); ++i)
		clipper.AddPolygon(planePolygonsClipper[i].outer, ClipperLib::ptSubject);

	// insert all new polygons
	for (unsigned int i = 0; i < newPoly.size(); ++i)
		clipper.AddPolygon(newPoly[i].outer, ClipperLib::ptClip);

	// execute join operation
	clipper.Execute(ClipperLib::ctUnion, planePolygonsClipper);
}
Example #2
0
void PolyMesh::chopPoly(const Polygon & rect, int pid,ClipperLib::ClipType ct)
{
  ClipperLib::Clipper c;
  c.AddPolygon(poly[pid][0],ClipperLib::ptSubject);
  c.AddPolygon(rect,ClipperLib::ptClip);
  Polygons solution;
  bool ret = c.Execute(ct,solution);
  if(solution.size()<1) {
    std::cout<<"ret "<<ret<<" "<<pid<<" is completely clipped\n";
  } else {
    std::cout<<"plane "<<pid<<"\n";
    std::cout<<"soln size "<<solution.size()<<"\n";
    size_t maxsize=solution[0].size();
    int maxidx=0;
    for(size_t jj=1; jj<solution.size(); jj++) {
      if(solution[jj].size()>maxsize) {
        maxsize=solution[jj].size();
        maxidx=jj;
      }
    }
    poly[pid][0]=solution[maxidx];
  }
}