-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgeodesic_convert_surface_points.m
46 lines (40 loc) · 1.21 KB
/
geodesic_convert_surface_points.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
%internal geodesic function
%conversion between C++ and matlab surface point representation
% Danil Kirsanov, 09/2007
function q = geodesic_convert_surface_points(p)
if isempty(p)
q = [];
return;
end;
point_types = {'vertex', 'edge', 'face'};
if ~isa(p,'numeric') %convert from matlab to C++
num_points = length(p);
q = zeros(num_points*5, 1);
for i = 1:num_points
shift = (i-1)*5;
q(shift + 1) = p{i}.x;
q(shift + 2) = p{i}.y;
q(shift + 3) = p{i}.z;
q(shift + 5) = p{i}.id - 1;
type = find(strcmp(point_types, p{i}.type));
if isempty(type)
disp('error: point type is incorrect');
q = [];
return;
else
q(shift + 4) = type - 1;
end
end
else %convert from C++ to matlab
num_points = length(p)/5;
q = cell(num_points, 1);
for i = 1:num_points
shift = (i-1)*5;
point.x = p(shift + 1);
point.y = p(shift + 2);
point.z = p(shift + 3);
point.type = point_types(p(shift + 4) + 1);
point.id = p(shift + 5) + 1;
q{i} = point;
end;
end;