-1

I am working on program which builds molecule from scratch. My intention is to use vtkMolecule for it. However, while it is easy to add Atom to molecule by AppendAtom method, there seems to be no function for removal.

Here is my code:

int main(int, char *[]) {
  vtkSmartPointer<vtkMolecule> molecule =
    vtkSmartPointer<vtkMolecule>::New();   
  molecule->AppendAtom(12, 0.0, 0.0, 0.0);
  molecule->AppendAtom(12, 1.0, 1.0, 1.0);
  molecule->AppendAtom(12, 2.0, 2.0, 2.0);

  molecule->AppendBond(molecule->GetAtom(0), molecule->GetAtom(1), 1);
  molecule->AppendBond(molecule->GetAtom(1), molecule->GetAtom(2), 1);

  //hypothetical code, I want something like this - remove atom by id:
  molecule->RemoveAtom(2)

  vtkSmartPointer<vtkMoleculeMapper> moleculeMapper =
    vtkSmartPointer<vtkMoleculeMapper>::New();
  moleculeMapper->SetInputData(molecule);
  //...rendering etc.
}

vtkMolecule Class Reference

I was thinking of some vtkGraph method like vtkGraph::RemoveVertexInternal, but it is (probably for some reason) protected and therefore not usable in child of child class.

My question is:

Is there a simple way to delete atom from molecule other than creating child class of vtkMolecule with specialized method?

Thank you in advance.

john.d
  • 31
  • 5

1 Answers1

0

You're right, there is no simple method to do that.

Protected means that it is usable from a child class but not externally that's why you need to create a new public method, like RemoveAtom(id), that call RemoveVertexInternal(id). You should either subclass vtkMolecule or just patch it.

Is suggest you to patch and to contribute upstream: https://gitlab.kitware.com/vtk/vtk/merge_requests

Nico Vuaille
  • 2,310
  • 1
  • 6
  • 14