src/ldtypes.cpp

changeset 311
c6e38e5e4f33
parent 310
c62edce5668c
child 312
97620579d86c
equal deleted inserted replaced
310:c62edce5668c 311:c6e38e5e4f33
549 549
550 // ============================================================================= 550 // =============================================================================
551 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 551 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
552 // ============================================================================= 552 // =============================================================================
553 str LDRadial::makeFileName () { 553 str LDRadial::makeFileName () {
554 short numer = segments (), 554 return "";
555 denom = divisions ();
556
557 // Simplify the fractional part, but the denominator must be at least 4.
558 simplify (numer, denom);
559
560 if (denom < 4) {
561 const short factor = (4 / denom);
562
563 numer *= factor;
564 denom *= factor;
565 }
566
567 // Compose some general information: prefix, fraction, root, ring number
568 str prefix = (divisions () == lores) ? "" : fmt ("%1/", divisions ());
569 str frac = fmt ("%1-%2", numer, denom);
570 str root = g_radialNameRoots[type ()];
571 str num = (type () == Ring || type () == Cone) ? fmt ("%1", number ()) : "";
572
573 // Truncate the root if necessary (7-16rin4.dat for instance).
574 // However, always keep the root at least 2 characters.
575 short extra = (frac.length () + num.length () + root.length ()) - 8;
576 root.chop (min<short> (max<short> (extra, 0), 2));
577
578 // Stick them all together and return the result.
579 return (prefix + frac + root + num + ".dat");
580 } 555 }
581 556
582 // ============================================================================= 557 // =============================================================================
583 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 558 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
584 // ============================================================================= 559 // =============================================================================

mercurial