<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font size="-1">Hi Cory,<br>
      Here's a java example below. Also attached with some_points.txt
      file (warning: z, theta, dR and not x,y,z).  Just comment the dRi
      sign change line in order to change the scalars from negative to
      positive.<br>
      Thanks,<br>
      Jim<br>
    </font><br>
    import java.awt.BorderLayout;<br>
    import java.io.BufferedReader;<br>
    import java.io.File;<br>
    import java.io.FileNotFoundException;<br>
    import java.io.FileReader;<br>
    import java.io.IOException;<br>
    import javax.swing.JFrame;<br>
    import javax.swing.JPanel;<br>
    import javax.swing.SwingUtilities;<br>
    import vtk.*;<br>
    <br>
    public class PlotSpheres extends JPanel {<br>
    <br>
        public static void main(String[] args) throws
    FileNotFoundException {<br>
            SwingUtilities.invokeLater(new Runnable() {<br>
                public void run() {<br>
                    JFrame frame = new JFrame("PlotSheres");<br>
                   
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);<br>
                    frame.getContentPane().setLayout(new
    BorderLayout());<br>
                    try {<br>
                        frame.getContentPane().add(new PlotSpheres(),<br>
                                BorderLayout.CENTER);<br>
                    } catch (FileNotFoundException e) {<br>
                        e.printStackTrace();<br>
                    }<br>
                    frame.setSize(1000, 1000);<br>
                    frame.setVisible(true);<br>
                }<br>
            });<br>
        }<br>
    <br>
        // Load VTK libraries<br>
        static {<br>
            if (!vtkNativeLibrary.LoadAllNativeLibraries()) {<br>
                for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {<br>
                    if (!lib.IsLoaded())<br>
                        System.out.println(lib.GetLibraryName() + " not
    loaded");<br>
                }<br>
                System.out.println("Make sure the search path is
    correct: ");<br>
               
    System.out.println(System.getProperty("java.library.path"));<br>
            }<br>
            vtkNativeLibrary.DisableOutputWindow(null);<br>
        }<br>
    <br>
        // Variables<br>
        private String dataFile;<br>
        private String dataFilePathString;<br>
        Double[] xValsArray = new Double[41];<br>
        Double[] yValsArray = new Double[721];<br>
        Double[][] zValsArray = new Double[41][721];<br>
        private vtkRenderWindowPanel renderWindowPanel = new
    vtkRenderWindowPanel();<br>
        private vtkPoints points;<br>
        private int pointsNum;<br>
        private vtkRenderWindowInteractor renderWindowInteractor;<br>
        private vtkPolyData polyData = new vtkPolyData();<br>
        private vtkFloatArray colorsScalars;<br>
    <br>
        public PlotSpheres() throws FileNotFoundException {<br>
            super(new BorderLayout());<br>
            dataFilePathString = "C:\\vtk123";<br>
            dataFile = "some_points.txt";<br>
            calcSheres();<br>
            System.out.println("calcSheres done");<br>
        }<br>
    <br>
        public void calcSheres() throws FileNotFoundException {<br>
            try {<br>
                renderWindowPanel.GetRenderer().RemoveAllViewProps();<br>
            } catch (Exception nullEx) {<br>
                System.out.println("renderWindowPanel props are null.");<br>
            }<br>
            <br>
            // Read the file<br>
            // Count the lines in the file<br>
            BufferedReader br_count = new BufferedReader(new FileReader(<br>
                    dataFilePathString + File.separator + dataFile));<br>
            String lineData = null;<br>
            int lineNum = 0;<br>
            try {<br>
                lineData = br_count.readLine();<br>
                // The first data line has just been read<br>
                while (lineData != null) {<br>
                    // Do nothing except increment the counter       
            <br>
                    lineNum = lineNum + 1; // on iteration 1, lineNum =
    1<br>
                    // Read blank line<br>
                    lineData = br_count.readLine();<br>
                    // Next action is in for the  br_count.readLine()
    (the<br>
                    // next data line)<br>
                    lineData = br_count.readLine();<br>
                    System.out.println("lineNum = " + lineNum + "   " +
    lineData);<br>
                }<br>
            } catch (Exception e) {<br>
                e.printStackTrace();<br>
                System.out.println("Datafile line counting error");<br>
            }<br>
            try {<br>
                br_count.close();<br>
            } catch (IOException e) {<br>
                System.out.println("Error closing br_count");<br>
                e.printStackTrace();<br>
            }<br>
            <br>
            BufferedReader br = new BufferedReader(new FileReader(<br>
                    dataFilePathString + File.separator + dataFile));<br>
            // Set number of data point sets (x,y,z sets)<br>
            pointsNum = lineNum;<br>
            <br>
            // Fill colorsScalars array with the actual scalar values<br>
            // Initialize/reinitialize variables<br>
            String linej;<br>
            int indexNum = 0;<br>
            points = new vtkPoints();<br>
            points.SetNumberOfPoints(pointsNum);<br>
            Double ZPOSi;<br>
            Double theta;<br>
            Double dRi;<br>
            Double tempx;<br>
            Double tempy;<br>
            Double tempz;<br>
            // colorsScalars is the array of native (pos or neg) scalars<br>
            // the sign is changed to meet the required application
    convention<br>
            // the sign change line can be used to show difference
    between <br>
            // plotting of positive and negative scalars<br>
            colorsScalars = new vtkFloatArray();<br>
            colorsScalars.SetNumberOfTuples(pointsNum);<br>
            String[] linejArray = {};<br>
            try {<br>
                linej = br.readLine();<br>
                while (linej != null) {<br>
                    linejArray = linej.split("\\s+");<br>
                    ZPOSi = Double.parseDouble(linejArray[1]); // Z
    position (m)<br>
                    theta = Double.parseDouble(linejArray[2]); // theta
    (deg)<br>
                    dRi = Double.parseDouble(linejArray[3]); // dRi (m)<br>
                    // dRi negative value means smaller than nominal
    radius<br>
                    // tempx = (r - dr) * cos(theta)<br>
                    // tempy = (r - dr) * sin(theta)<br>
                    // tempz = ZPOSi<br>
                    tempx = (.094629 - dRi) * Math.cos((3.14159 / 180) *
    theta);<br>
                    tempy = (.094629 - dRi) * Math.sin((3.14159 / 180) *
    theta);<br>
                    tempz = ZPOSi;<br>
                    points.SetPoint(indexNum, tempx, tempy, tempz);<br>
                    System.out.println(tempx + " " + tempy + " " +
    tempz);<br>
                    // Account for convention used in application<br>
                    // Change sign of dRi:<br>
                    dRi *= -1;<br>
                    colorsScalars.SetValue(indexNum, dRi);<br>
                    indexNum = indexNum + 1;<br>
                    System.out.println("indexNum = " + indexNum<br>
                            + "......... dRi  = " + dRi);<br>
                    linej = br.readLine();<br>
                    // (Account for blank line...)<br>
                    linej = br.readLine();<br>
                }<br>
            } catch (Exception ex) {<br>
                ex.printStackTrace();<br>
                System.out.println("Error reading datafile");<br>
            }<br>
            try {<br>
                br_count.close();<br>
            } catch (IOException e) {<br>
                System.out.println("Error closing br_count");<br>
                e.printStackTrace();<br>
            }<br>
    <br>
            // populate the polyData<br>
            this.polyData.SetPoints(points);<br>
            <br>
            // find min and max of colorsScalars array<br>
            double[] tmpScalarRange = new double[2];<br>
            tmpScalarRange = this.colorsScalars.GetRange();<br>
            Double scalarMax = tmpScalarRange[1];<br>
            Double scalarMin = tmpScalarRange[0];<br>
    <br>
            // populate the scalars<br>
            this.polyData.GetPointData().SetScalars(this.colorsScalars);<br>
    <br>
            // create sphere source<br>
            vtkSphereSource sphere = new vtkSphereSource();<br>
            sphere.Update();<br>
    <br>
            // setup glyph3D<br>
            vtkGlyph3D glyph3D = new vtkGlyph3D();<br>
            glyph3D.SetColorModeToColorByScalar();<br>
            glyph3D.SetSourceConnection(sphere.GetOutputPort());<br>
            glyph3D.SetInputData(polyData);<br>
            glyph3D.Update();<br>
    <br>
            // visualize<br>
            vtkDataSetMapper mapper = new vtkDataSetMapper();<br>
            mapper.SetInputConnection(glyph3D.GetOutputPort());<br>
            mapper.SetScalarRange(scalarMin, scalarMax);<br>
            mapper.Update();<br>
            <br>
            vtkActor actor = new vtkActor();<br>
            actor.GetProperty().SetSpecularPower(1.0);<br>
            actor.GetProperty().SetDiffuse(1.0);<br>
            actor.GetProperty().SetOpacity(1.0);<br>
            actor.SetMapper(mapper);<br>
    <br>
            vtkRenderer renderer = new vtkRenderer();<br>
            renderer = renderWindowPanel.GetRenderer();<br>
            renderer.AddActor(actor);<br>
            renderer.SetBackground(0.0, 0.0, 0.0);<br>
            renderer.ResetCameraClippingRange();<br>
    <br>
            // Create a lookup table to share between the mapper and the
    scalarbar<br>
            vtkLookupTable hueLut = new vtkLookupTable();<br>
            hueLut.SetTableRange(scalarMin, scalarMax);<br>
            hueLut.SetHueRange(0.6667, 0.0000); // H from HSV red (top)
    to blue<br>
            hueLut.SetSaturationRange(1.0, 1.0);<br>
            hueLut.SetValueRange(1.0, 1.0); // V from HSV<br>
            hueLut.Build();<br>
            mapper.SetLookupTable(hueLut);<br>
            mapper.Update();<br>
            <br>
            vtkScalarBarWidget sbWidget = new vtkScalarBarWidget();<br>
            sbWidget.RepositionableOn();<br>
            renderWindowInteractor =
    renderWindowPanel.getRenderWindowInteractor();<br>
            sbWidget.SetInteractor(renderWindowInteractor);<br>
            sbWidget.GetScalarBarActor().SetTitle("dR (m)");<br>
           
    sbWidget.GetScalarBarActor().SetLookupTable(mapper.GetLookupTable());<br>
            <br>
            vtkTextProperty SBtprop = new vtkTextProperty();<br>
            SBtprop.SetFontSize(1);<br>
            SBtprop.SetBold(1);<br>
            sbWidget.GetScalarBarActor().SetLabelTextProperty(SBtprop);<br>
            sbWidget.GetScalarBarActor().SetBarRatio(.7);<br>
            SBtprop.SetLineOffset(-10);<br>
    <br>
            renderer.ResetCameraClippingRange();<br>
    <br>
            vtkCubeAxesActor2D axes = new vtkCubeAxesActor2D();<br>
            axes.SetCamera(renderer.GetActiveCamera());<br>
            axes.SetBounds(actor.GetBounds());<br>
            axes.SetFlyModeToOuterEdges();<br>
            renderer.AddActor(axes);<br>
            renderer.ResetCamera();<br>
            sbWidget.EnabledOn();<br>
            <br>
            System.out.println("B4 this.add");<br>
            this.add(renderWindowPanel, BorderLayout.CENTER);<br>
    <br>
            renderer.ResetCamera();<br>
            renderWindowInteractor.Start();<br>
        }<br>
    }<br>
    <br>
    <div class="moz-cite-prefix">On 8/31/2015 10:08 AM, Cory Quammen
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAB5Fpx7UaE68G6rWOUW3JtQT_AbrtbxPsyr=FOdmbGHiJwmrAQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hmm, that should work. Mind posting a code example
        showing the problem?
        <div><br>
        </div>
        <div>Thanks,</div>
        <div>Cory</div>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Mon, Aug 31, 2015 at 9:51 AM, James
          Labiak <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:jim@jslengineeringsoftware.com"
              target="_blank">jim@jslengineeringsoftware.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">(vtk 6.0,
            Java wrapper) When using a vtkLookUpTable to map scalar
            values to hue range, it appears that everything works
            correctly when the table range is entirely positive, but
            when the table range is entirely negative, the graphical
            output is blank. If this is intended behavior, then I would
            make my own LUT except for mapper.SetLookupTable(hueLut). Is
            this likely my error or a LUT issue?<br>
            _______________________________________________<br>
            Powered by <a moz-do-not-send="true"
              href="http://www.kitware.com" rel="noreferrer"
              target="_blank">www.kitware.com</a><br>
            <br>
            Visit other Kitware open-source projects at <a
              moz-do-not-send="true"
              href="http://www.kitware.com/opensource/opensource.html"
              rel="noreferrer" target="_blank"><a class="moz-txt-link-freetext" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a></a><br>
            <br>
            Please keep messages on-topic and check the VTK FAQ at: <a
              moz-do-not-send="true"
              href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer"
              target="_blank"><a class="moz-txt-link-freetext" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a></a><br>
            <br>
            Search the list archives at: <a moz-do-not-send="true"
              href="http://markmail.org/search/?q=vtkusers"
              rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
            <br>
            Follow this link to subscribe/unsubscribe:<br>
            <a moz-do-not-send="true"
              href="http://public.kitware.com/mailman/listinfo/vtkusers"
              rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        <div class="gmail_signature">Cory Quammen<br>
          R&D Engineer<br>
          Kitware, Inc.</div>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
James Labiak
JSL Engineering and Software
Mobile: 231-638-3725
email: <a class="moz-txt-link-abbreviated" href="mailto:jim@jslengineeringsoftware.com">jim@jslengineeringsoftware.com</a></pre>
  </body>
</html>