Example #1
0
/**
- FUNCTION: GetResult
- FUNCTIONALITY: Computes the function evaluador on all the blobs of the class
and returns a vector with the result
- PARAMETERS:
- evaluador: function to apply to each blob (any object derived from the 
COperadorBlob class )
- RESULT:
- vector with all the results in the same order as the blobs
- RESTRICTIONS:
- AUTHOR: Ricard Borràs
- CREATION DATE: 25-05-2005.
- MODIFICATION: Date. Author. Description.
*/
double_vector CBlobResult::GetResult( funcio_calculBlob *evaluador ) const
{
  if( GetNumBlobs() <= 0 )
  {
    return double_vector();
  }

  // definim el resultat
  double_vector result = double_vector( GetNumBlobs() );
  // i iteradors sobre els blobs i el resultat
  double_vector::iterator itResult = result.GetIterator();
  blob_vector::const_iterator itBlobs = m_blobs.begin();

  // avaluem la funció en tots els blobs
  while( itBlobs != m_blobs.end() )
  {
    *itResult = (*evaluador)(**itBlobs);
    itBlobs++;
    itResult++;
  }
  return result;
}
Example #2
0
double* TclGetVector(Tcl_Interp* interp,char* aryname,char* varname,
                     int mustexist,double* defval) 
{
  int i,argc;
  char** argv;
  char* list;
  double* v;
  
  list=Tcl_GetVar2(interp,aryname,varname,0);
  if (!list) {
     if (mustexist) {
       fprintf(stderr,"error: could not read vector variable %s(%s)\n",aryname,varname);
       exit(-1);
     }
     if (verbose & VERBOSE_PAR) {
       printf("vector variable %s in array %s is set to default value ",varname,aryname);
       if (defval != NULL) {
         for (i=1;i<=LEN(defval);i++)
           printf("%f ",defval[i]);
       } else {
           printf("<null>\n");
       }
     }
     return defval;
  }
  if (Tcl_SplitList(interp,list,&argc,&argv) != TCL_OK) TclError(interp,"GetVector(2)");
  if (!argc) return NULL;
  v = double_vector(argc);
  for (i=0;i<argc;i++) {
    if (Tcl_GetDouble(interp,argv[i],&v[i+1]) != TCL_OK) TclError(interp,"GetVector(3)");
  }
  free(argv);
  if (verbose & VERBOSE_PAR) {
    printf("vector variable %s in array %s is set to value ",varname,aryname);
    for (i=1;i<=LEN(v);i++)
       printf("%f ",v[i]);
  }
  return v;
}