| 1 |
\section{Naming a solid} |
| 2 |
|
| 3 |
For certain purposes, it is helpful to save a solid in working |
| 4 |
storage to allow it to be referenced later on. To do so, we |
| 5 |
activate the Boolean \Lkeyword{solidmemory}, which allows the |
| 6 |
transmission of a variable throughout the code. |
| 7 |
|
| 8 |
Consequently, activation of this Boolean deactivates drawing |
| 9 |
by the macros \Lcs{psSolid}, \Lcs{psSurface} and \Lcs{psProjection} |
| 10 |
immediate. To obtain the drawing, we use the macro |
| 11 |
\Lkeyword{\composeSolid} at the end of the code. |
| 12 |
|
| 13 |
When \verb+\psset{solidmemory}+ is set up, we can use the option |
| 14 |
\Lkeyword{name} of the macro \Lcs{psSolid}. |
| 15 |
|
| 16 |
In the example below, a coloured solid is constructed, which is |
| 17 |
named $A$. It is drawn using the object \texttt{\Lkeyword{object}=cube} with |
| 18 |
the parameter \texttt{\Lkeyword{load}=$A$}. |
| 19 |
|
| 20 |
Note that \texttt{\Lkeyword{linecolor}=blue}, used while constructing our cube, |
| 21 |
has no effect on the drawing: only the structure of the solid is |
| 22 |
stored (vertices, faces, colours of faces), not the thickness of |
| 23 |
any line, nor its colour, nor the position of the light source. |
| 24 |
The settings of those parameters are taken into account at the |
| 25 |
time the solid is rendered. |
| 26 |
|
| 27 |
|
| 28 |
Finally, we demonstrate the use of the option |
| 29 |
\Lkeyword{deactivatecolor} which allows the cube to keep its |
| 30 |
original red colour (otherwise the default colours would be used |
| 31 |
within the object \Lkeyword{load}). |
| 32 |
|
| 33 |
\psset{lightsrc=10 0 10,viewpoint=50 -20 10 rtp2xyz,Decran=50} |
| 34 |
\begin{LTXexample}[width=6.5cm] |
| 35 |
\psset{unit=0.75} |
| 36 |
\begin{pspicture*}(-4,-4)(5,4) |
| 37 |
\psset{solidmemory} |
| 38 |
\psSolid[object=cube, |
| 39 |
linecolor=blue, |
| 40 |
a=4,fillcolor=red!50, |
| 41 |
ngrid=3, |
| 42 |
action=none, |
| 43 |
name=A, |
| 44 |
](0,0,0) |
| 45 |
\psSolid[object=load, |
| 46 |
deactivatecolor, |
| 47 |
load=A] |
| 48 |
\composeSolid |
| 49 |
\end{pspicture*} |
| 50 |
\end{LTXexample} |
| 51 |
|
| 52 |
With the option \Lkeyword{solidmemory}, the names of variables are |
| 53 |
relatively well encapsulated, and there will be no conflict with |
| 54 |
the variables of the dvips driver. There remains however the risk |
| 55 |
of a collision with the names used in the \texttt{solides.pro} |
| 56 |
file. You could use only single letter variable names, for |
| 57 |
example, and it is necessary to avoid names like \verb+vecteur+, |
| 58 |
\verb+distance+, \verb+droite+, etc. which are already defined in |
| 59 |
the package. |
| 60 |
|
| 61 |
|
| 62 |
\endinput |