Class DistanceCalculator


  • public class DistanceCalculator
    extends java.lang.Object
    The DistanceCalculator implements an efficient way of calculating
    different distances between two objects, each represented by a frame

    A list of frame pairs is contained within the distance calculater,
    that specifies which frames are to be checked against each other.
    The method of used for distance calculation relies on the DistanceStrategy
    chosen.

    The DistanceCalculator supports switching between multiple strategies
    • Constructor Detail

      • DistanceCalculator

        public DistanceCalculator​(long cPtr,
                                  boolean cMemoryOwn)
      • DistanceCalculator

        public DistanceCalculator​(FramePtr root,
                                  WorkCellPtr workcell,
                                  DistanceStrategyPtr strategy,
                                  State initial_state)
        Distance calculations for a given tree, collision setup and
        primitive distance calculator. Uses proximity strategy given by the workcell.

        strategy must be non-NULL.

        root must be non-NULL.

        Ownership of root is not taken.

        Parameters:
        root - [in] - the root of the Frame tree.

        workcell - [in] - the workcell to do the distance calculations in.

        strategy - [in] - the primitive strategy of distance calculations.

        initial_state - [in] - the work cell state to use for the
        initial traversal of the tree.
      • DistanceCalculator

        public DistanceCalculator​(WorkCellPtr workcell,
                                  DistanceStrategyPtr strategy)
        Construct distance calculator for a WorkCell with an associated
        distance calculator strategy.

        The DistanceCalculator extracts information about the tree and the
        CollisionSetup from workcell.

        Parameters:
        workcell - [in] the workcell to check
        strategy - [in] the distance calculation strategy to use
      • DistanceCalculator

        public DistanceCalculator​(FramePairVector pairs,
                                  DistanceStrategyPtr strategy)
        Constructs distance calculator for a selected set of frames

        The list pairs specifies which frame-pairs to be used for distance checking.

        strategy must be non-NULL.

        Ownership of root is not taken.

        Parameters:
        pairs - [in] Pairs of frame to check
        strategy - [in] the distance calculation strategy to use
    • Method Detail

      • delete

        public void delete()
      • distance

        public DistanceStrategy.DistanceStrategyResult distance​(State state,
                                                                DistanceStrategyResultVector result)
        Calculates the distances between frames in the tree

        Parameters:
        state - [in] The state for which to calculate distances.

        result - [out] If non-NULL, the distance results are written
        to result.

        Returns:
        the shortest distance between frame and frame tree
      • distance

        public DistanceStrategy.DistanceStrategyResult distance​(State state)
        Calculates the distances between frames in the tree

        Parameters:
        state - [in] The state for which to calculate distances.



        Returns:
        the shortest distance between frame and frame tree
      • distance

        public DistanceStrategy.DistanceStrategyResult distance​(State state,
                                                                FramePtr frame,
                                                                DistanceStrategyResultVector result)
        Calculates the distance between frame and the rest of the tree

        Parameters:
        state - [in] The state for which to calculate distances.

        frame - [in] The frame for which distances are to be calculated

        result - [out] If non-NULL, the distance results are written
        to result.

        Returns:
        the shortest distance between frame and frame tree
      • distance

        public DistanceStrategy.DistanceStrategyResult distance​(State state,
                                                                FramePtr frame)
        Calculates the distance between frame and the rest of the tree

        Parameters:
        state - [in] The state for which to calculate distances.

        frame - [in] The frame for which distances are to be calculated



        Returns:
        the shortest distance between frame and frame tree
      • setDistanceStrategy

        public void setDistanceStrategy​(DistanceStrategyPtr strategy)
        Set the primitive distance calculator to strategy.

        strategy must be non-NULL.

        Ownership of the strategy is not taken.

        Parameters:
        strategy - [in] - the primitive distance calculator to use.
      • addDistanceModel

        public boolean addDistanceModel​(FramePtr frame,
                                        Geometry faces)
        Adds distance model to frame

        The distance model is constructed based on the list of faces given.

        Parameters:
        frame - [in] frame to which the distance model should associate
        faces - [in] list of faces from which to construct the model
        Returns:
        true if a distance model was succesfully created and linked
        with the frame; false otherwise.
      • clearCache

        public void clearCache()
        Clears the cache of the distance models
      • getComputationTime

        public double getComputationTime()
      • getCount

        public int getCount()
      • resetComputationTimeAndCount

        public void resetComputationTimeAndCount()