Пример #1
0
int CRF_TextPage::GetIndexAtPos(CPDF_Point point, FX_FLOAT xTorelance, FX_FLOAT yTorelance) const
{
    int index = -1, i = 0, j = 0;
    FPDF_CHAR_INFO info;
    CFX_FloatRect rectTmp;
    FX_FLOAT MinDistance = 1000, DistanceTmp = 0;
    FX_FLOAT rect_bottom = point.x - xTorelance;
    CFX_FloatRect TorelanceRect(rect_bottom <= 0 ? 0 : rect_bottom, point.y - yTorelance, point.x + xTorelance, point.y + yTorelance);
    int count = CountChars();
    for(i = 0; i < count; i++) {
        GetCharInfo(i, info);
        rectTmp = info.m_CharBox;
        if(rectTmp.Contains(point.x, point.y)) {
            index = i;
            break;
        } else if(_IsIntersect(rectTmp, TorelanceRect)) {
            DistanceTmp = _GetDistance(rectTmp, point);
            if(DistanceTmp < MinDistance) {
                MinDistance = DistanceTmp;
                index = i;
            }
        }
    }
    return index;
}
Пример #2
0
bool ZQuadTree::_BuildQuadTree(CGeoMapData &pHeightMap, Point &bottomLeft)
{
	const unsigned char *buffer = pHeightMap.GetGeoBuffer();
	int nXSize = pHeightMap.GetXSize();
	int nBands = pHeightMap.GetNBands();

	m_fRadius = _GetDistance(Vertex (bottomLeft.x + m_nCorner[CORNER_TL].x, bottomLeft.y + m_nCorner[CORNER_TL].y, 0),
		Vertex(bottomLeft.x + m_nCorner[CORNER_BR].x, bottomLeft.y + m_nCorner[CORNER_BR].y, 0)) / 2.0f;

	if(_SubDivide())
	{
		m_pChild[CORNER_TL] -> _BuildQuadTree(pHeightMap, bottomLeft);
		m_pChild[CORNER_TR] -> _BuildQuadTree(pHeightMap, bottomLeft);
		m_pChild[CORNER_BL] -> _BuildQuadTree(pHeightMap, bottomLeft);
		m_pChild[CORNER_BR] -> _BuildQuadTree(pHeightMap, bottomLeft);
	}

	return true;
}
Пример #3
0
int ZQuadTree::_GetLODLevel(CGeoMapData &pHeightMap, Point &bottomLeft, Vertex &pCamera, float fLODRatio)
{
	float d = _GetDistance(Vertex(bottomLeft.x + m_nCenter.x,bottomLeft.y + m_nCenter.y, 0),pCamera);
	return MAX((int) (d * fLODRatio), MIN_SIZE);
}