void
 LocalFileFormat::BuildFileOps(OpRcPtrVec & ops,
                               const Config& /*config*/,
                               const ConstContextRcPtr & /*context*/,
                               CachedFileRcPtr untypedCachedFile,
                               const FileTransform& fileTransform,
                               TransformDirection dir) const
 {
     LocalCachedFileRcPtr cachedFile = DynamicPtrCast<LocalCachedFile>(untypedCachedFile);
     
     // This should never happen.
     if(!cachedFile)
     {
         std::ostringstream os;
         os << "Cannot build .3dl Op. Invalid cache type.";
         throw Exception(os.str().c_str());
     }
     
     TransformDirection newDir = CombineTransformDirections(dir,
         fileTransform.getDirection());
     if(newDir == TRANSFORM_DIR_UNKNOWN)
     {
         std::ostringstream os;
         os << "Cannot build file format transform,";
         os << " unspecified transform direction.";
         throw Exception(os.str().c_str());
     }
     
     // TODO: INTERP_LINEAR should not be hard-coded.
     // Instead query 'highest' interpolation?
     // (right now, it's linear). If cubic is added, consider
     // using it
     
     if(newDir == TRANSFORM_DIR_FORWARD)
     {
         if(cachedFile->has1D)
         {
             CreateLut1DOp(ops, cachedFile->lut1D,
                           INTERP_LINEAR, newDir);
         }
         if(cachedFile->has3D)
         {
             CreateLut3DOp(ops, cachedFile->lut3D,
                           fileTransform.getInterpolation(), newDir);
         }
     }
     else if(newDir == TRANSFORM_DIR_INVERSE)
     {
         if(cachedFile->has3D)
         {
             CreateLut3DOp(ops, cachedFile->lut3D,
                           fileTransform.getInterpolation(), newDir);
         }
         if(cachedFile->has1D)
         {
             CreateLut1DOp(ops, cachedFile->lut1D,
                           INTERP_LINEAR, newDir);
         }
     }
 }
Exemple #2
0
 void
 LocalFileFormat::BuildFileOps(OpRcPtrVec & ops,
                               const Config& config,
                               const ConstContextRcPtr & /*context*/,
                               CachedFileRcPtr untypedCachedFile,
                               const FileTransform& fileTransform,
                               TransformDirection dir) const
 {
     LocalCachedFileRcPtr cachedFile = DynamicPtrCast<LocalCachedFile>(untypedCachedFile);
     
     // This should never happen.
     if(!cachedFile)
     {
         std::ostringstream os;
         os << "Cannot build .cc Op. Invalid cache type.";
         throw Exception(os.str().c_str());
     }
     
     TransformDirection newDir = CombineTransformDirections(dir,
         fileTransform.getDirection());
     if(newDir == TRANSFORM_DIR_UNKNOWN)
     {
         std::ostringstream os;
         os << "Cannot build file format transform,";
         os << " unspecified transform direction.";
         throw Exception(os.str().c_str());
     }
     
     BuildCDLOps(ops,
                 config,
                 *cachedFile->transform,
                 newDir);
 }
        void LocalFileFormat::BuildFileOps(OpRcPtrVec & ops,
                                  const Config& /*config*/,
                                  const ConstContextRcPtr & /*context*/,
                                  CachedFileRcPtr untypedCachedFile,
                                  const FileTransform& fileTransform,
                                  TransformDirection dir) const
        {
            LocalCachedFileRcPtr cachedFile = DynamicPtrCast<LocalCachedFile>(untypedCachedFile);

            if(!cachedFile) // This should never happen.
            {
                std::ostringstream os;
                os << "Cannot build Spi1D Op. Invalid cache type.";
                throw Exception(os.str().c_str());
            }

            TransformDirection newDir = CombineTransformDirections(dir,
                fileTransform.getDirection());

            CreateLut1DOp(ops,
                          cachedFile->lut,
                          fileTransform.getInterpolation(),
                          newDir);
        }
 void BuildFileOps(OpRcPtrVec & ops,
                   const Config& config,
                   const ConstContextRcPtr & context,
                   const FileTransform& fileTransform,
                   TransformDirection dir)
 {
     std::string src = fileTransform.getSrc();
     if(src.empty())
     {
         std::ostringstream os;
         os << "The transform file has not been specified.";
         throw Exception(os.str().c_str());
     }
     
     std::string filepath = context->resolveFileLocation(src.c_str());
     CreateFileNoOp(ops, filepath);
     
     FileFormat* format = NULL;
     CachedFileRcPtr cachedFile;
     
     GetCachedFileAndFormat(format, cachedFile, filepath);
     if(!format)
     {
         std::ostringstream os;
         os << "The specified file load ";
         os << filepath << " appeared to succeed, but no format ";
         os << "was returned.";
         throw Exception(os.str().c_str());
     }
     
     if(!cachedFile.get())
     {
         std::ostringstream os;
         os << "The specified file load ";
         os << filepath << " appeared to succeed, but no cachedFile ";
         os << "was returned.";
         throw Exception(os.str().c_str());
     }
     
     format->BuildFileOps(ops,
                          config, context,
                          cachedFile, fileTransform,
                          dir);
 }
 void
 LocalFileFormat::BuildFileOps(OpRcPtrVec & ops,
                               const Config& config,
                               const ConstContextRcPtr & context,
                               CachedFileRcPtr untypedCachedFile,
                               const FileTransform& fileTransform,
                               TransformDirection dir) const
 {
     LocalCachedFileRcPtr cachedFile = DynamicPtrCast<LocalCachedFile>(untypedCachedFile);
     
     // This should never happen.
     if(!cachedFile)
     {
         std::ostringstream os;
         os << "Cannot build .cdl Op. Invalid cache type.";
         throw Exception(os.str().c_str());
     }
     
     TransformDirection newDir = CombineTransformDirections(dir,
         fileTransform.getDirection());
     if(newDir == TRANSFORM_DIR_UNKNOWN)
     {
         std::ostringstream os;
         os << "Cannot build ASC FileTransform,";
         os << " unspecified transform direction.";
         throw Exception(os.str().c_str());
     }
     
     // Below this point, we should throw ExceptionMissingFile on
     // errors rather than Exception
     // This is because we've verified that the cdl file is valid,
     // at now we're only querying whether the specified cccid can
     // be found.
     //
     // Using ExceptionMissingFile enables the missing looks fallback
     // mechanism to function properly.
     // At the time ExceptionMissingFile was named, we errently assumed
     // a 1:1 relationship between files and color corrections, which is
     // not true for .cdl files.
     //
     // In a future OCIO release, it may be more appropriate to
     // rename ExceptionMissingFile -> ExceptionMissingCorrection.
     // But either way, it's what we should throw below.
     
     std::string cccid = fileTransform.getCCCId();
     cccid = context->resolveStringVar(cccid.c_str());
     
     if(cccid.empty())
     {
         std::ostringstream os;
         os << "You must specify which cccid to load from the ccc file";
         os << " (either by name or index).";
         throw ExceptionMissingFile(os.str().c_str());
     }
     
     bool success=false;
     
     // Try to parse the cccid as a string id
     CDLTransformMap::const_iterator iter = cachedFile->transformMap.find(cccid);
     if(iter != cachedFile->transformMap.end())
     {
         success = true;
         BuildCDLOps(ops,
                     config,
                     *(iter->second),
                     newDir);
     }
     
     // Try to parse the cccid as an integer index
     // We want to be strict, so fail if leftover chars in the parse.
     if(!success)
     {
         int cccindex=0;
         if(StringToInt(&cccindex, cccid.c_str(), true))
         {
             int maxindex = ((int)cachedFile->transformVec.size())-1;
             if(cccindex<0 || cccindex>maxindex)
             {
                 std::ostringstream os;
                 os << "The specified cccindex " << cccindex;
                 os << " is outside the valid range for this file [0,";
                 os << maxindex << "]";
                 throw ExceptionMissingFile(os.str().c_str());
             }
             
             success = true;
             BuildCDLOps(ops,
                         config,
                         *cachedFile->transformVec[cccindex],
                         newDir);
         }
     }
     
     if(!success)
     {
         std::ostringstream os;
         os << "You must specify a valid cccid to load from the ccc file";
         os << " (either by name or index). id='" << cccid << "' ";
         os << "is not found in the file, and is not parsable as an ";
         os << "integer index.";
         throw ExceptionMissingFile(os.str().c_str());
     }
 }