372 segment->setVertex(1, {circle[i].x2(), 0.0, circle[i].y2()}); |
372 segment->setVertex(1, {circle[i].x2(), 0.0, circle[i].y2()}); |
373 segment->setVertex(2, {circle[i].x1(), 0.0, circle[i].y1()}); |
373 segment->setVertex(2, {circle[i].x1(), 0.0, circle[i].y1()}); |
374 } |
374 } |
375 } |
375 } |
376 |
376 |
|
377 void PrimitiveModel::generateChord(Model& model) const |
|
378 { |
|
379 QVector<QLineF> circle = makeCircle(segments, divisions, 1); |
|
380 |
|
381 for (int i = 1; i < segments; ++i) |
|
382 { |
|
383 LDTriangle* segment = model.emplace<LDTriangle>(); |
|
384 segment->setColor(MainColor); |
|
385 segment->setVertex(0, {circle[0].x1(), 0.0, circle[0].y1()}); |
|
386 segment->setVertex(1, {circle[i].x1(), 0.0, circle[i].y1()}); |
|
387 segment->setVertex(2, {circle[i].x2(), 0.0, circle[i].y2()}); |
|
388 } |
|
389 } |
|
390 |
377 void PrimitiveModel::generateBody(Model& model, bool deep) const |
391 void PrimitiveModel::generateBody(Model& model, bool deep) const |
378 { |
392 { |
379 switch (type) |
393 switch (type) |
380 { |
394 { |
381 case Cylinder: |
395 case Cylinder: |
415 model.emplace<LDCircularPrimitive>(Cylinder, segments, divisions, QMatrix4x4 {}); |
429 model.emplace<LDCircularPrimitive>(Cylinder, segments, divisions, QMatrix4x4 {}); |
416 model.emplace<LDCircularPrimitive>(Circle, segments, divisions, QMatrix4x4 {}); |
430 model.emplace<LDCircularPrimitive>(Circle, segments, divisions, QMatrix4x4 {}); |
417 model.emplace<LDCircularPrimitive>(Circle, segments, divisions, endCircleMatrix); |
431 model.emplace<LDCircularPrimitive>(Circle, segments, divisions, endCircleMatrix); |
418 } |
432 } |
419 } |
433 } |
|
434 return; |
|
435 |
|
436 case Chord: |
|
437 generateChord(model); |
420 return; |
438 return; |
421 |
439 |
422 default: |
440 default: |
423 break; |
441 break; |
424 } |
442 } |
555 } |
575 } |
556 |
576 |
557 // Compose some general information: prefix, fraction, root, ring number |
577 // Compose some general information: prefix, fraction, root, ring number |
558 QString prefix = (divisions == MediumResolution) ? "" : format ("%1\\", divisions); |
578 QString prefix = (divisions == MediumResolution) ? "" : format ("%1\\", divisions); |
559 QString frac = format ("%1-%2", numerator, denominator); |
579 QString frac = format ("%1-%2", numerator, denominator); |
560 static const char* roots[] = {"edge", "cyli", "disc", "ndis", "ring", "con"}; |
580 static const char* roots[] = {"edge", "cyli", "disc", "ndis", "ring", "con", "chrd"}; |
561 QString root = roots[type]; |
581 QString root = roots[type]; |
562 QString numberString = (type == Ring or type == Cone) ? format ("%1", ringNumber) : ""; |
582 QString numberString = (type == Ring or type == Cone) ? format ("%1", ringNumber) : ""; |
563 |
583 |
564 // Truncate the root if necessary (7-16rin4.dat for instance). |
584 // Truncate the root if necessary (7-16rin4.dat for instance). |
565 // However, always keep the root at least 2 characters. |
585 // However, always keep the root at least 2 characters. |