9 m_minorFrame.Canonical();
16 m_minorFrame.Canonical();
33 if (bbox.
Max()[1] - bbox.
Min()[1]
36 for (
size_t u = 0; u < uextent; ++u)
38 if (!(*componentImg)[u])
43 if ((*componentImg)[(vextent - 1) * uextent + u])
45 (*componentImg)[(vextent - 1) * uextent + u], &tempLabels);
46 if (u > 0 && u < uextent - 1 && (*componentImg)[(vextent - 1) * uextent + u + 1])
48 (*componentImg)[(vextent - 1) * uextent + u + 1], &tempLabels);
49 if (u > 0 && (*componentImg)[(vextent - 1) * uextent + u - 1])
51 (*componentImg)[(vextent - 1) * uextent + u - 1], &tempLabels);
56 float minorRot = MinorFrameRotation();
57 float ustartPrev, uendPrev, ustart = 0, uend = 0, ustartNext = 0, uendNext = 0;
58 size_t usPrev, uePrev, us = 0, ue = 0, usNext = 0, ueNext = 0;
59 float vangle = (bbox.
Min()[1] + .5f * epsilon) / m_torus->
MinorRadius();
61 + std::cos(vangle + minorRot) * m_torus->
MinorRadius();
65 (intptr_t)((ustartNext - bbox.
Min()[0]) / epsilon)));
67 (intptr_t)((uendNext - bbox.
Min()[0]) / epsilon)));
68 for (
size_t v = 0;
v < vextent; ++
v)
81 float vangle = ((
v + 1.5f) * epsilon + bbox.
Min()[1]) / m_torus->
MinorRadius();
83 + std::cos(vangle + minorRot) * m_torus->
MinorRadius();
87 (intptr_t)((ustartNext - bbox.
Min()[0]) / epsilon)));
89 (intptr_t)((uendNext - bbox.
Min()[0]) / epsilon)));
91 if (ustart <= bbox.
Min()[0] - epsilon
92 || uend >= bbox.
Max()[0] + epsilon
93 || !(*componentImg)[
v * uextent + us])
98 if ((*componentImg)[
v * uextent + ue])
100 (*componentImg)[
v * uextent + ue], &tempLabels);
102 && ustartPrev > bbox.
Min()[0] - epsilon
103 && uendPrev < bbox.
Min()[0] + epsilon
104 && (*componentImg)[(
v - 1) * uextent + uePrev])
106 (*componentImg)[(
v - 1) * uextent + uePrev], &tempLabels);
108 && ustartNext > bbox.
Min()[0] - epsilon
109 && uendNext < bbox.
Min()[0] + epsilon
110 && (*componentImg)[(
v + 1) * uextent + ueNext])
112 (*componentImg)[(
v + 1) * uextent + ueNext], &tempLabels);
116 for (
size_t i = tempLabels.
size() - 1; i > 0; --i)
122 labels->reserve(condensed.
size());
124 for (
size_t i = 0; i < tempLabels.
size(); ++i)
125 if (i == tempLabels[i].first)
127 labels->push_back(std::make_pair(count, tempLabels[i].second));
128 condensed[i] = count;
132 (*labels)[condensed[tempLabels[i].first]].second
133 += tempLabels[i].second;
135 for (
size_t i = 0; i < componentImg->
size(); ++i)
137 condensed[tempLabels[(*componentImg)[i]].first];
142 return 2 *
sizeof(
float);
150 rot = MajorFrameRotation();
151 o->write((
char*)&rot,
sizeof(rot));
152 rot = MinorFrameRotation();
153 o->write((
char*)&rot,
sizeof(rot));
157 *o << MajorFrameRotation() <<
" " << MinorFrameRotation() <<
" ";
163 float majorRot, minorRot;
166 i->read((
char*)&majorRot,
sizeof(majorRot));
167 i->read((
char*)&minorRot,
sizeof(minorRot));
171 *i >> majorRot >> minorRot;
175 nframe.RotateOnNormal(majorRot);
176 m_hcs[0] = nframe[0];
177 m_hcs[1] = nframe[1];
178 m_minorFrame.Canonical();
179 m_minorFrame.RotateFrame(minorRot);
182 float LowStretchTorusParametrization::MinorFrameRotation()
const
188 float LowStretchTorusParametrization::MajorFrameRotation()
const
194 nframe.ToTangent(m_hcs[0], &t);
195 for (
unsigned int i = 0; i < 2; ++i)
199 return std::atan2(t[1], t[0]);