001/*
002 * (C) Copyright 2006-2016 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Tiago Cardoso <tcardoso@nuxeo.com>
018 */
019package org.nuxeo.ecm.platform.threed.convert;
020
021import org.nuxeo.ecm.core.api.Blob;
022import org.nuxeo.ecm.core.api.blobholder.BlobHolder;
023import org.nuxeo.ecm.core.convert.api.ConversionException;
024
025import java.io.Serializable;
026import java.util.HashMap;
027import java.util.Map;
028import static org.nuxeo.ecm.platform.threed.convert.Constants.*;
029import static org.nuxeo.ecm.platform.threed.convert.Constants.MAX_TEX_PARAMETER;
030import static org.nuxeo.ecm.platform.threed.convert.Constants.PERC_TEX_PARAMETER;
031
032/**
033 * Level of details converter for 3D document type
034 *
035 * @since 8.4
036 */
037public class LodsConverter extends BaseBlenderConverter {
038
039    @Override
040    protected Map<String, Blob> getCmdBlobParameters(BlobHolder blobHolder, Map<String, Serializable> parameters)
041            throws ConversionException {
042        return null;
043    }
044
045    @Override
046    protected Map<String, String> getCmdStringParameters(BlobHolder blobHolder, Map<String, Serializable> parameters)
047            throws ConversionException {
048        Map<String, String> cmdStringParams = new HashMap<>();
049
050        String percPoly = null;
051        if (parameters.containsKey(PERC_POLY_PARAMETER)) {
052            percPoly = (String) parameters.get(PERC_POLY_PARAMETER);
053        } else if (initParameters.containsKey(PERC_POLY_PARAMETER)) {
054            percPoly = initParameters.get(PERC_POLY_PARAMETER);
055        }
056        cmdStringParams.put(PERC_POLY_PARAMETER, percPoly);
057
058        String maxPoly = null;
059        if (parameters.containsKey(MAX_POLY_PARAMETER)) {
060            maxPoly = (String) parameters.get(MAX_POLY_PARAMETER);
061        } else if (initParameters.containsKey(MAX_POLY_PARAMETER)) {
062            maxPoly = initParameters.get(MAX_POLY_PARAMETER);
063        }
064        cmdStringParams.put(MAX_POLY_PARAMETER, maxPoly);
065
066        String percTex = null;
067        if (parameters.containsKey(PERC_TEX_PARAMETER)) {
068            percTex = (String) parameters.get(PERC_TEX_PARAMETER);
069        } else if (initParameters.containsKey(PERC_TEX_PARAMETER)) {
070            percTex = initParameters.get(PERC_TEX_PARAMETER);
071        }
072        cmdStringParams.put(PERC_TEX_PARAMETER, percTex);
073
074        String maxTex = null;
075        if (parameters.containsKey(MAX_TEX_PARAMETER)) {
076            maxTex = (String) parameters.get(MAX_TEX_PARAMETER);
077        } else if (initParameters.containsKey(MAX_TEX_PARAMETER)) {
078            maxTex = initParameters.get(MAX_TEX_PARAMETER);
079        }
080        cmdStringParams.put(MAX_TEX_PARAMETER, maxTex);
081
082        return cmdStringParams;
083    }
084
085}