Hi ;)<div><br></div><div>I am trying to make writer to txt file to format  like this :</div><div><pre class="de1" style="padding:0px;border:0px none white;background-color:rgb(255,255,255);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top;text-align:left">
number_of_points
number_of_triangles
point[0]X point[0]Y point[0]Z
point[1]X point[1]Y point[1]Z
...
point[N]X point[N]Y point[N]Z
triangle[0]A triangle[0]B triangle[0]C
triangle[1]A triangle[1]B triangle[1]C
...
triangle[M]A triangle[M]B triangle[M]C</pre><pre class="de1" style="padding:0px;border:0px none white;background-color:rgb(255,255,255);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top;text-align:left">
<br></pre><pre class="de1" style="padding:0px;border:0px none white;background-color:rgb(255,255,255);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top;text-align:left">
<br></pre><pre class="de1" style="padding:0px;border:0px none white;background-color:rgb(255,255,255);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top;text-align:left">
<br></pre><pre class="de1" style="padding:0px;border:0px none white;background-color:rgb(255,255,255);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top;text-align:left">
<br></pre><pre class="de1" style="padding:0px;border:0px none white;background-color:rgb(255,255,255);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top;text-align:left">
I have written correctly numer of points, triangles and points .. </pre><pre class="de1" style="padding:0px;border:0px none white;background-color:rgb(255,255,255);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top;text-align:left">
I have problem with writing triangle :</pre><pre class="de1" style="padding:0px;border:0px none white;background-color:rgb(255,255,255);line-height:1.2em;font-size:10px;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top;text-align:left">
<pre class="de1" style="padding:0px;border:0px none white;line-height:1.2em;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top">triangle[0]A triangle[0]B triangle[0]C</pre><pre class="de1" style="padding:0px;border:0px none white;line-height:1.2em;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top">
<br></pre><pre class="de1" style="padding:0px;border:0px none white;line-height:1.2em;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top"><br></pre><pre class="de1" style="padding:0px;border:0px none white;line-height:1.2em;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top">
Here this is my code :</pre><pre class="de1" style="padding:0px;border:0px none white;line-height:1.2em;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top">Could You look at this code please ?</pre>
<pre class="de1" style="padding:0px;border:0px none white;line-height:1.2em;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top">I don&#39;t have any idea ? </pre><pre class="de1" style="padding:0px;border:0px none white;line-height:1.2em;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top">
What I could extract polys-&gt;GetCell ().. ?</pre><pre class="de1" style="padding:0px;border:0px none white;line-height:1.2em;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top"><br></pre><pre class="de1" style="padding:0px;border:0px none white;line-height:1.2em;margin-top:0px;margin-bottom:0px;background-image:none;vertical-align:top">

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&lt;vtkSmartPointer.h&gt;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&lt;vtkPolyData.h&gt;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&lt;vtkDelimitedTextWriter.h&gt;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&lt;vtkPolyDataReader.h&gt;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&lt;vtkSphereSource.h&gt;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&lt;vtkVariantArray.h&gt;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&lt;vtkPolyData.h&gt;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#000080">#include</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&lt;vtkTable.h&gt;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#808000">int</span><span style="color:#c0c0c0"> </span>main(<span style="color:#808000">int</span><span style="color:#c0c0c0"> </span>argc,<span style="color:#c0c0c0"> </span><span style="color:#808000">char</span><span style="color:#c0c0c0"> </span>*argv[])</pre>

<pre style="margin-top:0px;margin-bottom:0px">{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#008000">//</span><span style="color:#c0c0c0"> </span><span style="color:#008000">Polydata</span><span style="color:#c0c0c0"> </span><span style="color:#008000">reader</span><span style="color:#c0c0c0"> </span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">vtkPolyDataReader</span>*<span style="color:#c0c0c0"> </span>reader<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#800080">vtkPolyDataReader</span>::New();</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>reader-&gt;<span style="font-style:italic">SetFileName</span>(<span style="color:#008000">&quot;SimpleMesh.vtk&quot;</span>);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>reader-&gt;<span style="font-style:italic">Update</span>();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">vtkPolyData</span>*polydata<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>reader-&gt;GetOutput();</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">vtkPoints</span>*<span style="color:#c0c0c0"> </span>points<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>polydata-&gt;<span style="font-style:italic">GetPoints</span>();</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">vtkCellArray</span>*<span style="color:#c0c0c0"> </span>polys<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>polydata-&gt;GetPolys();</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>polydata-&gt;<span style="font-style:italic">SetPoints</span>(points);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>polydata-&gt;SetPolys(polys);</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#008000">//</span><span style="color:#c0c0c0"> </span><span style="color:#008000">Write</span><span style="color:#c0c0c0"> </span><span style="color:#008000">to</span><span style="color:#c0c0c0"> </span><span style="color:#008000">txt</span><span style="color:#c0c0c0"> </span><span style="color:#008000">file</span><span style="color:#c0c0c0"> </span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#808000">const</span><span style="color:#c0c0c0"> </span><span style="color:#808000">char</span>*<span style="color:#c0c0c0"> </span>filename<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;plik4.txt&quot;</span>;</pre>

<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">std</span>::<span style="color:#800080">fstream</span><span style="color:#c0c0c0"> </span>infile;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>infile.open(filename);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#800080">vtkIdType</span><span style="color:#c0c0c0"> </span>number_of_points,<span style="color:#c0c0c0"> </span>number_of_triangles;</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>number_of_points<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0">  </span>polydata-&gt;<span style="font-style:italic">GetNumberOfPoints</span>();</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>infile&lt;&lt;number_of_points&lt;&lt;<span style="color:#800080">std</span>::endl;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">   </span>number_of_triangles<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span>polydata-&gt;<span style="font-style:italic">GetNumberOfCells</span>();</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">   </span>infile&lt;&lt;number_of_triangles&lt;&lt;<span style="color:#800080">std</span>::endl;</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#808000">for</span><span style="color:#c0c0c0"> </span>(<span style="color:#800080">vtkIdType</span><span style="color:#c0c0c0"> </span>i<span style="color:#c0c0c0"> </span>=<span style="color:#c0c0c0"> </span><span style="color:#000080">0</span>;<span style="color:#c0c0c0"> </span>i<span style="color:#c0c0c0"> </span>&lt;<span style="color:#c0c0c0"> </span>number_of_points;<span style="color:#c0c0c0"> </span>i++)</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>{</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">      </span><span style="color:#808000">double</span><span style="color:#c0c0c0"> </span>p[<span style="color:#000080">3</span>];</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">      </span>points-&gt;GetPoint(i,p);</pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">      </span>infile<span style="color:#c0c0c0"> </span>&lt;&lt;p[<span style="color:#000080">0</span>]&lt;&lt;<span style="color:#008000">&quot;</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;</span>&lt;&lt;<span style="color:#c0c0c0"> </span>p[<span style="color:#000080">1</span>]&lt;&lt;<span style="color:#008000">&quot;</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;</span>&lt;&lt;p[<span style="color:#000080">2</span>];</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">      </span>infile&lt;&lt;<span style="color:#008000">&quot;</span><span style="color:#c0c0c0"> </span><span style="color:#008000">&quot;</span>&lt;&lt;<span style="color:#800080">std</span>::endl;</pre>

<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>}</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><b><font color="#ff0000">// HERE ?? 
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">  for (vtkIdType i = 0; i &lt; number_of_triangles; i++)</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">  {</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">      vtkIdType a, b, c;</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">      infile &lt;&lt; a &lt;&lt; b &lt;&lt; c &lt;&lt;std::endl;</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000"><br></font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">      double t[3];</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000"><br></font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">      points-&gt;GetPoint(i,t);</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">      infile &lt;&lt;t[0]&lt;&lt;&quot; &quot;&lt;&lt; t[1]&lt;&lt;&quot; &quot;&lt;&lt;t[2];</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">      infile&lt;&lt;&quot; &quot;&lt;&lt;std::endl;</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000"><br></font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000"><br></font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">     // polys-&gt;Ge</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">     //  polys-&gt;InsertCellPoint(a-1);</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">       //     polys-&gt;InsertCellPoint(b-1);</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">     //  polys-&gt;InsertCellPoint(c-1);</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000"><br></font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">      //      double t[3];</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">      //      points-&gt;GetPoint(i,t);</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">      //      infile&lt;&lt;t[0]&lt;&lt;t[1]&lt;&lt;t[2]&lt;&lt;std::endl;</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000"><br></font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000">  }</font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000"><br></font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000"><br></font></b></pre><b><font color="#ff0000">
</font></b><pre style="margin-top:0px;margin-bottom:0px"><b><font color="#ff0000"><br></font></b></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span>infile.close();</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:#c0c0c0">  </span><span style="color:#808000">return</span><span style="color:#c0c0c0"> </span>EXIT_SUCCESS;</pre>
<pre style="margin-top:0px;margin-bottom:0px">}</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">I would appreciate for any help please.</pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px">agatte</pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre><pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre></pre></pre></div>