예제 #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;
 }