diff --git a/Test/Interactive/rtbFetchReferenceData.m b/Test/Interactive/rtbFetchReferenceData.m new file mode 100644 index 0000000000000000000000000000000000000000..8b400f66c862002c233f8a601277efbe7a9f58aa --- /dev/null +++ b/Test/Interactive/rtbFetchReferenceData.m @@ -0,0 +1,64 @@ +function [renderings, referenceRoot, artifact] = rtbFetchReferenceData(recipeName, varargin) +% Fetch a reference rendering and make it available locally. +% +% renderings = rtbFetchReferenceData(recipeName) fetches a reference data +% zip-file from the default brainard-archiva server. The given recipeName +% must be the name of an rtb example recipe, like 'rtbMakeDragon'. Expands +% the fetched zip file into the current directory. Returns a struct array +% of rendering data files that were found in the reference data. +% +% Also returns the path to the root folder where the zip file was expanded. +% Also returns the RemoteDataToolbox artifact record for the fetched data. +% +% rtbFetchReferenceData( ... 'rdtConfig', rdtConfig) specify the Remote +% Data Toolbox configuration to use. The default is 'render-toolbox'. +% +% rtbFetchReferenceData( ... 'remotePath', remotePath) specify the Remote +% Data Toolbox artifact path to use. The default is 'reference-data'. +% +% rtbFetchReferenceData( ... 'referenceVersion', referenceVersion) specify +% the Remote Data Toolbox artifact version to fetch. The default is '+', +% the latest available. +% +% rtbFetchReferenceData( ... 'referenceRoot', referenceRoot) specify the +% root folder where to expand the fetched zip file. The default is pwd(). +% +% [renderings, referenceRoot, artifact] = rtbFetchReferenceData(recipeName, varargin) +% +%%% RenderToolbox4 Copyright (c) 2012-2017 The RenderToolbox Team. +%%% About Us://github.com/RenderToolbox/RenderToolbox4/wiki/About-Us +%%% RenderToolbox4 is released under the MIT License. See LICENSE file. + +parser = inputParser(); +parser.addRequired('recipeName', @ischar); +parser.addParameter('rdtConfig', 'render-toolbox'); +parser.addParameter('remotePath', 'reference-data', @ischar); +parser.addParameter('referenceVersion', '+', @ischar); +parser.addParameter('referenceRoot', pwd(), @ischar); +parser.parse(recipeName, varargin{:}); +recipeName = parser.Results.recipeName; +rdtConfig = parser.Results.rdtConfig; +remotePath = parser.Results.remotePath; +referenceVersion = parser.Results.referenceVersion; +referenceRoot = parser.Results.referenceRoot; + + +%% Get a whole recipe from the server. +artifactPath = fullfile(remotePath, recipeName); +[fileName, artifact] = rdtReadArtifact(rdtConfig, artifactPath, recipeName, ... + 'version', referenceVersion, ... + 'type', 'zip'); + +if isempty(fileName) + renderings = []; + artifact = []; + return; +end + + +%% Explode renderings it into the destination folder. +destination = fullfile(referenceRoot, recipeName); +unzip(fileName, destination); + +% scan for rendering records +renderings = rtbFindRenderings(destination); diff --git a/Test/Interactive/rtbFindRenderings.m b/Test/Interactive/rtbFindRenderings.m index 64114173d080408b2f724cb21c39e2c1fc60344b..cdde19cb50fced1a4ba722f4c9b6fd6ca2b2adaa 100644 --- a/Test/Interactive/rtbFindRenderings.m +++ b/Test/Interactive/rtbFindRenderings.m @@ -63,11 +63,7 @@ for ff = 1:nFiles renderingsFolderIndex = find(isRenderingsFolder, 1, 'last'); % recipe name comes just before renderingsFolderName - % ignore "rtb" prefix if any recipeName = pathParts{renderingsFolderIndex - 1}; - if strncmp(recipeName, 'rtb', 3) - recipeName = recipeName(4:end); - end % renderer name comes just after renderingsFolderName, if any if nPathParts > renderingsFolderIndex diff --git a/Test/Interactive/rtbRenderingRecord.m b/Test/Interactive/rtbRenderingRecord.m index 1a57ff03a24f0b4e3baa79d87b385016aff102f9..ce806872ccb708c241933fe53fd713f0bd8e678d 100644 --- a/Test/Interactive/rtbRenderingRecord.m +++ b/Test/Interactive/rtbRenderingRecord.m @@ -26,5 +26,23 @@ parser.addParameter('imageName', '',@ischar); parser.addParameter('fileName', '', @ischar); parser.parse(varargin{:}); -% let the parser do all the work +% let the parser do most of the work record = parser.Results; + +% format an identifier useful for comparing records with eg setdiff() +recipeName = record.recipeName; +if strncmp(recipeName, 'rtb', 3) + recipeName = recipeName(4:end); +end + +if isempty(record.imageNumber) + record.identifier = sprintf('%s-%s-%s', ... + recipeName, ... + record.rendererName, ... + record.imageName); +else + record.identifier = sprintf('%s-%s-%d', ... + recipeName, ... + record.rendererName, ... + record.imageNumber); +end