pcd-loader-0.3.0.1: PCD file loader.

Safe HaskellNone

PCD.Header

Description

Define a data structure for a PCD file header and an associated parser.

Synopsis

Documentation

data DimType Source

Fields attached to a point may be signed integers (I), unsigned integers (U), or floating point (F).

Constructors

I 
U 
F 

data DataFormat Source

The PCD format has both ASCII and binary variants.

Constructors

ASCII 
Binary 

class PCDType a whereSource

Methods

unsafeUnwrap :: FieldType -> aSource

Extract a raw Haskell value from the FieldType variant. If you know what you've got, this frees from having to pattern match on the FieldType constructor. If you're wrong, you'll get an exception.

fromHaskell :: a -> (DimType, Int)Source

Associate a DimType and a size (in bytes) for every instance of PCDType. The argument to fromHaskell is never evaluated.

fieldParser :: DimType -> Int -> Parser FieldTypeSource

Construct a parser for a field based on its type and size.

sequence' :: Monad m => [m a] -> m [a]Source

defaultVersion :: TextSource

The default PCD version of 0.7.

mkSimpleHeader :: [Text] -> (DimType, Int) -> Int -> HeaderSource

Make a PCD header for a monotyped vector point type. mkSimpleHeader fields (type,sz) n prepares a Header for n points with field names fields, field type given by type, and field size given by sz. Example to save 1000 3D points using a single-precision floating point number (4 bytes) for each field:

 mkSimpleHeader ["x","y","z"] (F,4) 1000

mkHeaderXYZ :: PCDType a => a -> Int -> HeaderSource

mkHeaderXYZ sample n builds a Header for n points with fields "x", "y", and "z" of DimType and size (in bytes) derived from the PCDType instance of sample. Example:

 mkHeaderXYZ (undefined::Float) 1000

pointParser :: Header -> Parser [FieldType]Source

Assemble a parser for points by sequencing together all necessary field parsers.

filterFields :: (Text -> Bool) -> Header -> HeaderSource

Create a Header based on an existing one that keeps only the fields whose names pass the supplied predicate.

nextLine :: Handle -> IO TextSource

Get the next non-comment line.

readHeader :: Handle -> IO (Header, Maybe Text)Source

Parse a PCD header. Returns the Header and the rest of the file contents.

writeHeader :: Header -> TextSource

Format a Header to be compatible with the PCD specification.

totalBinarySize :: Header -> IntSource

Compute the number of bytes this point cloud would occupy if serialized with the Binary encoding.