## BoolExtractPolygons

(bool_lib/bool2low.c:891)
Prototype:

      IPObjectStruct *BoolExtractPolygons(IPObjectStruct *PObj, int AinB)

Description:
This routine coordinates all the extraction of the polygons from the intersecting lists. Does it in the following steps: 1. Mark all polygons with no intersection at all as complete polygons. (this is because this polygon will be totally in or out, according to inter-polygon adjacencies propagation...) Also mark them as undefined (if in output or undefined) yet. Uses IPPolygonStruct Tags to save these bits. 2. do 2.1. Convert the unordered segment list of each polygon to closed loops (if create a hole in polygon) or open (if crosses its boundary). 2.2. Order the open loops along the perimeter of the polygon (note these loops cannt intersect. For example (5 vertices polygon):

                   -----------------------------L3
                  |  ---------------L1  -----L2 |          --------L4   --L5
                  | |               |  |     |  |         |        |   |  |
            P0 ------ P1 ------- P2 ----- P3 -------- P4 ------ P5 -------- P0

Note L1, L2 are enclosed in L3 loop, and that the order is circular. 2.3. "Break" the polygon at each open loop that has no enclosed loops in it. For example we can start at L1, L2, L4, L5 and then L3. "Break" means - replace the vertex chain between the two loop end points, with the loops itself. Depends upon the relation required we may need to output a new polygon form from the deleted chain and that loop. In addition we may form a new polygon from last loop and was was left from the original polygon For each formed polygon, for each complete edge of it (i.e. edge which was originally in the polygon) test the adjacent polygon if it is complete (as marked in 1.) and if in or undefined (marked undefined in 1.) is still undefined: 2.3.1. set it to be in. 2.3.2. push it on adjacency stack. 2.4. For each closed loop - find in which polygon (from polygons created in 2.3.) it is enclosed, and decompose it. 3. While adjacencies stack not empty do: 3.1. pop top polygon from stack and output it. 3.2. For each of its edges (which obviousely must be complete edges) if adjacent polygon is complete and undefined: 3.3.1. set it to be in. 3.3.2. push it on adjacency stack. 3.3 go back to 3. The above algorithm defines in as in output, but dont be confused with the required inter-object AinB (or AoutB if FALSE), which used to determine which side of the trimming loop should be output. Note this routine may return non-convex polygons (but marked as so) even though the input for the booleans must be convex polygons only! In order to keep the given object unchanged, a whole new copy off the polygon list is made. The polygons of the list that are not in the output are freed: a global list of all polygons (pointers) is used to scan them in the end and free the unused ones (list PolysPtr).
Parameters:

PObj: | Object that need to be rebuilt according to the intersection curves that were found, both closed and open loops.
--- | ---
AinB: | Type of inclusion/exclusion requested.

Returned Value:

IPObjectStruct *: The newly created clipped object.

Keywords:
Booleans

## BoolGenAdjacencies

(bool_lib/adjacncy.c:91)
Prototype:

      int BoolGenAdjacencies(IPObjectStruct *PObj)

Description:
Routine to generate adjacencies to the given object. Note an edge might be only partially adjacent to another edge, and a second attempt is made to find (again only part of - see below) them. Any case, FALSE will be returned as there is no way we can say the object is perfectly closed! This is the only routine to generate the adjacencies of a geometric object. These adjacencies are needed for the boolean operations on them. Algorithm: for each edge, for each polygon in the object, the edges are sorted according to the key defined by EdgeKey routine (sort in hash tbl). A second path on the table is made to match common keys edges and set the pointers from one to another. Note that each edge is common to exactly 2 faces if it is internal, or exactly 1 face if it is on the border (if the object is open).
Parameters:

PObj: | he polygonal object to compute the adjacency information for.
--- | ---

Returned Value:

int: TRUE if all adjacencies were resolved, or the object is completely closed.

Keywords:
adjacency topology

## BoolLoopsFromInterList

(bool_lib/bool1low.c:970)
Prototype:

      int BoolLoopsFromInterList(IPPolygonStruct *Pl,
                                 InterSegListStruct **PClosed,
                                 InterSegListStruct **POpen)

Description:
Given a polygon with the intersection list, creates the polylines loop(s) out of it, which can be one of the two: 1. Closed loop - all the intersections create a loop in one polygon. 2. Open polyline - if the intersections cross the polygon boundary. In this case the two end point of the polyline, must lay on polygon boundary. In both cases, the polyline will be as follows: First point at first list element at PtSeg[0] (see InterSegmentStruct). Second point at first list element at PtSeg[1] (see InterSegmentStruct). Point i at list element (i-1) at PtSeg[0] (PtSeg[1] is not used!). In the closed loop case the last point is equal to first. Both cases returns NULL terminated list.
Parameters:

Pl: | Polygon with intersection information in its PAux slot.
--- | ---
PClosed: | To be updated with the closed loops found in Pl.
POpen: | To be updated with the open loops found in Pl.

Returned Value:

int: TRUE if has loops.

Keywords:

## BoolSetHandleCoplanarPoly

(bool_lib/bool-hi.c:902)
Prototype:

      int BoolSetHandleCoplanarPoly(int HandleCoplanarPoly)

Description:
Controls if coplanar polygons should be handled or not.
Parameters:

HandleCoplanarPoly: | If TRUE, coplanar polygons are handled.
--- | ---

Returned Value:

int: Old value.

See Also:
BooleanOR BooleanAND BooleanSUB BooleanCUT BooleanMERGE BooleanNEG Boolean2D BoolSetOutputInterCurve BoolSetPolySortAxis BoolSetParamSurfaceUVVals
Keywords:
Booleans

## BoolSetOutputInterCurve

(bool_lib/bool-hi.c:875)
Prototype:

      int BoolSetOutputInterCurve(int OutputInterCurve)

Description:
Controls if intersection curves or full Boolean operation is to be performed.
Parameters:

OutputInterCurve: | If TRUE only intersection curves are computed, If false, full blown Boolean is applied.
--- | ---

Returned Value:

int: Old value.

See Also:
BooleanOR BooleanAND BooleanSUB BooleanCUT BooleanMERGE BooleanNEG Boolean2D BoolSetHandleCoplanarPoly BoolSetPolySortAxis BoolSetParamSurfaceUVVals
Keywords:
Booleans

## BoolSetParamSurfaceUVVals

(bool_lib/bool-hi.c:929)
Prototype:

      int BoolSetParamSurfaceUVVals(int HandleBoolParamSrfUVVals)

Description:
Controls if UV paprameter values of original surface should be returned.
Parameters:

HandleBoolParamSrfUVVals: | If TRUE, UV values are to be returned.
--- | ---

Returned Value:

int: Old value.

See Also:
BooleanOR BooleanAND BooleanSUB BooleanCUT BooleanMERGE BooleanNEG Boolean2D BoolSetOutputInterCurve BoolSetHandleCoplanarPoly BoolSetPolySortAxis
Keywords:
Booleans

## BoolSetPolySortAxis

(bool_lib/bool1low.c:502)
Prototype:

      int BoolSetPolySortAxis(int PolySortAxis)

Description:
Routine to set polygonal sorting axis.
Parameters:

PolySortAxis: | Sorting axis. Either 0(x), 1 (y), or 2 (z).
--- | ---

Returned Value:

int: Old value.

Keywords:
Booleans

## BoolSortOpenInterList

(bool_lib/bool1low.c:1194)
Prototype:

      void BoolSortOpenInterList(IPPolygonStruct *Pl, InterSegListStruct **POpen)

Description:
Sorts the open loops of given polygon to an order that can be used in subdividing into sub polygons later (see comment of BoolExtractPolygons). This order is such that each loops will have no other loop between its end points, if we walk along the polygon in the (linked list direction) perimeter from one end to the other, before it. For example:

                   -----------------------------L3
                  |  ---------------L1  -----L2 |          --------L4   --L5
                  | |               |  |     |  |         |        |   |  |
            P0 ------ P1 ------- P2 ----- P3 -------- P4 ------ P5 -------- P0

In this case, any order such that L1, L2 are before L3 will do. Obviously this is not a total order, and they are few correct ways to sort it. Algorithm: For each open loop, for each of its two end, evaluate a RealType key for the end point P between segment P(i) .. P(i+1) to be i + t, where: t is the ratio (P - P(i)) / (P(i+1) - P(i)) . This maps the all perimeter of the polygon onto 0..N-1, where N is number of vertices of that polygon. Sort the keys, and while they are keys in data sturcture, search and remove a consecutive pair of keys assosiated with same loop, and output it. Note that each open loop point sequence is tested to be such that it starts on the first point (first and second along vertex list) on polygon perimeter, and the sequence end is on the second point, and the sequence is reversed if not so. This order will make the replacement of the perimeter from first to second points by the open loop much easier. This may be real problem if there are two intersection points almost identical - floating point errors may cause it to loop forever. We use some reordering heuristics in this case, and return fatal error if fail!
Parameters:

Pl: | To sort the loops for.
--- | ---
POpen: | The set of open loops. Updated in place.

Returned Value:

void

Keywords:

## BoolVerifyShareEdge

(bool_lib/bool2low.c:751)
Prototype:

      int BoolVerifyShareEdge(IPVertexStruct *V, IPPolygonStruct *Pl)

Description:
Test if the edge [V - V->Pnext] is indeed on the boundary of Pl.
Parameters:

V: | First vertex of edge to verify.
--- | ---
Pl: | Polygon to verify the edge shares its boundary.

Returned Value:

int: TRUE if [V - V->Pnext] is on Pl's boundary, FALSE otherwise.

Keywords:
Booleans

## Boolean2D

(bool_lib/bool-2d.c:67)
Prototype:

      IPPolygonStruct *Boolean2D(IPPolygonStruct *Pl1,
                                 IPPolygonStruct *Pl2,
                                 BoolOperType BoolOper)

Description:
Given two polygons assumed to be in the same plane, compute their 2D Boolean operation BoolOper and return it as a new polygon. NULL is returned if an error occur (No intersection or invalid BoolOper).
Parameters:

Pl1: | First polygon to compute 2D Boolean for.
--- | ---
Pl2: | Second polygon to compute 2D Boolean for.
BoolOper: | Boolean operation requested (and, or, etc.)

Returned Value:

IPPolygonStruct: The resulting Boolean operation.

See Also:
BooleanOR BooleanAND BooleanSUB BooleanCUT BooleanMERGE BooleanNEG BoolSetHandleCoplanarPoly BoolSetOutputInterCurve Boolean2DComputeInters
Keywords:
Booleans

## Boolean2DComputeInters

(bool_lib/bool-2d.c:317)
Prototype:

      Bool2DInterStruct *Boolean2DComputeInters(IPPolygonStruct *Poly1,
                                                IPPolygonStruct *Poly2,
                                                int HandlePolygons)

Description:
Given two polygons/lines, Detect all edges in Pl1 that intersect with edges in Pl2. Returned is the information about all intersections as a Bool2DInter structure list.
Parameters:

Poly1, Poly2: | The two polygons/lines to intersect.
--- | ---
HandlePolygons: | If polygons, needs to handle normals etc.

Returned Value:

Bool2DInterStruct *: Intersection information.

See Also:
Boolean2D
Keywords:
Booleans

## BooleanAND

(bool_lib/bool-hi.c:255)
Prototype:

      IPObjectStruct *BooleanAND(IPObjectStruct *PObj1, IPObjectStruct *PObj2)

Description:
Performs a Boolean AND between two objects.
Parameters:

PObj1: | First object to perform the Boolean operation on.
--- | ---
PObj2: | Second object to perform the Boolean operation on.

Returned Value:

IPObjectStruct: The result of the Boolean operation.

See Also:
BooleanOR BooleanSUB BooleanCUT BooleanMERGE BooleanNEG Boolean2D BoolSetOutputInterCurve BoolSetHandleCoplanarPoly BoolSetPolySortAxis BoolSetParamSurfaceUVVals BooleanSELF BooleanICUT
Keywords:
Booleans

## BooleanCUT

(bool_lib/bool-hi.c:355)
Prototype:

      IPObjectStruct *BooleanCUT(IPObjectStruct *PObj1, IPObjectStruct *PObj2)

Description:
Performs a Boolean CUT between two objects.
Parameters:

PObj1: | First object to perform the Boolean operation on.
--- | ---
PObj2: | Second object to perform the Boolean operation on.

Returned Value:

IPObjectStruct: The result of the Boolean operation.

See Also:
BooleanOR BooleanAND BooleanSUB BooleanMERGE BooleanNEG Boolean2D BoolSetOutputInterCurve BoolSetHandleCoplanarPoly BoolSetPolySortAxis BoolSetParamSurfaceUVVals BooleanSELF BooleanICUT
Keywords:
Booleans

## BooleanICUT

(bool_lib/bool-hi.c:401)
Prototype:

      IPObjectStruct *BooleanICUT(IPObjectStruct *PObj1, IPObjectStruct *PObj2)

Description:
Performs a Boolean Inside CUT between two objects.
Parameters:

PObj1: | First object to perform the Boolean operation on.
--- | ---
PObj2: | Second object to perform the Boolean operation on.

Returned Value:

IPObjectStruct: The result of the Boolean operation.

See Also:
BooleanOR BooleanAND BooleanSUB BooleanMERGE BooleanNEG Boolean2D BoolSetOutputInterCurve BoolSetHandleCoplanarPoly BoolSetPolySortAxis BoolSetParamSurfaceUVVals BooleanSELF BooleanCUT
Keywords:
Booleans

## BooleanLow1In2

(bool_lib/bool1low.c:128)
Prototype:

      IPObjectStruct *BooleanLow1In2(IPObjectStruct *PObj1, IPObjectStruct *PObj2)

Description:
Finds the part of PObj1 which is in of PObj2:
Parameters:

PObj1: | First object of Boolean operation.
--- | ---
PObj2: | Second object of Boolean operation.

Returned Value:

IPObjectStruct: Result of one in two.

See Also:
BooleanLow1Out2 BooleanLowSelfInOut
Keywords:
Booleans

## BooleanLow1Out2

(bool_lib/bool1low.c:91)
Prototype:

      IPObjectStruct *BooleanLow1Out2(IPObjectStruct *PObj1, IPObjectStruct *PObj2)

Description:
Finds the part of PObj1 which is out of PObj2:
Parameters:

PObj1: | First object of Boolean operation.
--- | ---
PObj2: | Second object of Boolean operation.

Returned Value:

IPObjectStruct: Result of one out two.

See Also:
BooleanLow1In2 BooleanLowSelfInOut
Keywords:
Booleans

## BooleanLowSelfInOut

(bool_lib/bool1low.c:164)
Prototype:

      IPObjectStruct *BooleanLowSelfInOut(IPObjectStruct *PObj, int InOut)

Description:
Finds the part of PObj which is in/out of itself:
Parameters:

PObj: | Object of Boolean operation with itself (self intersection).
--- | ---
InOut: | What are we looking for? in or out.

Returned Value:

IPObjectStruct: Result of Boolean in/out with self.

See Also:
BooleanLow1Out2 BooleanLow1In2
Keywords:
self intersection Booleans

## BooleanMERGE

(bool_lib/bool-hi.c:447)
Prototype:

      IPObjectStruct *BooleanMERGE(IPObjectStruct *PObj1, IPObjectStruct *PObj2)

Description:
Performs a Boolean MERGE between two objects.
Parameters:

PObj1: | First object to perform the Boolean operation on.
--- | ---
PObj2: | Second object to perform the Boolean operation on.

Returned Value:

IPObjectStruct: The result of the Boolean operation.

See Also:
BooleanOR BooleanAND BooleanSUB BooleanCUT BooleanNEG Boolean2D BoolSetOutputInterCurve BoolSetHandleCoplanarPoly BoolSetPolySortAxis BoolSetParamSurfaceUVVals BooleanSELF BooleanICUT
Keywords:
Booleans

## BooleanNEG

(bool_lib/bool-hi.c:490)
Prototype:

      IPObjectStruct *BooleanNEG(IPObjectStruct *PObj)

Description:
Performs a Boolean NEG between two objects. Negation is simply reversing the direction of the plane equation of each polygon - the simplest Boolean operation...
Parameters:

PObj: | Object to negate.
--- | ---

Returned Value:

IPObjectStruct: The result of the Boolean operation.

See Also:
BooleanOR BooleanAND BooleanSUB BooleanCUT BooleanMERGE Boolean2D BoolSetOutputInterCurve BoolSetHandleCoplanarPoly BoolSetPolySortAxis BoolSetParamSurfaceUVVals BooleanSELF BooleanICUT
Keywords:
Booleans

## BooleanOR

(bool_lib/bool-hi.c:191)
Prototype:

      IPObjectStruct *BooleanOR(IPObjectStruct *PObj1, IPObjectStruct *PObj2)

Description:
Performs a Boolean OR between two objects.
Parameters:

PObj1: | First object to perform the Boolean operation on.
--- | ---
PObj2: | Second object to perform the Boolean operation on.

Returned Value:

IPObjectStruct: The result of the Boolean operation.

See Also:
BooleanAND BooleanSUB BooleanCUT BooleanMERGE BooleanNEG Boolean2D BoolSetOutputInterCurve BoolSetHandleCoplanarPoly BoolSetPolySortAxis BoolSetParamSurfaceUVVals BooleanSELF BooleanICUT
Keywords:
Booleans

## BooleanSELF

(bool_lib/bool-hi.c:546)
Prototype:

      IPObjectStruct *BooleanSELF(IPObjectStruct *PObj)

Description:
Performs a Boolean Self intersection operation.
Parameters:

PObj: | Object to perform the self intersecting Boolean operation on.
--- | ---

Returned Value:

IPObjectStruct: The result of the Boolean operation.

See Also:
BooleanOR BooleanAND BooleanSUB BooleanMERGE BooleanNEG Boolean2D BoolSetOutputInterCurve BoolSetHandleCoplanarPoly BoolSetPolySortAxis BoolSetParamSurfaceUVVals BooleanCUT BooleanICUT
Keywords:
Booleans

## BooleanSUB

(bool_lib/bool-hi.c:302)
Prototype:

      IPObjectStruct *BooleanSUB(IPObjectStruct *PObj1, IPObjectStruct *PObj2)

Description:
Performs a Boolean SUBtracion between two objects.
Parameters:

PObj1: | First object to perform the Boolean operation on.
--- | ---
PObj2: | Second object to perform the Boolean operation on.

Returned Value:

IPObjectStruct: The result of the Boolean operation.

See Also:
BooleanOR BooleanAND BooleanCUT BooleanMERGE BooleanNEG Boolean2D BoolSetOutputInterCurve BoolSetHandleCoplanarPoly BoolSetPolySortAxis BoolSetParamSurfaceUVVals BooleanSELF BooleanICUT
Keywords:
Booleans