org::scilab::modules::renderer::polylineDrawing::PolylineInterpColorDrawerGL Class Reference

Inheritance diagram for org::scilab::modules::renderer::polylineDrawing::PolylineInterpColorDrawerGL:

Inheritance graph
[legend]
Collaboration diagram for org::scilab::modules::renderer::polylineDrawing::PolylineInterpColorDrawerGL:

Collaboration graph
[legend]

Public Member Functions

 PolylineInterpColorDrawerGL ()
void drawPolyline (double[] xCoords, double[] yCoords, double[] zCoords, int[] colors)
boolean isZConstant ()

Private Member Functions

boolean checkIfZconstant (double[] zCoords)

Private Attributes

boolean isZconstant

Static Private Attributes

static final int TRIANGLE_NB_EDGE = 3

Detailed Description

Class containing the driver dependant routines to fill the area enclosed by the polyline with interpolated colors. Note that this class might be more generic by using a glu tesselator like in fill drawing.
Author:
Jean-Baptiste Silvy

Definition at line 33 of file PolylineInterpColorDrawerGL.java.


Constructor & Destructor Documentation

org::scilab::modules::renderer::polylineDrawing::PolylineInterpColorDrawerGL::PolylineInterpColorDrawerGL (  )  [inline]

Default constructor

Definition at line 42 of file PolylineInterpColorDrawerGL.java.

References isZconstant.

00042                                              {
00043                 super();
00044                 isZconstant = false;
00045         }


Member Function Documentation

void org::scilab::modules::renderer::polylineDrawing::PolylineInterpColorDrawerGL::drawPolyline ( double[]  xCoords,
double[]  yCoords,
double[]  zCoords,
int[]  colors 
) [inline]

Create the display list for the polyline

Parameters:
xCoords X coordinates of the polylines vertices
yCoords Y coordinates of the polylines vertices
zCoords Z coordinates of the polylines vertices
colors colors index for each vertex

Definition at line 54 of file PolylineInterpColorDrawerGL.java.

References checkIfZconstant(), org::scilab::modules::renderer::utils::ColorMap::convertScilabToColorMapIndex(), org::scilab::modules::renderer::utils::CoordinateTransformation::endPushPolygonsBack(), org::scilab::modules::renderer::ObjectGL::getColorMap(), org::scilab::modules::renderer::figureDrawing::DrawableFigureGL::getCoordinateTransformation(), org::scilab::modules::renderer::ObjectGL::getGL(), org::scilab::modules::renderer::ObjectGL::getParentFigureGL(), org::scilab::modules::renderer::figureDrawing::DrawableFigureGL::getShadeFacetDrawer(), org::scilab::modules::renderer::utils::TexturedColorMap::getTexture(), i, org::scilab::modules::renderer::polylineDrawing::ShadeFacetDrawer::paintPolygon(), org::scilab::modules::renderer::utils::CoordinateTransformation::pushPolygonsBack(), and TRIANGLE_NB_EDGE.

00055                                                                                          {
00056                 
00057                 // check if Z is constant
00058                 this.isZconstant = checkIfZconstant(zCoords);
00059                 
00060                 GL gl = getGL();
00061                 
00062                 Vector3D[] vertices = new Vector3D[xCoords.length];
00063                 for (int i = 0; i < xCoords.length; i++) {
00064                         vertices[i] = new Vector3D(xCoords[i], yCoords[i], zCoords[i]);
00065                         // colors are Scilab indices
00066                         colors[i] = getColorMap().convertScilabToColorMapIndex(colors[i]);
00067                 }
00068                 
00069                 ShadeFacetDrawer sfd = getParentFigureGL().getShadeFacetDrawer();
00070                 
00071                 // push polygons back if needed
00072                 CoordinateTransformation transform = getParentFigureGL().getCoordinateTransformation();
00073                 transform.pushPolygonsBack(gl, this);
00074                 
00075                 Texture colorMapTexture = getColorMap().getTexture();
00076                 colorMapTexture.enable();
00077                 colorMapTexture.bind();
00078                 
00079                 gl.glBegin(GL.GL_TRIANGLES);
00080                 
00081                 if (vertices.length == TRIANGLE_NB_EDGE) {
00082                         // only a triangle
00083                         sfd.paintPolygon(vertices, colors, gl, getColorMap());  
00084                         
00085                 } else {
00086                         
00087                         // its a quad, decompose it into 2 triangles
00088                         Vector3D[] triangle1 =  new Vector3D[TRIANGLE_NB_EDGE];
00089                         Vector3D[] triangle2 =  new Vector3D[TRIANGLE_NB_EDGE];
00090                         int[] colorT1 = new int[TRIANGLE_NB_EDGE];
00091                         int[] colorT2 = new int[TRIANGLE_NB_EDGE];
00092                         GeomAlgos.decomposeQuad(vertices, colors, triangle1, colorT1, triangle2, colorT2);
00093                         
00094                         // draw the two decomposed triangles
00095                         sfd.paintPolygon(triangle1, colorT1, gl, getColorMap());        
00096                         sfd.paintPolygon(triangle2, colorT2, gl, getColorMap());
00097                 }
00098                 gl.glEnd();
00099                 
00100                 colorMapTexture.disable();
00101                 
00102                 transform.endPushPolygonsBack(gl, this);
00103         }

Here is the call graph for this function:

boolean org::scilab::modules::renderer::polylineDrawing::PolylineInterpColorDrawerGL::checkIfZconstant ( double[]  zCoords  )  [inline, private]

Check if the z coordinate of the polyline is constant

Parameters:
zCoords z coordinates of the polyline vertices
Returns:
true if z is constant, false otherwise

Definition at line 110 of file PolylineInterpColorDrawerGL.java.

References i.

Referenced by drawPolyline().

00110                                                            {
00111                 for (int i = 0; i < zCoords.length; i++) {
00112                         if (zCoords[0] != zCoords[i]) {
00113                                 return false;
00114                         }
00115                 }
00116                 return true;
00117         }

Here is the caller graph for this function:

boolean org::scilab::modules::renderer::polylineDrawing::PolylineInterpColorDrawerGL::isZConstant (  )  [inline]

This method is used to know if polygon offset is needed in 2d mode. If this function returns true, then the polygon offset is not needed in 2d mode. If it returns false, polygon offset is always needed.

Returns:
true if the object is flat along Z coordinate

Reimplemented from org::scilab::modules::renderer::drawers::FillDrawerGL.

Definition at line 125 of file PolylineInterpColorDrawerGL.java.

References isZconstant.

00125                                      {
00126                 return isZconstant;
00127         }


Field Documentation

Definition at line 35 of file PolylineInterpColorDrawerGL.java.

Referenced by drawPolyline().

Definition at line 37 of file PolylineInterpColorDrawerGL.java.

Referenced by isZConstant(), and PolylineInterpColorDrawerGL().


The documentation for this class was generated from the following file:

Generated on Tue Sep 9 18:28:21 2008 for Scilab [trunk] by  doxygen 1.5.5