Difference between revisions of "User:Tohline/vtk/SimpleCubeTutorial/CubeDetails"

From VistrailsWiki
Jump to navigation Jump to search
(→‎Cube Definition Details: Begin describing in detail how to interpret each line of text/data in the input data file)
Line 45: Line 45:
</table>
</table>
</div>
</div>
This is how to interpret the lines of data, presented above, that are intended to define a simple cube.  Start with the appreciation that a cube has 8 corners (vertices or "POINTS") and six faces.  Each face of the cube is a four-sided polygon which, itself, can be defined by properly "connecting" subsets of the 8 POINTS. 
* When any of the "readers" within the visualization toolkit (VTK) library sees a line of text that reads "DATASET POLYDATA," it expects that the subsequent sequence of lines of text/data will define all of the POINTS and POLYGONS that are needed to graphically build the desired object &#8212; in this case, a cube.
* The line of text that reads "POINTS 8 float" means that the subsequent 8 lines will, in sequence, provide the <math>~(x,y,z)</math> coordinates of the 8 corners of the cube; for each POINT the coordinate values will be provided as a triplet set of floating point numbers.  As VTK reads in each triplet set of coordinates, it will (internally) assign a number to the POINT, starting with the number zero and incrementing by one so that, for example, the eighth point will be referenced as POINT "7".
The following 30 (= 6 x 5) integers will define 6 polygons; 5 integers are needed for each polygon.
The following 30 (= 6 x 5) integers will define 6 polygons; 5 integers are needed for each polygon.

Revision as of 23:09, 17 March 2014

Cube Definition Details

Whitworth's (1981) Isothermal Free-Energy Surface
|   Tiled Menu   |   Tables of Content   |  Banner Video   |  Tohline Home Page   |

A model of virtually any three-dimensional structure can be fed into VisTrails — and understood by the accompanying visualization toolkit (vtk) library of routines — using VTK's Simple Legacy Format. Here we explain how the set of vertices (POINTS) and POLYGONS of a simple cube can be defined using this Simple Legacy Format; this explanation is primarily intended to provide supplemental details for our accompanying Simple Cube Tutorial.


Defining the POINTS (vertices) & POLYGONS of a cube in Simple Legacy Format

Cube Details

# vtk DataFile Version 2.0 
Cube example 
ASCII 
DATASET POLYDATA 
POINTS 8 float 
0.0 0.0 0.0   <== (x,y,z) coordinates of POINT "0"
1.0 0.0 0.0   <== ... of POINT "1"
1.0 1.0 0.0   <== ... of POINT "2" 
0.0 1.0 0.0   <== ... of POINT "3" 
0.0 0.0 1.0   <== ... of POINT "4" 
1.0 0.0 1.0   <== ... of POINT "5"
1.0 1.0 1.0   <== ... of POINT "6"
0.0 1.0 1.0   <== ... of POINT "7"
POLYGONS 6 30  <== (see explanation in the accompanying text)
4 0 1 2 3   <== POLYGON "0": A four-sided polygon formed by connecting POINTS 0, 1, 2, & 3, in that order.
4 4 5 6 7   <== POLYGON "1": A four-sided polygon formed by connecting POINTS 4, 5, 6, & 7, in that order.
4 0 1 5 4   <== POLYGON "2": A four-sided polygon ... POINTS 0, 1, 5, & 4, in that order.
4 2 3 7 6   <== POLYGON "3": A four-sided polygon ... POINTS 2, 3, 7, & 6, in that order.
4 0 4 7 3   <== POLYGON "4": A four-sided polygon ... POINTS 0, 4, 7, & 3, in that order.
4 1 2 6 5   <== POLYGON "5": A four-sided polygon ... POINTS 1, 2, 6, & 5, in that order.

This is how to interpret the lines of data, presented above, that are intended to define a simple cube. Start with the appreciation that a cube has 8 corners (vertices or "POINTS") and six faces. Each face of the cube is a four-sided polygon which, itself, can be defined by properly "connecting" subsets of the 8 POINTS.

  • When any of the "readers" within the visualization toolkit (VTK) library sees a line of text that reads "DATASET POLYDATA," it expects that the subsequent sequence of lines of text/data will define all of the POINTS and POLYGONS that are needed to graphically build the desired object — in this case, a cube.
  • The line of text that reads "POINTS 8 float" means that the subsequent 8 lines will, in sequence, provide the <math>~(x,y,z)</math> coordinates of the 8 corners of the cube; for each POINT the coordinate values will be provided as a triplet set of floating point numbers. As VTK reads in each triplet set of coordinates, it will (internally) assign a number to the POINT, starting with the number zero and incrementing by one so that, for example, the eighth point will be referenced as POINT "7".

The following 30 (= 6 x 5) integers will define 6 polygons; 5 integers are needed for each polygon.