[vtkusers] SafeDownCast does not work properly

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Wed Aug 9 11:53:26 EDT 2017


Maximilian,

I am confused why any arbitrary vtkPolyData object would be castable to
"Mesh". It will only return non-null, if it's is indeed created as a Mesh.
Is it? Where's the "<vtkPolyData object>" coming from?

Utkarsh

On Wed, Aug 9, 2017 at 11:50 AM, Maximilian Weiherer <
weiherer.maximilian at gmx.de> wrote:

> Hi all,
>
>
>
> I defined my own mesh class (named *Mesh*) by inheriting from
> vtkPolyData. Now I am struggling with the SafeDownCast method in order to
> cast a vtkPolyData object into a *Mesh* object. Whenever I am applying a
> SafeDownCast to a vtkPolyData object, NULL is returned.
>
>
>
> The *Mesh* class looks as follows:
>
>
>
> class Mesh : public vtkPolyData
>
> {
>
>   public:
>
>     static Mesh* New();
>
>     vtkTypeMacro(Mesh, vtkPolyData);
>
>     void PrintSelf(ostream& os, vtkIndent indent);
>
>
>
>   protected:
>
>     Mesh();
>
>     ~Mesh();
>
>   private:
>
>     Mesh(const Mesh&); // Not implemented.
>
>     void operator=(const Mesh&); // Not implemented.
>
> };
>
>
>
> …and this is the cast that does not work properly:
>
>
>
> Mesh* mesh = Mesh::SafeDownCast(<vtkPolyData object>); // mesh always
> equals NULL
>
>
>
> Any help would be appreciated. Thanks!
>
>
>
> Best regards
>
> Maximilian
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient> Virenfrei.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
> <#m_3987841914009693506_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20170809/d6123080/attachment.html>


More information about the vtkusers mailing list