[vtkusers] Update of multiple clipping planes.

Zoltan Kovacs Zoltan.Kovacs at esi-group.com
Fri Jun 29 05:42:12 EDT 2018


Dear all,

    I have the a code for clipping 3D glyphs with there planes: the normal vectors of
    the planes point to the directions of the coordinate axes and the code clips
    with these three planes through given origins. It clips the glyphs properly with
    three planes and if I remove comments on the section which uses only one of
    the planes (with the normal vector pointing in the y-direction) the code clips
    with only one plane.

    If modify the origin of the plane in the version using only one plane it
    updates the clipping filter and the mapper automatically and I can see the
    new clipping with the modified origin of the clipping plane.
    However, when I modify the origin of one of the planes in the version
    using three planes nothing changes even if update the clipper or/and the
    mapper. Does anyone have a good idea how to implement plane position
    modification for clipping with multiple planes? The relevant part of the
    code is the following:

    clipPlaneOrigins = vtkSmartPointer<vtkPoints>::New();
    clipPlaneNormals = vtkSmartPointer<vtkDoubleArray>::New();
    clipPlaneY       = vtkSmartPointer<vtkPlane>::New();
    clipPlanes       = vtkSmartPointer<vtkPlanes>::New();
    clipper          = vtkSmartPointer<vtkClipPolyData>::New();

    double origin[3], normal[3];
    origin[0] = bounds[0]; origin[1] = bounds[2]; origin[2] = bounds[4];

    clipPlaneOrigins->SetNumberOfPoints(3);

    clipPlaneOrigins->InsertPoint(0, origin);
    clipPlaneOrigins->InsertPoint(1, origin);
    clipPlaneOrigins->InsertPoint(2, origin);

    clipPlaneNormals->SetNumberOfComponents(3);
    clipPlaneNormals->SetNumberOfTuples(3);

    // set the normal of the first clipping plane along the x-axis
    normal[0] = 1; normal[1] = 0; normal[2] = 0;
    clipPlaneNormals->SetTuple(0, normal);

    // set the normal of the second clipping plane along the y-axis
    normal[0] = 0; normal[1] = 1; normal[2] = 0;
    clipPlaneNormals->SetTuple(1, normal);

    // set the normal of the third clipping plane along the z-axis
    normal[0] = 0; normal[1] = 0; normal[2] = 1;
    clipPlaneNormals->SetTuple(2, normal);

    clipPlanes->SetPoints(clipPlaneOrigins);
    clipPlanes->SetNormals(clipPlaneNormals);

    clipper->SetInputConnection(glyph->GetOutputPort());
    clipper->SetClipFunction(clipPlanes);
/*
    normal[0] = 0; normal[1] = 1; normal[2] = 0;
    clipPlaneY->SetOrigin(origin[0],origin[1],origin[2]);
    clipPlaneY->SetNormal(normal[0],normal[1],normal[2]);
    clipper->SetClipFunction(clipPlaneY);
*/
    // connect the output of clipper to the input of the data set mapper
    mapper->SetInputConnection(clipper->GetOutputPort());
    mapper->Update();


    Thanks a for the help!
    Regards
    Zoltan


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180629/b8cfcc4d/attachment.html>


More information about the vtkusers mailing list