Difference between revisions of "Contrib:BondMatt/Pointclouds"

From CAELinuxWiki
Jump to: navigation, search
Line 5: Line 5:
 
<br/>
 
<br/>
 
<br/>
 
<br/>
import salome
+
import salome <br/>
import geompy
+
import geompy <br/>
import smesh, SMESH
+
import smesh, SMESH <br/>
import math
+
import math <br/>
import GEOM
+
import GEOM <br/>
import SALOMEDS
+
import SALOMEDS <br/>
from Numeric import *
+
from Numeric import * <br/>
global pnt
+
global pnt <br/>
XYZM=array([ Note: text file contents are copied here ]);
+
XYZM=array([ Note: text file contents are copied here ]); <br/>
for i in range (1, 9, 3):
+
for i in range (1, 9, 3): <br/>
pnt=geompy.MakeVertex (XYZM[i],XYZM[i+1],XYZM[i+2])
+
pnt=geompy.MakeVertex (XYZM[i],XYZM[i+1],XYZM[i+2]) <br/>
 
geompy.addToStudy(pnt,"pnt")
 
geompy.addToStudy(pnt,"pnt")
 
<br/>
 
<br/>

Revision as of 02:48, 23 July 2011

This page describes procedures used to create standard CAD format entities from point clouds in a text file format.
3D scanners can now be made using inexpensive equipment. Additionally, providers of this service in industry commonly offer 3D scanning at very affordable rates. The data that is obtained from this process can simply consist of a text file where each row consists of three floating point decimal numbers separated by commas. While commercial software with astonishing capabilities exist, they can be very expensive. Using Octave, Salome, and LS-Prepost (all freely available) CAD entities, including surfaces, can be generated.

The Salome platform ([1] available for Windows here: [2]) is an outstanding contribution to open source CAD software. One very interesting capability is the ability to output and read Python scripts. After completing tasks using the GUI one can output a Python script. This script can then be edited and imported to accomplish almost any task. Such a script can be used to generate points from the text file that may be the deliverable from the 3D scanning process. Such a script follows:

import salome
import geompy
import smesh, SMESH
import math
import GEOM
import SALOMEDS
from Numeric import *
global pnt
XYZM=array([ Note: text file contents are copied here ]);
for i in range (1, 9, 3):
pnt=geompy.MakeVertex (XYZM[i],XYZM[i+1],XYZM[i+2])
geompy.addToStudy(pnt,"pnt")

This is a crude solution with several disadvantages. As noted the text file with the coordinates of the points is directly copied into the script. With relatively small 3D scanning jobs there are millions of points and just copying the text from one file to another can take a decent workstations quite some time. Additionally, the format of the data must be consistent with Python syntax. Once this script is submitted to Salome a point cloud with millions of entities can take several hours to run. Also, visualizing the results is almost impossible. Several CAD environments were tested and all were unusable due to the large number of entities. The python script as shown does not group the points into a single entity, an operation that makes the CAD model much less computationally intensive. However, a simple revision of this script to accomplish this grouping does not seem possible.

Octave ([3]), which is very similar to MATLAB, is an environment in which rather complex computations can be completed very easily. It is quite simple to use this software to write files that use ASCII text. Octave is also available for Windows ([4]) and the XOctave GUI is highly recommended: [5]. A relatively simple script can directly generate a BREP CAD format file from a text file containing points from a 3D scanner: