1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-18 05:10:07 -07:00

Add colors to subparts

This commit is contained in:
David Hübner 2017-04-23 17:23:09 +02:00
parent a90376a824
commit 328d14426e
13 changed files with 394 additions and 48 deletions

View File

@ -0,0 +1,176 @@
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20170423104943 extends AbstractMigration
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (-1, '0033B2', 0, 'Unknown')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (0, '05131D', 0, 'Black')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (1, '0055BF', 0, 'Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (2, '237841', 0, 'Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (3, '008F9B', 0, 'Dark Turquoise')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (4, 'C91A09', 0, 'Red')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (5, 'C870A0', 0, 'Dark Pink')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (6, '583927', 0, 'Brown')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (7, '9BA19D', 0, 'Light Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (8, '6D6E5C', 0, 'Dark Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (9, 'B4D2E3', 0, 'Light Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (10, '4B9F4A', 0, 'Bright Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (11, '55A5AF', 0, 'Light Turquoise')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (12, 'F2705E', 0, 'Salmon')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (13, 'FC97AC', 0, 'Pink')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (14, 'F2CD37', 0, 'Yellow')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (15, 'FFFFFF', 0, 'White')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (17, 'C2DAB8', 0, 'Light Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (18, 'FBE696', 0, 'Light Yellow')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (19, 'E4CD9E', 0, 'Tan')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (20, 'C9CAE2', 0, 'Light Violet')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (21, 'D4D5C9', 0, 'Glow In Dark Opaque')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (22, '81007B', 0, 'Purple')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (23, '2032B0', 0, 'Dark Blue-Violet')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (25, 'FE8A18', 0, 'Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (26, '923978', 0, 'Magenta')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (27, 'BBE90B', 0, 'Lime')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (28, '958A73', 0, 'Dark Tan')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (29, 'E4ADC8', 0, 'Bright Pink')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (30, 'AC78BA', 0, 'Medium Lavender')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (31, 'E1D5ED', 0, 'Lavender')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (32, '635F52', 1, 'Trans-Black IR Lens')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (33, '0020A0', 1, 'Trans-Dark Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (34, '84B68D', 1, 'Trans-Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (35, 'D9E4A7', 1, 'Trans-Bright Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (36, 'C91A09', 1, 'Trans-Red')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (40, '635F52', 1, 'Trans-Black')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (41, 'AEEFEC', 1, 'Trans-Light Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (42, 'F8F184', 1, 'Trans-Neon Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (43, 'C1DFF0', 1, 'Trans-Very Lt Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (45, 'DF6695', 1, 'Trans-Dark Pink')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (46, 'F5CD2F', 1, 'Trans-Yellow')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (47, 'FCFCFC', 1, 'Trans-Clear')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (52, 'A5A5CB', 1, 'Trans-Purple')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (54, 'DAB000', 1, 'Trans-Neon Yellow')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (57, 'FF800D', 1, 'Trans-Neon Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (60, '645A4C', 0, 'Chrome Antique Brass')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (61, '6C96BF', 0, 'Chrome Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (62, '3CB371', 0, 'Chrome Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (63, 'AA4D8E', 0, 'Chrome Pink')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (64, '1B2A34', 0, 'Chrome Black')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (68, 'F3CF9B', 0, 'Very Light Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (69, 'CD6298', 0, 'Light Purple')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (70, '582A12', 0, 'Reddish Brown')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (71, 'A0A5A9', 0, 'Light Bluish Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (72, '6C6E68', 0, 'Dark Bluish Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (73, '5A93DB', 0, 'Medium Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (74, '73DCA1', 0, 'Medium Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (75, '000000', 0, 'Speckle Black-Copper')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (76, '635F61', 0, 'Speckle DBGray-Silver')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (77, 'FECCCF', 0, 'Light Pink')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (78, 'F6D7B3', 0, 'Light Flesh')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (79, 'FFFFFF', 0, 'Milky White')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (80, 'A5A9B4', 0, 'Metallic Silver')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (81, '899B5F', 0, 'Metallic Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (82, 'DBAC34', 0, 'Metallic Gold')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (84, 'CC702A', 0, 'Medium Dark Flesh')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (85, '3F3691', 0, 'Dark Purple')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (86, '7C503A', 0, 'Dark Flesh')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (89, '4C61DB', 0, 'Royal Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (92, 'D09168', 0, 'Flesh')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (100, 'FEBABD', 0, 'Light Salmon')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (110, '4354A3', 0, 'Violet')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (112, '6874CA', 0, 'Blue-Violet')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (114, 'DF6695', 1, 'Glitter Trans-Dark Pink')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (115, 'C7D23C', 0, 'Medium Lime')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (117, 'FFFFFF', 1, 'Glitter Trans-Clear')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (118, 'B3D7D1', 0, 'Aqua')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (120, 'D9E4A7', 0, 'Light Lime')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (125, 'F9BA61', 0, 'Light Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (129, 'A5A5CB', 1, 'Glitter Trans-Purple')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (132, '000000', 0, 'Speckle Black-Silver')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (133, '000000', 0, 'Speckle Black-Gold')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (134, 'AE7A59', 0, 'Copper')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (135, '9CA3A8', 0, 'Pearl Light Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (137, '7988A1', 0, 'Metal Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (142, 'DCBC81', 0, 'Pearl Light Gold')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (143, 'CFE2F7', 1, 'Trans-Medium Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (148, '575857', 0, 'Pearl Dark Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (150, 'ABADAC', 0, 'Pearl Very Light Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (151, 'E6E3E0', 0, 'Very Light Bluish Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (158, 'DFEEA5', 0, 'Yellowish Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (178, 'B48455', 0, 'Flat Dark Gold')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (179, '898788', 0, 'Flat Silver')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (182, 'F08F1C', 1, 'Trans-Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (183, 'F2F3F2', 0, 'Pearl White')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (191, 'F8BB3D', 0, 'Bright Light Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (212, '9FC3E9', 0, 'Bright Light Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (216, 'B31004', 0, 'Rust')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (226, 'FFF03A', 0, 'Bright Light Yellow')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (230, 'E4ADC8', 1, 'Trans-Pink')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (232, '7DBFDD', 0, 'Sky Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (236, '96709F', 1, 'Trans-Light Purple')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (272, '0A3463', 0, 'Dark Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (288, '184632', 0, 'Dark Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (294, 'BDC6AD', 1, 'Glow In Dark Trans')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (297, 'AA7F2E', 0, 'Pearl Gold')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (308, '352100', 0, 'Dark Brown')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (313, '3592C3', 0, 'Maersk Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (320, '720E0F', 0, 'Dark Red')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (321, '078BC9', 0, 'Dark Azure')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (322, '36AEBF', 0, 'Medium Azure')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (323, 'ADC3C0', 0, 'Light Aqua')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (326, '9B9A5A', 0, 'Olive Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (334, 'BBA53D', 0, 'Chrome Gold')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (335, 'D67572', 0, 'Sand Red')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (351, 'F785B1', 0, 'Medium Dark Pink')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (366, 'FA9C1C', 0, 'Earth Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (373, '845E84', 0, 'Sand Purple')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (378, 'A0BCAC', 0, 'Sand Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (379, '6074A1', 0, 'Sand Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (383, 'E0E0E0', 0, 'Chrome Silver')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (450, 'B67B50', 0, 'Fabuland Brown')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (462, 'FFA70B', 0, 'Medium Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (484, 'A95500', 0, 'Dark Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (503, 'E6E3DA', 0, 'Very Light Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (1000, 'D9D9D9', 0, 'Glow in Dark White')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (1001, '9391E4', 0, 'Medium Violet')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (1002, 'C0F500', 1, 'Glitter Trans-Neon Green')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (1003, '68BCC5', 1, 'Glitter Trans-Light Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (1004, 'FCB76D', 1, 'Trans Flame Yellowish Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (1005, 'FBE890', 1, 'Trans Fire Yellow')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (1006, 'B4D4F7', 1, 'Trans Light Royal Blue')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (1007, '8E5597', 0, 'Reddish Lilac')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (9999, '05131D', 0, '[No Color]')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (494, 'D0D0D0', 0, 'Electric Contact Alloy')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (493, '656761', 0, 'Magnet')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (375, 'C1C2C1', 0, 'Rubber Light Gray')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (324, 'C40026', 0, 'Rubber Red')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (256, '212121', 0, 'Rubber Black')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (67, 'FFFFFF', 1, 'Rubber Trans Clear')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (38, 'FF800D', 1, 'Trans-Neon Orange')");
$this->addSql("INSERT INTO color (id, rgb, transparent, name) VALUES (39, 'C1DFF0', 1, 'Trans Very Light Blue')");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');
}
}

View File

@ -1,4 +1,7 @@
# Define the relationship between LDraw models that are not automatically recognizabe to eliminate duplication of models # Define the relationship between LDraw models that are not automatically recognizable to eliminate duplication of models
# (filename or content does not match the LDraw specifications or models have same shape and unique color number)
#
# This file is used during model loading process.
# #
# format: # format:
# alias_ID: model_ID # alias_ID: model_ID
@ -48,8 +51,6 @@
82359: 3626b 82359: 3626b
122c02: 122c01
# Bucket 1 x 1 x 1 Cylindrical # Bucket 1 x 1 x 1 Cylindrical
12884c02: 12884c01 12884c02: 12884c01
@ -140,6 +141,15 @@ u9105p01c03: u9105p01c02
# Figure Fabuland Elephant Head # Figure Fabuland Elephant Head
u588p02c02: u588p01c02 u588p02c02: u588p01c02
92198p01c05: 92198p01c03
92198p01c13: 92198p01c07
92198p02c05: 92198p02c04
92198p08c05: 92198p02c04
# Figure Friends Chloe
92198p02c02: 92198p02c01
92198p04c03: 92198p02c01
30461c02: 30461c01 30461c02: 30461c01
10350p01c01: 10350c01 10350p01c01: 10350c01
@ -198,7 +208,6 @@ u588p02c02: u588p01c02
32181c03: 32181c01 32181c03: 32181c01
76019: 76244
4107539: 76244 4107539: 76244
3680c02: 3680c01 3680c02: 3680c01
@ -218,3 +227,100 @@ u588p02c02: u588p01c02
75192: 2977c01 75192: 2977c01
4539364: 64776 4539364: 64776
92710c01: 92709
92710c02: 92709
92710c03: 92709
54779c01: 54779
54779c02: 54779
# Bike 3 Wheel Motorcycle Body
30187c05: 30187c04
30187c06: 30187c04
30225bp1: 30225b
u9107p01c03: u9107p01c02
u9107p02c02: u9107p01c02
u9107p03c02: u9107p01c02
u9107p03c03: u9107p01c02
u9107p04c02: u9107p01c02
u9107p04c03: u9107p01c02
u9107p05c02: u9107p01c02
u9107p05c03: u9107p01c02
u9107p06c02: u9107p01c02
u9107p02c01: u9107p01c01
u9107p03c01: u9107p01c01
u9107p04c01: u9107p01c01
u9107p05c01: u9107p01c01
u9107p06c01: u9107p01c01
4100341: 6053c01
# Plane Aft Section 8 x 16 x 7
54654c02: 54654c01
54654c03: 54654c01
54654c04: 54654c01
54654c05: 54654c01
54654c06: 54654c01
54701p01c01: 54654c01
54779c01: 54779
54779c02: 54779
559c02: 559c01
57028b: 57028a
57028c: 57028a
57028d: 57028a
# Animal Cow Head
64835p01c01: 64835c01
64835p02c01: 64835c01
64779p01c01: 64779c01
# Sail Trapezoidal 28 x 17
64991c01: 64991
64991c02: 64991
64991c03: 64991
3135c02: 3135c01
3135c03: 3135c01
575c02: 575c01
u586p02c01: u586p01c01
u586p03c01: u586p01c01
u586p03c02: u586p01c02
u586p02c02: u586p01c02
u586p03c03: u586p01c04
u586p02c04: u586p01c04
u586p02c03: u586p01c03
u588p01c04: u588p01c03
u588p02c03: u588p01c03
u588p02c04: u588p01c05
u592p01c03: u592p01c02
u592p01c04: u592p01c02
u592p02c02: u592p01c02
u592p02c01: u592p01c01
u590p02c02: u590p01c02
u600p02c01: u600p01c01
u600p02c02: u600p01c02
u595p02c02: u595p01c03
u9153p02c02: u9153p01c02
u9153p02c01: u9153p01c01

View File

@ -1,6 +1,6 @@
# Define the relationship between LDraw models that are not automatically recognizabe to eliminate duplication of models # Define the relationship between LDraw models that are not automatically recognizabe to eliminate duplication of models
# #
# To load changes `run app:load:relation` command # To load changes run `bin/console app:load:relation` command
# #
# format: # format:
# rebrickable_part_ID: ldraw_model_ID # rebrickable_part_ID: ldraw_model_ID
@ -208,3 +208,5 @@ tech029: 2698c01
33299a: 33299 33299a: 33299
33299b: 33299 33299b: 33299
x222: 13459

View File

@ -2,7 +2,7 @@
namespace AppBundle\Controller\Rebrickable; namespace AppBundle\Controller\Rebrickable;
use AppBundle\Entity\Rebrickable\Color; use AppBundle\Entity\Color;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;

View File

@ -2,7 +2,7 @@
namespace AppBundle\Controller\Rebrickable; namespace AppBundle\Controller\Rebrickable;
use AppBundle\Entity\Rebrickable\Color; use AppBundle\Entity\Color;
use AppBundle\Entity\Rebrickable\Inventory_Part; use AppBundle\Entity\Rebrickable\Inventory_Part;
use AppBundle\Entity\Rebrickable\Inventory_Set; use AppBundle\Entity\Rebrickable\Inventory_Set;
use AppBundle\Entity\Rebrickable\Part; use AppBundle\Entity\Rebrickable\Part;

View File

@ -1,7 +1,8 @@
<?php <?php
namespace AppBundle\Entity\Rebrickable; namespace AppBundle\Entity;
use AppBundle\Entity\Rebrickable\Inventory_Part;
use AppBundle\Entity\Traits\NameTrait; use AppBundle\Entity\Traits\NameTrait;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@ -10,8 +11,8 @@ use Doctrine\ORM\Mapping as ORM;
/** /**
* Color. * Color.
* *
* @ORM\Table(name="rebrickable_color") * @ORM\Table(name="color")
* @ORM\Entity(repositoryClass="AppBundle\Repository\Rebrickable\ColorRepository") * @ORM\Entity(repositoryClass="AppBundle\Repository\ColorRepository")
*/ */
class Color class Color
{ {
@ -47,12 +48,20 @@ class Color
*/ */
protected $inventoryParts; protected $inventoryParts;
/**
* @var Collection
*
* @ORM\OneToMany(targetEntity="AppBundle\Entity\LDraw\Subpart", mappedBy="color")
*/
protected $subparts;
/** /**
* Constructor. * Constructor.
*/ */
public function __construct() public function __construct()
{ {
$this->inventoryParts = new ArrayCollection(); $this->inventoryParts = new ArrayCollection();
$this->subparts = new ArrayCollection();
} }
/** /**
@ -140,4 +149,12 @@ class Color
return $this; return $this;
} }
/**
* @return Collection
*/
public function getSubparts()
{
return $this->subparts;
}
} }

View File

@ -2,6 +2,7 @@
namespace AppBundle\Entity\LDraw; namespace AppBundle\Entity\LDraw;
use AppBundle\Entity\Color;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
@ -28,6 +29,14 @@ class Subpart
*/ */
private $subpart; private $subpart;
/**
* @var Color
*
* @ORM\Id
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Color", inversedBy="subparts")
*/
private $color;
/** /**
* @var int * @var int
* *
@ -75,6 +84,22 @@ class Subpart
return $this; return $this;
} }
/**
* @return Color
*/
public function getColor()
{
return $this->color;
}
/**
* @param Color $color
*/
public function setColor($color)
{
$this->color = $color;
}
/** /**
* @return int * @return int
*/ */

View File

@ -2,6 +2,7 @@
namespace AppBundle\Entity\Rebrickable; namespace AppBundle\Entity\Rebrickable;
use AppBundle\Entity\Color;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
/** /**
@ -22,7 +23,7 @@ class Inventory_Part
/** /**
* @var Color * @var Color
* @ORM\Id * @ORM\Id
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Rebrickable\Color", inversedBy="inventoryParts") * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Color", inversedBy="inventoryParts")
*/ */
protected $color; protected $color;

View File

@ -0,0 +1,7 @@
<?php
namespace AppBundle\Repository;
class ColorRepository extends BaseRepository
{
}

View File

@ -2,14 +2,15 @@
namespace AppBundle\Repository\LDraw; namespace AppBundle\Repository\LDraw;
use AppBundle\Entity\Color;
use AppBundle\Entity\LDraw\Subpart; use AppBundle\Entity\LDraw\Subpart;
use AppBundle\Repository\BaseRepository; use AppBundle\Repository\BaseRepository;
class SubpartRepository extends BaseRepository class SubpartRepository extends BaseRepository
{ {
public function findOneByKeys($parent, $child) public function findOneByKeys($parent, $child, $color)
{ {
return $this->find(['parent' => $parent, 'subpart' => $child]); return $this->find(['parent' => $parent, 'subpart' => $child, 'color' => $color]);
} }
/** /**
@ -19,16 +20,23 @@ class SubpartRepository extends BaseRepository
* *
* @return Subpart * @return Subpart
*/ */
public function getOrCreate($parent, $child, $count) public function getOrCreate($parent, $child, $count, $colorId)
{ {
if (($subpart = $this->findOneByKeys($parent, $child))) { if (($subpart = $this->findOneByKeys($parent, $child, $colorId))) {
$subpart->setCount($count); $subpart->setCount($count);
} else { } else {
$subpart = new Subpart(); $subpart = new Subpart();
$colorRepository = $this->getEntityManager()->getRepository(Color::class);
if(!($color = $colorRepository->find($colorId))) {
$color = $colorRepository->find(-1);
}
$subpart $subpart
->setParent($parent) ->setParent($parent)
->setSubpart($child) ->setSubpart($child)
->setCount($count); ->setCount($count)
->setColor($color);
} }
return $subpart; return $subpart;

View File

@ -1,9 +0,0 @@
<?php
namespace AppBundle\Repository\Rebrickable;
use AppBundle\Repository\BaseRepository;
class ColorRepository extends BaseRepository
{
}

View File

@ -179,16 +179,18 @@ class ModelLoader extends BaseLoader
// Recursively load models of subparts // Recursively load models of subparts
if (isset($modelArray['subparts'])) { if (isset($modelArray['subparts'])) {
foreach ($modelArray['subparts'] as $subpartId => $count) { foreach ($modelArray['subparts'] as $subpartId => $colors) {
// Try to find model of subpart foreach ($colors as $color => $count) {
if (($subpartFile = $this->findSubmodelFile($subpartId, $fileContext)) !== null) { // Try to find model of subpart
$subModel = $this->loadModel($subpartFile); if (($subpartFile = $this->findSubmodelFile($subpartId, $fileContext)) !== null) {
if ($subModel) { $subModel = $this->loadModel($subpartFile);
$subpart = $this->em->getRepository(Subpart::class)->getOrCreate($model, $subModel, $count); if ($subModel) {
$model->addSubpart($subpart); $subpart = $this->em->getRepository(Subpart::class)->getOrCreate($model, $subModel, $count, $color);
$model->addSubpart($subpart);
}
} else {
$this->logger->error('Subpart file not found', ['subpart' => $subpartId, 'model' => $modelArray]);
} }
} else {
$this->logger->error('Subpart file not found', ['subpart' => $subpartId, 'model' => $modelArray]);
} }
} }
} }
@ -217,7 +219,6 @@ class ModelLoader extends BaseLoader
} }
} catch (ConvertingFailedException $e) { } catch (ConvertingFailedException $e) {
$this->logger->error($e->getMessage()); $this->logger->error($e->getMessage());
return null; return null;
} }

View File

@ -16,7 +16,12 @@ class LDModelParser
* 'author' => string * 'author' => string
* 'modified' => DateTime * 'modified' => DateTime
* 'type' => string * 'type' => string
* 'subparts' => [], * 'subparts' => [
* 'id' => [
* 'color' => int
* ]
* ],
* 'parent' => sting
* 'licence' => string * 'licence' => string
* ]. * ].
* *
@ -67,7 +72,7 @@ class LDModelParser
} }
// 0 Name: <Filename>.dat // 0 Name: <Filename>.dat
elseif (strpos($line, 'Name: ') === 0 && !isset($header['id'])) { elseif (strpos($line, 'Name: ') === 0 && !isset($header['id'])) {
$model['id'] = preg_replace('/(^Name: )(.*)(.dat)/', '$2', $line); $model['id'] = preg_replace('/(^Name: )(.*)(.dat|.DAT)/', '$2', $line);
} }
// 0 Author: <Realname> [<Username>] // 0 Author: <Realname> [<Username>]
elseif (strpos($line, 'Author: ') === 0) { elseif (strpos($line, 'Author: ') === 0) {
@ -90,19 +95,23 @@ class LDModelParser
$model['license'] = preg_replace('/(^!LICENSE )(.*) : (.*)$/', '$2', $line); $model['license'] = preg_replace('/(^!LICENSE )(.*) : (.*)$/', '$2', $line);
} }
} elseif (strpos($line, '1 ') === 0) { } elseif (strpos($line, '1 ') === 0) {
$id = strtolower($this->getReferencedModelNumber($line)); $reference = $this->getReferencedModelNumber($line);
if (isset($model['subparts'][$id])) { $id = strtolower($reference['id']);
$model['subparts'][$id] = $model['subparts'][$id] + 1; $color = strtolower($reference['color']);
// group subparts by color and id
if (isset($model['subparts'][$id][$color])) {
$model['subparts'][$id][$color] = $model['subparts'][$id][$color] + 1;
} else { } else {
$model['subparts'][$id] = 1; $model['subparts'][$id][$color] = 1;
} }
} elseif (!empty($line) && !in_array($line[0], ['2', '3', '4', '5'])) { } elseif (!empty($line) && !in_array($line[0], ['2', '3', '4', '5'])) {
throw new ErrorParsingLineException($model['id'],$line); throw new ErrorParsingLineException($model['id'],$line);
} }
} }
if ($this->isSticker($model['name'], $model['id'])) { if ($this->isSticker($model['name'], $model['id']) && !in_array($model['type'], ['48_Primitive', '8_Primitive', 'Primitive', 'Subpart'])) {
$model['type'] = 'Sticker'; $model['type'] = 'Sticker';
} elseif (count($model['subparts']) == 1 && in_array($model['type'], ['Part Alias', 'Shortcut Physical_Colour', 'Shortcut Alias', 'Part Physical_Colour'])) { } elseif (count($model['subparts']) == 1 && in_array($model['type'], ['Part Alias', 'Shortcut Physical_Colour', 'Shortcut Alias', 'Part Physical_Colour'])) {
$model['parent'] = array_keys($model['subparts'])[0]; $model['parent'] = array_keys($model['subparts'])[0];
@ -130,10 +139,13 @@ class LDModelParser
*/ */
public function getReferencedModelNumber($line) public function getReferencedModelNumber($line)
{ {
$line = ($line); $line = strtolower(preg_replace('!\s+!', ' ', $line));
if (preg_match('/^1(.*) (.*)\.dat$/', strtolower($line), $matches)) { if (preg_match('/^1 ([0-9]{1,3}) (.*) (.*)\.dat$/', $line, $matches)) {
return str_replace('\\', DIRECTORY_SEPARATOR, $matches[2]); $id = str_replace('\\', DIRECTORY_SEPARATOR, $matches[3]);
$color = $matches[1];
return ['id' => $id, 'color' => $color];
} }
return null; return null;
@ -180,7 +192,7 @@ class LDModelParser
} }
// Check if in format n*Daa == sticker // Check if in format n*Daa == sticker
return preg_match('/(^.*)(d[0-9]{2})$/', $number); return preg_match('/(^.*)(d[0-9a-z]{2})$/', $number);
} }
/** /**