-
Notifications
You must be signed in to change notification settings - Fork 1
/
vt_eccentricCircularContourGeneration.m
170 lines (129 loc) · 8.1 KB
/
vt_eccentricCircularContourGeneration.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
function [PV_N, currTubeSectionDiameterCells_SegmentCounter] = vt_eccentricCircularContourGeneration(PV_N, numSections, totalTubeLengthInCells, tubeSectionDiameterCells, tubeCummSectionLength, boundaryInterpolation, tubeStart, pmlSwitch, pmlLayer, gridCellTypes, ds)
% Set a counter to traverse through tubeCummSectionLength
tubeSegmentCounter = 1;
cellHalfLen = ds/2;
% Define currTubeSectionDiameterCells
currTubeSectionDiameterCells_SegmentCounter = zeros(2, totalTubeLengthInCells);
tubeRadiusArray = zeros(1, totalTubeLengthInCells);
% Set starting coordinte of tube mid-sagittal axis
% For eccentric geometry we don't need startY
startX = tubeStart.startX;
startZ = tubeStart.startZ;
% STEP1: Each tube segment consists of number of yz-planes. We first store the
% tube radius for each of those planes.
for tubeLenCellsCount = 1:totalTubeLengthInCells
% Check the current tube length
currTubeLength = tubeLenCellsCount*ds;
% Verify if the currTubeLength is more than the tubeCummSectionLength
% for the current sectionCounter
% if small or equal then set the tube wall as expected-normal Case
if currTubeLength <= tubeCummSectionLength(tubeSegmentCounter)
% Get the tube Radius
% We are subtracting 1 as we'll assume that there is a middle
% row of cells which will act like a mirror/centerline.
currGetRadius = (tubeSectionDiameterCells(tubeSegmentCounter)-1)/2;
% store the current cross-section tube segment counter
currTubeSectionDiameterCells_SegmentCounter(2,tubeLenCellsCount) = tubeSegmentCounter;
else
% If the currTubeLength is greater than the actual tubeCummSectionLength
% Find the difference between currTubeLength and tubeCummSectionLength
diffLength = currTubeLength - tubeCummSectionLength(tubeSegmentCounter);
if diffLength>cellHalfLen && tubeSegmentCounter~=numSections
% Increase the tubeSegmentCounter
tubeSegmentCounter = tubeSegmentCounter+1;
% Get the radius for that cross-section [-1: each segment consist of odd number of cells]
currGetRadius = (tubeSectionDiameterCells(tubeSegmentCounter)-1)/2;
% store the current cross-section tube segment counter
currTubeSectionDiameterCells_SegmentCounter(2,tubeLenCellsCount) = tubeSegmentCounter;
else
% Get the radius for that cross-section [-1: each segment consist of odd number of cells]
currGetRadius = (tubeSectionDiameterCells(tubeSegmentCounter)-1)/2;
% store the current cross-section tube segment counter
currTubeSectionDiameterCells_SegmentCounter(2,tubeLenCellsCount) = tubeSegmentCounter;
% And then increase the tubeSegmentCounter
tubeSegmentCounter = tubeSegmentCounter+1;
end
end
tubeRadiusArray(tubeLenCellsCount) = currGetRadius;
end
if boundaryInterpolation == 1
[tubeRadiusArray] = vt_boundaryInterpolation(tubeRadiusArray, ds);
end
% Store the current cross-section tube segment diameter
currTubeSectionDiameterCells_SegmentCounter(1,:) = tubeRadiusArray.*2+1;
% STEP2: Now as we have tubeRadius for each yz-plane, draw the vocal tract
% contour starting from the tubeStart.startX
for tubeLenCellsCount = 1:totalTubeLengthInCells
currGetRadius = tubeRadiusArray(tubeLenCellsCount);
% For eccentric configuration, the y coordinate of the tube central
% axis will change but the z coordinate will remain the same for
% all the tube segments
% And the X axis will change as we move away from the
% glottal-end. We need to draw a circle in the yz-plane
% [-1 to start constructing tube exactly from the tubeStart.startX
% position]
% Deb: You mean tubeUpperY and tubeLowerY in yz-plane
tubeX = startX + (tubeLenCellsCount-1); %[For each iteration tubeX remains fix]
tubeUpperY = 1+(pmlLayer*pmlSwitch)+1; % deadcell+pmllayers +tube Wall
tubeLowerY = tubeUpperY+(currGetRadius*2+1)+1; % tubeUpperY+tubeDiameter+nextcell
tubeMidY = tubeUpperY+currGetRadius+1;
% Deb: tubeRightZ and tubeLeftZ mean the right and left side of
% the center in yz-plane.
tubeRightZ = startZ;
tubeLeftZ = startZ;
PV_N(tubeUpperY, tubeX, tubeRightZ, 5) = gridCellTypes.cell_wall;
PV_N(tubeLowerY, tubeX, tubeLeftZ, 5) = gridCellTypes.cell_wall;
% Store the yCoordinate to close if there are any gaps
prevtubeUpperY = tubeUpperY;
prevtubeLowerY = tubeLowerY;
for radiusCounter = 1:currGetRadius
% rActual = (currGetRadius+0.5)ds
% zPrime = (radiusCounter)ds
rActual = (currGetRadius+0.5)*ds;
zPrime = (radiusCounter)*ds;
currHeightFromCentralAxis = sqrt(rActual^2 - zPrime^2);
currHeightFromTopOfCentralAxisRowCell = currHeightFromCentralAxis-(ds/2);
currHeightInCells = round(currHeightFromTopOfCentralAxisRowCell/ds);
% Define tube cross-section coordinates in the yz plane
tubeRightZ = startZ+radiusCounter;
tubeLeftZ = startZ-radiusCounter;
% Define tubeUpperY and tubeLowerY
tubeUpperY = tubeMidY-currHeightInCells-1;
tubeLowerY = tubeMidY+currHeightInCells+1;
PV_N(tubeUpperY,tubeX,tubeRightZ,5) = gridCellTypes.cell_wall;
PV_N(tubeLowerY,tubeX,tubeRightZ,5) = gridCellTypes.cell_wall;
PV_N(tubeUpperY,tubeX,tubeLeftZ,5) = gridCellTypes.cell_wall;
PV_N(tubeLowerY,tubeX,tubeLeftZ,5) = gridCellTypes.cell_wall;
% Connect grid cells in yz-plane if there are any gaps
if tubeUpperY-prevtubeUpperY > 1
PV_N(prevtubeUpperY+1:tubeUpperY,tubeX,tubeRightZ,5) = gridCellTypes.cell_wall;
PV_N(prevtubeUpperY+1:tubeUpperY,tubeX,tubeLeftZ,5) = gridCellTypes.cell_wall;
PV_N(tubeLowerY:prevtubeLowerY-1,tubeX,tubeRightZ,5) = gridCellTypes.cell_wall;
PV_N(tubeLowerY:prevtubeLowerY-1,tubeX,tubeLeftZ,5) = gridCellTypes.cell_wall;
end
prevtubeUpperY = tubeUpperY;
prevtubeLowerY = tubeLowerY;
end
% In the end close the circle by using walls at the complete right
% and left side of the yz-plane [as per the tube radius]
tubeUpperY = tubeMidY;
tubeLowerY = tubeMidY;
tubeRightZ = startZ+currGetRadius+1;
tubeLeftZ = startZ-currGetRadius-1;
PV_N(tubeUpperY, tubeX, tubeRightZ, 5) = gridCellTypes.cell_wall;
PV_N(tubeLowerY, tubeX, tubeLeftZ, 5) = gridCellTypes.cell_wall;
if tubeUpperY-prevtubeUpperY > 1
PV_N(prevtubeUpperY+1:tubeUpperY,tubeX,tubeRightZ,5) = gridCellTypes.cell_wall;
PV_N(prevtubeUpperY+1:tubeUpperY,tubeX,tubeLeftZ,5) = gridCellTypes.cell_wall;
PV_N(tubeLowerY:prevtubeLowerY-1,tubeX,tubeRightZ,5) = gridCellTypes.cell_wall;
PV_N(tubeLowerY:prevtubeLowerY-1,tubeX,tubeLeftZ,5) = gridCellTypes.cell_wall;
end
% Connect grid cells between two adjacent yz-planes if there are
% any gaps
if tubeX ~= startX && prevGetRadius ~= currGetRadius
PV_N = vt_tubeSegmentConnector(PV_N, prevGetRadius, currGetRadius, gridCellTypes, tubeX);
end
% Store the gridRadius for the current yz-plane
prevGetRadius = currGetRadius;
end
end