Class TextStlFacetDefinitionReader

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean foundSolidEnd
      Flag indicating if the end of a solid definition was detected.
      private boolean foundSolidStart
      Flag indicating if the start of a solid definition was detected.
      private SimpleTextParser parser
      Text parser.
      private java.io.Reader reader
      Underlying reader instance.
      private java.lang.String solidName
      The name of the solid being read.
    • Constructor Summary

      Constructors 
      Constructor Description
      TextStlFacetDefinitionReader​(java.io.Reader reader)
      Construct a new instance for reading text STL content from the given reader.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void beginSolid()
      Begin reading an STL solid definition.
      void close()
      Close this instance and release all associated resources.
      private void ensureSolidStarted()
      Ensure that an STL solid definition is in the process of being read.
      java.lang.String getSolidName()
      Get the name of the STL solid being read or null if no name was specified.
      private void matchKeyword​(java.lang.String keyword)
      Read the next word from the content and match it against the given keyword.
      private void nextWord()
      Read the next word from the content, discarding preceding whitespace.
      private double readDouble()
      Read a double value from the input.
      FacetDefinition readFacet()
      Return the next facet definition from the input source or null if no more facets are available.
      private FacetDefinition readFacetInternal()
      Internal method to read a single facet from the STL content.
      private Vector3D readVector()
      Read a vector from the input.
      private static java.lang.String trimmedOrNull​(java.lang.String str)
      Return a trimmed version of the given string or null if the string contains only whitespace.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • reader

        private java.io.Reader reader
        Underlying reader instance.
      • foundSolidStart

        private boolean foundSolidStart
        Flag indicating if the start of a solid definition was detected.
      • foundSolidEnd

        private boolean foundSolidEnd
        Flag indicating if the end of a solid definition was detected.
      • solidName

        private java.lang.String solidName
        The name of the solid being read.
    • Constructor Detail

      • TextStlFacetDefinitionReader

        public TextStlFacetDefinitionReader​(java.io.Reader reader)
        Construct a new instance for reading text STL content from the given reader.
        Parameters:
        reader - reader to read characters from
    • Method Detail

      • getSolidName

        public java.lang.String getSolidName()
        Get the name of the STL solid being read or null if no name was specified.
        Returns:
        the name of the STL solid being read or null if no name was specified
        Throws:
        java.lang.IllegalStateException - if a data format error occurs
        java.io.UncheckedIOException - if an I/O error occurs
      • readFacet

        public FacetDefinition readFacet()
        Return the next facet definition from the input source or null if no more facets are available.
        Specified by:
        readFacet in interface FacetDefinitionReader
        Returns:
        the next facet definition or null if no more facets are available
      • close

        public void close()
        Close this instance and release all associated resources.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface FacetDefinitionReader
      • readFacetInternal

        private FacetDefinition readFacetInternal()
        Internal method to read a single facet from the STL content.
        Returns:
        next facet definition
        Throws:
        java.lang.IllegalStateException - if a data format error occurs
        java.io.UncheckedIOException - if an I/O error occurs
      • ensureSolidStarted

        private void ensureSolidStarted()
        Ensure that an STL solid definition is in the process of being read. If not, the beginning of a the definition is attempted to be read from the input.
        Throws:
        java.lang.IllegalStateException - if a data format error occurs
        java.io.UncheckedIOException - if an I/O error occurs
      • beginSolid

        private void beginSolid()
        Begin reading an STL solid definition. The "solid" keyword is read along with the name of the solid.
        Throws:
        java.lang.IllegalStateException - if a data format error occurs
        java.io.UncheckedIOException - if an I/O error occurs
      • nextWord

        private void nextWord()
        Read the next word from the content, discarding preceding whitespace.
        Throws:
        java.lang.IllegalStateException - if a data format error occurs
        java.io.UncheckedIOException - if an I/O error occurs
      • matchKeyword

        private void matchKeyword​(java.lang.String keyword)
        Read the next word from the content and match it against the given keyword.
        Parameters:
        keyword - keyword to match against
        Throws:
        java.lang.IllegalStateException - if the read content does not match the given keyword
        java.io.UncheckedIOException - if an I/O error occurs or
      • readVector

        private Vector3D readVector()
        Read a vector from the input.
        Returns:
        the vector read from the input
        Throws:
        java.lang.IllegalStateException - if a data format error occurs
        java.io.UncheckedIOException - if an I/O error occurs
      • readDouble

        private double readDouble()
        Read a double value from the input.
        Returns:
        double value read from the input
        Throws:
        java.lang.IllegalStateException - if a data format error occurs
        java.io.UncheckedIOException - if an I/O error occurs
      • trimmedOrNull

        private static java.lang.String trimmedOrNull​(java.lang.String str)
        Return a trimmed version of the given string or null if the string contains only whitespace.
        Parameters:
        str - input stream
        Returns:
        a trimmed version of the given string or null if the string contains only whitespace