-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflatten_sphere.m
55 lines (52 loc) · 1.62 KB
/
flatten_sphere.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
47
48
49
50
51
52
53
54
55
function [V_flat,cutMesh,flattener]=flatten_sphere(V,T,inds,orbifold_type,varargin)
%flatten a spherical mesh to one of the four euclidean orbifolds.
%Input:
%V,T - verts and tris of mesh
%inds - indices of the cones
%orbifold type - number of the orbfiold (1-4), ir choose from the Enum
%OrbifoldType
%Output:
%V_flat, 2d position of each vertex.
%cutMesh - the CutMesh object.
%flattener - the Flattener object which can be used to perform further
%operations
p = inputParser;
p.addParameter('CutMesh',[])
p.addParameter('verbose',true,@islogical)
p.addParameter('minimize_conformal',false,@islogical);
orbifold_type=uint32(orbifold_type);
%the cone structure of the 4 orbifolds, defined by the cone angles at the
%1st, 3rd, and possibly 4th cone.
singularities={[4 4], %type I
[3 3], %type II
[6 2], %type III
[2 2 2]}; %type IV
if orbifold_type<4 && orbifold_type>=1
if length(inds)~=3
error('type I-III orbifolds requires 3 cones');
end
elseif orbifold_type==4
if length(inds)~=4
error('type IV orbifold requires 4 cones');
end
else
error('orbifold type should be an integer between 1 and 4');
end
M_orig=[];
M_orig.V=V';
M_orig.F=T';
p.parse(varargin{:});
if isempty(p.Results.CutMesh)
flattener=Flattener(M_orig,inds,singularities{orbifold_type});
else
flattener=Flattener(M_orig,inds,singularities{orbifold_type},p.Results.CutMesh);
end
flattener.verbose=p.Results.verbose;
flattener.flatten();
if p.Results.minimize_conformal
assert(orbifold_type==4);
flattener.correctGlobalAffine;
end
V_flat=flattener.flat_V;
cutMesh=flattener.M_cut;
end