我是C ++的新手
class BlenderMesh{
public:
std::vector<double[3]> vertex_vectors;
std::vector<double[3]> normal_vectors;
std::vector<double[2]> uv_vectors;
std::vector<std::string> texture_list;
std::vector<int[6]> face_indices;
std::vector<int[3]> normal_indices;
std::vector<int[3]> uv_indices;
BlenderMesh();
~BlenderMesh();};
代码错误:mesh-&gt; vertex_vectors.push_back(vertex);
BlenderMesh::BlenderMesh(){}
BlenderMesh::~BlenderMesh(){}
BlenderMesh* mesh = new BlenderMesh();
PyObject* vertexVectors = PyList_GetItem(blenderObject,2);
unsigned int size_vertex_vectors = PyObject_Size(vertexVectors);
for (unsigned int i = 0; i < size_vertex_vectors; i++){
double vertex[3];
PyObject* pyVertex = PyList_GetItem(vertexVectors,i);
PyObject* vertexX = PyTuple_GetItem(pyVertex,0);
vertex[0] = PyFloat_AsDouble(vertexX);
PyObject* vertexY = PyTuple_GetItem(pyVertex,1);
vertex[1] = PyFloat_AsDouble(vertexY);
PyObject* vertexZ = PyTuple_GetItem(pyVertex,2);
vertex[2] = PyFloat_AsDouble(vertexZ);
mesh->vertex_vectors.push_back(vertex);
}
控制台:
/usr/include/c++/4.9.2/ext/new_allocator.h:120:4: error: parenthesized initializer in array new [-fpermissive]
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
/usr/include/c++/4.9.2/ext/new_allocator.h:124:29: error: request for member '~double [3]' in '* __p', which is of non-class type 'double [3]'
destroy(_Up* __p) { __p->~_Up(); }
答案 0 :(得分:1)
已经过去四年了,但希望这对某人有帮助。由于某些原因,您无法创建包含对象本机列表的矢量对象(也许有人可以解释原因?)。
例如,当创建一个包含1'ns的18x2向量时,例如:
std::vector<double[2]> my_vector(18, {1.0, 1.0});
因此,您应该执行以下操作:
std::vector<vector<double>> my_vector(18, vector<double>(2,{1.0, 1.0});