java.lang.Object
de.grogra.rgg.Scanner
- All Implemented Interfaces:
VolumeListener
,Options
Instances of
Scanner
enables to scan a structure using rays.
This code is largely inspired from AvoidIntersection
.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
beginGroup
(Object object, boolean asNode) This method is invoked by aSceneVisitor
when subsequent volumes shall be grouped into a single compound object.void
endGroup()
This method is invoked by aSceneVisitor
when the current group ends.return options for scene construction and/or concrete light modelLong[]
Return a HashSet of unique object IDs that got hit by a ray, i.e. had an intersection with.Return an ArrayListcontaining the scannedPoints. int
returns the number of scanned points (ie length of scannedPoints)void
This method prepare the whole scene, may for a new intersection-computation.void
This method triggers the scanning process.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.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]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)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]scanHemisphere
(Point3d center, double radius, double phiStep, double thetaStep, Vector3d xParam, Vector3d yParam, Vector3d zParam) Moves the origin of the scanner on a hemisphere, with a step "phiStep" along the colatitude and a step thetaStep along the longitude.scanPoint
(Point3d center, double radius, double phi, double theta, Vector3d xParam, Vector3d yParam, Vector3d zParam) Moves the origin of the scanner to a single point, with an angle "phi" along the colatitude and an angle theta along the longitude.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)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
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 accordinglyvoid
setDistanceNoise
(boolean param) sets distanceNoise on / offvoid
setDistanceNoiseType
(int type, boolean adapt, double param1, double param2) sets the parameters for the distance noisevoid
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 / offvoid
setPhiNoiseType
(int type, boolean adapt, double param1, double param2) sets the parameters for the phi noisevoid
This method sets theprepareScene
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 / offvoid
setThetaNoiseType
(int type, boolean adapt, double param1, double param2) sets the parameters for the theta noisevoid
showSpheres
(boolean value) void
volumeCreated
(Object object, boolean asNode, Volume volume) This method is invoked by aSceneVisitor
when avolume
is created as representation of the geometry ofobject
.void
writeDataToFile
(ArrayList<Point3d> data, String fileName) Writes an ArrayListto a file according to a 'x y z' format
-
Field Details
-
NO_HIT
public static final int NO_HIT- See Also:
-
HIT
public static final int HIT- See Also:
-
-
Constructor Details
-
Method Details
-
setLayerVisible
public void setLayerVisible(int id, boolean visible) Set layer #id
to visible (true) or invisible (false).- Parameters:
id
- Layer idvisible
- Layer visible or not.
-
setPrepareScene
public void setPrepareScene()This method sets theprepareScene
flag. When the methodprepareScene()
is invoked, an octree will re-computed. -
setpDrawRay
public void setpDrawRay(double pParam) Sets the probability of drawing one ray.- Parameters:
pParam
-
-
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 thetaphiRange
- angular opening in phi
-
setSteps
public void setSteps(double thetaStepParam, double phiStepParam) Set the steps for scanning the solid angle.- Parameters:
thetaStepParam
- step for the theta parameterphiStepParam
- step for the phi parameter
-
setRayLength
public void setRayLength(double rayLengthParam) Set the length of the rays that will be shot.- Parameters:
rayLengthParam
-
-
writeDataToFile
Writes an ArrayListto a file according to a 'x y z' format - Parameters:
data
-fileName
-- Throws:
IOException
-
scanPoint
public ArrayList<Point3d> scanPoint(Point3d center, double radius, double phi, double theta, Vector3d xParam, Vector3d yParam, Vector3d zParam) Moves the origin of the scanner to a single point, with an angle "phi" along the colatitude and an angle theta along the longitude. Rays are shot for the point on the hemisphere, 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:
-
scanHemisphere
public ArrayList<Point3d> scanHemisphere(Point3d center, double radius, double phiStep, double thetaStep, Vector3d xParam, Vector3d yParam, Vector3d zParam) Moves the origin of the scanner on a hemisphere, with a step "phiStep" along the colatitude and a step thetaStep along the longitude. Rays are shot for each point on the hemisphere, 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:
-
scanSphere
public 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:
-
scanSegment
public 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:
-
scanCircle
public 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 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 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:
-
scanCylinder
public 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:
-
setBasis
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
-
-
getScannedPointsNb
public int getScannedPointsNb()returns the number of scanned points (ie length of scannedPoints) -
getScannedPoints
Return an ArrayListcontaining the scannedPoints. -
getScannedObjectIDs
Return a HashSet of unique object IDs that got hit by a ray, i.e. had an intersection with. -
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 methodlook(Null node, double size, double distance)
invoke this automatically. -
scan
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 pointshowLines
- To visualize what is going on in front ofnode
, set this parameter true.
-
showSpheres
public void showSpheres(boolean value) -
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 noiseadapt
- false for a fixed noise, true for a noise dependent on the valueparam1
-param2
-
-
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 noiseadapt
- false for a fixed noise, true for a noise dependent on the valueparam1
-param2
-
-
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 noiseadapt
- false for a fixed noise, true for a noise dependent on the valueparam1
-param2
-
-
get
return options for scene construction and/or concrete light model -
volumeCreated
Description copied from interface:VolumeListener
This method is invoked by aSceneVisitor
when avolume
is created as representation of the geometry ofobject
. 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 interfaceVolumeListener
- Parameters:
object
- an object of the graphasNode
- isobject
a node or an edge?volume
- the volume which has been created as geometrical representation ofobject
-
beginGroup
Description copied from interface:VolumeListener
This method is invoked by aSceneVisitor
when subsequent volumes shall be grouped into a single compound object. The group extends until the corresponding invocation ofVolumeListener.endGroup()
. These invocations may be nested, i.e., there may be groups within groups.Each group starts at
object
in the graph. Ifobject
has a geometric representation itself, the corresponding invocation ofVolumeListener.volumeCreated(java.lang.Object, boolean, de.grogra.vecmath.geom.Volume)
may be either immediately before of afterbeginGroup
.- Specified by:
beginGroup
in interfaceVolumeListener
- Parameters:
object
- the object of the graph which represents the root of the groupasNode
- isobject
a node or an edge?- See Also:
-
endGroup
public void endGroup()Description copied from interface:VolumeListener
This method is invoked by aSceneVisitor
when the current group ends.- Specified by:
endGroup
in interfaceVolumeListener
- See Also:
-