cz.cuni.jagrlib.piece
Class FaceRenderFlat

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultProperty
      extended by cz.cuni.jagrlib.Piece
          extended by cz.cuni.jagrlib.piece.FaceRenderFlat
All Implemented Interfaces:
Breakable, FaceRender, Property, Template

public class FaceRenderFlat
extends Piece
implements FaceRender

Brep face rendering - flat shading.

Since:
0.25
See Also:
FaceRenderFlat.java

Nested Class Summary
protected static class FaceRenderFlat.EdgeComparator
          Edge comparator for actual edge list: [ x ].
protected static class FaceRenderFlat.PolyEdge
          Polygon edge.
 
Field Summary
protected  java.util.TreeSet<FaceRenderFlat.PolyEdge> actual
          Tmp: actual edge list sorted by [ x ].
protected  int attrColor
          Actual face-color attribute.
protected  int attrCoords
          Actual projected-coordinate attribute.
protected  java.util.TreeSet<FaceRenderFlat.PolyEdge> backup
          Tmp: edge list for the next line.
protected static java.lang.String CATEGORY
          Object category.
protected  double[] color
          Tmp: face color (double format).
protected  float[] colorF
          Tmp: face color (float format).
protected  java.lang.String colorName
          Name of face-color attribute.
protected  java.lang.String coordsName
          Name of projected-coordinate attribute.
protected  int counter
          Fill-counter for fill-outside mode.
protected  Brep data
          Accelerator: input B-rep database.
protected static double[] DEFAULT_COLOR
          Color used if no face-color attribute is defined.
protected static FaceRenderFlat.EdgeComparator eComparator
          Single comparator instance.
protected  java.util.TreeSet<FaceRenderFlat.PolyEdge> input
          Tmp: input edge set sorted by [ y0 ].
protected  int lastCtx
          Last used context (for attribute caches).
protected  int lastFace
          Last used face id (for repetitive calls of fillHLine(int, int, int, int, int)).
protected  BitMaskCore mask
          Accelerator: bitmask object (can be null).
protected  RasterGraphics output
          Accelerator: raster graphics output object.
static RegPiece reg
          Static registration instance for this class.
protected static java.lang.String TEMPLATE_NAME
          Object template identifier.
protected  double[][] vc
          Tmp: vertex coordinates for one edge.
protected  int[] vert
          Tmp: vertex handles for one face.
 
Fields inherited from class cz.cuni.jagrlib.Piece
channels, info, pl, plugs, TEMPLATE_TYPE, userBreak
 
Fields inherited from interface cz.cuni.jagrlib.iface.FaceRender
FACE_COLOR, FACE_NORMAL, FACE_SOLID, FACE_TEXTURE, PROJECTED_COORDS, VERTEX_COLOR, VERTEX_NORMAL, VERTEX_TEXTURE
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Fields inherited from interface cz.cuni.jagrlib.Template
ALL_PLUGS, C_1D, C_2D, C_3D, C_ALPHA, C_BINARY, C_BREP, C_CAMERA, C_CIRCLE, C_CLIP, C_COMPRESSION, C_CURVE, C_DATA, C_DRAW, C_EDITOR, C_ELLIPSE, C_FILL, C_FILTER, C_FLOAT, C_FUNCTION, C_IMAGE, C_INTEGER, C_IO, C_LIGHT, C_LINE, C_METRIC, C_POLYGON, C_PROJECTION, C_RADIOSITY, C_RASTER, C_RENDER, C_SAMPLE, C_SCENE, C_SET, C_SOLID, C_TEXT, C_TRANSFORM, C_VECTOR, C_VIEWER, C_WORKER, CAT_EMPTY, EMPTY, IFACE, JAGRLIB, JAGRLIB2, MANIPULATOR_COMBO, MANIPULATOR_CUSTOM, MANIPULATOR_DEFAULT, MANIPULATOR_MULTILINE, PL_ALPHAMASK, PL_BITMASK, PL_CAUSTIC, PL_CODEC, PL_COLORMAP, PL_COMPARE, PL_DATA, PL_DIRECT, PL_EDITOR, PL_FILTER, PL_FUNCTION, PL_IMAGE, PL_IMPORT, PL_INPUT, PL_INTERSECTION, PL_LIGHTSOURCE, PL_ORDER, PL_OUTPUT, PL_PALETTE, PL_PHOTON, PL_PROPERTY, PL_QUANTIZER, PL_RASTER, PL_RENDER, PL_SHADOW, PL_STREAM, PL_TRANSFORM, PL_TRIGGER, PL_VOLUME, PL_WINDOW, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_STRING
 
Constructor Summary
FaceRenderFlat()
           
 
Method Summary
protected  boolean accelerators(int ctx, int face, boolean maskNeeded)
          Prepare acelerators, returns true if failed.
protected  int commonFill(int ctx, int face, boolean inside)
          Fills the given face, common routine for both inside- and outside- fill modes.
 void fillHLine(int ctx, int face, int x1, int x2, int y)
          Fills the horizontal line from the given polygonal face.
 void fillInside(int ctx, int face)
          Fills the given polygonal face.
 int fillOutside(int ctx, int face)
          Fills the given polygonal face.
 java.lang.Object get(java.lang.String key)
          Gets the given property.
protected  void hLineInside(int y, FaceRenderFlat.PolyEdge e1, FaceRenderFlat.PolyEdge e2)
          Render horizontal segment (H-line) from [ e1.x, y ] to [ e2.x, y ].
protected  void hLineOutside(int y, FaceRenderFlat.PolyEdge e1, FaceRenderFlat.PolyEdge e2)
          Render horizontal segment (H-line) from [ e1.x, y ] to [ e2.x, y ].
 void set(java.lang.String key, java.lang.Object value)
          Sets the given property.
static int setTemplate(Template t, int ord)
          General-purpose registration routine.
 
Methods inherited from class cz.cuni.jagrlib.Piece
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, init, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplateDynamic, stop
 
Methods inherited from class cz.cuni.jagrlib.DefaultProperty
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, stringProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.jagrlib.iface.Property
commit
 

Field Detail

lastCtx

protected int lastCtx
Last used context (for attribute caches).


colorName

protected java.lang.String colorName
Name of face-color attribute.


attrColor

protected int attrColor
Actual face-color attribute.


coordsName

protected java.lang.String coordsName
Name of projected-coordinate attribute.


attrCoords

protected int attrCoords
Actual projected-coordinate attribute.


data

protected Brep data
Accelerator: input B-rep database.


output

protected RasterGraphics output
Accelerator: raster graphics output object.


mask

protected BitMaskCore mask
Accelerator: bitmask object (can be null).


counter

protected int counter
Fill-counter for fill-outside mode.


lastFace

protected int lastFace
Last used face id (for repetitive calls of fillHLine(int, int, int, int, int)).


DEFAULT_COLOR

protected static final double[] DEFAULT_COLOR
Color used if no face-color attribute is defined.


vert

protected int[] vert
Tmp: vertex handles for one face.


vc

protected double[][] vc
Tmp: vertex coordinates for one edge.


colorF

protected float[] colorF
Tmp: face color (float format).


color

protected double[] color
Tmp: face color (double format).


input

protected java.util.TreeSet<FaceRenderFlat.PolyEdge> input
Tmp: input edge set sorted by [ y0 ].


actual

protected java.util.TreeSet<FaceRenderFlat.PolyEdge> actual
Tmp: actual edge list sorted by [ x ].


backup

protected java.util.TreeSet<FaceRenderFlat.PolyEdge> backup
Tmp: edge list for the next line.


eComparator

protected static final FaceRenderFlat.EdgeComparator eComparator
Single comparator instance.


TEMPLATE_NAME

protected static final java.lang.String TEMPLATE_NAME
Object template identifier.

See Also:
Constant Field Values

CATEGORY

protected static final java.lang.String CATEGORY
Object category.

See Also:
Constant Field Values

reg

public static final RegPiece reg
Static registration instance for this class. Automatically initialized in class-loading time.

Constructor Detail

FaceRenderFlat

public FaceRenderFlat()
Method Detail

accelerators

protected boolean accelerators(int ctx,
                               int face,
                               boolean maskNeeded)
Prepare acelerators, returns true if failed.


hLineInside

protected void hLineInside(int y,
                           FaceRenderFlat.PolyEdge e1,
                           FaceRenderFlat.PolyEdge e2)
Render horizontal segment (H-line) from [ e1.x, y ] to [ e2.x, y ]. For inside-fill mode.


hLineOutside

protected void hLineOutside(int y,
                            FaceRenderFlat.PolyEdge e1,
                            FaceRenderFlat.PolyEdge e2)
Render horizontal segment (H-line) from [ e1.x, y ] to [ e2.x, y ]. For outside-fill mode.


commonFill

protected int commonFill(int ctx,
                         int face,
                         boolean inside)
Fills the given face, common routine for both inside- and outside- fill modes. Must be called after successfull accelerators(int, int, boolean) call!

Returns:
Number of drawn pixels (valid in outside-fill mode only).

fillInside

public void fillInside(int ctx,
                       int face)
Fills the given polygonal face. Uses only pixels which are set in the associated BitMaskCore (fills the whole face if no BitMaskCore is used).

Specified by:
fillInside in interface FaceRender
Parameters:
ctx - Handle to a context to draw from.
face - Handle of the face (in the associated Brep scene).
See Also:
BitMaskCore, Brep

fillHLine

public void fillHLine(int ctx,
                      int face,
                      int x1,
                      int x2,
                      int y)
Fills the horizontal line from the given polygonal face.

Specified by:
fillHLine in interface FaceRender
Parameters:
ctx - Handle to a context to draw from.
face - Handle of the face (in the associated Brep scene).
x1 - X coordinate of the starting pixel.
x2 - X coordinate of the first pixel after the line.
y - Common Y coordinate of the line.
See Also:
Brep

fillOutside

public int fillOutside(int ctx,
                       int face)
Fills the given polygonal face. Uses only pixels which are not set in the associated BitMaskCore. Sets the drawn pixels afterwards.

Specified by:
fillOutside in interface FaceRender
Parameters:
ctx - Handle to a context to draw from.
face - Handle of the face (in the associated Brep scene).
Returns:
Number of pixels filled.
See Also:
BitMaskCore, Brep

set

public void set(java.lang.String key,
                java.lang.Object value)
Sets the given property.

Specified by:
set in interface Property
Overrides:
set in class DefaultProperty
Parameters:
key - Key string.
value - The new value.
See Also:
Property.commit()

get

public java.lang.Object get(java.lang.String key)
Gets the given property.

Specified by:
get in interface Property
Overrides:
get in class DefaultProperty
Parameters:
key - Key string.
Returns:
The actual value or null.

setTemplate

public static int setTemplate(Template t,
                              int ord)
General-purpose registration routine. Sets all plugs, strings, etc. to the given Template.