[Paraview] [vtkusers] SafeDownCast does not work properly

Utkarsh Ayachit utkarsh.ayachit at kitware.com
Wed Aug 9 14:32:46 EDT 2017


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.maximilian at 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.ayachit at kitware.com]
> *Gesendet:* Mittwoch, 9. August 2017 17:53
> *An:* Maximilian Weiherer <weiherer.maximilian at gmx.de>
> *Cc:* vtk <vtkusers at 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.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
>
>
>
> [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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170809/dcf11835/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 350 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/paraview/attachments/20170809/dcf11835/attachment.jpg>


More information about the ParaView mailing list