Module rgg
Package de.grogra.rgg

Class Scanner

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

public class Scanner extends Object implements Options, VolumeListener
Instances of Scanner enables to scan a structure using rays. This code is largely inspired from AvoidIntersection.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    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

    Modifier and Type
    Method
    Description
    void
    beginGroup(Object object, boolean asNode)
    This method is invoked by a SceneVisitor when subsequent volumes shall be grouped into a single compound object.
    void
    This method is invoked by a SceneVisitor when the current group ends.
    get(String key, Object defaultValue)
    return options for scene construction and/or concrete light model
    Return a HashSet of unique object IDs that got hit by a ray, i.e. had an intersection with.
    Return an ArrayList containing 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
    scan(Point3d originPoint)
    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
    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
    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
    showSpheres(boolean value)
     
    void
    volumeCreated(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
    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 Details

  • Constructor Details

    • 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 Details

    • 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.
    • setPrepareScene

      public void setPrepareScene()
      This method sets the prepareScene flag. When the method prepareScene() 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 theta
      phiRange - 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 parameter
      phiStepParam - step for the phi parameter
    • setRayLength

      public void setRayLength(double rayLengthParam)
      Set the length of the rays that will be shot.
      Parameters:
      rayLengthParam -
    • writeDataToFile

      public void writeDataToFile(ArrayList<Point3d> data, String fileName) throws IOException
      Writes an ArrayList to 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

      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 -
    • getScannedPointsNb

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

      public ArrayList<Point3d> getScannedPoints()
      Return an ArrayList containing the scannedPoints.
    • getScannedObjectIDs

      public Long[] 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 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.
    • 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 noise
      adapt - false for a fixed noise, true for a noise dependent on the value
      param1 -
      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 noise
      adapt - false for a fixed noise, true for a noise dependent on the value
      param1 -
      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 noise
      adapt - false for a fixed noise, true for a noise dependent on the value
      param1 -
      param2 -
    • get

      public Object get(String key, 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
    • volumeCreated

      public void volumeCreated(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
    • beginGroup

      public void beginGroup(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:
    • 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: