filter:apply
List of: Scheme Extensions
Subjects: Filtering
Contents: Kernel

Action: Applies a filter to an entity or list of entities.

Filename: kern/kern_scm/filt_scm.cxx

Syntax: (filter:apply filter entity-or-list)

Arg Types: filter entity-filter

entity-or-list entity | (entity ... )

Returns: (entity ... )

Description: Once a filter is created, the filter can be applied to obtain the particular results. For example, if numerous entities are components of a part of various colors, applying a color filter to the list of entities returns the list of entities that match the filter's color. When applying the filter to an entity that does not meet the requirements for the filter, this extension returns the empty list.


filter specifies an entity-filter.


entity-or-list specifies an entity or an entity list.

Example: ; filter:apply

; Create solid block 1.

(define block1


(solid:block (position 10 0 10)


(position 20 30 40)))

;; block1

; Create linear edge 2.

(define edge1 (edge:linear (position 0 0 0)


(position 10 10 10)))

;; edge1

; Create circular edge 3.

(define edge2 (edge:circular (position 0 0 0) 20))

;; edge2

; Change the color of the entities so far to red.

(entity:set-color (part:entities) 1)

;; ()

; Create solid sphere 4.

(define sphere1 (solid:sphere


(position 20 30 40) 30))

;; sphere1

; Create solid sphere 5.

(define cyl1 (solid:cylinder


(position 40 0 0) (position 5 5 5) 8))

;; cyl1

; Create linear edge 6.

(define edge3 (edge:linear (position 0 50 0)


(position 50 50 0)))

;; edge3

; Create spline edge 7.

(define edge4 (edge:spline (list


(position 20 20 20) (position 10 20 30)


(position 50 40 10))))

;; edge4

; Apply a green filter and obtain the entities.

(filter:apply (filter:color 2) (part:entities))

;; (#[entity 5 1] #[entity 6 1]

;; #[entity 7 1] #[entity 8 1])

; Apply a solid, red filter and obtain the entities.

(filter:apply (filter:and (filter:type "solid?")


(filter:color 1)) (part:entities))

;; (#[entity 2 1])

; Apply a solid, green filter and

; obtain the entities.

(part:entities (filter:type "solid?"))

;; (#[entity 2 1] #[entity 5 1] #[entity 6 1])

(filter:apply (filter:type "solid?") edge1)

;; ()
PDF/KERN/13SCF.PDF
HTM/DATA/KERN/KERN/13SCF/0021.HTM