<div dir="ltr"><div>Hi Galera,</div><div><br></div><div>This doesn't look like a bug.  This is related to numerical precision.</div><div><br></div><div> 10000000000.0 - 1.0 -> 9999999999.0<br></div>







<div> 1.7976931348623157e+308 - 1.0 -> 1.7976931348623157e+308</div><div><br></div><div>If you subtract 1 from Double.MAX_VALUE, the result is Double.MAX_VALUE.</div><div>Floating point math is not exact, a double only has around 16 significant digits.<br></div><div><br></div><div>In other words, instead of subtracting 1, you should do this:</div><div><br></div><div>  threshold.ThresholdByLower(thresholdValue - thresholdValue*eps);</div><div><br></div><div>where eps=2.220446049250313e-16 is the double epsilon.</div>







<div><br></div><div> - David</div><div><br></div><div><br></div><div class="gmail_extra"><div class="gmail_quote">On Thu, Mar 17, 2016 at 12:07 PM, galera <span dir="ltr"><<a href="mailto:tonio.guillen@gmail.com" target="_blank">tonio.guillen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi all,<br>
<br>
I found a bug with the java wrapper for example:<br>
<br>
                        double thresholdValue = Math.pow(10, 10);<br>
                        vtkRectilinearGrid input = (vtkRectilinearGrid)<br>
this.getInput().getValue();<br>
                        vtkDataArray values = input.GetCellData().GetScalars();<br>
<br>
                        int k;<br>
                        for(int i = 0; i < input.GetNumberOfCells(); i++) {<br>
                                double x = 0, y = 0, z = 0;<br>
                                for(k = 0; k < input.GetCell(i).GetPoints().GetNumberOfPoints(); k++) {<br>
                                        double[] pcoords = input.GetCell(i).GetPoints().GetPoint(k);<br>
                                        x += pcoords[0];<br>
                                        y += pcoords[1];<br>
                                        z += pcoords[2];<br>
                                }<br>
                                Point3D p = new Point3D(x/k, y/k, z/k);<br>
                                int rank = model.rank(p, true);<br>
                                if (!this.getEntities().contains(model.getFormationWithRank(rank ))) {<br>
                                        values.SetTuple1(i, thresholdValue);<br>
                                }<br>
                        }<br>
                        input.GetCellData().SetScalars(values);<br>
                        vtkThreshold threshold = new vtkThreshold();<br>
                        threshold.SetInputData(input);<br>
                        threshold.ThresholdByLower(thresholdValue-1.);<br>
<br>
                        threshold.Update();<br>
<br>
                        vtkUnstructuredGrid output = threshold.GetOutput();<br>
                        Pipe<vtkUnstructuredGrid> pipe = FilterFactory.eINSTANCE.createPipe();<br>
                        pipe.setValue(output);<br>
                        this.getOutput().add(pipe);<br>
<br>
<br>
This code work fine if you set:<br>
 double thresholdValue = Math.pow(10, 10);<br>
<br>
if you set:<br>
double thresholdValue = Double.MAX_VALUE;<br>
<br>
you have a bug.<br>
<br>
Galera<br><br>
</blockquote></div><br></div></div>