public VertexStore MakeVxs(VertexStore output) { using (VectorToolBox.Borrow(output, out PathWriter pw)) { MakeVxs(pw); } return(output); }
// void CombinePathsInternal( VertexStore a, VertexStore b, VxsClipperType vxsClipType, bool separateIntoSmallSubPaths, List <VertexStore> resultList) { //prepare instance //reset all used fields ClipType clipType = (ClipType)vxsClipType; CreatePolygons(a, _aPolys); CreatePolygons(b, _bPolys); _clipper.AddPaths(_aPolys, PolyType.ptSubject, true); _clipper.AddPaths(_bPolys, PolyType.ptClip, true); _clipper.Execute(clipType, _intersectedPolys); if (separateIntoSmallSubPaths) { foreach (List <IntPoint> polygon in _intersectedPolys) { int j = polygon.Count; if (j > 0) { //first one IntPoint point = polygon[0]; using (VxsTemp.Borrow(out VertexStore v1)) using (VectorToolBox.Borrow(v1, out PathWriter pw)) { pw.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; pw.LineTo(point.X / 1000.0, point.Y / 1000.0); } } pw.CloseFigure(); resultList.Add(v1.CreateTrim()); //copy pw.Clear(); } } } } else { using (VxsTemp.Borrow(out VertexStore v1)) using (VectorToolBox.Borrow(v1, out PathWriter pw)) { foreach (List <IntPoint> polygon in _intersectedPolys) { int j = polygon.Count; if (j > 0) { //first one IntPoint point = polygon[0]; pw.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; pw.LineTo(point.X / 1000.0, point.Y / 1000.0); } } pw.CloseFigure(); } } pw.Stop(); resultList.Add(v1.CreateTrim()); } } }
// VertexStore CombinePathsInternal( VertexStore a, VertexStore b, VxsClipperType vxsClipType, bool separateIntoSmallSubPaths, List <VertexStore> resultList) { //prepare instance //reset all used fields ClipType clipType = (ClipType)vxsClipType; CreatePolygons(a, _aPolys); CreatePolygons(b, _bPolys); _clipper.AddPaths(_aPolys, PolyType.ptSubject, true); _clipper.AddPaths(_bPolys, PolyType.ptClip, true); _clipper.Execute(clipType, _intersectedPolys); if (separateIntoSmallSubPaths) { VertexStore firstOutput = null; //in this case we expect that resultList must not be null*** foreach (List <IntPoint> polygon in _intersectedPolys) { int j = polygon.Count; //*** if (j > 0) { //first one IntPoint point = polygon[0]; using (VxsTemp.Borrow(out VertexStore v1)) using (VectorToolBox.Borrow(v1, out PathWriter pw)) { pw.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; pw.LineTo(point.X / 1000.0, point.Y / 1000.0); } } pw.CloseFigure(); VertexStore result = v1.CreateTrim(); if (firstOutput == null) { firstOutput = result; } resultList.Add(result); //copy pw.Clear(); } } } return(firstOutput); } else { using (VxsTemp.Borrow(out var v1)) using (VectorToolBox.Borrow(v1, out PathWriter pw)) { foreach (List <IntPoint> polygon in _intersectedPolys) { int j = polygon.Count; if (j > 0) { //first one IntPoint point = polygon[0]; pw.MoveTo(point.X / 1000.0, point.Y / 1000.0); //next others ... if (j > 1) { for (int i = 1; i < j; ++i) { point = polygon[i]; pw.LineTo(point.X / 1000.0, point.Y / 1000.0); } } pw.CloseFigure(); } } pw.Stop(); VertexStore output = v1.CreateTrim(); if (resultList != null) { resultList.Add(output);//also add to here } return(output); } } }