src/file.cpp

changeset 266
12e7302f14e9
parent 265
955c0aabfebf
child 267
95fde37e1f00
equal deleted inserted replaced
265:955c0aabfebf 266:12e7302f14e9
625 // Vertex (0 !LDFORGE VERTEX) 625 // Vertex (0 !LDFORGE VERTEX)
626 CHECK_TOKEN_COUNT (7) 626 CHECK_TOKEN_COUNT (7)
627 CHECK_TOKEN_NUMBERS (3, 6) 627 CHECK_TOKEN_NUMBERS (3, 6)
628 628
629 LDVertex* obj = new LDVertex; 629 LDVertex* obj = new LDVertex;
630 obj->color = atol (tokens[3]); 630 obj->setColor (atol (tokens[3]));
631 631
632 for (const Axis ax : g_Axes) 632 for (const Axis ax : g_Axes)
633 obj->pos[ax] = atof (tokens[4 + ax]); // 4 - 6 633 obj->pos[ax] = atof (tokens[4 + ax]); // 4 - 6
634 634
635 return obj; 635 return obj;
651 if (eType == LDRadial::NumTypes) 651 if (eType == LDRadial::NumTypes)
652 return new LDGibberish (line, fmt ("Unknown radial type %s", tokens[3].chars ())); 652 return new LDGibberish (line, fmt ("Unknown radial type %s", tokens[3].chars ()));
653 653
654 LDRadial* obj = new LDRadial; 654 LDRadial* obj = new LDRadial;
655 655
656 obj->radType = eType; // 3 656 obj->radType = eType;
657 obj->color = atol (tokens[4]); // 4 657 obj->setColor (atol (tokens[4]));
658 obj->segs = atol (tokens[5]); // 5 658 obj->segs = atol (tokens[5]);
659 obj->divs = atol (tokens[6]); // 6 659 obj->divs = atol (tokens[6]);
660 obj->ringNum = atol (tokens[7]); // 7 660 obj->ringNum = atol (tokens[7]);
661 661
662 obj->pos = parseVertex (tokens, 8); // 8 - 10 662 obj->pos = parseVertex (tokens, 8); // 8 - 10
663 663
664 for (short i = 0; i < 9; ++i) 664 for (short i = 0; i < 9; ++i)
665 obj->transform[i] = atof (tokens[i + 11]); // 11 - 19 665 obj->transform[i] = atof (tokens[i + 11]); // 11 - 19
689 // If we cannot open the file, mark it an error 689 // If we cannot open the file, mark it an error
690 if (!load) 690 if (!load)
691 return new LDGibberish (line, "Could not open referred file"); 691 return new LDGibberish (line, "Could not open referred file");
692 692
693 LDSubfile* obj = new LDSubfile; 693 LDSubfile* obj = new LDSubfile;
694 obj->color = atol (tokens[1]); 694 obj->setColor (atol (tokens[1]));
695 obj->pos = parseVertex (tokens, 2); // 2 - 4 695 obj->pos = parseVertex (tokens, 2); // 2 - 4
696 696
697 for (short i = 0; i < 9; ++i) 697 for (short i = 0; i < 9; ++i)
698 obj->transform[i] = atof (tokens[i + 5]); // 5 - 13 698 obj->transform[i] = atof (tokens[i + 5]); // 5 - 13
699 699
707 CHECK_TOKEN_COUNT (8) 707 CHECK_TOKEN_COUNT (8)
708 CHECK_TOKEN_NUMBERS (1, 7) 708 CHECK_TOKEN_NUMBERS (1, 7)
709 709
710 // Line 710 // Line
711 LDLine* obj = new LDLine; 711 LDLine* obj = new LDLine;
712 obj->color = atol (tokens[1]); 712 obj->setColor (atol (tokens[1]));
713 for (short i = 0; i < 2; ++i) 713 for (short i = 0; i < 2; ++i)
714 obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 7 714 obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 7
715 return obj; 715 return obj;
716 } 716 }
717 717
720 CHECK_TOKEN_COUNT (11) 720 CHECK_TOKEN_COUNT (11)
721 CHECK_TOKEN_NUMBERS (1, 10) 721 CHECK_TOKEN_NUMBERS (1, 10)
722 722
723 // Triangle 723 // Triangle
724 LDTriangle* obj = new LDTriangle; 724 LDTriangle* obj = new LDTriangle;
725 obj->color = atol (tokens[1]); 725 obj->setColor (atol (tokens[1]));
726 726
727 for (short i = 0; i < 3; ++i) 727 for (short i = 0; i < 3; ++i)
728 obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 10 728 obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 10
729 729
730 return obj; 730 return obj;
735 CHECK_TOKEN_COUNT (14) 735 CHECK_TOKEN_COUNT (14)
736 CHECK_TOKEN_NUMBERS (1, 13) 736 CHECK_TOKEN_NUMBERS (1, 13)
737 737
738 // Quadrilateral 738 // Quadrilateral
739 LDQuad* obj = new LDQuad; 739 LDQuad* obj = new LDQuad;
740 obj->color = atol (tokens[1]); 740 obj->setColor (atol (tokens[1]));
741 741
742 for (short i = 0; i < 4; ++i) 742 for (short i = 0; i < 4; ++i)
743 obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13 743 obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13
744 744
745 return obj; 745 return obj;
750 CHECK_TOKEN_COUNT (14) 750 CHECK_TOKEN_COUNT (14)
751 CHECK_TOKEN_NUMBERS (1, 13) 751 CHECK_TOKEN_NUMBERS (1, 13)
752 752
753 // Conditional line 753 // Conditional line
754 LDCondLine* obj = new LDCondLine; 754 LDCondLine* obj = new LDCondLine;
755 obj->color = atol (tokens[1]); 755 obj->setColor (atol (tokens[1]));
756 756
757 for (short i = 0; i < 4; ++i) 757 for (short i = 0; i < 4; ++i)
758 obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13 758 obj->coords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13
759 759
760 return obj; 760 return obj;

mercurial