Exemple #1
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);
     
     // 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);
         }
     }
 }
        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 SpiMtx Ops. Invalid cache type.";
                throw Exception(os.str().c_str());
            }

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

            CreateMatrixOffsetOp(ops,
                                 cachedFile->m44,
                                 cachedFile->offset4,
                                 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);
     
     // 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());
     }
 }