This how-to guide will recap various methods to split curves at intersection events and how to get the remaining segments. The how-to Divide curves is focusing on a segmentation with a regular or pattern-based logic. To select the curves behind or before the intersecting shape and how to remove them, see Trim curves.
For the general purpose splitting of curves, we can use the component ShatterInputs Curve (C) Curve to trim Parameters (t) Parameters to split at Outputs Segments (S) Shattered remains
In simple cases, there is no need to calculate the parameter to split at,
because we can directly set it. For example, if we would like to split a line or
regular curve in the middle, we can reparameterize the curve and set t to
0.5
.
If you need to split polylines at the kinks, you can use the component ExplodeInputs Curve (C) Curve to explode Recursive (R) Recursive decomposition until all segments are atomic Outputs Segments (S) Exploded segments that make up the base curve Vertices (V) Vertices of the exploded segments
Calculate curve parameters for splitting
As said, before we can do the actual splitting, we have to compute the parameters to split at. The ribbon tab Intersect contains components for different intersection events. Some components will directly output the sought-for curve parameters t, while others just emit the intersection point P and we have to retrieve the splitting parameter t with an extra step.
Find parameters to split at a component’s output (two distinct sets of curves)
Given are two sets of curves: Set A contains vertical curves and set B
consists of one horizontal curve. We can solve the intersection of the two sets
with the component Curve | CurveInputs Curve A (A) First curve Curve B (B) Second curve Outputs Points (P) Intersection events Params A (tA) Parameters on first curve Params B (tB) Parameters on second curve Inputs Curve (C) Curve to trim Parameters (t) Parameters to split at Outputs Segments (S) Shattered remains
This procedure will split the curves in Set A. If we wish to also split set
B, we have to use another ShatterInputs Curve (C) Curve to trim Parameters (t) Parameters to split at Outputs Segments (S) Shattered remains
Next, let us assume that there is another horizontal curve in set B (the wire
has now switched to two parallel lines). To ensure that every curve from one
set is compared with each curve from the other set, we have to adjust the data
structure and graft either of the two input grips of Curve | CurveInputs Curve A (A) First curve Curve B (B) Second curve Outputs Points (P) Intersection events Params A (tA) Parameters on first curve Params B (tB) Parameters on second curve Inputs Tree (T) Data tree to flatten Depth (D) Number of outermost branches to merge Outputs Tree (T) Trimmed data tree Inputs Curve (C) Curve to trim Parameters (t) Parameters to split at Outputs Segments (S) Shattered remains
A similar procedure can be used with the components Line | LineInputs Line 1 (A) First line for intersection Line 2 (B) Second line for intersection Outputs Param A (tA) Parameter on line A Param B (tB) Parameter on line B Point A (pA) Point on line A Point B (pB) Point on line B Inputs Curve (C) Curve to intersect Line (L) Line to intersect with Outputs Points (P) Intersection events Params (t) Parameters on curve Count (N) Number of intersection events Inputs Curve (C) Curve for self-intersections Outputs Points (P) Intersection events Params (t) Parameters on curve
Find parameters to split at a component’s output (unsorted bundle of curves)
If all curves are bundled in a single list and there is no distinct set to solve
the intersection event for, we can use Multiple CurvesInputs Curves (C) Curves to intersect Outputs Points (P) Intersection events Index A (iA) Index of first intersection curve Index B (iB) Index of second intersection curve Param A (tA) Parameter on first curve Param B (tB) Parameter on second curve
To proceed, we will first bundle our outputs with MergeInputs Data 1 (D1) Data stream 1 Data 2 (D2) Data stream 2 Outputs Result (R) Result of merge Inputs List (L) List of data. Outputs Set (S) A set of all the distincts values in L Map (M) An index map from original indices to set indices Inputs Set (S) Set to operate on. Member (M) Member to search for. Outputs Index (I) Indices of member. Count (N) Number of occurences of the member. Inputs List (L) Base list Index (i) Item index Wrap (W) Wrap index to list bounds Outputs Item (i) Item at {i'} Inputs List (L) Base list Index (i) Item index Wrap (W) Wrap index to list bounds Outputs Item (i) Item at {i'} Inputs Curve (C) Curve to trim Parameters (t) Parameters to split at Outputs Segments (S) Shattered remains
Do note that curves which did not have an intersection event are
not part of the output. The component Combine DataInputs Input 0 (0) Data to combine Input 1 (1) Data to combine Outputs Result (R) Resulting data with as few nulls as possible Index (I) Index of input that was copied into result
Compute parameters to split with intersection points
For this example, we take the unsorted bundle of curves from the previous chapter
and again, we use Multiple CurvesInputs Curves (C) Curves to intersect Outputs Points (P) Intersection events Index A (iA) Index of first intersection curve Index B (iB) Index of second intersection curve Param A (tA) Parameter on first curve Param B (tB) Parameter on second curve Inputs Curve (C) Curve to trim Parameters (t) Parameters to split at Outputs Segments (S) Shattered remains Inputs Point (P) Point to project onto curve Curve (C) Curve to project onto Outputs Point (P) Point on the curve closest to the base point Parameter (t) Parameter on curve domain of closest point Distance (D) Distance between base point and curve
After grafting input C of Curve Closest PointInputs Point (P) Point to project onto curve Curve (C) Curve to project onto Outputs Point (P) Point on the curve closest to the base point Parameter (t) Parameter on curve domain of closest point Distance (D) Distance between base point and curve Inputs First Number (A) Number to test Second Number (B) Number to test against Outputs Smaller than (<) True if A < B … or Equal to (<=) True if A <= B Inputs List (L) List to filter Dispatch pattern (P) Dispatch pattern Outputs List A (A) Dispatch target for True values List B (B) Dispatch target for False values 1e-10
to account for software-related inaccuracies.
ShatterInputs Curve (C) Curve to trim Parameters (t) Parameters to split at Outputs Segments (S) Shattered remains Inputs Input 0 (0) Data to combine Input 1 (1) Data to combine Outputs Result (R) Resulting data with as few nulls as possible Index (I) Index of input that was copied into result
A similar procedure can be used with the components Brep | CurveInputs Brep (B) Base Brep Curve (C) Intersection curve Outputs Curves (C) Intersection overlap curves Points (P) Intersection points Inputs Surface (S) Base surface Curve (C) Intersection curve Outputs Curves (C) Intersection overlap curves Points (P) Intersection points UV Points (uv) Surface {uv} coordinates at intersection events Normals (N) Surface normal vector at intersection events Parameters (t) Curve parameter at intersection events Tangents (T) Curve tangent vector at intersection events Inputs Curve (C) Base curve Plane (P) Intersection plane Outputs Points (P) Intersection events Params C (t) Parameters {t} on curve Params P (uv) Parameters {uv} on plane Inputs Mesh (M) Mesh to intersect Curve (C) Curve to intersect with Outputs Points (X) Intersection points Faces (F) Intersection face index for each point