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

Move out the config checks at the start of triangulate into their own function #162

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/algorithms/triangulation/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ function triangulate(points::P;
polygonise_n=4096,
coarse_n=0,
enrich=false) where {P,I,E,V,Es,Ts,M,H}
number_type(points) == Float64 || @warn "Using non-Float64 coordinates may cause issues. If you run into problems, consider using Float64 coordinates." maxlog=1
is_weighted(weights) && throw(ArgumentError("Weighted triangulations are not yet fully implemented."))
is_constrained = !(isnothing(segments) || isempty(segments)) || !(isnothing(boundary_nodes) || !has_boundary_nodes(boundary_nodes))
is_weighted(weights) && is_constrained && throw(ArgumentError("You cannot compute a constrained triangulation with weighted points."))
check_config(points, weights, segments, boundary_nodes)
if enrich || (isempty(boundary_curves) && is_curve_bounded(boundary_nodes)) # If boundary_curves is not empty, then we are coming from triangulate_curve_bounded
return triangulate_curve_bounded(points; segments, boundary_nodes, weights, IntegerType, EdgeType, TriangleType, EdgesType, TrianglesType, randomise, delete_ghosts, delete_empty_features, try_last_inserted_point, skip_points, num_sample_rule, rng, insertion_order, recompute_representative_points, delete_holes, check_arguments, polygonise_n, coarse_n)
end
Expand All @@ -144,6 +141,14 @@ function triangulate(points::P;
recompute_representative_points, delete_holes, full_polygon_hierarchy, delete_ghosts, delete_empty_features)
end

function check_config(points, weights, segments, boundary_nodes)
number_type(points) == Float64 || @warn "Using non-Float64 coordinates may cause issues. If you run into problems, consider using Float64 coordinates." maxlog=1
is_weighted(weights) && throw(ArgumentError("Weighted triangulations are not yet fully implemented."))
is_constrained = !(isnothing(segments) || isempty(segments)) || !(isnothing(boundary_nodes) || !has_boundary_nodes(boundary_nodes))
is_weighted(weights) && is_constrained && throw(ArgumentError("You cannot compute a constrained triangulation with weighted points."))
return nothing
end

function _triangulate!(tri::Triangulation, segments, boundary_nodes, randomise, try_last_inserted_point, skip_points, num_sample_rule, rng, insertion_order,
recompute_representative_points, delete_holes, full_polygon_hierarchy, delete_ghosts, delete_empty_features)
unconstrained_triangulation!(tri; randomise, try_last_inserted_point, skip_points, num_sample_rule, rng, insertion_order)
Expand Down
Loading