Boolean Operations   

<<< Checking Chapters Instancing and Patterning >>>

Contents

[back to top]


9.1 Introduction

This chapter explains how you combine bodies using Boolean operations to produce the models you require.

It is assumed that you are familiar with the characteristics of the various body types, as explained in Chapter 6, "Manifold Bodies"and Chapter 7, "General Bodies".

[back to top]


9.2 The three basic boolean operations

The basic boolean operations are analogous to mathematical set operations:

 

Figure 9-1 Basic boolean operations

[back to top]


9.3 Terminology

This section explains the most relevant terminology that is associated with this chapter.

[back to top]

9.3.1 Target and tool

The "operands" of a boolean are called the target and the tool. The target of a boolean is the body you begin with, and the tool is the body you operate on it with. The target is modified by the tool, and the tool is deleted at the end of the operation. Parasolid preserves the tags of entities in the target as far as possible.

The following diagram shows the effect of swapping the target and tool of subtract:

 

Figure 9-2 Target, tool and result bodies on boolean subtraction

This is important when we come to consider Booleans between bodies of different types.

[back to top]

9.3.2 Tag persistence during boolean operations

The rules for the persistence of tags described in Section 2.2.2, "Tags", apply during boolean operations. However, tag persistence is disabled if normal attribute callbacks are registered and used. See Section 46.3, "Callback functions" for more information.

[back to top]

9.3.3 Global boolean

A global boolean is characterized by the comparison of all face pairs from the target and tool bodies.

These boolean operations are supported by the PK_BODY_boolean_2 function which requires one target body, one or more tool bodies and an options structure. If more than one tool body is supplied, the union of overlapping tools is computed first and then the boolean between the target and the tools is performed.

The following functions support boolean operations without requiring the specification of an option structure:

[back to top]

9.3.4 Local boolean

A local boolean is characterized by the comparison of selected face pairs in the target and tool bodies. This form of boolean operation is quicker than a global boolean but does not guarantee topological consistency on the resulting bodies.

These boolean operations are supported by the PK_FACE_boolean_2 function which requires one or more faces from a single target and tool body and an options structure.

[back to top]

9.3.5 Boundary regions

The imprinted edges divide the boundaries of the bodies into regions.

 

Figure 9-3 Using this target/tool combination in a boolean operation...

 

Figure 9-4 ... creates these boundary regions (imprinted edges and regions on tool are marked)

 

Figure 9-5 ... or creates these boundary regions after imprinting between f1 and f2 (imprinted edges and regions on tool are marked)

[back to top]


9.4 Boolean operations with manifold topology

The result of a boolean operation with generalized topology disabled, may be any number of bodies, each of which is a manifold and connected solid or sheet. Global and local boolean operations may be attempted with manifold topology.

The manifold boolean operations behave as follows:

 

Operation Description

Union

Extends the target body by gluing to it all facesets of the tool bodies which are out side of the target body. You cannot unite regular bodies and sheets, and you can only unite sheets along their edges.

Subtraction

Modifies the target body by removing all facesets which overlap the tool bodies. You can subtract sheets from regular bodies, and you can subtract sheets from sheets.

Intersection

Reduces the target body to only those facesets which overlap with the tool bodies

The behavior of the subtraction operation can be altered for:

 

Target/tool Behavior

solid target/sheet tools

The subtraction can be altered to reduce the target to only those facesets in front or behind the sheet tool bodies

sheet target/solid tools

The subtraction can be altered so that the tools punch the target and all faces on the target which overlap with the tools are removed; all facesets which are in front or behind the target body are glued to it

[back to top]


9.5 Boolean operations with generalized topology

The result of a boolean operation with generalized topology enabled is a single general body which may be disconnected, non-manifold, of mixed dimensions (or any combination of these). Only global boolean operations may be attempted with generalized topology.

The generalized topology boolean operations behave as follows:

 

Operation Description

Union

Extends the target body after imprinting to include all the facesets from both the target and tools. You can unite regular bodies and sheets, and you can unite sheets at any point, not just along their edges.

Subtraction

Modifies the target body by removing from it those pieces which overlap the union of the tool bodies

Intersection

Reduces the target body to those pieces which overlap with the union of the tool bodies

Irregular Boolean operations (such as boolean operations between two open shells) are supported when generalized topology is enabled.

To enable generalized topology, use PK_SESSION_set_general_topology.

[back to top]


9.6 Options for booleans

The behavior of the boolean interface functions, PK_BODY_boolean_2 (global Booleans) and PK_FACE_boolean_2 (local Booleans), is altered via the contents of an option structure passed to these functions. The option structures for these functions are different, but overlap with respect to a number of options. The options are as follows:

 

Option Description

function
(global & local)

specifies the boolean operation to be performed: union, subtraction or intersection

merge_imprinted
(global & local)

specifies that all mergeable imprinted edges created by the boolean operation are merged

selective_merge
(global & local)

modifies the edge merging behavior - the merge phase avoids merging edges in the imprint that existed and were mergeable before the start of the boolean

allow_disjoint
(global & local)

specifies that the boolean operation should return a single disjoint body if the operation would result in more than one body

prune_in_solid
(global - non-manifold topology only)

specifies that all solid regions in the resulting body are pruned - any faces, edges or vertices in the result body which are completely surrounded by solid regions are deleted

prune_in_void
(global - non-manifold topology only)

specifies that all void regions in the resulting body are pruned - any faces, edges or vertices in the result body which are completely surrounded by void regions are deleted, so long as the result body contains some pieces of a higher dimension, e.g. a sheet face is only deleted if the result body contains at least one solid region

fence
(global & local - manifold topology only)

modifies the behavior of the subtract operation and determines which resultant bodies are returned when performing solid/ sheet (trimming) or sheet/solid (punching) boolean operations

extend_face_list
(local)

a local boolean receives a subset of the faces of a target body - if the imprinting phase of the boolean results in incomplete loops of imprinted edges, then additional target faces are used

stop_self_intersect
(local)

stop self intersection, after imprinting, tool faces which survive the boolean are compared against all faces of the target body

configuration
(global & local)

this option sub-structure describes the configuration of the tar get and tool bodies - see "Optimizing boolean operations (global & local)" for a description of the options

select_region
(local)

this option sub-structure is used to identify regions of the tool to be included or excluded in the boolean result - see "Select regions in boolean operations (local)" for a description of the options.

matched_region
(global & local)

this option sub-structure describes matched regions between the target and tool bodies - see Section 9.6.3, "Matched topology in boolean operations (global & local)" for a description of the options

check_fa
(global and local)

checks faces involved in the boolean operation - only faces which are adjacent to imprinted edges are checked

default_tol
(global and local)

the default tolerance to which the boolean operation, if it has to, may approximate entities or assume that entities are coincident

max_tol
(global and local)

the maximum tolerance which may be applied to any entity involved in the boolean operation

keep_target_edges
(global & local)

Control which edge survives when a target edge and tool edge coincide during a boolean operation. This can be one of:

  • PK_LOGICAL_false: The older edge (with the smallest tag) survives. This is the default.
  • PK_LOGICAL_true: The target edge survives, unless both
    • the target edge is a new edge imprinted during the boolean, and
    • the tool edge was already present

    in which case, the tool edge survives.

If both faces adjacent to the tool edge survive, then the tool edge survives, regardless of the value of this option. If generalized topology is on, the target edge always survives.

[back to top]

9.6.1 Optimizing boolean operations (global & local)

If the boolean operation involves instancing, i.e. a boolean operation which takes a single target body and a list of tool bodies, e.g. when drilling an array of holes in a body, the performance of the operation can be improved by using one of the following instancing options in the configuration option sub-structure:

 

Option Description

no_tool_intersect

this option can be set when it is known that the set of tool bodies do intersect each other, though they are allowed to clash with existing edges on the target (including the periphery edge)

 

Figure 9-6 Tool bodies that do not intersect each other, but intersect edges on the target

 

Option Description

no_loop_intersect

this option can be set when it is known that there is no interference between any instances and the existing edges of the target; it is permissible for the tools to clash with each other

 

Figure 9-7 Tool bodies that have intersected each other but not the edges on the target

For a more efficient method of instancing when only a single tool body and a single target body are involved use PK_FACE_instance_tools.

[back to top]

9.6.2 Select regions in boolean operations (local)

When computing the imprinted edges for a local boolean it is possible to identify regions of the tool body that are to be either included or excluded from the local boolean.

A region in this context is a boundary faceset which lies wholly inside or outside the target body. (Tool faces which intersect the target body have been split by the boolean: the resultant faces lie wholly inside or outside the target body.)

Each region is identified by a single face, edge or vertex which is interior to it; it is not possible to specify some regions for inclusion and some for exclusion, they are all either included or excluded.

The select regions are specified with the select_region option sub-structure which describes the regions with the following options:

 

Option Description

select_type

the value of this option determines the inclusion or exclusion of the specified regions

selectors

an array of topological entities which each uniquely identify a region; the array may contain a mixture of faces, edges or vertices, but no other types; faces within this array may be associated with elements of the help points array

help_points

an array of help points (vectors) which, when combined with the appropriate topological entity from the selectors array, unambiguously identifies a region (help points may only be associated with a face)

selector_types

an array of selector types which, when combined with the appropriate topological entity from the selectors array, specifies the characteristics of the region selection - includes whether the region is allowed to be adjacent to imprinted edges, or whether the region selection is to be propagated if the region is split by imprinting (selector types may only be specified for face and edge region selections)

 

Figure 9-8 Using this target/tool combination in a local unite boolean operation with the exclude regions facility selected in the select_type option...

 

Figure 9-9 ... produces this result by trimming the tool body, discarding the regions containing the exclude faces

 

Figure 9-10 Using this target/tool combination in a local unite boolean operation with the include regions facility selected in the select_type option...

 

Figure 9-11 ... produces this result by trimming the tool body, keeping the region containing the include face

[back to top]

9.6.3 Matched topology in boolean operations (global & local)

When performing boolean operations in which there is a nearly coincident region between the target and tool bodies, you can specify that certain topological regions are matched when performing boolean functions. Doing this can produce better results, and make the boolean operation faster. A matched region is a region of overlap between two topological entities that are geometrically coincident to a specified tolerance. The entities in the matched region must be in the target or tools of the boolean operation.

 

Note: Matched topology information is only valid for regular booleans. It cannot be supplied for booleans with generalized topology enabled

Matched region information is specified using the PK_boolean_match_o_t substructure in PK_BODY_boolean_o_t. It takes the following information:

 

Field Description

n_match_regions

The number of matched regions supplied in the call. Default: 0

match_regions

A substructure (PK_boolean_match_region_o_t) containing information about each pair of entities that are matched. Default: NULL

match_style

Whether the neighbors of the matched regions only intersect in the matched region. This can have the following values:

If the "basic" match style is used, then boolean operations fail if faces intersect outside of matched regions. If the "relax" match style is used, then these operations succeed. See Figure 9-14 for an example. Default; PK_boolean_match_style_basic_c

Matched regions are specified in the PK_boolean_match_region_o_t substructure, using the following information:

 

Field Description

regions

A pair of topological entities that are to be treated as matched. The following combinations of entities can be matched:

  • Edge - Edge
  • Face - Edge
  • Face - Face
  • Vertex - Vertex (only for a match type of "imprinted")

Default: PK_ENTITY_null, PK_ENTITY_null

match_type

The type of match. See below for details. Default: PK_boolean_match_exact_c

tolerance

The tolerance within which the matched entities are geometrically coincident.

The match_type classifies the relationship between the entities:

 

Match type Description

Exact

The bounds of the topological entities match within the specified tolerance

Contains

The bounds of the second entity lie within the bounds of the first entity

Overlap

The bounds of one entity overlap with the bounds of the second entity

Imprinted

The bounds have been created by imprinting the topological entities

Examples

The following examples show how specifying matched regions can improve the performance of boolean operations.

Example 1

Performing a unite boolean with matched faces

In Figure 9-12 the tool body is a copy of the target body reflected about the plane of face F1.

 

Figure 9-12 Unite boolean with matched faces

Uniting the two bodies may fail due to the near coincident and tangential geometry meeting at the boundary of face F1 and F2. This is especially true if the geometry is of an approximate nature.

Specifying face F1 and F2 as a matched pair, with a suitable tolerance, enables the unite operation to succeed. The match type can be either 'exact' or 'overlapping'.

Example 2

Performing a unite boolean with matched faces and edges

In Figure 9-13 the target and tool bodies have been created by sweeping different profiles along the same guide path.

 

Figure 9-13 Unite boolean with matched face and edges

Boolean operations have difficulty with such bodies due to the approximate nature of the geometry of face F1 and F2. The boundaries of face F1 lie within a tolerance of face F2.

Specifying the face, F2, and the edges, E1 and E2, as matched topology, with a suitable tolerance, enables the unite operation to succeed. The match type can be either 'contained' or 'overlapping'.

Example 3

Performing a unite boolean with neighboring faces that intersect

In Figure 9-14, the target and tool bodies can be united at the base.

 

Figure 9-14 Unite boolean with intersecting neighboring faces

Specifying the base of the cone F1, and the base of the hemisphere, F2, as matched topology, with a suitable tolerance, lets the unite operation succeed, but only if match_style is set to PK_boolean_match_style_relax_c. Because the neighboring faces of the matched topology intersect in the united body, using the default match_style of PK_boolean_match_style_basic_c would cause the unite operation to fail.

[back to top]

9.6.4 Sheet punching operations

Figure 9-15 illustrates the punching of a target sheet body with solid tool bodies, so that the areas of the target outside the tools, plus the areas of faces of the tools on one side of the target are the resultant sheet body.

 

Figure 9-15 Punching a target (sheet) body with 5 solid tool bodies

[back to top]

9.6.5 Enclosing solid region with sheet body

It is possible to enclose solid regions or add solid regions to an existing solid body by uniting the solid body with a sheet body. The sheet body must enclose a valid manifold solid region within the solid body. This operation is only valid with generalized topology disabled.

Example:

Uniting a solid and sheet body to enclose a solid region

 

Figure 9-16 Uniting solid and sheet bodies to enclose a solid region

[back to top]

9.6.6 Effect of the fence option on solid/sheet operations

Use of the fence option controls which regions of the sheet body are returned.

Example 1:

Subtracting sheet body from solid body using the 'none' fence option

 

Figure 9-17 Solid sectioned by sheet, 4 bodies returned.

Example 2:

Subtracting sheet body from solid body using the 'front' fence option

 

Figure 9-18 Solid sectioned by sheet - only regions in front of the sheet body are returned, 3 bodies returned.

Example 3:

Subtracting sheet body from solid body using the 'back' fence option

 

Figure 9-19 Solid sectioned by sheet - only regions behind the sheet body are returned, 1 body returned.

[back to top]

9.6.7 Effect of merge options on the boolean operation

 

Figure 9-20 Results of merge options during boolean operations

[back to top]


9.7 Limitations on booleans with generalized topology disabled

[back to top]

9.7.1 General

Booleans operate on sheet or solid bodies, not wires. If the target and the tool are the same body type, you can use any of the three boolean operations. For targets and tools of different body types, the operations allowed are described below. The result of a boolean always has the same body type as the target.

Booleans between sheet bodies cannot result in a sheet body with a 'T' or an 'X' shaped cross-section. This type of body is invalid and the boolean fails.

All Booleans return their results via PK Interface arrays of bodies, whether the result is many bodies or just a single one. Booleans do not change the type of the bodies involved.

Most of the Booleans illustrated below have a single tool, but you can supply a list of tool bodies:

 

Figure 9-21 Subtracting multiple solid bodies from a sheet

[back to top]

9.7.2 Unite

You can unite like with like, but you can also unite a solid with a sheet to add a solid region to the solid. You can unit a sheet with a solid. When you are uniting two sheet bodies, they must meet at their edges, unless they have overlapping faces.

[back to top]

9.7.3 Subtract

You can subtract like from like, but you can also subtract solids from sheets, and sheets from solids, so long as the sheet cuts the solid completely. If it doesn't, PK_ERROR_non_manifold is returned.

 

Figure 9-22 Subtracting a sheet body from a solid body

 

Figure 9-23 Subtracting a solid body from a sheet body

[back to top]

9.7.4 Intersect

You can intersect solids with solids, as illustrated earlier.

When using more than one tool the resulting intersection is:

 

Figure 9-24 Intersecting a solid with more than one tool

You can intersect sheets with sheets, so long as the faces have coincident surfaces. The following rules apply when intersecting sheets with sheets:

 

Figure 9-25 Intersecting sheet bodies that touch but do not overlap

 

Figure 9-26 Intersecting sheet bodies that have a single overlap

 

Figure 9-27 Intersecting sheet bodies that have multiple overlaps

 

Figure 9-28 Intersecting sheet bodies that have opposite face normals

If the faces have crossing surfaces then there is no intersection:

 

Figure 9-29 Intersecting sheet bodies that cross

You can intersect a sheet with a solid, but not a solid with a sheet.

 

Figure 9-30 Intersecting a sheet body with a solid body

[back to top]

9.7.5 Summary of permitted booleans with generalized topology disabled

 

Target Boolean Tool Allowed Fence

sheet

unite

sheet

yes

no

sheet

subtract

sheet

yes

yes

sheet

intersect

sheet

yes

no

sheet

unite

solid

no

-

sheet

subtract

solid

yes

yes

sheet

intersect

solid

yes

no

solid

unite

sheet

yes

-

solid

subtract

sheet

yes

yes

solid

intersect

sheet

no

-

solid

unite

solid

yes

no

solid

subtract

solid

yes

yes

solid

intersect

solid

yes

no

[back to top]


9.8 Shared geometry after a boolean operation

Using a boolean operation to subtract a slot from a block. Face 'A' is split creating the new face 'B' resulting in the both the 'A' and 'B' faces sharing the original surface. Similarly this applies for edges 'C' and 'D' as they have a common direction.

 

Figure 9-31 Two faces sharing the same surface

[back to top]

9.8.1 Subtraction resulting in sharing

In Figure 9-32 face 'E' has the same surface as face '1' and face 'F' has the same surface as face '2'. Therefore, if face '1' and face '2' shared the surface to begin with, then face 'E' and face 'F' share the surface in the result.

After the subtraction boolean faces 'A' and 'B' share the surface of the bottom of the tool, and faces 'C' and 'D' share the surface of the back of the tool since they were created from those surfaces of the tool.

 

Figure 9-32 Subtracting a tool from a target

 

Note: The edges between faces 'C' / 'E', and 'D' / 'F' (see Figure 9-32) do NOT share a curve even if 'E' and 'F' share a surface. This is because of the dependence of the boolean algorithm on topological boxes; although the new curves are both the intersections of the same two surfaces, the edges are a result of intersections of different faces.

[back to top]

9.8.2 Subtraction preserving sharing

Figure 9-33 is similar to the previous example except that the target and tool are reversed. In this example the sharing of the surface under faces 'A' and 'B' is determined by the sharing of the surface under faces '1' and '2'; if '1' and '2' share, then so do 'A' and 'B'.

 

Figure 9-33 Subtracting a tool from a target

[back to top]


9.9 Boolean tools

[back to top]

9.9.1 Imprinting

The initial stage of the boolean operation is required to generate the sets of imprinted edges and vertices on the target and tool entities. These imprinted edges and vertices form the boundaries of intersection between target and tool entities.

You can create the sets of imprinted edges and vertices on a target and tool entity using PK_BODY_imprint_body and PK_FACE_imprint_faces. These functions create the imprinted edges and vertices on the supplied entities and return the imprinted edges and vertices as paired sets.

The functions receive option structures to control the imprinting process and to supply the imprinting functions with matched topology (in the same format as the boolean option structure).

 

Figure 9-34 Imprinting a cylindrical tool on a target cube resulting in 4 pairs of imprinted edges

[back to top]

9.9.2 Identifying facesets

Once a set of edges and vertices has been imprinted on a target and tool body, it is possible to identify which facesets (on both the target and tool) would survive a boolean operation.

PK_BODY_identify_facesets receives loops of coincident edges, points of contact and a boolean operation (unite, subtract and intersect) and then calculates which facesets would survive the operation and which facesets would be deleted. The loops of coincident edges and points of contact would typically be obtained via calls to the imprinting functions, PK_BODY_imprint_body and PK_FACE_imprint_faces.

 

Figure 9-35 Simulating a unite operation based on imprinted edges from Figure 9-34

[back to top]


9.10 Clash detection of bodies

Clash detection supporting clearance analysis is managed by PK_TOPOL_clash. This function receives two sets of topologies, and can detect clashes between:

PK_TOPOL_clash detects and distinguishes:

 

Type of clash Description

clashes

Two topologies have one, two or three-dimensional overlap.

interference

Two bodies interfere if faces from each body cross.

Two faces interfere if at least one of the following occurs:

  • The faces cross
  • Edges of the faces cross
  • There is a common area to both faces

A body and a face interfere if there is a point in space within the bounding topologies of both entities.

abutment

Two bodies abut if they have faces that touch, but do not share a common volume.

Two faces abut if they have edges which touch, but do not cross each other.

A body and a face abut if they clash, but there is no point in space within the bounding topologies of both entities.

containment

One topology is completely inside another.

Options available with this clash detection function for controlling the output are:

 

Option Description
find_all

If PK_LOGICAL_true, find all the clashes between the two topologies. If PK_LOGICAL_false, stop after the first clash. (Default: PK_LOGICAL_false)

find_intersect

If PK_LOGICAL_true, classify each clash between the two topologies, and return the information in the clash_types field of PK_TOPOL_clash_t. (Default: PK_LOGICAL_false)

When clashes of faces can go undetected

Face clashes can go undetected in either of the following situations:

 

[back to top]

<<< Checking Chapters Instancing and Patterning >>>