1
0
mirror of https://github.com/ToxicCrack/PrintABrick.git synced 2025-05-17 21:00:09 -07:00

Improve models quality

Use high-quality studs
This commit is contained in:
Unknown 2017-06-14 17:47:38 +02:00
parent 50248d4d69
commit 4cd5ce1874
5 changed files with 22 additions and 7 deletions

View File

@ -59,5 +59,10 @@ This command consists of multiple subcommands that can be called separately:
4. Download images of models from rebrickable.com `$ bin/console app:load:images [--color=INT] [--rebrickable] [--missing]` 4. Download images of models from rebrickable.com `$ bin/console app:load:images [--color=INT] [--rebrickable] [--missing]`
5. Populate Elastisearch index `$ bin/console fos:elastica:populate` 5. Populate Elastisearch index `$ bin/console fos:elastica:populate`
##### Adding part relation
Relations between LDraw models and Rebrickable parts are matched automatically by identical (or similar) id/name when executing command `$ bin/console app:load:relation`.
Unmatched relations can be specified by adding relation of IDs to `app/Resources/relations/part_model.yml`
## Testing ## Testing
You can run complete system tests by `$ phpunit`. These should cover the main system functions and the functionality of calling the third-party programs that are required are needed to seamlessly retrieve the necessary application data. You can run complete system tests by `$ phpunit`. These should cover the main system functions and the functionality of calling the third-party programs that are required are needed to seamlessly retrieve the necessary application data.

View File

@ -12,7 +12,7 @@ parameters:
name: "PrintABrick" name: "PrintABrick"
# rebrickable csv files root URL (http://rebrickable.com/media/downloads/ or local dir containing csv files) # rebrickable csv files root URL (http://rebrickable.com/media/downloads/ or local dir containing csv files)
app.rebrickable_downloads_url: 'http://rebrickable.com/media/downloads/' app.rebrickable_downloads_url: 'http://rebrickable.com/media/downloads/'
app.ld_library_download_url: 'http://www.ldraw.org/library/updates/completeCA.zip' app.ld_library_download_url: 'http://www.ldraw.org/library/updates/complete.zip'
app.media_root: "%kernel.root_dir%/../var/media/" app.media_root: "%kernel.root_dir%/../var/media/"

View File

@ -36,13 +36,13 @@ class ModelController extends Controller
{ {
$modelSearch = new ModelSearch(); $modelSearch = new ModelSearch();
$form = $formFactory->createNamedBuilder('', ModelSearchType::class, $modelSearch)->getForm(); $form = $formFactory->createNamedBuilder('model', ModelSearchType::class, $modelSearch)->getForm();
$form->handleRequest($request); $form->handleRequest($request);
/** @var Paginator $paginator */ /** @var Paginator $paginator */
$paginator = $this->get('knp_paginator'); $paginator = $this->get('knp_paginator');
$models = $paginator->paginate( $models = $paginator->paginate(
$searchService->searchModels($modelSearch), $searchService->searchModels($modelSearch,500),
$request->query->getInt('page', 1)/*page number*/, $request->query->getInt('page', 1)/*page number*/,
$request->query->getInt('limit', 30)/*limit per page*/ $request->query->getInt('limit', 30)/*limit per page*/
); );

View File

@ -45,9 +45,6 @@ class ModelLoader extends BaseLoader
/** @var RelationMapper */ /** @var RelationMapper */
private $relationMapper; private $relationMapper;
/** @var string */
private $LDLibraryUrl;
/** @var bool */ /** @var bool */
private $rewrite = false; private $rewrite = false;
@ -90,6 +87,12 @@ class ModelLoader extends BaseLoader
} }
} }
/**
* Download library form $url, unzip archive and return directory path with library
*
* @param $url
* @return bool|string
*/
public function downloadLibrary($url) public function downloadLibrary($url)
{ {
$this->writeOutput([ $this->writeOutput([
@ -116,6 +119,11 @@ class ModelLoader extends BaseLoader
$this->writeOutput(['<info>LDraw libary downloaded</info>']); $this->writeOutput(['<info>LDraw libary downloaded</info>']);
// return ldraw directory if in zip file
if(file_exists($temp_dir.'/ldraw/')) {
return $temp_dir.'/ldraw/';
}
return $temp_dir; return $temp_dir;
} }
@ -160,6 +168,7 @@ class ModelLoader extends BaseLoader
]); ]);
$files = $this->ldrawLibraryContext->listContents('parts', false); $files = $this->ldrawLibraryContext->listContents('parts', false);
$this->initProgressBar(count($files)); $this->initProgressBar(count($files));
$index = 0; $index = 0;
@ -274,7 +283,7 @@ class ModelLoader extends BaseLoader
try { try {
// update model only if newer version // update model only if newer version
if (!$model->getModified() || ($model->getModified() < $modelArray['modified'])) { if ($this->rewrite || ($model->getModified() < $modelArray['modified'])) {
$stl = $this->stlConverter->datToStl($file, $this->rewrite)->getPath(); $stl = $this->stlConverter->datToStl($file, $this->rewrite)->getPath();
$model->setPath($stl); $model->setPath($stl);

View File

@ -83,6 +83,7 @@ class StlConverterService
'-LDrawDir='.$this->ldrawLibraryContext->getAdapter()->getPathPrefix(), '-LDrawDir='.$this->ldrawLibraryContext->getAdapter()->getPathPrefix(),
'-ExportFiles=1', '-ExportFiles=1',
'-ExportSuffix=.stl', '-ExportSuffix=.stl',
'-UseQualityStuds=1',
'-ExportsDir='.$this->mediaFilesystem->getAdapter()->getPathPrefix().'models', '-ExportsDir='.$this->mediaFilesystem->getAdapter()->getPathPrefix().'models',
]); ]);