Create Face with GeometryInput Creating Empty Component


I am looping through getting my points in p0_x, p0_y…and so on. Then I push them into my vector of SUPoint3D.

    SUPoint3D pPoint0 = {p0_x, p0_y, p0_z};
    SUPoint3D pPoint1 = {p1_x, p1_y, p1_z};
    SUPoint3D pPoint2 = {p2_x, p2_y, p2_z};

My vector gets filled with about 2000 points.
Then I go to create my GeometryInputRef and LoopRef.

                        SUGeometryInputRef input = SU_INVALID;

			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;
			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.


Have you checked the return values of your function calls?


The variable face_index is not valid (it’s uninitialized) at the point of calling
SUGeometryInputFaceAddInnerLoop(); it’s set on the SUGeometryInputAddFace() call that follows. That’s why you’re getting an error_out_of_range result. You shouldn’t need to call SUGeometryInputFaceAddInnerLoop() with the outer loop anyways.