de.grogra.ray2.radiosity
Class SubPatch

java.lang.Object
  extended by de.grogra.ray2.radiosity.SubPatch
All Implemented Interfaces:
Mesh

public class SubPatch
extends java.lang.Object
implements Mesh

This class describes a patch containing a triangle.

Author:
Ralf Kopsch

Constructor Summary
SubPatch(SubPatch in)
          Copy Constructor
SubPatch(Vector3d a, Vector3d b, Vector3d c)
          Constructor, creates a new SubPatch.
 
Method Summary
 void clearFFMap()
          Clears the form factor map.
 MyMeshVolume createMesh()
          Converts this patch into a mesh.
 boolean ffMapContains(java.util.List<SubPatch> deprecatedPatches)
          Checks whether, the list of deprecated patches contains this patch.
 Vector3d getCenter()
          Return the center of this patch.
 java.util.Map<SubPatch,FormFactor> getFFMap()
          Returns the form factor map.
 int getMaxEdgeCount()
          Returns the maximum number of edges of a single polygon of the mesh.
 float getMaxRadDifference(SubPatch other)
          Returns the maximum difference of radiosity color.
 Vector3d getNormal()
          Returns the normal vector of this patch.
 void getNormal(int index, Tuple3d out)
          Gets the normal vector of normal index.
 int getNormalCount()
          Returns the number of normals of the mesh.
 int getPolygon(int index, int[] indicesOut, int[] normalsOut)
          Writes the vertex indices of polygon index to indicesOut and the normal indices to normalsOut and returns the number of vertices of the polygon.
 int getPolygonCount()
          Returns the number of polygons of the mesh.
 Color3f getRadiosity()
          Returns the radiosity color.
 void getUV(int index, Tuple2d out)
          Gets the uv coordinates of vertex index.
 void getVertex(int index, Tuple3d out)
          Gets the spatial vertex coordinates of vertex index.
 int getVertexCount()
          Returns the number of vertices of the mesh.
 Vector3d[] getVertices()
          Returns an array of vertices.
 boolean isClosed()
          Indicates whether this mesh is a closed surface or not.
 boolean isPolygonPlanar(int index)
          Returns true iff the polygon number index is planar.
 boolean isTriangle()
          Returns true.
 void move(Vector3d deltaVert)
          Moves the patch along the given vector.
 void rotateX(double thetaX)
          Rotates the patch around the x-axis.
 void rotateY(double thetaY)
          Rotates the patch around the y-axis.
 void rotateZ(double thetaZ)
          Rotates the patch around the z-axis.
 void set(Vector3d a, Vector3d b, Vector3d c)
          Sets the vertices for this patch.
 void setRadiosity(Color3f col)
          Sets the radiosity color.
 void setRadiosity(float x, float y, float z)
          Sets the radiosity color.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SubPatch

public SubPatch(SubPatch in)
Copy Constructor

Parameters:
in - the SubPatch to copy.

SubPatch

public SubPatch(Vector3d a,
                Vector3d b,
                Vector3d c)
Constructor, creates a new SubPatch.

Parameters:
a - vertice 1
b - vertice 2
c - vertice 3
Method Detail

clearFFMap

public void clearFFMap()
Clears the form factor map.


createMesh

public MyMeshVolume createMesh()
Converts this patch into a mesh.

Returns:
Converts this patch into a mesh.

ffMapContains

public boolean ffMapContains(java.util.List<SubPatch> deprecatedPatches)
Checks whether, the list of deprecated patches contains this patch.

Parameters:
deprecatedPatches - the list of deprecated patches.
Returns:

getCenter

public Vector3d getCenter()
Return the center of this patch.

Returns:
Return the center of this patch.

getFFMap

public java.util.Map<SubPatch,FormFactor> getFFMap()
Returns the form factor map.

Returns:
Returns the form factor map.

getMaxEdgeCount

public int getMaxEdgeCount()
Description copied from interface: Mesh
Returns the maximum number of edges of a single polygon of the mesh.

Specified by:
getMaxEdgeCount in interface Mesh
Returns:
maximum number of edges

getMaxRadDifference

public float getMaxRadDifference(SubPatch other)
Returns the maximum difference of radiosity color.

Parameters:
other - another patch.
Returns:
Returns the maximum difference of radiosity color.

getNormal

public Vector3d getNormal()
Returns the normal vector of this patch.

Returns:
Returns the normal vector of this patch.

getNormal

public void getNormal(int index,
                      Tuple3d out)
Description copied from interface: Mesh
Gets the normal vector of normal index. The normal vector is not necessarily normalized.

Specified by:
getNormal in interface Mesh
Parameters:
index - normal number
out - normal vector will be placed in here

getNormalCount

public int getNormalCount()
Description copied from interface: Mesh
Returns the number of normals of the mesh.

Specified by:
getNormalCount in interface Mesh
Returns:
number of normals

getPolygon

public int getPolygon(int index,
                      int[] indicesOut,
                      int[] normalsOut)
Description copied from interface: Mesh
Writes the vertex indices of polygon index to indicesOut and the normal indices to normalsOut and returns the number of vertices of the polygon. If the mesh is closed (see Mesh.isClosed()), inside and outside are determined by the ordering of the vertices: when seen from the outside, vertices have to be oriented in a counter-clockwise manner. Then also the normal vectors have to point to the outside.

Specified by:
getPolygon in interface Mesh
Parameters:
index - polygon number
indicesOut - the vertex indices will be placed in here
normalsOut - the normal indices will be placed in here
Returns:
number of vertex indices of polygon

getPolygonCount

public int getPolygonCount()
Description copied from interface: Mesh
Returns the number of polygons of the mesh.

Specified by:
getPolygonCount in interface Mesh
Returns:
number of polygons

getRadiosity

public Color3f getRadiosity()
Returns the radiosity color.

Returns:
Returns the radiosity color.

getUV

public void getUV(int index,
                  Tuple2d out)
Description copied from interface: Mesh
Gets the uv coordinates of vertex index.

Specified by:
getUV in interface Mesh
Parameters:
index - vertex number
out - uv coordinates will be placed in here

getVertex

public void getVertex(int index,
                      Tuple3d out)
Description copied from interface: Mesh
Gets the spatial vertex coordinates of vertex index.

Specified by:
getVertex in interface Mesh
Parameters:
index - vertex number
out - vertex coordinates will be placed in here

getVertexCount

public int getVertexCount()
Description copied from interface: Mesh
Returns the number of vertices of the mesh.

Specified by:
getVertexCount in interface Mesh
Returns:
number of vertices

getVertices

public Vector3d[] getVertices()
Returns an array of vertices.

Returns:
Returns an array of vertices.

isClosed

public boolean isClosed()
Description copied from interface: Mesh
Indicates whether this mesh is a closed surface or not. If it is closed, normal vectors have to point to the exterior.

Specified by:
isClosed in interface Mesh
Returns:
is surface closed?

isPolygonPlanar

public boolean isPolygonPlanar(int index)
Description copied from interface: Mesh
Returns true iff the polygon number index is planar.

Specified by:
isPolygonPlanar in interface Mesh
Parameters:
index - polygon number
Returns:
is polygon planar?

isTriangle

public boolean isTriangle()
Returns true.

Returns:

move

public void move(Vector3d deltaVert)
Moves the patch along the given vector.

Parameters:
deltaVert - the move vector.

rotateX

public void rotateX(double thetaX)
Rotates the patch around the x-axis.

Parameters:
thetaX - the rotation angle.

rotateY

public void rotateY(double thetaY)
Rotates the patch around the y-axis.

Parameters:
thetaY - the rotation angle.

rotateZ

public void rotateZ(double thetaZ)
Rotates the patch around the z-axis.

Parameters:
thetaZ - the rotation angle.

set

public void set(Vector3d a,
                Vector3d b,
                Vector3d c)
Sets the vertices for this patch.

Parameters:
a - vertice 1
b - vertice 2
c - vertice 3

setRadiosity

public void setRadiosity(Color3f col)
Sets the radiosity color.

Parameters:
col - the radiosity color to set.

setRadiosity

public void setRadiosity(float x,
                         float y,
                         float z)
Sets the radiosity color.

Parameters:
x - the x-value.
y - the y-value.
z - the z-value.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object