Scalar Algorithms: Color Mapping Color mapping is a common scalar visualization technique that maps scalar data to colors. The scalar mapping is implemented by indexing into a color lookup table (discrete).
V i = 0 V > max => i = n-1 i = (n-1) * (V - min) / (max – min) max lower bound (mlb) i = (truncate) (n-1) * (V - min) / (max – min) least upper bound (lub) i = (ceiling) (n-1) * (V - min) / (max – min)
Scalar Algorithms: Color Mapping To define a color table we need to provide the number of colors and the color for each entry. To use a color table we need to provide the range of the scalar values. One color table can be used by multiple scalars.
Scalar Algorithms: Color Mapping A color table is discrete. A transfer function is continuous. A transfer function can be any monotonic expression that maps scalar value into a color specification (continuous). R = Fr(V); G = Fg(V); B = Fb(V);
Contouring: Edge Tracking (2D) Tracks a contour as it moves across cell boundaries. 1.For each unprocessed cell, check if the contour passes through one of its edges by checking if the contour value is between the nodal data values. 2.If not, mark the cell processed and go to the next unprocessed cell. 3.If an edge intersection detected, follow the contour to the exit edge and track the contour to the next cell until the contour closes itself or exit from a boundary edge. Mark each cell processed as the contour passes it. 4.Start the next unprocessed cell till all cells are processed.
Contouring: Marching Squares (2D) Processing each cell independently, using state code to determine how to draw the contour line. 1.Loop through every cell. For each cell, 2.Encoding the state of each vertex as binary code (state code): inside (data value > contour value) or outside (data value < contour value).
Contouring: Marching Squares (2D) 3.Create an index based on the bitwise combined state codes of the vertexes. (Similar to the outcode in Cohen-Sutherland clipping) 4.Using the index to look up the topological state of the cell in a case table. (how) 5.Calculate the contour location (geometry) for each edge in the case table. (where)
Contouring: Marching Squares (2D) 16 cases (4 bit indexing) 6 unique topological cases (one unique case for n vertex inside, n = 0, 1, 2, 3, 4. One additional case for 2 inside vertexes: diagonal (vs. same side). From programming point of view, there are only 4 unique cases: no draw (n=0 or 4); cut one corner (n=1 or 3); cut one side (two connected corners); and cut two opposite corners.
Contouring Ambiguity Need to see how its neighbors are drawn to decide which way to draw. Or to use gradient information to decide which way to draw.
Color Map Programming: Creating a Color Table vtkLookupTable *lut = vtkLookupTable:New(); lut->SetHueRange(0.667, 0); //value range [0, 2* П] lut->SetSaturationRange(1,1); lut->SetValueRange(1,1); lut->SetAlphaRange(1,1); // transparency lut->SetNumberOfColor(256); lut->Build();
Color Map Programming: Creating a Color Table Linear interpolation to build the table c: h, s, v, a; Modify the color of an entry (i) in the LUT lut->SetTableValue(i, h, s, v, a);
Color Map Programming: Using a Color Table mapper SetLookupTable(lut) There is a default red—blue color table. Mapper maps scalars to colors according to lut (Linear interpolation b/w entries) For the default lut, it uses data range set by mapper SetScalarRange(d 0, d 1 ) To turn the scalar-color mapping off: Mapper ScalarVisibilityOff();
Color Map Programming: Using a Color Table To force VTK to use a single object color: Actor GetProperty() SetColor(R,G,B) SubClassing from vtkLookUp Table VtkLogLookUpTable uses log scale instead linear interpolation.
Contour (Isosurface) Programming //Create a contour filter object vtkContourFilter *c= vtkContourFilter::New(); c SetInput(s GetOutput()); //Create contours c GenerateValues(4,0,3) //first: number of contours //second: starting value //third: ending value
Contour Programming //Create a mapper to hold the geometry of the contours vtkPolyDataMapper *m= vtkPolyDataMapper::New(); m SetInput(c GetOutput); m SetScalarRange(0,3); // for color mapping //Create an actor to hold the geometry vtkActor *a= vtkActor::New(); a SetMapper(m);
Vector Algorithms Vector data is a three-dimensional representation of direction and magnitude. 3 values: (v x, v y, v z ) => direction and length
Vector Algorithms: Directed Lines Draw a directed line based on the vector value at each data point. A scaling factor is needed to map the data vector field to the display vector field so that the displayed vectors will not be too small or too large.
Vector Algorithms: Vector Algorithms: Hedgehogs Similar to Directed Lines, but no direction arrow on the lines.
Vector Algorithms: Vector Algorithms: Oriented Glyphs Similar to Directed Lines, but use graphical objects to represent vector values.
Vector Algorithms: Vector Algorithms: Warping Deformation of geometry according to a vector field. Where DX is the deformation, V is the vector field and α is the scaling factor.
Vector Algorithms: Vector Algorithms: Displacement Plots Shows the motion of an object in the direction perpendicular to its surface. Vectors are converted to scalars by computing the dot product between the surface normal (N) and vector (V) at each point. Where D is the displacement, V is the vector field, N is the normal field and α is the scaling factor.
Vector Algorithms: Vector Algorithms: Time Animation Time dependent geometry change according to a vector field. Where dX is the geometry change, V is the vector field, α is the scaling factor and dt the time elapsed from previous step. Most vector algorithms need to use a scaling factor to map the data vector field to the display so that the displayed results will not be too small or too large.
Particle Traces: trajectories traced by fluid particles over time. Each trajectory follows a particle. Streaklines: the set of particle traces at a particular time that have previously passed through a specific point. Streamlines: a snap shot of how particles will move at different locations at a given time. The tangent of the streamline curve at any given location represents the vector value at the location. where s is the path on a streamline, V is the vector field.
Vector Algorithms: Vector Algorithms: Streamlines When the vector field is time independent, all three methods can generate the same result.
Tensor Algorithms Convert a tensor into three vectors (X) A X = X det |A- I| = 0 Using three eigenvalues and three eigenvectors: 1 2 3 X 1 X 2 X 3 Tensor ellipsoid: an ellipsoid drawn using the three eigenvectors as the major, medium, minor axis.
Modeling Algorithms For creating or changing dataset geometry or topology.
Modeling Algorithms Source Objects: used to define geometry, read data from data file, create data. Implicit Functions: F(x, y, z) = C: Generate geometry. Region separation, F>4, F=4, F<4.
Modeling Algorithms Modeling Objects F(x,y,z) = x*x + y*y + z*z => Creates a data set with field value F(x i,y j,z k ); F(x,y,z) = 1.0; => Creates an Isosurface (a sphere object). Logical operations on two fields: F and G F G = min(F, G) F G = max(F,G) F - G = max(F-G)
Modeling Algorithms Implicit Modeling Scalars are generated using a distance function to a given object. Cutting: Cutting through a data set with a surface and then display the interpolated data values on the surface. Geometric intersections Interpolate data values onto the surface. Map the data into color or contours.
Modeling Algorithms Cutting: Cutting through a data set with a surface and then display the interpolated data values on the surface.