Maximilian,

That's not a reasonable expectation. Mesh **isa** vtkPolyData, and not
vice-versa. Look at docs for dynamic_cast in C++. In spirit, SafeDownCast
is essentially the same thing.

Utkarsh

On Wed, Aug 9, 2017 at 2:12 PM, Maximilian Weiherer <
weiherer.maximil...@gmx.de> wrote:

> Hi Utkarsh,
>
>
>
> thanks for your reply. I created the custom mesh class in order to add
> some new functionality (e.g. a method to check whether a mesh intersects
> another mesh). The vtkPolyData object which should be casted is the output
> of a vtkSTLReader, i.e.
>
> Mesh* mesh = Mesh::SafeDownCast(reader->GetOutput()); // mesh always
> equals NULL
>
> Best regards
>
> Maximilian
>
>
>
> *Von:* Utkarsh Ayachit [mailto:utkarsh.ayac...@kitware.com]
> *Gesendet:* Mittwoch, 9. August 2017 17:53
> *An:* Maximilian Weiherer <weiherer.maximil...@gmx.de>
> *Cc:* vtk <vtkus...@vtk.org>
> *Betreff:* Re: [vtkusers] SafeDownCast does not work properly
>
>
>
> 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.maximil...@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
>
>
>
> [image: Das Bild wurde vom Absender entfernt.]
> <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>
>
>
> _______________________________________________
> 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
>
>
>
_______________________________________________
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 ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to