Hello, sorry for the long silence, I moved away from the project for a while, and had just got back to it recently.
Unfortunately, the SetCappingOn() made no difference, not sure if it is a bug or not on vtk’s part.
Regardless, turns out a simpler solution is indeed possible, simply create 2 ellipses (the caps), extrude the back one forwards, then combine them via the Combine Poly data example.
The result is this, with no enclosed surfaces.
Pipeline is as follows:
void CreateEllipse(vtkVector3d center, std::vector<vtkVector3d> &points, double radiusX, double radiusY, double zPosition, int resolution = 20)
{
double stepAngleDeg = 360.0 / resolution;
double stepAngleRad = stepAngleDeg * (vtkMath::Pi() / 180.0);
for (double theta = 0; theta < 2 * vtkMath::Pi(); theta += stepAngleRad)
{
double x = center.GetX() + (std::cos(theta) * radiusX);
double y = center.GetY() + (std::sin(theta) * radiusY);
points.push_back(vtkVector3d(x, y, zPosition));
}
}
....
// main
std::vector<vtkVector3d> backEllipse, frontEllipse;
double height = 200;
CreateEllipse(vtkVector3d(0, 0, 0), backEllipse, 35, 65, 0 - (height / 2.0));
CreateEllipse(vtkVector3d(0, 0, 0), frontEllipse, 35, 65, 0 + (height / 2.0));
vtkSmartPointer<vtkPolyData> backEllipsePolyData, frontEllipsePolyData;
ConstructPolyDataFromPoints(backEllipse, backEllipsePolyData);
ConstructPolyDataFromPoints(frontEllipse, frontEllipsePolyData);
vtkSmartPointer<vtkLinearExtrusionFilter> extrudeForward = vtkSmartPointer<vtkLinearExtrusionFilter>::New();
extrudeForward->SetInputData(backEllipsePolyData);
extrudeForward->SetExtrusionTypeToVectorExtrusion();
extrudeForward->SetVector(0, 0, height);
extrudeForward->CappingOn();
extrudeForward->Update();
//Append the two meshes
vtkSmartPointer<vtkAppendPolyData> appendFilter = vtkSmartPointer<vtkAppendPolyData>::New();
appendFilter->AddInputData(extrudeForward->GetOutput());
appendFilter->AddInputData(frontEllipsePolyData);
// Remove any duplicate points.
vtkSmartPointer<vtkCleanPolyData> cleanFilter = vtkSmartPointer<vtkCleanPolyData>::New();
cleanFilter->SetInputConnection(appendFilter->GetOutputPort());
cleanFilter->Update();
Hope this helps anyone in the future.