HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GA_IO.h File Reference
#include "GA_API.h"
#include "GA_Types.h"
#include <SYS/SYS_Types.h>
#include <iosfwd>
+ Include dependency graph for GA_IO.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  io_ReadHandle
 
class  io_WriteHandle
 

Macros

#define __GA_IO__
 

Functions

virtual bool readFile (GA_Detail &g, const char *filename, const GA_LoadOptions *opts, UT_StringArray *errors) const
 Class which defines an I/O interface to save/load geometry. More...
 
virtual bool readStream (GA_Detail &g, UT_IStream &is, const GA_LoadOptions *opts, UT_StringArray *errors) const =0
 Load geometry from an input stream. More...
 
virtual bool writeFile (const GA_Detail &g, const char *filename, const GA_SaveOptions *opts, UT_StringArray *errors) const
 
virtual bool writeStream (const GA_Detail &g, std::ostream &os, bool binary, const GA_SaveOptions *opts, UT_StringArray *errors) const =0
 Write geometry to an output stream. More...
 
virtual bool readCheckStdin () const
 
virtual bool readCheckCompressed () const =0
 
virtual bool writeCheckStdout () const
 
bool isStdout (const char *filename) const
 
bool setLoadCounts (GA_Detail &gdp, GA_Size npoints, GA_Size nvertex, GA_Size nprimitive, GA_LoadMap &loadmap) const
 
bool rebuildTopology (GA_Detail &gdp, bool create_attributes=false) const
 
bool jsonSavePointReference (const GA_Detail &gdp, UT_JSONWriter &w, const GA_SaveMap &savemap) const
 
bool jsonLoadPointReference (GA_Detail &gdp, UT_JSONParser &p, const GA_LoadMap &loadmap) const
 

Macro Definition Documentation

#define __GA_IO__

Definition at line 14 of file GA_IO.h.

Function Documentation

bool isStdout ( const char *  filename) const
protected
bool jsonLoadPointReference ( GA_Detail gdp,
UT_JSONParser p,
const GA_LoadMap loadmap 
) const
protected

Save and load the vertex point-reference array using JSON

Warning
: After calling jsonLoadPointReference() you must rebuild the topology attributes.
bool jsonSavePointReference ( const GA_Detail gdp,
UT_JSONWriter w,
const GA_SaveMap savemap 
) const
protected

Save and load the vertex point-reference array using JSON

Warning
: After calling jsonLoadPointReference() you must rebuild the topology attributes.
virtual bool readCheckCompressed ( ) const
protectedpure virtual

If the io_ReadHandle should scan for filenames ending with extensions that indicate it is compressed then this method should return true

virtual bool readCheckStdin ( ) const
protectedvirtual

If the io_ReadHandle should scan for filenames starting with "stdin", this method should return true.

Definition at line 167 of file GA_IO.h.

virtual bool readFile ( GA_Detail g,
const char *  filename,
const GA_LoadOptions opts,
UT_StringArray errors 
) const
virtual

Class which defines an I/O interface to save/load geometry.

Loading a GA_Detail from a disk file goes through the following process

GA_Detail::load(const char *filename, const GA_LoadOptions *opts)
foreach (IO) {
if (IO->checkFilename(filename, opts) &&
IO->readFile(*this, filename, opts))
{
return true;
}
}
GA_IO::io_ReadHandle io(IO, filename, errors);
if (io.isValid())
return load(*io.getStream(), options);
return false;

Loading a GA_Detail from a stream goes through a similar process

uint8 magic = is.peek();
foreach (IO) {
if (IO->checkByteMagic(magic) && IO->readFile(*this, is, opts))
return true;
}
return false;

Saving geometry works similarly:

GA_Detail::save(const char *filename, const GA_SaveOptions *opts):
foreach (IO) {
if (IO->checkFilename(filename, opts))
return IO->writeFile(*this, filename, opts);
}
return false;
GA_Detail::save(ostream &os, const GA_SaveOptions *opts) const
IO = selectIO(opts);
return IO->writeStream(*this, os, opts);
class GA_API GA_IO
{
public:
GA_IO();
virtual ~GA_IO();
@{
Return identifiers for the file format.
virtual const char *getToken() const = 0;
virtual const char *getLabel() const = 0;
@}
@{
Check whether the filename could be handled by this IO handler.
This is called on both load and save operations.
virtual bool checkFilename(const char *filename,
const GA_SaveOptions *opts) const = 0;
virtual bool checkFilename(const char *filename,
const GA_LoadOptions *opts) const = 0;
@}
When loading an un-named stream, check whether the first byte of the
stream is an indicator of the file format. This is only called for
loading.
virtual bool checkByteMagic(uint8 first_byte,
const GA_LoadOptions *opts) const = 0;
Stat a disk file without necessarily loading the entire geometry
virtual bool statFile(const char *filename,
GA_Stat &stat, uint stat_level) const;
Stat a stream
virtual bool statStream(UT_IStream &is,
GA_Stat &stat, uint stat_level) const = 0;
Load geometry from a disk file. The default behaviour for this method
is: @code
GA_IO::io_ReadHandle io(filename, true);
return (io.isValid()) ? readStream(g, *io.getStream(), opts) : false;
virtual bool readStream ( GA_Detail g,
UT_IStream is,
const GA_LoadOptions opts,
UT_StringArray errors 
) const
pure virtual

Load geometry from an input stream.

bool rebuildTopology ( GA_Detail gdp,
bool  create_attributes = false 
) const
protected

After the geometry has been loaded, the sub-class may need to call the method to rebuild the topology attributes on the detail. The caller may also request that full topology attributes are created after load.

If the method fails, it's because the geometry failed the sanity check on topology. In this case, the geometry is cleared. The user should probably add an error in this case.

Warning
This method is for advanced users.
bool setLoadCounts ( GA_Detail gdp,
GA_Size  npoints,
GA_Size  nvertex,
GA_Size  nprimitive,
GA_LoadMap loadmap 
) const
protected

Provide access to private portions of the GA_Detail class for loading Tell the detail that the loading will be adding npoints, nvertex and nprimitive primitives. This will adjust the load map so that the proper index/offset mappings can be created. It also adjusts the index maps. The method will return false if there was an error.

virtual bool writeCheckStdout ( ) const
protectedvirtual

If the io_WriteHandle should scan for filenames starting with "stdout", this method should return true.

Definition at line 174 of file GA_IO.h.

virtual bool writeFile ( const GA_Detail g,
const char *  filename,
const GA_SaveOptions opts,
UT_StringArray errors 
) const
virtual

Save geometry to a disk file. The default behaviour for this method is:

GA_IO::io_WriteHandle io(filename, true);
return io.isValid() ? writeStream(g, *io.getStream(), opts) : false;
virtual bool writeStream ( const GA_Detail g,
std::ostream &  os,
bool  binary,
const GA_SaveOptions opts,
UT_StringArray errors 
) const
pure virtual

Write geometry to an output stream.