Scheme Extensions

 

 

Technical Article


Scheme is a public domain programming language, based on the LISP language, that uses an interpreter to run commands. ACIS provides extensions (written in C++) to the native Scheme language that can be used by an application to interact with ACIS through its Scheme Interpreter. The C++ source files for ACIS Scheme extensions are provided with the product. Spatial's Scheme based demonstration application, Scheme ACIS Interface Driver Extension (Scheme AIDE), also uses these Scheme extensions and the Scheme Interpreter.

body:combine

Action
Combines a list of solid and/or wire bodies into a single body.

Filename
scm/scmext/eulr/eulr_scm.cpp

APIs
api_combine_body

Syntax
(body:combine body-list [ao])

Arg Types
body-list body | (body ...)
ao acis-options

Returns
body


Description
This extension does not check for overlapping bodies. It is therefore possible to generate invalid bodies. (Lumps are not allowed to intersect or overlap, which could result from this operation.) If it is known that the bodies do not overlap, use body:combine. If it is known that the bodies overlap, or if there is some uncertainty as to whether the bodies overlap, use bool:unite.

This extension is useful during the course of modeling when two separate entities (bodies) need to be treated as one. The result is a single body (entity) with two lumps.
Arguments
body-list specifies the list of two or more solid and/or wire entities (bodies) to be combined. This extension combines all lumps and wires into one body. The resulting body assumes the entity number of the first body in the list. The remaining bodies in the list, with respect to their entity numbers, are deleted. #f is returned if the list contains 0 or 1 bodies.
 
ao specifies options such as versioning and journaling.
; body:combine
; Create block 1.
(define block1
    (solid:block (position 0 0 0)
    (position 10 20 20)))
;; block1
; Set a color for block1
(entity:set-color block1 2)
;; ()
; Create block 2.
(define block2
    (solid:block (position 20 0 0)
    (position 30 40 40)))
;; block2
; Set a color for block2
(entity:set-color block2 3)
;; ()
; OUTPUT Original

; Combine the blocks into a single body
; with two lumps.
(define comb (body:combine (list block1 block2)))
;; comb
; OUTPUT Result

Figure. body:combine

[Top]


body:expand

Action
Transforms the face lists of each shell in the body into a hierarchy of subshells with spatial locality.

Filename
eulr/eulr_scm/eulr_scm.cxx

APIs
api_expand_body

Syntax
(body:expand body-list [acis-opts])

Arg Types
body-list body | (body ...)
acis-opts acis-options

Returns
boolean


Description
This extension expands the body shells.
A successful outcome indicates that the process has run to completion, even if nothing has been changed.
Arguments
body-list specifies the list of two or more solid entities (bodies) to expand.
 
acis-opts contains information related to versioning and journaling.
(part:clear)
(define prism (solid:prism 30 8 8 24))
(define p (pattern:linear (gvector 20 0 0) 10 (gvector 0 20 0) 10 ))
(define prism_pat (entity:pattern prism p))
(define box (solid:block (position -10 -10 -10) (position 205 205 20)))
(bool:subtract box prism_pat)
;; the result of the Boolean operation does not contain any subshells
(entity:debug box 3)
              ;; using command body:expand introduces 126 subshells
(body:expand box)
;; #t
(entity:debug box 3)
;; using command body:flatten removes the 126 subshells
(body:flatten box)
;; #t
(entity:debug box 3)

[Top]


body:flatten

Action
Removes subshell structures from the shells of the given body and replaces the faces in a single list for each shell.

Filename
eulr/eulr_scm/eulr_scm.cxx

APIs
api_flatten_body

Syntax
(body:flatten body-list [acis-opts])

Arg Types
body-list body | (body ...)
acis-opts acis-options

Returns
boolean
Description
This extension removes subshell structures from the shells of the given body and replaces the faces in a single list for each shell. No action is performed when there are no subshells.
A successful outcome indicates that the process has run to completion, even if nothing has been changed.
Arguments
body-list specifies the list of two or more solid entities to flatten.
 
acis-opts contains information related to versioning and journaling.
(part:clear)
(define prism (solid:prism 30 8 8 24))
(define p (pattern:linear (gvector 20 0 0) 10 (gvector 0 20 0) 10 ))
(define prism_pat (entity:pattern prism p))
(define box (solid:block (position -10 -10 -10) (position 205 205 20)))
(bool:subtract box prism_pat)
;; the result of the Boolean operation does not contain any subshells
(entity:debug box 3)
              ;; using command body:expand introduces 126 subshells
(body:expand box)
(entity:debug box 3)
;; using command body:flatten removes the 126 subshells
(body:flatten box)
(entity:debug box 3)

[Top]


body:separate

Action
Separates a single disjoint body into multiple entities.

Filename
scm/scmext/eulr/eulr_scm.cpp

APIs
api_separate_body

Syntax
(body:separate entity)

Arg Types
body body

Returns
(entity ...)
Description
When a disjoint body is created from Boolean operations and sections of solids, the disjoint pieces of the single body can be turned into separate bodies. The disjoint body is separated into a list of bodies, each containing one lump or one wire body. body specifies the body entity to separate. When separating solids, this extension locates all the disjoint pieces and creates individual entities for each body. This extension returns the entities in a list. If the input body contains only one lump or one wire, the input body is returned without change.
; body:separate
; Create a solid block.
(define block1
    (solid:block (position -30 -30 -30)
    (position 5 10 15)))
;; block1
; Set a color for block
(entity:set-color block1 2)
;; ()
; Create a solid cylinder.
(define cyl1
    (solid:cylinder (position 20 15 30)
    (position 20 20 20) 15 1 (position 0 0 0)))
;; cyl1
; Set a color for cyl
(entity:set-color cyl1 3)
;; ()
; Combine entities 1 and 2.
; Result becomes one body with disjoint pieces.
(define combo (body:combine
    (list block1 cyl1)))
;; combo
; OUTPUT Original

; Separate entities 1 and 2.
(define sep (body:separate combo))
;; sep
; OUTPUT Result

Figure. body:separate

[Top]