Class SoDataCompressor
- java.lang.Object
-
- com.openinventor.inventor.Inventor
-
- com.openinventor.ldm.compressors.SoDataCompressor
-
- Direct Known Subclasses:
SoGzipDataCompressor
,SoJpegDataCompressor
public abstract class SoDataCompressor extends Inventor
Data compression. This is an abstract class which is only needed for advanced users who intend to add a new LDM data compression technique.By implementing each virtual method of this class, it is possible to create a new compression algorithm. As with a custom node, the initClass of the custom compressor must be called before creating and instantiating an instance of the custom class. After you call initClass, the compression algorithm will be available in the '-c' option of
SoConverter
.- See Also:
SoGzipDataCompressor
,SoJpegDataCompressor
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.openinventor.inventor.Inventor
Inventor.ConstructorCommand
-
-
Field Summary
-
Fields inherited from class com.openinventor.inventor.Inventor
VERBOSE_LEVEL, ZeroHandle
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.ByteBuffer
allocateCompressedBuffer(long size)
Allocates the internal buffer to hold the compressed data.static long
crc32(java.nio.ByteBuffer buf, long len)
Utility function to get the CRC32 of a buffer.static SoDataCompressor
getAppropriateCompressor(java.lang.String name)
Create and return an instance of a compressor of the given type.java.nio.ByteBuffer
getCompressedBuffer()
Returns the compressed data.java.lang.String
getCompressionFormatName()
Returns the name of the compression algorithm used by this class.long
getCompressionLevel()
Returns the compression level.boolean
isLossless()
Returns true if the compression algorithm is lossless.void
setCompressionLevel(long level)
Sets the compression level.-
Methods inherited from class com.openinventor.inventor.Inventor
dispose, getNativeResourceHandle
-
-
-
-
Method Detail
-
getCompressionFormatName
public java.lang.String getCompressionFormatName()
Returns the name of the compression algorithm used by this class. This is the name the user will pass to the "-c" option of the converter, so it should be something simple and clear.- Returns:
- A String containing the name of the compression.
-
crc32
public static long crc32(java.nio.ByteBuffer buf, long len)
Utility function to get the CRC32 of a buffer.- Parameters:
buf
- a pointer to the data.len
- the size of the buffer.- Returns:
- The CRC32 of the data.
-
allocateCompressedBuffer
public java.nio.ByteBuffer allocateCompressedBuffer(long size)
Allocates the internal buffer to hold the compressed data.- Parameters:
size
- is the size to allocate in bytes.
-
setCompressionLevel
public void setCompressionLevel(long level)
Sets the compression level.- Parameters:
level
- the level of the compression used. Valid compression levels are specific to the compression algorithm.
-
isLossless
public boolean isLossless()
Returns true if the compression algorithm is lossless.Warning It allows the converter to know if it must do CRC32 on original data or decompressed data when the '-C' option is enabled. Computing CRC32 on lossy compression is more costly than on lossless compression because data must be uncompressed before applying the CRC32 in order to have the real data stored in the file. Setting the environment variable LDM_COMPRESS_CHECK_CRC32 to 1 will force the LDM reader to check data integrity.
- Returns:
- True if the compression is lossless.
-
getCompressionLevel
public long getCompressionLevel()
Returns the compression level.- Returns:
- The level of compression. See
setCompressionLevel
.
-
getAppropriateCompressor
public static SoDataCompressor getAppropriateCompressor(java.lang.String name)
Create and return an instance of a compressor of the given type.- Parameters:
name
- The name of the compressor.- Returns:
- A pointer to the newly created compressor. If this compressor is not available, returns NULL.
-
getCompressedBuffer
public java.nio.ByteBuffer getCompressedBuffer()
Returns the compressed data. This pointer must not be deleted.- Returns:
- A pointer to the compressed data.
-
-