1、ReadPointCloudFromTextfile(::Filename:X,Y,Z)
open_file(Filename,'input',file)
NumColumns := 3
VecOutLine.clear()
repeat
fread_line(file, oneline, IsEOF)
if(IsEOF == 1)
break
endif
if(oneline == ' ')
continue
endif
tuple_str_first_n (oneline, 0, Substring)
if(Substring == '#')
continue
endif
VecOutLine.at(VecOutLine.length()) := oneline
until (IsEOF)
convert_vector_to_tuple(VecOutLine, P)
P := split(P,' ')
Number := number(regexp_replace(P,'^\\s*0*(.+?)\\s*\n*$','$1'))
P := HNULL
X := Number[[0:NumColumns:|Number|-1]]
Y := Number[[1:NumColumns:|Number|-1]]
Z := Number[[2:NumColumns:|Number|-1]]
close_file(file)
return ()
2、demo
dev_update_off ()
Filename := 'C:/Users/shining3d/Documents/Halcon_demo/Point_0.txt'
X := []
Y := []
Z := []
count_seconds (Then)
ReadPointCloudFromTextfile (Filename, X, Y, Z)
count_seconds (Now)
DurationSeconds := Now - Then
Msg := 'opening file ' + Filename + ' in ' + DurationSeconds + 's'
dev_inspect_ctrl (Msg)
gen_object_model_3d_from_points (X, Y, Z, ObjectModel3D)
X := HNULL
Y := HNULL
Z := HNULL
dev_get_window (WindowHandle)
visualize_object_model_3d (WindowHandle, ObjectModel3D, [], [], [], [], [], [], [], PoseOut)