Picking   

<<< KID Rendering Chapters Fault Reporting in KID >>>

Contents

[back to top]


14.1 Introduction

Assemblies, bodies, points, edges, faces, vertices, curves and surfaces can be picked from the screen or directly from other entities:

Picking makes a connection between the KID object and the tag of the kernel item.

[back to top]


14.2 Picking from the screen

pick

To pick an item from the screen, the command pick is used. Initially the user has to define the type of entity which is to be picked from the items displayed on the screen. The command:

 

> ( <entity> pick )

produces a cursor on the screen, which can then be positioned over the entity (face, edge, body, etc.) which is to be picked. Pressing an appropriate key records the tag or coordinates for the pick. In the case of topological items further calls to ( <entity> pick ) allow further entities of the same type to be picked and added to the tag list of <entity> .

 

Object

Function

entity

pick

> (b0 sketch)        -- sketch the body
> (define f1 face)   -- define the object
> (f1 pick)          -- puts up the moveable crosswires -
                        press any key to pick the item
> (f1 sketch)        -- now the object can be used

pick is also a function of p_points , and can be used to pick coordinate sets from the screen in image space, or directly by giving an optional argument of a set of coordinates. This is described in the section "Using p_points to create a p_profile". The function pick can pick indirectly from the screen when used with two optional arguments.

The pick can only be made from a graphics view, so that if a model is not drawn the pick cannot be made. The entity to be picked must first be defined.

To assist the above operations the commands pick2, and pick3 are used, these commands expect multiple picks from the screen to be made.

Using p_points to create a p_profile

The primitive p_points can be used with the function "pick" to build a set of coordinates in the image plane. The p_points object must first be defined, and the cursor enabled by the "pick" function. A series of points can be picked in the image plane, by pressing an appropriate key, and the sequence terminated by picking a previously picked point. The item of class p_points can be used to create a body from a profile using p_profile , which in turn can be swept or swung to produce a new item.

 

> (define b0 p_block)
> (b0 x 10; y 10; z 10; create)
> (graphics sketch ´b0)
> (define p1 p_points) -- define p1 as p_points
> (p1 pick)            -- enable cursor for picking coordinate
                       -- set in the image plane
> (define b1 p_profile)

The coordinates for b0 can also be given in either of the ways shown:

 

> (b1 coordinate (p1 coordinate))  -- implicit coordinate list
> (b1 coordinate `( (1 2 3 ) (...)))
    -- explicit coordinate list
> (b1 create)
    -- create kernel item (acorn, wire  or sheet body)

[back to top]

14.2.1 Pick with one argument

When "pick" is invoked with just one argument ( the position vector of the eye point in model space), the nearest entity to that point in the current view direction is picked. Only a face facing toward the eye_point would be picked, assuming a face had been defined.

[back to top]

14.2.2 Pick with two arguments

When both arguments are given, the implicit current view direction is overwritten with the second argument, and entities are picked in an identical way. This mode of use could be applied when an eye point and view direction are already known, for example when taken directly from a journal file.

 

> (f1 pick `(200 200 200) `(1 1 1) )
Note: The "pick" command actually uses the graphics "drawing_list" to determine which entities have been selected.

The "drawing_list" is not reset by the (graphics clear) command but needs to be reset independently:

 

> (graphics drawing_list nil) 

If the "drawing_list" is not reset then it is possible to pick from objects which no longer appear in the display. Conversely, if "pick" is being used with arguments then it is only necessary to add the entities to the drawing_list in order to pick from them - there is no actual need to display them:

 

> (define b0 p_block)            -- define a p_block
> (b0 create)                    -- create the block
> (graphics drawing_list nil)    -- empty the drawing_list
> (graphics add ´b0)             -- add b0 to the drawing_list

               (graphics drawing_list ´(b0)) would be
               equivalent to the previous two commands

> (define f0 face)        -- define a face
> (f0 pick ´(0 0 11))     -- pick the face nearest to ´(0 0 11)
                              in the current view_direction

[back to top]


14.3 Picking directly from other objects

Picking can be done without an image on the screen. This type of logical picking is achieved by successive qualification, for example by picking all the faces in a body, then selecting only those with specified geometric properties. Three functions can be used, "pick_from", "pick_using" and "pick_node".

pick_from

"pick_from" collects all items of a particular type from an object below the entity class. The equivalent statement might be "all edges in the body". "pick_from" purges any duplicates from the resulting tag list. Unlike "pick", "pick_from" is not cumulative, and a further call to it replaces the tags collected previously with a new set.

pick_using

"pick_using" filters a set of items using a function as a qualifying clause. This is equivalent to a statement such as "only those faces with spherical surfaces". If "pick_using" finds no items, an empty sublist is returned. A few examples of this are shown next.

pick_node

"pick_node" uses the node identifier of an object to pick it from the body or KI assembly to which it belongs.

 

Object

Function

entity

pick_from, pick_using, pick_node

> (define b1 p_block)
> (b1 x 20; y 20; z 10; create)   -- create block b1
> (define f1 face)
> (define e1 edge)
> (define e2 edge)
> (define v1 vertex)
> (f1 pick_from ´b1)      -- f1 has a list of all 6 face tags
> (e1 pick_from ´b1)      -- e1 has a list of all 12 edge tags
> (v1 pick_from ´b1)      -- v1 has a list of all 8 vertex tags

> (f1 pick_using ´(f1 clash ´(0 0 0)))
      -- f1 will now only possess tags of faces which 
         contain the point ´(0 0 0) i.e. 1 tag only

> (e1 pick_using ´(e1 clash ´(10 10 0)))
      -- e1 will now only possess tags of edges which 
         contain the point ´(10 10 0) i.e. 3 tags

> (v1 pick_using t)       -- v1 tag list will remain unchanged
                              as condition is always true

Assume a body b1 has been created with some toroidal faces. The example which follows shows how to find those faces which are toroidal and have a specific major radius.

 

> (define f1 face)
> (f1 pick_from b1)       -- f1 will contain all faces in b1
> (f1 pick_using ´(eq (f1 enquire ´type) ´toroidal))
> (f1 pick_using ´(eq (f1 enquire ´majrad ) 10.0 ))

> (f1 pick_using ´(equal (f1 enquire ´point) ´(0.0 0.0 0.0)))
    -- f1  will now only contain toroidal faces with a 
       major radius of 10.0, and axis point at the origin

   NOTE:  >eq< only works for atoms >equal< for lists and atoms

The next example shows how the top face of a block can be picked without using the cursor, so that a new surface can be exchanged for this one using tweak .

 

> (define b1 p_block)
> (b1 x 10;y 10;z 10;create)
> (face help tweak)   -- for information on how to tweak a face
> (define f1 face)
> (f1 pick_from ´b1)  -- f1 now contains all 6 faces of b1
> (f1 pick_using ´(f1 clash ´(0 0 10)))
                      -- f1 is now the top face of b1

> (p_planar help create)    -- information
> (define s1 p_planar)
> (s1 point ´(0 0 50); direction ´(0 0 1); create)
                 -- s1 is plane at Z = 50 parallel to XY plane

> (f1 tweak ´s1) -- this will raise the face up to the surface
                    s1, and now body b1 has the 
                     dimensions x 1O, y 10, z 50

If pick_using finds no items an error message is returned, e.g.

 

( error "f2; no match entity" )

and the existing list is left unaltered.

 

> ((define f0 face) pick_node 34 ´b0)
> ((define f0 face) pick_node ´(34 45 56) ´b0)
> ((define c0 curve) pick_node ´(21 23 25) ´b0)

Using a list of tags to manipulate an object

Some KID functions result in the tag property of an entity having a LISP list of tags. An example of this is the function pick_from . It is often possible to manipulate an object with a list of tags using the same functions as if it had a single tag. This facility is not provided by all KID functions.

 

> (define b1 p_block)
> (b1 x 10; y 20; z 10; create)   -- create block b1
> (define f1 face)
> (f1 pick_from ´b1)           -- f1 is a list of b1´s 6 faces
> (f1 pick_using ´(f1 clash ´(5 5 10)))
     -- leave only those faces which clash with this point,
        f1 now refers to a set of two faces from body b1

> (f1 enquire )                  --> information
> (f1 direction ´(10 9 8); move)  -- this will move both faces

[back to top]


14.4 Picking vector points

A class p_points exists as a subclass of primitive. The class has a function "pick" which allows the user to give a list of vector points as its argument. These are held in the object's coordinate property. The user can either supply the list as an argument to pick, or can supply no argument and thus employ the cursor to select the vector points. Consider the following examples:

 

Object

Function

p_points

pick

> (define b0 p_points)
> (b0 help pick)         --> information
> (b0 pick ´(0 0 0))     -- b0 is set to the origin
> (b0 coordinate)        --> (0 0 0)
> (define b0 p_points)
> (b0 pick ´( (0 0 0) (1 1 1) (2 2 2) ) )  -- b0 is set to
> (b0 coordinate) --> ((0 0 0) (1 1 1) (2 2 2))
                       coordinate list
> (define b0 p_points)
> (b0 pick)

This then prompts the user to select the list of points by moving the cursor in the graphics frame with the arrow keys. Points are selected by moving to the desired location and striking any key, the list is terminated when a key is struck without the user having moved the cursor. The selected vector points are located on the graphics viewing plane. (The viewing plane is a plane perpendicular to the current view_direction passing through the current view_to point.)

No other functions are provided; p_points is intended only as a convenient location for storing a list of coordinates.

[back to top]


14.5 Picking an entity from an assembly

To pick from an assembly, first the assembly must be converted from a single layer assembly to a list of bodies (changes the type of entity from an assembly to a body).

 

> (a0 disassemble)    -- unpacks bodies from instances and 
                         applies transforms; a0 is now a body
> (graphics ske a0)
> (define e0 edge)
> (e0 pick)  -- pick the edge from the body a0 using the cursor

assemble function

The inverse operation, to create the assembly, takes the part with one or more tags and makes each an instance in an assembly, which can then be transmitted as a single entity.

 

> (a0 tag)
> (100 174 279 1000)
> (a0 assemble)           -- a0 is now an assembly
> (a0 transmit "part_name")

[back to top]

<<< KID Rendering Chapters Fault Reporting in KID >>>