Esempio n. 1
0
// SkipString
//------------------------------------------------------------------------------
void BFFIterator::SkipString( char quote )
{
    // start on open char (first ++ will handle this)
    ASSERT( *m_Pos == quote );

    while ( !IsAtEnd() )
    {
        m_Pos++;

        const char c = *m_Pos;

        // escape char?
        if ( c == '^' )
        {
            m_Pos++; // extra increment to skip escaped char
            continue;
        }

        // closing quote?
        if ( *m_Pos == quote )
        {
            return;
        }
    }
}
Esempio n. 2
0
// ParseExactString
//------------------------------------------------------------------------------
bool BFFIterator::ParseExactString( const char * string )
{
    const char * const originalPos = m_Pos;

    const char * stringPos = string; // stores pointer to the next character to be checked for presence in our sequence
    while ( !IsAtEnd() && ( *stringPos != '\000' ) )
    {
        if ( *m_Pos != *stringPos )
        {
            break;
    }
        m_Pos++;
        stringPos++;
    }

    if ( *stringPos == '\000' )
    {
        // we are at the end of string, that means all characters have successfuly matched
        return true;
    }
    else
    {
        // we are not at the end of string, that means either our sequence ended, or there is non matching character
        // restore our pos before returning
        m_Pos = originalPos;
        return false;
    }
}
Esempio n. 3
0
// SkipVariableName
//------------------------------------------------------------------------------
void BFFIterator::SkipVariableName()
{
    while ( !IsAtEnd() )
    {
        if ( !IsAtValidVariableNameCharacter() )
        {
            return;
        }

        // character still part of variable name
        (*this)++;
    }
}
Esempio n. 4
0
// SkipComment
//------------------------------------------------------------------------------
void BFFIterator::SkipComment()
{
    // keep going until we hit the end of a line
    while ( !IsAtEnd() )
    {
        bool atLineEnd = (*m_Pos == '\n' );
        (*this)++;
        if ( atLineEnd )
        {
            break;
        }
    }
}
Esempio n. 5
0
// SkipWhiteSpace
//------------------------------------------------------------------------------
void BFFIterator::SkipWhiteSpace()
{
    while ( !IsAtEnd() )
    {
        if ( IsAtWhitespace() )
        {
            (*this)++;
        }
        else
        {
            break;
        }
    }
}
Esempio n. 6
0
// ParseToNext
//------------------------------------------------------------------------------
bool BFFIterator::ParseToNext( char c )
{
    if ( IsAtEnd() )
    {
        return false;
    }

    char prev = '\000';
    do
    {
        (*this)++;
        if ( *m_Pos == c )
        {
            if ( prev != '^' )
            {
                return true;
            }
        }
        prev = *m_Pos;
    } while ( !IsAtEnd() );

    return false;
}
Esempio n. 7
0
// SkipDirectiveName
//------------------------------------------------------------------------------
void BFFIterator::SkipDirectiveName()
{
    while ( !IsAtEnd() )
    {
        if ( IsAtValidDirectiveNameCharacter() )
        {
            // character still part of directive name
            (*this)++;
            continue;
        }

        break; // hit the end of a non-valid character for a directive name
    }
}
Esempio n. 8
0
// SkipFunctionName
//------------------------------------------------------------------------------
void BFFIterator::SkipFunctionName()
{
    while ( !IsAtEnd() )
    {
        if ( IsAtValidFunctionNameCharacter() )
        {
            // character still part of variable name
            (*this)++;
            continue;
        }

        break; // hit the end of a non-valid character for a function name
    }
}
Esempio n. 9
0
// Determines whether move conflicts with other pegs in end slots
bool Player::PossibleMove(int i, int adv) const
{
    if ((peg[i] + adv) > endPosition + (NUM_PEGS - 1))
        return false; // Can't go past the four end slots

    for (int p = 0; p < NUM_PEGS; p++)
    {
        if (i == p) continue; // Doesn't compare with itself

        if (IsAtEnd(p) && peg[p] == (peg[i] + adv))
            // Prevents peg from landing on space occupied by another peg in end slots
            return false;
    }

    return true;
}
Esempio n. 10
0
cv::Mat LogReaderImageSource::GetNextImage() {
    cv::Mat imageDist;

    if (IsAtEnd()) {
        return imageDist;
    }

    logReader->getNext();

    cv::Mat3b img(h, w, (cv::Vec3b *) logReader->rgb);

    cv::cvtColor(img, imageDist, CV_RGB2GRAY);

    index++;

    return img;
}
Esempio n. 11
0
cv::Mat FileListImageSource::GetNextImage() {
    cv::Mat imageDist;

    if (IsAtEnd()) {
        return imageDist;
    }

    imageDist = cv::imread(files[index], CV_LOAD_IMAGE_GRAYSCALE);

    if (imageDist.rows != h || imageDist.cols != w) {
        if (imageDist.rows * imageDist.cols == 0) {
            printf("failed to load image %s! skipping.\n", files[index].c_str());
        } else {
            printf("image %s has wrong dimensions - expecting %d x %d, found %d x %d. Skipping.\n", files[index].c_str(), w, h, imageDist.cols, imageDist.rows);
        }
    }

    index++;

    return imageDist;
}
Esempio n. 12
0
// ParseToMatchingBrace
//------------------------------------------------------------------------------
bool BFFIterator::ParseToMatchingBrace( char openBrace, char closeBrace )
{
    ASSERT( *m_Pos == openBrace );

    do
    {
        m_Pos++;
        SkipWhiteSpaceAndComments();

        // hit a nested brace?
        if ( *m_Pos == openBrace )
        {
            if ( ParseToMatchingBrace( openBrace, closeBrace ) == false )
            {
                return false;
            }
            continue;
        }

        // hit a string?
        if ( ( *m_Pos == '\'' ) || ( *m_Pos == '"' ) )
        {
            SkipString( *m_Pos );
        }

        // hit the close brace?
        if ( *m_Pos == closeBrace )
        {
            return true;
        }

        // a regular charater.... keep searching

    } while ( !IsAtEnd() );

    return false;
}
Esempio n. 13
0
void mitk::CLUtil::itkInterpolateCheckerboardPrediction(TImageType * checkerboard_prediction, Image::Pointer &checkerboard_mask, mitk::Image::Pointer & outimage)
{
  typename TImageType::Pointer itk_checkerboard_mask;
  mitk::CastToItkImage(checkerboard_mask,itk_checkerboard_mask);

  typename TImageType::Pointer itk_outimage = TImageType::New();
  itk_outimage->SetRegions(checkerboard_prediction->GetLargestPossibleRegion());
  itk_outimage->SetDirection(checkerboard_prediction->GetDirection());
  itk_outimage->SetOrigin(checkerboard_prediction->GetOrigin());
  itk_outimage->SetSpacing(checkerboard_prediction->GetSpacing());
  itk_outimage->Allocate();
  itk_outimage->FillBuffer(0);

  //typedef typename itk::ShapedNeighborhoodIterator<TImageType>::SizeType SizeType;
  typedef itk::Size<3> SizeType;
  SizeType size;
  size.Fill(1);
  itk::ShapedNeighborhoodIterator<TImageType> iit(size,checkerboard_prediction,checkerboard_prediction->GetLargestPossibleRegion());
  itk::ShapedNeighborhoodIterator<TImageType> mit(size,itk_checkerboard_mask,itk_checkerboard_mask->GetLargestPossibleRegion());
  itk::ImageRegionIterator<TImageType> oit(itk_outimage,itk_outimage->GetLargestPossibleRegion());

  typedef typename itk::ShapedNeighborhoodIterator<TImageType>::OffsetType OffsetType;
  OffsetType offset;
  offset.Fill(0);
  offset[0] = 1;       // {1,0,0}
  iit.ActivateOffset(offset);
  mit.ActivateOffset(offset);
  offset[0] = -1;      // {-1,0,0}
  iit.ActivateOffset(offset);
  mit.ActivateOffset(offset);
  offset[0] = 0; offset[1] = 1; //{0,1,0}
  iit.ActivateOffset(offset);
  mit.ActivateOffset(offset);
  offset[1] = -1;      //{0,-1,0}
  iit.ActivateOffset(offset);
  mit.ActivateOffset(offset);

  //    iit.ActivateOffset({{0,0,1}});
  //    iit.ActivateOffset({{0,0,-1}});
  //    mit.ActivateOffset({{0,0,1}});
  //    mit.ActivateOffset({{0,0,-1}});

  while(!iit.IsAtEnd())
  {
    if(mit.GetCenterPixel() == 0)
    {
      typename TImageType::PixelType mean = 0;
      for (auto i = iit.Begin(); ! i.IsAtEnd(); i++)
      { mean += i.Get(); }


      //std::sort(list.begin(),list.end(),[](const typename TImageType::PixelType x,const typename TImageType::PixelType y){return x<=y;});

      oit.Set((mean+0.5)/6.0);
    }
    else
    {
      oit.Set(iit.GetCenterPixel());
    }
    ++iit;
    ++mit;
    ++oit;
  }

  mitk::CastToMitkImage(itk_outimage,outimage);
}