cz.cuni.jagrlib
Class DefaultGeometrySearch

java.lang.Object
  extended by cz.cuni.jagrlib.DefaultProperty
      extended by cz.cuni.jagrlib.Piece
          extended by cz.cuni.jagrlib.DefaultGeometrySearch
All Implemented Interfaces:
Breakable, GeometrySearch, Property, Template
Direct Known Subclasses:
UniformGrid

public abstract class DefaultGeometrySearch
extends Piece
implements GeometrySearch

Default implementation of GeometrySearch interface.

Since:
0.24
See Also:
DefaultGeometrySearch.java

Field Summary
 
Fields inherited from class cz.cuni.jagrlib.Piece
channels, info, pl, plugs, reg, TEMPLATE_TYPE, userBreak
 
Fields inherited from interface cz.cuni.jagrlib.iface.Property
LOGGING, STATISTICS, TEXT_DESCRIPTION
 
Fields inherited from interface cz.cuni.jagrlib.Template
ALL_PLUGS, C_1D, C_2D, C_3D, C_ALPHA, C_BINARY, C_BREP, C_CAMERA, C_CIRCLE, C_CLIP, C_COMPRESSION, C_CURVE, C_DATA, C_DRAW, C_EDITOR, C_ELLIPSE, C_FILL, C_FILTER, C_FLOAT, C_FUNCTION, C_IMAGE, C_INTEGER, C_IO, C_LIGHT, C_LINE, C_METRIC, C_POLYGON, C_PROJECTION, C_RADIOSITY, C_RASTER, C_RENDER, C_SAMPLE, C_SCENE, C_SET, C_SOLID, C_TEXT, C_TRANSFORM, C_VECTOR, C_VIEWER, C_WORKER, CAT_EMPTY, EMPTY, IFACE, JAGRLIB, JAGRLIB2, MANIPULATOR_COMBO, MANIPULATOR_CUSTOM, MANIPULATOR_DEFAULT, MANIPULATOR_MULTILINE, PL_ALPHAMASK, PL_BITMASK, PL_CAUSTIC, PL_CODEC, PL_COLORMAP, PL_COMPARE, PL_DATA, PL_DIRECT, PL_EDITOR, PL_FILTER, PL_FUNCTION, PL_IMAGE, PL_IMPORT, PL_INPUT, PL_INTERSECTION, PL_LIGHTSOURCE, PL_ORDER, PL_OUTPUT, PL_PALETTE, PL_PHOTON, PL_PROPERTY, PL_QUANTIZER, PL_RASTER, PL_RENDER, PL_SHADOW, PL_STREAM, PL_TRANSFORM, PL_TRIGGER, PL_VOLUME, PL_WINDOW, TYPE_BOOLEAN, TYPE_DOUBLE, TYPE_FLOAT, TYPE_INTEGER, TYPE_LONG, TYPE_OBJECT, TYPE_STRING
 
Constructor Summary
DefaultGeometrySearch()
           
 
Method Summary
 boolean buildDirectory(int entity, int ctx)
          Builds the whole data structure (directory) from scratch.
 BrepIterator centerPass(double[] center, double radius, BrepIterator pre)
          Initializes a new center pass.
 double finishedSegment(BrepIterator iter)
          Returns end value (coordinate) of already finished pass-segment.
 double getProgress(BrepIterator iter, int[] count)
          Returns progress parameters of the given pass.
 int getStatistics(long[] counters)
          Returns (and resets) counters (for statistics, profiling).
 void insertObject(int handle)
          Inserts another object into the directory.
 BrepIterator intervalQuery(double[] min, double[] max, BrepIterator pre)
          Initializes a new interval query for floating-point coordinates.
 BrepIterator intervalQuery(int[] min, int[] max, BrepIterator pre)
          Initializes a new interval query for integer coordinates.
 int localize(double[] coord)
          Localizes the given point - finds the object which contains it (first of such objects).
 int localize(int[] coord)
          Localizes the given point - finds the object which contains it (first of such objects).
 boolean optimizeDirectory()
          Optimizes the data structure (directory).
 BrepIterator rayPass(double[] start, double[] direction, BrepIterator pre)
          Initializes a new ray-casting pass.
 boolean removeObject(int handle)
          Removes the given object from the directory.
 boolean resetDirectory(int entity, int ctx)
          (Re-)initializes the data structure (directory).
 BrepIterator sweepPass(double[] plane, double[] origin, BrepIterator pre)
          Initializes a new sweep-plane pass.
 
Methods inherited from class cz.cuni.jagrlib.Piece
className, connect, findPlug, findPlug, getInfo, getInterface, getInterface, getPlug, getReg, init, isCompatible, isCompatible, isConnected, logError, logWarning, myInterface, newInputPlug, newOptOutputPlug, newOutputPlug, newPlug, noTemplates, propBegin, propBounds, propDefault, propEnd, propEnum, propManipulator, propManipulator, setProgressListener, setRegStrings, setTemplate, setTemplateDynamic, stop
 
Methods inherited from class cz.cuni.jagrlib.DefaultProperty
booleanProperty, booleanProperty, colorDoubleProperty, colorProperty, commit, doubleProperty, doubleProperty, doubleProperty, enumProperty, floatProperty, floatProperty, floatProperty, get, intProperty, intProperty, intProperty, longProperty, longProperty, longProperty, set, set, stringProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.jagrlib.iface.Property
commit, get, set
 

Constructor Detail

DefaultGeometrySearch

public DefaultGeometrySearch()
Method Detail

buildDirectory

public boolean buildDirectory(int entity,
                              int ctx)
Builds the whole data structure (directory) from scratch.

Specified by:
buildDirectory in interface GeometrySearch
Parameters:
entity - Type of stored entities (VERTEX, EDGE or FACE from Brep).
ctx - Handle to the used Brep-context.
Returns:
true if this service is implemented.
See Also:
resetDirectory(int, int), optimizeDirectory(), Brep.VERTEX, Brep.EDGE, Brep.SOLID

resetDirectory

public boolean resetDirectory(int entity,
                              int ctx)
(Re-)initializes the data structure (directory).

Specified by:
resetDirectory in interface GeometrySearch
Parameters:
entity - Type of stored entities (VERTEX, EDGE or FACE from Brep).
ctx - Handle to the used Brep-context.
Returns:
true if this service is implemented.
See Also:
buildDirectory(int, int), optimizeDirectory(), Brep.VERTEX, Brep.EDGE, Brep.SOLID

insertObject

public void insertObject(int handle)
Inserts another object into the directory. Should be called after resetDirectory(int, int).

Specified by:
insertObject in interface GeometrySearch
Parameters:
handle - Handle to an inserted object (its entity type and context were defined in advance).
See Also:
resetDirectory(int, int)

removeObject

public boolean removeObject(int handle)
Removes the given object from the directory.

Specified by:
removeObject in interface GeometrySearch
Parameters:
handle - Handle to a removed object (its entity type and context were defined in advance).
Returns:
true if this service is implemented and if the object was successfully removed.
See Also:
resetDirectory(int, int)

optimizeDirectory

public boolean optimizeDirectory()
Optimizes the data structure (directory). Can be used for finishing of the update phase or for explicit data structure optimization. Non-mandatory. (but application has to call it at the end of update phase).

Specified by:
optimizeDirectory in interface GeometrySearch
Returns:
true if this service is implemented.
See Also:
buildDirectory(int, int), resetDirectory(int, int)

localize

public int localize(int[] coord)
Localizes the given point - finds the object which contains it (first of such objects).

Specified by:
localize in interface GeometrySearch
Parameters:
coord - Coordinate vector of the localized point.
Returns:
Handle to the result object or NULL if not found (or the service is not implemented).
See Also:
localize(double[])

localize

public int localize(double[] coord)
Localizes the given point - finds the object which contains it (first of such objects).

Specified by:
localize in interface GeometrySearch
Parameters:
coord - Coordinate vector of the localized point.
Returns:
Handle to the result object or NULL if not found (or the service is not implemented).
See Also:
localize(int[])

intervalQuery

public BrepIterator intervalQuery(int[] min,
                                  int[] max,
                                  BrepIterator pre)
Initializes a new interval query for integer coordinates.

Specified by:
intervalQuery in interface GeometrySearch
Parameters:
min - Coordinate vector of minimum-vertex.
max - Coordinate vector of maximum-vertex. Non-mandatory ?
pre - Pre-allocated BrepIterator object (can be null).
Returns:
The initialized iterator data.
See Also:
intervalQuery(double[],double[],BrepIterator), getProgress(cz.cuni.jagrlib.iface.BrepIterator, int[])

intervalQuery

public BrepIterator intervalQuery(double[] min,
                                  double[] max,
                                  BrepIterator pre)
Initializes a new interval query for floating-point coordinates.

Specified by:
intervalQuery in interface GeometrySearch
Parameters:
min - Coordinate vector of minimum-vertex.
max - Coordinate vector of maximum-vertex. Non-mandatory ?
pre - Pre-allocated BrepIterator object (can be null).
Returns:
The initialized iterator data.
See Also:
intervalQuery(int[],int[],BrepIterator), getProgress(cz.cuni.jagrlib.iface.BrepIterator, int[])

rayPass

public BrepIterator rayPass(double[] start,
                            double[] direction,
                            BrepIterator pre)
Initializes a new ray-casting pass.

Specified by:
rayPass in interface GeometrySearch
Parameters:
start - Starting point of the ray.
direction - Direction vector of the ray.
pre - Pre-allocated BrepIterator object (can be null).
Returns:
The initialized iterator data.
See Also:
getProgress(cz.cuni.jagrlib.iface.BrepIterator, int[])

centerPass

public BrepIterator centerPass(double[] center,
                               double radius,
                               BrepIterator pre)
Initializes a new center pass. Objects are enumerated in order defined by increasing distance from the given center point.

Specified by:
centerPass in interface GeometrySearch
Parameters:
center - Center of a pass.
radius - Maximum radius to be searched.
pre - Pre-allocated BrepIterator object (can be null).
Returns:
The initialized iterator data.
See Also:
getProgress(cz.cuni.jagrlib.iface.BrepIterator, int[])

sweepPass

public BrepIterator sweepPass(double[] plane,
                              double[] origin,
                              BrepIterator pre)
Initializes a new sweep-plane pass. Objects are enumerated in order defined by the given sweep-plane.

Specified by:
sweepPass in interface GeometrySearch
Parameters:
plane - (Oriented) normal vector of the sweep-plane.
origin - Starting point of a pass.
pre - Pre-allocated BrepIterator object (can be null).
Returns:
The initialized iterator data.
See Also:
getProgress(cz.cuni.jagrlib.iface.BrepIterator, int[])

finishedSegment

public double finishedSegment(BrepIterator iter)
Returns end value (coordinate) of already finished pass-segment. Semantics depends on pass type: safely processed distance from pass/ray origin, ..

Specified by:
finishedSegment in interface GeometrySearch
Parameters:
iter - Pass data.
Returns:
Safely processed distance from pass origin.

getProgress

public double getProgress(BrepIterator iter,
                          int[] count)
Returns progress parameters of the given pass.

Specified by:
getProgress in interface GeometrySearch
Parameters:
iter - Pass data.
count - Array to hold two counters: count[0] .. number of objects yet passed, count[1] .. total number of objects relevant to this pass (non-mandatory). Can be null.
Returns:
Actual pass-distance (or similar metric).

getStatistics

public int getStatistics(long[] counters)
Returns (and resets) counters (for statistics, profiling).

counters[0] .. number of point-to-point distance calculations.

counters[1] .. number of point-to-box distance calculations.

counters[2] .. number of log(N) heap operations.

Specified by:
getStatistics in interface GeometrySearch
Parameters:
counters - Array to hold result. If null functions returns required length.
Returns:
Required array length.