Blender V5.3
blender::ed::greasepencil::boolean Namespace Reference

Classes

struct  BooleanResult
struct  CurveBooleanOpParameters
class  WindingState

Typedefs

using ProjectionFunc = FunctionRef<float2(const float3)>

Enumerations

enum class  Operation : int8_t { Intersect , Union , Difference }

Functions

static float point_in_tri_winding (const float2 pt, const float2 v1, const float2 v2, const float2 v3)
static int point_in_polygon_winding_twice (const float2 &point, const Span< float2 > poly)
static int point_in_polygon_winding_int (const float2 &point, const Span< float2 > poly)
static std::pair< WindingState, WindingState > LR_states_from_segment (const Segment &segment, const Span< float2 > all_positions, const OffsetIndices< int > points_by_curve, const GroupedSpan< int > shapes, const IndexMask &mask_shapes, const VArray< bool > &is_fill)
static void get_inside_states_for_segments (const CurveBooleanOpParameters &op_params, const int curve_k, const bool is_subj, const int subj_shape_i, const Span< float2 > points, const GroupedSpan< int > shapes, const OffsetIndices< int > points_by_curve, const IndexMask &clipping_shapes, const Span< Segment > all_segments, const OffsetIndices< int > segments_by_curve, const VArray< bool > &is_fill, MutableSpan< bool > all_inside_left, MutableSpan< bool > all_inside_right)
static void separate_fill_islands (bke::CurvesGeometry &dst, const Span< bool > unchanged_curves, const ProjectionFunc project_fn)
static int intersect (const float2 &P1, const float2 &P2, const float2 &Q1, const float2 &Q2, float *r_alpha_P, float *r_alpha_Q)
static void find_intersections_between_curves (const Span< float2 > points_i, const Span< float2 > points_j, const int curve_i, const int curve_j, const bool cyclic_i, const bool cyclic_j, const int point_offset_i, const int point_offset_j, Array< Vector< int > > &r_inters_per_curves, Vector< IntersectionPoint > &r_intersections)
static void find_intersections_between_shapes (const Span< float2 > points, const GroupedSpan< int > shapes, const IndexMask &shapes_i, const IndexMask &shapes_j, const OffsetIndices< int > points_by_curve, const VArray< bool > &cyclic, const bool self_intersection, Array< Vector< int > > &r_inters_per_curves, Vector< IntersectionPoint > &r_intersections)
static void create_connections_from_intersection_points (const Span< IntersectionPoint > &intersections, const Span< bool > &segments_to_keep, MutableSpan< SegmentConnections > segment_connections)
static BooleanResult execute_single_boolean (const CurveBooleanOpParameters op_params, const int subj_shape_id, const Span< float2 > points, const GroupedSpan< int > shapes, const OffsetIndices< int > points_by_curve, const IndexMask &clipping_shapes, const VArray< bool > &is_fill, const VArray< bool > &cyclic)
static Array< bool > calculate_unchanged_curves (const Span< Segment > segments, const Span< bool > is_segments_clipping, const OffsetIndices< int > segment_offsets)
static BooleanResult execute_boolean (const CurveBooleanOpParameters op_params, const Span< float2 > positions_2d, const OffsetIndices< int > points_by_curve, const IndexMask &editable_shapes, const IndexMask &clipping_shapes, const GroupedSpan< int > shapes, const VArray< int > &fill_ids, const VArray< bool > &is_cyclic)
static bke::CurvesGeometry create_curves_from_segments (const bke::CurvesGeometry &src, const Span< Segment > segments, const Span< bool > segment_reversed, const Span< bool > cyclic, const Span< bool > is_segments_clipping, const Span< int > dst_to_src_curves, const OffsetIndices< int > segment_offsets, const Span< bool > unchanged_curves, const bool skip_clipping_attributes, Vector< bool > &r_is_point_clipping)
static float4 transform_plane (const float4x4 &mat, const float4 &plane)
bke::CurvesGeometry curve_boolean (const CurveBooleanOpParameters op_params, const bke::CurvesGeometry &curves, const ProjectionFunc project_fn, const GroupedSpan< int > shapes, const IndexMask &editable_shapes, const IndexMask &clipping_shapes)
bke::CurvesGeometry curve_boolean_with_planes (const CurveBooleanOpParameters op_params, const bke::CurvesGeometry &curves, const ProjectionFunc project_fn, const GroupedSpan< int > shapes, const Span< float4 > curve_planes, const IndexMask &editable_shapes, const IndexMask &clipping_shapes, const float4x4 &layer_to_world, const ARegion &region)

Variables

constexpr float epsilon_distance = 0.01f
constexpr float epsilon_factor = 0.05f
constexpr float mid_point_factor = 0.35421f

Typedef Documentation

◆ ProjectionFunc

Enumeration Type Documentation

◆ Operation

Enumerator
Intersect 
Union 
Difference 

Definition at line 987 of file ED_grease_pencil.hh.

Function Documentation

◆ calculate_unchanged_curves()

Array< bool > blender::ed::greasepencil::boolean::calculate_unchanged_curves ( const Span< Segment > segments,
const Span< bool > is_segments_clipping,
const OffsetIndices< int > segment_offsets )
static

◆ create_connections_from_intersection_points()

◆ create_curves_from_segments()

bke::CurvesGeometry blender::ed::greasepencil::boolean::create_curves_from_segments ( const bke::CurvesGeometry & src,
const Span< Segment > segments,
const Span< bool > segment_reversed,
const Span< bool > cyclic,
const Span< bool > is_segments_clipping,
const Span< int > dst_to_src_curves,
const OffsetIndices< int > segment_offsets,
const Span< bool > unchanged_curves,
const bool skip_clipping_attributes,
Vector< bool > & r_is_point_clipping )
static

Definition at line 958 of file grease_pencil_boolean.cc.

References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), blender::Vector< T, InlineBufferCapacity, Allocator >::append_n_times(), blender::Vector< T, InlineBufferCapacity, Allocator >::as_span(), attribute, blender::bke::attribute_filter_from_skip_ref(), blender::bke::CurvesGeometry::attributes(), blender::bke::CurvesGeometry::attributes_for_write(), create_curves_from_segments(), blender::bke::Curve, blender::bke::CurvesGeometry::cyclic(), blender::bke::CurvesGeometry::cyclic_for_write(), blender::offset_indices::OffsetIndices< T >::data(), blender::ed::greasepencil::End, blender::IndexRange::first(), blender::index_mask::IndexMask::foreach_index(), blender::index_mask::IndexMask::foreach_range(), blender::IndexRange::from_begin_size(), blender::IndexMask::from_bools(), blender::bke::gather_attributes(), blender::IndexRange::index_range(), blender::offset_indices::OffsetIndices< T >::index_range(), blender::Array< T, InlineBufferCapacity, Allocator >::last(), blender::IndexRange::last(), blender::bke::CurvesGeometry::offsets_for_write(), blender::bke::Point, blender::bke::CurvesGeometry::points_by_curve(), blender::bke::retrieve_attributes_for_transfer(), blender::IndexRange::shift(), blender::IndexRange::size(), blender::offset_indices::OffsetIndices< T >::size(), blender::ed::greasepencil::Start, T, blender::bke::attribute_math::to_static_type(), and blender::offset_indices::OffsetIndices< T >::total_size().

Referenced by create_curves_from_segments(), curve_boolean(), and curve_boolean_with_planes().

◆ curve_boolean()

◆ curve_boolean_with_planes()

◆ execute_boolean()

◆ execute_single_boolean()

◆ find_intersections_between_curves()

void blender::ed::greasepencil::boolean::find_intersections_between_curves ( const Span< float2 > points_i,
const Span< float2 > points_j,
const int curve_i,
const int curve_j,
const bool cyclic_i,
const bool cyclic_j,
const int point_offset_i,
const int point_offset_j,
Array< Vector< int > > & r_inters_per_curves,
Vector< IntersectionPoint > & r_intersections )
static

◆ find_intersections_between_shapes()

void blender::ed::greasepencil::boolean::find_intersections_between_shapes ( const Span< float2 > points,
const GroupedSpan< int > shapes,
const IndexMask & shapes_i,
const IndexMask & shapes_j,
const OffsetIndices< int > points_by_curve,
const VArray< bool > & cyclic,
const bool self_intersection,
Array< Vector< int > > & r_inters_per_curves,
Vector< IntersectionPoint > & r_intersections )
static

◆ get_inside_states_for_segments()

void blender::ed::greasepencil::boolean::get_inside_states_for_segments ( const CurveBooleanOpParameters & op_params,
const int curve_k,
const bool is_subj,
const int subj_shape_i,
const Span< float2 > points,
const GroupedSpan< int > shapes,
const OffsetIndices< int > points_by_curve,
const IndexMask & clipping_shapes,
const Span< Segment > all_segments,
const OffsetIndices< int > segments_by_curve,
const VArray< bool > & is_fill,
MutableSpan< bool > all_inside_left,
MutableSpan< bool > all_inside_right )
static

◆ intersect()

int blender::ed::greasepencil::boolean::intersect ( const float2 & P1,
const float2 & P2,
const float2 & Q1,
const float2 & Q2,
float * r_alpha_P,
float * r_alpha_Q )
static

This is a heavily modified implementation of the Greiner-Hormann clipping algorithm.

Greiner, Günther; Kai Hormann (1998). "Efficient clipping of arbitrary polygons". ACM Transactions on Graphics. 17 (2): 71-83.

The original Greiner-Hormann algorithm works in three phases: 1: Find all intersections and sort them. 2: Set the direction of all intersection point (the paper call it entry_exit) 3: Create all polygons by following the direction of each intersection point until it loops.

This implementation adds the following: 1: Groups of curves, called fills. This allows for input geometry with holes. 2: Curves can have no fill, so they will get cut.

This implementation works by: 1: Break one subject fill and all clipping fills into segments and store their intersections. 2: Remove all segments that are not contributing. 3: Follow each segment until it loops or terminates. 4: Repeat for every subject fill.

Definition at line 463 of file grease_pencil_boolean.cc.

References intersect(), and blender::isect_seg_seg_v2_lambda_mu_db().

Referenced by find_intersections_between_curves(), and intersect().

◆ LR_states_from_segment()

◆ point_in_polygon_winding_int()

int blender::ed::greasepencil::boolean::point_in_polygon_winding_int ( const float2 & point,
const Span< float2 > poly )
static

◆ point_in_polygon_winding_twice()

int blender::ed::greasepencil::boolean::point_in_polygon_winding_twice ( const float2 & point,
const Span< float2 > poly )
static

◆ point_in_tri_winding()

float blender::ed::greasepencil::boolean::point_in_tri_winding ( const float2 pt,
const float2 v1,
const float2 v2,
const float2 v3 )
static

◆ separate_fill_islands()

void blender::ed::greasepencil::boolean::separate_fill_islands ( bke::CurvesGeometry & dst,
const Span< bool > unchanged_curves,
const ProjectionFunc project_fn )
static

Separate disjoint fill islands.

Note: Nested islands of 3 or more curves will not be split, (i.e. an island inside a lake inside a island, will stay the same fill id as the upper most parent island.)

If a curve as been changed and it is not a child then update it's and it's children's fill ids.

Note: Previously unchanged curves may have their fill id changed, if their parent curve id is changed.

Definition at line 364 of file grease_pencil_boolean.cc.

References blender::bke::CurvesGeometry::attributes_for_write(), blender::bke::SpanAttributeWriter< T >::finish(), blender::Span< T >::first(), blender::bke::greasepencil::get_next_available_fill_id(), blender::offset_indices::OffsetIndices< T >::index_range(), blender::bke::MutableAttributeAccessor::lookup_for_write_span(), point_in_polygon_winding_int(), blender::bke::CurvesGeometry::points_by_curve(), blender::bke::CurvesGeometry::points_num(), blender::bke::CurvesGeometry::points_range(), blender::bke::CurvesGeometry::positions(), separate_fill_islands(), blender::offset_indices::OffsetIndices< T >::size(), blender::Span< T >::slice(), and blender::bke::SpanAttributeWriter< T >::span.

Referenced by curve_boolean(), curve_boolean_with_planes(), and separate_fill_islands().

◆ transform_plane()

float4 blender::ed::greasepencil::boolean::transform_plane ( const float4x4 & mat,
const float4 & plane )
static

Variable Documentation

◆ epsilon_distance

float blender::ed::greasepencil::boolean::epsilon_distance = 0.01f
constexpr

Definition at line 197 of file grease_pencil_boolean.cc.

Referenced by LR_states_from_segment().

◆ epsilon_factor

float blender::ed::greasepencil::boolean::epsilon_factor = 0.05f
constexpr

Definition at line 200 of file grease_pencil_boolean.cc.

Referenced by LR_states_from_segment().

◆ mid_point_factor

float blender::ed::greasepencil::boolean::mid_point_factor = 0.35421f
constexpr

Definition at line 203 of file grease_pencil_boolean.cc.

Referenced by LR_states_from_segment().