<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16915" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Dear All:<BR></FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; I have been stuck in loading in 
and viewing the VRML files in the past two days. I found some codes online, and 
wrote my own based on those codes. However, there are some problems, always the 
access violation problem.&nbsp;I have tested on different files, some created by 
my collegues before, and some downloaded from the internet. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp; I post the code patch, anyone could 
help me?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>---------------------------------------------------------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>#include "vtkRenderer.h"<BR>#include 
"vtkRenderWindow.h"<BR>#include "vtkRenderWindowInteractor.h"</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>#include "vtkVRMLImporter.h"<BR>#include 
"vtkDataSet.h"<BR>#include "vtkActorCollection.h"<BR>#include 
"vtkPolyData.h"<BR>#include "vtkPolyDataMapper.h"<BR>#include 
"vtkPolyDataNormals.h"<BR>#include "vtkActor.h"</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>#include &lt;iostream&gt;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>int main (int argc, char **argv)<BR>{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;// VRML Import<BR>vtkVRMLImporter 
*importer=vtkVRMLImporter::New();<BR>//importer-&gt;SetFileName(argv[1]);<BR>importer-&gt;SetFileName(file 
name);<BR>importer-&gt;Read();<BR>importer-&gt;Update();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>//Convert to vtkDataSet<BR>vtkDataSet 
*pDataset;<BR>vtkActorCollection *actors = 
importer-&gt;GetRenderer()-&gt;GetActors();<BR>actors-&gt;InitTraversal();<BR><FONT 
color=#ff0000>pDataset = 
actors-&gt;GetNextActor()-&gt;GetMapper()-&gt;GetInput(); //Problem happened 
here</FONT></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>//Convert to vtkPolyData<BR>vtkPolyData *polyData = 
vtkPolyData::SafeDownCast(pDataset);<BR>polyData-&gt;Update();</FONT></DIV>
<DIV>&nbsp;</DIV><FONT face=Arial size=2>
<DIV><BR>// Create Normal Vectors to enhance smoothness &amp; illumination 
<BR>vtkPolyDataNormals *normals = 
vtkPolyDataNormals::New();<BR>normals-&gt;SetInput(polyData);<BR>normals-&gt;SetFeatureAngle(60.0);</DIV>
<DIV>&nbsp;</DIV>
<DIV>// Mapper<BR>vtkPolyDataMapper *SolidMapper = 
vtkPolyDataMapper::New();<BR>SolidMapper-&gt;SetInput(normals-&gt;GetOutput());<BR>SolidMapper-&gt;ScalarVisibilityOff(); 
</DIV>
<DIV>&nbsp;</DIV>
<DIV>// Actor<BR>vtkActor *SolidActor = 
vtkActor::New();<BR>SolidActor-&gt;SetMapper(SolidMapper);<BR>//SolidActor-&gt;GetProperty()-&gt;SetOpacity(1);</DIV>
<DIV>&nbsp;</DIV>
<DIV>// Render<BR>vtkRenderer *ren = 
vtkRenderer::New();<BR>ren-&gt;AddActor(SolidActor); 
<BR>ren-&gt;SetBackground(1,1,1);</DIV>
<DIV>&nbsp;</DIV>
<DIV>// RenderWindow<BR>vtkRenderWindow *renWin = 
vtkRenderWindow::New();<BR>renWin-&gt;AddRenderer(ren);</DIV>
<DIV>&nbsp;</DIV>
<DIV>// RenderWindowInteractor<BR>vtkRenderWindowInteractor *iren = 
vtkRenderWindowInteractor::New();<BR>iren-&gt;SetRenderWindow(renWin);</DIV>
<DIV>&nbsp;</DIV>
<DIV>renWin-&gt;Start(); <BR>renWin-&gt;SetSize(800-5,600-5); // Must be Called 
after Start() and before Render() <BR>// interact with 
data<BR>iren-&gt;Initialize();<BR>iren-&gt;Start();</DIV>
<DIV>&nbsp;</DIV>
<DIV>// delete </DIV>
<DIV>&nbsp;</DIV>
<DIV>actors-&gt;Delete();</DIV>
<DIV>normals-&gt;Delete(); <BR>SolidMapper-&gt;Delete(); 
<BR>SolidActor-&gt;Delete();<BR>ren-&gt;Delete(); 
<BR>renWin-&gt;Delete();<BR>iren-&gt;Delete();</DIV>
<DIV>&nbsp;</DIV>
<DIV>return 0;<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>----------------------------------------------------------------------------------------------------------------------------------------------</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;</DIV></FONT>
<DIV><FONT face=Arial size=2>Best 
Wishes,<BR>-----------------------------------------------------------------------------<BR>Dongqing 
Chen, Ph.D.<BR>Computer Vision &amp; Image Processing (CVIP) Lab<BR>Department 
of Electrical &amp; Computer Engineering<BR>Speed School of 
Engineering<BR>University of Louisville<BR>Louisville, KY, 
40292<BR>U.S.A<BR>email: <A 
href="mailto:dqchen@cvip.louisville.edu">dqchen@cvip.louisville.edu</A><BR>phone: 
1-502-852-2789 
(Lab)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
1-502-852-6130 
(Office)<BR>----------------------------------------------------------------------------</FONT></DIV></BODY></HTML>