84 |
84 |
85 str LDLine::getContents () { |
85 str LDLine::getContents () { |
86 str val = fmt ("2 %d", color); |
86 str val = fmt ("2 %d", color); |
87 |
87 |
88 for (ushort i = 0; i < 2; ++i) |
88 for (ushort i = 0; i < 2; ++i) |
89 val.appendformat (" %s", coords[i].stringRep (false).chars ()); |
89 val += fmt (" %s", coords[i].stringRep (false).chars ()); |
90 |
90 |
91 return val; |
91 return val; |
92 } |
92 } |
93 |
93 |
94 str LDTriangle::getContents () { |
94 str LDTriangle::getContents () { |
95 str val = fmt ("3 %d", color); |
95 str val = fmt ("3 %d", color); |
96 |
96 |
97 for (ushort i = 0; i < 3; ++i) |
97 for (ushort i = 0; i < 3; ++i) |
98 val.appendformat (" %s", coords[i].stringRep (false).chars ()); |
98 val += fmt (" %s", coords[i].stringRep (false).chars ()); |
99 |
99 |
100 return val; |
100 return val; |
101 } |
101 } |
102 |
102 |
103 str LDQuad::getContents () { |
103 str LDQuad::getContents () { |
104 str val = fmt ("4 %d", color); |
104 str val = fmt ("4 %d", color); |
105 |
105 |
106 for (ushort i = 0; i < 4; ++i) |
106 for (ushort i = 0; i < 4; ++i) |
107 val.appendformat (" %s", coords[i].stringRep (false).chars ()); |
107 val += fmt (" %s", coords[i].stringRep (false).chars ()); |
108 |
108 |
109 return val; |
109 return val; |
110 } |
110 } |
111 |
111 |
112 str LDCondLine::getContents () { |
112 str LDCondLine::getContents () { |
113 str val = fmt ("5 %d", color); |
113 str val = fmt ("5 %d", color); |
114 |
114 |
115 // Add the coordinates |
115 // Add the coordinates |
116 for (ushort i = 0; i < 4; ++i) |
116 for (ushort i = 0; i < 4; ++i) |
117 val.appendformat (" %s", coords[i].stringRep (false).chars ()); |
117 val += fmt (" %s", coords[i].stringRep (false).chars ()); |
118 |
118 |
119 return val; |
119 return val; |
120 } |
120 } |
121 |
121 |
122 str LDGibberish::getContents () { |
122 str LDGibberish::getContents () { |
384 |
384 |
385 // Plural of "vertex" is "vertices". Stupid English. |
385 // Plural of "vertex" is "vertices". Stupid English. |
386 if (objType == LDObject::Vertex && objCount != 1) |
386 if (objType == LDObject::Vertex && objCount != 1) |
387 noun = "vertices"; |
387 noun = "vertices"; |
388 |
388 |
389 text.appendformat ("%lu %s", objCount, noun.chars ()); |
389 text += fmt ("%lu %s", objCount, noun.chars ()); |
390 firstDetails = false; |
390 firstDetails = false; |
391 } |
391 } |
392 |
392 |
393 return text; |
393 return text; |
394 } |
394 } |
604 // ============================================================================= |
604 // ============================================================================= |
605 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
605 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
606 // ============================================================================= |
606 // ============================================================================= |
607 str LDRadial::getContents () { |
607 str LDRadial::getContents () { |
608 return fmt ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", |
608 return fmt ("0 !LDFORGE RADIAL %s %d %d %d %d %s %s", |
609 str (radialTypeName()).toupper ().strip (' ').chars (), |
609 str (radialTypeName()).upper ().strip (' ').c (), |
610 color, segs, divs, ringNum, |
610 color, segs, divs, ringNum, |
611 pos.stringRep (false).chars(), transform.stringRep().chars()); |
611 pos.stringRep (false).chars(), transform.stringRep().chars()); |
612 } |
612 } |
613 |
613 |
614 char const* g_saRadialNameRoots[] = { |
614 char const* g_radialNameRoots[] = { |
615 "edge", |
615 "edge", |
616 "cyli", |
616 "cyli", |
617 "disc", |
617 "disc", |
618 "ndis", |
618 "ndis", |
619 "ring", |
619 "ring", |
639 } |
639 } |
640 |
640 |
641 // Compose some general information: prefix, fraction, root, ring number |
641 // Compose some general information: prefix, fraction, root, ring number |
642 str prefix = (divs == 16) ? "" : fmt ("%d/", divs); |
642 str prefix = (divs == 16) ? "" : fmt ("%d/", divs); |
643 str frac = fmt ("%d-%d", numer, denom); |
643 str frac = fmt ("%d-%d", numer, denom); |
644 str root = g_saRadialNameRoots[radType]; |
644 str root = g_radialNameRoots[radType]; |
645 str num = (radType == Ring || radType == Cone) ? fmt ("%d", ringNum) : ""; |
645 str num = (radType == Ring || radType == Cone) ? fmt ("%d", ringNum) : ""; |
646 |
646 |
647 // Truncate the root if necessary (7-16rin4.dat for instance). |
647 // Truncate the root if necessary (7-16rin4.dat for instance). |
648 // However, always keep the root at least 2 characters. |
648 // However, always keep the root at least 2 characters. |
649 short extra = (~frac + ~num + ~root) - 8; |
649 short extra = (~frac + ~num + ~root) - 8; |