find:pattern-index
List of: Scheme Extensions
Subjects: Patterns
Contents: Kernel

Action: Finds the pattern index associated with a given entity.

Filename: kern/kern_scm/pattern_scm.cxx

Syntax: (find:pattern-index entity)

Arg Types: entity entity

Returns: integer

Errors: An invalid entity was specified.

Description: Finds the zero-based pattern index associated with the entity specified by entity.


entity specifies the entity to be searched.

Example: ; find:pattern-index

; 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

; find the pattern index of a specific lump

(define lump (list-ref (entity:lumps body) 8))

;; lump

(define index (find:pattern-index lump))

;; index

; check the index

(law:equal-test index 8)

;; #t
PDF/KERN/13SCF.PDF
HTM/DATA/KERN/KERN/13SCF/0028.HTM