[Paraview-developers] addrofthis to give Python the address of a vtkObject

Gerstenberger, Axel Axel.Gerstenberger at Rolls-Royce.com
Thu Aug 18 10:29:44 EDT 2016


Dear developers,

When looking through the source code of Paraview (from which we learn all the time for our own code), I found that to get the address of a vtkObject for Python interaction you use code like this:

  // Set self to point to this
  char addrofthis[1024];
  sprintf(addrofthis, "%p", somepointer);
  char *aplus = addrofthis;
  if ((addrofthis[0] == '0') && ((addrofthis[1] == 'x') || addrofthis[1] == 'X'))
    {
    aplus += 2; //skip over "0x"
    }
  return std::string(aplus);

However, sometimes you use aplus for referencing the address (e.g. in vtkPythonAnnotationFilter), but sometimes you use directly addrofthis, but still execute the part to compute aplus. This happens for example in vtkPythonView.cxx, line 142 ff.

Since the first version is used a lot, is the second version in vtkPythonView.cxx a bug or does it serve a different purpose?

Also, this code snippet appears to be copied to quite a few places, but it is crucial for vtk Python interaction. Maybe a little static method in VTK could be created for that?

Thanks,
Axel


--
Dr. Axel Gerstenberger
Aero Methods and Design Systems Engineering (ET-DSE)

Rolls-Royce Deutschland Ltd & Co KG
Eschenweg 11, Dahlewitz, 15827 Blankenfelde-Mahlow, Germany

Tel: +49(0)33708-6-3101
E-Mail: axel.gerstenberger at rolls-royce.com

Absence pending: 14.06.2016

Rolls-Royce Deutschland Ltd & Co KG Sitz/Registered Office: Blankenfelde-Mahlow, Deutschland, Registergericht/Court of Register: Amtsgericht Potsdam, HRA 2731 P, Persönlich haftende Gesellschafterin/General Partner: Rolls-Royce General Partner Limited, Sitz/Registered Office: Derby, United Kingdom, Register: Registry of Companies Wales and England, 4066556, Directors/Geschäftsführer: Paul O’Neil, Alastair McIntosh, Nicole Fehr, Dr. Holger Cartsburg Confidentiality Notice: This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person.
The data contained in, or attached to, this e-mail, may contain confidential information. If you have received it in error you should notify the sender immediately by reply e-mail, delete the message from your system and contact +44 (0) 3301235850 (Security Operations Centre) if you need assistance. Please do not copy it for any purpose, or disclose its contents to any other person.

An e-mail response to this address may be subject to interception or monitoring for operational reasons or for lawful business practices.

(c) 2016 Rolls-Royce plc

Registered office: 62 Buckingham Gate, London SW1E 6AT Company number: 1003142. Registered in England.


More information about the Paraview-developers mailing list