com.interactivemesh.jfx.importer.stl

## Class StlMeshImporter

- java.lang.Object
- - com.interactivemesh.jfx.importer.stl.StlMeshImporter

- All Implemented Interfaces:
    Importer

      public class StlMeshImporter
      extends java.lang.Object
      implements Importer

  A JavaFX importer for ASCII and binary STL files.

  For further details see the package page.

  Import process

  Prepare the importer (opt.) | Read the file | React (opt.) | Access the imported data | Clean up (recom'd)
  `setCreaseAngle(double)` `setOptions(EnumSet)` `setOptions(StlImportOption...)` | `read(File)` `read(String)` `read(URL)` | `onFileImported()` | `getImport()` `getSolidName()` | `clear()` `close()`

  Sample code

  Following structure of the application-jar is assumed:

  ../app/MyApp.class
  ../app/resources/MyModel.stl

      StlMeshImporter stlImporter = new StlMeshImporter();
      try {
          URL modelUrl = this.getClass().getResource("resources/MyModel.stl");
          stlImporter.read(modelUrl);
      }
      catch (ImportException e) {
          // handle exception
      }
      TriangleMesh stlMesh = stlImporter.getImport();

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `StlMeshImporter()` Creates a STL mesh importer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Disposes of the imported data.
    `void` | `close()` Disposes of the imported data and closes the importer.
    `double` | `getCreaseAngle()` Gets the crease angle for normals generation measured in degrees.
    `javafx.scene.shape.TriangleMesh` | `getImport()` Gets the TriangleMesh from the imported file.
    `java.util.EnumSet<StlImportOption>` | `getOptions()` Gets a copy of the import options enum set.
    `java.lang.String` | `getSolidName()` Gets the solid name from the imported ASCII file or the header from the imported binary file.
    `void` | `onFileImported()` Method is invoked upon completion of import.
    `void` | `read(java.io.File file)` Imports a 3D model file passed as a File object.
    `void` | `read(java.lang.String filePath)` Imports a 3D model file with the passed file path.
    `void` | `read(java.net.URL url)` Imports a 3D model file from the passed location.
    `void` | `setCreaseAngle(double degrees)` Sets the crease angle for normals generation measured in degrees.
    `void` | `setOptions(java.util.EnumSet<StlImportOption> options)` Sets the import options.
    `void` | `setOptions(StlImportOption... options)` Sets the import options.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### StlMeshImporter

          public StlMeshImporter()

      Creates a STL mesh importer.

  - ### Method Detail

    - #### getCreaseAngle

          public double getCreaseAngle()

      Gets the crease angle for normals generation measured in degrees.

      Default value: 45

      Specified by:
        `getCreaseAngle` in interface `Importer`
      Returns:
        crease angle for normals generation

    - #### setCreaseAngle

          public void setCreaseAngle(double degrees)

      Sets the crease angle for normals generation measured in degrees. The value will be clamped to [0, 180].

      Default value: 45

      Specified by:
        `setCreaseAngle` in interface `Importer`
      Parameters:
        `degrees` - crease angle for generating normals

    - #### getOptions

          public java.util.EnumSet<StlImportOption> getOptions()

      Gets a copy of the import options enum set. Default options: `StlImportOption.NONE`.
      Returns:
        enum set of the import options

    - #### setOptions

          public void setOptions(StlImportOption... options)

      Sets the import options. Currently set options are removed. Default options: `StlImportOption.NONE`.
      Parameters:
        `options` - a sequence or an array of import options
      Throws:
        `java.lang.IllegalArgumentException` - if options is `null`, its length is 0, or `StlImportOption.NONE` is not the sole element

    - #### setOptions

          public void setOptions(java.util.EnumSet<StlImportOption> options)

      Sets the import options. Currently set options are removed. Default options: `StlImportOption.NONE`.
      Parameters:
        `options` - enum set of import options
      Throws:
        `java.lang.IllegalArgumentException` - if options is `null`, its size is 0, or `StlImportOption.NONE` is not the sole element

    - #### read

          public void read(java.io.File file)

      Imports a 3D model file passed as a File object. The data of the last imported file will be disposed of. The imported data is available as soon as this method returns.
      Specified by:
        `read` in interface `Importer`
      Parameters:
        `file` - File object to import

    - #### read

          public void read(java.lang.String filePath)

      Imports a 3D model file with the passed file path. The data of the last imported file will be disposed of. The imported data is available as soon as this method returns.
      Specified by:
        `read` in interface `Importer`
      Parameters:
        `filePath` - location of the file to import

    - #### read

          public void read(java.net.URL url)

      Imports a 3D model file from the passed location. The data of the last imported file will be disposed of. The imported data is available as soon as this method returns.
      Specified by:
        `read` in interface `Importer`
      Parameters:
        `url` - location of the file to import

    - #### onFileImported

          public void onFileImported()

      Method is invoked upon completion of import. This implementation doesn't do anything, but may be customized in subclasses.
      Specified by:
        `onFileImported` in interface `Importer`

    - #### getImport

          public javafx.scene.shape.TriangleMesh getImport()

      Gets the TriangleMesh from the imported file.
      Specified by:
        `getImport` in interface `Importer`
      Returns:
        imported TriangleMesh or `null` if no TriangleMesh is imported

    - #### getSolidName

          public java.lang.String getSolidName()

      Gets the solid name from the imported ASCII file or the header from the imported binary file.
      Returns:
        solid name or header, `null` if no TriangleMesh is imported

    - #### clear

          public void clear()

      Disposes of the imported data. Imported data should be disposed of if the importer isn't used for some time. The importer doesn't run the garbage collector.
      Specified by:
        `clear` in interface `Importer`

    - #### close

          public void close()

      Disposes of the imported data and closes the importer. The importer should be closed if it isn't used again. The importer doesn't run the garbage collector.
      Specified by:
        `close` in interface `Importer`

Copyright (C) 2013-2014 InteractiveMesh e.K.