struct POINT3DID
{
unsigned int newID;
float x, y, z;
};
typedef std::map<unsigned int, POINT3DID> ID2POINT3DID;
ID2POINT3DID m_i2pt3idVertices;
x,y and z
誰かが使用して変数にアクセスする方法を教えてもらえますかm_i2pt3idVertices
m_i2pt3idVertices
POINT3DID
オブジェクトを格納するためのコンテナです。x
単独では、メンバー変数、、、y
またははありませんz
。あなたはそれの中に置くことができPOINT3DID
ます:
m_i2pt3idVertices[0] = POINT3DID(); // Put a POINT3DID into key 0
m_i2pt3idVertices[0].x = 1.0f; // Assign x for key 0
m_i2pt3idVertices[0].y = 2.0f; // Assign y for key 0
m_i2pt3idVertices[0].z = 3.0f; // Assign z for key 0
イテレータを使用する必要があります。サンプルは次のとおりです。
std::map<unsigned int, POINT3DID>::iterator it;
it = m_i2pt2idVertices.find(5);
it->second.x = 0;
it->second.y = 1;
it->second.z = 2;
ID2POINT3DID
マップコンテナです。unsigned int
いくつかのキーで単一の要素にアクセスできます。
m_i2pt3idVertices[42].x
または、コンテナ内の要素を反復処理できます。
for(ID2POINT3DID::iterator it=m_i2pt3idVertices.begin();it!=m_i2pt3idVertices.end();++it) {
cout << it->second.x << " " << it->second.y << " " << it->second.z << endl;
}