Hello all,
Given the Linear extrusion example, and the elliptical cylinder example, I produced an elliptical cylinder with a capped top and bottom. This is done by extruding towards the center of the ellipse then forwards.
The ellipse is functionally the same as the example:
double angle = 0;
double rx, ry;
double centerX, centerY;
double resolution = 18.0; // Better to be multiples of 6
rx = 20;
ry = 30;
centerX = 0.0;
centerY = 0.0;
double centerZ = -50.0;
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
int id = 0;
while (angle <= 2.0 * vtkMath::Pi() + (vtkMath::Pi() / resolution))
{
points->InsertNextPoint(
rx * cos(angle) + centerX,
ry * sin(angle) + centerY,
centerZ);
angle = angle + (vtkMath::Pi() / resolution);
++id;
}
...
vtkSmartPointer<vtkLinearExtrusionFilter> extrudeIn = vtkSmartPointer<vtkLinearExtrusionFilter>::New();
extrudeIn->SetInputData(polyData);
extrudeIn->SetExtrusionTypeToPointExtrusion();
extrudeIn->SetExtrusionPoint(0, 0, -50);
extrudeIn->SetScaleFactor(-1.0);
extrudeIn->Update();
vtkSmartPointer<vtkLinearExtrusionFilter> extrudeForward = vtkSmartPointer<vtkLinearExtrusionFilter>::New();
extrudeForward->SetInputConnection(extrudeIn->GetOutputPort());
extrudeForward->SetExtrusionTypeToVectorExtrusion();
extrudeForward->SetVector(0, 0, 100);
extrudeForward->Update();
where the polydata
is functionally the same as elliptical cylinder example; the center of the ellipse is (0,0,-50), and extrudes forwards by 100 in z direction.
The problem:
when it extruded inwards, it creates a point in the center, and connects the points in the circumference with lines, and when extruded forwards, the lines form its own surfaces inside the cylinder:
How to avoid the lines being connected when extruding forwards?
An indirect solution would be to identify the interior lines and remove them, however I would need to convert the extrudeIn
data back to vtkPoints and re-generate vtkPolyLine, and even then I don’t have a clue how to identify interior lines.
Source:
Look for the EllipticalCylinder() method
Cutter.cxx (12.3 KB) CMakeLists.txt (688 Bytes)