VRUT::IOStlModule Class Reference

STL import/export module class. More...

#include <iostl.h>

Inheritance diagram for VRUT::IOStlModule:

VRUT::IOModule VRUT::SceneModule VRUT::Module

List of all members.

Public Member Functions

 IOStlModule (const MODULE_ID &_id, const wxString &_name, EventHandler *msgSink)
 Class constructor.
virtual ~IOStlModule ()
 Class destructor.
virtual wxString GetDesc () const
 Get module description - Module overload.
virtual wxString GetSupportedExts () const
 Get string with file extensions supported by module - IOModule overload.
virtual bool ImportScene (const wxString &fname, SCENE_ID _sceneID, const wxString &rootUid)
virtual bool ExportScene (const wxString &fname, const Scene *scene)
 Export scene to file.

Protected Member Functions

virtual void processEvent (wxCommandEvent &evt)
 Process event - SceneIOModule overload.

Protected Attributes

bool saveBinary
 Use binary output when exporting?
Parameter::ParameterIdentificator saveBinaryParamID
 saveBinary param identificator
bool recomputeNormals
 Recompute normals when importing?
Parameter::ParameterIdentificator recomputeNormalsParamID
 recomputeNormals param identificator


Detailed Description

STL import/export module class.

Definition at line 24 of file iostl.h.


Constructor & Destructor Documentation

IOStlModule::IOStlModule ( const MODULE_ID _id,
const wxString &  _name,
EventHandler msgSink 
)

Class constructor.

Definition at line 20 of file iostl.cpp.

00021               : IOModule(_id, _name, 0, msgSink)
00022 {
00023        saveBinary = true;
00024        REGISTER_PARAM_GUI_CHECKBOX(saveBinaryParamID, wxT("saveBinary"), wxT("1"), wxT("Use binary format for saving."));
00025        recomputeNormals = true;
00026        REGISTER_PARAM_GUI_CHECKBOX(recomputeNormalsParamID, wxT("recomputeNormals"), wxT("1"), wxT("Recompute normals on import."));
00027 }

IOStlModule::~IOStlModule (  )  [virtual]

Class destructor.

Definition at line 30 of file iostl.cpp.

00031 {
00032 }


Member Function Documentation

void IOStlModule::processEvent ( wxCommandEvent &  evt  )  [protected, virtual]

Process event - SceneIOModule overload.

Reimplemented from VRUT::IOModule.

Definition at line 47 of file iostl.cpp.

00048 {
00049        IOModule::processEvent(evt);
00050        switch (evt.GetEventType())
00051        {
00052        case Event::EVT_PARAM_SET:
00053               UPDATE_PARAM_FROM_EVENT_BOOL(saveBinaryParamID, saveBinary, evt);
00054               UPDATE_PARAM_FROM_EVENT_BOOL(recomputeNormalsParamID, recomputeNormals, evt);
00055               break;
00056        default:
00057               break;
00058        }
00059 }

wxString IOStlModule::GetDesc (  )  const [virtual]

Get module description - Module overload.

Implements VRUT::Module.

Definition at line 35 of file iostl.cpp.

00036 {
00037        return wxT("Import and export STL files");
00038 }

wxString IOStlModule::GetSupportedExts (  )  const [virtual]

Get string with file extensions supported by module - IOModule overload.

Implements VRUT::IOModule.

Definition at line 41 of file iostl.cpp.

00042 {
00043        return wxT("STL");
00044 }

bool IOStlModule::ImportScene ( const wxString &  fname,
SCENE_ID  _sceneID,
const wxString &  rootUid 
) [virtual]

Import scene from file - SceneIOModule overload

Parameters:
[in] fname Path to scene files (archive)
[in] _sceneID ID of scene to be filled with data
[in] rootUid Uid of node where to start filling
Returns:
True if successful

Implements VRUT::IOModule.

Definition at line 62 of file iostl.cpp.

00063 {
00064        wxStopWatch sw;
00065        bool ret = false;
00066        wxInputStream * is = GetInputStream(fname);
00067        if (is)
00068        {
00069               //TODO!!!! convert to MT
00070               STLParser stlParser(is, _sceneID, fname, this);
00071               ret = stlParser.Parse(rootUid, recomputeNormals);
00072               delete is;
00073        }
00074        LOG(wxString::Format(wxT("<IOStlModule>Scene parsed in %.3f secs, ID %i"), 0.001f * sw.Time(), _sceneID));
00075        wxCommandEvent ev = Event::GET_EVT_IO_SCENE_IMPORT_DONE(_sceneID);
00076        PostToKernel(ev);
00077        return ret;
00078 }

bool IOStlModule::ExportScene ( const wxString &  fname,
const Scene scene 
) [virtual]

Export scene to file.

Implements VRUT::IOModule.

Definition at line 81 of file iostl.cpp.

00082 {
00083        wxOutputStream * sceneStream = new wxFileOutputStream(fname);
00084        if (sceneStream && sceneStream->IsOk())
00085        {
00086               wxBufferedOutputStream *sceneStream2=new wxBufferedOutputStream(*sceneStream);
00087               STLWriter stlWriter(sceneStream2, scene);
00088               stlWriter.Write(saveBinary);
00089               sceneStream2->Sync();
00090               SAFE_DELETE(sceneStream);
00091               return true;
00092        }
00093        SAFE_DELETE(sceneStream);
00094        return false;
00095 }


Member Data Documentation

Use binary output when exporting?

Definition at line 28 of file iostl.h.

saveBinary param identificator

Definition at line 30 of file iostl.h.

Recompute normals when importing?

Definition at line 32 of file iostl.h.

recomputeNormals param identificator

Definition at line 34 of file iostl.h.


The documentation for this class was generated from the following files:

Generated on Tue Mar 10 14:41:41 2009 for VRUT by  doxygen 1.5.5