[vtkusers] Picking point clouds inside vtkBoxWidget

German26 b.almatrouk at outlook.com
Tue Mar 19 09:01:50 EDT 2019


Hello, I have just started experimenting with VTK library. So far in my
project, I have created the following cube structure:

    struct Cube
    {
        Cube(){
            type="unknown";
           
this->detail.center_x=this->detail.center_y=this->detail.center_z=0;
            this->detail.yaw=2;
            this->detail.length=this->detail.width=this->detail.height=1;
        }
        Cube(const double p1[3],const double p2[3],string type_="unknown"){
            type=type_;
            this->detail.center_x=(p1[0]+p2[0])/2;
            this->detail.center_y=(p1[1]+p2[1])/2;
            this->detail.center_z=(p1[2]+p2[2])/2;
            this->detail.yaw=0;
            this->detail.length=p2[0]-p1[0];
            this->detail.width=p2[1]-p1[1];
            this->detail.height=p2[2]-p1[2];
        }
        string type;
        union{
            double data[7];
            struct{
                double center_x;
                double center_y;
                double center_z;
                double length;
                double width;
                double height;
                double yaw;
            } detail;
        };

        string toString(){
            char buffer [200];
            sprintf(buffer,"%s %f %f %f %f %f %f %f",
                   
type.c_str(),data[0],data[1],data[2],data[3],data[4],data[5],data[6]);
            return std::string(buffer);;
         }
    };

When the cube is selected, its vtkBoxWidget gets activated as follow:

    boxWidget = vtkSmartPointer<vtkBoxWidgetRestricted>::New();
    boxWidgetCallback0 = vtkSmartPointer<vtkBoxWidgetCallback0>::New();
    boxWidgetCallback0->setAnno(this);
    
    boxWidget->SetInteractor(interactor);
    double bounds[6]={-1,1,-1,1,-1,1};
    boxWidget->PlaceWidget(bounds);

    vtkSmartPointer<vtkTransform> t=vtkSmartPointer<vtkTransform>::New();
    t->DeepCopy(actor->GetUserTransform());
    boxWidget->SetTransform(t);
    boxWidget->SetHandleSize(0.01);
    boxWidget->GetOutlineProperty()->SetAmbientColor(1.0,0.0,0.0);

    boxWidget->AddObserver( vtkCommand::InteractionEvent, boxWidgetCallback0
);
    boxWidget->On();

In my program I open a point cloud file, where the point clouds can be
viewed in the visalizer and I can add as many cubes on the point clouds as I
can. 

My question is, is there a possible way to pick all the point clouds inside
the selected vtkBoxWidget so I can then remove these points inside the box,
would getPolyData work for this purpose? 

Any help is appreciated :) 





--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list