示例#1
0
int NFCRecord::FindVector2(const int nCol, const NFVector2& value, NFDataList& varResult)
{
	if (!ValidCol(nCol))
	{
		return -1;
	}

	if (TDATA_VECTOR2 != mVarRecordType->Type(nCol))
	{
		return -1;
	}

	{
		for (int i = 0; i < mnMaxRow; ++i)
		{
			if (!IsUsed(i))
			{
				continue;
			}

			if (GetVector2(i, nCol) == value)
			{
				varResult << (int64_t)i;
			}
		}

		return varResult.GetCount();
	}

	return -1;
}
void	cFishShowProbability::ProcessAreaData(TiXmlElement*e_pTiXmlElement)
{
	m_AreaDataVector.clear();
	e_pTiXmlElement = e_pTiXmlElement->FirstChildElement();
	while( e_pTiXmlElement )
	{
		sAreaData	l_sAreaData;
		l_sAreaData.ShowAreaID = e_pTiXmlElement->Attribute(L"AreaID")[0];
		l_sAreaData.Range = GetVector2(e_pTiXmlElement->Attribute(L"Range"));
		l_sAreaData.vFishAppearDistance = GetVector2(e_pTiXmlElement->Attribute(L"FishAppearDistance"));
		if( m_AreaDataVector.size() > 0 )
		{
			if( m_AreaDataVector[m_AreaDataVector.size()-1].Range.y >= l_sAreaData.Range.x )
			{
				UT::ErrorMsg(L"fish show range data is error",L"ProcessAreaData(TiXmlElement*e_pTiXmlElement)");
			}
		}
		m_AreaDataVector.push_back(l_sAreaData);
		e_pTiXmlElement = e_pTiXmlElement->NextSiblingElement();
	}
}
void	cFishShowProbability::ProcessFishesShowProbabilityData(TiXmlElement*e_pTiXmlElement)
{
	m_FishesShowProbability.FishAndProbabilityVector.clear();
	m_FishesShowProbability.iAppearFishesCount = GetInt(e_pTiXmlElement->Attribute(L"AppearFishTypeCount"));
	m_FishesShowProbability.vFishShowRange = GetVector2(e_pTiXmlElement->Attribute(L"FishShowRange"));
	e_pTiXmlElement = e_pTiXmlElement->FirstChildElement();
	while( e_pTiXmlElement )
	{
		std::wstring	l_strFileName = e_pTiXmlElement->Attribute(L"FileName");
		float	l_fProbability = GetFloat(e_pTiXmlElement->Attribute(L"Probability"));
		WCHAR	l_wcShowAreaID = e_pTiXmlElement->Attribute(L"AreaID")[0];
		sFishAndProbability	l_sFishAndProbability(l_strFileName,l_fProbability,l_wcShowAreaID);
		m_FishesShowProbability.FishAndProbabilityVector.push_back(l_sFishAndProbability);
		e_pTiXmlElement = e_pTiXmlElement->NextSiblingElement();
	}
}
示例#4
0
    const Urho3D::Vector2 ConfigManager::GetVector2(const Urho3D::String& section, const Urho3D::String& parameter, const Urho3D::Vector2& defaultValue)
    {
        auto value = Get(section, parameter);

        if (value.GetType() == Urho3D::VAR_VECTOR2)
            return value.GetVector2();

        if (value.GetType() == Urho3D::VAR_STRING)
            return Urho3D::ToVector2(value.GetString());

        // Parameter doesn't exist, or is a different type
        if (_saveDefaultParameters)
        {
            // Set back to default
            Set(section, parameter, defaultValue);
        }

        return defaultValue;
    }
示例#5
0
template <> Vector2 Variant::Get<Vector2>() const
{
    return GetVector2();
}
示例#6
0
template <> const Vector2& Variant::Get<const Vector2&>() const
{
    return GetVector2();
}
示例#7
0
const NFVector2& NFCRecord::GetVector2(const int nRow, const std::string& strColTag) const
{
	int nCol = GetCol(strColTag);
	return GetVector2(nRow, nCol);
}
ProjectStructs::MESHLESS_OBJECT_STRUCT PointCloudHandler::ProcessPointCloud( std::string file, CSGTree *&volumeTree , Volume *&volume)
{
    TiXmlDocument pointCloudXml;

    if(!pointCloudXml.LoadFile(file.c_str())) {
        std::string errorText = "Could not parse " + file;
        std::string errorHeader = "Point Cloud Error";

        MessageBox(0, errorText.c_str(), errorHeader.c_str(), 0);
    }

    ProjectStructs::MESHLESS_OBJECT_STRUCT meshlessStruct;

    TiXmlNode *meshNode = pointCloudXml.FirstChild(XML_MESHLESS_ROOT);

    meshlessStruct.name = meshNode->FirstChild(XML_MESHLESS_NAME)->FirstChild()->Value();
    meshlessStruct.materialProperties.deformable = meshNode->FirstChild(XML_MESHLESS_DEFORMABLE)->FirstChild()->Value() == XML_MESHLESS_TRUE;
    meshlessStruct.materialProperties.texture= meshNode->FirstChild(XML_MESHLESS_TEXTURE)->FirstChild()->Value();

    D3DXVECTOR3 translation = GetVector3(meshNode->FirstChild(XML_MESHLESS_WORLDTRANSLATION)->ToElement());
    D3DXVECTOR3 scale = GetVector3(meshNode->FirstChild(XML_MESHLESS_WORLDSCALE)->ToElement());
    D3DXVECTOR3 yawpitchroll= GetVector3(meshNode->FirstChild(XML_MESHLESS_WORLDYAWPITCHROLL)->ToElement());

    double d;
    meshNode->FirstChild(XML_MESHLESS_LIGHTING)->ToElement()->Attribute(XML_MESHLESS_MATERIAL_RHO.c_str(), &d);
    meshlessStruct.materialProperties.rho = (float)d;
    meshNode->FirstChild(XML_MESHLESS_LIGHTING)->ToElement()->Attribute(XML_MESHLESS_MATERIAL_SIGMA.c_str(), &d);
    meshlessStruct.materialProperties.sigma = (float)d;
    meshlessStruct.materialProperties.vertexGridSize= -1.0f;

    if(meshlessStruct.materialProperties.deformable) {
        meshlessStruct.materialProperties.density = (float)atof(meshNode->FirstChild(XML_MESHLESS_DENSITY)->FirstChild()->Value());
//			meshlessStruct.materialProperties.mass = (float)atof(meshNode->FirstChild(XML_MESHLESS_MASS)->FirstChild()->Value());
        meshlessStruct.materialProperties.toughness = (float)atof(meshNode->FirstChild(XML_MESHLESS_TOUGHNESS)->FirstChild()->Value());
        meshlessStruct.materialProperties.youngsModulus = (float)atof(meshNode->FirstChild(XML_MESHLESS_YOUNGS_MODULUS)->FirstChild()->Value());// * pow(10.0f, 5.0f);
        meshlessStruct.materialProperties.poissonRatio = (float)atof(meshNode->FirstChild(XML_MESHLESS_POISSON_RATIO)->FirstChild()->Value());
        meshlessStruct.materialProperties.phyxelGridSize= (float)atof(meshNode->FirstChild(XML_MESHLESS_PHYXEL_GRID_SIZE)->FirstChild()->Value());
        meshlessStruct.materialProperties.minimunSurfelSize = (float)atof(meshNode->FirstChild(XML_MESHLESS_MINIMUM_SURFEL_SIZE)->FirstChild()->Value());
        meshlessStruct.materialProperties.vertexGridSize= (float)atof(meshNode->FirstChild(XML_MESHLESS_VERTEX_GRID_SIZE)->FirstChild()->Value());
    }


    meshlessStruct.transform = translation;

    D3DXMATRIX translationMatrix, scaleMatrix, yawpitchrollMatrix;
    D3DXMatrixTranslation(&translationMatrix, translation.x, translation.y, translation.z);
    D3DXMatrixScaling(&scaleMatrix, scale.x, scale.y, scale.z);
    D3DXMatrixRotationYawPitchRoll(&yawpitchrollMatrix, yawpitchroll.x, yawpitchroll.y, yawpitchroll.z);
    meshlessStruct.scale = scale;
    meshlessStruct.rotation= yawpitchroll;

    meshlessStruct.world = scaleMatrix * yawpitchrollMatrix * translationMatrix;

    TiXmlNode* volumeNode = meshNode->FirstChild(XML_MESHLESS_VOLUME);

    TiXmlNode* surfel;

    std::vector<Volume*> volumes;

    do {
        surfel = volumeNode->FirstChild(XML_MESHLESS_SURFACE);
        Volume *v = new Volume(meshlessStruct.materialProperties);
        v->SetWorld(meshlessStruct.world);

        do {
            D3DXVECTOR3 pos = GetVector3(surfel ->FirstChild(XML_MESHLESS_SURFACE_POSITION)->ToElement());
            D3DXVECTOR3 majorAxis = GetVector3(surfel ->FirstChild(XML_MESHLESS_SURFACE_SURFEL_MAJOR_AXIS)->ToElement());
            D3DXVECTOR3 minorAxis = GetVector3(surfel ->FirstChild(XML_MESHLESS_SURFACE_SURFEL_MINOR_AXIS)->ToElement());
            D3DXVECTOR3 normal = GetVector3(surfel ->FirstChild(XML_MESHLESS_SURFACE_SURFEL_NORMAL)->ToElement());
            D3DXVECTOR2 count = GetVector2(surfel ->FirstChild(XML_MESHLESS_SURFACE_SURFEL_COUNT)->ToElement());

            CreateSurface(v, pos, majorAxis, minorAxis, normal, count.x, count.y, meshlessStruct.texture);

            surfel = surfel->NextSibling(XML_MESHLESS_SURFACE);

        } while(surfel);

        v->Init();

        volumes.push_back(v);

        volumeNode = volumeNode->NextSibling(XML_MESHLESS_VOLUME);

    } while(volumeNode);

    if(volumes.size() == 1)
    {
        volume = volumes[0];

        volumes.clear();
        return meshlessStruct;
    }
    else if(volumes.size() == 2)
    {
        volumeTree = new CSGTree();
        volumeTree->CreateTree(volumeTree->And(volumes[0], volumes[1]));
        volumes.clear();
        return meshlessStruct;
    }

    volumeTree = new CSGTree();

    std::vector<OPERATOR_NODE*> one, two;

    bool done = false;
    int size = volumes.size();

    for(unsigned int i = 0; i<volumes.size()-1; i+=2) {
        one.push_back(volumeTree->And(volumes[i], volumes[i+1]));
    }
    if(volumes.size() % 2 == 1) {
        one[one.size()-1] = volumeTree->And(one[one.size()-1], volumes[volumes.size()-1]);
    }

    while(!done) {
        two.clear();

        for(unsigned int i = 0; i<one.size()-1; i+=2) {
            two.push_back(volumeTree->And(one[i], one[i+1]));
        }
        if(one.size() % 2 == 1) {
            two[two.size()-1] = volumeTree->And(two[two.size()-1], one[one.size()-1]);
        }

        if(one.size() == 2) {
            volumeTree->CreateTree(volumeTree->And(one[0], one[1]));
            break;
        }
        if(two.size() == 2) {
            volumeTree->CreateTree(volumeTree->And(two[0], two[1]));
            break;
        }
        if(one.size() == 1) {
            volumeTree->CreateTree(one[0]);
            break;
        }
        if(two.size() == 1) {
            volumeTree->CreateTree(two[0]);
            break;
        }

        one.clear();

        for(unsigned int i = 0; i<two.size()-1; i+=2)
            one.push_back(volumeTree->And(two[i], two[i+1]));

        if(two.size() % 2 == 1) {
            one[one.size()-1] = volumeTree->And(one[one.size()-1], two[two.size()-1]);
        }
    }

    volumes.clear();
    return meshlessStruct;
}