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.

shell:hollow-body

Action
Creates a thin walled solid shell from a solid body.
Filename
scm/scmext/shl/shl_scm.cpp
APIs
api_hollow_body
Syntax
(shell:hollow-body body-or-face-list thickness
    [box-height box-length] [lopt] [acis-opts])
Arg Types
body-or-face-list body | face | (face ...)
thickness real
box-height position
box-length position
lopt lop_options
acis-opts acis-options
Returns
body
Errors
In addition to the following, refer to the Errors listed for the Scheme extension, lop:tweak-faces.
Valid offset ( greater than minus half the body box max side ), and not a zero offset ( magnitude greater than twice SPAresabs ) or error;-
          LOP_OFF_BAD_OFFSET
Valid body transformation (no shear component) or error;-
          LOP_BAD_BODY_TRANSFORM
Body must have only one shell, or error;-
          LOP_HOL_MULTI_SHELL
Some faces must remain unopen, or error;-
          LOP_HOL_ALL_OPEN

Note: ENTITYs returned in the outcome standard_error_info object are highlighted.

Description
Offsets the owning body of given faces by the supplied thickness, using the optional intersection box, omitting the open faces and subtracts the original body.

Body faces with radial surfaces which cannot be offset by the thickness are removed and the resulting wound healed by the surrounding face surfaces. Radial surfaces are spheres, cones, and tori, blended edges and blended vertices.

This generally leads to shells which are locally overly thick. However in the case of vertex blends with large setbacks being removed, the shell may be locally too thin, or may even have a hole.

Multi-lump bodies may be shelled, but any lumps with more than one shell are not further shelled.

The optional intersection box limits the size of intersections between surfaces which might otherwise be very long. It can not be used to choose faces. Its main purpose is to speed up complicated cases where the intersection curves might be very long, thus improving performance. The box must contain the final faces and if omitted defaults to the size box.

Mergeable edges are retained provided they have a NO_MERGE_ATTRIB.

Topology Changes

Refer to the topology changes listed for the Scheme extension, lop:tweak-faces.

Geometry Changes

Refer to the geometry changes listed for the Scheme extension, lop:tweak-faces.

Arguments
body-or-face-list identifies a body or faces of a body to be shelled.
 
thickness specifies the distance of the shell offset.
 
box-height specifies one position defining a diagonal corner of a box used as an intersection limit.
 
box-length specifies the other position defining a diagonal corner of a box used as an intersection limit.
 
lopt is the local operation option. This argument contains flags that enable repair of self-intersections and vent face additions.
 
acis-opts contains journaling and versioning information.
 
Limitations
Refer to the Limitations listed for the Scheme extension, lop:tweak-faces.
 
The sheet must be manifold.
; shell:hollow-body
; Create a solid block.
(define block1
    (solid:block (position -20 -20 -20)
    (position 20 20 20)))
;; block1
; OUTPUT Original

(define face1 (car (entity:faces block1)))
;; face1
; Hollow the body
(define hollow (shell:hollow-body face1 10))
;; hollow
; OUTPUT Result

Figure. shell:hollow-body

; Example
; Clear previous entities
(part:clear)
;; #t
; Create a sphere.
(define s1 (solid:sphere (position 40 0 0) 20))
;; s1
; Create another sphere.
(define s2 (solid:sphere (position -40 0 0) 20))
;; s2
; Create a cylinder.
(define cyl1 (solid:cylinder (position -40 0 0)
    (position 40 0 0) 10))
;; cyl1
; Unite cylinder and spheres.
(define unite1 (solid:unite cyl1 s1))
;; unite1
(define unite2 (solid:unite cyl1 s2))
;; unite2
; Create a block.
(define block2
    (solid:block (position -100 -200 -100)
    (position 100 0 100)))
;; block2
(define subtract (solid:subtract cyl1 block2))
;; subtract
; OUTPUT Original

; Blend the edges
(define blend1 (solid:blend-edges (pick:edge (ray
    (position 0 10 0) (gvector 1 0 0))) 5))
;; blend1
(define blend2 (solid:blend-edges (pick:edge (ray
    (position 0 10 0) (gvector -1 0 0))) 5))
;; blend2
; Hollow the body to the outside
(define hollow2 (shell:hollow-body (pick:face (ray
    (position 0 5 0) (gvector 0 -1 0))) 5))
;; hollow2
; OUTPUT Shelled to the outside

Figure. shell:hollow-body to the outside

; Roll back three steps.
(roll -3)
;; -3
; Hollow the body to the inside
(define hollow3 (shell:hollow-body (pick:face (ray
    (position 0 5 0) (gvector 0 -1 0))) -10))
;; hollow3
; OUTPUT Shelled to the inside

Figure. shell:hollow-body to the inside

[Top]


shell:hollow-body-specific

Action
Creates a thin walled solid shell from a solid body, with default and specific inner and outer offsets.
Filename
scm/scmext/shl/shl_scm.cpp
APIs
api_hollow_body_specific
Syntax
(shell:hollow-body-specific body
    def-inside-off def-outside-off openface-list
    spec-inside-face-list spec-inside-off-list
    spec-outside-face-list spec-outside-off-list
    [box-height box-length] [lopt] [acis-opts])
Arg Types
body body
def-inside-off (real ...)
def-outside-off (real ...)
openface-list (face ...)
spec-inside-face-list (face ...)
spec-inside-off-list (real ...)
spec-outside-face-list (face ...)
spec-outside-off-list (real ...)
box-height position
box-length position
lopt lop_options
acis-opts acis-options
Returns
body
Errors
In addition to the following, refer to the Errors listed for the Scheme extension, lop:tweak-faces.
Inner or outer default must be set (size greater than twice SPAresabs), and valid (greater than minus half the body box max side), and inner default offset must be less than the outer. Specific offsets must be non zero ( size greater than twice SPAresabs ), and valid ( greater than minus half the body box max side ). The outer offset for any face ( default or specific ) must be greater than the inner offset ( default or specific )
LOP_OFF_BAD_OFFSET
Valid body transformation (no shear component) or error.
LOP_BAD_BODY_TRANSFORM
Body must have at least one lump with only one shell, or error.
LOP_HOL_MULTI_SHELL
Some faces must remain unopen, or error.
LOP_HOL_ALL_OPEN
Open faces must not have a specific offset, or error.
LOP_TWK_BAD_FACE

Note: that ENTITYs returned in the outcome standard_error_info object are highlighted.

Description
Shells the supplied body by the offset distances omitting the specified open faces which thus generate openings into the internal void. The default offsets are applied to all faces except the open faces, unless overridden by specific offsets.

Body faces with radial surfaces which cannot be offset by the thickness are removed and the resulting wound healed by the surrounding face surfaces. Radial surfaces are spheres, cones, and tori, blended edges and blended vertices. This generally leads to shells which are locally overly thick. However, in the case of vertex blends with large setbacks being removed, the shell may be locally too thin, or may even have a hole.

Multi-lump bodies may be shelled, but any lumps with more than one shell are not further shelled.

The optional intersection box limits the size of intersections between surfaces which might otherwise be very long. It can not be used to choose faces. Its main purpose is to speed up complicated cases where the intersection curves might be very long, thus improving performance. The box must contain the final faces and if omitted, defaults to the size box.

Mergeable edges are retained provided they have a NO_MERGE_ATTRIB .

Topology Changes:

Refer to the topology changes listed for the Scheme extension, lop:tweak-faces.

Geometry Changes:

Refer to the geometry changes listed for the Scheme extension, lop:tweak-faces.

Arguments
body is an input solid body.
 
def-inside-off is a real value that gives the inner default offset.
 
def-outside-off is a real value that gives the outer default offset which should be more than the inner one.
 
openface-list is a list of open faces.
 
spec-inside-face-list specifes inside face list.
 
spec-inside-off-list is real values that gives the inside default offset.
 
spec-outside-face-list specifies outside face list.
 
spec-outside-off-list is real values that gives the outside default offset.
 
box-height specifies one position defining a diagonal corner of a box used as an intersection limit.
 
box-length specifies the other position defining a diagonal corner of a box used as an intersection limit.
 
lopt is the local operation option. This argument contains flags that enable repair of self-intersections and vent face additions.
 
acis-opts contains versioning and journaling information.
 
Limitations
The sheet must be manifold. Refer to the Limitations listed for the Scheme extension, lop:tweak-faces.
; shell:hollow-body-specific
; Build a model
(view:set (position 75 25 50) (position 0 0 0)
    (gvector 0 0 1))
;; #[view 1076829024]
(view:set-perspective OFF)
;; #f
(define block1 (solid:block
    (position -20 -20 -20) (position 20 20 20)))
;; block1
; OUTPUT Original
(define top-face (pick:face (ray (position 0 0 0)
    (gvector 0 0 1))))
;; top-face
(define front-face (pick:face
    (ray (position 0 0 0) (gvector 1 0 0))))
;; front-face
; Hollow the body,default inside -5,top open,
; front outside 10
(define hollow3 (shell:hollow-body-specific block1
     (list -5) (list)
    (list top-face) (list) (list)
    (list front-face) (list 10)))
;; hollow3
; OUTPUT Result

Figure. shell:hollow-body-specific

[Top]


shell:offset-make-sheet

Action
Offsets specified faces by distances specific to each, and creates a sheet body out of the offset faces.
Filename
scm/scmext/shl/shl_scm.cpp
APIs
api_offset_faces_make_sheet
Syntax
(shell:offset-make-sheet def-face-list def-offset
    spec-face-list spec-offset-list [box-height box-length]
   [lopt] [acis-opts])
Arg Types
def-face-list face | (face ...)
def-offset real
spec-face-list face | (face ...)
spec-offset-list real | (real ...)
box-height position
box-length position
lopt lop_options
acis-opts acis-options
Returns
body
Errors
Refer to the errors listed for the Scheme extension, lop:offset-specific.

Description
Offsets surfaces of the supplied faces by an offset distance specific for each face. Creates a new sheet body out of those faces. The sheet body is converted to sheet2d.

Radial faces with surfaces which cannot be so offset are removed and the resulting wound healed by the surrounding face surfaces.

Optionally repair body can be used during the offset.

Topology Changes:

In addition to the following, refer to the topology changes listed for the Scheme extension, lop:tweak-faces.

Faces with radial surfaces which cannot be offset by the distance without degenerating or inverting (spheres, cones, blended edges, blended vertices, and tori) are removed and the resulting wound healed by the surrounding face surfaces, before the offset.

Geometry Changes:

The geometry changes performed by tweak-faces on the tweaked faces and their neighbors are:

pipe_spl_sur spline surfaces will be converted to rb_blend_spl_sur spline surfaces in the supplied faces and their neighbors if the option lop_convert_pipe is set on, which is the default setting.

Arguments
def-face-list identifies faces of a body to be offset.
 
def-offset specifies the value of the offset distance.
 
spec-face-list identifies faces of a body to be offset. based on the specific face list.
 
spec-offset-list specifies the value of the offset distance of a specific list of entities.
 
box-height specifies one position defining a diagonal box for an intersection limit.
 
box-length specifies one position defining a diagonal box for an intersection limit.
 
lopt is the local operation option. This argument contains flags that enable repair of self-intersections and vent face additions.
 
acis-opts specifies ACIS options such as version and journal.
Limitations
Body must be manifold and solid.

No other topology changes than those documented above are permitted. Tweak faces does not extend the geometry of the tool surfaces or their neighbors (unlike the other local operations which do).
; shell:offset-make-sheet
; Set the position of the view.
(define viewset (view:set (position 75 25 50)
    (position 0 0 0) (gvector 0 0 1)))
;; viewset
; Set the perspective of the view.
(view:set-perspective #f)
;; #f
(define b1 (solid:block (position -25 -25 -25)
    (position 25 25 25)))
;; b1
; OUTPUT Original
; Offset bottom and back 10 (default),
; top 20 and front -10 (specific)s
(define shl-off (shell:offset-make-sheet
    (list
       (pick:face (ray (position 0 0 0)
       (gvector 0 0 -1)))
       (pick:face (ray (position 0 0 0)
       (gvector -1 0 0)))) 10 (list
       (pick:face (ray (position 0 0 0)
       (gvector 0 0 1)))
       (pick:face (ray (position 0 0 0)
       (gvector 1 0 0))))
       (list 20.0 -10.0)))
;; shl-off

Figure. shell:offset-make-sheet

[Top]


shell:sheet-thicken

Action
Creates a solid body from a sheet.
Filename
scm/scmext/shl/shl_scm.cpp
APIs
api_sheet_thicken
Syntax
(shell:sheet-thicken body thickness [both=#f]
    [box-height box-length] [lopt] [acis-opts])
Arg Types
body body
thickness real
both boolean
box-height position
box-length position
lopt lop_options
acis-opts acis-options
Returns
body
Errors
Refer to the Errors listed for the Scheme extension, lop:tweak-faces .

Note: ENTITYs returned in the outcome standard_error_info object are highlighted.

Description
The purpose of sheet thickening is to create a realistic, three-dimensional sheet from an ideal two-dimensional sheet. Typically, the thickness supplied is very small.

This extension makes a copy of the sheet to be thickened, offsets it, and fits new orthogonal side faces between the two copies. If the boolean both is false and the thickness supplied is positive, the sheet is thickened in the direction of the sheet normal. Supplying a negative thickness provokes thickening in the opposite direction from the sheet normal. If the boolean both is true the sheet is thickened in both directions by half the thickness. If both is not supplied, its default value is false.

The optional intersection box limits the size of intersections between surfaces which might otherwise be very long. It can not be used to choose faces. Its main purpose is to speed up complicated cases where the intersection curves might be very long, thus improving performance. The box must contain the final faces and if omitted defaults to the size box.

Topology Changes:

Refer to the topology changes listed for the Scheme extension, lop:tweak-faces.

Vertices may be split as a result of thickening the sheet.

Mergeable edges are removed unless they have a NO_MERGE_ATTRIB.

Geometry Changes:

Refer to the geometry changes listed for the Scheme extension, lop:tweak-faces.

Arguments
body identifies the sheet to be thickened.
 
thickness specifies the distance of the thickness.
 
both specifies the type of thickness to be done, in one direction (#f) or two directions (#t). The default is one direction.
 
box-height specifies one position defining a diagonal corner of a box used as an intersection limit.
 
box-length specifies the other position defining a diagonal corner of a box used as an intersection limit.
 
lopt is the local operation option.
 
acis-opts contains versioning and journaling information.
Limitations
In addition to the following, refer to the Limitations listed for the Scheme extension, lop:tweak-faces.
 
The sheet must be manifold. More specifically, that means:
 
There cannot be more than two sheet edges meeting at any vertex and the sheet must consist of no more than one shell.
If the sheet is made up of several faces, the normals of adjacent faces must be consistent.
Laminas cannot be thickened. Only single-sided sheets can be thickened. If a double-sided sheet is encountered it is made single-sided.
; shell:sheet-thicken
; Thicken a sheet made up of two faces by 5 in the
; direction of the face normals.
(define s1
    (sheet:face (face:plane
    (position -60 50 -20) 50 50)))
;; s1
(define s2
    (sheet:face (face:reverse
    (face:plane (position -60 50 -20) 50 50
    (gvector 0 1 0)))))
;; s2

; OUTPUT Original
; Convert the bodies to 2d and unite.
(define convert1 (sheet:2d s1))
;; convert1
(define convert2 (sheet:2d s2))
;; convert2
(define unite (bool:unite s1 s2))
;; unite
; Thicken the sheet body.
(define thicken (shell:sheet-thicken s1 5 #f))
;; thicken
; OUTPUT Result

Figure. shell:sheet-thicken

[Top]


solid:make-from-face-list

Action
Create a solid from each manifold connected set of faces in the input face list.
Filename
scm/scmext/shl/shl_scm.cpp
APIs
api_make_solid_from_faces
Syntax
(solid:make-from-face-list face-list [growth-type]
    [remove-faces] [lopt] [acis-opts])
Arg Types
face-list (face... )
growth-type integer
remove-faces integer
lopt lop_options
acis-opts acis-options
Returns
((boolean... ) (body... ))

Description
Creates a solid from a list of faces and connecting or growing new faces in the gaps between them. These faces are copied and separated to form a unique manifold body. Each connected set of faces are then repaired by growing faces to cover opening and a solid is created from the faces. These solids are then return from the function along with a boolean flag that describes if the body is the result of filling a hole (TRUE) or replicating a boss (FALSE).

Arguments
face-list identifies the set of faces to be used.
 
growth-type specifies the way in how to grow the open faces.
0 (from_parent) : Grow faces to repair hole from parent body (Default)
1 (from_child) : Grow faces to repair hole from child body
2 (from_cover) : Use cover to repair hole
 
remove-faces changes the orginal body by removing the faces in the face-list from the body (0 - FALSE, 1 - TRUE).
 
lopt is the local operation option.
 
acis-opts contains versioning and journaling information.
Limitations
Faces must be a manifold connected set.
 
Faces must be able to be removed from the body by api_remove_faces.
; solid:make-from-face-list
(part:clear)
;; #t
(define b (solid:block
    (position -5 -2.5 0)(position 5 2.5 1)))
;; b
(shell:hollow-body (list-ref
    (entity:faces b) 0) -0.1)
;; #[entity 1 1]
(bool:unite b (solid:cylinder
    (position 0 0 0)(position 0 0 2) .25))
;; #[entity 1 1]
(bool:unite b (solid:sphere
    (position 0 0 2) 0.5))
;; #[entity 1 1]
; OUTPUT Original

;; Select the faces needed
(entity:fix-transform b)
;; #[entity 1 1]
(ray:queue 0 0 1 1 0 0 0.1)
;; #[ray (0 0 1) (1 0 0)]
(define f1 (pick-face))
;; f1
(ray:queue 0 0 2 1 0 0 0.1)
;; #[ray (0 0 2) (1 0 0)]
(define f2 (pick-face))
;; f2
(define faces (list f1 f2))
;; faces
(entity:set-color faces 1)
;; ()
; Make a new body from the selected faces,
; leaving the original body intact.
(solid:make-from-face-list faces 0 0)
;; ((#f) (#[entity 12 1]))
; OUTPUT Result

Figure. solid:make-from-face-list

[Top]