69 int faceCount = edge.GetNumFaces();
71 mask.SetNumVertexWeights(2);
72 mask.SetNumEdgeWeights(0);
73 mask.SetNumFaceWeights(faceCount);
74 mask.SetFaceWeightsForFaceCenters(
false);
93 typedef typename MASK::Weight Weight;
95 Weight vWeight = mask.AreFaceWeightsForFaceCenters() ? 0.125f : 0.375f;
96 Weight fWeight = mask.AreFaceWeightsForFaceCenters() ? 0.375f : 0.125f;
98 mask.VertexWeight(0) = vWeight;
99 mask.VertexWeight(1) = vWeight;
101 if (faceCount == 2) {
102 mask.FaceWeight(0) = fWeight;
103 mask.FaceWeight(1) = fWeight;
107 fWeight *= 2.0f / (Weight) faceCount;
108 for (
int i = 0; i < faceCount; ++i) {
109 mask.FaceWeight(i) = fWeight;
139 int const creaseEnds[2])
const {
140 typedef typename MASK::Weight Weight;
142 int valence = vertex.GetNumEdges();
144 mask.SetNumVertexWeights(1);
145 mask.SetNumEdgeWeights(valence);
146 mask.SetNumFaceWeights(0);
147 mask.SetFaceWeightsForFaceCenters(
false);
149 Weight vWeight = 0.75f;
150 Weight eWeight = 0.125f;
152 mask.VertexWeight(0) = vWeight;
153 for (
int i = 0; i < valence; ++i) {
154 mask.EdgeWeight(i) = 0.0f;
156 mask.EdgeWeight(creaseEnds[0]) = eWeight;
157 mask.EdgeWeight(creaseEnds[1]) = eWeight;
165 typedef typename MASK::Weight Weight;
167 int valence = vertex.GetNumFaces();
169 mask.SetNumVertexWeights(1);
170 mask.SetNumEdgeWeights(valence);
171 mask.SetNumFaceWeights(0);
172 mask.SetFaceWeightsForFaceCenters(
false);
175 Weight eWeight = (Weight) 0.0625f;
176 Weight vWeight = (Weight) 0.625f;
183 double dValence = (double) valence;
184 double invValence = 1.0f / dValence;
185 double cosTheta = std::cos(M_PI * 2.0f * invValence);
187 double beta = 0.25f * cosTheta + 0.375f;
189 eWeight = (Weight) ((0.625f - (beta * beta)) * invValence);
190 vWeight = (Weight) (1.0f - (eWeight * dValence));
193 mask.VertexWeight(0) = vWeight;
194 for (
int i = 0; i < valence; ++i) {
195 mask.EdgeWeight(i) = eWeight;
220 int const creaseEnds[2])
const {
222 typedef typename MASK::Weight Weight;
224 int valence = vertex.GetNumEdges();
226 posMask.SetNumVertexWeights(1);
227 posMask.SetNumEdgeWeights(valence);
228 posMask.SetNumFaceWeights(0);
229 posMask.SetFaceWeightsForFaceCenters(
false);
242 Weight vWeight = (Weight) (4.0 / 6.0);
243 Weight eWeight = (Weight) (1.0 / 6.0);
245 posMask.VertexWeight(0) = vWeight;
246 for (
int i = 0; i < valence; ++i) {
247 posMask.EdgeWeight(i) = 0.0f;
249 posMask.EdgeWeight(creaseEnds[0]) = eWeight;
250 posMask.EdgeWeight(creaseEnds[1]) = eWeight;
258 typedef typename MASK::Weight Weight;
260 int valence = vertex.GetNumFaces();
262 posMask.SetNumVertexWeights(1);
263 posMask.SetNumEdgeWeights(valence);
264 posMask.SetNumFaceWeights(0);
265 posMask.SetFaceWeightsForFaceCenters(
false);
269 Weight eWeight = (Weight) (1.0 / 12.0);
270 Weight vWeight = 0.5f;
272 posMask.VertexWeight(0) = vWeight;
274 posMask.EdgeWeight(0) = eWeight;
275 posMask.EdgeWeight(1) = eWeight;
276 posMask.EdgeWeight(2) = eWeight;
277 posMask.EdgeWeight(3) = eWeight;
278 posMask.EdgeWeight(4) = eWeight;
279 posMask.EdgeWeight(5) = eWeight;
282 double dValence = (double) valence;
283 double invValence = 1.0f / dValence;
284 double cosTheta = std::cos(M_PI * 2.0f * invValence);
286 double beta = 0.25f * cosTheta + 0.375f;
287 double gamma = (0.625f - (beta * beta)) * invValence;
289 Weight eWeight = (Weight) (1.0f / (dValence + 3.0f / (8.0f * gamma)));
290 Weight vWeight = (Weight) (1.0f - (eWeight * dValence));
292 posMask.VertexWeight(0) = vWeight;
293 for (
int i = 0; i < valence; ++i) {
294 posMask.EdgeWeight(i) = eWeight;
370 MASK& tan1Mask, MASK& tan2Mask)
const {
372 int valence = vertex.GetNumEdges();
374 tan1Mask.SetNumVertexWeights(1);
375 tan1Mask.SetNumEdgeWeights(valence);
376 tan1Mask.SetNumFaceWeights(0);
377 tan1Mask.SetFaceWeightsForFaceCenters(
false);
379 tan2Mask.SetNumVertexWeights(1);
380 tan2Mask.SetNumEdgeWeights(valence);
381 tan2Mask.SetNumFaceWeights(0);
382 tan2Mask.SetFaceWeightsForFaceCenters(
false);
385 tan1Mask.VertexWeight(0) = -3.0f;
386 tan1Mask.EdgeWeight(0) = 3.0f;
387 tan1Mask.EdgeWeight(1) = 0.0f;
389 tan2Mask.VertexWeight(0) = -3.0f;
390 tan2Mask.EdgeWeight(0) = 0.0f;
391 tan2Mask.EdgeWeight(1) = 3.0f;
394 for (
int i = 2; i < valence; ++i) {
395 tan1Mask.EdgeWeight(i) = 0.0f;
396 tan2Mask.EdgeWeight(i) = 0.0f;
404 MASK& tan1Mask, MASK& tan2Mask,
int const creaseEnds[2])
const {
406 typedef typename MASK::Weight Weight;
415 int valence = vertex.GetNumEdges();
417 tan1Mask.SetNumVertexWeights(1);
418 tan1Mask.SetNumEdgeWeights(valence);
419 tan1Mask.SetNumFaceWeights(0);
420 tan1Mask.SetFaceWeightsForFaceCenters(
false);
422 tan1Mask.VertexWeight(0) = 0.0f;
423 for (
int i = 0; i < valence; ++i) {
424 tan1Mask.EdgeWeight(i) = 0.0f;
428 tan1Mask.EdgeWeight(creaseEnds[0]) = 1.5f;
429 tan1Mask.EdgeWeight(creaseEnds[1]) = -1.5f;
451 tan2Mask.SetNumVertexWeights(1);
452 tan2Mask.SetNumEdgeWeights(valence);
453 tan2Mask.SetNumFaceWeights(0);
454 tan2Mask.SetFaceWeightsForFaceCenters(
false);
456 for (
int i = 0; i < creaseEnds[0]; ++i) {
457 tan2Mask.EdgeWeight(i) = 0.0f;
459 int interiorEdgeCount = creaseEnds[1] - creaseEnds[0] - 1;
460 if (interiorEdgeCount == 2) {
463 static Weight
const Root3 = (Weight) 1.73205080756887729352;
464 static Weight
const Root3by2 = (Weight) (Root3 * 0.5);
466 tan2Mask.VertexWeight(0) = -Root3;
468 tan2Mask.EdgeWeight(creaseEnds[0]) = -Root3by2;
469 tan2Mask.EdgeWeight(creaseEnds[1]) = -Root3by2;
471 tan2Mask.EdgeWeight(creaseEnds[0] + 1) = Root3;
472 tan2Mask.EdgeWeight(creaseEnds[0] + 2) = Root3;
473 }
else if (interiorEdgeCount > 2) {
478 double theta = M_PI / (interiorEdgeCount + 1);
480 tan2Mask.VertexWeight(0) = 0.0f;
482 Weight cWeight = (Weight) (-3.0f * std::sin(theta));
483 tan2Mask.EdgeWeight(creaseEnds[0]) = cWeight;
484 tan2Mask.EdgeWeight(creaseEnds[1]) = cWeight;
486 double eCoeff = -3.0f * 2.0f * (std::cos(theta) - 1.0f);
487 for (
int i = 1; i <= interiorEdgeCount; ++i) {
488 tan2Mask.EdgeWeight(creaseEnds[0] + i) = (Weight) (eCoeff * std::sin(i * theta));
490 }
else if (interiorEdgeCount == 1) {
493 tan2Mask.VertexWeight(0) = -3.0f;
495 tan2Mask.EdgeWeight(creaseEnds[0]) = 0.0f;
496 tan2Mask.EdgeWeight(creaseEnds[1]) = 0.0f;
498 tan2Mask.EdgeWeight(creaseEnds[0] + 1) = 3.0f;
502 tan2Mask.VertexWeight(0) = -6.0f;
504 tan2Mask.EdgeWeight(creaseEnds[0]) = 3.0f;
505 tan2Mask.EdgeWeight(creaseEnds[1]) = 3.0f;
507 for (
int i = creaseEnds[1] + 1; i < valence; ++i) {
508 tan2Mask.EdgeWeight(i) = 0.0f;
516 MASK& tan1Mask, MASK& tan2Mask)
const {
518 typedef typename MASK::Weight Weight;
520 int valence = vertex.GetNumFaces();
522 tan1Mask.SetNumVertexWeights(1);
523 tan1Mask.SetNumEdgeWeights(valence);
524 tan1Mask.SetNumFaceWeights(0);
525 tan1Mask.SetFaceWeightsForFaceCenters(
false);
527 tan2Mask.SetNumVertexWeights(1);
528 tan2Mask.SetNumEdgeWeights(valence);
529 tan2Mask.SetNumFaceWeights(0);
530 tan2Mask.SetFaceWeightsForFaceCenters(
false);
532 tan1Mask.VertexWeight(0) = 0.0f;
533 tan2Mask.VertexWeight(0) = 0.0f;
536 static Weight
const Root3by2 = (Weight)(0.5 * 1.73205080756887729352);
538 tan1Mask.EdgeWeight(0) = 1.0f;
539 tan1Mask.EdgeWeight(1) = 0.5f;
540 tan1Mask.EdgeWeight(2) = -0.5f;
541 tan1Mask.EdgeWeight(3) = -1.0f;
542 tan1Mask.EdgeWeight(4) = -0.5f;
543 tan1Mask.EdgeWeight(5) = 0.5f;
545 tan2Mask.EdgeWeight(0) = 0.0f;
546 tan2Mask.EdgeWeight(1) = Root3by2;
547 tan2Mask.EdgeWeight(2) = Root3by2;
548 tan2Mask.EdgeWeight(3) = 0.0f;
549 tan2Mask.EdgeWeight(4) = -Root3by2;
550 tan2Mask.EdgeWeight(5) = -Root3by2;
552 double alpha = 2.0f * M_PI / valence;
553 for (
int i = 0; i < valence; ++i) {
554 double alphaI = alpha * i;
555 tan1Mask.EdgeWeight(i) = (Weight) std::cos(alphaI);
556 tan2Mask.EdgeWeight(i) = (Weight) std::sin(alphaI);