de.grogra.rgg
Class Scanner

java.lang.Object
  extended by de.grogra.rgg.Scanner
All Implemented Interfaces:
VolumeListener, Options

public class Scanner
extends java.lang.Object
implements Options, VolumeListener

Instances of Scanner enables to scan a structure using rays. This code is largely inspired from AvoidIntersection.


Field Summary
static int HIT
           
static int NO_HIT
           
 
Constructor Summary
Scanner()
          Create an instance of Scanner
Scanner(Vector3d x, Vector3d y, Vector3d z, double thetaRangeParam, double phiRangeParam, double thetaStepParam, double phiStepParam, double rayLenghtParam)
          Create an instance of Scanner
 
Method Summary
 void beginGroup(java.lang.Object object, boolean asNode)
          This method is invoked by a SceneVisitor when subsequent volumes shall be grouped into a single compound object.
 void endGroup()
          This method is invoked by a SceneVisitor when the current group ends.
 java.lang.Object get(java.lang.String key, java.lang.Object defaultValue)
          return options for scene construction and/or concrete light model
 java.util.ArrayList<Point3d> getScannedPoints()
          Return an ArrayList containing the scannedPoints.
 int getScannedPointsNb()
          returns the number of scanned points (ie length of scannedPoints)
 void prepareScene()
          This method prepare the whole scene, may for a new intersection-computation.
 void scan(Point3d originPoint)
          This method triggers the scanning process.
 java.util.ArrayList<Point3d> scanCircle(Point3d center, double radius, Vector3d normal, double angleStep)
          Does the same as scanCircle(Point3d, double, Vector3d, Vector3d, double) but the origin of the angle (zeroAngleVector) is arbitrary chosen.
 java.util.ArrayList<Point3d> scanCircle(Point3d center, double radius, Vector3d normalParam, Vector3d zeroAngleVectorParam, double angleStep)
          Moves the origin of the scanner along the circle of center center, radius radius, and contained in a plane orthogonal to the vector normal ; zeroAngleVector specifies must be orthogonal to normal, and specifies an origin for the angles ; for each angular step angleStep, rays are shot according to the angular parameters specified (see setRange / setSteps) and the local basis (-uR,-uTheta,normal) [see cylindrical coordinate system]
 java.util.ArrayList<Point3d> scanCylinder(Point3d startingPoint, Vector3d axisParam, double radius, double angularStep, double lengthAxisStep, int nbSteps)
          Works as scanCylinder (Point3d, Vector3d, double, double, double, int, Vector3d) but an origin for the angles is arbitrary chosen)
 java.util.ArrayList<Point3d> scanCylinder(Point3d startingPoint, Vector3d axisParam, double radius, double angularStep, double lengthAxisStep, int nbSteps, Vector3d zeroAngleVectorParam)
          Moves the origin of the scanner on the cylinder which axis starts at startingPoint, has axisParam as direction, and of length (nbSteps-1)* lengthAxisStep, and of radius radius ; for each step along the axis, the origin of the scanner revolves around the axis with an angular step angularStep ; zeroAngleVector specifies must be orthogonal to axisParam, and specifies an origin for the angles ; rays are shot at each step according to the angular parameters specified (see setRange / setSteps) and the local basis (-uR,-uTheta,normal) [see cylindrical coordinate system]
 java.util.ArrayList<Point3d> scanSegment(Point3d startingPoint, Vector3d directionParam, float stepLength, int nbSteps)
          Move the origin of the scanner along the segment starting at startingPoint, of direction directionParam and of length (nbSteps-1) * stepLength ; rays are shot according to the angular parameters specified (see setRange / setSteps) and the basis set (see setBasis)
 java.util.ArrayList<Point3d> scanSphere(Point3d center, double radius, double phiStep, double thetaStep, Vector3d xParam, Vector3d yParam, Vector3d zParam)
          Moves the origin of the scanner on a sphere, with a step "phiStep" along the colatitude and a step thetaStep along the longitude.
 void setBasis(Vector3d xParam, Vector3d yParam, Vector3d zParam)
          set the (x,y,z) basis which will serve as reference for the spherical coordinates system ; (x,y,z) must form an orthogonal basis ; the vectors are then normalized to form an orthonormal basis also compute the P matrix, and change the basisCorrect value accordingly
 void setDistanceNoise(boolean param)
          sets distanceNoise on / off
 void setDistanceNoiseType(int type, boolean adapt, double param1, double param2)
          sets the parameters for the distance noise
 void setLayerVisible(int id, boolean visible)
          Set layer # id to visible (true) or invisible (false).
 void setpDrawRay(double pParam)
          Sets the probability of drawing one ray.
 void setPhiNoise(boolean param)
          set phiNoise on / off
 void setPhiNoiseType(int type, boolean adapt, double param1, double param2)
          sets the parameters for the phi noise
 void setPrepareScene()
          This method sets the prepareScene flag.
 void setRange(double thetaRangeParam, double phiRangeParam)
          Set the angular parameters of the solid angle that will be scanned.
 void setRayLength(double rayLengthParam)
          Set the length of the rays that will be shot.
 void setSteps(double thetaStepParam, double phiStepParam)
          Set the steps for scanning the solid angle.
 void setThetaNoise(boolean param)
          sets thetaNoise on / off
 void setThetaNoiseType(int type, boolean adapt, double param1, double param2)
          sets the parameters for the theta noise
 void volumeCreated(java.lang.Object object, boolean asNode, Volume volume)
          This method is invoked by a SceneVisitor when a volume is created as representation of the geometry of object.
 void writeDataToFile(java.util.ArrayList<Point3d> data, java.lang.String fileName)
          Writes an ArrayList to a file according to a 'x y z' format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HIT

public static final int HIT
See Also:
Constant Field Values

NO_HIT

public static final int NO_HIT
See Also:
Constant Field Values
Constructor Detail

Scanner

public Scanner()
Create an instance of Scanner


Scanner

public Scanner(Vector3d x,
               Vector3d y,
               Vector3d z,
               double thetaRangeParam,
               double phiRangeParam,
               double thetaStepParam,
               double phiStepParam,
               double rayLenghtParam)
Create an instance of Scanner

Parameters:
RayCount - Number of rays.
Method Detail

beginGroup

public void beginGroup(java.lang.Object object,
                       boolean asNode)
Description copied from interface: VolumeListener
This method is invoked by a SceneVisitor when subsequent volumes shall be grouped into a single compound object. The group extends until the corresponding invocation of VolumeListener.endGroup(). These invocations may be nested, i.e., there may be groups within groups.

Each group starts at object in the graph. If object has a geometric representation itself, the corresponding invocation of VolumeListener.volumeCreated(java.lang.Object, boolean, de.grogra.vecmath.geom.Volume) may be either immediately before of after beginGroup.

Specified by:
beginGroup in interface VolumeListener
Parameters:
object - the object of the graph which represents the root of the group
asNode - is object a node or an edge?
See Also:
VolumeListener.endGroup()

endGroup

public void endGroup()
Description copied from interface: VolumeListener
This method is invoked by a SceneVisitor when the current group ends.

Specified by:
endGroup in interface VolumeListener
See Also:
VolumeListener.beginGroup(java.lang.Object, boolean)

get

public java.lang.Object get(java.lang.String key,
                            java.lang.Object defaultValue)
return options for scene construction and/or concrete light model

Specified by:
get in interface Options
Parameters:
key - identifier for option
defaultValue - default value of option
Returns:
value of option named key

getScannedPoints

public java.util.ArrayList<Point3d> getScannedPoints()
Return an ArrayList containing the scannedPoints.


getScannedPointsNb

public int getScannedPointsNb()
returns the number of scanned points (ie length of scannedPoints)


prepareScene

public void prepareScene()
This method prepare the whole scene, may for a new intersection-computation. This is necessary, when something in the scene has changed. The method look(Null node, double size, double distance) invoke this automatically.


scan

public void scan(Point3d originPoint)
This method triggers the scanning process. NB : each time this method is called, the list of scan point is re-initialized. Make sure to save your data !

Parameters:
originPoint - Scan from this point
showLines - To visualize what is going on in front of node, set this parameter true.

scanCircle

public java.util.ArrayList<Point3d> scanCircle(Point3d center,
                                               double radius,
                                               Vector3d normal,
                                               double angleStep)
Does the same as scanCircle(Point3d, double, Vector3d, Vector3d, double) but the origin of the angle (zeroAngleVector) is arbitrary chosen.

Parameters:
center -
radius -
normal -
angleStep -
Returns:

scanCircle

public java.util.ArrayList<Point3d> scanCircle(Point3d center,
                                               double radius,
                                               Vector3d normalParam,
                                               Vector3d zeroAngleVectorParam,
                                               double angleStep)
Moves the origin of the scanner along the circle of center center, radius radius, and contained in a plane orthogonal to the vector normal ; zeroAngleVector specifies must be orthogonal to normal, and specifies an origin for the angles ; for each angular step angleStep, rays are shot according to the angular parameters specified (see setRange / setSteps) and the local basis (-uR,-uTheta,normal) [see cylindrical coordinate system]

Parameters:
center -
radius -
normalParam -
zeroAngleVectorParam -
angleStep -
Returns:

scanCylinder

public java.util.ArrayList<Point3d> scanCylinder(Point3d startingPoint,
                                                 Vector3d axisParam,
                                                 double radius,
                                                 double angularStep,
                                                 double lengthAxisStep,
                                                 int nbSteps)
Works as scanCylinder (Point3d, Vector3d, double, double, double, int, Vector3d) but an origin for the angles is arbitrary chosen)

Parameters:
startingPoint -
axisParam -
radius -
angularStep -
lengthAxisStep -
nbSteps -
Returns:

scanCylinder

public java.util.ArrayList<Point3d> scanCylinder(Point3d startingPoint,
                                                 Vector3d axisParam,
                                                 double radius,
                                                 double angularStep,
                                                 double lengthAxisStep,
                                                 int nbSteps,
                                                 Vector3d zeroAngleVectorParam)
Moves the origin of the scanner on the cylinder which axis starts at startingPoint, has axisParam as direction, and of length (nbSteps-1)* lengthAxisStep, and of radius radius ; for each step along the axis, the origin of the scanner revolves around the axis with an angular step angularStep ; zeroAngleVector specifies must be orthogonal to axisParam, and specifies an origin for the angles ; rays are shot at each step according to the angular parameters specified (see setRange / setSteps) and the local basis (-uR,-uTheta,normal) [see cylindrical coordinate system]

Parameters:
startingPoint -
axisParam -
radius -
angularStep -
lengthAxisStep -
nbSteps -
zeroAngleVectorParam -
Returns:

scanSegment

public java.util.ArrayList<Point3d> scanSegment(Point3d startingPoint,
                                                Vector3d directionParam,
                                                float stepLength,
                                                int nbSteps)
Move the origin of the scanner along the segment starting at startingPoint, of direction directionParam and of length (nbSteps-1) * stepLength ; rays are shot according to the angular parameters specified (see setRange / setSteps) and the basis set (see setBasis)

Parameters:
startingPoint -
directionParam -
stepLength -
nbSteps -
Returns:

scanSphere

public java.util.ArrayList<Point3d> scanSphere(Point3d center,
                                               double radius,
                                               double phiStep,
                                               double thetaStep,
                                               Vector3d xParam,
                                               Vector3d yParam,
                                               Vector3d zParam)
Moves the origin of the scanner on a sphere, with a step "phiStep" along the colatitude and a step thetaStep along the longitude. Rays are shot for each point on the sphere, according to the angular parameters set (see setRange and setSteps) and the local coordinate system (-uR,-uPhi,uTheta) [see spherical coordinate system]

Parameters:
center -
radius -
phiStep -
thetaStep -
xParam -
yParam -
zParam -
Returns:

setBasis

public void setBasis(Vector3d xParam,
                     Vector3d yParam,
                     Vector3d zParam)
set the (x,y,z) basis which will serve as reference for the spherical coordinates system ; (x,y,z) must form an orthogonal basis ; the vectors are then normalized to form an orthonormal basis also compute the P matrix, and change the basisCorrect value accordingly

Parameters:
x -
y -
z -

setDistanceNoise

public void setDistanceNoise(boolean param)
sets distanceNoise on / off

Parameters:
param -

setDistanceNoiseType

public void setDistanceNoiseType(int type,
                                 boolean adapt,
                                 double param1,
                                 double param2)
sets the parameters for the distance noise

Parameters:
type - 0 for uniform noise, 1 for gaussian noise
adapt - false for a fixed noise, true for a noise dependent on the value
param1 -
param2 -

setLayerVisible

public void setLayerVisible(int id,
                            boolean visible)
Set layer # id to visible (true) or invisible (false).

Parameters:
id - Layer id
visible - Layer visible or not.

setpDrawRay

public void setpDrawRay(double pParam)
Sets the probability of drawing one ray.

Parameters:
pParam -

setPhiNoise

public void setPhiNoise(boolean param)
set phiNoise on / off

Parameters:
param -

setPhiNoiseType

public void setPhiNoiseType(int type,
                            boolean adapt,
                            double param1,
                            double param2)
sets the parameters for the phi noise

Parameters:
type - 0 for uniform noise, 1 for gaussian noise
adapt - false for a fixed noise, true for a noise dependent on the value
param1 -
param2 -

setPrepareScene

public void setPrepareScene()
This method sets the prepareScene flag. When the method prepareScene() is invoked, an octree will re-computed.


setRange

public void setRange(double thetaRangeParam,
                     double phiRangeParam)
Set the angular parameters of the solid angle that will be scanned. NB : if thetaRangeParam > 2*PI then thetaRangeParam = 2*PI will be used instead if phiRangeParam > PI then phiRangeParam = PI will be used instead

Parameters:
thetaRange - angular opening in theta
phiRange - angular opening in phi

setRayLength

public void setRayLength(double rayLengthParam)
Set the length of the rays that will be shot.

Parameters:
rayLengthParam -

setSteps

public void setSteps(double thetaStepParam,
                     double phiStepParam)
Set the steps for scanning the solid angle.

Parameters:
thetaStepParam - step for the theta parameter
phiStepParam - step for the phi parameter

setThetaNoise

public void setThetaNoise(boolean param)
sets thetaNoise on / off

Parameters:
param -

setThetaNoiseType

public void setThetaNoiseType(int type,
                              boolean adapt,
                              double param1,
                              double param2)
sets the parameters for the theta noise

Parameters:
type - 0 for uniform noise, 1 for gaussian noise
adapt - false for a fixed noise, true for a noise dependent on the value
param1 -
param2 -

volumeCreated

public void volumeCreated(java.lang.Object object,
                          boolean asNode,
                          Volume volume)
Description copied from interface: VolumeListener
This method is invoked by a SceneVisitor when a volume is created as representation of the geometry of object. By storing the information provided by the parameters, the link from graph objects (nodes and edges) to volumes can be established.

Specified by:
volumeCreated in interface VolumeListener
Parameters:
object - an object of the graph
asNode - is object a node or an edge?
volume - the volume which has been created as geometrical representation of object

writeDataToFile

public void writeDataToFile(java.util.ArrayList<Point3d> data,
                            java.lang.String fileName)
                     throws java.io.IOException
Writes an ArrayList to a file according to a 'x y z' format

Parameters:
data -
fileName -
Throws:
java.io.IOException