Class SbProjection

  • Direct Known Subclasses:
    SbCylindricalProjection, SbProj4Projection, SbSphericalProjection, SbTransformProjection

    public class SbProjection
    extends Inventor
    Base class for coordinate projection classes. This is the base class for classes that define a coordinate projection. The projection of a point P consists of computing a point P' and replacing internally the coordinates of P with the coordinates of P'. Projections can modify points in complex ways that are not possible with a transformation matrix. For example, projections allow the use of spherical coordinates, geospatial coordinates and others. An SoProjection node applies a coordinate projection to geometry nodes. A valid instance of a SbProjection class is needed by an SoProjection node put in a scene graph.

    To create a new projection class, implement a class inheriting from SbProjection. The only mandatory method to define a projection is the apply() method. To obtain the result of a projected point, call the project() method, which internally computes the result and calls apply(). You can also define the inverse() method, which is only used for applications that must compute the inverse of a projected point.

    The applyPreProjection() method can be defined and will be called just before a point is projected. The applyPostProjection() method can be defined and will be called just after a point has been projected.

    A projection class stores a list of string parameters and a list of float parameters. You can set or inquire a parameter using setParameter() or getParameter()

    The projection routine can get parameter values from the fields of the associated SoProjection node (if any). The parameters for a projection should be stored in the SoProjection node, as it is the only entry in the scene graph. The SoProjection.floatParameters field stores the float values that are synchronized with the float parameters of the projection class. The SoProjection.parameters field stores the string values that are synchronized with the string parameters of the projection class.

    The init() method is called each time a parameter of the associated SoProjection node is modified. The exit() method is called at the SbProjection instance destruction.

    If using the VolumeViz extension, defining the getProjectedBoundingBox() method will improve the rendering speed (see getProjectedBoundingBox comments).

    SbProj4Projection, SbSphericalProjection, SoProjection, SoGeoProjection, SbProjectionCoordinates
    • Constructor Detail

      • SbProjection

        public SbProjection()
      • SbProjection

        public SbProjection​(SoProjection node)
      • SbProjection

        public SbProjection​(SbProjection proj)
        Copy constructor.
    • Method Detail

      • inverse

        public SbVec3f inverse()
        Apply the inverse coordinate to one point. Modifies the given object.
      • exit

        public void exit()
        Exit method.
      • init

        public void init()
        Initialisation method.
      • getProjectedBoundingBox

        public SbBox3f getProjectedBoundingBox()
        Return projected bounding box if available. Note: Projecting a bounding box is most of the time not equivalent to the result of a bounding box that contains all projected point.

        It depends on the projection, and it is why by default it returns false, and should be redefined by the specific inherited projection class if it make sense.

      • setNumFloatParameters

        public void setNumFloatParameters​(int numParameters)
        Set number of float parameters to use.
      • getProjectionNode

        public SoProjection getProjectionNode()
        Return associated projection node.
      • setParameter

        public void setParameter​(int parameterId,
                                 java.lang.String parameterString)
        Set string parameter.
      • setParameter

        public void setParameter​(int parameterId,
                                 float parameterFloat)
        Set float parameter.
      • setNumStringParameters

        public void setNumStringParameters​(int numParameters)
        Set number of string parameters to use.
      • getNumStringParameters

        public int getNumStringParameters()
        Get number of used string parameters.
      • project

        public SbVec3f project()
        Apply the complete computation (matrix, pre-projection, projection, post-projection) to one point. Modifies the given object.
      • getFloatParameter

        public float getFloatParameter​(int pos)
        Get float parameter at position pos.
      • getStringParameter

        public java.lang.String getStringParameter​(int pos)
        Get string parameter at position pos.
      • getNumFloatParameters

        public int getNumFloatParameters()
        Get number of used float parameters.