"Fossies" - the Fresh Open Source Software Archive

Member "brlcad-7.32.4/doc/mged/k.tex" (29 Jul 2021, 16822 Bytes) of package /linux/misc/brlcad-7.32.4.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TeX and LaTeX source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 \chapter{BUILDING A TIN WOODSMAN}
    2 
    3 \begin{figure}
    4 \centering \includegraphics{wm-prims.ps}
    5 \caption{WoodsMan Primitives.}
    6 \label{wm-prims}
    7 \end{figure}
    8 
    9 The purpose of this tutorial is to demonstrate how to build a model using
   10 a few basic primitives.  The model to be constructed is a tin woodsman.
   11 The four primitives used in the construction of the tin woodsman
   12 are an ARB8, a cylinder, an ellipsoid, and a torus.
   13 These four primitives will be duplicated several times,
   14 and each copy will be modified using solid editing,
   15 to obtain the required shapes.
   16 The finished version of this database can be found in
   17 the BRL-CAD Package file ``db/woodsman.g''.
   18 
   19 \section{Create Primitives}
   20 
   21 \noindent{\tt
   22 \$ {\em mged woodsman.g} \\
   23 BRL-CAD Release 3.0 Graphics Editor (MGED) Compilation 82 \\
   24     Thu Sep 22 08:08:39 EDT 1988 \\
   25     mikel@video.br:/cad/.mged.4d2 \\
   26  \\
   27 woodsman.g: No such file or directory \\
   28 Create new database (y|n)[n]? {\em y} \\
   29 attach (nu|tek|tek4109|ps|plot|sgi)[nu]? {\em sgi} \\
   30 ATTACHING sgi (SGI 4d) \\
   31 Untitled MGED Database (units=mm) \\
   32 mged> {\em size 20} \\
   33 mged> {\em title A Tin Woodsman} \\
   34 mged> {\em in solid8 rpp} \\
   35 Enter XMIN, XMAX, YMIN, YMAX, ZMIN, ZMAX: {\em -1 1  -1 1  -1 1} \\
   36 mged> {\em in torus tor} \\
   37 Enter X, Y, Z of vertex: {\em 0 0 0} \\
   38 Enter X, Y, Z of normal vector: {\em 0 1 0} \\
   39 Enter radius 1: {\em 1} \\
   40 Enter radius 2: {\em 0.2} \\
   41 mged> {\em in ellipsoid ellg} \\
   42 Enter X, Y, Z of vertex: {\em 0 0 0} \\
   43 Enter X, Y, Z of vector A: {\em 1 0 0} \\
   44 Enter X, Y, Z of vector B: {\em 0 0.5 0} \\
   45 Enter X, Y, Z of vector C: {\em 0 0 0.5} \\
   46 mged> {\em in cylinder rcc} \\
   47 Enter X, Y, Z of vertex: {\em 0 0 0} \\
   48 Enter X, Y, Z of height (H) vector: {\em 2 0 0} \\
   49 Enter radius: {\em 1} \\
   50 mged>
   51 }
   52 
   53 At this point, the screen should look like Figure \ref{wm-prims}.
   54 
   55 \section{Copy Primitives and Set Up for Edit}
   56 
   57 Although eight copies of the ellipsoid and two copies of the cylinder
   58 shall be used in the final solid, fewer copies are made initially since there
   59 is replication in the editing of these primitives.
   60 
   61 \noindent{\tt
   62 mged> {\em cp ellipsoid e.2} \\
   63 mged> {\em cp ellipsoid e.6} \\
   64 mged> {\em cp cylinder c.1} \\
   65 mged> {\em cp solid8 s.1} \\
   66 mged> {\em cp torus t.1} \\
   67 mged> {\em Z} \\
   68 mged> {\em e e.* c.1 t.1 s.1} \\
   69 vectorized in 0 sec \\
   70 mged>  \\
   71 }
   72 
   73 \begin{figure}
   74 \centering \includegraphics{wm-hat1.ps}
   75 \caption{Funnel Bowl Cylinder After Rotation.}
   76 \label{wm-hat1}
   77 \end{figure}
   78 
   79 \begin{figure}
   80 \centering \includegraphics{wm-hat2.ps}
   81 \caption{Funnel Bowl Cylinder After End Scaling.}
   82 \label{wm-hat2}
   83 \end{figure}
   84 
   85 \begin{figure}
   86 \centering \includegraphics{wm-hat3.ps}
   87 \caption{Funnel Bowl Cylinder After Moving.}
   88 \label{wm-hat3}
   89 \end{figure}
   90 
   91 \begin{figure}
   92 \centering \includegraphics{wm-tube.ps}
   93 \caption{Funnel Tube Scaled and Positioned.}
   94 \label{wm-tube}
   95 \end{figure}
   96 
   97 \section{Create Funnel Hat}
   98 
   99 The solid ``cylinder'' has a height vector (``H'') which is 2mm
  100 long.
  101 This will be used to good advantage, to make the Tin Woodsman's
  102 funnel hat, with the bowl of the funnel being 2mm high,
  103 and the tube of the funnel being 2mm long.
  104 The tube of the funnel will point straight up the +Y axis.
  105 
  106 \noindent{\tt
  107 mged> {\em sed c.1} \\
  108 mged> {\em Select the ``Rotate'' entry in the solid edit menu} \\
  109 mged> {\em p 0 45 90} \\
  110 mged>
  111 }
  112 
  113 This places the cylinder so that the lines BD and AC are at the outer
  114 ends of the cylinder.  See Figure \ref{wm-hat1}.
  115 
  116 Next, the cylinder is shaped to look like the top of a funnel.
  117 The vectors c and d are scaled.
  118 
  119 \noindent{\tt
  120 {\em Select the ``edit menu'' entry in the solid edit menu} \\
  121 {\em Select the ``scale c'' entry in the TGC menu} \\
  122 mged> {\em p .1} \\
  123 {\em Select the ``scale d'' entry in the TGC menu} \\
  124 mged> {\em p .1} \\
  125 mged> \\
  126 }
  127 
  128 Figure \ref{wm-hat2} is the new shape of the cone.
  129 Note how the on-screen display records the new lengths of the ``c''
  130 and ``d'' vectors.
  131 This cone must be moved to the planned locations for the top of the head.
  132 
  133 \noindent{\tt
  134 {\em Select the ``Translate'' entry in the solid edit menu} \\
  135 mged> {\em p 0 2.2 0} \\
  136 {\em Select the ``ACCEPT Edit'' entry in the button menu} \\
  137 mged> \\
  138 }
  139 
  140 The bottom of the hat is now properly shaped and positioned.  The
  141 new version of the solid ``c.1'' has been saved in the model database.
  142 The editor returns to the viewing state.  See Figure \ref{wm-hat3}.
  143 
  144 A copy of the saved ``c.1'' cone is made.  A byproduct of the {\em cp}
  145 command is to display the new solid, as if the {\em cp c.1 c.2} command
  146 had been immediately followed by an {\em e c.2} command.
  147 This new solid will be edited to make the neck of the funnel,
  148 which is the top of the hat.
  149 The ``c.2'' copy of the cone must be
  150 scaled down to become a tube and the tube must be placed on top of the
  151 cone ``c.1''.
  152 
  153 \noindent{\tt
  154 mged> {\em cp c.1 c.2} \\
  155 mged> {\em sed c.2} \\
  156 {\em Select ``scale A,B'' in the TGC menu} \\
  157 mged> {\em p 0.1} \\
  158 {\em Select ``Translate'' in the Solid Edit menu} \\
  159 mged> {\em p 0 4.2 0} \\
  160 {\em Select ``ACCEPT Edit'' in the Button menu} \\
  161 mged>
  162 }
  163 
  164 Figure \ref{wm-tube} is the new shape of the funnel tube.
  165 The woodsman's hat is comprised of solids c.1 and c.2.
  166 
  167 \begin{figure}
  168 \centering \includegraphics{wm-head.ps}
  169 \caption{Head Sphere.}
  170 \label{wm-head}
  171 \end{figure}
  172 
  173 \section{Building the Head}
  174 
  175 The head of our Tin Woodsman is perfectly spherical, and will be located
  176 at coordinates (0, 2, 0).
  177 While it would be possible to duplicate the ellipsoid solid created above,
  178 and modify it to produce the desired sphere, since all the parameters
  179 of the head sphere are known, it is more economical simply to use
  180 the {\em in} command to construct it directly.
  181 Figure \ref{wm-head} shows the results of this operation.
  182 
  183 \noindent{\tt
  184 mged> {\em in e.1} \\
  185 Enter solid type: {\em sph} \\
  186 Enter X, Y, Z of vertex: {\em 0 2 0} \\
  187 Enter radius: {\em 1} \\
  188 mged>
  189 }
  190 
  191 \begin{figure}
  192 \centering \includegraphics{wm-collar.ps}
  193 \caption{The Woodsman's Collar.}
  194 \label{wm-collar}
  195 \end{figure}
  196 
  197 \section{Building the Collar}
  198 
  199 The torus (primitive t.1) is used to build a collar between the head and
  200 the body.
  201 The ring of the collar is scaled to 0.1 of its original size,
  202 and repositioned at the base of the head.
  203 The results of this step are shown in Figure \ref{wm-collar}.
  204 
  205 \noindent{\tt
  206 mged> {\em sed t.1} \\
  207 {\em Select ``scale radius 2'' in the TORUS menu} \\
  208 mged> {\em p 0.1} \\
  209 {\em Select ``Translate'' in the Solid Edit menu} \\
  210 mged> {\em p 0 1 0} \\
  211 {\em Select ``ACCEPT Edit'' in the Button menu} \\
  212 mged>
  213 }
  214 
  215 \begin{figure}
  216 \centering \includegraphics{wm-body.ps}
  217 \caption{The Woodsman's Body.}
  218 \label{wm-body}
  219 \end{figure}
  220 
  221 \section{Building the Body}
  222 
  223 The ARB8 (primitive s.1) is used to build the body.
  224 The original height of s.1 is only 2mm;  the required
  225 length of the body is 3mm, so the extrusion command is
  226 used to adjust the position of the lower (-Y) face of the solid.
  227 The result is shown in Figure \ref{wm-body}.
  228 
  229 \noindent{\tt
  230 mged> {\em sed s.1} \\
  231 mged> {\em extrude 2367 3} \\
  232 {\em Select ``ACCEPT Edit'' in the Button menu} \\
  233 mged>
  234 }
  235 
  236 \begin{figure}
  237 \centering \includegraphics{wm-arm1.ps}
  238 \caption{An Upper Arm Prototype.}
  239 \label{wm-arm1}
  240 \end{figure}
  241 
  242 \begin{figure}
  243 \centering \includegraphics{wm-arm2.ps}
  244 \caption{The Woodsman's Arms.}
  245 \label{wm-arm2}
  246 \end{figure}
  247 
  248 \section{Building the Arms}
  249 
  250 The ellipsoid primitive (e.2) is used to build the upper and lower parts
  251 of the left and right arms.
  252 The original solid ``e.2'' is oriented with the major axis of the ellipse
  253 oriented along the X axis.
  254 The arms need to have the major axis oriented along the Y axis,
  255 so first the solid is rotated.
  256 A more graceful arm is obtained by decreasing the length of
  257 the B and C vectors, and the resulting upper arm solid can be
  258 seen in Figure \ref{wm-arm1}.
  259 
  260 \noindent{\tt
  261 mged> {\em sed e.2} \\
  262 {\em Select ``Rotate'' in the Solid Edit menu} \\
  263 mged> {\em p 0 45 90} \\
  264 {\em Select ``edit menu'' in the Solid Edit menu} \\
  265 {\em Select ``scale B'' in the ELLIPSOID menu} \\
  266 mged> {\em p 0.25} \\
  267 {\em Select ``scale C'' in the ELLIPSOID menu} \\
  268 mged> {\em p 0.25} \\
  269 mged>
  270 }
  271 
  272 This e.2 solid will now be moved into final position as the upper left arm.
  273 Then it will be duplicated three times
  274 to make the rest of the arm parts.  Finally, each new arm
  275 part will be translated into the proper position,
  276 as seen in Figure \ref{wm-arm2}.
  277 
  278 \noindent{\tt
  279 {\em Select ``Translate'' in the Solid Edit menu} \\
  280 mged> {\em p -1.3 0 0} \\
  281 {\em Select ``ACCEPT Edit'' in the Button menu -- This is the upper left arm} \\
  282 mged> {\em cp e.2 e.3} \\
  283 mged> {\em cp e.2 e.4} \\
  284 mged> {\em cp e.2 e.5} \\
  285 mged> {\em sed e.3} \\
  286 {\em Select ``Translate'' in the Solid Edit menu} \\
  287 mged> {\em p -1.3 -2 0} \\
  288 {\em Select ``ACCEPT Edit'' in the Button menu -- This is the lower left arm} \\
  289 mged> {\em sed e.4} \\
  290 {\em Select ``Translate'' in the Solid Edit menu} \\
  291 mged> {\em p 1.3 0 0} \\
  292 {\em Select ``ACCEPT Edit'' in the Button menu -- This is the upper right arm} \\
  293 mged> {\em sed e.5} \\
  294 {\em Select ``Translate'' in the Solid Edit menu} \\
  295 mged> {\em p 1.3 -2 0} \\
  296 {\em Select ``ACCEPT Edit'' in the Button menu -- This is the lower right arm} \\
  297 mged>
  298 }
  299 
  300 \begin{figure}
  301 \centering \includegraphics{wm-leg1.ps}
  302 \caption{The First Leg.}
  303 \label{wm-leg1}
  304 \end{figure}
  305 
  306 \begin{figure}
  307 \centering \includegraphics{wm-final1.ps}
  308 \caption{The Tin Woodsman.}
  309 \label{wm-final1}
  310 \end{figure}
  311 
  312 \section{Building the Legs}
  313 
  314 The ellipsoid primitive (e.6) is used as a prototype
  315 to build the upper and lower parts of both legs from.
  316 The primitive e.6 is scaled, rotated, and translated
  317 into position as the upper left leg, as seen in Figure \ref{wm-leg1}.
  318 Then, copies are made and translated to the remaining positions,
  319 just like the arms were.
  320 
  321 \noindent{\tt
  322 mged> {\em sed e.6} \\
  323 {\em Select ``Rotate'' in the Solid Edit menu} \\
  324 mged> {\em p 0 45 90} \\
  325 {\em Select ``Translate'' in the Solid Edit menu} \\
  326 mged> {\em p -0.5 -3 0} \\
  327 {\em Select ``ACCEPT Edit'' in the Button menu -- This is the upper left leg} \\
  328 mged> {\em cp e.6 e.7} \\
  329 mged> {\em cp e.6 e.8} \\
  330 mged> {\em cp e.6 e.9} \\
  331 mged> {\em sed e.7} \\
  332 {\em Select ``Translate'' in the Solid Edit menu} \\
  333 mged> {\em p -0.5 -5 0} \\
  334 {\em Select ``ACCEPT Edit'' in the Button menu -- This is the lower left leg} \\
  335 mged> {\em sed e.8} \\
  336 {\em Select ``Translate'' in the Solid Edit menu} \\
  337 mged> {\em p 0.5 -3 0} \\
  338 {\em Select ``ACCEPT Edit'' in the Button menu -- This is the upper right leg} \\
  339 mged> {\em sed e.9} \\
  340 {\em Select ``Translate'' in the Solid Edit menu} \\
  341 mged> {\em p 0.5 -5 0} \\
  342 {\em Select ``ACCEPT Edit'' in the Button menu -- This is the lower right leg} \\
  343 }
  344 
  345 Figure \ref{wm-final1} is the view on the screen, the Tin Woodsman.
  346 Take a moment to use the rotation knobs to view the model from various
  347 angles.
  348 
  349 \section{Building Regions}
  350 
  351 So far, this example has concentrated on describing the basic shapes
  352 involved in making the Tin Woodsman, without concern for establishing
  353 a proper hierarchical structure.  To illustrate this point,
  354 the various solids will be grouped by purpose and composition.
  355 First, a region will be constructed to contain the torso,
  356 and the color of ``cadet blue'' will be assigned:
  357 
  358 \noindent{\tt
  359 mged> {\em r torso.r u s.1} \\
  360 Defaulting item number to 1001 \\
  361 Creating region id=1000, air=0, los=100, GIFTmaterial=1 \\
  362 mged> {\em mater torso.r} \\
  363 Material = \\
  364 Material?  (CR to skip) {\em plastic} \\
  365 Param = \\
  366 Parameter string? (CR to skip) {\em [RETURN]} \\
  367 Color = (No color specified) \\
  368 Color R G B (0..255)? (CR to skip) {\em 95 159 159} \\
  369 Inherit = 0:  lower nodes (towards leaves) override \\
  370 Inheritance (0|1)? (CR to skip) {\em [RETURN]} \\
  371 mged>
  372 }
  373 
  374 Second, a region will be constructed to contain the collar,
  375 which will be colored red:
  376 
  377 \noindent{\tt
  378 mged> {\em r collar.r u t.1} \\
  379 Defaulting item number to 1003 \\
  380 Creating region id=1002, air=0, los=100, GIFTmaterial=1 \\
  381 mged> {\em mater collar.r} \\
  382 Material = \\
  383 Material?  (CR to skip) {\em plastic} \\
  384 Param = \\
  385 Parameter string? (CR to skip)  {\em [RETURN]} \\
  386 Color = (No color specified) \\
  387 Color R G B (0..255)? (CR to skip) {\em 255 127 0} \\
  388 Inherit = 0:  lower nodes (towards leaves) override \\
  389 Inheritance (0|1)? (CR to skip)  {\em [RETURN]} \\
  390 mged>
  391 }
  392 
  393 Third, a region will be constructed to contain all the limbs,
  394 and a flesh color will be assigned.
  395 Even though none of the limbs touch each other, note how they
  396 are combined with the UNION operation, to create a single
  397 object of uniform composition and color.
  398 
  399 \noindent{\tt
  400 mged> {\em r limbs.r u e.2 u e.3 u e.4 u e.5 u e.6 u e.7 u e.8 u e.9} \\
  401 Defaulting item number to 1001 \\
  402 Creating region id=1000, air=0, los=100, GIFTmaterial=1 \\
  403 mged> {\em mater limbs.r} \\
  404 Material = \\
  405 Material?  (CR to skip) {\em plastic} \\
  406 Param = \\
  407 Parameter string? (CR to skip)  {\em [RETURN]} \\
  408 Color = 0 0 0 \\
  409 Color R G B (0..255)? (CR to skip) {\em 255 200 160} \\
  410 Inherit = 0:  lower nodes (towards leaves) override \\
  411 Inheritance (0|1)? (CR to skip)  {\em [RETURN]} \\
  412 mged>
  413 }
  414 
  415 Next, the funnel needs to be placed in a region.
  416 For the sake of simplicity, the funnel will be solid, rather
  417 than having a hollow center.
  418 Note that the interior of the funnel overlaps with the top
  419 of the Woodsman's head.
  420 The funnel can be made ``form fitting'' by subtracting out
  421 the overlap zone:
  422 
  423 \noindent{\tt
  424 mged> {\em r funnel.r u c.1 - e.1 u c.2 - e.1} \\
  425 Defaulting item number to 1004 \\
  426 Creating region id=1003, air=0, los=100, GIFTmaterial=1 \\
  427 mged> {\em mater funnel.r} \\
  428 Material = \\
  429 Material?  (CR to skip) {\em plastic} \\
  430 Param = \\
  431 Parameter string? (CR to skip) {\em sh=100} \\
  432 Color = (No color specified) \\
  433 Color R G B (0..255)? (CR to skip) {\em 35 107 142} \\
  434 Inherit = 0:  lower nodes (towards leaves) override \\
  435 Inheritance (0|1)? (CR to skip)
  436 mged> {\em l funnel.r} \\
  437 funnel.r (len 4) REGION id=1003  (air=0, los=100, GIFTmater=1) -- \\
  438 Material 'plastic' 'sh=100' \\
  439 Color 35 107 142 \\
  440 \ \ u c.1 \\
  441 \ \ - e.1 \\
  442 \ \ u c.2 \\
  443 \ \ - e.1 \\
  444 mged>
  445 }
  446 
  447 \begin{figure}
  448 \centering \includegraphics{wm-hat-E.ps}
  449 \caption{Evaluation of Funnel Hat Region.}
  450 \label{wm-hat-E}
  451 \end{figure}
  452 
  453 Note how the boolean expression was written.
  454 The concept that we need to express here is
  455 the combination of all the funnel parts, minus the
  456 portion of the head that overlaps with the inside of the funnel.
  457 The natural way to write this is
  458 \begin{center}
  459 (c.1 union c.2) - e.1
  460 \end{center}
  461 but note that there are no grouping operations permitted in the {\em r}
  462 command.
  463 Furthermore, for historic reasons, union operations bind more loosely than
  464 intersection and subtraction, i.e., there are implied groups
  465 between union operations.  Thus, the expression above needs to be
  466 rewritten as the formula:
  467 \begin{center}
  468 (c.1 - e.1) union (c.2 - e.1)
  469 \end{center}
  470 which with the binding precedence can be expressed as:
  471 \begin{center}
  472 c.1 - e.1 union c.2 - e.1
  473 \end{center}
  474 which is what was entered in the sequence above.
  475 To see the effect that this command had on the shape of ``funnel.r'',
  476 run these commands, the effect of which is shown in Figure \ref{wm-hat-E}:
  477 
  478 \noindent{\tt
  479 mged> {\em Z } \\
  480 mged> {\em E funnel.r } \\
  481 vectorized in 1 sec \\
  482 mged>
  483 }
  484 
  485 These regions should be grouped together into a group,
  486 for convenience in referencing.  This can be done with these commands:
  487 
  488 \noindent{\tt
  489 mged> {\em g man.g collar.r funnel.r limbs.r torso.r} \\
  490 mged> {\em Z} \\
  491 mged> {\em e man.g} \\
  492 vectorized in 1 sec \\
  493 mged>
  494 }
  495 
  496 The grouping {\em g} command combined the regions, the Zap command {\em Z}
  497 cleared the screen, and the edit {\em e man.g} command drew the whole
  498 object.
  499 As an exercise, run
  500 the database structure printing command {\em tree man.g}
  501 to obtain a simple depiction of the tree structure that has been created.
  502 For the final step of this example, the model will be ray-traced.
  503 Run the command:
  504 
  505 \noindent{\tt
  506 mged> {\em rt -s128} \\
  507 rt -s50 -M -s128 woodsman.g man.g  \\
  508 db title:  A Tin Woodsman \\
  509 Buffering single scanlines \\
  510 initial dynamic memory use=35152.\\
  511 Interpreting command stream in old format\\
  512 GETTREE: 0.01 CPU secs in 1 elapsed secs (1\%)\\
  513                                               \\
  514 ...................Frame     0...................\\
  515 PREP: 0.01 CPU secs in 0.01 elapsed secs (100\%)\\
  516 shooting at 13 solids in 4 regions              \\
  517 model X(-2,2), Y(-6,7), Z(-2,2)\\
  518 Beam radius=0.078125 mm, divergence=0 mm/1mm\\
  519                                              \\
  520 SHOT: 3.73 CPU secs in 6 elapsed secs (62.1667\%)\\
  521 Additional dynamic memory used=29728. bytes\\
  522 3515 solid/ray intersections: 1005 hits + 2510 miss\\
  523 pruned 28.6\%:  13647 model RPP, 8197 dups, 10740 RPP\\
  524 Frame     0:    16384 pixels in       3.73 sec =    4392.49 pixels/sec\\
  525 Frame     0:    16384 rays   in       3.73 sec =    4392.49 rays/sec (RTFM)\\
  526 \\
  527 Press RETURN to reattach\\
  528 {\em [RETURN]} \\
  529 mged>
  530 }