# Paraview PTSReader misses the first point

**URL:** https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495
**Category:** ParaView Support
**Created:** [February 18, 2021, 2:22am UTC](https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495 "2021-02-18T02:22:05Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![alex\_xu](https://discourse.paraview.org/user_avatar/discourse.paraview.org/alex_xu/32/5937_2.png) [@alex\_xu](https://discourse.paraview.org/u/alex_xu)
#### Post date: [February 18, 2021, 2:22am UTC](https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495/1 "2021-02-18T02:22:05Z")

</div>

I try to read .pts file in the Paraview.  
here is one point in the test.pts file. the content is as follows:  
7.75 14.28 19.08

Based on the source code here

> <https://github.com/Kitware/VTK/blob/master/IO/Geometry/vtkPTSReader.cxx>

There should be one point read in the Paraview.  
However, there is no point at all.  
 ![image](https://discourse.paraview.org/uploads/default/original/2X/7/7409be9dbcef91bd44f8dfedf28779c7da4768ba.png)

Furthermore, when I have two points in the test.pts, such as  
7.75 14.28 19.08  
7.75 14.28 20.08

I will have only 1 point (the 2nd point) in the Paraview.

What need I do to have all points in the .pts file?  
Thanks!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [February 18, 2021, 8:37am UTC](https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495/2 "2021-02-18T08:37:26Z")

</div>

Please share your data.

---

<div class="post-metadata">

### Author: ![aron.helser](https://discourse.paraview.org/user_avatar/discourse.paraview.org/aron.helser/32/13_2.png) [@aron.helser](https://discourse.paraview.org/u/aron.helser)
#### Post date: [February 18, 2021, 1:11pm UTC](https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495/3 "2021-02-18T13:11:06Z")

</div>

The comments in the source code you link make it a little more clear what is expected:  
[https://github.com/Kitware/VTK/blob/master/IO/Geometry/vtkPTSReader.cxx#L164](https://github.com/Kitware/VTK/blob/master/IO/Geometry/vtkPTSReader.cxx#L164)  
The first line of the .pts file should contain the number of points to be read.

---

<div class="post-metadata">

### Author: ![alex\_xu](https://discourse.paraview.org/user_avatar/discourse.paraview.org/alex_xu/32/5937_2.png) [@alex\_xu](https://discourse.paraview.org/u/alex_xu)
#### Post date: [February 18, 2021, 1:16pm UTC](https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495/4 "2021-02-18T13:16:35Z")

</div>

[test1.pts](https://discourse.paraview.org/uploads/short-url/iQrgcRuvIJZ8kz2SeNwFNASsbCZ.pts) (16 Bytes) [test2.pts](https://discourse.paraview.org/uploads/short-url/5aorCIhH5Y67yYl85s6OkaqDfpx.pts) (18 Bytes)

Here are two test .pts files.  
Each file has only one point.

test1.pts has point only.  
test2.pts has the # of points at the first line.

---

<div class="post-metadata">

### Author: ![alex\_xu](https://discourse.paraview.org/user_avatar/discourse.paraview.org/alex_xu/32/5937_2.png) [@alex\_xu](https://discourse.paraview.org/u/alex_xu)
#### Post date: [February 18, 2021, 1:19pm UTC](https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495/5 "2021-02-18T13:19:12Z")

</div>

I tried both formats. You can find two test files in this thread.

Furthermore,

> <https://github.com/Kitware/VTK/blob/fb8caa82f798b8015119aed8b1db940c09dd81f7/IO/Geometry/vtkPTSReader.cxx#L181>

  
It also shows that we can have points-only content.

---

<div class="post-metadata">

### Author: ![aron.helser](https://discourse.paraview.org/user_avatar/discourse.paraview.org/aron.helser/32/13_2.png) [@aron.helser](https://discourse.paraview.org/u/aron.helser)
#### Post date: [February 18, 2021, 1:25pm UTC](https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495/6 "2021-02-18T13:25:44Z")

</div>

Cool - do you see any issue with the code?

---

<div class="post-metadata">

### Author: ![alex\_xu](https://discourse.paraview.org/user_avatar/discourse.paraview.org/alex_xu/32/5937_2.png) [@alex\_xu](https://discourse.paraview.org/u/alex_xu)
#### Post date: [February 18, 2021, 2:36pm UTC](https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495/7 "2021-02-18T14:36:41Z")

</div>

I just looked through the code.  
The issue may be here:

> <https://github.com/Kitware/VTK/blob/fb8caa82f798b8015119aed8b1db940c09dd81f7/IO/Geometry/vtkPTSReader.cxx#L332>

let’s say onRatio = 1.0  
when we process the first point,  
lastCount = 0  
i = 0  
i \* onRatio = 0  
floor(i \* onRatio) \> lastCount is always false, lastCount remains 0  
we miss the 1st point

however, in the following points  
lastCount = 0  
i = 1  
i \* onRatio = 1.0  
floor(i \* onRatio) \> lastCount is true  
we have the 2nd point,  
lastCount becomes 1

then, i = 2, etc.

what’s more, even we set the Max Number of points  
( onRatio = static\_cast(this-\>MaxNumberOfPoints) / numPts;),  
floor(i \* onRatio) \> lastCount doesn’t work as well IMHO.

I don’t understand why we need onRatio here,  
why not use  
if (this-\>MaxNumberOfPoints \> lastCount)

But, I haven’t tested it yet. I am not very familiar with Paraview/VTK. And, my current work doesn’t allow me spend more time in debugging the vtkPTSReader. That’s the reason I posted this help-thread. Sorry about that.

---

<div class="post-metadata">

### Author: ![alex\_xu](https://discourse.paraview.org/user_avatar/discourse.paraview.org/alex_xu/32/5937_2.png) [@alex\_xu](https://discourse.paraview.org/u/alex_xu)
#### Post date: [February 25, 2021, 8:58pm UTC](https://discourse.paraview.org/t/paraview-ptsreader-misses-the-first-point/6495/8 "2021-02-25T20:58:11Z")

</div>

It seems that I forgot to @ you in the previous post, please take a look at my previous post.  
thank you 🙂
