I am looping through getting my points in p0_x, p0_y…and so on. Then I push them into my vector of SUPoint3D.
std::vector<SUPoint3D>polygon;
SUPoint3D pPoint0 = {p0_x, p0_y, p0_z};
SUPoint3D pPoint1 = {p1_x, p1_y, p1_z};
SUPoint3D pPoint2 = {p2_x, p2_y, p2_z};
polygon.push_back(pPoint0);
polygon.push_back(pPoint1);
polygon.push_back(pPoint2);
My vector gets filled with about 2000 points.
Then I go to create my GeometryInputRef and LoopRef.
SUGeometryInputRef input = SU_INVALID;
SUGeometryInputCreate(&input);
long vertex_index_start = 0;
size_t face_index;
int count = polygon.size();
SUPoint3D* points = new SUPoint3D[count];
for(int c=0; c < count; c++){
/*double pX = polygon[c].x;
double pY = polygon[c].y;
double pZ = polygon[c].z;*/
points[count - c - 1] = polygon[c];
}
//SUGeometryInputSetVertices(input, polygon.size(), &polygon[0]);
//SUGeometryInputSetVertices(input, count, points);
//delete [] points;
SULoopInputRef loop = SU_INVALID;
SULoopInputCreate(&loop);
for(size_t i=0; i < count; i++){
//SUGeometryInputAddVertex(input, &polygon[i]);
SUGeometryInputAddVertex(input, &points[i]);
SULoopInputAddVertexIndex(loop, i);
}
//SUResult addInnerLoop = SUGeometryInputFaceAddInnerLoop(input, face_index, &loop);
SUResult addFace = SUGeometryInputAddFace(input, &loop, &face_index);
The addInnerLoop result gets an error_out_of_range, but the addFace result is none.
Then I call:
SUEntitiesRef entities = SU_INVALID;
SUModelGetEntities(model, &entities);
SUEntitiesFill(entities, input, true);
But it creates an empty model.