Ejemplo n.º 1
0
//----------------------------------------------------------------------------
//
// Name       : A_Star_Heuristic_Cost::Relax_One_Cost_Grid
//
// Description: Sets a (relaxed) block value to the minimum (raw) value of 
//              itself and its direct neighbours.
//
// Parameters : a_Row			: block row number
//				a_Column		: block column number
//
// Globals    : -
//
// Returns    : -
//
// Remark(s)  : Assumes that input is valid.
//
//----------------------------------------------------------------------------
void A_Star_Heuristic_Cost::Relax_One_Cost_Grid
(
	int		a_Row,
	int		a_Column
)
{
	int const	radius		= 1;	// how direct a neighbour should be
	int const	ownIndex	= a_Column + (a_Row * columns);

	// Initialise with own value (just to have something)
	double &	relaxedMin	= relaxed_min_movement_costs[ownIndex];
	relaxedMin = raw_min_movement_costs[ownIndex];

	for (int i = a_Row - radius; i <= a_Row + radius; ++i)
	{
		int row;
		if (IsInRange(i, 0, rows, y_wrap, row))
		{
			for (int j = a_Column - radius; j <= a_Column + radius; ++j)
			{
				int column;
				if (IsInRange(j, 0, columns, x_wrap, column))
				{
					double const &	neighbourValue	= 
						raw_min_movement_costs[column + (row * columns)];

					if (neighbourValue < relaxedMin)
					{
						relaxedMin = neighbourValue;
					}
				}
			}
		}
	}
}
Ejemplo n.º 2
0
bool Arcusical::IsAlphaNumeric(Windows::System::VirtualKey key) {
  int val = (int)(key);
  // Source of values: https://msdn.microsoft.com/en-us/library/windows/apps/windows.system.virtualkey.aspx
  return IsInRange(val, 48, 57) ||  // Numbers
         IsInRange(val, 65, 90) ||  // Letters
         IsInRange(val, 96, 105);   // Numpad
}
Ejemplo n.º 3
0
	bool is_in_on(const vt& x, const vt& y = 0, const vt& z = 0) const {
		return (IsInRange(this->get(_M_, _X_), x, this->get(_P_, _X_), _cc_)
				&& ((Dim >= 2) ?
						IsInRange(this->get(_M_, _Y_), y, this->get(_P_, _Y_),
								_cc_) :
						true)
				&& ((Dim == 3) ?
						IsInRange(this->get(_M_, _Z_), z, this->get(_P_, _Z_),
								_cc_) :
						true));
	}
Ejemplo n.º 4
0
bool FloatingPointValidatorBase::DoValidateNumber(wxString * errMsg) const
{
   wxTextEntry * const control = GetTextEntry();
   if ( !control )
      return false;

   wxString s(control->GetValue());
   wxChar thousandsSep;
   if ( NumberFormatter::GetThousandsSeparatorIfUsed(&thousandsSep) )
      s.Replace(wxString(thousandsSep), wxString());

   if ( s.empty() )
   {
      if ( HasFlag(NUM_VAL_ZERO_AS_BLANK) )
         return true; //Is blank, but allowed. Stop here
      else
      {
         *errMsg = _("Empty value");
         return false; //We can't do any checks with an empty string
      }
   }

   LongestValueType value;
   bool res = FromString(s, &value); // Can it be converted to a value?
   if ( !res )
      *errMsg = _("Value overflow");
   else
   {
      res = ValidatePrecision(s);
      if ( !res )
         *errMsg = _("Too many decimal digits");
      else
      {
         res = IsInRange(value);
         if ( !res )
         {
            wxString strMin = wxString::Format(wxT("%f"), m_min);
            wxString strMax = wxString::Format(wxT("%f"), m_max);
            NumberFormatter::RemoveTrailingZeroes(strMin);
            NumberFormatter::RemoveTrailingZeroes(strMax);

            if (m_minSet && m_maxSet)
            {
               errMsg->Printf(_("Value not in range: %s to %s"),
                              strMin, strMax);
            }
            else if (m_minSet)
            {
               errMsg->Printf(_("Value must not be less than %s"), strMin);
            }
            else if (m_maxSet)
            {
               errMsg->Printf(_("Value must not be greather than %s"), strMax);
            }
         }
      }
   }

   return res;
}
Ejemplo n.º 5
0
void CChatWnd::OnChatItalic()
{
    if ( IsInRange( _T("i") ) )
        InsertText( _T("[/i]") );
    else
        InsertText( _T("[i]") );
}
Ejemplo n.º 6
0
void CChatWnd::OnChatUnderline()
{
    if ( IsInRange( _T("u") ) )
        InsertText( _T("[/u]") );
    else
        InsertText( _T("[u]") );
}
Ejemplo n.º 7
0
void CChatWnd::OnChatBold()
{
    if ( IsInRange( _T("b") ) )
        InsertText( _T("[/b]") );
    else
        InsertText( _T("[b]") );
}
Ejemplo n.º 8
0
bool StressTest::GoToNextFile()
{
    for (;;) {
        while (filesToOpen.Count() > 0) {
            // test next file
            ScopedMem<TCHAR> path(filesToOpen.At(0));
            filesToOpen.RemoveAt(0);
            if (!IsInRange(fileRanges, ++fileIndex))
                continue;
            if (OpenFile(path))
                return true;
        }

        if (dirsToVisit.Count() > 0) {
            // test next directory
            ScopedMem<TCHAR> path(dirsToVisit.At(0));
            dirsToVisit.RemoveAt(0);
            OpenDir(path);
            continue;
        }

        if (--cycles <= 0)
            return false;
        // start next cycle
        if (file::Exists(basePath))
            filesToOpen.Append(str::Dup(basePath));
        else
            OpenDir(basePath);
    }
}
Ejemplo n.º 9
0
UAnimSequenceBase * FAnimSegment::GetAnimationData(float PositionInTrack, float& PositionInAnim, float& Weight) const
{
	if( IsInRange(PositionInTrack) )
	{
		if( AnimReference )
		{
			const float ValidPlayRate = GetValidPlayRate();

			// this result position should be pure position within animation
			float Delta = (PositionInTrack - StartPos);

			// LoopingCount should not be zero, and it should not get here, but just in case
			if (LoopingCount > 1)
			{
				// we need to consider looping count
				float AnimPlayLength = (AnimEndTime - AnimStartTime) / FMath::Abs(ValidPlayRate);
				Delta = FMath::Fmod(Delta, AnimPlayLength);
			}

			// no blending supported
			Weight = 1.f;
			if (ValidPlayRate > 0.f)
			{
				PositionInAnim = AnimStartTime + Delta * ValidPlayRate;
			}
			else
			{
				PositionInAnim = AnimEndTime + Delta * ValidPlayRate;
			}
			return AnimReference;
		}
	}

	return NULL;
}
Ejemplo n.º 10
0
CVisDimIterator::CVisDimIterator(const CVisDim& refdim, int i0, int i1,
		int i2, int i3)
  : CVisDimIndex(i0, i1, i2, i3),
	m_pdim(&refdim),
	m_fAtEnd(false)
{
	assert(IsInRange(*m_pdim));
}
Ejemplo n.º 11
0
CVisDimIterator& CVisDimIterator::operator=(const CVisDimIndex& refdimindex)
{
	*((CVisDimIndex *) this) = refdimindex;

	assert(IsInRange(*m_pdim));

	return *this;
}
Ejemplo n.º 12
0
CVisDimIterator::CVisDimIterator(const CVisDim& refdim,
		const CVisDimIndex& refdimindex)
  : CVisDimIndex(refdimindex),
	m_pdim(&refdim),
	m_fAtEnd(false)
{
	assert(IsInRange(*m_pdim));
}
Ejemplo n.º 13
0
		TEST_F(RectDiff, Divide) {
			// ランダムなテスト範囲
			auto rd = getRand();
			auto randI = rd.template getUniformF<int>();
			constexpr int MaxRange = 100;
			const Size size(randI({1, MaxRange}),
							randI({1, MaxRange}));
			bool imap[MaxRange*2][MaxRange*2];
			const auto randX = rd.template getUniformF<int>({-size.width/2, size.width/2}),
						randY = rd.template getUniformF<int>({-size.height/2, size.height/2});
			constexpr int NItr = 0x100;
			for(int i=0 ; i<NItr ; i++) {
				std::memset(imap, 0, sizeof(imap));
				// テスト範囲以下の矩形をランダムな位置に置く
				const auto rect = RandomRect(randX, randY);
				int area = 0;
				ASSERT_NO_FATAL_FAILURE(
					rect::DivideRect(
						size,
						rect,
						[&size, &area, &imap](const Rect& g, const Rect& l){
							ASSERT_NO_THROW(g.checkValidness());
							ASSERT_NO_THROW(l.checkValidness());
							// グローバルとローカル矩形の面積は同じ
							ASSERT_EQ(g.area(), l.area());
							// ローカル座標がテスト範囲を出ていないか
							ASSERT_TRUE(IsInRange(l.x0, 0, size.width));
							ASSERT_TRUE(IsInRange(l.x1, 0, size.width));
							ASSERT_TRUE(IsInRange(l.y0, 0, size.height));
							ASSERT_TRUE(IsInRange(l.y1, 0, size.height));
							// 矩形を塗りつぶしていき、重なりや面積が違っていなければOK
							for(int i=g.y0 ; i<g.y1 ; i++) {
								for(int j=g.x0 ; j<g.x1 ; j++) {
									auto& im = imap[i+MaxRange][j+MaxRange];
									ASSERT_FALSE(im);
									im = true;
								}
							}
							area += g.area();
						}
					)
				);
				ASSERT_EQ(rect.area(), area);
			}
		}
Ejemplo n.º 14
0
Entity* Creature::Find_Target_Player(int range)
{
	auto chunks = World::GetChunksAround(x, y);
	for each (auto c in *chunks)
		for each (Tile *t in c.second->data)
			if (t->entity && dynamic_cast<Player*>(t->entity.get()) && IsInRange(*t->entity, range))
			{
				return &*t->entity;
			}
	return nullptr;
}
Ejemplo n.º 15
0
void ribi::DrawCanvas::DrawDot(const double x, const double y) noexcept
{
  //Assume a dot has dimensions 1.0 x 1.0
  //and x and y are exactly in the middle of this dot
  const double xBegin = x - 0.5;
  const double yBegin = y - 0.5;
  const double fracLeft = std::ceil(xBegin) - xBegin;
  const double fracTop  = std::ceil(yBegin) - yBegin;
  const int indexLeft = std::floor(xBegin);
  const int indexTop  = std::floor(yBegin);
  if (IsInRange(indexLeft  ,indexTop  ))
    m_canvas[indexTop  ][indexLeft  ] += (fracLeft * fracTop);
  if (IsInRange(indexLeft+1,indexTop  ))
    m_canvas[indexTop  ][indexLeft+1] += ((1.0-fracLeft) * fracTop);
  if (IsInRange(indexLeft  ,indexTop+1))
    m_canvas[indexTop+1][indexLeft  ] += (fracLeft * (1.0-fracTop));
  if (IsInRange(indexLeft+1,indexTop+1))
    m_canvas[indexTop+1][indexLeft+1] += ((1.0-fracLeft) * (1.0-fracTop));
  m_signal_changed(this);
}
Ejemplo n.º 16
0
void BoxBrowser::ClearCache( bool full )
{
	//RsxMem::PrintInfo( true );
	u32 r1Low = 0xffffffff;
	u32 r1High = 0xffffffff;
	u32 r2Low = 0xffffffff;
	u32 r2High = 0xffffffff;
	std::map<u32, GuiImageAsync *> keepers;
	if( !full )
	{
		r1Low = listIdx;
		r1High = listIdx + NUM_BOXES;
		if( r1High >= (u32)GameList::Count() )
		{
			r1High = GameList::Count() - 1;
			r2Low = 0;
			r2High = NUM_BOXES - ( r1High - r1Low );
		}
	}
	else
	{
		needToUpdateBoxes = true;
	}
	if( coverImg.size() )
	{
		for( std::map<u32, GuiImageAsync *>::iterator i = coverImg.begin(), iEnd = coverImg.end(); i != iEnd; ++i )
		{
			if( full
				|| ( !IsInRange( (*i).first, r1Low, r1High) && !IsInRange( (*i).first, r2Low, r2High) ) )
			{
				if( (*i).second )
					delete (*i).second;
			}
			else
			{
				keepers[ (*i).first ] = (*i).second;
			}
		}
	}
	coverImg = keepers;
}
Ejemplo n.º 17
0
bool CStringConstraint::DoesTextMatch (const string& text)
{
    string match = m_MatchText;
    if (match.length() == 0) {
        return true;
    }
        
    bool rval = false;
    
    string tmp = text;
    if (m_IgnoreSpace) {
        NStr::ReplaceInPlace(match, " ", "");
        NStr::ReplaceInPlace(tmp, " ", "");
    }
    if (m_IgnoreCase) {
        NStr::ToLower(match);
        NStr::ToLower(tmp);
    }
    
    vector<string> tokens;
    if (m_MatchType == eMatchType_Equals)
        tokens.push_back(match);
    else
        NStr::Split(match, ",; ", tokens);
    ITERATE(vector<string>, it, tokens) {
        switch (m_MatchType) {
        case eMatchType_Contains: 
            rval |= (NStr::Find(tmp, *it) != string::npos);
            break;
        case eMatchType_Equals:
            rval |= NStr::Equal(tmp, *it);
            break;
        case eMatchType_StartsWith:
            rval |= NStr::StartsWith(tmp, *it);
            break;
        case eMatchType_EndsWith:
            rval |= NStr::EndsWith(tmp, *it);
            break;
        case eMatchType_IsOneOf:
            rval |= (IsInRange(*it, tmp) || NStr::Equal(*it, tmp));
            break;
        }
        if (rval)
            break;
    }
    if (m_NotPresent) {
        rval = !rval;
    }
    return rval;    
}
Ejemplo n.º 18
0
bool
wxFloatingPointValidatorBase::IsCharOk(const wxString& val,
                                       int pos,
                                       wxChar ch) const
{
    // We may accept minus sign if we can represent negative numbers at all.
    if ( ch == '-' )
        return m_min < 0 && IsMinusOk(val, pos);

    const wxChar separator = wxNumberFormatter::GetDecimalSeparator();
    if ( ch == separator )
    {
        if ( val.find(separator) != wxString::npos )
        {
            // There is already a decimal separator, can't insert another one.
            return false;
        }

        // Prepending a separator before the minus sign isn't allowed.
        if ( pos == 0 && !val.empty() && val[0] == '-' )
            return false;

        // Otherwise always accept it, adding a decimal separator doesn't
        // change the number value and, in particular, can't make it invalid.
        // OTOH the checks below might not pass because strings like "." or
        // "-." are not valid numbers so parsing them would fail, hence we need
        // to treat it specially here.
        return true;
    }

    // Must be a digit then.
    if ( ch < '0' || ch > '9' )
        return false;

    // Check whether the value we'd obtain if we accepted this key is correct.
    const wxString newval(GetValueAfterInsertingChar(val, pos, ch));

    LongestValueType value;
    if ( !FromString(newval, &value) )
        return false;

    // Also check that it doesn't have too many decimal digits.
    const size_t posSep = newval.find(separator);
    if ( posSep != wxString::npos && newval.length() - posSep - 1 > m_precision )
        return false;

    // Finally check whether it is in the range.
    return IsInRange(value);
}
Ejemplo n.º 19
0
bool StressTest::GoToNextFile() {
    for (;;) {
        AutoFreeW nextFile(fileProvider->NextFile());
        if (nextFile) {
            if (!IsInRange(fileRanges, ++fileIndex))
                continue;
            if (OpenFile(nextFile))
                return true;
            continue;
        }
        if (--cycles <= 0)
            return false;
        fileProvider->Restart();
    }
}
Ejemplo n.º 20
0
void CNumberEdit::ProcessTextChangingMessage()
{
	CString csOrigText;
	GetWindowText(csOrigText);

	Default();

	CString csNewText;
	GetWindowText(csNewText);
	if (!IsNumber(csNewText) || !IsInRange(_tstoi(csNewText)))
	{
		MessageBeep(-1);
		SetWindowText(csOrigText);
	}
}
//************************************************************************************
int CBCGPOutlineParser::GetNameOffset (const CString& strIn, int nStartFrom, int nSearchTo,
									   const BlockType* pBlockType, CObList& lstIgnore,
									   CString& strName)
{
	ASSERT (nStartFrom >= 0);
	ASSERT (nSearchTo >= 0);
	ASSERT (pBlockType != NULL);

	int nOffset = nStartFrom - 1;
	const int nCharsMaxNum = 256;
	nSearchTo = max (nSearchTo, nStartFrom - nCharsMaxNum);
	LPCTSTR lpszDelimiters = _T(";{}");

	const CStringList* pListKeywords = &(pBlockType->m_lstKeywords);
	ASSERT_VALID (pListKeywords);

	if (pListKeywords->GetCount () == 0)
	{
		// if no keywords then nameoffset = 0
		nSearchTo = nStartFrom;
	}	

	while (nOffset >= nSearchTo)
	{
		CString strWord;
		nOffset = GetPrevWord (strIn, nOffset, nSearchTo, lpszDelimiters, strWord);
		if (nOffset >= nSearchTo &&
			!IsInRange (lstIgnore, nOffset, nOffset + strWord.GetLength ()))
		{
			// Compare strWord with keywords
			if (pListKeywords->Find (strWord) != NULL)
			{
				strName = strWord;
				return nStartFrom - nOffset;
			}
			else if (IsBlockName (strIn, strWord, nOffset, nStartFrom))
			{
				strName = strWord;
				return nStartFrom - nOffset;
			}
		}
		nOffset--;
	}

	strName = _T("");
	return 0;
}
Ejemplo n.º 22
0
bool StressTest::GoToNextPage()
{
    double pageRenderTime = currPageRenderTime.GetTimeInMs();
    ScopedMem<TCHAR> s(str::Format(_T("Page %d rendered in %d milliseconds"), currPage, (int)pageRenderTime));
    ShowNotification(win, s, true, false, NG_STRESS_TEST_BENCHMARK);

    ++currPage;
    while (!IsInRange(pageRanges, currPage) && currPage <= win->dm->PageCount()) {
        currPage++;
    }

    if (currPage > win->dm->PageCount()) {
        if (GoToNextFile())
            return true;
        Finished(true);
        return false;
    }

    win->dm->GoToPage(currPage, 0);
    currPageRenderTime.Start();

    // start text search when we're in the middle of the document, so that
    // search thread touches both pages that were already rendered and not yet
    // rendered
    // TODO: it would be nice to also randomize search starting page but the
    // current API doesn't make it easy
    if (currPage == pageForSearchStart) {
        // use text that is unlikely to be found, so that we search all pages
        win::SetText(win->hwndFindBox, _T("!z_yt"));
        FindTextOnThread(win);
    }

    if (1 == rand() % 3) {
        ClientRect rect(win->hwndFrame);
        int deltaX = (rand() % 40) - 23;
        rect.dx += deltaX;
        if (rect.dx < 300)
            rect.dx += (abs(deltaX) * 3);
        int deltaY = (rand() % 40) - 23;
        rect.dy += deltaY;
        if (rect.dy < 300)
            rect.dy += (abs(deltaY) * 3);
        SendMessage(win->hwndFrame, WM_SIZE, 0, MAKELONG(rect.dx, rect.dy));
    }
    return true;
}
Ejemplo n.º 23
0
bool IntegerValidatorBase::DoValidateNumber(wxString * errMsg) const
{
   wxTextEntry * const control = GetTextEntry();
   if ( !control )
      return false;

   wxString s(control->GetValue());
   wxChar thousandsSep;
   if ( NumberFormatter::GetThousandsSeparatorIfUsed(&thousandsSep) )
      s.Replace(wxString(thousandsSep), wxString());

   if ( s.empty() )
   {
      // Is blank, but allowed. Stop here
      if ( HasFlag(NUM_VAL_ZERO_AS_BLANK) )
      {
         return true;
      }
      // We can't do any check with an empty string
      else
      {
         *errMsg = _("Empty value");
         return false;
      }
   }

   // Can it be converted to a value?
   LongestValueType value;
   bool res = FromString(s, &value);
   if ( !res )
      *errMsg = _("Malformed number");
   else
   {
      res = IsInRange(value);
      if ( !res )
         errMsg->Printf(_("Not in range %d to %d"),
                        (int) m_min, (int) m_max);
   }

   return res;
}
//************************************************************************************
int CBCGPOutlineParser::GetStartOffset (const CString& strIn, int nStartFrom, int nSearchTo, CObList& lstIgnore)
{
	ASSERT (nStartFrom >= 0);
	ASSERT (nSearchTo >= 0);
	
	CString strDelimeters = _T(" \t\n");
	int i = nStartFrom;

	while (i > nSearchTo)
	{
		i--;
		if (strDelimeters.Find (strIn[i]) == -1 && 
			!IsInRange (lstIgnore, i, i))
		{
			nStartFrom = i + 1;
			break;
		}
	}
		
	return nStartFrom;
}
Ejemplo n.º 25
0
bool
PreReservedVirtualAllocWrapper::IsInRange(void * address)
{
    if (!this->IsPreReservedRegionPresent())
    {
        return false;
    }
    bool isInRange = IsInRange(GetPreReservedStartAddress(), address);
#if DBG
    if (isInRange)
    {
        //Check if the region is in MEM_COMMIT state.
        MEMORY_BASIC_INFORMATION memBasicInfo;
        size_t bytes = VirtualQuery(address, &memBasicInfo, sizeof(memBasicInfo));
        if (bytes == 0)
        {
            return false;
        }
        AssertMsg(memBasicInfo.State == MEM_COMMIT, "Memory not committed? Checking for uncommitted address region?");
    }
#endif
    return isInRange;
}
Ejemplo n.º 26
0
bool
wxIntegerValidatorBase::IsCharOk(const wxString& val, int pos, wxChar ch) const
{
    // We may accept minus sign if we can represent negative numbers at all.
    if ( ch == '-' )
    {
        // Notice that entering '-' can make our value invalid, for example if
        // we're limited to -5..15 range and the current value is 12, then the
        // new value would be (invalid) -12. We consider it better to let the
        // user do this because perhaps he is going to press Delete key next to
        // make it -2 and forcing him to delete 1 first would be unnatural.
        //
        // TODO: It would be nice to indicate that the current control contents
        //       is invalid (if it's indeed going to be the case) once
        //       wxValidator supports doing this non-intrusively.
        return m_min < 0 && IsMinusOk(val, pos);
    }

    // We only accept digits here (remember that '-' is taken care of by the
    // base class already).
    if ( ch < '0' || ch > '9' )
        return false;

    // And the value after insertion needs to be in the defined range.
    LongestValueType value;
    if ( !FromString(GetValueAfterInsertingChar(val, pos, ch), &value) )
        return false;

    wxString smin = ToString(m_min);
    wxString smax = ToString(m_max);
    if ( pos < (int) smin.Length() )
       return true;
    if ( pos < (int) smax.Length() - 1 )
       return true;

    return IsInRange(value);
}
Ejemplo n.º 27
0
bool GatherFoodAction::Execute(AGOAPAIController& controller)
{
	// Check if the desired effects are already valid, if so, we're done
	if (AreEffectsSatisfied(controller))
	{
		return true;
	}

	// Check if we have a target, if not, find one
	if (ActionTarget == nullptr)
	{
		ActionTarget = (&controller)->FindNewResourceActor(EResourceType::Food);
	}
	if (ActionTarget == nullptr)
	{
		// No targets, we need to abort this action
		// TODO: Abort code
		return false;
	}

	// If we're not in range of the target, change to a move state
	if (!IsInRange(controller))
	{
		(&controller)->SetMoveToStateWithTarget(ActionTarget->GetActorLocation());
		return false;
	}
	// Otherwise, we're in range! Let's nuke the target
	else
	{
		ActionTarget->Destroy();
		ActionTarget = nullptr;
		(&controller)->character->Stat_HasFood = true;
		return true;
	}

	return false;
}
Ejemplo n.º 28
0
bool
OLCTriangle::FindClosingPairs(unsigned old_size)
{
  if (predict) {
    return closing_pairs.Insert(ClosingPair(0, n_points-1));
  }

  struct TracePointNode {
    const TracePoint *point;
    unsigned index;
  };

  struct TracePointNodeAccessor {
    gcc_pure
    int GetX(const TracePointNode &node) const {
      return node.point->GetFlatLocation().x;
    }

    gcc_pure
    int GetY(const TracePointNode &node) const {
      return node.point->GetFlatLocation().y;
    }
  };

  QuadTree<TracePointNode, TracePointNodeAccessor> search_point_tree;

  for (unsigned i = old_size; i < n_points; ++i) {
    TracePointNode node;
    node.point = &GetPoint(i);
    node.index = i;

    search_point_tree.insert(node);
  }

  search_point_tree.Optimise();

  bool new_pair = false;

  for (unsigned i = old_size; i < n_points; ++i) {
    TracePointNode point;
    point.point = &GetPoint(i);
    point.index = i;

    const SearchPoint start = *point.point;
    const unsigned max_range = trace_master.ProjectRange(start.GetLocation(), max_distance);
    const unsigned half_max_range_sq = max_range * max_range / 2;

    const int min_altitude = GetMinimumFinishAltitude(*point.point);
    const int max_altitude = GetMaximumStartAltitude(*point.point);

    unsigned last = 0, first = i;

    const auto visitor = [this, i, start,
                          half_max_range_sq,
                          min_altitude, max_altitude,
                          &first, &last]
      (const TracePointNode &node) {
      const auto &dest = *node.point;

      if (node.index + 2 < i &&
          dest.GetIntegerAltitude() <= max_altitude &&
          IsInRange(start, dest, half_max_range_sq, max_distance)) {
        // point i is last point
        first = std::min(node.index, first);
        last = i;
      } else if (node.index > i + 2 &&
                 dest.GetIntegerAltitude() >= min_altitude &&
                 IsInRange(start, dest, half_max_range_sq, max_distance)) {
        // point i is first point
        first = i;
        last = std::max(node.index, last);
      }
    };

    search_point_tree.VisitWithinRange(point, max_range, visitor);

    if (last != 0 && closing_pairs.Insert(ClosingPair(first, last)))
      new_pair = true;
  }

  return new_pair;
}
Ejemplo n.º 29
0
inline bool IsDecimalDigit(char c) {
	return IsInRange(c, '0', '9');
}
Ejemplo n.º 30
0
// 二点の距離が指定範囲いないかどうか
bool IsInRange( const Vector2 &vecA, const Vector2 &vecB, const uint32_t &range )
{
	return IsInRange( vecA, vecB, static_cast<float>(range) );
}