Initialisation du projet pst-solides3d.git (SVN revision 142)
[pst-solides3d.git] / doc-en / par-datfile-en.tex
1 \section{Using the data file types \texttt{.obj} and \texttt{.off}}
2
3 Sometimes it will helpful to use external files, either for reading or writing.
4 When there is a solid which needs a long time to be calculated and which
5 will be tested in different views or different colors, it is very
6 interesting to save them externally and then only reread them by
7 avoiding the time expensive recalculations. In particular, this technique
8 is often used to generate some animations.
9 One can also export a solid by that method to reuse with another software.
10
11 For \texttt{pst-solides3d}, all the procedures of reading$/$writing are
12 delegated to the PostScript interpreter (and not to \TeX {} or \LaTeX).
13 Consequently it is not the \LaTeX{} compilation that will cause the
14 execution of reading$/$writing, but the visualisation of the PostScript
15 file that is produced.
16
17 Generally the reading of external files by a PostScript interpreter doesn't
18 cause any trouble normally. The writing of files however, can cause some
19 security problems and it is often the case that the PostScript viewer forbids
20 the writing by default. So the system must be configured to get authorisation for that writing.
21
22 \encadre{By default, under Windows and Linux, the security of files on the
23 hard drive is activated and doesn't allow to write on the drive.
24 To deactivate that security option, more or less temporarily, here the two
25 corresponding procedures:
26
27 \begin{description}
28
29 \item[Linux:] The advice from Jean-Michel \textsc{Sarlat}: the simplest will
30 be to use GhostScript directly, within the console. As there is no image to wait for:
31
32 \$$>$ gs -dNOSAFER monfichier.ps quit.ps
33 \item[Windows:] Within the menue \texttt{Options}, the option
34 \textsf{Security of files} must be turned to unchecked.
35 \end{description}}
36
37
38 \subsection{\texttt{\Index{.dat}} files (specific to \texttt{pst-solides3d})}
39
40 In \texttt{pst-solides3d}, the data structure used for a solid has 4 fields.
41 It can be stored in a set of $4$
42 \texttt{.dat} files.
43
44
45 \subsubsection{Writing \texttt{.dat} files}
46
47 One uses the action \Lkeyword{writesolid} within \Lcs{psSolid}, and one
48 uses the option \Lkeyword{file} to specify the name of the file.
49
50 For example, let's look at the code below:
51 \begin{verbatim}
52 \psSolid[object=tore,
53 file=montore,
54 action=writesolid]
55 \end{verbatim}
56
57 The command chain
58 \Cadre{LaTeX->dvips->GSview (Windows) or gv (Linux)}
59 first compiles, then transforms into PostScript to finally get
60 visualised.
61
62 That last operation creates 4 files:
63 \begin{compactitem}
64 \item \texttt{montore-sommets.dat } $\rightarrow$ the list of the vertices;
65 \item \texttt{montore-faces.dat } $\rightarrow$ the list of the faces;
66 \item \texttt{montore-couleurs.dat } $\rightarrow$ the colors of the faces;
67 \item \texttt{montore-io.dat } $\rightarrow$ the limits of the indices
68 of the external and internal faces.
69 \end{compactitem}
70 \encadre{All these four files will automatically be saved within the same folder as the generating file.}
71
72 \subsubsection{Reading \texttt{.dat} files}
73
74 We use the object \Lkeyword{datfile} of \Lcs{psSolid}, with the argument
75 \Lkeyword{file} to specify the name.
76 Now the code
77 \begin{verbatim}
78 \psSolid[object=datfile, file=montore]
79 \end{verbatim}
80 will allow us to use the object---now saved in the \texttt{.dat} files generated---
81 as described in the previous paragraph.
82
83 \subsection{\texttt{.obj} files}
84
85 We use only a simplified form of the \texttt{.obj} format. In particular, the
86 files should not contain a character like
87 \verb+#+ (the character for a comment in that format).
88
89 This format just uses a single file and permits within this file to specify
90 the vertices and the faces.
91
92 \subsubsection{Writing \texttt{\Index{.obj}} files}
93
94 One uses the action \Lkeyword{writeobj} in \Lcs{psSolid}, and one uses
95 the option \Lkeyword{file} to specify the name of the file.
96
97 For example, the code below:
98 \begin{verbatim}
99 \psSolid[object=tore,
100 file=montore,
101 action=writeobj]
102 \end{verbatim}
103 will produce a single file \texttt{montore.obj} (after compilation and
104 visualisation of the \texttt{.ps} that was produced).
105
106 \subsubsection{Reading \texttt{.obj} files}
107
108 One uses the option \Lkeyword{objfile} of \Lcs{psSolid}, with the argument
109 \Lkeyword{file} to specify the name of the file.
110 Now the following code
111 \begin{verbatim}
112 \psSolid[object=objfile, file=montore]
113 \end{verbatim}
114 will allow to use the object---now saved in the \texttt{.obj} file generated---as
115 described in the previous paragraph.
116
117 \begin{LTXexample}[width=6cm]
118 \psset{viewpoint=20 15 10 rtp2xyz,Decran=20}
119 \begin{pspicture}(-3,-4)(3,3)
120 \psframe*[linecolor=cyan!50](-3,-4)(1,3)
121 \psSolid[object=objfile,
122 unit=20,RotX=60,
123 file=./rocket]%
124 \end{pspicture}
125 \end{LTXexample}
126
127
128
129 \subsection{\texttt{.off} files}
130
131 We use only a simplified form of the \texttt{.off} format. In particular, these
132 files only comprise \verb+v+ and \verb+f+ entries.
133
134 This format just uses a single file and permits within this file to specify the
135 vertices and the faces.
136
137 \subsubsection{Writing \texttt{\Index{.off}} files}
138
139 We use the action \Lkeyword{writeobj} in \Lcs{psSolid}, and we use the option
140 \Lkeyword{file} to specify the name of the file.
141
142 For example the code below:
143 \begin{verbatim}
144 \psSolid[object=tore,
145 file=montore,
146 action=writeoff]
147 \end{verbatim}
148 will produce the \texttt{montore.off} file (after compilation and
149 visualisation of the \texttt{.ps} that was produced).
150
151 \subsubsection{Reading.off files}
152
153 We use the option \Lkeyword{offfile} of \Lcs{psSolid}, with the argument
154 \Lkeyword{file} to specify the name of the file.
155 Now the following code
156 \begin{verbatim}
157 \psSolid[object=offfile, file=montore]
158 \end{verbatim}
159 will allow to use the object---now saved in the \texttt{.off} file
160 generated---like described in the previous paragraph.
161
162 \endinput

Licence Creative Commons Les fichiers de Syracuse sont mis à disposition (sauf mention contraire) selon les termes de la
Licence Creative Commons Attribution - Pas d’Utilisation Commerciale - Partage dans les Mêmes Conditions 4.0 International.