Esempio n. 1
0
 int getThresholdLayerInfo(Layer* pLayer, struct ThresholdLayerInfo* pInfo)
 {
    ThresholdLayer* pThresh = dynamic_cast<ThresholdLayer*>(pLayer);
    if (pThresh == NULL || pInfo == NULL)
    {
       setLastError(SIMPLE_BAD_PARAMS);
       return 1;
    }
    // convert the threshold values to the current threshold region units
    pInfo->firstThreshold = pThresh->convertThreshold(RAW_VALUE,
       pThresh->getFirstThreshold(), pThresh->getRegionUnits());
    pInfo->secondThreshold = pThresh->convertThreshold(RAW_VALUE,
       pThresh->getSecondThreshold(), pThresh->getRegionUnits());
    switch(pThresh->getPassArea())
    {
    case LOWER:
       pInfo->passArea = 0;
       break;
    case UPPER:
       pInfo->passArea = 1;
       break;
    case MIDDLE:
       pInfo->passArea = 2;
       break;
    case OUTSIDE:
       pInfo->passArea = 3;
       break;
    default:
       setLastError(SIMPLE_OTHER_FAILURE);
       return 1;
    }
    switch(pThresh->getRegionUnits())
    {
    case RAW_VALUE:
       pInfo->regionUnits = 0;
       break;
    case PERCENTAGE:
       pInfo->regionUnits = 1;
       break;
    case PERCENTILE:
       pInfo->regionUnits = 2;
       break;
    case STD_DEV:
       pInfo->regionUnits = 3;
       break;
    default:
       setLastError(SIMPLE_OTHER_FAILURE);
       return 1;
    }
    setLastError(SIMPLE_NO_ERROR);
    return 0;
 }
Esempio n. 2
0
   int setThresholdLayerInfo(Layer* pLayer, struct ThresholdLayerInfo* pInfo)
   {
      ThresholdLayer* pThresh = dynamic_cast<ThresholdLayer*>(pLayer);
      if (pThresh == NULL || pInfo == NULL)
      {
         setLastError(SIMPLE_BAD_PARAMS);
         return 1;
      }
      switch(pInfo->passArea)
      {
      case 0:
         pThresh->setPassArea(LOWER);
         break;
      case 1:
         pThresh->setPassArea(UPPER);
         break;
      case 2:
         pThresh->setPassArea(MIDDLE);
         break;
      case 3:
         pThresh->setPassArea(OUTSIDE);
         break;
      default:
         setLastError(SIMPLE_BAD_PARAMS);
         return 1;
      }
      switch(pInfo->regionUnits)
      {
      case 0:
         pThresh->setRegionUnits(RAW_VALUE);
         break;
      case 1:
         pThresh->setRegionUnits(PERCENTAGE);
         break;
      case 2:
         pThresh->setRegionUnits(PERCENTILE);
         break;
      case 3:
         pThresh->setRegionUnits(STD_DEV);
         break;
      default:
         setLastError(SIMPLE_BAD_PARAMS);
         return 1;
      }
      // convert the thresholds to raw from the specified units
      pThresh->setFirstThreshold(pThresh->convertThreshold(pInfo->firstThreshold, RAW_VALUE));
      pThresh->setSecondThreshold(pThresh->convertThreshold(pInfo->secondThreshold, RAW_VALUE));

      setLastError(SIMPLE_NO_ERROR);
      return 0;
   }