<!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.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi deras vtkusers,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>i would like to read a mesh file (points 
coordinates and mesh caracteristics) and then draw it under a simple SDI MFC 
</FONT></DIV>
<DIV><FONT face=Arial size=2>application.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>So my idea was the following :</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>read the mesh file, and use the vtk Mesh structure 
to save data.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Mesh *m_pMaillage3D;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>then&nbsp;here is the code of the&nbsp;function 
which read the mesh file :</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>int CvtkMaillage::ReadMesh(char 
*nom_fichier){<BR>&nbsp;FILE *ft;<BR>&nbsp;long i,nb_elt_cot;<BR>&nbsp;char 
buffer[256];<BR>&nbsp;int dim_noe, dim_elt,nb_elt;<BR>&nbsp;long 
fin;<BR>&nbsp;int nb_car_lu2=0;<BR>&nbsp;int n1,n2,n3,n4;<BR>&nbsp;vtkIdType Id, 
nb_pts_cell;<BR>&nbsp;vtkIdType *IdList;<BR>&nbsp;vtkTetra* Element_Courant = 
vtkTetra::New();</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;if((ft=fopen(nom_fichier,"r"))!=NULL) 
{</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial 
size=2>&nbsp;&nbsp;fgets(buffer,256,ft);<BR>&nbsp;&nbsp;sscanf(buffer,"%d %d %d 
%d", &amp;this-&gt;m_pMaillage3D-&gt;vertices, &amp;dim_noe, 
&amp;this-&gt;m_pMaillage3D-&gt;faces, &amp;dim_elt) ;<BR>&nbsp;nb_elt_cot = 
this-&gt;m_pMaillage3D-&gt;faces;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; //Initialisation du tableau des 
points<BR>&nbsp;this-&gt;m_pMaillage3D-&gt;vertex = new 
Vector[this-&gt;m_pMaillage3D-&gt;vertices];<BR>&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp; //Tableau de connectivité des 
éléments<BR>&nbsp;&nbsp;&nbsp; this-&gt;m_pMaillage3D-&gt;aCellArray = 
vtkCellArray::New();<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp; for(i = 0 ; i&lt;this-&gt;m_pMaillage3D-&gt;vertices ; 
i++) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
fgets(buffer,256,ft);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
traitement_texte_reel(buffer);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
sscanf(buffer,"%lf %lf 
%lf",&amp;(this-&gt;m_pMaillage3D-&gt;vertex[i][0]),&amp;(this-&gt;m_pMaillage3D-&gt;vertex[i][1]),&amp;(this-&gt;m_pMaillage3D-&gt;vertex[i][2]));<BR>&nbsp;&nbsp;&nbsp; 
}&nbsp; <BR>&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;Element_Courant-&gt;PointIds-&gt;Initialize();<BR>&nbsp;Element_Courant-&gt;PointIds-&gt;Allocate(4);<BR>&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;fin = - 1;</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>&nbsp;for(i=0;i&lt;nb_elt_cot;i++) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
fgets(buffer,256,ft);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sscanf(buffer,"%d %d %d 
%d",&amp;n1,&amp;n2,&amp;n3,&amp;n4);<BR>&nbsp;&nbsp; 
Element_Courant-&gt;PointIds-&gt;InsertId(0, n1);<BR>&nbsp;&nbsp; 
Element_Courant-&gt;PointIds-&gt;InsertId(1, n2);<BR>&nbsp;&nbsp; 
Element_Courant-&gt;PointIds-&gt;InsertId(2, n3);<BR>&nbsp;&nbsp; 
Element_Courant-&gt;PointIds-&gt;InsertId(3, 
n4);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; Id = 
this-&gt;m_pMaillage3D-&gt;aCellArray-&gt;InsertNextCell(Element_Courant);&nbsp;<BR>&nbsp;&nbsp; 
/*maillage3D.topologie.tab_typeelt[i]=1;*/<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
if(fin==-1 &amp;&amp; n4==0) <BR>&nbsp;&nbsp;fin=i;<BR>&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; if(fin!=-1) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
nb_elt=fin;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
this-&gt;m_pMaillage3D-&gt;faces=nb_elt_cot-fin;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
this-&gt;m_pMaillage3D-&gt;face = new 
Face[this-&gt;m_pMaillage3D-&gt;faces];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(i 
= 0 ; i &lt; this-&gt;m_pMaillage3D-&gt;faces; i++) 
{<BR>&nbsp;&nbsp;this-&gt;m_pMaillage3D-&gt;aCellArray-&gt;GetCell(fin + i, 
nb_pts_cell, IdList);<BR>&nbsp;&nbsp;this-&gt;m_pMaillage3D-&gt;face[i].a = 
IdList[0];<BR>&nbsp;&nbsp;this-&gt;m_pMaillage3D-&gt;face[i].b = 
IdList[1];<BR>&nbsp;&nbsp;this-&gt;m_pMaillage3D-&gt;face[i].c = 
IdList[2];<BR>&nbsp;&nbsp;//free(maillage3D.topologie.tab_elt[fin+i]);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;&nbsp;&nbsp; else {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
nb_elt=nb_elt_cot;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp; <BR>&nbsp;&nbsp; 
fclose(ft);<BR>&nbsp;&nbsp; return 1;<BR>&nbsp; }<BR>&nbsp; return 
0;<BR>}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>as you can see, i first save&nbsp;number of 
vertices and number of faces.&nbsp;Then i first use&nbsp;</FONT>&nbsp;<FONT 
face=Arial size=2>m_pMaillage3D-&gt;vertex to save points coordinates. Then i 
use m_pMaillage3D-&gt;aCellArray to save elements connectivity of the mesh and 
m_pMaillage3D-&gt;face to save face.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>When I saved this data, i build a vtkActor using a 
vtk3DSImporter. I generate PolyData using vtk3DSImporter::GeneratePolyData. Then 
i build the actor as usual in vtk.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>But now mesh cant be drawn although i call a 
CView::OnPaint overroden method which call the vtkRenderer. Could you tell me if 
the data structures and the general idea to save my mesh in VTK is good ? How 
could I do better this method ?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>This project cant demonstrate my company that VTK 
is a useful library :)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Thanks a lot,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Frederic</FONT></DIV></BODY></HTML>