<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hello Tomas,<div class=""><br class=""></div><div class=""><blockquote type="cite" class="">I'm quite surprised by the lack of information to learn this tool.</blockquote><div class=""><br class=""></div>There are quite a few sources information out there on how to use VTK: a <a href="https://www.vtk.org/Wiki/VTK" class="">wiki</a>, a <a href="https://www.kitware.com/products/books/VTKUsersGuide.pdf" class="">user’s guide</a>, a <a href="https://www.kitware.com/products/books/VTKTextbook.pdf" class="">textbook</a>, <a href="https://www.vtk.org/doc/release/7.1/html/" class="">generated documentation</a>, and <a href="https://vtk.markmail.org" class="">archives of this mailing list</a> to name a few. <br class=""><div><br class=""></div><div><blockquote type="cite" class=""> My task is to extract a sphere from a model using vtkSphereWidget and visualize its scalar atrribute distribution using vtkGlyphs.</blockquote><br class=""></div><div>So, you have a dataset and you wish to clip a sphere from it and draw glyphs on this sphere’s surface? There are several ways you could try this, but here’s one off the top of my head: import your dataset, construct a sphere source, use vtkProbeFilter to sample your first dataset onto your sphere, and then glyph the resulting fields on your sphere polydata. You probably could use vtkCutter to accomplish this as well. Good luck, and welcome to VTK!</div><div><br class=""></div><div>Sincerely,</div><div>T.J.</div><div><br class=""><blockquote type="cite" class=""><div class="">On Jun 5, 2018, at 2:59 AM, TomasKiniulis <<a href="mailto:tkiniulis@gmail.com" class="">tkiniulis@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Hey folks, have a course in university to study The Visualization Toolkit. I'm a complete newbie and I'm quite surprised by the lack of information to learn this tool. So I hope you can help me here.

My task is to extract a sphere from a model using vtkSphereWidget and visualize its scalar atrribute distribution using vtkGlyphs. How can I use a vtkSphereWidget to extract a sphere? Do I need to create a sphere that follows around the widget? Any examples you could suggest of such task?

Found this useful example, but it's using a plane to cut. How would I use this with a sphere?
<a href="https://www.vtk.org/Wiki/VTK/Examples/Cxx/VisualizationAlgorithms/Cutter" class="">https://www.vtk.org/Wiki/VTK/Examples/Cxx/VisualizationAlgorithms/Cutter</a>

This is my messy code, my attempt here was to make box cut instead of a plane one. But instead it throws me an error that "there is no suitable conversion function from "vtkSmartPointer<vtkcubesource class=""> to "vtkImplicitFunction *" exists.
<code class="">//Cutter code
#include <vtksmartpointer.h class="">
#include <vtkcubesource.h class="">
#include <vtkpolydata.h class="">
#include <vtkpolydatamapper.h class="">
#include <vtkplane.h class="">
#include <vtkcutter.h class="">
#include <vtkproperty.h class="">
#include <vtkactor.h class="">
#include <vtkrenderer.h class="">
#include <vtkrenderwindow.h class="">
#include <vtkrenderwindowinteractor.h class="">

#include <vtkstructuredpoints.h class="">
#include <vtkstructuredpointsreader.h class="">

#include <vtkdatasetattributes.h class="">
#include <vtkdatasetmapper.h class="">
#include <vtkglyph3d.h class="">

#include <vtkspheresource.h class="">
#include <vtkspherewidget.h class="">
#include <vtksphererepresentation.h class="">
#include <vtkcommand.h class="">

class SphereCallback : public vtkCommand
{
public:
        static SphereCallback *New()
        {
                return new SphereCallback;
        }
        SphereCallback() {}

        virtual void Execute(vtkObject *caller, unsigned long, void*)
        {
                vtkSphereWidget *sphereWidget =
                        reinterpret_cast<vtkSphereWidget*>(caller);

                double center[3];
                sphereWidget->GetCenter(center);
                std::cout << "Center: " << center[0] << " " << center[1] << " " << center[2] << std::endl;
        }

};

int main(int, char *[])
{
        //nuskaitymas
        vtkSmartPointer<vtkstructuredpointsreader class=""> reader = vtkSmartPointer<vtkstructuredpointsreader class="">::New();
        reader->SetFileName("Models\\carotid.vtk");
        reader->Update();

        vtkSmartPointer<vtkdatasetmapper class=""> carotidMapper = vtkSmartPointer<vtkdatasetmapper class="">::New();
        carotidMapper->SetInputConnection(reader->GetOutputPort());
        //Create carotid actor
        vtkSmartPointer<vtkactor class=""> carotidActor =
                vtkSmartPointer<vtkactor class="">::New();
        carotidActor->GetProperty()->SetOpacity(0.5);
        carotidActor->SetMapper(carotidMapper);
        //Creating plane to cut this majestic peace of model
        vtkSmartPointer<vtkcubesource class=""> sphereC =
                vtkSmartPointer<vtkcubesource class="">::New();
        sphereC->SetXLength(40);
        sphereC->SetYLength(30);
        sphereC->SetZLength(20);
        sphereC->SetOrigin(20, 0, 0);
        // Create carotid cutter
        vtkSmartPointer<vtkcutter class=""> cutterC =
                vtkSmartPointer<vtkcutter class="">::New();
        cutterC->SetCutFunction(sphereC);
        cutterC->SetInputConnection(reader->GetOutputPort());
        cutterC->Update();

        vtkSmartPointer<vtkdatasetmapper class=""> cutterMapperC =
                vtkSmartPointer<vtkdatasetmapper class="">::New();
        cutterMapperC->SetInputConnection(cutterC->GetOutputPort());
        //
        vtkSmartPointer<vtkcubesource class=""> cube =
                vtkSmartPointer<vtkcubesource class="">::New();
        cube->SetXLength(40);
        cube->SetYLength(30);
        cube->SetZLength(20);
        vtkSmartPointer<vtkpolydatamapper class=""> cubeMapper =
                vtkSmartPointer<vtkpolydatamapper class="">::New();
        cubeMapper->SetInputConnection(cube->GetOutputPort());

        // Create a plane to cut,here it cuts in the XZ direction (xz normal=(1,0,0);XY =(0,0,1),YZ =(0,1,0)
        vtkSmartPointer<vtkplane class=""> plane =
                vtkSmartPointer<vtkplane class="">::New();
        plane->SetOrigin(10, 0, 0);
        plane->SetNormal(1, 0, 0);

        // Create cutter
        vtkSmartPointer<vtkcutter class=""> cutter =
                vtkSmartPointer<vtkcutter class="">::New();
        cutter->SetCutFunction(plane);
        cutter->SetInputConnection(cube->GetOutputPort());
        cutter->Update();


        vtkSmartPointer<vtkpolydatamapper class=""> cutterMapper =
                vtkSmartPointer<vtkpolydatamapper class="">::New();
        cutterMapper->SetInputConnection(cutter->GetOutputPort());

        // Create plane actor
        vtkSmartPointer<vtkactor class=""> planeActor =
                vtkSmartPointer<vtkactor class="">::New();
        planeActor->GetProperty()->SetColor(1.0, 1, 0);
        planeActor->GetProperty()->SetLineWidth(2);
        planeActor->SetMapper(cutterMapper);

                //Create second plane actor
                vtkSmartPointer<vtkactor class=""> planeActor2 =
                        vtkSmartPointer<vtkactor class="">::New();
                planeActor2->GetProperty()->SetColor(1.0, 1, 0);
                planeActor2->GetProperty()->SetLineWidth(2);
                planeActor2->SetMapper(cutterMapper2);

                //Create carotid actor
                vtkSmartPointer<vtkactor class=""> carotidPlaneActor =
                        vtkSmartPointer<vtkactor class="">::New();
                carotidPlaneActor ->GetProperty()->SetColor(1.0, 1, 0);
                carotidPlaneActor->GetProperty()->SetLineWidth(2);
                carotidPlaneActor->SetMapper(cutterMapperC);

        // Create cube actor
        vtkSmartPointer<vtkactor class=""> cubeActor =
                vtkSmartPointer<vtkactor class="">::New();
        cubeActor->GetProperty()->SetColor(0.5, 1, 0.5);
        cubeActor->GetProperty()->SetOpacity(0.5);
        cubeActor->SetMapper(cubeMapper);

        // Create renderers and add actors of plane and cube
        vtkSmartPointer<vtkrenderer class=""> renderer =
                vtkSmartPointer<vtkrenderer class="">::New();
        renderer->AddActor(planeActor); //display the rectangle resulting from the cut
        renderer->AddActor(cubeActor); //display the cube
        renderer->AddActor(carotidActor); //display carotid
        renderer->AddActor(planeActor2); //display rectangle of second cut
        renderer->AddActor(carotidPlaneActor); //display rectangle of carotid cut

        // Add renderer to renderwindow and render
        vtkSmartPointer<vtkrenderwindow class=""> renderWindow =
                vtkSmartPointer<vtkrenderwindow class="">::New();
        renderWindow->AddRenderer(renderer);

                //Sphere widget interactor
                // An interactor
                vtkSmartPointer<vtkrenderwindowinteractor class=""> renderWindowInteractor =
                        vtkSmartPointer<vtkrenderwindowinteractor class="">::New();
                renderWindowInteractor->SetRenderWindow(renderWindow);

                vtkSmartPointer<vtkspherewidget class=""> sphereWidget = vtkSmartPointer<vtkspherewidget class="">::New();

                sphereWidget->SetInteractor(renderWindowInteractor);
                sphereWidget->SetRepresentationToWireframe();
                sphereWidget->SetProp3D(carotidActor);
                sphereWidget->SetPlaceFactor(0.5);
                sphereWidget->PlaceWidget();

                vtkSmartPointer<vtkcutter class=""> cutter2 =
                        vtkSmartPointer<vtkcutter class="">::New();
                cutter2->SetCutFunction(sphereWidget);
                cutter2->SetInputConnection(cube->GetOutputPort());
                cutter2->Update();

                vtkSmartPointer<vtkdatasetmapper class=""> cutterMapper2 =
                        vtkSmartPointer<vtkdatasetmapper class="">::New();
                cutterMapper2->SetInputConnection(cutter2->GetOutputPort());

                sphereWidget->SetInteractor(renderWindowInteractor);
                sphereWidget->SetRepresentationToSurface();

                vtkSmartPointer<spherecallback class=""> sphereCallback =
                        vtkSmartPointer<spherecallback class="">::New();

                sphereWidget->AddObserver(vtkCommand::InteractionEvent, sphereCallback);

        renderWindow->SetSize(600, 600);

        renderWindowInteractor->SetRenderWindow(renderWindow);
        renderer->SetBackground(0, 0, 0);
        renderWindow->Render();

                //sphere widget interactor
                renderWindowInteractor->Initialize();
                renderWindow->Render();
                sphereWidget->On();
                renderWindowInteractor->Start();

        return EXIT_SUCCESS;
}</spherecallback></spherecallback></vtkdatasetmapper></vtkdatasetmapper></vtkcutter></vtkcutter></vtkspherewidget></vtkspherewidget></vtkrenderwindowinteractor></vtkrenderwindowinteractor></vtkrenderwindow></vtkrenderwindow></vtkrenderer></vtkrenderer></vtkactor></vtkactor></vtkactor></vtkactor></vtkactor></vtkactor></vtkactor></vtkactor></vtkpolydatamapper></vtkpolydatamapper></vtkcutter></vtkcutter></vtkplane></vtkplane></vtkpolydatamapper></vtkpolydatamapper></vtkcubesource></vtkcubesource></vtkdatasetmapper></vtkdatasetmapper></vtkcutter></vtkcutter></vtkcubesource></vtkcubesource></vtkactor></vtkactor></vtkdatasetmapper></vtkdatasetmapper></vtkstructuredpointsreader></vtkstructuredpointsreader></vtkcommand.h></vtksphererepresentation.h></vtkspherewidget.h></vtkspheresource.h></vtkglyph3d.h></vtkdatasetmapper.h></vtkdatasetattributes.h></vtkstructuredpointsreader.h></vtkstructuredpoints.h></vtkrenderwindowinteractor.h></vtkrenderwindow.h></vtkrenderer.h></vtkactor.h></vtkproperty.h></vtkcutter.h></vtkplane.h></vtkpolydatamapper.h></vtkpolydata.h></vtkcubesource.h></vtksmartpointer.h></code>

Any suggestions would be highly appreciated.

        
        
        
<br class=""><hr align="left" width="300" class="">
Sent from the <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html" class="">VTK - Users mailing list archive</a> at <a href="http://Nabble.com" class="">Nabble.com</a>.<br class="">_______________________________________________<br class="">Powered by <a href="http://www.kitware.com" class="">www.kitware.com</a><br class=""><br class="">Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" class="">http://www.kitware.com/opensource/opensource.html</a><br class=""><br class="">Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" class="">http://www.vtk.org/Wiki/VTK_FAQ</a><br class=""><br class="">Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" class="">http://markmail.org/search/?q=vtkusers</a><br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class=""><a href="https://public.kitware.com/mailman/listinfo/vtkusers" class="">https://public.kitware.com/mailman/listinfo/vtkusers</a><br class=""></vtkcubesource></div></blockquote></div><br class=""></div></body></html>