vtkVRMLImport
Tom Radcliffe
radcliffe at esg.ca
Mon Jun 21 13:27:07 EDT 1999
I'm using a tweaked version of vtkVRMLImport with quite a bit of
success. As well as Visual C++'s broken for-loop scoping, there
were a number of places where I had to fix up memory allocations
so the parser could be reused safely (I have an application where
the user can load any number of VRML files to view different
parts of the environment being visualized.) To do this I added
a ResetParser method that is appended below, and also added
a method to the VrmlNodeType class that deals with clearing it. This
is also shown below. Apart from these things, the parser has worked
really well, and I do not recall seeing the problem Thomas mentioned,
either under VC++5.0 or VC++6.0.
-- Tom
=====================================================
Tom Radcliffe Ph.D., P.Eng. ESG Canada Ltd.
Head of Software Development 1 Hyperion Court,
(613) 548-8287 x36 Kingston, Ontario
radcliffe at esg.ca CANADA K7K 7G3
=====================================================
// these are used by memyyInput
static int yyI = 0; // put these at global scope so can re-init
static int yyJ = 0;
void vtkVRMLImporter::ResetParser ()
{
creatingDEF = 0;
createdMF = 0;
curDEFName = 0;
free(yy_current_buffer->yy_ch_buf);
free(yy_current_buffer);
yy_current_buffer = 0;
yy_c_buf_p = (char*) 0;
yy_init = 1;
yy_start = 0;
yy_start_stack_ptr = 0;
yy_start_stack_depth = 0;
free(yy_start_stack);
yy_start_stack = 0;
parsing_mf = 0;
sfImageIntsParsed = 0;
sfImageIntsExpected = 0;
yyI = 0;
yyJ = 0;
int i;
int iEnd = useList.Count();
for (i = 0;i < iEnd;i++)
{
vtkVRMLUseStruct *pUseStruct = useList.Pop();
delete [] pUseStruct->defName;
delete pUseStruct;
}
iEnd = currentProtoStack.Count();
for (i = 0;i < iEnd; i++)
{
delete currentProtoStack.Pop();
}
VrmlNodeType::ClearTypeList();
}
and in VrmlNodeType:
static void ClearTypeList()
{
int i;
int iEnd = typeList.Count();
for(i = 0; i < iEnd; i++)
{
delete typeList.Pop();
}
}
-----------------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>. For help, send message body containing
"info vtkusers" to the same address. Live long and prosper.
-----------------------------------------------------------------------------
More information about the vtkusers
mailing list