@@ -246,16 +246,30 @@ public class ReuseableDataContainer64 {
246246 private final List <LocalMinima > minimaList ;
247247 private final List <Vertex > vertexList ;
248248
249+ /**
250+ * Creates an empty container for reusable subject and clip path data.
251+ */
249252 public ReuseableDataContainer64 () {
250253 minimaList = new ArrayList <>();
251254 vertexList = new ArrayList <>();
252255 }
253256
257+ /**
258+ * Removes all cached path data from this container.
259+ */
254260 public void clear () {
255261 minimaList .clear ();
256262 vertexList .clear ();
257263 }
258264
265+ /**
266+ * Adds paths that can later be loaded into a {@link Clipper64} instance via
267+ * {@link Clipper64#addReuseableData(ReuseableDataContainer64)}.
268+ *
269+ * @param paths the paths to cache
270+ * @param pt the role these paths will play in the clipping operation
271+ * @param isOpen whether the cached paths should be treated as open paths
272+ */
259273 public void addPaths (Paths64 paths , PathType pt , boolean isOpen ) {
260274 ClipperEngine .AddPathsToVertexList (paths , pt , isOpen , minimaList , vertexList );
261275 }
@@ -342,6 +356,10 @@ static class VertexFlags {
342356
343357 }
344358
359+ /**
360+ * Creates a new clipping engine with {@linkplain #setPreserveCollinear(boolean)
361+ * collinear preservation} enabled by default.
362+ */
345363 protected ClipperBase () {
346364 minimaList = new ArrayList <>();
347365 intersectList = new ArrayList <>();
@@ -353,6 +371,11 @@ protected ClipperBase() {
353371 setPreserveCollinear (true );
354372 }
355373
374+ /**
375+ * Returns whether collinear vertices are preserved in closed-path solutions.
376+ *
377+ * @return {@code true} when collinear vertices are preserved where possible
378+ */
356379 public final boolean getPreserveCollinear () {
357380 return preserveCollinear ;
358381 }
@@ -370,10 +393,21 @@ public final void setPreserveCollinear(boolean value) {
370393 preserveCollinear = value ;
371394 }
372395
396+ /**
397+ * Returns whether solution path orientation is reversed before being output.
398+ *
399+ * @return {@code true} when closed and open solution paths are returned in
400+ * reverse order
401+ */
373402 public final boolean getReverseSolution () {
374403 return reverseSolution ;
375404 }
376405
406+ /**
407+ * Sets whether generated solution paths should use the reverse orientation.
408+ *
409+ * @param value {@code true} to reverse the orientation of generated paths
410+ */
377411 public final void setReverseSolution (boolean value ) {
378412 reverseSolution = value ;
379413 }
@@ -639,6 +673,10 @@ private static boolean EdgesAdjacentInAEL(IntersectNode inode) {
639673 return (inode .edge1 .nextInAEL == inode .edge2 ) || (inode .edge1 .prevInAEL == inode .edge2 );
640674 }
641675
676+ /**
677+ * Clears the current solution state while leaving the loaded subject and clip
678+ * paths unchanged.
679+ */
642680 protected final void ClearSolutionOnly () {
643681 while (actives != null ) {
644682 DeleteFromAEL (actives );
@@ -650,6 +688,9 @@ protected final void ClearSolutionOnly() {
650688 horzJoinList .clear ();
651689 }
652690
691+ /**
692+ * Removes all loaded paths together with any current solution state.
693+ */
653694 public final void clear () {
654695 ClearSolutionOnly ();
655696 minimaList .clear ();
@@ -659,6 +700,9 @@ public final void clear() {
659700 hasOpenPaths = false ;
660701 }
661702
703+ /**
704+ * Prepares the loaded input paths so another clipping operation can be executed.
705+ */
662706 protected final void Reset () {
663707 if (!isSortedMinimaList ) {
664708 minimaList .sort ((locMin1 , locMin2 ) -> Long .compare (locMin2 .vertex .pt .y , locMin1 .vertex .pt .y ));
@@ -705,6 +749,11 @@ private LocalMinima PopLocalMinima() {
705749 return minimaList .get (currentLocMin ++);
706750 }
707751
752+ /**
753+ * Adds a closed subject path.
754+ *
755+ * @param path the path to add
756+ */
708757 public final void addSubject (Path64 path ) {
709758 addPath (path , PathType .Subject );
710759 }
@@ -723,6 +772,11 @@ public final void addOpenSubject(Path64 path) {
723772 addPath (path , PathType .Subject , true );
724773 }
725774
775+ /**
776+ * Adds one or more open subject paths (polylines) to the Clipper object.
777+ *
778+ * @param paths the open subject paths to add
779+ */
726780 public final void addOpenSubject (Paths64 paths ) {
727781 paths .forEach (path -> addPath (path , PathType .Subject , true ));
728782 }
@@ -734,24 +788,55 @@ public final void addClip(Path64 path) {
734788 addPath (path , PathType .Clip );
735789 }
736790
791+ /**
792+ * Adds one or more clip polygons to the Clipper object.
793+ *
794+ * @param paths the clip polygons to add
795+ */
737796 public final void addClip (Paths64 paths ) {
738797 paths .forEach (path -> addPath (path , PathType .Clip ));
739798 }
740799
800+ /**
801+ * Adds a path as either a subject or clip polygon.
802+ *
803+ * @param path the path to add
804+ * @param polytype the role the path will play in the clipping operation
805+ */
741806 public final void addPath (Path64 path , PathType polytype ) {
742807 addPath (path , polytype , false );
743808 }
744809
810+ /**
811+ * Adds a path as either a closed polygon or an open path.
812+ *
813+ * @param path the path to add
814+ * @param polytype the role the path will play in the clipping operation
815+ * @param isOpen {@code true} when the path should be treated as open
816+ */
745817 public final void addPath (Path64 path , PathType polytype , boolean isOpen ) {
746818 Paths64 tmp = new Paths64 ();
747819 tmp .add (path );
748820 addPaths (tmp , polytype , isOpen );
749821 }
750822
823+ /**
824+ * Adds multiple closed subject or clip polygons.
825+ *
826+ * @param paths the paths to add
827+ * @param polytype the role the paths will play in the clipping operation
828+ */
751829 public final void addPaths (Paths64 paths , PathType polytype ) {
752830 addPaths (paths , polytype , false );
753831 }
754832
833+ /**
834+ * Adds multiple subject or clip paths.
835+ *
836+ * @param paths the paths to add
837+ * @param polytype the role the paths will play in the clipping operation
838+ * @param isOpen {@code true} when the paths should be treated as open
839+ */
755840 public final void addPaths (Paths64 paths , PathType polytype , boolean isOpen ) {
756841 if (isOpen ) {
757842 hasOpenPaths = true ;
@@ -760,6 +845,13 @@ public final void addPaths(Paths64 paths, PathType polytype, boolean isOpen) {
760845 ClipperEngine .AddPathsToVertexList (paths , polytype , isOpen , minimaList , vertexList );
761846 }
762847
848+ /**
849+ * Loads preprocessed path data created in a {@link ReuseableDataContainer64}.
850+ * Reusing cached data avoids rebuilding the internal vertex structures when the
851+ * same inputs are clipped repeatedly.
852+ *
853+ * @param reuseableData cached path data to load
854+ */
763855 protected void addReuseableData (ReuseableDataContainer64 reuseableData ) {
764856 if (reuseableData .minimaList .isEmpty ()) {
765857 return ;
@@ -1667,6 +1759,14 @@ private void AdjustCurrXAndCopyToSEL(long topY) {
16671759 }
16681760 }
16691761
1762+ /**
1763+ * Executes the core clipping algorithm for the currently loaded input paths.
1764+ * Subclasses call this before converting the generated solution into the desired
1765+ * output format.
1766+ *
1767+ * @param ct the clipping operation to perform
1768+ * @param fillRule the fill rule used during clipping
1769+ */
16701770 protected final void ExecuteInternal (ClipType ct , FillRule fillRule ) {
16711771 if (ct == ClipType .NoClip ) {
16721772 return ;
@@ -2783,6 +2883,15 @@ private void FixSelfIntersects(OutRec outrec) {
27832883 }
27842884 }
27852885
2886+ /**
2887+ * Converts a linked {@link OutPt} solution into a {@link Path64}.
2888+ *
2889+ * @param op the linked solution points to convert
2890+ * @param reverse whether to traverse the points in reverse order
2891+ * @param isOpen whether the source path is open
2892+ * @param path receives the converted path
2893+ * @return {@code true} when a non-degenerate path was produced
2894+ */
27862895 public static boolean buildPath (@ Nullable OutPt op , boolean reverse , boolean isOpen , Path64 path ) {
27872896 if (op == null || op .next == op || (!isOpen && op .next == op .prev )) {
27882897 return false ;
@@ -2820,6 +2929,13 @@ public static boolean buildPath(@Nullable OutPt op, boolean reverse, boolean isO
28202929 }
28212930 }
28222931
2932+ /**
2933+ * Builds closed and open path solutions from the current clipping result.
2934+ *
2935+ * @param solutionClosed receives closed solution paths
2936+ * @param solutionOpen receives open solution paths
2937+ * @return always {@code true}
2938+ */
28232939 protected final boolean BuildPaths (Paths64 solutionClosed , Paths64 solutionOpen ) {
28242940 solutionClosed .clear ();
28252941 solutionOpen .clear ();
@@ -2922,6 +3038,13 @@ private void RecursiveCheckOwners(OutRec outrec, PolyPathBase polypath) {
29223038 }
29233039 }
29243040
3041+ /**
3042+ * Builds a polygon tree, preserving parent-child nesting information, and
3043+ * collects any open solution paths.
3044+ *
3045+ * @param polytree receives the closed solution hierarchy
3046+ * @param solutionOpen receives open solution paths
3047+ */
29253048 protected void BuildTree (PolyPathBase polytree , Paths64 solutionOpen ) {
29263049 polytree .clear ();
29273050 solutionOpen .clear ();
@@ -2952,6 +3075,12 @@ protected void BuildTree(PolyPathBase polytree, Paths64 solutionOpen) {
29523075 }
29533076 }
29543077
3078+ /**
3079+ * Returns the bounding rectangle of all currently loaded input paths.
3080+ *
3081+ * @return the bounds of the loaded paths, or an empty rectangle when no paths
3082+ * have been added
3083+ */
29553084 public final Rect64 getBounds () {
29563085 Rect64 bounds = Clipper .InvalidRect64 .clone ();
29573086 for (Vertex t : vertexList ) {
0 commit comments