0
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

4

3 回答 3

2

m_i2pt3idVertices是存储POINT3DID对象的容器。单独来说,它没有成员变量x,yz. 你可以在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
于 2013-03-27T05:13:12.507 回答
1

您需要使用迭代器。这是一个示例:

std::map<unsigned int, POINT3DID>::iterator it;
it = m_i2pt2idVertices.find(5);
it->second.x = 0;
it->second.y = 1;
it->second.z = 2;
于 2013-03-27T05:13:53.740 回答
1

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;
}
于 2013-03-27T05:14:42.300 回答