Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ph03 committed May 14, 2014
1 parent b1961ab commit 4c3453f
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 75 deletions.
2 changes: 0 additions & 2 deletions Deform2DConformal.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,5 @@ function init(obj, hidxs)

mesh.p = reshape(u,2,[]);
end

end

end
2 changes: 0 additions & 2 deletions Deform2DFinite.m
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,5 @@ function init(obj, hidxs)

obj.mesh.p = reshape(u,2,[]);
end

end

end
4 changes: 2 additions & 2 deletions TriSystemTikhonovGradientEnergy.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
% beta - smoothing factor in [0,1]
% en - number of quadratic error components per triangle
% d - dimension of unknown coefficients at vertices
% c - number of independent functions to setup system rhs for in
% pure quadratic case (defaults to 1)
% c - number of independent functions to setup system rhs
% (defaults to 1)

if nargin < 6, c = 1; end

Expand Down
2 changes: 1 addition & 1 deletion util/CholConstrSolver.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
b=obj.b;
end

b(obj.cidxs,:)=[]; %correct?
b(obj.cidxs,:)=[];
b=b-obj.A01*constr;

y=obj.L00'\(obj.L00\b(obj.cholPerm,:));
Expand Down
6 changes: 3 additions & 3 deletions util/LagrConstrSolver.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
methods
function obj = LagrConstrSolver(E,A_or_cidxs,b)
%% Constructor
% minimizes f(x) = 1/2*x'*E*x - x'*b + d s.t. A*x=c using
% lagrange multipliers.
% If cidxs are given A is a corresponding identity matrix.
% Minimizes f(x) = 1/2*x'*E*x - x'*b + d s.t. A*x=c using
% Lagrange multipliers.
% If cidxs are given A is a corresponding identity matrix.

if nargin > 2 && ~isempty(b),
obj.b=b;
Expand Down
62 changes: 31 additions & 31 deletions util/readMesh.m
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
function [p,t,uv] = readMesh(filename)
% read in vertices and faces from a .off or .obj file
% Input:
% filename file holding mesh
% Output:
% p (vertex list)
% t (face list)
% uv (texture coordinates list)
%
% Copyright 2011, Alec Jacobson ([email protected])
%
% See also: readOBJ, readOBJfast, readOFF
%
uv = [];
% read in vertices and faces from a .off or .obj file
% Input:
% filename file holding mesh
% Output:
% p (vertex list)
% t (face list)
% uv (texture coordinates list)
%
% Copyright 2011, Alec Jacobson ([email protected])
%
% See also: readOBJ, readOBJfast, readOFF
%
uv = [];

if ~isempty(regexp(filename,'\.off$'))
[V,F] = readOFF(filename);
elseif ~isempty(regexp(filename,'\.obj$'))
if nargout > 2,
[V,F,UV] = readOBJ(filename);
uv = UV';
else
try
[V,F] = readOBJfast(filename);
catch exception
fprintf('Fast reader failed, retrying with more robust, slower reader\n');
[V,F] = readOBJ(filename);
if ~isempty(regexp(filename,'\.off$'))
[V,F] = readOFF(filename);
elseif ~isempty(regexp(filename,'\.obj$'))
if nargout > 2,
[V,F,UV] = readOBJ(filename);
uv = UV';
else
try
[V,F] = readOBJfast(filename);
catch exception
fprintf('Fast reader failed, retrying with more robust, slower reader\n');
[V,F] = readOBJ(filename);
end
end
else
error('Input file must be .off or .obj file.');
end
else
error('Input file must be .off or .obj file.');
end

% adapt to our convention
p = V';
t = F';
% adapt to our convention
p = V';
t = F';
end
70 changes: 36 additions & 34 deletions util/readOBJ.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,44 @@
% WARNING: This is at least 40 times slower than readOFF but probably much much
% slower...
%
% Copyright 2011, Alec Jacobson ([email protected])
%
% See also: load_mesh, readOBJfast, readOFF

V = [];
UV = [];
F = [];
fp = fopen( filename, 'r' );
type = fscanf( fp, '%s', 1 );
while strcmp( type, '' ) == 0
if strcmp( type, 'v' ) == 1
v = fscanf( fp, '%g %g %g\n' );
V = [V; v'];
elseif strcmp( type, 'vt')
v = fscanf( fp, '%g %g %g\n' );
UV = [UV; v'];
elseif strcmp( type, 'f' ) == 1
line = fgets(fp);
[t, count] = sscanf(line, '%d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d');
V = [];
UV = [];
F = [];
fp = fopen( filename, 'r' );
type = fscanf( fp, '%s', 1 );
while strcmp( type, '' ) == 0
if strcmp( type, 'v' ) == 1
v = fscanf( fp, '%g %g %g\n' );
V = [V; v'];
elseif strcmp( type, 'vt')
v = fscanf( fp, '%g %g %g\n' );
UV = [UV; v'];
elseif strcmp( type, 'f' ) == 1
line = fgets(fp);
[t, count] = sscanf(line, '%d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d %d/%d/%d');

if (count>2)
t = t(1:3:end);
else
[t, count] = sscanf(line, '%d/%d %d/%d %d/%d %d/%d %d/%d');
if (count>2)
t = t(1:2:end);
else
[t, count] = sscanf( line, '%d %d %d %d %d %d %d %d %d %d %d\n' );
end
end
F = [F; t'];
elseif strcmp( type, '#' ) == 1
fscanf( fp, '%s\n', 1 );
end
type = fscanf( fp, '%s', 1 );
end
fclose( fp );
if (count>2)
t = t(1:3:end);
else
[t, count] = sscanf(line, '%d/%d %d/%d %d/%d %d/%d %d/%d');
if (count>2)
t = t(1:2:end);
else
[t, count] = sscanf( line, '%d %d %d %d %d %d %d %d %d %d %d\n' );
end
end
F = [F; t'];
elseif strcmp( type, '#' ) == 1
fscanf( fp, '%s\n', 1 );
end
type = fscanf( fp, '%s', 1 );
end
fclose( fp );

%% transform into array if all faces have the same number of vertices
if (size(UV,1)>0) UV = UV; end
%% transform into array if all faces have the same number of vertices
if (size(UV,1)>0) UV = UV; end
end
2 changes: 2 additions & 0 deletions util/readOFF.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
% C #V by 3 list of colors
% N #V by 3 list of normals
%
% Copyright 2011, Alec Jacobson ([email protected])
%
% See also: load_mesh, readOBJfast, readOBJ

V = [];
Expand Down

0 comments on commit 4c3453f

Please sign in to comment.