[vtkusers] Why cannot I build and run a subclass of vtkInteractorStyleTrackballActor in the debug mode?

pnt1614 minpu.code at gmail.com
Wed Mar 21 19:37:43 EDT 2018


I use the following code (VTK and MFC) to drag a point to a new position.
After click a "picking" button, I use the middle mouse button to move pick
and move a point. I can build and run the release mode, but I cannot build
in the debug mode because of an error. Is there anyone experienced this
problem? Please help me. Thank you.

The error messages are
"Error (active)      no instance of overloaded "InteractorStyle2::operator
new" matches the argument list

Error   C2660   'vtkObject::operator new': function does not take 3
arguments"


This my C++ code:
class InteractorStyle2 : public vtkInteractorStyleTrackballActor 
{
public:
  static InteractorStyle2* New();
  vtkTypeMacro(InteractorStyle2, vtkInteractorStyleTrackballActor);

  InteractorStyle2()
  {
    this->Move = false;
    this->PointPicker = vtkSmartPointer<vtkPointPicker>::New();

    // Setup ghost glyph
    vtkSmartPointer<vtkPoints> points =
        vtkSmartPointer<vtkPoints>::New();
    points->InsertNextPoint(0, 0, 0);
    this->MovePolyData = vtkSmartPointer<vtkPolyData>::New();
    this->MovePolyData->SetPoints(points);
    this->MoveGlyphFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New();
    this->MoveGlyphFilter->SetInputData(this->MovePolyData);
    this->MoveGlyphFilter->Update();

    this->MoveMapper = vtkSmartPointer<vtkPolyDataMapper>::New();
   
this->MoveMapper->SetInputConnection(this->MoveGlyphFilter->GetOutputPort());

    this->MoveActor = vtkSmartPointer<vtkActor>::New();
    this->MoveActor->SetMapper(this->MoveMapper);
    this->MoveActor->VisibilityOff();
    this->MoveActor->GetProperty()->SetPointSize(10);
    this->MoveActor->GetProperty()->SetColor(1, 0, 0);
  }

  void OnMouseMove()
  {
    if (!this->Move)
        return;

    vtkInteractorStyleTrackballActor::OnMouseMove();
  }

  void OnMiddleButtonUp()
  {
    this->EndPan();

    this->Move = false;
    this->MoveActor->VisibilityOff(); // Turn off rendering a red point

    this->Data->GetPoints()->SetPoint(this->SelectedPoint,
this->MoveActor->GetPosition());
    this->Data->Modified();
    this->GetCurrentRenderer()->Render();
    this->GetCurrentRenderer()->GetRenderWindow()->Render();

  }
  void OnMiddleButtonDown()
  {
    // Get the selected point
    int x = this->Interactor->GetEventPosition()[0];
    int y = this->Interactor->GetEventPosition()[1];
    this->FindPokedRenderer(x, y);

    this->PointPicker->Pick(this->Interactor->GetEventPosition()[0],
        this->Interactor->GetEventPosition()[1],
        0,  // always zero.
       
this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());

    if (this->PointPicker->GetPointId() >= 0)
    {
        this->StartPan();
        this->MoveActor->VisibilityOn(); // turn on rendering a red point
        this->Move = true;
        this->SelectedPoint = this->PointPicker->GetPointId();

        std::cout << "Dragging point " << this->SelectedPoint << std::endl;

        double p[3];
        this->Data->GetPoint(this->SelectedPoint, p);
        std::cout << "p: " << p[0] << " " << p[1] << " " << p[2] <<
std::endl;
        this->MoveActor->SetPosition(p);

        this->GetCurrentRenderer()->AddActor(this->MoveActor);
        this->InteractionProp = this->MoveActor;
    }
  }

  vtkPolyData* Data;
  vtkPolyData* GlyphData;

  vtkSmartPointer<vtkPolyDataMapper> MoveMapper;
  vtkSmartPointer<vtkActor> MoveActor;
  vtkSmartPointer<vtkPolyData> MovePolyData;
  vtkSmartPointer<vtkVertexGlyphFilter> MoveGlyphFilter;

  vtkSmartPointer<vtkPointPicker> PointPicker;

  bool Move;
  vtkIdType SelectedPoint;
};
vtkStandardNewMacro(InteractorStyle2); // error occurs in the debug mode

//....
void CvtkMFCDlgExDlg::OnBnClickedButtonPicking()
{       
  vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
  points->InsertNextPoint(0, 0, 0);
  points->InsertNextPoint(1, 0, 0);
  points->InsertNextPoint(2, 0, 0);

  vtkSmartPointer<vtkPolyData> input = vtkSmartPointer<vtkPolyData>::New();
  input->SetPoints(points);

  vtkSmartPointer<vtkVertexGlyphFilter> glyphFilter =
vtkSmartPointer<vtkVertexGlyphFilter>::New();

  glyphFilter->SetInputData(input);
  glyphFilter->Update();

  // Create a mapper and actor
  vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(glyphFilter->GetOutputPort());

  vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
  actor->SetMapper(mapper);
  actor->GetProperty()->SetPointSize(10);

  // Visualize
  vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();

  renderer->AddActor(actor);

  m_vtkWindow->AddRenderer(renderer);
  m_vtkWindow->Render();

  vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
m_vtkWindow->GetInteractor();

  vtkSmartPointer<InteractorStyle2> style =
vtkSmartPointer<InteractorStyle2>::New();
  renderWindowInteractor->SetInteractorStyle(style);

  style->Data = input;
}



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


More information about the vtkusers mailing list