>SVPs

# SVPs

## Name

SVPs -- Manipulating SVPs

## Synopsis

 ``` ArtVpath* art_vpath_from_svp (const ArtSVP *svp); ArtSVP* art_svp_from_vpath (ArtVpath *vpath); ArtSVP* art_svp_union (const ArtSVP *svp1, const ArtSVP *svp2); ArtSVP* art_svp_intersect (const ArtSVP *svp1, const ArtSVP *svp2); ArtSVP* art_svp_diff (const ArtSVP *svp1, const ArtSVP *svp2);```

## Description

SVPs cannot be created in many different ways: art_svp_from_vpath and art_vpath_from_svp can be used to generate SVPs from a Vpath and to generate VPaths from SVPs.

Once SVPs have been created, it is possible to manipulate them and apply a number of interesting operations on them. Most notably, it is possible to do the union of two SVPs with art_svp_union (Given two SVPs, the union of these two SVPs is an SVP representing the area obtained by the concatenation of the underlying areas of the two original SVPs). art_svp_intersect calculates the intersection of two SVPs: the resulting SVPs contain points which were in the two original SVPs. Finally, art_svp_diff calculates the difference of two SVPs: the resulting SVPs contains all the points which were in only one of the original SVP. These operations are sumamrized below:

Figure 1. Operations on SVPs

## Details

### art_vpath_from_svp ()

 `ArtVpath* art_vpath_from_svp (const ArtSVP *svp);`

Converts the sorted vector path svp into standard vpath form.

 svp : Original ArtSVP. Returns : the newly allocated vpath.

### art_svp_from_vpath ()

 `ArtSVP* art_svp_from_vpath (ArtVpath *vpath);`

Converts a vector path into sorted vector path form. The svp form is more efficient for rendering and other vector operations.

Basically, the implementation is to traverse the vector path, generating a new segment for each "run" of points in the vector path with monotonically increasing Y values. All the resulting values are then sorted.

Note: I'm not sure that the sorting rule is correct with respect to numerical stability issues.

 vpath : ArtVPath to convert. Returns : Resulting sorted vector path.

### art_svp_union ()

 ```ArtSVP* art_svp_union (const ArtSVP *svp1, const ArtSVP *svp2);```

Computes the union of the two argument svp's. Given two svp's with winding numbers of 0 and 1 everywhere, the resulting winding number will be 1 where either (or both) of the argument svp's has a winding number 1, 0 otherwise. The result is newly allocated.

Currently, this routine has accuracy problems pending the implementation of the new intersector.

 svp1 : One sorted vector path. svp2 : The other sorted vector path. Returns : The union of svp1 and svp2.

### art_svp_intersect ()

 ```ArtSVP* art_svp_intersect (const ArtSVP *svp1, const ArtSVP *svp2);```

Computes the intersection of the two argument svp's. Given two svp's with winding numbers of 0 and 1 everywhere, the resulting winding number will be 1 where both of the argument svp's has a winding number 1, 0 otherwise. The result is newly allocated.

Currently, this routine has accuracy problems pending the implementation of the new intersector.

 svp1 : One sorted vector path. svp2 : The other sorted vector path. Returns : The intersection of svp1 and svp2.

### art_svp_diff ()

 ```ArtSVP* art_svp_diff (const ArtSVP *svp1, const ArtSVP *svp2);```

Computes the symmetric of the two argument svp's. Given two svp's with winding numbers of 0 and 1 everywhere, the resulting winding number will be 1 where either, but not both, of the argument svp's has a winding number 1, 0 otherwise. The result is newly allocated.

Currently, this routine has accuracy problems pending the implementation of the new intersector.

 svp1 : One sorted vector path. svp2 : The other sorted vector path. Returns : The symmetric difference of svp1 and svp2.