Scheme Extensions Ia thru Qz

 

 

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. Spatials Scheme based demonstration application, Scheme ACIS Interface Driver Extension (Scheme AIDE), also uses these Scheme extensions and the Scheme Interpreter.

iccache:set-mode

Action
Set int_cur global cache run mode.

Filename
kern/kern_scm/gcmgr_scm.cpp

APIs
None

Syntax
(iccache:set-mode run_mode)

Arg Types
run_mode string

Returns
string, previous run mode

Description
Set int_cur global cache run mode.

Arguments
run_mode specifies the int_cur global cache run mode. The two possible values are "no_limit" or "hard_limit".

Example

; set new int_cur global cache run mode
(iccache:set-mode 'hard_limit')
;; no_limit

[Top]


iccache:set-size

Action
Set int_cur global cache size.

Filename
kern/kern_scm/gcmgr_scm.cpp

APIs
None

Syntax
(iccache:set-size new_size)

Arg Types
new_size integer

Returns
integer, if successful, value is size of cache before change otherwise, zero.

Description
Set int_cur global cache size.

Arguments
new_size specifies the int_cur global cache size, must be greater than or equal to three.

Example

; set new int_cur global cache size
(iccache:set-size 40)
;; 80

[Top]


is:helix

Action
Determines whether or not the input entity is a helix.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(is:helix in-entity)

Arg Types
in-ent entity

Returns
boolean

Description
The input entity in-ent should be an edge.

Arguments
in-ent specifies an entity.
; is:helix
; Create a profile to sweep into a helix.
(option:set "sil" #f)
;; #t
(define profile1 (edge:linear
    (position 5 0 0) (position 10 0 0)))
;; profile1
(is:helix profile1)
;; #f
(define path1(edge:helix
    (position 0 0 0)
    (position 0 40 0)
    (gvector 1 0 0) 10 20 #t))
;; path1
(define helix1(sweep:law profile1 path1))
;; helix1
(define edge-list (entity:edges helix1))
;; edge-list
(is:helix (list-ref edge-list 0))
;; #f
(is:helix (list-ref edge-list 1))
; Axis 0.000000 1.000000 0.000000
; Root 0.000000 9.325620 0.000000
; Pitch 20.000000
; Radius 5.000000
; Right Handed
;; #t
(is:helix (list-ref edge-list 2))
;; #f
(is:helix (list-ref edge-list 3))
; Axis 0.000000 1.000000 0.000000
; Root 0.000000 9.328920 0.000000
; Pitch 20.000000
; Radius 10.000000
; Right Handed
;; #t

[Top]


law

Action
Creates a law Scheme data type composed of one or more law functions.

Filename
scm/scmext/kern/law_scm.cpp

APIs
api_str_to_law

Syntax
(law {"law-functions" | type} [law-data]*)

Arg Types
"law-functions" string
type law | real | position | par-pos | gvector
law-data law | real | position | par-pos | gvector | transform | edge | wire

Returns
law

Description
The law Scheme extension creates a law Scheme data type composed of one or more law functions.

Arguments
"law-functions" is a string specifying law function enclosed in quotation marks. The law functions are very similar to common mathematical notation and to the adaptation of mathematical notation for use in computers. The valid syntax for the character strings are given in the law function templates. The strings used to define laws are not case-sensitive, but when returned from a law function, the lower-case letters are converted to upper-case letters. Only laws that are used to define the geometry, such as wire-body:offset and sweep:law, are stored in a save file.

type defines the data type of law-functions.

The optional argument defined in law-data must agree with the items specified within law-functions in type, number, and order. For example, if the law-functions calls for law1, edge2, and wire3, the input must be a list with at least three items: the first item must be a law; the second item must be an edge; and the third item must be a wire. The index number of the item within the law function specifies its ordering in the input list. position, par-pos, or gvector may be used as law-data, which correspond to the law# and are converted into the "vec" law function.
; law
; Create a new law.
(define law1 (law "x+x^2-cos(x)"))
;; law1
; Evaluate the given law at 1.5 radians
(law:eval law1 1.5)
;; 3.6792627983323

; Another example using law data
; This creates a law that returns the position
; of an edge with its position mapped to the
; closed interval [0,1].
; Create an edge.
(define edge1 (edge:linear (position 0 0 0)
    (position 40 40 0)))
;; edge1
(define edge-law (law
    "map(cur(edge1)),edge1)" edge1))
;; edge-law

[Top]


law:bounds

Action
Finds the bounds for a law function.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:bounds law1 [low high])

Arg Types
law1 law
low real
high real

Returns
( real ...)

Errors
Checking the bounds on a law with an infinite domain returns an error.

Description
This returns a list of bounds of the law from the different interval pairs entered.

Arguments
law1 specifies a law.

low and high are optional intervals over which the bounds are computed. If not specified, the extension attempts to compute the domain from the law itself.
; law:bounds
; Define a law and find the bounds on interval.
; Create a law.
(define law1 (law "x+x^2-cos(x)"))
;; law1
(law:bounds law1 -2 20)
; -5.350134 to 423.799265
; Tolerance: 0.001000
;; (-5.35013412467261 423.799264988314 0.001)

[Top]


law:check

Action
Prints out the laws string.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:check law)

Arg Types
law law | string | real | position | par-pos | gvector

Returns
string

Description
Prints out the laws string or a simplified laws string. Determines if a law is zero, constant, or linear. Tells what its takes and returns. Return the domain of the law.

Arguments
law specifies a law.
; law:check
; Create a law.
(define law1 (law "x+x^2-cos(x)"))
;; law1
; Check the law.
(law:check law1)
; (X+X^2)-COS(X
; Simplified (X+X^2)-COS(X)
; Zero #f
; Constant #f
; Linear #f
; Takes 1 argument
; Returns 1 argument
; Dx = 1+2*X+SIN(X)
; Inverse of this law is not available.
; Numerator = (X+X^2)-COS(X)
; Denominator = 1
; The domain in variable 0 is infinite
;; #t

[Top]


law:count

Action
Gets a count of laws in use.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:count)

Arg Types
None

Returns
boolean

Description
A static list holding each of one law class is maintained. Therefore, the law count number will never be zero. This is used for testing of memory leaks in laws. This command should be used with the collect Scheme extension to find memory leaks.

; law:count
; Create a law.
(define law1 (law "x+x^2-cos(x)"))
;; law1
; Check to see how many laws are in use.
(law:count)
;; 121
; This return depends on how many laws were defined
; and the number of laws maintained in the law static
; list.

[Top]


law:cubic

Action
Creates a cubic law given {a,b,f(a),f(b),f(a),f(b)}.

Filename
scm/scmext/kern/law_scm.cpp

APIs
api_make_cubic

Syntax
(law:cubic a b f-a f-b df-a df-b)

Arg Types
a real
b real
f-a real
f-b real
df-a real
df-b real

Returns
boolean

Description
Produces a cubic a polynomial with given boundary conditions for both it and its first derivative.

Arguments
a and b specify the boundary values.

f-a and f-b are the desired output of the law at a and b.

df-a and df-b are the desired output of the first derivative at a and b.  
; law:cubic
; Create a law.
(define law1 (law:cubic 0 1 2 3 4 5))
;; law1
; According to the definition, if a 0 is input,
; the output should be 2 and its first derivative
; at 0 is 4.
(law:eval law1 0)
;; 2
(law:eval law1 1)
;; 3
(define deriv (law:derivative law1))
;; deriv
(law:eval deriv 0)
;; 4
(law:eval deriv 1)
;; 5

[Top]


law:derivative

Action
Creates a law object that is the derivative of the given law with respect to the given variable.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:derivative law [with-respect-to])

Arg Types
law law | string | real | position | par-pos | gvector
with-respect-to law | string

Returns
law

Description
The law:derivative returns the exact derivative of the given law function.

Arguments
law specifies a law.

with-respect-to is an optional argument specifying an identity law, such as x, y, z, or a#, etc. If with-respect-to is provided, then the derivative is performed with respect to this argument; else the derivative is assumed to be with respect to x or a1.
; law:derivative
; Define a law to use.
(define law1 (law "x^2"))
;; law1
; To get exact results, take the exact derivative.
; Create the derivative of that law.
(define d-law (law:derivative law1))
;; d-law
; Evaluate the derivative.
(law:eval d-law 3)
;; 6
; Evaluate the second derivative.
(law:eval (law:derivative d-law) 3)
;; 2
; Find the numerical derivative at 3.
(law:nderivative law1 3 "x" 1)
;; 5.9999999999838
; Find the second numerical derivative at 3.
(law:nderivative law1 3 "x" 2)
;; 1.9999997294066

[Top]


law:end

Action
Returns the end of the domain for a law.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:end in-law [term])

Arg Types
in-law law
term integer

Returns
real

Description
Returns the end of the domain of a law.

Arguments
in-law specifies a law.

The optional term argument could be used to localize which term in the law is used.
; law:end
; Define a profile to sweep for interesting shape
(define profile1 (wire-body:points
    (list (position 5 0 0)
    (position 10 0 0)
    (position 10 5 0)
    (position 5 5 0)
    (position 5 0 0))))
;; profile1
(define path1(edge:helix
    (position 0 0 0)
    (position 0 40 0)
    (gvector 1 0 0) 10 20 #t))
;; path1
(define helix1(sweep:law profile1 path1))
;; helix1
(define edge-list(entity:edges helix1))
;; edge-list
(define law1
    (law "cur(EDGE1)"
    (list-ref edge-list 3)))
;; law1
(law:start law1)
;; 0
(law:end law1)
;; 12.5663706143592

[Top]


law:eval

Action
Evaluates a given law or law expression with the specified input and returns a real or list of reals.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:eval law input)

Arg Types
law law | string | real | position | par-pos | gvector
input (entity | entity ...) | real | gvector | position | par-pos

Returns
real | (real ...)

Description
This Scheme extension evaluates the law at the given input value(s).

Arguments
law can be: a law Scheme type or a string enclosed by double quotation marks, any combination of law functions or can be multidimensional in domain and range. The vec law symbol can be used as part of the law definition to generate a multidimensional range (for example, output is a list of reals).

input specifies the value(s) for evaluating the law.
; law:eval
; Create a new law.
(define law1 (law "x+x^2-cos(x)"))
;; law1
; Evaluate the given law at 1.5 radians
(law:eval law1 1.5)
;; 3.6792627983323
; Create a law with a multidimensional range.
(define mlaw (law "vec(x+2,x+3,x+4,x+5)"))
;; mlaw
(law:eval mlaw 3)
;; (5 6 7 8)
; Create a law with a multidimensional domain.
(define law2 (law "x^2 + y + z"))
;; law2
(law:eval law2 (list 2 3 4))
;; 11
(define law3 (law "a3^2 + a2 + a4"))
;; law3
; When evaluating this, the law function has 4 as its
; highest input index. Thus, the input list has to
; have at least four items. Input a1 is not used in
; the law function, so the first element of list
; is not used.
(law:eval law3 (list 1 2 3 4))
;; 15
; a3=3, a2=2, and a4=4. (a1=1).

[Top]


law:eval-par-pos

Action
Evaluates a parameter position.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:eval-par-pos in-law input)

Arg Types
in-law law | string | real | position | par-pos | gvector
input (entity | (entity ...)) | real | gvector | position | par-pos

Returns
position | par-pos

Errors
The in-law must return 2 or 3 values.

Arguments
in-law can be: a law Scheme type or a string enclosed by double quotation marks or any combination of law functions.

input specifies the value(s) for evaluating the law.
; law:eval-par-pos
; Evaluate a parameters position
(define law1 (law "vec(x,x^2)"))
;; law1
(law:eval-par-pos law1 2)
;; #[par-pos 2 4]
(define law2 (law "vec(x^2, y+3*z)"))
;; law2
(law:eval-par-pos law2 (list 2 3 4))
;; #[par-pos 4 15]

[Top]


law:eval-position

Action
Evaluates a given law or law expression with the specified input and returns a position or a par-pos.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:eval-position law input)

Arg Types
law law | string | real | position | par-pos | gvector
input (entity | (entity ...)) | real | gvector | position | par-pos

Returns
position | par-pos

Errors
The law must return 2 or 3 values.

Description
This Scheme extension evaluates the law at the given input. It is the same as law:eval except that it returns either a position or a par-pos instead of a real or list of reals. The output dimension of law has to be two (2) or three (3). The result is a par-pos when the output dimension is two, and position when it is three.

Arguments
law can be: a law Scheme type or a string enclosed by double quotation marks, or any combination of law functions.

input specifies the value(s) for evaluating the law.
; law:eval-position
; Create a new law.
(define law1 (law "vec(x,x^2,-cos(x))"))
;; law1
; Evaluate the given law at 1.5 radians
(law:eval-position law1 2)
;; #[position 2 4 0.416146836547142]
(define law2 (law "vec(x^2, y, 3 * z)"))
;; law2
; Evaluate the second law at some input values.
(law:eval-position law2 (list 2 3 4))
;; #[position 4 3 12]
(define law3 (law "vec(a3^2,a2,a4)"))
;; law3
; When evaluating this, the law function has 4 as its
; highest input index. Thus, the input list has to
; have at least four items. In law3, input A1 is
; not used in the law function, so the first element
; of list is not used.
; a3=3, a2=2, and a4=4. (a1=1).
(define law4 (law "vec(a3^2,a4)"))
;; law4
(law:eval-position law3 (list 1 2 3 4))
;; #[position 9 2 4]
(law:eval law3 (list 1 2 3 4))
;; (9 2 4)
(law:eval-position law4 (list 1 2 3 4))
;; #[par-pos 9 4]

[Top]


law:eval-vector

Action
Evaluates a given law or law expression with the specified input and returns a gvector.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:eval-vector law input)

Arg Types
law law | string | real | position | par-pos | gvector
input (entity | (entity ...)) | real | position | par-pos

Returns
unspecified

Errors
The law must return 3 values.

Description
This Scheme extension evaluates the law at the given input. It is the same as law:eval except that it returns a gvector instead of a real or list of reals. The output dimension of law has to be three (3).

Arguments
law can be: a law Scheme type or a string enclosed by double quotation marks, or any combination of law functions.

input specifies the value(s) for evaluating the law.
; law:eval-vector
; Create a new law.
(define law1 (law "vec(x,x^2,-cos(x))"))
;; law1
; Evaluate the given law at 1.5 radians
(law:eval-vector law1 2)
;; #[gvector 2 4 0.416146836547142]
(define law2 (law "vec(x^2, y, 3 * z)"))
;; law2
; Evaluate the second law at some input values.
(law:eval-vector law2 (list 2 3 4))
;; #[gvector 4 3 12]
(define law3 (law "vec(a3^2,a2,a4)"))
;; law3
; When evaluating this, the law function has 4 as its
; highest input index. Thus, the input list has to
; have at least four items. Input A1 is not used in
; the law function, so the first element of list
; is not used.
; a3=3, a2=2, and a4=4. (a1=1).
(law:eval-vector law3 (list 1 2 3 4))
;; #[gvector 9 2 4]
(law:eval law3 (list 1 2 3 4))
;; (9 2 4)

[Top]


law:hedgehog

Action
Creates visible vector field lines along an edge or wire.

Filename
scm/scmext/kern/law_scm.cpp

APIs
api_hedgehog

Syntax
(law:hedgehog
    {path vector-list [number-hair [size]]} |
    {hair-law base-law start-x end-x
    {[number-hair] | [start-y end-y [number-hair]] |
    [start-y end-y start-z end-z [number-hair]]}})

Arg Types
path entity
vector-list law | (law ...)
number-hair integer
size real
hair-law law | string | gvector
base-law law | string | position
start-x real
end-x real
start-y real
end-y real
start-z real
end-z real

Returns
boolean

Description
The law:hedgehog extension defines vector fields that are attached to a curve. They are useful for defining orientation when sweeping along a non-planar path. There are two major ways to use this command. The determination as to which method is used is based on the first argument type.

If the first argument is an entity, as would be the case for a wire body or edge, then that argument is assumed to be the path and should be followed by a Scheme list of laws, vector-list Optionally, the number of hairs on the hedgehog and its size can be specified.

If the first argument is not an entity, then it is assumed to be a hair-law, which can be a law, string, or gvector. hair-law specifies the direction for the hair vectors. This is followed by base-law, which specifies what is to receive the vector field. Thereafter, this can be followed by 0 or up to 5 arguments. number-hair specifies the number of vectors to use. The start and end parameters limit the range for displaying the vector field.

; law:hedgehog
; The edge is not required, but is useful
; for visualization purposes. It is defined
; the same as base-law.
(define edge1
(edge:law "vec(cos(x),sin(x),x/10)" 0 50))
;; edge1
(define base-law
(law "vec(cos(x),sin(x),x/10)"))
;; base-law
(define vector-law (law "vec(cos(x),sin(x),0)"))
;; vector-law
(define hedgehog1 (law:hedgehog vector-law
base-law 0 50 200 ))
;; hedgehog1

; Another example.
; Clear out the result of the previous example
(part:clear)
;; #t
; The face is not required, but is useful
; for visualization purposes. It is defined
; the same as base-law.
(define face1
(face:law "vec(x,y,cos(x)*sin(y))" -5 5 -5 5))
;; face1
(define base-law1(law "vec(x,y,cos(x)*sin(y))"))
;; base-law1
(define dx (law:derivative base-law))
;; dx
(define dy(law:derivative base-law1 "y"))
;; dy
(define norm (law "cross(law1,law2)" dx dy))
;; norm
(define hedgehog2 (law:hedgehog norm
base-law -5 5 -5 5 20 ))
;; hedgehog2
; Another example.
; Clear out the previous example
(part:clear)
;; #t
(define base-law2 (law "vec(x,y,z)"))
;; base-law2
(define hair-law (law "norm(vec(x,y,z))"))
;; hair-law
(define hedgehog3 (law:hedgehog hair-law
base-law -10 10 -10 10 -10 10))
;; hedgehog3

[Top]


law:inverse

Action
Returns a law that is the inverse of the supplied law.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:inverse in-law)

Arg Types
in-law law

Returns
law

Description
The inverse of a given law is not supported for most laws. The only supported law having an inverse is something derived from the bend law.

Arguments
in-law specifies a law.
; law:inverse
; Create a cylinder
(define a-part (solid:cylinder (position -20 0 -2)
    (position 20 0 -2) 0.75))
;; a-part
(entity:bend a-part (position -8 0 -2)
    (gvector 0 0 1) (gvector 0 1 0) 4 90)
;; #[entity 2 1]
(define e-list (entity:edges a-part))
;; e-list
(define law1 (law "cur(EDGE1)"
    (list-ref e-list 0)))
;; law1
(define law2 (law:inverse law1))
;; law2

[Top]


law:line-line-intersect

Action
Returns TRUE if two lines intersect.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:line-line-interset point1 gvector1 point2 gvector2)

Arg Types
point1 position
gvector1 gvector
point2 position
gvector2 gvector

Returns
boolean

Description
Returns TRUE if the line given by point1 + t * gvector1 intersects the line point2 + s * gvector2. Also prints out the parameter values of the two nearest points.

Arguments
point1 specifies a position on the first line.
 
gvector1 specifies the direction of the first line.
 
point2 specifies a position on the second line.
 
gvector2 specifies the direction of the second line.
; law:line-line-intersect
; Create a cylinder
; intersect at (1 2 3)
(law:line-line-intersect (position 4 4 4)
    (gvector 3 2 1) (position 1 10 3)
    (gvector 0 -.3 0))
; Lines intersect at (1.000000 2.000000
;      3.000000)
; Param values are:
;      param0 at -1.000000
;      param1 at 26.666667
;; #t
; no intersection
(law:line-line-intersect (position 5 4 4)
    (gvector 3 2 1) (position 3 10 1)
    (gvector 0 -.3 0))
; Param values are:
;      param0 at -0.900000
;      param1 at 26.000000
;; #f

[Top]


law:linear

Action
Creates a linear law given {a,b,f(a),f(b)}.

Filename
scm/scmext/kern/law_scm.cpp

APIs
api_make_linear

Syntax
(law:linear a b f-a f-b)

Arg Types
a real
b real
f-a real
f-b real

Returns
boolean

Description
Produces a linear polynomial using the input boundary conditions.

Arguments
a and b specify the boundary values.
 
f-a and f-b specifies the desired output of the law at a and b.
; law:linear
; Create a law.
(define law1 (law:linear 0 1 2 3))
;; law1
(law:eval 0)
;; 0
(law:eval 1)
;; 1

[Top]


law:make-entity

Action
Creates a law entity data type composed of one law function.

Filename
scm/scmext/kern/law_scm.cpp

APIs
api_law_to_entity

Syntax
(law:make-entity {some-law-functions | type}
    [law-data]* [ao])

Arg Types
some-law-functions string
law-data law | real | position | par-pos | gvector | transform | edge | wire
type law | real | position | par-pos
ao acis-options

Returns
law

Description
This routine creates a law entity which can be saved and restored from a SAT file. The law does not have to be attached to model geometry.

; law:make-entity
; Create a law to use
(define law1 (law "vec(x^2,cos(x)+arctan(y))"))
;; law1
(define law-ent (law:make-entity law1))
;; law-ent

[Top]


law:make-rails

Action
Creates a rail law or a list of rail laws for use by sweeping.

Filename
scm/scmext/kern/law_scm.cpp

APIs
api_make_rails

Syntax
(law:make-rails path [twist [axis [faces
    [user-rails [version]]]]])

Arg Types
path edge | wire
twist law
axis law | (law ...)
faces face | (face ...)
user-rails law | (law ...)
version version_tag

Returns
law | (law ...)

Description
This produces a rail law or a list of rail laws that can be used by sweeping or law:hedgehog.

If the path is a single edge or a wire with a single underlying edge, then a single rail law is produced. Otherwise, the extension creates multiple rail laws, one for each underlying edge in the path.

The only required argument is the path. If no other arguments are supplied, then the following default rails are created:

Arguments
-If the path is planar, the rail law is the planar normal.
 
-If the path is a helix, the rail law points towards the axis.
 
-If all edges in the wire are planar, then an array of rail laws is created, whereby each law in the array corresponds to an edge in the wire. The rail laws correspond to the planar normal of edges.
 
-If the path is not one of the above cases, the rail uses minimum rotation.
 
Because the input arguments are chained together, "NULL" arguments (double quotation marks required) must be supplied for early elements in the argument list in order to change later arguments. If the input path is composed of multiple pieces, such as a wire with more than one underlying edge, then list arguments must supply the same number of elements as the number of path elements. They may pad their list with "NULL" arguments (double quotation marks required).
 
For example, assume that an input path has three underlying edges. Assume that a list of axis laws are to be supplied, but no twist law. The list of axis laws would have to contain three elements. The list of axis laws could contain "NULL", which would result in the default rail for those corresponding portions of the path. The example call might look like:
(law:make-rails my-path "NULL"
    (list "NULL" my-law "NULL"))
The twist argument works on the whole rail. After the other rail parameters have been input and calculated, the law provided by twist operates on the whole set of rails. This takes in an angle of twist per distance along the path. The twist argument can be "NULL".
 
The axis argument is used for path segments that have an implied center axis. An example of this might be a helix, an expanding helix, or the coil of a telephone handset cable. The axis argument is the derivative of the implied center axis, which tells the implied axis direction. When the axis is supplied, the created rails point towards it. The axis list can be padded with "NULL" for sections of the path that do not have an implied axis.
 
The face argument is used when a portion of the path segments borders a non-analytic face. The coedge of the wire provided as path must actually belong to the face entity supplied. The face must be non-analytic. The resulting rail is oriented to the face normal. The face list can be padded with "NULL" for sections of the path that do not have such a face.
 
The user-rails argument permits any default rail for a given section of the path to be overridden by the user-supplied law in the list. The user-rails list can be padded with "NULL" for sections of the path that are to use the default.
 
The version argument permits the user to specify a versiontag leaving the min_rotation_law as the rail.  This behavior is not recommended for performance and robustness.
; law:make-rails
; is:helix
(define path1 (wire-body:offset (wire-body
    (edge:linear (position 0 0 0) (position 0 0 20)))
    5 "x"))
;; path1
(define rail-1 (law:make-rails path1))
;; rail-1
; #[law
; "NORM(CROSS(DOMAIN(VEC(-(5*COS(X)),
; -(5*SIN(X)),1),0,20),VEC(0,0,1)))"]
; IF YOU WANT TO SEE THE RAILS, use law:hedgehog

[Top]


law:nderivative

Action
Computes the numerical derivative of a law function with respect to a given variable, for a specified number of times.

Filename
scm/scmext/kern/law_scm.cpp

APIs
api_ndifferentiate_law

Syntax
(law:nderivative law value [with-respect-to
    [number-of [type=0]]])

Arg Types
law law | string | real | position | par-pos | gvector
value (entity | (entity ...)) | real | position | gvector | par-pos
with-respect-to law
number-of integer
type integer

Returns
real

Description
The law:nderivative returns a specified type of derivative of the given law function.

Arguments
law specifies a law.
 
value specifies a value at which the derivative is evaluated.
 
with-respect-to is an optional argument specifying an identity law, such as x, y, z, or a#, etc. If with-respect-to is provided, then the derivative is performed with respect to this argument; else the derivative is assumed to be with respect to x or a1.
 
If number-of is specified as some integer, then the extension performs multiple derivatives. If number-of is not specified, it is assumed to be 1.
 
type defines the type of derivative. Zero is normal (default); 1 is from the left; and 2 is from the right.
; law:nderivative
; Define a law to use.
(define law1 (law "x^2"))
;; law1
; Find the numerical derivative at 3.
(law:nderivative law1 3 "x" 1)
;; 5.9999999999838
; Find the second numerical derivative at 3.
(law:nderivative law1 3 "x" 2)
;; 1.9999997294066
; To get exact results, take the exact derivative.
; Create the derivative of that law.
(define dlaw (law:derivative law1))
;; dlaw
; Evaluate the derivative.
(law:eval dlaw 3)
;; 6

; Example of left and right derivatives.
(law:nderivative "abs(x)" 0 "x" 1 1)
;; -1
(law:nderivative "abs(x)" 0 "x" 1 2)
;; 1
(law:nderivative "abs(x)" 0 "x" 1 0)
;; -1.52465930505774e-16
; In the case of non-differentiable functions,
; the normal option returns the average value.

[Top]


law:nintegrate

Action
Computes the numerical integral of the given law function over the specified range.

Filename
scm/scmext/kern/law_scm.cpp

APIs
api_integrate_law

Syntax
(law:nintegrate law low-lim up-lim [tol])

Arg Types
law law | string | real | position | par-pos | gvector
low-lim real
up-lim real
tol real

Returns
real

Description
The law:nintegrate Scheme extension computes a numerical integration on law.

Arguments
law can be a defined law, a law string, or a constant number.
 
low-lim and up-lim are two real values that specify the lower and upper limit for integration.
 
tol is an optional real value that specifies the tolerance for the integration calculation.
; law:nintegrate
; Define a law to integrate.
(define law1 (law "x + 1"))
;; law1
; Evaluate the law over the range 0 and 1.
(law:nintegrate law1 0 1)
;; 1.5

[Top]


law:nmax

Action
Computes where a law is the maximum over a given interval.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:nmax law low-lim up-lim)

Arg Types
law law | string | real | position | par-pos | gvector
low-lim real
up-lim real

Returns
real

Description
law:nmax
computes where a law is the maximum over a given interval.

Arguments
law can be a defined law, a law string, or a constant number.
 
low-lim and up-lim are two real values that specify the interval.
 
The example defines law1 to be the law that returns the curvature of testcur1 with its parameter range mapped to [0,1]. The "CurC" law returns the curvature of its curve. Because the radius of curvature is the reciprocal of the curvature, finding where law1 is maximum finds where the radius of curvature is minimum, or where the tightest turn in the curve is located.
; law:nmax
; Define a list of points for a spline edge
(define plist (list (position 0 0 0)
    (position 20 20 0) (position 40 0 0)
    (position 60 25 0) (position 40 50 0)
    (position 20 30 0) (position 0 50 0)))
;; plist
(define start (gvector 1 1 0))
;; start
(define end (gvector -1 1 0))
;; end
(define testcur1 (edge:spline plist start end))
;; testcur1
(define law1
    (law "map(Curc(edge1),edge1)" testcur1))
;; law1
(define maxpoint (law:nmax law1 0 1))
;; maxpoint
; All curves in Scheme are parameterized from 0 to 1.
(define point1 (dl-item:point
    (curve:eval-pos testcur1 maxpoint)))
;; point1
(dl-item:display point1)
;; ()
; OUTPUT Result

Figure. law:nmax - First Maximum Point on a Test Curve

[Top]


law:nmin

Action
Computes where a law is the minimum over a given interval.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:nmin law low-lim up-lim)

Arg Types
law law | string | real | position | par-pos | gvector
low-lim real
up-lim real

Returns
real

Description
law:nmin
computes where a law is the minimum over a given interval.

Arguments
law can be a defined law, a law string, or a constant number.
 
low-lim and up-lim are two real values that specify the interval.
; law:nmin
; Define a simple law to find minimum.
(law:nmin "x^2+x" -1 1)
;; -0.5

; Another Example.
; Create the points for a test curve.
(define plist (list (position 0 0 0)
    (position 20 20 20) (position -20 20 20)
    (position 0 0 0)))
;; plist
(define start (gvector 1 1 1))
;; start
(define end (gvector 1 1 1))
;; end
(define testcur (edge:spline plist start end))
;; testcur
; Create a curve law.
(define curlaw
    (law "map(term(cur(edge1),1),edge1)"
    testcur))
;; curlaw
; Find its minimum.
(define min (law:nmin curlaw 0 1))
;; min
; Plot and mark that point.
(define minpoint (dl-item:point
    (curve:eval-pos testcur min)))
;; minpoint
(dl-item:display minpoint)
;; ()
; OUTPUT Result

Figure. law:nmin - Minimum Point on a Test Curve

[Top]


law:nroot

Action
Computes all of the roots of a law function over a given interval.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:nroot law low-lim up-lim)

Arg Types
law law | string | real | position | par-pos | gvector
low-lim real
up-lim real

Returns
(real | (real ...))

Description
Returns a list of numbers that represent the roots of the law over a given range.

Arguments
law can be a defined law, a law string, or a constant number.
 
low-lim and up-lim are two real values that specify the interval.
; law:nroot
; Find the roots of a sine wave.
(law:nroot "sin(x)" 0 10)
;; (0 3.14159265358979 6.2831853071295
    9.42477796085266)

[Top]


law:nsolve

Action
Computes all the locations where two laws are equal to one another over a given interval.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:nsolve law1 law2 low-lim up-lim)

Arg Types
law1 law | string | real | position | par-pos | gvector
law2 law | string | real | position | par-pos | gvector
low-lim real
up-lim real

Returns
(real | (real ...))

Description
This returns a list of real values representing where two laws are equal over a given range.

Arguments
law1 can be a defined law, a law string, or a constant number.
 
law2 can be a defined law, a law string, or a constant number.
 
low-lim and up-lim are two real values that specify the interval.
; law:nsolve
; Define two laws and find where equal on interval.
(law:nsolve "x" "x^3" -2 2)
;; (-1.0 0 1.0)

[Top]


law:quintic

Action
Creates a quintic law given {a,b,f(a),f(b),f(a),f(b) f(a) f(b)}.

Filename
scm/scmext/kern/law_scm.cpp

APIs
api_make_quintic

Syntax
(law:quintic a b f-a f-b df-a df-b ddf-a ddf-b)

Arg Types
a real
b real
f-a real
f-b real
df-a real
df-b real
ddf-a real
ddf-b real

Returns
boolean

Description
Produces a quintic polynomial with given boundary conditions for it, its first derivative, and its second derivative.

Arguments
a and b specify the boundary values.
 
f-a and f-b are the desired output of the law at a and b.
 
df-a and df-b are the desired output of the first derivative at a and b.
 
ddf-a and ddf-b are the desired output of the second derivative at a and b.
; law:quintic
; Create a law.
(define law1 (law:quintic 0 1 2 3 4 5 6 7))
;; law1
(law:eval law1 0)
;; 2
(law:eval law1 1)
;; 3
(define dlaw (law:derivative law1))
;; dlaw
(define ddlaw (law:derivative dlaw))
;; ddlaw
(law:eval dlaw 0)
;; 3.99999999999998
(law:eval dlaw 1)
;; 5.00000000000003
(law:eval ddlaw 0)
;; 6
(law:eval ddlaw 1)
;; 7

[Top]


law:reset-deriv

Action
Sets the derivative of ith driving variable.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:reset-deriv a-law i)

Arg Types
a-law law | string | real | position | par-pos | gvector
i integer

Returns
unspecified
Arguments
a-law can be a defined law, a law string, or a constant number.
 
i specifies the order of derivative.
; law:reset-deriv
; Create a law
(define a-law (law "x^2+3"))
;; a-law
; Create a deriv-law
(define deriv-law (law "2*x"))
;; deriv-law
; Set the derivative
(law:set-deriv a-law 0 deriv-law)
;; #t
; Reset the derivative
(law:reset-deriv a-law 0)
;; #t

[Top]


law:set-deriv

Action
Manually sets the derivative of ith driving variable.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:set-deriv a-law i deriv-law)

Arg Types
a-law law | string | real | position | par-pos | gvector
i integer
deriv-law law | string | real | position | par-pos | gvector

Returns
unspecified
Arguments
a-law can be a defined law, a law string, or a constant number.
 
i specifies the order of derivative.
 
deriv-law specifies the closed form derivative of law:set-deriv.
; law:set-deriv
; Create a law
(define a-law (law "x^2+3"))
;; a-law
; Create a deriv-law
(define deriv-law (law "2*x"))
;; deriv-law
; Set the derivative
(law:set-deriv a-law 0 deriv-law)
;; #t

[Top]


law:simplify

Action
Creates a law which is the algebraic simplification of the given law.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:simplify law)

Arg Types
law law | string | real | position | par-pos | gvector

Returns
law

Description
The simplifier should always produce a law that is algebraically equivalent to the given law, but it may fail to simplify the law completely. Its original intent was to remove 0s and 1s from derivatives.

Arguments
law can be a defined law, a law string, or a constant number.
; law:simplify
; Create a new law.
(define law1 (law "x^2/x-3*x"))
;; law1
; Simplify the given law.
(define simplaw2 (law:simplify law1))
;; simplaw2
; Simplify the given law.
(define simplaw (law:simplify "x^2/x-3*x"))
;; simplaw

[Top]


law:start

Action
Finds the start of the domain of a law.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law:start in-law [term])

Arg Types
in-law law
term integer

Returns
boolean

Description
Returns the start of the domain of a law.

Arguments
law specifies a law.
 
The optional term argument could be used to localize which term in the law is used.
; law:start
; Define a profile to sweep for interesting shape
(define profile1 (wire-body:points
    (list (position 5 0 0)
    (position 10 0 0)
    (position 10 5 0)
    (position 5 5 0)
    (position 5 0 0))))
;; profile1
(define path1(edge:helix
    (position 0 0 0)
    (position 0 40 0)
    (gvector 1 0 0) 10 20 #t))
;; path1
(define helix1(sweep:law profile1 path1))
;; helix1
(define edge-list(entity:edges helix1))
;; edge-list
(define law1
    (law "cur(EDGE1)"
    (list-ref edge-list 3)))
;; law1
(law:start law1)
;; 0
(law:end law1)
;; 12.5663706143592
(define law2 (law "cur(EDGE1)"
    (list-ref edge-list 4)))
;; law2
(law:start law2)
;; 0
(law:end law2)
;; 5

[Top]


law?

Action
Determines whether or not a Scheme object is of the law Scheme data type.

Filename
scm/scmext/kern/law_scm.cpp

APIs
None

Syntax
(law? object)

Arg Types
object scheme-object

Returns
boolean

Description
This extension returns a #t if the given object is a law Scheme data type. Otherwise, it returns a #f.

Arguments
object specifies a scheme-object that has to be queried for a law.
; law?
; Create a new law.
(define law1 (law "x+x^2-cos(x)"))
;; law1
; Test to see if item is a law Scheme data type.
(law? law1)
;; #t
; Evaluate the given law at 1.5 radians
(define answer (law:eval law1 1.5))
;; answer
; Test to see if item is a law Scheme data type.
(law? answer)
;; #t
; This is true, because real numbers can be laws.

[Top]


loop:find

Action
Gets loops shared by two entities.

Filename
scm/scmext/kern/loop_scm.cpp

APIs
None

Syntax
(loop:find entity1 entity2)

Arg Types
entity1 entity
entity2 entity

Returns
loop

Description
This extension returns #f if no loop is found that is shared by both entities.

Arguments
entity1 specifies the first entity.
 
entity2 specifies the second entity.
; loop:find
; Create a solid block.
(define block1 (solid:block (position 20 30 0)
    (position 0 0 40)))
;; block1
; Create a solid cylinder.
(define cyl1 (solid:cylinder (position 0 0 0)
    (position -20 -20 -20) 15 3 (position -5 -5 0)))
;; cyl1
; Determine if any loops are shared.
(loop:find block1 cyl1)
;; #f
; Create an edge list.
(define list1 (entity:edges block1))
;; list1
(define one-edge (car list1))
;; one-edge
(define two-edge (car (cdr list1)))
;; two-edge
; Determine if any loops are shared.
(loop:find one-edge two-edge)
;; #[entity 16 1]

[Top]


loop:type

Action
Returns the type of given loop.

Filename
scm/scmext/kern/loop_scm.cpp

APIs
None

Syntax
(loop:type loop)

Arg Types
loop entity

Returns
string

Description
This returns a string specifying the type of loop. This includes "Periphery loop", "Hole", "Separation loop", "Separation loop (U)", "Separation loop (V)", "Separation loop (UV)", and "Unknown type of loop".

Arguments
loop is an entity representing a loop.
; loop:type
; Create a model with loops
(define profile1 (edge:linear
    (position 5 0 0) (position 10 0 0)))
;; profile1
(is:helix profile1)
;; #f
(define path1(edge:helix
    (position 0 0 0)
    (position 0 40 0)
    (gvector 1 0 0) 10 20 #t))
;; path1
(define helix1(sweep:law profile1 path1))
;; helix1
(define loop-list (entity:loops helix1))
;; loop-list
(loop:type (list-ref loop-list 0))
;; "Periphery loop"

[Top]


loop?

Action
Determines if a Scheme object is a loop.

Filename
scm/scmext/kern/ent_scm.cpp

APIs
None

Syntax
(loop? object)

Arg Types
object scheme-object

Returns
boolean

Description
This extension returns #t if the object is a loop; otherwise, it returns #f.

Arguments
object specifies the scheme-object that has to be queried for a loop.
; loop?
; Create a solid cylinder.
(define cyl1 (solid:cylinder (position 0 0 0)
    (position 8 8 8) 32))
;; cyl1
; Find the loops of the cylinder.
(define loops1 (entity:loops cyl1))
;; loops1
; Determine if the cylinders loop is
; actually a loop.
(loop? (car (cdr loops1)))
;; #t
(loop? cyl1)
;; #f

[Top]


lump?

Action
Determines if a Scheme object is a lump.

Filename
scm/scmext/kern/ent_scm.cpp

APIs
None

Syntax
(lump? object)

Arg Types
object scheme-object

Returns
boolean

Description
This extension returns #t if the object is a lump; otherwise it returns #f.

Arguments
object specifies the scheme-object that has to be queried for a lump.
; lump?
; Create a solid cylinder.
(define cyl1 (solid:cylinder (position 0 0 0)
    (position 8 8 8) 32))
;; cyl1
; Find the lumps of the cylinder.
(define limps1 (entity:lumps cyl1))
;; limps1
; Determine if the cylinders lump is
; actually a lump.
(lump? (car limps1))
;; #t
(lump? cyl1)
;; #f

[Top]


minimize-options:set

Action
Sets the options of a scheme minimize_options object.

Filename
scm/scmext/kern/pageopts_scm.cxx

APIs
None

Syntax
(minimize-options:set [minimize_options] ["option_name" option] ["option_name" option] ... )

Arg Types
minimize_options minimize_options object
option_name string
option 0 or 1

Returns
scheme minimize_options object

Description
This command generates a scheme minimize_options object that can be used to control the behavior of individual minimization commands. The options are specified as pairs of option names and associated values. Options not defined explicitly are set to zero.

If the first argument is an existing minimize_options object, then the option values are initialized to the values of that object, and then individual option settings are processed. If no arguments are specified, a minimize_options object with all options set to zero is returned.

The default behavior of the minimization commands may be set using the (minimize:set-defaults) command.

Arguments
minimize_options specifies the scheme minimize_options object.

option_name specifies either "geometry_action" or "approx_action".

option specifies a valid value of either 0 or 1.
; create a minimize_options object to page the geometry to a file
; and delete the approximations
(define mo (minimize-options:set 'geometry_action 1 'approx_action 1))
;; mo

[Top]


minimize:box

Action
Frees memory by minimizing geometry outside of the specified box.

Filename
scm/scmext/kern/page_scm.cpp

APIs
api_pm_part_entities
api_wcs_get_active
api_get_entity_box
api_get_faces
api_get_edges
api_minimize_entities

Syntax
(minimize:box pos1 pos2 [wcs] [entity_list] [minimize_options] [acis_options])

Arg Types
pos1 position
pos2 position
wcs wcs
entity_list entity | (entity ...)
minimize_options minimize_options
acis_options acis_options

Returns
boolean , #t if minimize operation is successful, otherwise #f

Description
This operation minimizes the memory usage of the specified geometric entities that lie outside of the minimization box. This box is defined by the two corners, pos1 and pos2, in relation to the coordinate system specified using wcs. If the wcs argument is omitted, the corners will be taken relative to model space or the active work coordinate system.

The entities to consider for minimization are specified by the optional entity_list argument. If this list is omitted, all entities of the active part are considered.

The minimize_options argument controls the types of action taken by the minimization mechanism. If the minimize_options object is omitted, the global settings are used.

For the minimization operation to be successful, the paging system must first be initialized with the page:init command.

Arguments
pos1 specifies the position of the low corner of the minimization box.
 
pos2 specifies the position of the high corner of the minimization box.
 
wcs specifies the work coordinate system of the minimization box.
 
entity_list specifies the list of entities to be considered for minimization.
 
minimize_options is a Scheme minimize_options object.

          acis_options is used to set options related to journaling and versioning.

Example

minimize:box
(part:clear)
;; #t
; Initialize the paging system
(page:init)
;; #t
; Create two bezier curves
(define c1 (edge:bezier-ndeg (list (position 0 0 0) (position 0 1 0) (position 0 1 1) (position 1 1 1))))
;; c1
(define c2 (edge:bezier-ndeg (list (position 2 2 2) (position 2 3 2) (position 2 3 3) (position 3 3 3))))
;; c2
; Set up minimize-options object to page geometry and delete approximations
(define mo (minimize-options:set 'geometry_action 1 'approx_action 1))
;; mo
; Display paging statistics before performing minimize operation
(page:stats)
;; (("page-bytes" . 0) ("page-count" . 0) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 0) ("smallest-entry" . 0) ("page-file" . "acis.swp")
;; ("file-size" . 0) ("state" . 1))
; Minimize everything outside of a box which contains c1
(minimize:box (position 0 0 0) (position 1 1 1) mo)
;; #t
; Display paging statistics after performing minimize operation
(page:stats)
;; (("page-bytes" . 512) ("page-count" . 1) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 527) ("state" . 1))

 

[Top]


minimize:entities

Action
Frees memory by minimizing the specified geometric entities.

Filename
scm/scmext/kern/page_scm.cpp

APIs
api_minimize_entities

Syntax
(minimize:entities entity_list [minimize_options] [acis_options])

Arg Types
entity_list entity | (entity ...)
minimize_options minimize_options
acis_options acis_options

Returns
boolean , #t if minimize operation is successful, otherwise #f

Description
This operation minimizes the memory usage of the specified geometric entities. The (minimize:entities) command is the scheme interface for api_minimize_entities.
The minimize_options argument controls the types of action taken by the minimization mechanism. If the minimize_options object is omitted, the global settings are used.
For the minimization operation to be successful, the paging system must first be initialized with the (page:init) command.

Arguments
entity_list specifies the list of entities to minimize.
 
minimize_options is a Scheme minimize_options object.
 
acis_options is used to set options related to journaling and versioning.

Example

; minimize:entities
(part:clear)
;; #t
; Initialize the paging system
(page:init)
;; #t
; Create two bezier curves
(define c1 (edge:bezier-ndeg (list (position 0 0 0) (position 0 1 0) (position 0 1 1) (position 1 1 1))))
;; c1
(define c2 (edge:bezier-ndeg (list (position 2 2 2) (position 2 3 2) (position 2 3 3) (position 3 3 3))))
;; c2
; Set up minimize-options object to page geometry and delete approximations
(define mo (minimize-options:set 'geometry_action 1 'approx_action 1))
;; mo
; Display paging statistics before performing minimize operation
(page:stats)
;; (("page-bytes" . 0) ("page-count" . 0) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 0) ("smallest-entry" . 0) ("page-file" . "acis.swp")
;; ("file-size" . 0) ("state" . 1))
; Minimize all entities in the active part
(minimize:entities (part:entities) mo)
;; #t
; Display paging statistics after performing minimize operation
(page:stats)
;; (("page-bytes" . 512) ("page-count" . 1) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 527) ("state" . 1))

[Top]


minimize:inactive

Action
Frees memory by minimizing inactive parts.

Filename
scm/scmext/kern/page_scm.cpp

APIs
api_get_active_part
api_pm_part_entities
api_minimize_entities

Syntax
(minimize:inactive [minimize_options] [acis_options])

Arg Types
minimize_options minimize_options
acis_options acis_options

Returns
boolean , #t if minimize operation is successful, otherwise #f

Description
This operation uses the minimization mechanism to reduce the memory usage of geometric entities associated with inactive parts. The minimize_options argument controls the types of action taken by the minimization mechanism. If the minimize_options object is omitted, the global settings are used. For the minimization operation to be successful, the paging system must first be initialized with the page:init command.

Arguments
minimize_options is a Scheme minimize_options object.
 
acis_options is used to set options related to journaling and versioning.

Example

; minimize:inactive
(part:clear)
;; #t
; Initialize the paging system
(page:init)
;; #t
; Create first part
(define part1 (env:active-part))
; Create a bezier curve in part1
;; part1
(define c1 (edge:bezier-ndeg (list (position 0 0 0) (position 0 1 0) (position 0 1 1) (position 1 1 1))))
;; c1
; Create second part and make it active
(define part2 (part:new))
;; part2
(env:set-active-part part2)
;; ()
; Create a different bezier curve in part2
(define c2 (edge:bezier-ndeg (list (position 2 2 2) (position 2 3 2) (position 2 3 3) (position 3 3 3))))
;; c2
; Set up minimize-options object to page geometry to file and delete approximations
(define mo (minimize-options:set 'geometry_action 1 'approx_action 1))
;; mo
; Display paging statistics before performing minimize operation
(page:stats)
;; (("page-bytes" . 0) ("page-count" . 0) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 0) ("smallest-entry" . 0) ("page-file" . "acis.swp")
;; ("file-size" . 0) ("state" . 1))
; Minimize inactive part1
(minimize:inactive mo)
;; #t
; Display paging statistics after performing minimize operation
(page:stats)
;; (("page-bytes" . 512) ("page-count" . 1) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 527) ("state" . 1))

[Top]


minimize:least-used

Action
Frees memory by minimizing least-used geometric entities.

Filename
scm/scmext/kern/page_scm.cpp

APIs
api_pm_part_entities
api_minimize_entities

Syntax
(minimize:least-used threshold [mode] [minimize_options] [acis_options])

Arg Types
threshold integer
mode string
minimize_options minimize_options
acis_options acis_options

Returns
boolean, #t if minimize operation is successful, otherwise #f

Description
This operation uses the minimization mechanism to reduce the memory usage of geometric entities based on the time stamp of the top-level entities. In the "time" mode, entities that have not been accessed for a specified amount of time are minimized. All entities not accessed within the previous "threshold" number of seconds are minimized.

In the "memory" mode, the threshold value defines the target memory usage (in KB) of the current process. The time stamp determines the order in which the entities are minimized with the "oldest" entity minimized first. If the target memory use is reached, no additional entities are minimized. Setting the target memory use to zero minimizes the entire model.

The minimize_options argument controls the types of action taken by the minimization mechanism. If the minimize_options object is omitted, the global settings are used.
For the minimization operation to be successful, the paging system must first be initialized with the page:init command.

Arguments
threshold is a non-negative number.  
mode specifies "time" or "memory"; default is "time".
 
minimize_options is a Scheme minimize_options object.
 
acis_options is used to set options related to journaling and versioning.

Example

; minimize:least-used
(part:clear)
;; #t
; Initialize the paging system
(page:init)
;; #t
; Set up minimize-options object to page geometry and delete approximations
(define mo (minimize-options:set 'geometry_action 1 'approx_action 1))
;; mo
; Create three bezier curves with 10 second gap after first
(define c1 (edge:bezier-ndeg (list (position 0 0 0) (position 0 1 0) (position 0 1 1) (position 1 1 1))))
;; c1
(system:sleep 10000)
;; 10000
(define c2 (edge:bezier-ndeg (list (position 2 2 2) (position 2 3 2) (position 2 3 3) (position 3 3 3))))
;; c2
(define c3 (edge:bezier-ndeg (list (position 1 1 1) (position 1 2 1) (position 1 2 2) (position 2 2 2))))
;; c3
; Immediately minimize everything that hasn't been accessed in 8 seconds
(minimize:least-used 8 mo)
;; #t
; Display paging statistics after performing minimize operation
(page:stats)
;; (("page-bytes" . 512) ("page-count" . 1) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 527) ("state" . 1))
; Minimize everything
(minimize:least-used 0 'memory mo)
;; #t
(page:stats)
;; (("page-bytes" . 1536) ("page-count" . 3) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 1551) ("state" . 1))

[Top]


minimize:set-defaults

Action
Sets the default behavior of the minimization commands.

Filename
scm/scmext/kern/page_scm.cpp

APIs
api_set_default_minimize_options

Syntax
(minimize:set-defaults [minimize_options] ["option_name" option] ["option_name" option] ... )

Arg Types
minimize_options minimize_options
option_name "geometry_action" or "approx_action"
option 0 or 1

Returns
boolean, #t if minimize operation is successful, otherwise #f

Description
This command is provided to set the default behavior of the minimization commands. These include (minimize:entities), (minimize:box), (minimize:inactive) and (minimize:least-used). Individual options must be specified as a pair, a string identifying the name of the option and the associated option value. An option which is not defined explicitly is set to the default value zero.
If a minimize_options object is provided as the first argument, the default settings are initialized to the values of that object, and then individually listed options are set. If no arguments are provided, the default minimization system options are all set to zero.
It is possible to override the specified default behavior on a case-by-case basis by passing a minimize_options object into a scheme minimize command.

Arguments
minimize_options is a Scheme minimize_options object.
 
option_name specifies either "geometry_action" or "approx_action".
 
option specifies the value 0 or 1.
 

Example

; minimize:set-defaults
(part:load "test.sat")
;; (#[entity 1 1])
; set the minimization default options individually
(minimize:set-defaults "geometry_action" 1 "approx_action" 1)
;; #t
; minimize entities based on default option settings
(minimize:entities (part:entities))
;; #t
; define a minimize_options object
(define mo (minimize-options:set "geometry_action" 1))
;; mo
; set the default options using the minimize_options object
(minimize:set-defaults mo "approx_action" 1)
;; #t
; set all the defaults to zero
(minimize:set-defaults)
;; #t
; minimize entities using the minimize_options object
(minimize:entities (part:entities) mo)
#t

[Top]


minimize:strategy

Action
Set up or remove minimization strategies.

Filename
scm/scmext/kern/page_scm.cpp

APIs
None

Syntax
(minimize:strategy type [val] [minimize_options] [acis_options])

Arg Types
type string
val integer
minimize_options minimize_options
acis_options acis_options

Returns
boolean, #t if strategy setup is successful, otherwise #f

Description
The minimize:strategy command automates the minimization process. The memory footprint of geometric entities is automatically minimized in response to certain events triggered by the part manager. The way in which the memory minimzation occurs is controlled by the specified strategies.

Currently, three strategies may be defined: "inactive", "time" and "memory". The "val" parameter has an impact only for the "time" and "memory" strategies and has a default value of zero. The optional "minimize_options" and "acis_options" arguments are stored specific to each strategy and used whenever that strategy is invoked in response to a part manager event.

The "inactive" strategy causes geometric entities associated with inactive parts to be minimized when the part manager triggers an "activate part" event. The way the entities are minimized is identical to the action caused by issuing the (minimize:inactive) command.

The "time" strategy is triggered whenever the part manager causes a "change part" or "create part" event. In response, all geometric entities that have not been accessed in the time period specified by "val" (in seconds) will be minimized. This action is equivalent to the effect of the (minimize:least-used 'time) command.

The "memory" strategy causes the least-used geometric entities to be minimized until the memory use is reduced to the amount specifed by the "val" argument. This action is identical to the effect of issuing the (minimize:least-used 'mem) command. This strategy is also triggered by a "change part" or "create part" event.

Each time a (minimize:strategy) command is issued, the specified strategy is immediately carried out without waiting for an event from the part manager. Multiple strategies may be defined simultaneously. The part callback mechanism calls each strategy in the sequence they were defined. All strategies remain in effect until the (minimize:strategy 'none) command is issued, at which point all existing strategies are permanently deleted.
The paging system must be initialized with the (page:init) command before any minimization strategies may be defined. All minimization strategies are lost when the paging system is terminated.

Arguments
type specifies the strategy type.
 
val specifies a value for the strategy type.
 
minimize_options a Scheme minimize_options object.
 
acis_options is used to set options related to journaling and versioning.

Example

; minimize:strategy
(part:clear)
;; #t
; Initialize the paging system
(page:init)
;; #t
; Set up minimize-options object to page geometry and delete approximations
(define mo (minimize-options:set 'geometry_action 1 'approx_action 1))
;; mo
; Set up a strategy that minimizes inactive parts
(minimize:strategy 'inactive mo)
;; #t
; Create first curve in first part
(define part1 (env:active-part))
;; part1
(define c1 (edge:bezier-ndeg (list (position 0 0 0) (position 0 1 0) (position 0 1 1) (position 1 1 1)))) ;; c1
; Show initial paging statistics
(page:stats)
;; (("page-bytes" . 0) ("page-count" . 0) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 0) ("smallest-entry" . 0) ("page-file" . "acis.swp")
;; ("file-size" . 0) ("state" . 1))
; Swtich to a new part -> first curve paged to file
(define part2 (part:new))
;; part2
(env:set-active-part part2)
;; ()
(page:stats)
;; (("page-bytes" . 512) ("page-count" . 1) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 527) ("state" . 1))
; Add strategy to minimize parts not accessed for 10 seconds
(minimize:strategy 'time 10 mo)
;; #t
; Create second curve in second part -> no additional paging
(define c2 (edge:bezier-ndeg (list (position 2 2 2) (position 2 3 2) (position 2 3 3) (position 3 3 3))))
;; c2
(page:stats)
;; (("page-bytes" . 512) ("page-count" . 1) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 527) ("state" . 1))
; Wait for 11 seconds
(system:sleep 11000)
;; 11000
; Create third curve -> second curve is paged to file due to second strategy
(define c3 (edge:bezier-ndeg (list (position 1 1 1) (position 1 2 1) (position 1 2 2) (position 2 2 2))))
(page:stats)
;; (("page-bytes" . 1024) ("page-count" . 2) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 1039) ("state" . 1))
; Reactivate the first part -> third curve is paged to file due to first strategy
(env:set-active-part part1)
;; ()
(page:stats)
;; (("page-bytes" . 1536) ("page-count" . 3) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 1551) ("state" . 1))
; Remove the minimization strategies
(minimize:strategy 'none)
;; #t

 

[Top]


mixed-body?

Action
Determines if a Scheme object is a mixed body.

Filename
scm/scmext/kern/ent_scm.cpp

APIs
None

Syntax
(mixed-body? object)

Arg Types
object scheme-object

Returns
boolean

Description
A body is considered to be mixed if it has at least one face and at least one LUMP with a SHELL, and at least one WIRE and one FACE are attached to that SHELL, but no WIREs are attached to the BODY directly.

Arguments
object specifies the scheme-object that has to be queried for a mixed body.
; mixed-body?
; Create a solid block.
(define block1
    (solid:block (position -20 -20 -20)
    (position 20 20 20)))
;; block1
; Determine if the block is a mixed body.
(mixed-body? block1)
;; #f
; Create a wire body.
(define wirebody1
    (wire-body:points (list (position 20 0 0)
    (position 50 0 0))))
;; wirebody1
; Determine if the wire body is a mixed body.
(mixed-body? wirebody1)
;; #f
; Unite the entities.
(define mixed
    (bool:nonreg-unite block1 wirebody1))
;; mixed
; Determine if the resulting body is a mixed body.
(mixed-body? mixed)
;; #t

[Top]


monitor:file

Action
Opens or closes a monitor file, which records the text in the I/O window.

Filename
scm/scmext/kern/dbg_scm.cpp

APIs
None

Syntax
(monitor:file filename)

Arg Types
filename string | boolean

Returns
string | boolean

Description
The monitor file records all text going to the Scheme I/O window in a file.

Arguments
If filename is a string, a file of that name is opened and recording of the output begins. If filename is #f, the file is closed.
; monitor:file
; Open a monitor file
(monitor:file "record1")
;; record1

[Top]


option:get

Action
Gets the value of an option.

Filename
scm/scmext/kern/opt_scm.cpp

APIs
None

Syntax
(option:get option-string)

Arg Types
option-string string

Returns
integer | real | boolean | position | string

Description
The command option:list displays the available options.

Arguments
The argument option-string is generally a quoted text. When entering an option, the text can be abbreviated to the portion preceding the pound (#) sign. For example, brief_s#urface_debug can be abbreviated as brief_s.
; option:get
; List the options available.
(option:list)
;; (("abl_c#aps" . #t)
;; ("abl_off_x#curves" . #f)
;; ("abl_rem#ote_ints" . #f)
;; ("abl_require_on#_support" . #t)
;; ("abort_on_illegal_surface" . #t)
;; ("adaptive#_grid" . #f)
;; ("adaptive_t#riangles" . #f)
;; ("add_bl_atts" . #f)
;; ("addr#ess_debug" . #t)
;; ("align_corners" . #t)
;; ("align_first_wire" . #f)
;; ("all_free_edges" . #f)
;; ("angular_control" . #t)
;; ("anno#tations" . #f)
;; ("api_checking" . #t)
;; ("approx#_eval" . #t)
;; ("approx-vbl_off#set" . #t)
;; ("auto_disp#lay" . #t)
;; ("backup_boxes" . #t)
;; ("bb_immediate_close" . #f)
;; ("bend_debug_file" . )
;; ("bend_self_int" . #f)
;; ("bhl_smooth_edges" . #t)
;; ("bhl_smooth_surfaces" . #t)
;; ("bhl-use_ds_patch" . #f)
;; ("bhl-use_iso_approx" . #f)
;; ("bhl-use_iso_patch" . #f)
;; ("binary_format" . #f)
; .
; .
; .
; Get the value of an option.
(option:get "addr")
;; #t

[Top]


option:list

Action
Gets a list of available options and their associated values.

Filename
scm/scmext/kern/opt_scm.cpp

APIs
None

Syntax
(option:list)

Arg Types
None

Returns
((string . integer | real | boolean | position | string) ...)

Description
The extension returns a list of pairs of option names and values. The list displayed is bound by the variable print-length. It may be insufficient to display the whole list. If the whole list is not printed, try increasing the print length to 200 using the following:

(fluid-let ((print-length 200))
             (print (option:list)))
; option:list
; Get a list of some of the options and their values.
; If not all of the options are displayed using
; the list command try the following command
; which increases the print-length
; (fluid-let ((print-length 200))
;   (print (option:list)))
(option:list)
;; (("abl_c#aps" . #t)
;; ("abl_off_x#curves" . #f)
;; ("abl_rem#ote_ints" . #f)
;; ("abl_require_on#_support" . #t)
;; ("abort_on_illegal_surface" . #t)
;; ("adaptive#_grid" . #f)
;; ("adaptive_t#riangles" . #f)
;; ("add_bl_atts" . #f)
;; ("addr#ess_debug" . #t)
;; ("align_corners" . #t)
;; ("align_first_wire" . #f)
;; ("all_free_edges" . #f)
;; ("angular_control" . #t)
;; ("anno#tations" . #f)
;; ("api_checking" . #t)
;; ("approx#_eval" . #t)
;; ("approx-vbl_off#set" . #t)
;; ("auto_disp#lay" . #t)
;; ("backup_boxes" . #t)
;; ("bb_immediate_close" . #f)
;; ("bend_debug_file" . "")
;; ("bend_self_int" . #f)
;; ("bhl_smooth_edges" . #t)
;; ("bhl_smooth_surfaces" . #t)
;; ("bhl-use_ds_patch" . #f)
;; ("bhl-use_iso_approx" . #f)
;; ("bhl-use_iso_patch" . #f)
;; ("binary_format" . #f)
; .
; .
; .

[Top]


option:reset

Action
Sets the list of available options to their initial values.

Filename
scm/scmext/kern/opt_scm.cpp

APIs
None

Syntax
(option:reset)

Arg Types
None

Returns
boolean

Description
The default values for the options are presented in the option templates.

; option:reset
; List the options available.
(option:list)
;; ;; (("abl_c#aps" . #t)
;; ("abl_off_x#curves" . #f)
;; ("abl_rem#ote_ints" . #f)
;; ("abl_require_on#_support" . #t)
;; ("abort_on_illegal_surface" . #t)
;; ("adaptive#_grid" . #f)
;; ("adaptive_t#riangles" . #f)
;; ("add_bl_atts" . #f)
;; ("addr#ess_debug" . #t)
;; ("align_corners" . #t)
;; ("align_first_wire" . #f)
;; ("all_free_edges" . #f)
;; ("angular_control" . #t)
;; ("anno#tations" . #f)
;; ("api_checking" . #t)
;; ("approx#_eval" . #t)
;; ("approx-vbl_off#set" . #t)
;; ("auto_disp#lay" . #t)
;; ("backup_boxes" . #t)
;; ("bb_immediate_close" . #f)
;; ("bend_debug_file" . "")
;; ("bend_self_int" . #f)
;; ("bhl_smooth_edges" . #t)
;; ("bhl_smooth_surfaces" . #t)
;; ("bhl-use_ds_patch" . #f)
;; ("bhl-use_iso_approx" . #f)
;; ("bhl-use_iso_patch" . #f)
;; ("binary_format" . #f)
;; ("bl_ana#lytic_spine" . #t)
; .
; .
; .
; Set the value of an option.
(option:set "sphere_silhouettes" "on")
;; #t
; Reset the option to its previous value.
(option:reset)
;; #t

[Top]


option:set

Action
Sets the value of an option.

Filename
scm/scmext/kern/opt_scm.cpp

APIs
None

Syntax
(option:set option-string value)

Arg Types
option-string string
value real | integer | boolean | position | string

Returns
real | integer | boolean | position | string

Description
The return value is the previous option value. If option-string is not a valid option, an error message returns.

Refer to the option reference sections for information on each specific options. Availability of the options is based on the products that have been included in your executable.

Arguments
The argument option-string specifies the type of option to set.
 
value specifies the search value or attribute (boolean, integer, real, string, position) associated with the option-string.
; option:set
; List the options available.
(option:list)
;; ;; (("abl_c#aps" . #t)
;; ("abl_off_x#curves" . #f)
;; ("abl_rem#ote_ints" . #f)
;; ("abl_require_on#_support" . #t)
;; ("abort_on_illegal_surface" . #t)
;; ("adaptive#_grid" . #f)
;; ("adaptive_t#riangles" . #f)
;; ("add_bl_atts" . #f)
;; ("addr#ess_debug" . #t)
;; ("align_corners" . #t)
;; ("align_first_wire" . #f)
;; ("all_free_edges" . #f)
;; ("angular_control" . #t)
;; ("anno#tations" . #f)
;; ("api_checking" . #t)
;; ("approx#_eval" . #t)
;; ("approx-vbl_off#set" . #t)
;; ("auto_disp#lay" . #t)
;; ("avoid_box_backups" . #f)
;; ("backup_boxes" . #t)
;; ("bb_immediate_close" . #f)
;; ("bend_debug_file" . "")
;; ("bend_self_int" . #f)
;; ("bhl_smooth_edges" . #t)
;; ("bhl_smooth_surfaces" . #t)
;; ("bhl-use_ds_patch" . #f)
;; ("bhl-use_iso_approx" . #f)
;; ("bhl-use_iso_patch" . #f)
;; ("bin#ary_format" . #f)
;; ("bl_ana#lytic_spine" . #t)
; .
; .
; .
; Set the value of an option.
(option:set "sphere_silhouettes" "on")
;; #t

[Top]


page:init

Action
Initializes the paging system.

Filename
scm/scmext/kern/page_scm.cppp

APIs
None

Syntax
(page:init [file_name]) [run_mode])

Arg Types
file_name string
run_mode string

Returns
Boolean #t if initialization is successful, otherwise #f

Description
The paging system must be initialized before any geometric entities can be paged to disk.

The page:init command may be used to change the run_mode at any time. However, attempting to reinitialize the name of the page file results in an error. For terminate the paging system before attempting to change the page file path and name, use page:term command.

Use page:init to reactivate the paging system after it has been suspended.

Arguments
file_name specifies the name of the page file.
 
run_mode specifies the mode for the page system. The run_mode determines the action the paging system takes when mode is delete which means the page file is deleted when it becomes empty. Setting run_mode to keep retains the empty page file and its record structure.

Example

; page:init
(part:clear)
;; #t
; Create two bezier curves
(define c1 (edge:bezier-ndeg (list (position 0 0 0) (position 0 1 0) (position 0 1 1) (position 1 1 1))))
;; c1
(define c2 (edge:bezier-ndeg (list (position 2 2 2) (position 2 3 2) (position 2 3 3) (position 3 3 3))))
;; c2
; Initialize the paging system
(page:init)
;; #t
; Set up minimize_options object to page geometry to file and delete the
; approximations
(define mo (minimize-options:set 'geometry_action 1 'approx_action 1))
;; mo
; Minimize all entities in the active part
(minimize:entities (part:entities) mo)
;; #t
; Display paging statistics after performing the minimize operation
(page:stats)
;; (("page-bytes" . 512) ("page-count" . 1) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 527) ("state" . 1))

[Top]


page:stats

Action
Displays the paging system. statistics.

Filename
kern/kern_scm/page_scm.cpp

APIs
None

Syntax
(page:stats)

Arg Types
None

Returns
List of pairs (( str1 . int1) (str2 . int2) ... ) where str1, str2, ... are strings and int1, int2, ... are associated strings or integer values.

Description
Displays the total number and size of items paged and umpaged, details of the page file and the paging system state. The "page-bytes" and "page-count" values track items as they are written to the page file. Note that subsequent pages of the same (unmodified) geometric entities simply involve deletion of the object from memory without rewriting the information to the file and thus are not reflected in these statistics.

The "unpage-bytes" and "unpage-count" values relate to the process of restoring geometric information from the page file to memory. The statistics are updated each time the geometric information must be retrieved, so these statistics can reflect multiple access to the same entities.

The "trash-bytes" and "trash-count" values track items as they are permanently removed from the page file. When geometric entities which have been paged are deleted in the model, all the associated page data is removed from the file, and the corresponding statistics are updated.
The "biggest-entry" and "smallest-entry" values list the sizes of the biggest and smallest chunks of data stored in the page file. The "file-size" quantity refers to the size of the page file.

The paging system state is the last item displayed. If the paging system is initialized with the (page:init) command, the state changes from "uninitialized" to "active". The (page:term) command causes the state to change to "suspended" or "uninitialized" depending on whether or not the page file is still needed for unpaging.

Example

; page:stats
(part:clear)
;; #t
; Initialize the paging system
(page:init)
;; #t
; Create two bezier curves
(define c1 (edge:bezier-ndeg (list (position 0 0 0) (position 0 1 0) (position 0 1 1) (position 1 1 1))))
;; c1
(define c2 (edge:bezier-ndeg (list (position 2 2 2) (position 2 3 2) (position 2 3 3) (position 3 3 3))))
;; c2
; Set up minimize-options object to page geometry and delete approximations
(define mo (minimize-options:set 'geometry_action 1 'approx_action 1))
;; mo
; Display paging statistics before performing minimize operation
(page:stats)
;; (("page-bytes" . 0) ("page-count" . 0) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 0) ("smallest-entry" . 0) ("page-file" . "acis.swp")
;; ("file-size" . 0) ("state" . 1))
; Minimize everything outside of a box which contains c1
(minimize:box (position 0 0 0) (position 1 1 1) mo)
;; #t
; Display paging statistics after performing minimize operation
(page:stats)
;; (("page-bytes" . 512) ("page-count" . 1) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 527) ("state" . 1))

 

[Top]


page:term

Action
Terminates or suspends the paging system. paging system.

Filename
scm/scmext/kern/page_scm.cpp

APIs
None

Syntax
(page:term)

Arg Types
None

Returns
Boolean, #t if paging system is successfully terminated and #f if paging system is not suspended or termination does not succeed

Description
The (page:term) command essentially turns off the paging system. The (page:term) command causes the state to change to "suspended" or "uninitialized" depending on whether or not the page file is still needed for unpaging.

If the page system is active and the page file is empty, the (page:term) command puts the page system in the uninitialized state. If the page system is active and the page file contains paged geometric data, then (page:term) suspends the page system in the sense that entities may be unpaged from the page file as needed, but no additional entities are saved to the file.

If the paging system is suspended and the page file contains paged data when (page:term) is issued, an error message is returned. If the page system is in suspended mode, use the (part:clear) command to clear the page file. The state of the page system is automatically changed from suspended to uninitialized.

Attempting to terminate the paging system when it is in an uninitialized state results in an error.

Please note that any existing minimization strategies (defined using the (minimize:strategy) command) are automatically deleted if the paging system is suspended or terminated.

Example

; page:term
(part:clear)
;; #t
; Create two bezier curves
(define c1 (edge:bezier-ndeg (list (position 0 0 0) (position 0 1 0) (position 0 1 1) (position 1 1 1))))
;; c1
(define c2 (edge:bezier-ndeg (list (position 2 2 2) (position 2 3 2) (position 2 3 3) (position 3 3 3))))
;; c2
; Initialize and then suspend the paging system
(page:init)
;; #t
; Minimize all entities in the active part
(minimize:entities (part:entities))
;; #t
; Display paging statistics
(page:stats)
;; (("page-bytes" . 1024) ("page-count" . 2) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 1039) ("state" . 1))
; Put the paging system in suspended mode
(page:term)
;; #f
; Display paging statistics
(page:stats)
;; (("page-bytes" . 1024) ("page-count" . 2) ("unpage-bytes" . 0)
;; ("unpage-count" . 0) ("trash-bytes" . 0) ("trash-count" . 0)
;; ("biggest-entry" . 344) ("smallest-entry" . 344) ("page-file" . "acis.swp")
;; ("file-size" . 1039) ("state" . 2))
; Clear the page file (and terminate the page system)
(part:clear)
;; #t
; Try to minimize all entities in the active part
(minimize:entities (part:entities))
;; #f

 

[Top]


par-pos

Action
Creates a new uv parametric position given coordinate values u and v.

Filename
scm/scmext/kern/par_scm.cpp

APIs
None

Syntax
(par-pos u v)

Arg Types
u real
v real

Returns
par-pos

Description
Builds and returns a par-pos object for parametric location uv.

Arguments
u defines the u coordinate in parameter space.
 
v defines the v coordinate in parameter space.
; par-pos
; Create a par-pos object.
(par-pos 3 3)
;; #[par-pos 3 3]

[Top]


par-pos:copy

Action
Creates a new par-pos by copying an existing par-pos.

Filename
scm/scmext/kern/par_scm.cpp

APIs
None

Syntax
(par-pos:copy par-pos)

Arg Types
par-pos par-pos

Returns
par-pos
Arguments
par-pos specifies a par-pos object to be copied.
; par-pos:copy
; Create a par-pos object.
(define par1 (par-pos 3 3))
;; par1
; Create a new par-pos by copying an
; existing par-pos.
(par-pos:copy par1)
;; #[par-pos 3 3]

[Top]


par-pos:distance

Action
Gets the 2D distance between two par-pos.

Filename
scm/scmext/kern/par_scm.cpp

APIs
None

Syntax
(par-pos:distance par-pos1 par-pos2)

Arg Types
par-pos1 par-pos
par-pos2 par-pos

Returns
real
Arguments
par-pos1 defines the start location.
 
par-pos2 defines the end location.
; par-pos:distance
; Determine the distance between two par-pos.
(par-pos:distance (par-pos 0 1) (par-pos 0 20))
;; 19

[Top]


par-pos:set!

Action
Sets the u and v-components of a par-pos.

Filename
scm/scmext/kern/par_scm.cpp

APIs
None

Syntax
(par-pos:set! par-pos {u v})

Arg Types
par-pos par-pos
u real
v real

Returns
par-pos
Arguments
par-pos specifies the u and v values.
 
u specifies the value to replace the original u value specified in par-pos.
 
v specifies the value to replace the original v value specified in par-pos.
; par-pos:set!
; Set new u- and v-coordinates for an
; existing par-pos.
(define par1 (par-pos 0 0))
;; par1
(par-pos:set! par1 3 5)
;; #[par-pos 3 5]

[Top]


par-pos:set-u!

Action
Sets the u-component of a par-pos.

Filename
scm/scmext/kern/par_scm.cpp

APIs
None

Syntax
(par-pos:set-u! par-pos u)

Arg Types
par-pos par-pos
u real

Returns
real

Description
The u-coordinate is returned as a real.

Arguments
par-pos identifies the original u and v values.
 
u specifies the value to replace the original u value specified in par-pos.
; par-pos:set-u!
; Create a par-pos object.
(define par1 (par-pos 0 0))
;; par1
; Set a new u-coordinate for an existing par-pos.
(par-pos:set-u! par1 5)
;; 5

[Top]


par-pos:set-v!

Action
Sets the v-component of a par-pos.

Filename
scm/scmext/kern/par_scm.cpp

APIs
None

Syntax
(par-pos:set-v! par-pos v)

Arg Types
par-pos par-pos
v real

Returns
real

Description
The v-coordinate is returned as a real.

Arguments
par-pos identifies the original u and v values.
 
v specifies the value to replace the original v value specified in par-pos.
; par-pos:set-v!
; Create a par-pos object.
(define par1 (par-pos 0 0))
;; par1
; Set a new v-coordinate for an existing par-pos.
(par-pos:set-v! par1 8)
;; 8

[Top]


par-pos:u

Action
Gets the u-component of a par-pos.

Filename
scm/scmext/kern/par_scm.cpp

APIs
None

Syntax
(par-pos:u par-pos)

Arg Types
par-pos par-pos

Returns
real

Arguments
par-pos identifies the u and v values.
; par-pos:u
; Create a par-pos object.
(define par1 (par-pos 3 7))
;; par1
; Get a par-poss u-coordinate.
(par-pos:u par1)
;; 3

[Top]


par-pos:v

Action
Gets the v-component of a par-pos.

Filename
scm/scmext/kern/par_scm.cpp

APIs
None

Syntax
(par-pos:v par-pos)

Arg Types
par-pos par-pos

Returns
real

Arguments
par-pos identifies the u and v values.
; par-pos:v
; Create a par-pos object.
(define par1 (par-pos 3 7))
;; par1
; Get a par-poss v-coordinate
(par-pos:v par1)
;; 7

[Top]


par-pos?

Action
Determines if a Scheme object is a part.

Filename
scm/scmext/kern/par_scm.cpp

APIs
None

Syntax
(par-pos? object)

Arg Types
object scheme-object

Returns
boolean

Description
Returns #t for par-pos objects, otherwise returns #f.

Arguments
object specifies the scheme-object that has to be queried for a part.
; par-pos?
; Create a par-pos object.
(define par1 (par-pos 3 7))
;; par1
; Determine if an object is a par-pos.
(par-pos? par1)
;; #t
(par-pos? (gvector 0 0 0))
;; #f
(par-pos? -4)
;; #f

[Top]


part:model

Action
Gets the model associated with the specified part or the active part.

Filename
scm/scmext/kern/asm_scm.cpp

APIs
none

Syntax
(part:model [part])

Arg Types

Returns
TBD

Returns
TBD
; part:model

[Top]


pattern

Action
Constructs a pattern Scheme data type.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_from_laws, api_pattern_create_from_list

Syntax
(pattern {trans-vec [x-vec [y-vec [scale [z-vec
          [keep [root-transf]]]]]]} | in-pat |
          {positions [root]})

Arg Types
trans-vec law
x-vec law
y-vec law
scale law
z-vec law
keep boolean
root-transf transform
in-pat pattern
positions position | (position ...)
root position

Returns
pattern

Description
This extension constructs a pattern based upon the supplied arguments. The pattern may be based upon laws or upon a list of positions. (The latter type may only be used to generate translational patterns. For more general kinds of list-based patterns, use the pattern:from-list extension). In the case of law-based patterns, the user need only provide laws necessary for the creation of the pattern.

Arguments
trans-vec argument governs the translations.
 
x-vec, y-vec, and z-vec specify the orientation of the body axes of the pattern elements. Together, they govern the rotations. If z-vec is omitted, the z axis is assumed to be given by the cross product of the x-vec and y-vec. It is therefore necessary to specify z-vec only if the pattern contains reflections.
 
scale defines a scale law to be applied to the existing pattern. The scale law may evaluate either to a scalar for uniform scaling or a gvector for non-uniform scaling.
 
keep may be specified as false (#f) to suppress the pattern elements whose indices lie within the ranges of the other laws.
root-transf may be used if the seed pattern element should be transformed. Without it, the seed remains unchanged.
 
in-pat specifies a pattern. If in-pat alone is supplied, the extension merely makes a copy of this.
 
positions may be used to provide a list of pattern positions.
 
root specifies the neutral point about which the scaling takes place (that is, the point on the seed entity that remains fixed while the entity's dimensions are altered).
; pattern
; Create a translation law and attach a domain.
(define trans-vec (law "DOMAIN
    (VEC (10*X, 5*Y, 0), 0, 5, 0, 4)"))
;; trans-vec
; Create orientation laws.
(define x-vec (law "VEC (COS (X*PI/4),
    SIN (X*PI/4), 0)"))
;; x-vec
(define y-vec (law "VEC (0,0,1)"))
;; y-vec
; Create a pattern from the laws.
(define pat (pattern trans-vec x-vec y-vec))
;; pat

[Top]


pattern:check

Action
Lists the elements in an entity that have a pattern attached.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_get_coedges, api_get_edges, api_get_faces, api_get_loops, api_get_lumps, api_get_shells, api_get_vertices, api_get_wires

Syntax
(pattern:check entity [type-list] [color])

Arg Types
entity entity
type-list string | (string ...)
color boolean

Returns
boolean

Description
Checks for the presence of patterns on the BODY, LUMPs, SHELLs, FACEs, and LOOPs of an entity and generates a list of the elements with patterns. Returns #t when elements with patterns exist and #f when there are no elements with patterns.

Arguments
entity specifies an entity.
 
Defining type-list (bodies, lumps, shells, faces, or loops) generates a more selective check. By default, the function checks all entities.
 
If color is specified as #t, the faces, edges, and vertices that are patterned are colored in the display.
; pattern:check
; Create a sphere at the origin to demonstrate
; command.
(define s (solid:sphere (position 0 0 0) 10))
;; s
; Define a 2x2 hex pattern.
(define p (pattern:hex (gvector 0 1 1)
    (gvector 40 0 0) 2 2))
;; p
; Create an entity using sphere in the pattern.
(define hexpat (entity:pattern s p))
;; hexpat
; Check that hexpat is a pattern.
(pattern:check hexpat)
; entities with patterns:
;          1 bodies
;          4 lumps
;          4 shells
;          0 wires
;          4 faces
;          4 surfaces
;          1 loops
;          0 coedges
;          0 pcurves
;          0 edges
;          0 curves
;          0 vertices
;          0 points
;          All entities examined have patterns
;; #t
; Check faces only.
(pattern:check hexpat 'faces)
;      face: (entity 11 1)
;      face: (entity 12 1)
;      face: (entity 13 1)
;      face: (entity 14 1)
; entities with patterns:
;      4 faces
; All entities examined have patterns
;; #t

[Top]


pattern:circular?

Action
Determines whether or not a pattern lies on a given circle.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:circular? pat {face | {center axis}})

Arg Types
pat pattern
face face
center position
axis gvector

Returns
boolean

Description
This extension is limited in that the pattern must be defined.

This extension returns #t if a pattern lies on the circular surface associated with the face or, alternately, with the combination of center and axis. Otherwise, it returns #f.

Arguments
pat specifies a pattern.
 
face specifies a circular face.
 
center and axis together specify a circular surface.
; pattern:circular?
; choose an axis and a center defining a circle
(define center (position 5 6 3))
;; center
(define normal (gvector 0 0 1))
;; normal
; make a pattern
(define pat (pattern:cylindrical
    center normal 4 10 3))
;; pat
; does the result have circular symmetry about center
; and normal?
(pattern:circular? pat center normal)
;; #f
; what about this pattern?
(set! pat (pattern:elliptical center normal 5))
;; trans-vec:  "DOMAIN(VEC(5,6,3)+VEC(0,0,1)
;; *3*X2,0,3,0,9)"
;; x-vec:      "VEC(-1,0,0)*COS
;; (1.570796326794897*X+0)
;; +VEC(0,1,0)*SIN(1.570796326794897*X+0)"
;; y-vec:      "VEC(0,0,1)"
;; z-vec:      "null_law"
;; scale:      "null_law"
;; keep:       "null_law"
;; no list]
(pattern:circular? pat center normal)
;; #t

[Top]


pattern:coords-to-index

Action
For the specified pattern, returns the pattern index associated with the specified pattern coordinates.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:coords-to-index pat coords)

Arg Types
pat pattern
coords pair

Returns
integer
Arguments
pat specifies a pattern.
 
coords specifies the pattern coordinates.
; pattern:coords-to-index
; make a pattern
(define center (position 1 2 3))
;; center
(define normal (gvector 0 0 1))
;; normal
(define num-radial 4)
;; num-radial
(define num-angular 5)
;; num-angular
(define spacing 3)
;; spacing
(define pat (pattern:radial center
    normal num-radial num-angular spacing))
;; pat
; find the pattern index of a specific element
(define coords (list 3 2))
;; coords
(define index (pattern:coords-to-index pat coords))
;; index

[Top]


pattern:copy

Action
Makes a copy of a pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_copy

Syntax
(pattern:copy pat)

Arg Types
pat pattern

Returns
pattern
Arguments
pat specifies a pattern.
; pattern:copy
; make a pattern
(define center (position 1 2 3))
;; center
(define normal (gvector 0 0 1))
;; normal
(define num-radial 4)
;; num-radial
(define num-angular 5)
;; num-angular
(define spacing 3)
;; spacing
(define pat (pattern:radial center
    normal num-radial num-angular spacing))
;; pat
; copy the pattern
(define pat_copy (pattern:copy pat))
;; pat_copy

[Top]


pattern:cylindrical

Action
Constructs a pattern with cylindrical symmetry.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_cylindrical

Syntax
(pattern:cylindrical {center normal | face}
          num-angular [num-axial=0] [distance=0]
          [alternating=#f])

Arg Types
center position
normal gvector
face face
num-angular integer
num-axial integer
distance real
alternating boolean

Returns
pattern
Arguments
center and normal together specify the radius for the circular pattern.
 
face specifies a cylindrical face.
 
num-angular specifies the number of transverse elements in the pattern.
 
num-axial specifies the number of longitudinal elements in the pattern.
 
distance specifies the distance between the circular pattern layers.
 
If alternating is #t, adjacent layers are staggered in angle.
; pattern:cylindrical
; Create a cylindrical pattern using defaults only.
(define s (solid:sphere (position -15 -10 0) 3))
;; s
(define p (pattern:cylindrical (position -10 -10 -10)
    (gvector 1 0 1) 5 10 5))
;; p
; Attach the defined pattern to the sphere.
(define attach (entity:pattern s p))
;; attach
; Create an alternating cylindrical pattern.
; Roll back 1 step and redefine the pattern.
(roll)
;; -1
(define p (pattern:cylindrical (position 0 0 0)
    (gvector 0 0 1) 15 5 10 #t))
;; p
; Attach the defined pattern to the sphere.
(define attach (entity:pattern s p))
;; attach
; Create an alternating cylindrical pattern.
; Roll back 1 step and redefine the pattern.
(roll)
;; -1
(define p (pattern:cylindrical (position 0 0 0)
    (gvector 1 1 0) 5 7 10))
;; p
; Attach the defined pattern to the sphere.
(define attach (entity:pattern s p))
;; attach

[Top]


pattern:cylindrical?

Action
Determines whether or not a pattern lies on a given cylinder.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:cylindrical? pat {face | {center axis}})

Arg Types
pat pattern
face face
center position
axis gvector

Returns
boolean

Description
This extension returns #t if a pattern lies on the cylindrical surface. Otherwise, it returns #f.

Arguments
pat specifies a pattern.
 
face specifies a cylindrical face.
 
center and axis together specify a cylindrical surface.
; pattern:cylindrical?
; Choose an axis and a center defining a cylinder.
(define center (position 5 6 3))
;; center
(define normal (gvector 0 0 1))
;; normal
; Make a pattern.
(define pat (pattern:cylindrical
    center normal 4 10 3))
;; pat
; Does the result have cylindrical symmetry about
; the center and normal?
(pattern:cylindrical? pat center normal)
;; #t
; Try another pattern.
(set! pat (pattern:elliptical center normal 5))
;; #[pattern
;; trans-vec:  "DOMAIN(VEC(5,6,3)+VEC
;; (0,0,1)*3*X2,0,3,0,9)"
;; x-vec:      "VEC(-1,0,0)*COS
;; (1.570796326794897*X+0)
;; +VEC(0,1,0)*SIN
;; (1.570796326794897*X+0)"
;; y-vec:  "VEC(0,0,1)"
;; z-vec:  "null_law"
;; sale:   "null_law"
;; keep:   "null_law"
;; no list]
(pattern:cylindrical? pat center normal)
;; #t
; Try yet another pattern.
(set! pat (pattern:elliptical center
    (gvector 1 0 0) 5))
;; #[pattern
;; trans-vec:  "VEC(5,6,3)"
;; x-vec:      "DOMAIN(VEC(-1,0,0)
;; *COS(1.256637061435917*X)
;; +VEC(0,-1,0)*SIN
;;  (1.256637061435917*X),0,4)"
;; y-vec: "VEC(0,0,1)"
;; z-vec: "null_law"
;; scale: "null_law"
;; keep:  "null_law"
;; no list]
(pattern:cylindrical? pat center normal)
;; #f

[Top]


pattern:edge

Action
Creates a pattern parallel to an edge.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_on_edge

Syntax
(pattern:edge entity-list number root
    [on-endpoints=#f] [normal-dir tangent-dir])

Arg Types
entity-list entity | (entity ...)
number integer
root position
on-endpoints boolean
normal-dir gvector
tangent-dir gvector

Returns
pattern

Description
Creates a one-dimensional pattern of number elements, equally spaced in parameter space, parallel to an edge.

Arguments
entity-list argument may consist of an edge, a face and one of its bounding edges, or a coedge.
 
root specifies the position (which can be on or off the seed pattern entity, as desired) to be mapped to the pattern sites.
 
If on-endpoints is set to #t, the pattern could be extended to the endpoints of the edge.
 
normal-dir and tangent-dir specify the directions, relative to the seed entity, that are mapped to the normal and tangent directions of the edge, respectively.
          If normal-dir and tangent-dir are specified, the pattern members instead follow the curvature of the edge. By default, pattern members are oriented identically to one another.
          (When entity-list consists entirely of a single edge, a rail law is generated to determine the normal direction of the edge.)

; pattern:edge
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes origin
    (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define axis_start (position 0 -25 0))
;; axis_start
(define axis_end (position 0 25 0))
;; axis_end
(define start-dir (gvector 1 0 0))
;; start-dir
(define radius 5)
;; radius
(define thread_distance 10)
;; thread_distance
(define edge (edge:helix axis_start axis_end
    start-dir radius thread_distance))
;; edge
(define num 50)
;; num
(define root origin)
;; root
(define on-endpoints #f)
;; on-endpoints
(define rail-dir (gvector 1 0 0))
;; rail-dir
(define tangent-dir (gvector 0 1 0))
;; tangent-dir
(define pat (pattern:edge edge num
    root on-endpoints rail-dir tangent-dir))
;; pat
(entity:delete edge)
;; ()
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:elliptical

Action
Creates an elliptical pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_elliptical

Syntax
(pattern:elliptical center normal num
          [not-rotate=#f root [angle=360
          [ratio=1 major-axis]]])

Arg Types
center position
normal gvector
num integer
not-rotate boolean
root position
angle real
ratio real
major-axis gvector

Returns
pattern

Description
Creates a one-dimensional elliptical pattern defined by an axis of rotation.

Arguments
center and normal define the (global) position and orientation of the axis.
 
num argument defines the number of entities in the pattern. 
 
When not-rotate is #t, the elements of the pattern are kept in a fixed, relative orientation.  In which case, root is required because it defines the position mapped to the pattern sites.
angle defines the angular extent of the pattern, with positive/negative values producing patterns proceeding clockwise/counter-clockwise (accordingly) about the normal vector.
 
ratio defines the ratio of minor/major radii of the pattern.
 
major-axis defines the direction of the ellipse's major axis.
; pattern:elliptical
; Make a prism to demonstrate command.
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height maj_rad
    min_rad num_sides))
;; prism
; Output Original
; Redefine position of origin.
(define origin (position 1 2 3))
;; origin
; Reposition prism.
(define transform (entity:transform prism
    (transform:axes origin (gvector 1 0 0)
    (gvector 0 1 0))))
;; transform
; Make a pattern.
(define center (position 11 2 3))
;; center
(define normal (gvector 0 0 1))
;; normal
(define num 24)
;; num
(define not-rotate #f)
;; not-rotate
(define root origin)
;; root
(define ang 360)
;; ang
(define ratio 0.5)
;; ratio
(define major-axis (gvector 2 1 0))
;; major-axis
(define pat (pattern:elliptical center normal num
    not-rotate root ang ratio major-axis))
;; pat
; Apply the pattern to the prism.
(define body (entity:pattern prism pat))
;; body
; Output Result

Figure. pattern:elliptical

[Top]


pattern:from-list

Action
Creates a pattern from a list of positions or transformations.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_from_list

Syntax
(pattern:from-list {position-list [root]} |
          {transf-list [root-transf]})

Arg Types
position-list position | (position ...)
root position
transf-list transform | (transform ...)
root-transf transform

Returns
pattern

Description
Creates a pattern from either the positions list or the transfs list. The optional arguments root and root-transf specify the transformation to the first pattern site.

; pattern:from-list
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(entity:set-color (point origin) RED)
;; ()
(define trans (entity:transform prism
    (transform:axes origin (gvector 1 0 0)
    (gvector 0 1 0))))
;; trans
; make a pattern
(define t0 (transform:axes (position 0 0 3)
    (gvector 1 0 0) (gvector 0 1 0)))
;; t0
(define t1 (transform:axes (position 0 6 3)
    (gvector 1 0 0) (gvector 0 1 0)))
;; t1
(define t2 (transform:axes (position 6 0 3)
    (gvector 1 0 0) (gvector 0 1 0)))
;; t2
(define t3 (transform:axes (position 6 6 3)
    (gvector 1 0 0) (gvector 0 1 0)))
;; t3
(define t4 (transform:axes (position 3 3 0)
    (gvector 0 1 0) (gvector 1 0 0)))
;; t4
(define t5 (transform:axes (position 0 0 -3)
    (gvector 0 1 0) (gvector 0 0 1)))
;; t5
(define t6 (transform:axes (position 0 6 -3)
    (gvector 0 1 0) (gvector 0 0 1)))
;; t6
(define t7 (transform:axes (position 6 0 -3)
    (gvector 0 1 0) (gvector 0 0 1)))
;; t7
(define t8 (transform:axes (position 6 6 -3)
    (gvector 0 1 0) (gvector 0 0 1)))
;; t8
(define root (transform:translation
    (gvector:from-to (position 0 0 0) origin)))
;; root
(define pat (pattern:from-list
    (list t0 t1 t2 t3 t4 t5 t6 t7 t8) root))
;; pat
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:get-transform

Action
Returns the requested pattern transform.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:get-transform pat [index1 [index2]])

Arg Types
pat pattern
index1 integer
index2 integer

Returns
transform

Description
This extension returns a transform associated with the pattern specified by pat. By default, the root transformation is returned.

Arguments
pat specifies a pattern.
 
If index1 is given, the relative transformation for the pattern element indexed by its value is returned;
 
If both index1 and index2 are given, the transformation that generates the element indexed by index2 from the element indexed by index1 is returned.
; pattern:get-transform
; make a pattern
(define axis_start (position 0 -25 0))
;; axis_start
(define axis_end (position 0 25 0))
;; axis_end
(define start-dir (gvector 1 0 0))
;; start-dir
(define radius 5)
;; radius
(define thread_distance 10)
;; thread_distance
(define edge (edge:helix axis_start axis_end
    start-dir radius thread_distance))
;; edge
(define num 50)
;; num
(define root (position 1 2 3))
;; root
(define on-endpoints #f)
;; on-endpoints
(define rail-dir (gvector 1 0 0))
;; rail-dir
(define tangent-dir (gvector 0 1 0))
;; tangent-dir
(define pat (pattern:edge edge num
    root on-endpoints rail-dir tangent-dir))
;; pat
(entity:delete edge)
;; ()
; get the root transform
(define t_root (pattern:get-transform pat))
;; t_root
;get the first transform
(define t_0 (pattern:get-transform pat 0))
;; t_0
; print the two transforms
(transform:print t_root)
; rotation no reflection no shear not identity
; translation part:
;  4.111957   -27.965300   -0.288970
; affine part:
;  0.951057    0.000000  -0.309017
; -0.294459   0.303314   -0.906253
;  0.093729   0.952891    0.288469
; scaling part:
; 1.000000
;; #[transform 118280584]
(transform:print t_0)
; rotation   no reflection   no shear   not identity
; translation part:
;  4.755283   -24.500000   -1.545085
; affine part:
; -0.294459    0.303314   -0.906253
;  0.951057    0.000000   -0.309017
; -0.093729   -0.952891   -0.288469
; scaling part:
; 1.000000
;; #[transform 118280584]

[Top]


pattern:hex

Action
Creates a hexagonal packing pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_hex

Syntax
(pattern:hex normal xvec xnum ynum)

Arg Types
normal gvector
xvec gvector
xnum integer
ynum integer

Returns
pattern

Description
Creates a hexagonal pattern in the plane defined by normal.

Arguments
normal defines the plane.
 
xvec defines the x direction.
 
xnum and ynum defines the number of pattern entities in the x and y directions.
; pattern:hex
; Create a prism to demonstrate command.
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; Enlarge prism for viewing.
(define zoom (zoom 4))
;; zoom
; OUTPUT Original

; Reposition the prism.
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes origin
    (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; Create a pattern.
(define normal (gvector 0 0 1))
;; normal
(define x-vec (gvector 2 0 0))
;; x-vec
(define num_x 6)
;; num_x
(define num_y 6)
;; num_y
(define pat (pattern:hex normal x-vec num_x num_y))
;; pat
; Apply the pattern to the prism.
(define body (entity:pattern prism pat))
;; body
; Adjust picture for better viewing.
(view:compute-extrema)
;; ()
; OUTPUT Result

Figure. pattern:hex

[Top]


pattern:hex-cylindrical

Action
Creates a hexagonal pattern with cylindrical symmetry.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_hex_cylindrical

Syntax
(pattern:hex-cylindrical center normal num-angular
          [num-axial=0] [radius=0])

Arg Types
center position
normal gvector
num-angular integer
num-axial integer
radius real

Returns
pattern

Description
Creates a two-dimensional hexagonal pattern with cylindrical symmetry.

Arguments
center specifies the center position of the circular edge.
 
normal specifies the direction of extension.
 
num-angular specifies the number of angular elements in the pattern.
 
num-axial specifies the number of axial elements in the pattern.
 
radius specifies the distance between pattern elements.
; pattern:hex-cylindrical
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(entity:set-color (point origin) RED)
;; ()
(define transform (entity:transform prism
    (transform:axes origin
     (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define center (position 6 2 3))
;; center
(define normal (gvector 0 1 0))
;; normal
(define num-angular 8)
;; num-angular
(define num-axial 6)
;; num-axial
(define spacing 3)
;; spacing
(define pat (pattern:hex-cylindrical
    center normal num-angular num-axial spacing))
;; pat
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:index-to-coords

Action
For the specified pattern, returns the pattern coordinates associated with the specified pattern index.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:index-to-coords pat index)

Arg Types
pat pattern
index integer

Returns
( real ...)
Arguments
pat specifies a pattern.
 
index specifies a pattern index.
; pattern:index-to-coords
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define center origin)
;; center
(define normal (gvector 0 0 1))
;; normal
(define num-radial 4)
;; num-radial
(define num-angular 5)
;; num-angular
(define spacing 3)
;; spacing
(define pat1
    (pattern:radial center normal
    num-radial num-angular spacing))
;; pat1
; find the pattern coords of a specific element
(define index 13)
;; index
(define coords (pattern:index-to-coords pat1 index))
;; coords

[Top]


pattern:linear

Action
Creates a linear pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_linear

Syntax
(pattern:linear xvec xnum [yvec ynum [zvec znum]])

Arg Types
xvec gvector
xnum integer
yvec gvector
ynum integer
zvec gvector
znum integer

Returns
pattern

Description
Creates a linear pattern in one, two, or three dimensions based on the number of input arguments.

Arguments
xvec, yvec and zvec specify the pattern directions (these do not have to be in the coordinate directions or orthogonal.)
 
xnum, ynum and znum specify the number of repetitions along xvec, yvec and zvec respectively.
; pattern:linear
; create a sphere at the origin
(define s (solid:sphere (position 0 0 0)10))
;; s
; define the pattern in three dimensions with 3
;  repetitions along each axis
(define p (pattern:linear (gvector 30 10 0)
    3(gvector 0 30 0)3(gvector 0 0 30)3))
;; p
; create an entity using sphere in the pattern
(define spherepat (entity:pattern s p))
;; spherepat
(entity:check spherepat)
; checked:
;      27 lumps
;      27 shells
;      0 wires
;      27 faces
;      0 loops
;      0 coedges
;      0 edges
;      0 vertices
;; ()

[Top]


pattern:make-entity

Action
Creates a pattern entity data type composed of one pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_to_entity

Syntax
(pattern:make-entity pat)

Arg Types
pat pattern

Returns
pattern

Description
Creates a pattern entity which can be saved and restored from a SAT file. The pattern does not have to be attached to model geometry.

Arguments
pat specifies a pattern.
; pattern:make-entity
; make a pattern
(define normal (gvector  0 0 1))
;; normal
(define x-vec (gvector  2 0 0))
;; x-vec
(define num_x 6)
;; num_x
(define num_y 6)
;; num_y
(define pat (pattern:hex normal x-vec num_x num_y))
;; pat
; Make the associated APATTERN entity.
(define apat (pattern:make-entity pat))
;; apat
; Save myfile to a SAT file.
(part:save-selection apat "myfile.sat")
;; #t

[Top]


pattern:mod-alternating-keep

Action
Modifies an existing pattern by applying an alternating keep filter.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_filter_alternating

Syntax
(pattern:mod-alternating-keep pat keep1 keep2
           which-dim [merge=#t])

Arg Types
pat pattern
keep1 real
keep2 real
which-dim integer
merge boolean

Returns
pattern

Description
Applies an alternating keep filter to an existing pattern, merging with any existing filter or, optionally (with merge=#f), replacing it.

Arguments
pat specifies a pattern.

          keep1 and keep2 are successive Boolean keep values.

          which-dim specifies the dimension in which the filter is applied.

          If merge is false (#f), the existing filter is replaced.
; pattern:mod-alternating-keep
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes origin
    (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 4 0 0))
;; x-vec
(define num_x 8)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 10)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; modify the pattern
(define keep1 #f)
;; keep1
(define keep2 #t)
;; keep2
(define dim 1)
;; dim
(pattern:mod-alternating-keep pat
    keep1 keep2 dim))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(4,0,0)+X2*VEC
;; (0,2,0),0,7,0,9)"
;; x-vec:      "null_law"
;; y-vec:      "null_law"
;; z-vec:      "null_law"
;; scale:      "null_law"
;; keep:       "null_law"
;; no list]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-alternating-scale

Action
Modifies an existing pattern by applying an alternating scale.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_scale_alternating

Syntax
(pattern:mod-alternating-scale pat scale1 scale2
           which-dim root [merge=#t])

Arg Types
pat pattern
scale1 real | gvector
scale2 real | gvector
which-dim integer
root position
merge boolean

Returns
pattern

Description
Applies an alternating scale to an existing pattern, merging with any existing scaling, or optionally (with merge=#f), replacing it.

Arguments
pat specifies a pattern.

          scale1 and scale2 specifies the alternating scales. The scale values must be greater than zero. They may be given as vectors when non-uniform scaling is desired.

          which-dim specifies the dimension in which the scale is applied.

          root specifies the neutral point about which the scaling takes place (that is, the point on the seed entity that remains fixed while the entity's dimensions are altered).

          If merge is false (#f), the existing scaling is replaced.
; pattern:mod-alternating-scale
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 4 0 0))
;; x-vec
(define num_x 8)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 10)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; modify the pattern
(define scale1 0.8)
;; scale1
(define scale2 1.2)
;; scale2
(define dim 1)
;; dim
(define root origin)
;; root
(pattern:mod-alternating-scale
    pat scale1 scale2 dim root))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(4,0,0)+X2*VEC
;; (0,2,0),0,7,0,9)"
;; x-vec:      "null_law"
;; y-vec:      "null_law"
;; z-vec:      "null_law"
;; scale:      "null_law"
;; keep:       "null_law"
;; no list]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-compose

Action
Modifies an existing pattern by composing it with another pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:mod-compose pat1 pat2)

Arg Types
pat1 pattern
pat2 pattern

Returns
pattern
Arguments
pat1 and pat2 specify the pattern.
; pattern:mod-compose
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 2 0 0))
;; x-vec
(define num_x 4)
;; num_x
(define y-vec (gvector 1 3 0))
;; y-vec
(define num_y 5)
;; num_y
(define pat1
    (pattern:linear x-vec num_x y-vec num_y))
;; pat1
; make another pattern
(set! x-vec (gvector 20 0 0))
;; #[gvector 2 0 0]
(set! num_x 3)
;; 4
(set! y-vec (gvector 10 30 0))
;; #[gvector 1 3 0]
(set! num_y 2)
;; 5
(define pat2
    (pattern:linear x-vec num_x y-vec num_y))
;; pat2
; compose the two patterns
(pattern:mod-compose pat1 pat2)
;; pat1
; apply the pattern to the prism
(define body (entity:pattern prism pat1))
 ;; body

[Top]


pattern:mod-concatenate

Action
Modifies an existing pattern by concatenating it with another pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:mod-concatenate pat1 pat2 [transform])

Arg Types
pat1 pattern
pat2 pattern
transform transform

Returns
pattern

Description
Modifies an existing pattern by concatenating it with another pattern, optionally applying a transform to the second.

Arguments
pat1 specifies the first pattern.

          pat2 specifies the second pattern.

          transform is an optional argument specifying the transformation to be applied to the second pattern.
; pattern:mod-concatenate
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 2 0 0))
;; x-vec
(define num_x 8)
;; num_x
(define pat1 (pattern:linear x-vec num_x))
;; pat1
; make another pattern
(define center (position -4 2 3))
;; center
(define normal (gvector 0 0 1))
;; normal
(define num 8)
;; num
(define pat2 (pattern:elliptical center normal num))
;; pat2
; concatenate the patterns
(pattern:mod-concatenate pat1 pat2)
;; pat1
; apply the pattern to the prism
(define body (entity:pattern prism pat1))
;; body

[Top]


pattern:mod-keep

Action
Modifies an existing pattern by applying a keep law.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:mod-keep pat keep [merge=#t])

Arg Types
pat pattern
keep law
merge boolean

Returns
pattern

Description
Applies a keep law to an existing pattern, merging with any existing scaling or, optionally (with merge=#f), replacing it.

Arguments
pat specifies an exisiting pattern.

          keep specifies a law.

          If merge is specified as #f, the existing pattern is replaced. The default value is #t.
; pattern:mod-keep
; create a linear pattern in two dimensions
(define pat (pattern:linear
    (gvector 10 0 0) 5 (gvector 0 8 4) 4))
;; pat
; create a keep law that keeps only elements
; for which x + y < 5
(define keep (law "X + Y < 5"))
;; keep
; attach the keep law to the pattern
(set! pat (pattern:mod-keep pat keep))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(10,0,0)+X2*VEC
;; (0,8,4),0,4,0,3)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; no list]

[Top]


pattern:mod-linear-scale

Action
Modifies an existing pattern by applying a linear scale.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_scale_linear

Syntax
(pattern:mod-linear-scale pat begin-scale end-scale
           which-dim root [merge=#t])

Arg Types
pat pattern
begin-scale real | gvector
end-scale real | gvector
which-dim integer
root position
merge boolean

Returns
pattern

Description
Applies a linear scale, from begin-scale to end-scale, to an existing pattern, merging with any existing scaling or, optionally (with merge=#f), replacing it.

Arguments
pat specifies a pattern.

          begin-scale and end-scale specify the starting and ending scales respectively. Both begin-scale and end-scale must be greater than zero. They may be given as vectors when non-uniform scaling is desired.

          which-dim specifies the dimension in which the scale is applied.

          root specifies the neutral point about which the scaling takes place (that is, the point on the seed entity that remains fixed while the entity's dimensions are altered).

          If merge is specifies as #f, the existing scaling is replaced. The default value is #t.
; pattern:mod-linear-scale
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 4 0 0))
;; x-vec
(define num_x 8)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 10)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; modify the pattern
(define begin-scale 0.5)
;; begin-scale
(define end-scale 2.0)
;; end-scale
(define dim 0)
;; dim
(define root origin)
;; root
(pattern:mod-linear-scale
    pat begin-scale end-scale dim root))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(4,0,0)+X2*VEC
;; (0,2,0),0,7,0,9)"
;; x-vec:      "null_law"
;; y-vec:      "null_law"
;; z-vec:      "null_law"
;; scale:      "null_law"
;; keep:       "null_law"
;; no list]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-mirror

Action
Modifies an existing pattern by concatenating it with its reflection through a specified plane.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:mod-mirror pat root normal)

Arg Types
pat pattern
root position
normal gvector

Returns
pattern

Description
Modifies the pattern pat by concatenating it with its reflection.

Arguments
pat specifies a pattern.

          root specifies a point on the plane of reflection.

          normal specifies the normal to the plane of reflection.
; pattern:mod-mirror
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define t1 (transform:translation (gvector 0 0 0)))
;; t1
(define t2 (transform:translation (gvector 2 2 0)))
;; t2
(define t3 (transform:translation (gvector 4 0 0)))
;; t3
(define t4 (transform:translation (gvector 0 4 0)))
;; t4
(define t5 (transform:translation (gvector 4 4 0)))
;; t5
(define pat (pattern:from-list
    (list t1 t2 t3 t4 t5)))
;; pat
; mirror the pattern about the origin
(define root (position 0 0 0))
;; root
(define normal (gvector 1 1 0))
;; normal
(pattern:mod-mirror pat root normal)
;; #[pattern [list]]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-periodic-keep

Action
Modifies an existing pattern by applying a periodic keep filter.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_filter_periodic

Syntax
(pattern:mod-periodic-keep pat keep which-dim [merge=#t])

Arg Types
pat pattern
keep boolean
which-dim integer
merge boolean

Returns
pattern

Description
Applies a periodic keep filter to an existing pattern, merging with any existing filter or, optionally (with merge=#f), replacing it.

Arguments
pat specifies a pattern.

          keep is the list of successive keep values, so that the size of the list is the periodicity of the filter.

          which-dim specifies the dimension within which the filter is applied.

          If merge is specified as #f, the existing filter is replaced. The default value is #t.
; pattern:mod-periodic-keep
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 4 0 0))
;; x-vec
(define num_x 6)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 12)
;; num_y
(define z-vec (gvector 0 0 3))
;; z-vec
(define num_z 4)
;; num_z
(define pat (pattern:linear x-vec num_x
    y-vec num_y z-vec num_z))
;; pat
; modify the pattern
(define keep1 #t)
;; keep1
(define keep2 #t)
;; keep2
(define keep3 #f)
;; keep3
(define dim 1)
;; dim
(pattern:mod-periodic-keep pat
    (list keep1 keep2 keep3) dim))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(4,0,0)+X2*VEC(0,2,0)
;; +X3*VEC(0,0,3),0,5,0,11,0,3)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec   "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; no list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-periodic-scale

Action
Modifies an existing pattern by applying a periodic scale.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_scale_periodic

Syntax
(pattern:mod-periodic-scale pat scales which-dim root
           [merge=#t])

Arg Types
pat pattern
scales (real ...) | (gvector ...)
which-dim integer
root position
merge boolean

Returns
pattern

Description
Applies a periodic scale to an existing pattern, merging with any existing scaling or, optionally (with merge=#f), replacing it.

Arguments
pat specifies a pattern.

          scales is the list of successive scale values, so that the size of the list is the periodicity of the scaling. All scale values in the list must be greater than zero. They may be given as real (for uniform scaling) or as gvectors (for non-uniform scaling).

          which-dim specifies the dimension in which the scale is applied.

          root specifies the neutral point about which the scaling takes place (that is, the point on the seed entity that remains fixed while the entity's dimensions are altered).

          If merge is specified as #f, the existing scaling is replaced. The default value is #t.
; pattern:mod-periodic-scale
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 4 0 0))
;; x-vec
(define num_x 8)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 10)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; modify the pattern
(define scale1 0.5)
;; scale1
(define scale2 1.5)
;; scale2
(define scale3 1.0)
;; scale3
(define scale4 2.0)
;; scale4
(define dim 0)
;; dim
(define root origin)
;; root
(pattern:mod-periodic-scale pat
    (list scale1 scale2 scale3 scale4) dim root))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(4,0,0)+X2*VEC
;; (0,2,0),0,7,0,9)"
;; x-vec   "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; no list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-random-offset

Action
Modifies an existing pattern by adding random offsets to its elements.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_offset_random

Syntax
(pattern:mod-random-offset pat amplitude)

Arg Types
pat pattern
amplitude gvector

Returns
pattern

Description
Randomizes the given pattern by adding random offsets at each of the pattern sites.

Arguments
pat specifies a pattern.

          The components of the amplitude argument determine, in magnitude, the maximum offsets that are imposed in each dimension.
; pattern:mod-random-offset
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism
    (solid:prism height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 4 0 0))
;; x-vec
(define num_x 12)
;; num_x
(define y-vec (gvector 0 4 0))
;; y-vec
(define num_y 12)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; modify the pattern
(define amplitude (gvector 1 0.5 4.0))
;; amplitude
(pattern:mod-random-offset pat amplitude)
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(4,0,0)+X2*VEC(0,4,0),
;; 0,11,0,11)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; [list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-random-orient

Action
Modifies an existing pattern by adding random rotations to its elements.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_orient_random

Syntax
(pattern:mod-random-orient pat [min-axial max-axial
           axial-dir min-tilt max-tilt tilt-dir])

Arg Types
pat pattern
min-axial real
max-axial real
axial-dir gvector
min-tilt real
max-tilt real
tilt-dir gvector

Returns
pattern

Description
Randomizes the given pattern by applying random rotations at each of the pattern sites. The default arguments yield a totally random rotation.

Arguments
pat specifies a pattern.

          min-axial and max-axial arguments specify the range of values in the axial direction specified by axial-dir.

          axial-dir specifies the axial direction.

          min-tilt and max-tilt arguments specify the range of values in the tilt direction specified by tilt-dir.

          tilt-dir specifies the tilt direction. If the tilt-dir direction is not orthogonal to axial-dir, only its orthogonal component is used.
; pattern:mod-random-orient
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism
    (solid:prism height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 4 0 0))
;; x-vec
(define num_x 8)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 10)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; modify the pattern
(define root origin)
;; root
(define min-axial 0)
;; min-axial
(define max-axial 360)
;; max-axial
(define axial-dir (gvector 1 0 0))
;; axial-dir
(define min-tilt 0)
;; min-tilt
(define max-tilt 0)
;; max_tilt
(define tilt-dir (gvector 0 0 1))
;; tilt-dir
(pattern:mod-random-orient pat root
    min-axial max-axial axial-dir
    min-tilt max-tilt tilt-dir))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(4,0,0)+X2*VEC
;; (0,2,0),0,7,0,9)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; no list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-random-keep

Action
Modifies an existing pattern by applying a random keep filter.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_filter_random

Syntax
(pattern:mod-random-keep pat fraction [merge=#t])

Arg Types
pat pattern
fraction real
merge boolean

Returns
pattern

Description
Applies a periodic keep filter to an existing pattern, merging with any existing filter or, optionally (with merge=#f), replacing it.

Arguments
pat specifies a pattern.

          fraction determines the fraction of pattern elements that are kept.

          If merge is specified as false (#f), the existing filter is replaced. The default value is true (#t).
; pattern:mod-random-keep
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism
    (solid:prism height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 4 0 0))
;; x-vec
(define num_x 12)
;; num_x
(define y-vec (gvector 0 4 0))
;; y-vec
(define num_y 12)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; modify the pattern
(define keep_fraction 0.5)
;; keep_fraction
(pattern:mod-random-keep pat keep_fraction)
;; #[pattern
;; trans-vec:"DOMAIN(X*VEC(4,0,0)+X2*VEC
;; (0,4,0),0,11,0,11)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; [list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-random-scale

Action
Modifies an existing pattern by applying a random scale.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_scale_random

Syntax
(pattern:mod-random-scale pat min_scale max_scale
           root [merge=#t])

Arg Types
pat pattern
min_scale real | gvector
max_scale real | gvector
root position
merge boolean

Returns
pattern

Description
Applies a random scale to an existing pattern, merging with any existing scaling or, optionally (with merge=#f), replacing it.

Arguments
pat specifies a pattern.

          min_scale and max_scale arguments specify limits for the scale values. Both min_scale and max_scale must be greater than zero. They may be given as gvectors when non-uniform scaling is required.

          root specifies the neutral point about which the scaling takes place (that is, the point on the seed entity that remains fixed while the entity's dimensions are altered).

          If merge is specified as false (#f), the existing scaling is replaced. The default value is true (#t).
; pattern:mod-random-scale
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism
    (solid:prism height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 4 0 0))
;; x-vec
(define num_x 8)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 10)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; modify the pattern
(define min_scale 0.5)
;; min_scale
(define max_scale 2.0)
;; max_scale
(define root origin)
;; root
(pattern:mod-random-scale
    pat min_scale max_scale root))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(4,0,0)+X2*VEC
;; (0,2,0),0,7,0,9)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; no list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:mod-reflect

Action
Modifies an existing pattern by reflecting it through a given plane.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:mod-reflect pat root normal)

Arg Types
pat pattern
root position
normal gvector

Returns
pattern
Arguments
pat specifies a pattern.

          root specifies a point on the plane of reflection.

          normal specifies the normal to the reflection plane.
; pattern:mod-reflect
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism
    (solid:prism height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a copy of the prism
(define prismr (entity:copy prism))
;; prismr
; make a pattern
(define t1 (transform:translation (gvector 0 0 0)))
;; t1
(define t2 (transform:translation (gvector 2 2 0)))
;; t2
(define t3 (transform:translation (gvector 4 0 0)))
;; t3
(define t4 (transform:translation (gvector 0 4 0)))
;; t4
(define t5 (transform:translation (gvector 4 4 0)))
;; t5
(define pat (pattern:from-list
    (list t1 t2 t3 t4 t5)))
;; pat
; reflect the pattern about the origin
(define root (position 0 0 0))
;; root
(define normal (gvector 1 1 0))
;; normal
(define patr (pattern:copy pat))
;; patr
(pattern:mod-reflect patr root normal))
;; ;; patr
; apply the original pattern to the original prism
(define apply (entity:pattern prism pat))
;; apply
; apply the reflected pattern to the copy
(define body (entity:pattern prismr patr))
;; body

[Top]


pattern:mod-scale

Action
Modifies an existing pattern by applying a scale law.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:mod-scale pat scale root [merge=#t])

Arg Types
pat pattern
scale law
root position
merge boolean

Returns
pattern

Description
Applies a scale law to an existing pattern, merging with any existing scaling or, optionally (with merge=#f), replacing it.

Arguments
pat specifies a pattern.

          scale law specifies the scaling to be applied. The scale law may evaluate to a scalar if uniform scaling is desired or to a gvector if non-uniform scaling is desired.

          root specifies the neutral point about which the scaling takes place (that is, the point on the seed entity that remains fixed while the entity's dimensions are altered).

          If merge is specified as false (#f), the existing pattern is replaced. The default value is true (#t).
; pattern:mod-scale
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism
    height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform2 (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform2
; make a pattern
(define x-vec (gvector 2 0 0))
;; x-vec
(define num_x 5)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 5)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; modify the pattern
(define scale (law "(Y+1)/5"))
;; scale
(define root origin)
;; root
(pattern:mod-scale pat scale root)
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(2,0,0)+X2*VEC
;; (0,2,0),0,4,0,4)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; no list]
; modify the pattern again
(set! scale (law "(5 - X)/5"))
;; #[law "(Y+1)/5"]
(pattern:mod-scale pat scale root)
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(2,0,0)+X2*VEC
;; (0,2,0),0,4,0,4)+VEC(1,2,3)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "(Y+1)/5"
;; keep:   "null_law"
;; no list]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:move-element

Action
Moves a single element within an existing pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_element_transform

Syntax
(pattern:move-element pat coords transf)

Arg Types
pat pattern
coords pair
transf transform

Returns
pattern

Description
Moves the element specified by coords according to the transformation transf.

Arguments
pat specifies a pattern.
 
coords specifies the element to be transformed.
 
transf specifies the transformation to be applied.
; pattern:move-element
; Make a prism.
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; Position the prism.
(define origin (position 1 2 3))
;; origin
; Move the prism.
(define transform (entity:transform prism
    (transform:axes origin (gvector 1 0 0)
    (gvector 0 1 0))))
;; transform
; Make a pattern.
(define x-vec (gvector 2 0 0))
;; x-vec
(define num_x 8)
;; num_x
(define y-vec (gvector 0 3 0))
;; y-vec
(define num_y 8)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; OUTPUT Original

;Move one of the pattern elements.
(define disp (gvector 0.4 1.2 0.5))
;; disp
(define move (transform:translation disp))
;; move
(set! pat (pattern:move-element pat (list 3 2) move))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(2,0,0)+X2*VEC
;; (0,3,0),0,7,0,7)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; [list]]
; Apply the pattern to the prism.
(define body (entity:pattern prism pat))
;; body
; OUTPUT Result

Figure. Moving Pattern Elements

[Top]


pattern:planar?

Action
Determines whether or not a pattern is parallel to a given plane.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:planar? pat {face | {root-point normal}})

Arg Types
pat pattern
face face
root-point position
normal gvector

Returns
boolean

Description
This extension returns #t if a pattern lies on the plane. Otherwise, it returns #f.

Arguments
pat specifies a pattern.
 
face specifies a plane.
 
root-point specifies a point on the plane.
 
normal specifies the normal to the plane.
; pattern:planar?
; define root position for test
(define root (position 0 0 3))
;; root
; make a linear pattern in the xy plane
(define x-vec (gvector 10 0 0))
;; x-vec
(define y-vec (gvector 10 10 0))
;; y-vec
(define pat (pattern:linear x-vec 3 y-vec 5))
;; pat
; Is it planar with respect to a normal in the
; x direction?
(pattern:planar? pat root
    (gvector:cross x-vec y-vec))
;; #t
; make a circular pattern in the xy plane
(define center (position 5 6 3))
;; center
(define normal (gvector 0 0 1))
;; normal
(set! pat (pattern:elliptical center normal 5))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(10,0,0)+X2*VEC
;; (10,10,0),0,2,0,4)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; no list]
; Is it planar with respect to a normal in the
; z direction?
(pattern:planar? pat root normal)
;; #t

[Top]


pattern:polar-grid

Action
Creates a polar-grid pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_polar_grid

Syntax
(pattern:polar-grid center normal num dist
           [start] [not-rotate=#f] [hex-symmetry=#f]
           [start-angle=0] [end-angle=360] [ratio=1])

Arg Types
center position
normal gvector
num integer
dist real
start gvector
not-rotate boolean
hex-symmetry boolean
start-angle real
end-angle real
ratio real

Returns
pattern

Description
Creates a two-dimensional polar-grid pattern. The pattern coordinates are specified in the order (radial, angular).

Arguments
center defines the root position (that may or may not lie upon the seed entity).
 
normal vector sets the orientation of the pattern.
 
num specifies the number of rings in the grid (including the center).
 
dist specifies the distance between the rings.
 
start is an optional argument that specifies the direction of the first spoke of the pattern.
 
If not-rotate is true (#t), the elements of the pattern are kept in a fixed relative orientation.
 
If hex-symmetry is true (#t), the hexagonal symmetry is maintained for patterns extending either 360 or 180 degrees.
 
start-angle and end-angle arguments fix the angular extent of the pattern.
 
ratio argument sets the ratio of minor/major radii at the pattern perimeter.
; pattern:polar-grid
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define center origin)
;; center
(define normal (gvector 0 0 1))
;; normal
(define num_rings 5)
;; num_rings
(define spacing 4)
;; spacing
(define pat (pattern:polar-grid
    center normal num_rings spacing))
;; pat
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:print-transform

Action
Prints the requested pattern transform to stdout.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:print-transform [index1 [index2]])

Arg Types
pat pattern
index1 integer
index2 integer

Returns
boolean

Description
This extension prints a transform associated with the pattern specified by pat. By default, the root transformation is printed.

Arguments
pat specifies a pattern.
 
If index1 is given, the relative transformation for the pattern element indexed by its value is output instead.
 
If both index1 and index2 are given, the output is the element which is indexed by index2 from the element indexed by index1.
; pattern:print-transform
; make a pattern
(define axis_start (position 0 -25 0))
;; axis_start
(define axis_end (position 0 25 0))
;; axis_end
(define start-dir (gvector 1 0 0))
;; start-dir
(define radius 5)
;; radius
(define thread_distance 10)
;; thread_distance
(define edge (edge:helix axis_start axis_end
    start-dir radius thread_distance))
;; edge
(define num 50)
;; num
(define root (position 1 2 3))
;; root
(define on-endpoints #f)
;; on-endpoints
(define rail-dir (gvector 1 0 0))
;; rail-dir
(define tangent-dir (gvector 0 1 0))
;; tangent-dir
(define pat (pattern:edge edge num
    root on-endpoints rail-dir tangent-dir))
;; pat
(entity:delete edge)
;; ()
; print the root transform
(define result1 (pattern:print-transform pat))
;; result1
; print the first transform
(define result2 (pattern:print-transform pat 0))
;; result2
; check for success
(law:equal-test result1 #t)
;; #t
(law:equal-test result2 #t)
;; #t

[Top]


pattern:radial

Action
Creates a radial pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_radial

Syntax
(pattern:radial center normal num-radial
           num-angular dist [start] [not-rotate=#f]
           [start-angle=0] [end-angle=360] [ratio=1])

Arg Types
center position
normal gvector
num-radial integer
num-angular integer
dist real
start gvector
not-rotate boolean
start-angle real
end-angle real
ratio real

Returns
pattern

Description
Creates a two-dimensional radial pattern. The pattern coordinates are specified in the order (radial, angular).

Arguments
center defines the root position (that may or may not lie upon the seed entity).
 
normal vector sets the orientation of the pattern.
 
num-radial specifies the number of elements in the radial direction.
 
num-angular specifies the number of elements in the angular direction.
 
dist specifies the distance between successive rings of the pattern.
 
start is an optional argument that specifies the direction of the first spoke of the pattern.
 
If not-rotate is true (#t), the elements of the pattern are kept in a fixed relative orientation.
 
start-angle and end-angle arguments fix the angular extent of the pattern.
 
ratio argument sets the ratio of minor/major radii at the pattern perimeter.
; pattern:radial
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism
    (solid:prism height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define center origin)
;; center
(define normal (gvector 0 0 1))
;; normal
(define num-radial 4)
;; num-radial
(define num-angular 5)
;; num-angular
(define spacing 3)
;; spacing
(define pat (pattern:radial
    center normal num-radial num-angular spacing))
;; pat
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:random

Action
Creates a random pattern within the indicated region.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_random

Syntax
(pattern:random extents number [dimension=3]
           [ellipsoidal=#f] [x-vec=(1 0 0)] [y-vec=(0 1 0)])

Arg Types
extents gvector
number integer
dimension integer
ellipsoidal boolean
x-vec gvector
y-vec gvector

Returns
pattern

Description
Creates a random pattern of a specified number of elements, centered at the location of the pattern seed entity. The distance from center may be extended by specifying a value for extents.

Arguments
extents specifies the extension distance.
 
number specifies the number of elements.
 
dimension specifies the extension dimension.
 
If ellipsoidal is set to true (#t), the number of pattern elements actually generated may differ somewhat from number.
 
x-vec and y-vec specify the orientation of the pattern, and are the directions associated with the first two components of extents. (The third component is associated with the cross product of these arguments.)
; pattern:random
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism
    (solid:prism height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define extents (gvector 50 25 10))
;; extents
(define num 100)
;; num
(define dim 3)
;; dim
(define pat (pattern:random extents num dim))
;; pat
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:remove

Action
Removes all patterns from an entity.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:remove entity)

Arg Types
entity entity

Returns
boolean
Arguments
entity specifies an entity.
; pattern:remove
; create a pattern to be removed
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define t1 (transform:translation (gvector 0 0 0)))
;; t1
(define t2 (transform:translation (gvector 2 2 0)))
;; t2
(define t3 (transform:translation (gvector 4 0 0)))
;; t3
(define t4 (transform:translation (gvector 0 4 0)))
;; t4
(define t5 (transform:translation (gvector 4 4 0)))
;; t5
(define pat (pattern:from-list
    (list t1 t2 t3 t4 t5)))
;; pat
; mirror the pattern about the origin
(define root (position 0 0 0))
;; root
(define normal (gvector 1 1 0))
;; normal
(set! pat (pattern:mod-mirror pat root normal))
;; #[pattern [list]]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body
; remove the pattern
(pattern:remove body)
;; #t

[Top]


pattern:remove-element

Action
Removes a single element from an existing pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_element_remove

Syntax
(pattern:remove-element pat coords)

Arg Types
pat pattern
coords pair

Returns
pattern

Description
Removes the element specified by coords from an existing pattern.

Arguments
pat specifies a pattern.
 
coords identify the element in the pattern to be removed.
; pattern:remove-element
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism
    height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define center origin)
;; center
(define normal (gvector 0 0 1))
;; normal
(define num-radial 4)
;; num-radial
(define num-angular 5)
;; num-angular
(define spacing 3)
;; spacing
(define pat (pattern:radial
    center normal num-radial num-angular spacing))
;; pat
; remove the center element
(set! pat (pattern:remove-element
    pat (list 0 0)))
;; #[pattern
;; trans-vec:  "DOMAIN(VEC(-1,0,0)*COS
;; (1.256637061435917*X2)*3*X+VEC
;; (0,-1,0)*SIN(1.256637061435917*X2)
;; *3*X+VEC(1,2,3),0,3,0,4)"
;; x-vec:  "VEC(-1,0,0)*COS
;; (1.256637061435917*X2)
;; +VEC(0,-1,0)*SIN
;; (1.25663706143591?7*X2)"
;; y-vec:  "VEC(0,0,1)"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "PIECEWISE(X>0,X,X2<1)"
;; [list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:restore-element

Action
Restores the element specified by coords to an existing pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_element_restore

Syntax
(pattern:restore-element pat coords)

Arg Types
pat pattern
coords pair

Returns
pattern

Description
Restores the element specified by coords to an existing pattern.

Arguments
pat specifies a pattern.
 
coords identify the element to be restored.
; pattern:restore-element
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism
    height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform2 (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform2
; make a pattern
(define x-vec (gvector 2 0 0))
;; x-vec
(define num_x 4)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 4)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; apply a keep law to the pattern
(define keep (law "X + Y < 4"))
;; keep
(set! pat (pattern:mod-keep pat keep))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(2,0,0)+X2*VEC
;; (0,2,0),0,3,0,3)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; no list]
; restore the corner element removed by the keep law
(set! pat (pattern:restore-element pat (list 3 3)))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(2,0,0)+X2*VEC
;; (0,2,0),0,3,0,3)"
;; x-vec:  "null_law"
;; y-vec:  "null_law"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "X+Y<4"
;; [list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:scale-element

Action
Scales a single element of an existing pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_element_scale

Syntax
(pattern:scale-element pat coords scale root)

Arg Types
pat pattern
coords real
scale real | gvector
root position

Returns
pattern

Description
Scales the element specified by coords of an existing pattern about the position root by an amount scale.

Arguments
pat specifies a pattern.
 
coords identify the element in the pattern.
 
scale argument specifies the scale value to be applied. The scale may be a real number, for uniform scaling, or a vector, for non-uniform scaling.
 
root specifies the neutral point about which the scaling takes place (that is, the point on the seed entity that remains fixed while the entity's dimensions are altered).
; pattern:scale-element
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define trans (entity:transform prism
    (transform:axes origin
    (gvector 1 0 0) (gvector 0 1 0))))
;; trans
; make a pattern
(define center origin)
;; center
(define normal (gvector 0 0 1))
;; normal
(define num-radial 4)
;; num-radial
(define num-angular 5)
;; num-angular
(define spacing 3)
;; spacing
(define pat (pattern:radial center normal
    num-radial num-angular spacing))
;; pat
; modify the pattern
(define scaling 2)
;; scaling
(define root origin)
;; root
(set! pat (pattern:scale-element pat
    (list 0 0) scaling root))
;; #[pattern
;; trans-vec:  "DOMAIN(VEC(-1,0,0)*COS
;; (1.256637061435917*X2)*3*X+VEC
;; (0,-1,0)*SIN(1.256637061435917*X2)
;; *3*X+VEC (1,2,3),0,3,0,4)"
;;  x-vec:"VEC(-1,0,0)*COS
;; (1.256637061435917*X2)+VEC
;; (0,-1,0)*SIN(1.256637061435917*X2)"
;; y-vec:  "VEC(0,0,1)"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "PIECEWISE(X>0,X,X2<1)"
;; [list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body
(law:equal-test (length (entity:vertices body)) 96)
;; #t

[Top]


pattern:set-root-transf

Action
Creates a new pattern by applying a root transformation to an existing pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:set-root-transf pat root-transf)

Arg Types
pat pattern
root-transf transform

Returns
pattern

Description
Applies a root transformation to an existing pattern, replacing the existing root transformation, if any.

Arguments
pat specifies a pattern.
 
root-transf specifies the root transformation to be applied.
; pattern:set-root-transf
; make a body and a copy
(define body1 (solid:sphere (position 0 0 0) 1))
;; body1
(define body2 (entity:copy body1))
;; body2
; make a linear pattern along the x-axis
(define pat1 (pattern:linear (gvector 5 0 0) 5))
;; pat1
; apply the pattern to the original body
(define apply (entity:pattern body1 pat1))
;; apply
; make a new pattern from the original, but
; translated four units in the y direction
(define root-transf (transform:translation
    (gvector 0 4 0)))
;; root-transf
(define pat2 (pattern:set-root-transf
    pat1 root-transf))
;; pat2
; apply the new pattern to the second body
(define apply2 (entity:pattern body2 pat2))
;; apply2

[Top]


pattern:size

Action
Returns the number of elements in the given pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_query_size

Syntax
(pattern:size pat)

Arg Types
pat pattern

Returns
integer

Description
This extension returns the number of elements in the pattern specified by pat.

; pattern:size
; make a pattern
(define center (position 1 2 3))
;; center
(define normal (gvector 0 0 1))
;; normal
(define num-radial 4)
;; num-radial
(define num-angular 5)
;; num-angular
(define spacing 3)
;; spacing
(define pat
    (pattern:radial center normal
    num-radial num-angular spacing))
;; pat
; find the pattern size
(define size (pattern:size pat))
;; size

[Top]


pattern:spherical

Action
Creates a spherical pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_spherical

Syntax
(pattern:spherical center num-latitudes
           root [spacing])

Arg Types
center position
num-latitudes integer
root position
spacing real

Returns
pattern

Description
Creates a two-dimensional spherical pattern about the center position, with the seed pattern entity at one pole of the associated sphere. The pattern coordinates are specified in the order longitude, latitude.

Arguments
center specifies the center of the spherical pattern.
 
num-latitudes specifies the number of latitudinal rings in the pattern. If num-latitudes is set to zero, this number is instead determined by the optional spacing parameter.
 
root specifies the root position of the pattern.
 
spacing is an optional argument specifying the distance between the elements. The spacing must be given if num-latitudes is zero.
; pattern:spherical
; make a pyramid
(define height 0.5)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.1)
;; min_rad
(define num_sides 3)
;; num_sides
(define pyramid
    (solid:pyramid height maj_rad min_rad num_sides))
;; pyramid
;position the pyramid
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform pyramid
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
(zoom-all)
;; #[view 1508128]
; output original

; make a pattern
(define center (position 1 2 -2))
;; center
(define num-latitudes 10)
;; num-latitudes
(define root origin)
;; root
(define pat
    (pattern:spherical center num-latitudes root))
;; pat
; apply the pattern to the pyramid
(define body (entity:pattern pyramid pat))
;; body
; output Result

Figure. Spherical Patterns

[Top]


pattern:spherical?

Action
Determines whether or not a pattern lies on a given sphere.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:spherical? pat {face | center})

Arg Types
pat pattern
face face
center position

Returns
boolean

Description
This extension returns #t if a pattern lies on the spherical surface associated with the face or, alternately, with center. Otherwise, it returns #f.

Arguments
pat specifies a pattern.
 
face specifies a spherical face.
 
center specifies the center point of a spherical surface.
; pattern:spherical?
; make a spherical pattern
(define center (position 5 6 3))
;; center
(define root (position 0 0 0))
;; root
(define pat (pattern:spherical center 5 root))
;; pat
; is it spherical about its center?
(pattern:spherical? pat center)
;; #t
; make a circular pattern in the xy plane
(define normal (gvector 0 0 1))
;; normal
(set! pat (pattern:elliptical center normal 5))
;; #[pattern
;; trans-vec:  "VEC(5,6,3)"
;; x-vec:  "DOMAIN(VEC(0,0.4472135954999579,
;; -0.8944271909999159)*COS
;; (0.89759790102?56552*X)*COS
;; (0.7853981633974483*X2)+VEC
;; (0.801783725737273,
;; -0.5345224838248487,
;; -0.2672612419124243)*SIN
;; (0.8975979010256552*X)*COS
;; (0.7853981633974483*X2)+VEC
;; (0.5976143046671968,
;; 0.7171371656006361,
;; 0.3585685828003181)*SIN
;; (0.7853981633974483*X2),0,6,0,4)"
;; y-vec:  "VEC(0,0.4472135954999579,
;; -0.8944271909999159)*-1*SIN
;; (0.897597901025655?2*X)+VEC
;; (0.801783725737273,
;; -0.5345224838248487,
;; -0.2672612419124243)*COS
;; (0.8975979010256552*X)"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "X2>0ANDX2<4ORNOT(X2>0ANDX2<4)ANDX=0"
;; no list]
; is it spherical about its center?
(pattern:spherical? pat center)
;; #t
; make a circular pattern in the yz plane
(set! pat
    (pattern:elliptical center (gvector 1 0 0) 5))
;; #[pattern
;; trans-vec:  "VEC(5,6,3)"
;; x-vec:      "DOMAIN(VEC(-1,0,0)*COS
;; (1.256637061435917*X)+VEC
;; (0,-1,0)*SIN(1.256637061435917*X),
;; 0,4)"
;; y-vec:      "VEC(0,0,1)"
;; z-vec:      "null_law"
;; scale:      "null_law"
;; keep:       "null_law"
;; no list]
;is it spherical about its center?
(pattern:spherical? pat center)
;; #t
; make a spherical pattern about a new center
(define new_center (position 5 5 3))
;; new_center
(set! pat (pattern:spherical new_center 5 root))
;; #[pattern
;; trans-vec:  "VEC(5,6,3)"
;; x-vec:  "DOMAIN(VEC(0,-1,0)*COS
;; (1.256637061435917*X)+VEC
;; (0,0,-1)*SIN(1.25663706?1435917*X),
;; 0,4)"
;; y-vec:  "VEC(1,0,0)"
;; z-vec:  "null_law"
;; scale:  "null_law"
;; keep:   "null_law"
;; no list]
; is it spherical about the old center?
(pattern:spherical? pat center)
;; #f

[Top]


pattern:surface

Action
Creates a pattern parallel to a surface.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_create_on_surface

Syntax
(pattern:surface entity num-u num-v root
           [on-boundary=#f] [dir-u dir-v])

Arg Types
entity entity
num-u integer
num-v integer
root position
on-boundary boolean
dir-u gvector
dir-v gvector

Returns
pattern
Arguments
entity specifies a face entity.

          num-u and num-v arguments specify the number of elements along u and v directions respectively.
 
root specifies the position (which can be on or off the seed pattern entity, as desired) to be mapped to the pattern sites.
 
If on-boundary is set to true (#t), the pattern extends to the face boundary.
 
If dir-u and dir-v are specified, the orientation of the pattern members follow the surface normal. In this case, these vectors specify the directions, relative to the seed entity, that are mapped to the u- and v-direction of the face. By default, pattern members are oriented identically to one another.
; pattern:surface
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define pos origin)
;; pos
(define radius 20)
;; radius
(define long_start 0)
;; long_start
(define long_end 90)
;; long_end
(define lat_start -360)
;; lat_start
(define lat_end 360)
;; lat_end
(define normal (gvector 0 0 1))
;; normal
(define face (face:sphere pos radius
    long_start long_end lat_start lat_end normal))
;; face
(define u_num 8)
;; u_num
(define v_num 6)
;; v_num
(define root origin)
;; root
(define pat (pattern:surface face
    u_num v_num root))
;; pat
(entity:delete face)
;; ()
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:transform

Action
Creates a new pattern by applying a transformation to an existing pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
api_pattern_modify_transform

Syntax
(pattern:transform pat transf)

Arg Types
pat pattern
transf transform

Returns
pattern

Description
Applies the transformation transf to an existing pattern pat.

; pattern:transform
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 2 0 0))
;; x-vec
(define num_x 5)
;; num_x
(define y-vec (gvector 1 3 0))
;; y-vec
(define num_y 4)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; transform the pattern
(define t (transform:axes (position 4 5 6)
    (gvector 0 1 0) (gvector 0 0 1)))
;; t
(set! pat (pattern:transform pat t))
;; #[pattern
;; trans-vec:  "TRANS(DOMAIN(X*VEC(2,0,0)+X2*VEC
;; (1,3,0),0,4,0,3),TRANS1)"
;; x-vec:      "DOMAIN(VEC(0,1,0),0,3)"
;; y-vec:      "DOMAIN(VEC(0,0,1),0,3)"
;; z-vec:      "null_law"
;; scale:      "null_law"
;; keep:       "null_law"
;; no list]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern:undo-move-element

Action
Undoes a move applied to a single element of an existing pattern.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern:undo-move-element pat coords)

Arg Types
pat pattern
coords pair

Returns
pattern

Description
Undoes all moves applied to the pattern element specified by coords, restoring it to its original position within the pattern.

Arguments
pat specifies a pattern.
 
coords identifies the element in the pattern.
; pattern:undo-move-element
; make a prism
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism (solid:prism height
    maj_rad min_rad num_sides))
;; prism
; position the prism
(define origin (position 1 2 3))
;; origin
(define transform (entity:transform prism
    (transform:axes
    origin (gvector 1 0 0) (gvector 0 1 0))))
;; transform
; make a pattern
(define x-vec (gvector 2 0 0))
;; x-vec
(define num_x 8)
;; num_x
(define y-vec (gvector 0 3 0))
;; y-vec
(define num_y 8)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; move one of the pattern elements
(define disp (gvector 0.4 1.2 0.5))
;; disp
(define move (transform:translation disp))
;; move
(set! pat (pattern:move-element pat (list 3 2) move))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(2,0,0)+X2*VEC
;; (0,3,0),0,7,0,7)"
;; x-vec:      "null_law"
;; y-vec:      "null_law"
;; z-vec:      "null_law"
;; scale:      "null_law"
;; keep:       "null_law"
;; [list]]
; undo the move
(set! pat (pattern:undo-move-element pat (list 3 2)))
;; #[pattern
;; trans-vec:  "DOMAIN(X*VEC(2,0,0)+X2*VEC
;; (0,3,0),0,7,0,7)"
;; x-vec:      "null_law"
;; y-vec:      "null_law"
;; z-vec:      "null_law"
;; scale:      "null_law"
;; keep:       "null_law"
;; [list]]
; apply the pattern to the prism
(define body (entity:pattern prism pat))
;; body

[Top]


pattern?

Action
Determines whether or not a Scheme object is of the pattern Scheme data type.

Filename
scm/scmext/kern/pattern_scm.cpp

APIs
None

Syntax
(pattern? object)

Arg Types
object scheme-object

Returns
boolean

Description
This extension returns #t if the given object is a pattern Scheme data type. Otherwise, it returns #f.

Arguments
object specifies the scheme-object that has to be queried for a pattern.
; pattern?
; Create prism geometry to illustrate command.
(define height 1)
;; height
(define maj_rad 1)
;; maj_rad
(define min_rad 0.5)
;; min_rad
(define num_sides 3)
;; num_sides
(define prism
    (solid:prism height maj_rad min_rad num_sides))
;; prism
(zoom-all)
;; [view 13369704]
; Verify prism is not a pattern.
(pattern? prism))
;; #f
; Create a pattern.
(define x-vec (gvector 2 0 0))
;; x-vec
(define num_x 5)
;; num_x
(define y-vec (gvector 0 2 0))
;; y-vec
(define num_y 5)
;; num_y
(define pat (pattern:linear x-vec num_x y-vec num_y))
;; pat
; Verify pat is a pattern.
(pattern? pat)
;; #t

[Top]


point:position

Action
Computes the position of a point.

Filename
scm/scmext/kern/pnt_scm.cpp

APIs
None

Syntax
(point:position point)

Arg Types
point point

Returns
position

Description
This extension accepts an entity of the type point, and it returns the position of the point.

; point:position
; Create a point.
(define point1 (point (position 6 6 7)))
;; point1
; Get the location of the point.
(point:position point1)
;; #[position 6 6 7]

[Top]


point?

Action
Determines if a Scheme object is a point.

Filename
scm/scmext/kern/pnt_scm.cpp

APIs
None

Syntax
(point? object)

Arg Types
object scheme-object

Returns
boolean
Arguments
object specifies the scheme-object that has to queried for a point.
; point?
; Create a point.
(define point1 (point (position 6 6 7)))
;; point1
; Determine if the point is actually a point.
(point? point1)
;; #t

[Top]


position

Action
Creates a new position with coordinates x, y, and z.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position x y z [space="models"])

Arg Types
x real
y real
z real
space string

Returns
position
Arguments
x defines the x-coordinate relative to the active coordinate system.
 
y defines the y-coordinate relative to the active coordinate system.
 
z defines the z-coordinate relative to the active coordinate system.
 
The optional space argument defaults to "WCS". If no active WCS exists, space defaults to model. The other optional space arguments return a gvector in the new coordinate system. The following values for the space argument are:
-        "wcs" is the default if an active WCS exists. Otherwise, the default setting is "model".
-        "model" means that the x, y, and z values are with respect to the model. If the model has an origin other than the active WCS, this returns the position relative to the active coordinate system in rectangular Cartesian coordinates.
-        "polar" or "cylindrical" mean that the x, y, and z values are interpreted as the radial distance from the z-axis, the polar angle in degrees measured from the xz plane (using right-hand rule), and the z coordinate, respectively. This returns the x, y, and z terms with respect to the active coordinate system.
-        "spherical" means that the provided x, y, and z values are the radial distance from the origin, the angle of declination from the z-axis in degrees, and the polar angle measured from the xz plane in degrees, respectively. This returns the x, y, and z terms with respect to the active coordinate system.

  A position is not saved with the part, but is used to help define geometry. Positions are not displayed in Scheme. A point is an entity. A point is different from a vertex in that it has no edge associations. Use env:set-point-size and env:set-point-style to change its appearance.
; position
; Create a position.
(define pos1 (position 3 3 3))
;; pos1
; Create a position in the
; "cylindrical" coordinate system.
(define pos-cyl (position 20 20 0 "cylindrical"))
;; pos-cyl
; Define a solid block using the created position.
(define block1 (solid:block pos1 pos-cyl))
;; block1

[Top]


position:closest

Action
Gets the position from a list of positions that is closest to a given position.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:closest position position-list)

Arg Types
position position
position-list position | (position ...)

Returns
position
Arguments
position specifies the location that all other positions are compared against.
 
position-list specifies the locations to compare against the given position.
; position:closest
; Determine the closest position in a list
; of positions to a given position.
(define pos1 (position:closest (position 30 30 30)
    (list (position 10 10 0) (position 25 22 0))))
;; pos1

[Top]


position:copy

Action
Creates a new position by copying an existing position.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:copy position)

Arg Types
position position

Returns
position
Arguments
position specifies the position object that has to be copied.
; position:copy
; Create a new position by copying
; an existing position.
(define pos1 (position 20 20 0 "cylindrical"))
;; pos1
(define pos2 (position:copy pos1))
;; pos2

[Top]


position:distance

Action
Gets the distance between two positions.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:distance position1 {position2 | ray})

Arg Types
position1 position
position2 position
ray ray

Returns
real
Arguments
position1 defines the start location.
 
position2 defines the end location.
 
ray defines the ray to calculate the distance.
; position:distance
; Determine the distance between two positions.
(define pos1 (position 20 20 0 "cylindrical"))
;; pos1
(position:distance pos1 (position 0 20 0))
;; 22.9430574540418

[Top]


position:interpolate

Action
Interpolates a new position based on the weight between two given positions.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:interpolate position1 position2 weight)

Arg Types
position1 position
position2 position
weight real

Returns
position

Description
This extension returns the position as determined by weight.

Arguments
position1 specifies the first position.
 
position2 specifies the second position.
 
weight is a real number, ranging from 0 to 1.
 
The position is given by:
 
((1-weight) * position1) + (weight * position2)
 
Given weight:               Resulting position:
0                                     position1
          1                                     position2
          0.5                                  The midpoint between position1 and position2.
; position:interpolate
; Interpolate new positions between
; two given positions.
(position:interpolate (position 3 5 4)
    (position 3 3 3) 0)
;; #[position 3 5 4]
(position:interpolate (position 3 5 4)
    (position 3 3 3) 1)
;; #[position 3 3 3]
(position:interpolate (position 3 5 4)
    (position 3 3 3) 0.5)
;; #[position 3 4 3.5]

[Top]


position:offset

Action
Creates a new position offset from a given position.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:offset position gvector)

Arg Types
position position
gvector gvector

Returns
position
Arguments
position specifies the location of the old position.
 
gvector specifies the gvector to apply to the position.
; position:offset
; Create a new position, offset by a gvector
; from a given position.
(position:offset (position 0 0 0)
    (gvector 10 10 10))
;; #[position 10 10 10]
; Define the start position.
(define pos-start (position 0 -4 0))
;; pos-start
; Define the start direction.
(define dir-start (gvector 8 -8 0))
;; dir-start
; Create a new position, offset by a gvector
; from a given position.
(position:offset pos-start dir-start)
;; #[position 8 -12 0]

[Top]


position:project-to-line

Action
Gets the projection of a position on to a line.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:project-to-line position line-pos line-dir)

Arg Types
position position
line-pos position
line-dir gvector

Returns
position

Description
line-pos and line-dir together define the line. This extension returns the position on the line.

Arguments
position specifies the position to project.
 
line-pos specifies a position on the line.
 
line-dir specifies a gvector defining the direction of the line.
; position:project-to-line
; Project a position onto a line.
(position:project-to-line (position 10 10 10)
    (position 0 0 0) (gvector 0 1 0))
;; #[position 0 10 0]

[Top]


position:project-to-plane

Action
Gets the projection of a position onto a plane.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:project-to-plane position
           plane-pos plane-normal)

Arg Types
position position
plane-pos position
plane-normal gvector

Returns
position

Description
plane-pos and plane-normal together specify the plane. This extension returns the position on the plane.

Arguments
position specifies the position to project.
 
plane-pos specifies a position on the plane.
 
plane-normal specifies a gvector defining the plane normal.
; position:project-to-plane
; Project a position onto a plane.
(position:project-to-plane (position 0 0 0)
    (position 25 25 25) (gvector 1 0 0))
;; #[position 25 0 0]

[Top]


position:set!

Action
Sets the x, y, and z-components of a position.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:set! pos1 {{x y z} | {pos2}})

Arg Types
pos1 position
x real
y real
z real
pos2 position

Returns
position
Arguments
pos1 specifies the position to be set.
 
If x, y and z values are specified, they are copied into pos1.
 
If pos2 is specified, its position value is copied into pos1.
; position:set!
; Set new x-, y-, and z-coordinates for
; an existing position.
(define pos1 (position 0 0 0))
;; pos1
(position:set! pos1 3 5 4)
;; #[position 3 5 4]

[Top]


position:set-x!

Action
Sets the x-component of a position.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:set-x! position x)

Arg Types
position position
x real

Returns
real

Description
The coordinates are computed relative to the active coordinate system. This extension returns the x-coordinate as a real.

Arguments
position identifies the original y and z values.
 
x specifies the value to replace the original x-value specified in position.
; position:set-x!
; Set a new x-coordinate for an existing position.
(define pos1 (position 0 0 0))
;; pos1
(position:set-x! pos1 5)
;; 5

[Top]


position:set-y!

Action
Sets the y-component of a position.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:set-y! position y)

Arg Types
position position
y real

Returns
real

Description
The coordinates are computed relative to the active coordinate system. This extension returns the y-coordinate as a real.

Arguments
position identifies the original x and z values.
 
y specifies the value to replace the original y-value specified in position.
; position:set-y!
; Set a new y-coordinate for an existing position.
(define pos1 (position 0 0 0))
;; pos1
(position:set-y! pos1 8)
;; 8

[Top]


position:set-z!

Action
Sets the z-component of a position.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:set-z! position z)

Arg Types
position position
z real

Returns
real

Description
The coordinates are computed relative to the active coordinate system. This extension returns the z-coordinate as a real.

Arguments
position specifies the original x and y values.
 
z specifies the value to replace the original z-value specified in position.
; position:set-z!
; Set a new z-coordinate for an existing position.
(define pos1 (position 0 0 0))
;; pos1
(position:set-z! pos1 -4)
;; -4

[Top]


position:transform

Action
Applies a transform to a position.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:transform position transform)

Arg Types
position position
transform transform

Returns
position
Arguments
position specifies the location to apply the transform.
 
transform is any valid transform.
; position:transform
; Apply a transform to a position.
(define pos1 (position 5 10 15))
;; pos1
(define pos2 (position:transform pos1
    (transform:translation (gvector 0 1 0))))
;; pos2

[Top]


position:x

Action
Gets the x-component of a position relative to the active coordinate system.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:x position)

Arg Types
position position

Returns
real
Arguments
position specifies a position.
; position:x
; Get a positions x-coordinate.
(define pos1 (position 5 10 15))
;; pos1
(position:x pos1)
;; 5

[Top]


position:y

Action
Gets the y-component of a position relative to the active coordinate system.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:y position)

Arg Types
position position

Returns
real
Arguments
position specifies a position.
; position:y
; Get a positions y-coordinate.
(define pos1 (position 5 10 15))
;; pos1
(position:y pos1)
;; 10

[Top]


position:z

Action
Gets the z-component of a position relative to the active coordinate system.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position:z position)

Arg Types
position position

Returns
real
Arguments
position specifies a position.
; position:z
; Get a positions z-coordinate.
(define pos1 (position 5 10 15))
;; pos1
(position:z pos1)
;; 15

[Top]


position?

Action
Determines if a Scheme object is a position.

Filename
scm/scmext/kern/pos_scm.cpp

APIs
None

Syntax
(position? object)

Arg Types
object scheme-object

Returns
boolean
Arguments
object specifies the scheme-object that has to be queried for a position.
; position?
; Determine if a position is a position.
(define pos1 (position 5 10 15))
;; pos1
(position? pos1)
;; #t
(position? (position 6 5 8))
;; #t
; Determine if a gvector is a position.
(position? (gvector 0 0 0))
;; #f
; Determine if a value is a position.
(position? -4)
;; #f
; Define a new position.
(define pts (position 10 10 10))
;; pts
; Determine if the new position is a position.
(position? pts)
;; #t

[Top]


sscache:set-mode

Action
Sets spl_sur global cache run mode.

Filename
kern/kern_scm/gcmgr_scm.cpp

APIs
None

Syntax
(sscache:set-mode run_mode)

Arg Types
run_mode string

Returns
string, previous run mode.

Description
Sets spl_sur global cache run mode.

Arguments
run_mode specifies the spl_sur global cache run mode; the two possible values are "no_limit" and "hard_limit".

Example

; set new spl_sur global cache run mode
(sscache:set-mode 'hard_limit')
;; no_limit

[Top]


sscache:set-size

Action
Sets spl_sur global cache size.

Filename
kern/kern_scm/gcmgr_scm.cpp

APIs
None

Syntax
(sscache:set-size new_size)

Arg Types
new_size integer

Returns
integer if successful, value is size of cache before change, otherwise, zero

Description
Sets spl_sur global cache size.

Arguments
new_size specifies the spl_sur global cache size; must be greater than or equal to three.

Example

; set new spl_sur global cache size
(sscache:set-size 40)
;; 20

[Top]


system:memory-use

Action
Displays the memory use of the current scheme process.

Filename
scm/scmext/kern/page_scm.cpp

APIs
None

Syntax
(system:memory-use)

Arg Types
None

Returns
integer committed memory in KBytes.

Description
For NT systems, the memory displayed is the total committed memory in the virtual address space of the current process as returned by the Win32 API VirtualQuery. For further information on Windows memory management, please consult the Microsoft documentation.

Limitations
Currently implemented only on NT operating systems.

Example

(part:clear)
;; #t
; Get initial memory usage
(system:memory-use)
;; 127128
; Load a part
(part:load "test.sat")
;;(#[entity 1 1])
; Get new memory usage
(system:memory-use)
;; 135712

[Top]