Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algorithm + manifold and accelerator passthrough in clipping functions #273

Open
wants to merge 9 commits into
base: as/adaptivepredicates
Choose a base branch
from

Conversation

asinghvi17
Copy link
Member

@asinghvi17 asinghvi17 commented Mar 4, 2025

Spun out from #259
Parent: #275 (adaptive predicates)
Child PRs: #274 (trees)

  • Create a FosterHormannClipping(manifold, accelerator)algorithm - we can bikeshed the name
  • Pass the algorithm, manifold, and accelerator (will be used in Tree based acceleration for polygon clipping / boolean ops #274) all the way through to the base level methods which we can define different dispatches for.
  • Add a tracing error type TracingError that actually stores all the context including a_list and b_list, this way we can more effectively diagnose what's going on.

Copy link
Member Author

asinghvi17 commented Mar 4, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Copy link
Member

@rafaqz rafaqz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but have to remove line breaks between methods of the same function 😆

struct DoubleSTRtree <: IntersectionAccelerator end
struct SingleNaturalTree <: IntersectionAccelerator end
struct DoubleNaturalTree <: IntersectionAccelerator end
struct ThinnedDoubleNaturalTree <: IntersectionAccelerator end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the only one with thinning?

Wondering if it can be a type parameter

"""
FosterHormannClipping{M <: Manifold, A <: Union{Nothing, Accelerator}} <: GeometryOpsCore.Algorithm{M}

A type that represents the Foster-Hormann clipping algorithm.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A type that represents the Foster-Hormann clipping algorithm.
Applies the Foster-Hormann clipping algorithm.

Comment on lines +48 to +49


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

_cut(T, GI.trait(geom), geom, GI.trait(line), line; exact = True())
cut(geom, line, ::Type{T} = Float64) where {T <: AbstractFloat} = cut(FosterHormannClipping(), geom, line, T)
cut(m::Manifold, geom, line, ::Type{T} = Float64) where {T <: AbstractFloat} = cut(FosterHormannClipping(m), geom, line, T)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

) where {T<:AbstractFloat}
return _difference(
TraitTarget(target), T, GI.trait(geom_a), geom_a, GI.trait(geom_b), geom_b;
alg, TraitTarget(target), T, GI.trait(geom_a), geom_a, GI.trait(geom_b), geom_b;
exact = True(), kwargs...,
)
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

) where T
return UnionIntersectingPolygons(#=TODO: alg.manifold=#)(GI.MultiPolygon([poly_a, poly_b]))
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

return GI.MultiPolygon(res)
end
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

) where T
union(alg, poly_b, multipoly_a; target, fix_multipoly, kwargs...)
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

) where T
return GI.MultiPolygon(_union(alg, TraitTarget{GI.PolygonTrait}(), T, trait_a, multipoly_a, trait_b, multipoly_b; fix_multipoly, kwargs...))
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -526,6 +526,11 @@ function _point_filled_curve_orientation(
return iseven(k) ? out : in
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Not sure of name (too verbose, maybe Foster()?).  Intersection accelerators will come into the picture later (next PR) but we need them now to instantiate the struct.
Better than printing out since we can (A) check on it and (B) access the polygons as well as the a_list and b_list in Julia.  I have a few plot recipes for them but not sure if they are worth putting in a Makie extension...they would also be inaccessible there.  Maybe in GeoMakie?  Then we can make full use of customizations etc.
This is a shorter change list as a sampler, to show what needs to happen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants