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 47 48 49
| % fid = fopen('module.py', 'r');
fid = fopen('treilli.py', 'r');
X = textscan(fid, '%s', 'delimiter', '\n');
fclose(fid);
% Recuperation des coordonnees des noeuds
idx = ~cellfun('isempty', strfind(X{1},'geompy.MakeVertex'));
subX = X{1}(idx);
points = struct('coord', zeros(numel(subX),3), 'name', {});
for n = 1:numel(subX)
points(1).coord(n,:) = sscanf(subX{n}, '%*s = geompy.MakeVertex(%f,%f,%f)');
points(1).name{n} = sscanf(subX{n}, '%s%*s%*s%*s%*s');
end
% Recuperation de la connectivite des barres
idx = ~cellfun('isempty', strfind(X{1},'geompy.MakeLineTwoPnt'));
subX = X{1}(idx);
lignes = struct('point1',{}, 'point2',{}, 'name', {});
for n = 1:numel(subX)
lignes(1).point1{n} = sscanf(subX{n}, '%*s = geompy.MakeLineTwoPnt(%s%*s');
lignes(1).point2{n} = sscanf(subX{n}, '%*s%*s%*s%s');
lignes(1).name{n} = sscanf(subX{n}, '%s%*s%*s%*s');
end
lignes.point1 = cellfun(@(x) x(1:end-1), lignes.point1, 'UniformOutput',false);
lignes.point2 = cellfun(@(x) x(1:end-1), lignes.point2, 'UniformOutput',false);
figure
plot3(points.coord(:,1), points.coord(:,2), points.coord(:,3), 'ro', 'markerfacecolor', 'r');
hold on
for n = 1:numel(lignes.point1)
idx = strcmp(points.name, lignes.point1{n}) | strcmp(points.name, lignes.point2{n});
if strncmp(lignes.name{n}, 'BARR', 4)
h_barr(n) = line(points.coord(idx,1), points.coord(idx,2), points.coord(idx,3) ...
, 'color', 'g', 'linewidth', 2);
else
h_geomobj(n) = line(points.coord(idx,1), points.coord(idx,2), points.coord(idx,3) ...
, 'color', 'b', 'linewidth', 2);
end
end
axis equal vis3d |
Partager