LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

3D Object - Draw Cylinder from array data

Solved!
Go to solution
Highlighted

I have a system that is generating about 1200 X-Y data points that represent a circle (which is about 30mm in radius). I generate this data pretty frequently and store it in a data file with a Z distance for each X-Y data set.

 

My question is: If I were trying to mesh all of these data sets together to visualize a cylinder, what would the best method be for doing that? Unfortunately, the X-Y data points don't line up neatly and won't always have exactly 1200 points. The circles themselves should be equally spaced (in the Z direction).

 

Currently using LV 2017.

Thanks for the help in advance!

0 Kudos
Message 1 of 24
(261 Views)

If I understand you correctly, you have a set of points with X, Y, Z coordinates that are supposed to lie on the surface of a cylinder.  Have you tried plotting them using the 3D Graph plot in LabVIEW?  You haven't posted either code (don't bother posting a picture) or a file with data for us to try out ...

 

Bob Schor

0 Kudos
Message 2 of 24
(244 Views)

Do you need it to draw a surface or can it be a point cloud?

0 Kudos
Message 3 of 24
(231 Views)

That is correct, They all lie on the surface of this cylinder. I apologize for not posting example code or data sooner.

 

I have attached a rough example of the code I have tried. (Note: LV version 2017 w/ OpenG function used)

I have also attached a text file with the raw data in it. Data is split by columns where each "slice" is three columns (X data, Y data, Z data). When you run the example using the .txt file the differences in array length of each "slice" cause 0's to appear which cause problems in the surface plot. The way I use the code in my  program I read each "slice" by itself THEN normalize to 1280 points THEN plot. This takes care of the differing array lengths. All that to say: I am not worried about the points inside the cylinder for now. I posted a file with data all in the same table because I figure one text document was better than nine.

 

Back to the problem at hand:

My biggest problem with this outcome is that the graph itself is not very malleable. It can only show whats inside the "cube" and when you add more data it just squishes the data to make it fit inside the same display area. In an ideal world the cylinder would be able to grow (only to a certain extent) and the user could pan around it and down its length. I am basing my visualizations off of how SolidWorks or AutoDesk would do it.

 

I have not been able to make a point cloud work well enough where I can see the undulations on the surface of the cylinder.

0 Kudos
Message 4 of 24
(189 Views)
Solution
Accepted by topic author RyanLC
06-20-2019 08:21 AM

In general I've found the surface plot to be pretty unreliable. It has a memory leak in it that causes programs to crash if run for large periods of time. It is much better to use just the options that the 3d picture control give you. By doing this and using the right camera controller you can achieve results similar to how a cad program might work. The hard part here comes with setting your settings in a way that your model is easily viewable.

 

I'm not entirely sure I understand what your data is exactly or how you collect it, but assuming that you have a list of points that lay on a surface you should be able to use my attached example and end up with something usable.

 

The vi that I've written to display arbitrary models which could easily be converted into something to just draw cylinders. In spherical camera mode you can rotate with left-click+drag, pan with ctrl+left-click+drag, and zoom with shift+left-click+drag. I haven't played with all of the settings but I've tried to leave them in a way that you can tinker with them. You can replace the .stl import with any list of vertices (x,y,z) and draw just about anything. The diagram disable removes the NIVision calls that I've used to better color my model in the case that you don't have vision. I had to zip the stl as the forum does not support them. 

 

I'm happy to answer any questions that you might have. 

Message 5 of 24
(184 Views)

Allow me to try and explain the scenario a little better. I am scanning the surface of a tube using laser scanners. From the scanners I receive a X array and a corresponding Y array. This is what I call a "slice". I trigger a slice at a specific interval. As an example lets say every 0.25in of linear tube travel. So for every one inch of linear tube travel I get four "slices". Each "slice" is supposed to have 1280 points, however the scanners in reality usually produce fewer than 1280 points. The .txt file I previously uploaded contains data from nine "slices" (Col A,B,C = slice 1, Col D,E,F = slice 2, etc.)

 

To deal with the difference in points generated per slice I "normalize" by creating a new slice that has 1280 points. The new slice takes data from its original data arrays and interpolates points at the correct intervals. This results in each slice having the same number of points.

As each slice is generated I also return a value that corresponds to distance traveled down the tube. This becomes the "Z" value for that slice which I turn into an array that goes along with the X-Y data.

 

I hope that clarifies what the data I am working with is, and how I get it.

 

I just opened your example and the elephant loads just fine! I tried converting the data I have into an array of clusters of x,y,z points but it does not populate in the 3D picture.

Annotation 2019-06-05 085506.png

Is there a specific way the points need to be arranged for this to work?

 

0 Kudos
Message 6 of 24
(158 Views)

The way that you constructed your point array looks fine to me, assuming that the outer loop is for each slice and the inner loop is around the tube. 

 

I cant remember exactly, but my bet is that it has to do with the order that you are trying to draw your points(at least for triangle draw). If you change the draw mode to "points" you should be able to see exactly where each point lives in 3d space. If you do this before you interpolate your data you should be able to verify that you have the correct (x,y,z) points. If I remember correctly the triangle draw mode didn't always produce clean models for me. There are a few different draw modes, you might just have to play around to see if there is one that works better.

drawmode.PNG

Message 7 of 24
(144 Views)

Jake,

 

Any chance you could upload the VIs in 2015? I would be interested in taking a look.

 

 

 

0 Kudos
Message 8 of 24
(139 Views)

I've attempted to save for previous version, I don't have 2015 installed, so you'll have to let me know if you can open it and if it works.

0 Kudos
Message 9 of 24
(135 Views)

Thanks, that opened fine!

0 Kudos
Message 10 of 24
(132 Views)