Keywords:

Summary

This demo shows the use of the DIRSIG-specific Object HDF format for storing facetized object geometry data. The simulation encompasses importing the same facetized object geometry representation into a DIRSIG scene from a variety of different representations, including the commonly used Alias/Wavefront OBJ format, a DIRSIG-specific binary HDF file and a binary HDF file with internal compression. Utilizing binary and/or compressed geometry files can be useful to reduce storage space for highly detailed CAD objects in cloud environments where the costs of data ingress and/or egress can be a concern.

Details

This demo imports a DIRS branded VW van into the scene using three different geometry representations:

Alias Wavefront OBJ

This is the default Alias/Wavefront OBJ ASCII/Text file (see https://en.wikipedia.org/wiki/Wavefront_.obj_file for more info).

DIRSIG Object HDF

The original .obj file is converted to a HDF (Hierarchical Data Format) file (see https://en.wikipedia.org/wiki/Hierarchical_Data_Format for more info).

DIRSIG Object HDF + Compression

Finally this HDF is converted to a version employing internal compression using the h5repack tool included in the HDF developer kit.

The DIRSIG "Object HDF" format is essentially the same format used to store individual facet objects in the DIRSIG Scene HDF file. The data mirrors that of the classic OBJ file in that it utilizes a list of 3D vertexes, a list of triangular facets that are created by indexing the 3D vertex list and optionally vertex normals and/or texture coordinates. Although this DIRSIG-specific format is not supported natively by any 3D software, this binary alternative to the classic ASCII/Text OBJ file was introduced as a way to reduce storage requirements for high resolution facetized geometry objects. Additionally, since the HDF format natively supports lossless data compression in it’s data tables, the storage sizes can be further reduced. Due to it’s reduced portability, this format is primarily used in Bundled Objects, where the geometry has been finalized and isn’t expected to be routinely edited anymore.

Important
These "object HDF" files only contain the facetized geometry and an integer index for the material assigned to each facet. However, the material description itself is not contained in the object HDF and must be associated with the geometry as part of the import process.

Important Files

This demo is focused on different storage formats for a vintage VW van object. The final simulation shows three instances of the same VW van geometry using the three different 3D geometry format options described above.

Alias/Wavefront OBJ

The first instance of the VW van uses a conventional OBJ file (see the geometry/bundles/vw.obj file). The details of this OBJ file can be examined with the DIRSIG object_tool utility:

$ object_tool vw.obj
Reading input OBJ file ...
Reading in geometry file: vw.obj
    Part count   = 1
    Facet count  = 36974
    Vertex count = 18949

Geometry summary tool:
    Triangle count = 36974
    Vertex count = 18949
    Group Count = 1
    Minimum = -0.879, -2.147, 0.000
    Mid     = 0.000, 0.000, 0.955
    Maximum = 0.879, 2.147, 1.910
    Size = 1.758 x 4.293 x 1.910 [m]

Group summary tool:
    default (assigned to 36974 facets)

Material summary tool:
    exterior (assigned to 23282 facets)
    windows (assigned to 70 facets)
    tire (assigned to 6679 facets)
    metal (assigned to 6943 facets)

The Material summary tool lists the 4 materials that need to be provided by the DIRSIG material database. Examination of the geometry/bundles/materials/dirs_van.mat file will reveal that materials with these 4 labels (IDs) are present. Therefore, the OBJ can be directly instanced into the scene (see geometry/bundles/obj.glist):

Bundling the OBJ file with the VW materials.
<geometrylist>
  <object search_paths="local">
    <localmaterials>materials/dirs_van.mat</localmaterials>
    <basegeometry>
      <obj swapyz="false">
        <filename>vw.obj</filename>
      </obj>
    </basegeometry>
    <staticinstance>
      <translation>
        <point><x>-5</x><y>5</y><z>0</z></point>
      </translation>
      <rotation rotationorder="xyz" units="degrees">
        <cartesiantriple><x>0</x><y>0</y><z>60</z></cartesiantriple>
      </rotation>
    </staticinstance>
  </object>
</geometrylist>

DIRSIG Object HDF w/o Compression

DIRSIG-specific "Object HDF" facet object files can be generated with the facet_tool utility that is included with the DIRSIG software. To perform the conversion operation on the vw.obj file, the following syntax can be used:

Converting the OBJ file to an Object HDF with the DIRSIG facet_tool utility.
$ facet_tool convert vw.obj
Material indexes for "vw.obj":
  0 => exterior
  1 => windows
  2 => tire
  3 => metal

The material index table produced by the tool captures the mapping of the integer indexes using within the HDF file to the original material labels in the OBJ file. To associate materials with the geometry, these indexes must be mapped to DIRSIG material labels (IDs). This has be done within the hdf.glist file as shown below as the Object HDF is imported as HDF base geometry:

Mapping DIRSIG materials to the indexes in the Object HDF file.
    <basegeometry>
      <hdf>
        <filename>vw.obj.hdf</filename>
        <assign id="exterior">0</assign>
        <assign id="windows">1</assign>
        <assign id="tire">2</assign>
        <assign id="metal">3</assign>
      </hdf>
    </basegeometry>

DIRSIG Object HDF w/ Compression

If the HDF5 tools are installed on your machine you can then apply lossless compresseion to the object HDF file to reduce the file size even further using the h5repack utility:

$ h5repack -v -f GZIP=9 vw.obj.hdf vw.obj.gzip9.hdf
No all objects to modify layout
All objects to apply filter are...
 All with GZIP, parameter 9
Making new file ...
-----------------------------------------
 Type     Filter (Compression)     Name
-----------------------------------------
 group                       /
 dset     GZIP   (0.800:1)   /BoundingBox
 dset     GZIP   (845.120:1) /FacetMaterials
 dset     GZIP   (869.976:1) /FacetTemperatureOverrides
 dset     GZIP   (3.278:1)   /Facets
 dset     GZIP   (1.640:1)   /TextureCoordinates
 dset     GZIP   (3.235:1)   /TextureFacets
 dset     GZIP   (3.425:1)   /VertexNormalFacets
 dset     GZIP   (1.250:1)   /VertexNormals
 dset     GZIP   (2.024:1)   /Vertices

Similar to the uncompressed Object HDF case, the base geometry import of the compressed HDF file must map the DIRSIG material labels (IDs) to the indexes created during the initial Object HDF conversion (see the geometry/bundles/gzip9hdf.glist file):

Mapping DIRSIG materials to the indexes in the compressed Object HDF file.
    <basegeometry>
      <hdf swapyz="false">
        <filename>vw.obj.gzip9.hdf</filename>
        <assign id="exterior">0</assign>
        <assign id="windows">1</assign>
        <assign id="tire">2</assign>
        <assign id="metal">3</assign>
      </hdf>
    </basegeometry>

Assembling the Scene

The scene is assembled by combining a ground (see geometry/ground.glist) with the 3 GLIST files outlined above:

  <odbdirectory>$SCENE_DIR/geometry</odbdirectory>
  <gdbdirectory>$SCENE_DIR/geometry</gdbdirectory>
  <geometrylist enabled="true">
    <geometrylistinclude name="ground" enabled="true">ground.glist</geometrylistinclude>
    <geometrylistinclude name="ground" enabled="true">bundles/obj.glist</geometrylistinclude>
    <geometrylistinclude name="ground" enabled="true">bundles/hdf.glist</geometrylistinclude>
    <geometrylistinclude name="ground" enabled="true">bundles/gzip9hdf.glist</geometrylistinclude>
  </geometrylist>

Simulations and Results

To run this demo the scene must be compiled with the DIRSIG5 scene2hdf scene compiler:

Compiling the scene.
$ scene2hdf demo.scene

The high-quality below above was produced with DIRSIG using increased covergence settings and by scaling the output image from 640 x 480 → 1280 x 960:

$ dirsig5 --scale_resolution=2 --convergence=30,250,1e-06 demo.sim

The PAN image produced by the simulation was scaled using the 2% scaling option in the DIRSIG image_tool utility:

$ image_tool convert --autoscale=percent demo.img
demo
Figure 1. Image of the 3 VW van objects (from 3 different input formats) and their relative storage sizes.