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.

edge:helix

Action
Creates an edge that is a helix.

Filename
scm/scmext/ofst/woff_scm.cpp

APIs
api_edge_helix

Syntax
(edge:helix axis-start axis-end start-dir radius
    thread-distance [handedness=#t] [ao])

Arg Types
axis-start position
axis-end position
start-dir gvector
radius real
thread-distance real
handedness boolean
ao acis-options

Returns
edge
Arguments
axis-start specifies the start position of the helix axis.

axis-end specifies the end position of the helix axis.

start-dir specifies the start direction.

radius specifies the radius of the helix.

thread-distance specifies the distance between the threads.

handedness is set to true (#t) for right hand helix or false (#f) for left hand helix. The default value is true (#t).

ao contains journaling and versioning information.
; edge:helix
; Create a helical edge.
(define axis-start1 (position 0 0 0))
;; axis-start1
(define axis-end1 (position 0 0 10))
;; axis-end1
(define start-dir1 (gvector 1 0 0))
;; start-dir1
(define radius1 5)
;; radius1
(define thread-distance1 2)
;; thread-distance1
(define helix1
    (edge:helix axis-start1
    axis-end1 start-dir1 radius1 thread-distance1))
;; helix1
; Create another helical edge.
(define helix2
    (edge:helix (position -20 0 0)
    (position -20 10 10) (gvector 0 1 0) 5 2 #f))
;; helix2
; And one more.
(define helix3
    (edge:helix (position 20 0 0)
    (position 20 0 10) (gvector 0 1 0) 5 2 #f))
;; helix3
; OUTPUT Example

Figure. edge:helix

[Top]


face:offset

Action
Creates a new face offset from a given face.

Filename
scm/scmext/ofst/foff_scm.cpp

APIs
api_offset_face

Syntax
(face:offset face distance [apply-transform=#f] [ao])

Arg Types
face face
distance real
apply-transform boolean
ao acis-options

Returns
face

Description
This extension creates a new face that is offset a specified distance from a given face.

Arguments
face specifies the face to offset.

distance specifies the offset distance.

If apply-transform is set to true (#t), the transform of the body which contains the given face is applied to the offset face. The default is false (#f).

ao contains journaling and versioning information.

Limitations
This extension assumes that the user does not try to create a degenerate face; for example, offsetting a cylinder toward its axis a distance greater than the cylinder radius.
; face:offset
; Create a face.
(define face1 (face:plane (position 0 0 0) 30 30))
;; face1
; Create a face offset.
(define offset1 (face:offset face1 5))
;; offset1
; OUTPUT Example

Figure. face:offset

[Top]


wire-body:offset

Action
Creates a new wire by offsetting the given wire using offset and twist laws.

Filename
scm/scmext/ofst/woff_scm.cpp

APIs
api_offset_planar_wire

Syntax
(wire-body:offset base_wire offset_options [ao])

Arg Types
base_wire wire
offset_options wire_offset_options
ao acis-options

Returns
wire

Description
This command performs an offset operation to the given base wire with the parameters specified by the given wire offset options.

Arguments
base_wire must be a planar wire body entity.

offset_options is the wire_offset_options scheme object.

ao contains journaling and versioning information.

Limitations
Non-constant offset laws and non-zero twist laws are not supported by the gap fill feature and may not produce the desired results.
; wire-body:offset
; Create a wire-body by offsetting a wire by
; a given distance.
; Create edge 1.
(define edge1
    (edge:circular (position 10 0 0) 10))
;; edge1
; Create a wire-body from the edges.
(define wirebody1 (wire-body (list edge1)))
;; wirebody1
; OUTPUT Original ; Offset a wire-body outside the original wire-body.
(define offset (wire-body:offset wirebody1 5 "2*x"))
;; offset
; OUTPUT Result

Figure. wire-body:offset

; Another example using laws.
(part:clear)
;; #t
(define edge1 (edge:circular (position 0 0 0) 20))
;; edge1
; OUTPUT Original
(define wirebody2 (wire-body edge1))
;; wirebody2
(define offset1
    (wire-body:offset wirebody2
    "20+10*cos(x*10)"))
;; offset1
; OUTPUT Result

Figure. wire-body:offset - Using Laws to Define Geometry

[Top]


wire-body:offset1

Action
Creates an offset of a planar wire body.

Filename
scm/scmext/ofst/woff_scm.cpp

APIs
api_offset_planar_wire

Syntax
(wire-body:offset1 wire offset-distance [direction] [ao])

Arg Types
wire wire
offset-distance real
direction par-pos | gvector
ao acis-options

Returns
wire

Description
The function expects a body containing at least one independent wire that is not connected to any faces. If the body contains multiple independent wires, each independent wire in the body will be offset and united with the offsets of the others.

This function offsets a single wire of a multi-wire body.

Arguments
wire must be a planar wire body entity.

offset-distance is the offset distance.

direction is an optional argument that specifies the plane normal to be used for offsetting the non-planar wires.

ao is an optional argument that contains journaling and versioning information
; wire-body:offset1
(define e1(edge:linear (position 0 0 0) (position 10 0 0)))
(define e2(edge:linear (position 10 0 0) (position 20 0 0)))
(define WB(wire-body (list e1 e2)))
(define x-vec(gvector 0 1 0))
(define offset1 (wire-body:offset1 WB 5 x-vec))

[Top]


wire-body:offset2

Action
Creates an offset of a planar wire body.

Filename
scm/scmext/ofst/woff_scm.cpp

APIs
api_offset_planar_wire

Syntax
(wire-body:offset2 wire offset-distance [transf] [direction] [ao])

Arg Types
wire wire
offset-distance real
transf transform
direction par-pos | gvector
ao acis-options

Returns
wire

Description
The function expects a body containing at least one independent wire that is not connected to any faces. If the body contains multiple independent wires, each independent wire in the body will be offset and united with the offsets of the others.

This function offsets a single wire of a multi-wire body.

Arguments
wire must be a planar wire body entity.

offset-distance is the offset distance.

transf is an optional argument that translates, rotates, scales, and reflects top-level entities.

direction is an optional argument that specifies the plane normal to be used for offsetting the non-planar wires.

ao is an optional argument that contains journaling and versioning information
; wire-body:offset2
(define e1(edge:linear (position 0 0 0) (position 10 0 0)))
(define e2(edge:linear (position 10 0 0) (position 0 10 0)))
(define WB(wire-body (list e1 e2)))
(define x-vec(gvector 0 1 0))
(define offset1 (wire-body:offset2 WB 5 (transform:rotation (position 0 0 0) (gvector -3 0 0) 45) x-vec))

[Top]


wire-offset:options

Action
Sets the wire_offset_options scheme object used by the wire offset scheme extensions.

Filename
scm/scmext/ofst/woff_scm.cpp

APIs
None.

Syntax
(wire-offset:options (name-of-option value) [options])

Arg Types
name-of-option string
value string | law | real | gvector
options wire_offset_options

Returns
None.

Description
Sets the wire_offset_options scheme object used by the wire offset scheme extensions.

Assume that the planar wire body wire, is re-parameterized to the variable x, becoming curve(x). T is the tangent to curve(x), and N is a normal to the wire's plane. The double bars surrounding the cross product T x N indicate they are unitized. The offset curve to the wire body at x is then given by the following equation.

Arguments
name-of-option is a string placed within quotation marks. If value is a real, it does not require delimiters. If value is a string representing a law, it should be enclosed in quotation marks. If value is a law, only the variable name for the law is required. Multiple pairs of name-of-option and value can be specified simultaneously. The available values for this option are:
  • gap_type
  • distance
  • trim
  • overlap
  • keep_minimum_topology
  • plane_normal
  • twist_law

gap_type specifies the type of gap to be placed when the offsets of adjacent, non-tangential wire edges do not touch at a common vertex. The type can be "n", "r", or "e" ("N", "R", "E"), which represents natural, arc, or linear gap fill, respectively. Presently, the gap type "natural" might be done with a linear extension if curvature extension cannot be achieved. Also the gap types "linear" and "natural" might be done with an "arc" extension if the gap cannot be filled by the intersection of the two extended neighboring offset curve segments. A warning is issued if the gap_type is changed.

distance can be either a double value or a law, which specifies the offset distance.

trim is a Boolean value to indicate if self intersections are to be removed. Default value is true.

overlap is a Boolean value to indicate if overlapping segments are to be removed. Default value is true.

keep_minimum_topology is a Boolean value to indicate if additional edges are allowed in a gap fill. Currently when filling a gap linearly or with an arc, additional edges are added at the gap. If keep_minimum_topology is true, the additional gap fill edges will not be added. If this leads to an unconnected offset curve, an error will be issued. Default value is false.

plane_normal is the option that specifies the normal vector of the wire plane, which is the plane where the wire body lies. Because wire offset is a 2D offset, the wire body must lie on a plane. Default value is computed plane normal by an ACIS internal function.

twist_law specifies whether to use the twist law. Default value is no law (that is, no twist); thus, the offset curve becomes simply a function of the given offset-distance-law at the curve parameter x. In such a case and if the offset-distance-law is a constant, the unitized cross product T x N specifies the positive direction for the offset. If the twist-law is specified, the given equation determines where the offset curve at curve parameter x lies in three dimensional space. Twisting is about the tangent vector T of the wire curve and in the plane created by T x N and N. The twist-law specifies the angle in the TxN and N plane for the offset curve. (The twist-law evaluates to a number that is input as radians to the cos and sin law functions.) For example, if the offset-distance-law is the constant 2 and the twist-law is simply the law function "x", then the result is a helix of radius 2 that winds around wire.

Note: All the options are optional, except distance, which must be specified for a successful wire offsetting operation. If an option is not specified, the default one is used.


options specifies wire_offset_options.
(define wopts (wire-offset:options "distance" -2))
(define wopts (wire-offset:options

               "distance" -2
               "gap_type" "N"
               "trim" #t
               "wire_normal" (gvector 0 0 -1)))

(define wopts (wire-offset:options "distance" "x/4 + 20" "twist_law" "x"))

[Top]