TuttleOFX  1
ColorSpaceKeyerPlugin.cpp
Go to the documentation of this file.
00001 #include "ColorSpaceKeyerPlugin.hpp"
00002 #include "ColorSpaceKeyerProcess.hpp"
00003 #include "ColorSpaceKeyerDefinitions.hpp"
00004 #include "CloudPointData.hpp"
00005 
00006 #include <boost/gil/gil_all.hpp>
00007 
00008 namespace tuttle {
00009 namespace plugin {
00010 namespace colorSpaceKeyer {
00011 
00012 
00013 ColorSpaceKeyerPlugin::ColorSpaceKeyerPlugin( OfxImageEffectHandle handle )
00014 : ImageEffectGilPlugin( handle )
00015 {
00016                 _clipColor = fetchClip( kClipColorSelection );
00017                 _clipSpill = fetchClip( kClipSpillSelection );
00018 
00019                 _paramBoolPointCloudDisplay = fetchBooleanParam( kPointCloudDisplay ); //Is CloudPointData displayed (boolean parameter)
00020                 _cloudPointDataCount = 0;
00021                 
00022                 //Associate intern parameters pointers to GUI components
00023                 _paramBoolDiscretizationActive = fetchBooleanParam(kBoolDiscretizationDisplay); //is discretization active on point cloud - check box
00024                 _paramIntDiscretization = fetchIntParam(kIntDiscretizationDisplay);                             //discretization step - Int parameter
00025                 _paramIntNbOfDivisionsGF = fetchIntParam(kIntNumberOfDivisonGeodesicForm);              //number of divisions geodesic form - Int parameter
00026                 _paramBoolDisplayGeodesicForm = fetchBooleanParam(kBoolOnlySelection);                  //display geodesic form - check box
00027                 _paramChoiceAverageMode = fetchChoiceParam(kColorAverageMode);                                  //average color mode - Choice parameter
00028                 _paramRGBAColorSelection = fetchRGBAParam(kColorAverageSelection);                              //average color selection - RGBA parameter
00029                 _paramPushButtonAverageCompute = fetchPushButtonParam(kColorAverageComputing);  //average color computing - Push button
00030                 _paramBoolSeeSelection = fetchBooleanParam(kBoolColorSelectionDisplay);                 //see selection on overlay - check box
00031                 _paramDoubleScaleGF = fetchDoubleParam(kDoubleScaleGeodesicForm);                               //scale geodesic form - double parameter
00032                 _paramBoolSeeSpillSelection = fetchBooleanParam(kBoolSpillSelectionDisplay);    //see spill selection - check box
00033                 _paramBoolDisplaySpillGF = fetchBooleanParam(kBoolDisplaySpillGF);                              //see spill geodesic form - check box
00034                 
00035                 //verify display Discrete enable value
00036                 if(_paramBoolPointCloudDisplay->getValue())     //called default value
00037                 {
00038                         _paramBoolDiscretizationActive->setEnabled(true);       //Enable discretization check box
00039                         _paramIntDiscretization->setEnabled(true);                      //Enable discretization int parameter
00040                         _paramBoolDisplayGeodesicForm->setEnabled(true);        //Enable see color geodesic form display
00041                         _paramBoolSeeSelection->setEnabled(true);                       //Enable see color selection display
00042                         _paramBoolDisplaySpillGF->setEnabled(true);                     //Enable see spill geodesic form display
00043                         _paramBoolSeeSpillSelection->setEnabled(true);          //Enable see spill selection display
00044                 }
00045                 //verify choice average enable value
00046                 if(_paramChoiceAverageMode->getValue() == 1)
00047                 {
00048                         _paramRGBAColorSelection->setEnabled(true);                     //Enable color average selection (RGBA parameter)
00049                         _paramPushButtonAverageCompute->setEnabled(true);       //Enable color average computing (Push button)
00050                 }
00051                 
00052                 _updateAverage = false;                                         //does display need to update average
00053                 _updateGeodesicForm = false;                            //does display need to update geodesic form
00054                 _updateVBO = false;                                                     //does display need to update VBO
00055                 _updateGeodesicFormAverage = false;                     //does Geodesic form need to be updated
00056                 _resetViewParameters = false;                           //do view parameters need to be reseted
00057                 _presetAverageSelection = false;                        //does average selection need to be set 
00058 }
00059 
00060 ColorSpaceKeyerProcessParams<ColorSpaceKeyerPlugin::Scalar> ColorSpaceKeyerPlugin::getProcessParams( const OfxPointD& renderScale ) const
00061 {
00062         ColorSpaceKeyerProcessParams<Scalar> params;                   // create parameters container object
00063         return params;                                                 // pass parameters to process
00064 }
00065 
00066 /**
00067  * A GUI parameter has changed
00068  * @param args          current time and renderScale
00069  * @param paramName parameter name (variable name)
00070  */
00071 void ColorSpaceKeyerPlugin::changedParam( const OFX::InstanceChangedArgs &args, const std::string &paramName )
00072 {
00073         if( paramName == kPointCloudDisplay) //display point cloud check box value has changed
00074         {
00075                 if( _paramBoolPointCloudDisplay->getValue() && hasCloudPointData() )    //display point cloud is selected
00076                 {
00077                         //enable discretization GUI components
00078                         _paramBoolDiscretizationActive->setEnabled(true);       //Enable discretization check box
00079                         _paramIntDiscretization->setEnabled(true);                      //Enable discretization int parameter
00080                         _paramBoolDisplayGeodesicForm->setEnabled(true);        //Enable geodesic form display
00081                         _paramBoolSeeSelection->setEnabled(true);                       //Enable geodesic form display
00082                         _paramBoolDisplaySpillGF->setEnabled(true);                     //Enable see spill geodesic form display
00083                         _paramBoolSeeSpillSelection->setEnabled(true);          //Enable see spill selection display
00084                         
00085                         //generate VBO data (VBO object is created in overlay)
00086                         getCloudPointData()._time = args.time;                          //update time
00087                         getCloudPointData().generateVBOData(                            //create a VBO
00088                                 _clipSrc,                                                                               //source clip
00089                                 args.renderScale,                                                               //current render scale
00090                                 _paramBoolDiscretizationActive->getValue(),             //is discretization mode active
00091                                 _paramIntDiscretization->getValue() );                  //get discretization step
00092                         //generate color selection VBO data (object created in overlay)
00093                         getCloudPointData().generateColorSelectionVBO(          //create a color selection VBO
00094                                 _clipColor,                                                                             //color clip
00095                                 args.renderScale,                                                               //current render scale
00096                                 _paramBoolDiscretizationActive->getValue(),             //is discretization mode active
00097                                 _paramIntDiscretization->getValue());                   //get discretization step
00098                         //generate spill selection VBO data (object created in overlay)
00099                         getCloudPointData().generateSpillSelectionVBO(          //create a spill selection VBO
00100                                 _clipSpill,                                                                             //spill clip
00101                                 args.renderScale,                                                               //current render scale
00102                                 _paramBoolDiscretizationActive->getValue(),             //is discretization mode active
00103                                 _paramIntDiscretization->getValue());                   //get discretization step
00104                         //update geodesic form
00105                         updateGeodesicForms(args);                                                      //update geodesic form
00106                 }
00107                 else                                                                                                    //display point cloud is not selected
00108                 {
00109                         //disable discretization GUI components
00110                         _paramBoolDiscretizationActive->setEnabled(false);      //Disable discretization treatment
00111                         _paramIntDiscretization->setEnabled(false);                     //Disable discretization choice
00112                         _paramBoolDisplayGeodesicForm->setEnabled(false);       //Disable geodesic form display
00113                         _paramBoolSeeSelection->setEnabled(false);                      //Disable geodesic form display
00114                         _paramBoolDisplaySpillGF->setEnabled(false);            //Disable see spill geodesic form display
00115                         _paramBoolSeeSpillSelection->setEnabled(false);         //Disable see spill selection display
00116                 }
00117         }
00118         if( paramName == kBoolDiscretizationDisplay) // discretization active check box changed
00119         {
00120                 if(hasCloudPointData()) //if there is overlay data
00121                 {
00122                         //generate VBO data
00123                         getCloudPointData()._time = args.time;                          //update time
00124                         getCloudPointData().generateVBOData(                            //create a VBO data
00125                                 _clipSrc,                                                                               //source clip
00126                                 args.renderScale,                                                               //current render scale
00127                                 _paramBoolDiscretizationActive->getValue(),             //is discretization mode active
00128                                 _paramIntDiscretization->getValue() );                  //get discretization step
00129                         //generate selection VBO data
00130                         getCloudPointData().generateColorSelectionVBO(          //create a selection VBO
00131                                 _clipColor,                                                                             //color clip
00132                                 args.renderScale,                                                               //current render scale
00133                                 _paramBoolDiscretizationActive->getValue(),             //is discretization mode active
00134                                 _paramIntDiscretization->getValue());                   //get discretization step
00135                         //generate spill selection VBO data (object created in overlay)
00136                         getCloudPointData().generateSpillSelectionVBO(          //create a spill selection VBO
00137                                 _clipSpill,                                                                             //spill clip
00138                                 args.renderScale,                                                               //current render scale
00139                                 _paramBoolDiscretizationActive->getValue(),             //is discretization mode active
00140                                 _paramIntDiscretization->getValue());                   //get discretization step
00141                         //update VBOs (create VBO objects in overlay)
00142                         _updateVBO = true;                                                                      //update VBO on overlay
00143                 }
00144         }
00145         if( paramName == kIntDiscretizationDisplay) //discretization value has changed (int range)
00146         {
00147                 if(hasCloudPointData() && _paramBoolDiscretizationActive->getValue()) //it is not batch mode
00148                 {
00149                         if(_paramBoolDiscretizationActive->getValue()) //discretization is active
00150                         {
00151                                 getCloudPointData()._time = args.time;          //update time
00152                                 getCloudPointData().generateVBOData(            //create a VBO data with discretization (and the new discretization step)
00153                                         _clipSrc,                                                               //source clip
00154                                         args.renderScale,                                               //current render scale
00155                                         true,                                                                   //create cloud point with discretization 
00156                                         _paramIntDiscretization->getValue() );  //get discretization step 
00157                                 _updateVBO = true;                                                      //update VBO on overlay
00158                         }
00159                 }
00160         }
00161         if( paramName == kIntNumberOfDivisonGeodesicForm) //number of divisions geodesic form has changed (int range)
00162         {
00163                 if(hasCloudPointData()) // if there is overlay data
00164                 {
00165                         updateGeodesicForms(args);
00166                 }
00167                 _renderAttributes.recomputeGeodesicForm = true;         //recompute process attributes
00168         }
00169         if( paramName == kPushButtonResetTransformationParameters && hasCloudPointData()) //Push button reset transformation has changed
00170         {
00171                  _resetViewParameters = true;                                                                                             //reset rotation view parameters on overlay
00172         }
00173         if( paramName == kColorAverageMode && hasCloudPointData())                                                //Average mode : choice list
00174         {
00175                 if(_paramChoiceAverageMode->getValue() == 1)                                                             //selection mode is manual
00176                         _paramRGBAColorSelection->setEnabled(true);                                                              //active component
00177                 else
00178                         _paramRGBAColorSelection->setEnabled(false);                                                     //disable component
00179                 updateGeodesicForms(args);                                                                                                       //update geodesic form
00180                 
00181         }
00182         if( paramName == kColorAverageSelection && hasCloudPointData())                                   //selection average RGBA component
00183         {
00184                 updateGeodesicForms(args);
00185         }
00186         if( paramName == kColorAverageComputing && hasCloudPointData())                                                         //push button : average computing (selection => manual)
00187         {
00188                 //update automatic average
00189                 getCloudPointData()._averageColor._time = args.time;                                                                    //change current time
00190                 getCloudPointData()._averageColor.computeAverageSelection(_clipColor,args.renderScale); //compute automatic average
00191                 //set computed average value into GUI component
00192                 double alpha = 1.0;     // alpha value of new average (doesn't care)
00193                 _paramRGBAColorSelection->setValue(
00194                         getCloudPointData()._averageColor._averageValue.x,              //red value
00195                         getCloudPointData()._averageColor._averageValue.y,              //green value
00196                         getCloudPointData()._averageColor._averageValue.z,              //blue value
00197                         alpha                                                                                                   //alpha value
00198                 );
00199                 //compute geodesic form
00200                 changedParam(args,kColorAverageSelection); //call changedParam function with modification of selectionAverage value
00201         }
00202         if(paramName == kDoubleScaleGeodesicForm && hasCloudPointData())
00203         {
00204                 updateGeodesicForms(args);
00205         }
00206 }
00207 
00208 /*
00209  * If clip has changed
00210  */
00211 void ColorSpaceKeyerPlugin::changedClip( const OFX::InstanceChangedArgs& args, const std::string& clipName )
00212 {
00213         if( clipName == kOfxImageEffectSimpleSourceClipName )   // if source clip has changed
00214         {
00215                 if( this->hasCloudPointData() )                                         //it is not batch mode
00216                 {
00217                         OFX::Clip* test = fetchClip(clipName);                  //test if source clip is connected
00218                         if(test->isConnected())
00219                         {
00220                                 getCloudPointData()._time = args.time;                                  //update time
00221                                 getCloudPointData().generateVBOData(                                    //create a VBO data with or without discretization
00222                                         _clipSrc,                                                                                       //source clip
00223                                         args.renderScale,                                                                       //current render scale
00224                                         _paramBoolDiscretizationActive->getValue(),                     //is discretization used to generate VBO
00225                                         _paramIntDiscretization->getValue() );                          //discretization step
00226                         
00227                                 _updateVBO = true;                      //update VBO on overlay
00228                                 this->redrawOverlays();         //redraw scene
00229                         }
00230                         else //source clip is no more connected
00231                                 getCloudPointData()._imgVBO.deleteVBO(); //delete VBO
00232                 }
00233         }
00234         else if( clipName == kClipColorSelection)                               // if color clip has changed
00235         {
00236                 _renderAttributes.recomputeGeodesicForm = true;         //recompute process attributes
00237                 if( this->hasCloudPointData() )                                         //it is not batch mode
00238                 {
00239                         OFX::Clip* test = fetchClip(clipName);                  //test if color clip is connected
00240                         if(test->isConnected())
00241                         {
00242                                 //generate selection VBO data
00243                                 getCloudPointData()._time = args.time;                                  //update time
00244                                 getCloudPointData().generateColorSelectionVBO(                  //create a selection VBO data with or without discretization
00245                                                 _clipColor,                                                                             //color clip
00246                                                 args.renderScale,                                                               //current render scale
00247                                                 _paramBoolDiscretizationActive->getValue(),             //is discretization used to generate selection VBO
00248                                                 _paramIntDiscretization->getValue());                   //discretization step
00249                                 updateGeodesicForms(args);
00250                         }
00251                 }
00252         }
00253         else if( clipName == kClipSpillSelection)                               // if color clip has changed
00254         {
00255                 _renderAttributes.recomputeGeodesicForm = true;         //recompute process attributes
00256                 if( this->hasCloudPointData() )                                         //it is not batch mode
00257                 {
00258                         OFX::Clip* test = fetchClip(clipName);                  //test if color clip is connected
00259                         if(test->isConnected())
00260                         {
00261                                 
00262                                 //generate spill selection VBO data
00263                                 getCloudPointData()._time = args.time;                                  //update time
00264                                 getCloudPointData().generateSpillSelectionVBO(                  //create a spill selection VBO data with or without discretization
00265                                                 _clipSpill,                                                                             //spill clip
00266                                                 args.renderScale,                                                               //current render scale
00267                                                 _paramBoolDiscretizationActive->getValue(),             //is discretization used to generate selection VBO
00268                                                 _paramIntDiscretization->getValue());                   //discretization step
00269                                 updateGeodesicForms(args);
00270                         }
00271                 }
00272         }
00273         else
00274         {
00275                 
00276         }
00277 }
00278 
00279 bool ColorSpaceKeyerPlugin::isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime )
00280 {
00281 //      ColorSpaceKeyerProcessParams<Scalar> params = getProcessParams();
00282 //      if( params._in == params._out )
00283 //      {
00284 //              identityClip = _clipSrc;
00285 //              identityTime = args.time;
00286 //              return true;
00287 //      }
00288         return false;
00289 }
00290 
00291 /**
00292  * @brief The overridden render function
00293  * @param[in]   args     Rendering parameters
00294  */
00295 void ColorSpaceKeyerPlugin::render( const OFX::RenderArguments &args )
00296 {
00297         if( OFX::getImageEffectHostDescription()->hostName == "uk.co.thefoundry.nuke" && /// HACK: Nuke doesn't call changeClip function when time is changed
00298             hasCloudPointData()
00299            ) // if there is overlay data
00300         {
00301                 if(args.time != getCloudPointData()._time)                      // different time between overlay and VBO data
00302                 {
00303                         //update VBO data
00304                         getCloudPointData()._time = args.time;                  //change computing time in cloud point data
00305                         getCloudPointData().generateVBOData(                    //create a VBO data (with discretization or not)
00306                                 _clipSrc,                                                                       //source clip
00307                                 args.renderScale,                                                       //current render scale
00308                                 _paramBoolDiscretizationActive->getValue(),     //is discretization used
00309                                 _paramIntDiscretization->getValue() );          //discretization step
00310                         
00311                         //update selection VBO data
00312                         getCloudPointData().generateColorSelectionVBO(  //create a selection VBO data (with or without discretization)
00313                                 _clipColor,                                                                     //color clip
00314                                 args.renderScale,                                                       //current render scale
00315                                 _paramBoolDiscretizationActive->getValue(),     //is discretization used
00316                                 _paramIntDiscretization->getValue());           //discretization step
00317                         _updateVBO = true;                                                              //VBO need to be updated in overlay
00318                 }
00319                 if(args.time != getCloudPointData()._averageColor._time) //different time between overlay and average data
00320                 {
00321                         //update automatic average
00322                         getCloudPointData()._averageColor._time = args.time;                                                                    //update time
00323                         getCloudPointData()._averageColor.computeAverageSelection(_clipColor,args.renderScale); //update average value
00324                         //color geodesic form
00325                         getCloudPointData()._geodesicFormColor._scale = _paramDoubleScaleGF->getValue();                                //set scale value
00326                         //spill geodesic form
00327                         getCloudPointData()._geodesicFormSpill._scale = _paramDoubleScaleGF->getValue();                                //set scale value
00328                         //update geodesic form if average mode is automatic
00329                         if(_paramChoiceAverageMode->getValue() == 0) //mode is automatic
00330                         {
00331                                 getCloudPointData()._geodesicFormColor.subdiviseFaces(getCloudPointData()._averageColor._averageValue,_paramIntNbOfDivisionsGF->getValue()); //update color geodesic form
00332                                 getCloudPointData()._geodesicFormSpill.subdiviseFaces(getCloudPointData()._averageColor._averageValue,_paramIntNbOfDivisionsGF->getValue()); //update geodesic form
00333                         }
00334                         //extends geodesic forms
00335                         getCloudPointData()._averageColor.extendGeodesicForm(_clipColor,args.renderScale,getCloudPointData()._geodesicFormColor); //extends geodesic form (color)
00336                         getCloudPointData()._geodesicFormSpill.copyGeodesicForm(getCloudPointData()._geodesicFormColor);                                                  //extends geodesic form (spill)
00337                         getCloudPointData()._averageColor.extendGeodesicForm(_clipSpill,args.renderScale,getCloudPointData()._geodesicFormSpill); //extends geodesic form (spill)
00338                 }
00339         }
00340         //update  current parameters for process
00341         _renderScale = args.renderScale; //change render scale (before rendering)
00342         _time = args.time;                              // change time
00343         //update process attributes
00344         if(_renderAttributes.recomputeGeodesicForm || _renderAttributes.time != args.time)
00345                 updateProcessGeodesicForms(args);
00346         //call process functions
00347         doGilRender<ColorSpaceKeyerProcess>( *this, args ); //launch process
00348 }
00349 
00350 /*
00351  *Update geodesic forms for overlay (and call update function for process parameters) 
00352  * @param args
00353  */
00354 void ColorSpaceKeyerPlugin::updateGeodesicForms(const OFX::InstanceChangedArgs& args)
00355 {
00356         //update geodesic forms scale values
00357         getCloudPointData()._geodesicFormColor._scale = _paramDoubleScaleGF->getValue();                                                                        //set scale value
00358         //spill geodesic form
00359         getCloudPointData()._geodesicFormSpill._scale = _paramDoubleScaleGF->getValue();                                                                        //set scale value
00360         //refresh selection average
00361         getCloudPointData()._averageColor._time = args.time;                                                                    //set current time into average
00362         getCloudPointData()._averageColor.computeAverageSelection(_clipColor,args.renderScale); //update automatic average
00363         if(_paramChoiceAverageMode->getValue() == 1) //average mode is manual
00364         {
00365                 //get current average selection
00366                 OfxRGBAColourD selectionColor = _paramRGBAColorSelection->getValue();   //get current average selection
00367                 //transform average color in 3D point average
00368                 Ofx3DPointD selectionAverage;                                                                                   //initialize
00369                 selectionAverage.x = selectionColor.r;                                                                  // x == red
00370                 selectionAverage.y = selectionColor.g;                                                                  // y == green
00371                 selectionAverage.z = selectionColor.b;                                                                  // z == blue
00372                 getCloudPointData()._geodesicFormColor.subdiviseFaces(selectionAverage,_paramIntNbOfDivisionsGF->getValue()); //update color geodesic form
00373                 getCloudPointData()._geodesicFormSpill.subdiviseFaces(selectionAverage,_paramIntNbOfDivisionsGF->getValue()); //update spill geodesic form
00374         }
00375         else //average mode is automatic
00376         {
00377                 getCloudPointData()._geodesicFormColor.subdiviseFaces(getCloudPointData()._averageColor._averageValue,_paramIntNbOfDivisionsGF->getValue());    //update color geodesic form
00378                 getCloudPointData()._geodesicFormSpill.subdiviseFaces(getCloudPointData()._averageColor._averageValue,_paramIntNbOfDivisionsGF->getValue());    //update spill geodesic form
00379         }
00380         //extends geodesic forms
00381         getCloudPointData()._averageColor.extendGeodesicForm(_clipColor,args.renderScale,getCloudPointData()._geodesicFormColor);       //extends color geodesic form
00382         getCloudPointData()._geodesicFormSpill.copyGeodesicForm(getCloudPointData()._geodesicFormColor);                                                        //extends spill geodesic form (color clip)
00383         getCloudPointData()._averageColor.extendGeodesicForm(_clipSpill,args.renderScale,getCloudPointData()._geodesicFormSpill);       //extends spill geodesic form (spill clip)      
00384         //scale geodesic form
00385         getCloudPointData()._geodesicFormColor.scaleGeodesicForm(_paramDoubleScaleGF->getValue());
00386         getCloudPointData()._geodesicFormSpill.scaleGeodesicForm(_paramDoubleScaleGF->getValue());
00387         _updateVBO = true;                                                                      //update VBO in overlay
00388         _renderAttributes.recomputeGeodesicForm = true;         //recompute process attributes
00389         this->redrawOverlays();                                                         //redraw scene
00390 }
00391 
00392 /*
00393  *Update process parameters (goedesic forms, time and selection average) 
00394  * @param args
00395  */
00396 void ColorSpaceKeyerPlugin::updateProcessGeodesicForms(const OFX::RenderArguments &args)
00397 {
00398         //update time
00399         _renderAttributes.time = args.time;                                                                                                             //update time
00400         //Create geodesic form
00401         SelectionAverage selectionAverage = SelectionAverage(_time);                                                    //create selection
00402         //update color geodesic form
00403         _renderAttributes.geodesicFormColor._scale = _paramDoubleScaleGF->getValue();                   //set good scale to geodesic form
00404         //update spill geodesic form
00405         _renderAttributes.geodesicFormSpill._scale = _paramDoubleScaleGF->getValue();                   //set good scale to geodesic forms
00406 
00407         if(_paramChoiceAverageMode->getValue() ==0) //average mode is automatic
00408         {
00409                 selectionAverage.computeAverageSelection(_clipColor,_renderScale); //compute average selection
00410                 //subdivise geodesic forms
00411                 _renderAttributes.geodesicFormColor.subdiviseFaces(selectionAverage._averageValue, _paramIntDiscretization->getValue()); //create geodesic form
00412                 _renderAttributes.geodesicFormSpill.subdiviseFaces(selectionAverage._averageValue, _paramIntDiscretization->getValue()); //create geodesic form
00413         }
00414         else //average mode is manual
00415         {
00416                 Ofx3DPointD selectedAverage;//initialize average
00417                 OfxRGBAColourD colorSelected =  _paramRGBAColorSelection->getValue(); //get selected color
00418                 selectedAverage.x = colorSelected.r; //x == red
00419                 selectedAverage.y = colorSelected.g; //y == green
00420                 selectedAverage.z = colorSelected.b; //z == blue
00421                 //compute geodesic forms
00422                 _renderAttributes.geodesicFormColor.subdiviseFaces(selectedAverage, _paramIntDiscretization->getValue()); //create geodesic form
00423                 _renderAttributes.geodesicFormSpill.subdiviseFaces(selectedAverage, _paramIntDiscretization->getValue()); //create geodesic form
00424         }
00425         //Extend geodesic forms
00426         selectionAverage.extendGeodesicForm(_clipColor,_renderScale,_renderAttributes.geodesicFormColor);       //extends geodesic form color
00427         _renderAttributes.geodesicFormSpill.copyGeodesicForm(_renderAttributes.geodesicFormColor);                                                      //extends geodesic form spill (color clip)
00428         selectionAverage.extendGeodesicForm(_clipSpill,_renderScale,_renderAttributes.geodesicFormSpill);       //extends geodesic form spill (spill takes account of spill clip)
00429         _renderAttributes.recomputeGeodesicForm = false;
00430 }
00431 
00432 
00433 
00434 
00435 
00436 
00437 
00438 
00439 
00440 
00441 
00442 
00443 /// @brief Cloud point data
00444 /// @{
00445 //cloud point data management
00446 //Add a reference to CloudPointData
00447 void ColorSpaceKeyerPlugin::addRefCloudPointData()
00448 {
00449         if( _cloudPointDataCount == 0 ) //no reference has been added yet
00450         {
00451                 const OfxPointI imgSize = this->_clipSrc->getPixelRodSize( 0 ); ///@todo set the correct time !
00452                 _cloudPointData.reset(new CloudPointData(imgSize,0));                           //Create data
00453         }
00454         ++_cloudPointDataCount;//increments number of reference
00455 }
00456 //remove a reference to CloudPointData
00457 void ColorSpaceKeyerPlugin::releaseCloudPointData()
00458 {
00459         --_cloudPointDataCount;         
00460         if(_cloudPointDataCount == 0)   //no more reference on CloudPointData
00461         {
00462                 _cloudPointData.reset(NULL);    //reset data
00463         }
00464 }
00465 //Has CloudPointData already been created (batch mode)
00466 bool ColorSpaceKeyerPlugin::hasCloudPointData() const
00467 {
00468         return _cloudPointDataCount != 0;
00469 }
00470 
00471 CloudPointData& ColorSpaceKeyerPlugin::getCloudPointData()
00472 {
00473         return *_cloudPointData.get();
00474 }
00475 const CloudPointData& ColorSpaceKeyerPlugin::getCloudPointData() const
00476 {
00477         return *_cloudPointData.get();
00478 }
00479 /// @}
00480 
00481 }
00482 }
00483 }