Selective Booleans
From DocR21
The Selective Booleans perform the standard Boolean unite, subtract, and intersect operations. Whereas pure Boolean operations will act upon the full model, selective Boolean operations use graph theory to act upon only selected portions of the model. The sequence of edges or faces encountered in the model is graphed, and ordered pieces of the graph can be tagged for inclusion or exclusion in the result of the Boolean operation.
The selective Boolean operation allows two or more bodies to be combined with greater flexibility regarding what is kept and what is discarded, without having to intersect the bodies more than once. The flexibility in what may be selected is at the cellular level, which allows for more choices than unite, subtract, and intersect.
The two ways of selecting the cells to be retained in the result are as follows:
- Direct user input of a list of cells that have been picked (the easiest way). For example, in Scheme, this can be achieved by loading pick.scm and then using the pick-cell procedure. To make the interactive selection of cells easier, you may include the Graphic Interaction component which facilitates picking, coloring, and highlighting of cells.
- Analyzing and subsetting the connectivity graph of cells. This uses the Graph Theory component, which creates and maintains the graphs of the cells.
Example
The following figure shows a blank body consisting of a block with two slots cut out of it and a tool body consisting of a cylinder that penetrates the block in three places. The first stage of the selective Boolean operation performs a non-regularized unite of the two bodies and attaches cellular topology to the result. In addition, the connectivity graph of the resulting cells is returned and the vertices of the graph (the cells) are marked in a way that lets you know from which body or bodies they came.
The resulting body contains eight three dimensional cells, seven that came from the tool body and four that came from the blank body. Three of the cells came from both bodies. The connectivity graph that is returned by the first stage is depicted in the following figure.
Cells A through G came from the tool body. Cells B, D, F, and H came from the blank body.
The second stage of the selective Boolean engine takes the non-regularized, united body and a list or graph of cells. It returns a regularized body that is made up of the specified cells or vertices of the graph. For example, if you specified all of the cells from the original blank body and cells C and G from the tool body, you would obtain the body shown in the figure below.
Interface
| C++ | Scheme | Description |
|---|---|---|
| api_initialize_sbooleans | None | Initializes the Selective Booleans component library. |
| api_selective_boolean_stage1 | bool:select1 | Performs the first stage of the selective Boolean process on a tool body and blank body. |
| api_selective_boolean_stage2 | bool:select2 | Completes the selective Boolean process for the cells selected. |
| api_selective_unite | bool:sel-unite | Performs a selective Boolean operation given two lists of positions specifying which portions to keep. |
| api_boolean_tube_body | bool:tube | Performs a selective Boolean operation as specified in the tube options. |
| tube_options | tube_options | Tube options C++ object and Scheme data type. |
| tube_options | tube:options | Creates a tube options object or Scheme data type. |
| api_create_graph_from_cells | graph | Creates a graph used in graph theory. |
| api_subgraph_2dcell | graph:subgraph-2dcell | Returns a subgraph containing only the vertices that are 2D cells. |
| api_subgraph_3dcell | graph:subgraph-3dcell | Returns a subgraph containing only the vertices that are 3D cells. |
| api_subset_graph_with_plane | graph:subset-with-plane | Finds the subset of a graph on one side of a plane. |
| api_terminate_sbooleans | None | Terminates the Selective Booleans component library. |
Scheme Examples
The following Scheme script demonstrates how to construct the body depicted in the Example above. This script uses api_selective_boolean_stage1, api_selective_boolean_stage2, and a list of cells to keep.
; Demonstrate a selective Boolean operation. (define blank (solid:block (position 0 0 0)(position 25 10 10))) ;; blank (define b2 (solid:block (position 5 0 0)(position 10 5 10))) ;; b2 (define b3 (solid:block (position 15 0 0)(position 20 5 10))) ;; b3 (define subtract (solid:subtract blank b2)) ;; subtract (define subtract2 (solid:subtract blank b3)) ;; subtract2 (define tool (solid:cylinder (position -5 2.5 5) (position 30 2.5 5)1)) ;; tool ; Change the color of the tool for viewing. (entity:set-color tool 3) ;; () ; Perform the first stage of the selective Boolean operation. (define g (bool:select1 blank tool)) ;; g ; Find the cells in the blank. (define cells (entity:cells blank)) ;; cells ; Create a list of cells to keep. Leave out cells 1 and 3. ; CAREFUL: The mapping of cell numbers to entities may not be the same each time this is run. (define in-cells (list (list-ref cells 0)(list-ref cells 2)(list-ref cells 4) (list-ref cells 5)(list-ref cells 6)(list-ref cells 7))) ;; in-cells ; Perform the second stage of the selective Boolean operation. (define select (bool:select2 blank in-cells)) ;; select
The following Scheme script demonstrates an alternative way to construct the body depicted in the Example above. This script uses api_selective_unite, and specifies to keep all of the cells from the blank body and two of cells from the tool body. The tool body cells are specified by positions in their interiors.
; Demonstrate a selective Boolean operation. (define blank (solid:block (position 0 0 0)(position 25 10 10))) ;; blank (define b2 (solid:block (position 5 0 0)(position 10 5 10))) ;; b2 (define b3 (solid:block (position 15 0 0)(position 20 5 10))) ;; b3 (define subtract (solid:subtract blank b2)) ;; subtract (define subtract2 (solid:subtract blank b3)) ;; subtract2 (define tool (solid:cylinder (position -5 2.5 5) (position 30 2.5 5)1)) ;; tool ; Change the color of the tool for viewing. (entity:set-color tool 3) ;; () ; Perform the selective Boolean operation. (define pnt1 (position 7.5 2.5 5)) ;; pnt1 (define pnt2 (position 27.5 2.5 5)) ;;pnt2 (define sbool (bool:sel-unite blank tool #t (list pnt1 pnt2))) ;; sbool

