[Index for tmp_for_tar/vrml.doc] [Return to Master Index]

select_3D_points

(tmp_for_tar/vrml.doc/select_3D_points.m)


Function Synopsis

sel2 = select_3D_points (x, sel1, deco)

Help text

 sel2 = select_3D_points (x, sel1, deco) - select 3D points

 x     : 3 x P  : 3D points
 sel1  : P      : 0-1 matrix specifying currently selected points
      or Q1     : List of indices of currently selected points
                                                    Default=zeros(1,P)
 deco  : string : Vrml code for decorating set of 3D points
                                                    Default=""

 sel2  : P      : 0-1 matrix or list of selected points    (default)
      or Q2       List of selected points

 Last modified: December 2000



Listing of function file tmp_for_tar/vrml.doc/select_3D_points.m

## sel2 = select_3D_points (x, sel1, deco) - select 3D points
##
## x     : 3 x P  : 3D points
## sel1  : P      : 0-1 matrix specifying currently selected points
##      or Q1     : List of indices of currently selected points
##                                                    Default=zeros(1,P)
## deco  : string : Vrml code for decorating set of 3D points
##                                                    Default=""
##
## sel2  : P      : 0-1 matrix or list of selected points    (default)
##      or Q2       List of selected points
## 

## Author:        Etienne Grossmann  <etienne@isr.ist.utl.pt>
## Last modified: December 2000

function sel2 = select_3D_points (x, sel1, deco)

P = columns (x);
global vrml_b_pid = 0;

want_list = 0;			# Return list of selected points or 0-1
				# matrix 


if nargin < 3,  deco = ""; end	# default is no decoration

if nargin >=2,
				# sel1 has been passed 
  sel1 = sel1(:)';
  if columns (sel1) != P || !isempty (sel1) && any (sel1!=1 & sel1!=0),
    want_list = 1;
    sel1 = loose (sel1, P)';
  end
else
  sel1 = zeros (1,P);		# Default : nothing pre-selected
end
				# NOTE : this filename hardcoded in
				# vrml_browse()
data_out = "/tmp/octave_browser_out.txt";

s = vrml_select_points (x, sel1);

## vrml_browse ("-kill");	# Stop previous browser, if any

				# Clean data file ####################
[st,err,msg] = stat (data_out);
if ! err,			# There's a file : clean it
  [err,msg] = unlink (data_out);
  if err,
    error ("select_3D_points : Can't remove data file '%s'",data_out);
  end
				# There's no file, but there's a pid.
elseif vrml_b_pid,		
				# assume browser died. kill it for sure
  vrml_browse ("-kill");
end

				# Start browser ######################
vrml_browse ([s,deco]);


while my_menu ("\nMenu: (R)estart browser. Other key : done") == "R",
  vrml_browse ("-kill");
  vrml_browse ([s,deco]);
end
## printf ("press <CR> when done selecting points\n");
## pause

## vrml_browse ("-kill");	# Stop browser #######################

				# Retrieve history of clicks #########
perlcmd = "print qq{$1,$2;} if /^TAG:\\s*(\\d+)\\s*STATE:\\s*(\\d+)/";
cmd = sprintf ("perl -ne '%s' %s",perlcmd,data_out);

res = system (cmd, 1);
res = res(1:length(res)-1);	# Remove last ";"
stl = eval (["[",res,"];"])';	# List of clicks

sel2 = sel1 ;

				# Build new selection matrix
## HERE I trust octave to behave as 
## for i=1:columns(stl), sel2(stl(1,:)) = stl(2,i); end

if ! isempty (stl), sel2(stl(1,:)) = stl(2,:); end

				# Eventually transform 0-1 matrix into 
				# list of selected points.
if want_list, sel2 = find (sel2); end

Produced by oct2html on Sat Dec 2 19:08:39 2000
Cross-Directory links are: ON