Package de.javagl.ply

Class ObjectPlyTarget

  • All Implemented Interfaces:
    PlyTarget

    public final class ObjectPlyTarget
    extends Object
    implements PlyTarget
    Implementation of a PlyTarget that can be configured to translate the elements from the PLY into objects, assign the property values to these objects, and pass the final objects to a consumer.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  ObjectPlyTarget.Handle<T>
      A handle for a specific type of element.
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectPlyTarget()
      Default constructor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void endElement​(int elementTypeIndex, int elementIndex)
      Will be called to indicate that the specified element was finished, and all handle...Property calls for that element have been made.
      void endElementList​(int elementTypeIndex)
      Will be called to indicate that the sequence of calls to handle the specified sequence of elements is finished.
      void handleCharListProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, byte[] value)
      Will be called to handle the specified property of the specified element.
      void handleCharProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, byte value)
      Will be called to handle the specified property of the specified element.
      void handleDoubleListProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, double[] value)
      Will be called to handle the specified property of the specified element.
      void handleDoubleProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, double value)
      Will be called to handle the specified property of the specified element.
      void handleFloatListProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, float[] value)
      Will be called to handle the specified property of the specified element.
      void handleFloatProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, float value)
      Will be called to handle the specified property of the specified element.
      void handleIntListProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, int[] value)
      Will be called to handle the specified property of the specified element.
      void handleIntProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, int value)
      Will be called to handle the specified property of the specified element.
      void handleShortListProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, short[] value)
      Will be called to handle the specified property of the specified element.
      void handleShortProperty​(int elementTypeIndex, int elementIndex, int propertyIndex, short value)
      Will be called to handle the specified property of the specified element.
      <T> ObjectPlyTarget.Handle<T> register​(String elementName, Supplier<T> supplier)
      Register a new element type to be handled by this instance.
      void setDescriptor​(Descriptor descriptor)
      Will receive the Descriptor for the PLY data.
      void startElement​(int elementTypeIndex, int elementIndex)
      Will be called to indicate the start of the specified element.
      void startElementList​(int elementTypeIndex, int elementCount)
      Will be called to indicate the start of a list of elements.
    • Constructor Detail

      • ObjectPlyTarget

        public ObjectPlyTarget()
        Default constructor
    • Method Detail

      • setDescriptor

        public void setDescriptor​(Descriptor descriptor)
        Description copied from interface: PlyTarget
        Will receive the Descriptor for the PLY data. This will be called once, at the beginning of the process. It may be used to initialize internal data structures based on the given Descriptor.
        Specified by:
        setDescriptor in interface PlyTarget
        Parameters:
        descriptor - The Descriptor
      • startElementList

        public void startElementList​(int elementTypeIndex,
                                     int elementCount)
        Description copied from interface: PlyTarget
        Will be called to indicate the start of a list of elements. It will be followed by calls that reflect a sequence of elements. Each element will be represented by calls
        Specified by:
        startElementList in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementCount - The number of elements that will follow
      • startElement

        public void startElement​(int elementTypeIndex,
                                 int elementIndex)
        Description copied from interface: PlyTarget
        Will be called to indicate the start of the specified element. It will be followed by a sequence of calls to handle...Property for all the element properties.
        Specified by:
        startElement in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
      • handleCharProperty

        public void handleCharProperty​(int elementTypeIndex,
                                       int elementIndex,
                                       int propertyIndex,
                                       byte value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleCharProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • handleShortProperty

        public void handleShortProperty​(int elementTypeIndex,
                                        int elementIndex,
                                        int propertyIndex,
                                        short value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleShortProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • handleIntProperty

        public void handleIntProperty​(int elementTypeIndex,
                                      int elementIndex,
                                      int propertyIndex,
                                      int value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleIntProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • handleFloatProperty

        public void handleFloatProperty​(int elementTypeIndex,
                                        int elementIndex,
                                        int propertyIndex,
                                        float value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleFloatProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • handleDoubleProperty

        public void handleDoubleProperty​(int elementTypeIndex,
                                         int elementIndex,
                                         int propertyIndex,
                                         double value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleDoubleProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • handleCharListProperty

        public void handleCharListProperty​(int elementTypeIndex,
                                           int elementIndex,
                                           int propertyIndex,
                                           byte[] value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleCharListProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • handleShortListProperty

        public void handleShortListProperty​(int elementTypeIndex,
                                            int elementIndex,
                                            int propertyIndex,
                                            short[] value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleShortListProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • handleIntListProperty

        public void handleIntListProperty​(int elementTypeIndex,
                                          int elementIndex,
                                          int propertyIndex,
                                          int[] value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleIntListProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • handleFloatListProperty

        public void handleFloatListProperty​(int elementTypeIndex,
                                            int elementIndex,
                                            int propertyIndex,
                                            float[] value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleFloatListProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • handleDoubleListProperty

        public void handleDoubleListProperty​(int elementTypeIndex,
                                             int elementIndex,
                                             int propertyIndex,
                                             double[] value)
        Description copied from interface: PlyTarget
        Will be called to handle the specified property of the specified element.
        Specified by:
        handleDoubleListProperty in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
        propertyIndex - The index of the property
        value - The value of the property
      • endElement

        public void endElement​(int elementTypeIndex,
                               int elementIndex)
        Description copied from interface: PlyTarget
        Will be called to indicate that the specified element was finished, and all handle...Property calls for that element have been made.
        Specified by:
        endElement in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
        elementIndex - The index of the element
      • endElementList

        public void endElementList​(int elementTypeIndex)
        Description copied from interface: PlyTarget
        Will be called to indicate that the sequence of calls to handle the specified sequence of elements is finished.
        Specified by:
        endElementList in interface PlyTarget
        Parameters:
        elementTypeIndex - The element type index
      • register

        public <T> ObjectPlyTarget.Handle<T> register​(String elementName,
                                                      Supplier<T> supplier)
        Register a new element type to be handled by this instance. This will return a ObjectPlyTarget.Handle that allows further configuration about how to handle the specific element type. The handle offers methods to configure how each property is supposed to be handled, using the handle.with... functions, and how the final elements should be consumed, using the ObjectPlyTarget.Handle.consume(Consumer) method.
        Type Parameters:
        T - The element type
        Parameters:
        elementName - The element name
        supplier - The supplier for the elements
        Returns:
        The ObjectPlyTarget.Handle