# IsA() errors

**URL:** https://discourse.vtk.org/t/isa-errors/1916
**Category:** Development
**Created:** [October 12, 2019, 1:29am UTC](https://discourse.vtk.org/t/isa-errors/1916 "2019-10-12T01:29:43Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [October 12, 2019, 1:29am UTC](https://discourse.vtk.org/t/isa-errors/1916/1 "2019-10-12T01:29:43Z")

</div>

There a few places in the VTK code where calling IsA() is flawed.

Classes **vtkOpenGL2ContextDevice2D, vtkSimpleTransform, vtkXXX** do not exist, so the code should either be deleted or the class name changed.

Classes **vtkLabeledDataMapper, vtkMPIController, vtkImageStack** are descendant classes referenced by an ancestor module.

```
 VTK-8\Charts\Core\Testing\Cxx\TestScalarsToColors.cxx(81): if (view->GetContext()->GetDevice()->IsA("vtkOpenGL2ContextDevice2D"))
 VTK-8\Common\Transforms\vtkTransform.cxx(176): !this->Concatenation->GetTransform(i)->IsA("vtkSimpleTransform");
 VTK-8\Filters\Modeling\Testing\Cxx\UnitTestCollisionDetectionFilter.cxx(144): if (collision->IsA("vtkXXX"))
 VTK-8\Rendering\Core\vtkActor2D.cxx(103): this->Mapper->IsA("vtkLabeledDataMapper"))))
 VTK-8\Rendering\Core\vtkImageMapper3D.cxx(250): if (a->IsA("vtkAssembly") || a->IsA("vtkImageStack"))
 VTK-8\Rendering\Parallel\vtkSynchronizedRenderers.cxx(384): if (this->ParallelController->IsA("vtkMPIController"))
```

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [October 12, 2019, 4:26am UTC](https://discourse.vtk.org/t/isa-errors/1916/2 "2019-10-12T04:26:09Z")

</div>

Thanks for reporting this. VTK developers might respond to this here but if not then [submit a merge request](https://gitlab.kitware.com/vtk/vtk/merge_requests) with a proposed fix.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [October 12, 2019, 4:29am UTC](https://discourse.vtk.org/t/isa-errors/1916/3 "2019-10-12T04:29:53Z")

</div>

I’m not sure what the fix should be for a base module referencing a descendant class. Either refactoring of the modules is required or those classes should not be referenced in those places.

It all compiles because the test is done with a class name which effectively hides the dependency.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 12, 2019, 3:14pm UTC](https://discourse.vtk.org/t/isa-errors/1916/4 "2019-10-12T15:14:49Z")

</div>

The non-existent classes should certainly be fixed. The dependent module thing should probably be fixed by adding a virtual method to the base class named after what is being asked (e.g., `vtkProcessController::SupportsAllReduce` should be added and `vtkActor::GetCapturingGL2PSSpecialProps` already exists) instead of assuming functionality based on class names.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [October 13, 2019, 12:49am UTC](https://discourse.vtk.org/t/isa-errors/1916/5 "2019-10-13T00:49:37Z")

</div>

AllReduce() is implemented in vtkMultiProcessController, so I’m not sure why it isn’t used for both vtkMPIController and vtkSocketController.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [October 13, 2019, 1:52am UTC](https://discourse.vtk.org/t/isa-errors/1916/6 "2019-10-13T01:52:33Z")

</div>

The comments in that code state it doesn’t work for some reason. You’ll have to track down authors of the code to figure out the story.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [October 13, 2019, 3:18am UTC](https://discourse.vtk.org/t/isa-errors/1916/7 "2019-10-13T03:18:12Z")

</div>

The original author was @utkarshayachit in commit  
SHA-1: 59b4bd57cdbff9fad35c52572ff25092c672fe46

- Added API to compute visible prop bounds collectively.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [October 14, 2019, 6:21pm UTC](https://discourse.vtk.org/t/isa-errors/1916/8 "2019-10-14T18:21:01Z")

</div>

I’m familiar enough with vtkImageMapper3D and vtkTransform to put together an MR, maybe TestScalarsToColors.cxx as well.

The classes that IsA refers to may have existed in the past, but were removed/renamed during refactoring. The SafeDownCast() is better in this regard, because it won’t compile if the class is missing.

---

<div class="post-metadata">

### Author: ![toddy](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/t/edb3f5/32.png) [@toddy](https://discourse.vtk.org/u/toddy)
#### Post date: [October 14, 2019, 8:55pm UTC](https://discourse.vtk.org/t/isa-errors/1916/9 "2019-10-14T20:55:33Z")

</div>

I understood that **IsA()** is used here because **Safedowncast()** might break third party libraries that compare by class name rather than class type.

---

<div class="post-metadata">

### Author: ![utkarshayachit](https://discourse.vtk.org/user_avatar/discourse.vtk.org/utkarshayachit/32/379_2.png) [@utkarshayachit](https://discourse.vtk.org/u/utkarshayachit)
#### Post date: [October 15, 2019, 6:59pm UTC](https://discourse.vtk.org/t/isa-errors/1916/10 "2019-10-15T18:59:02Z")

</div>

> [@toddy](#):
>
> AllReduce() is implemented in vtkMultiProcessController, so I’m not sure why it isn’t used for both vtkMPIController and vtkSocketController.

`vtkMultiProcessController::AllReduce` calls `vtkCommunicator` APIs and `vtkSocketCommunicator` (a `vtkCommunicator` subclass) does not implement the collectives. The correct fix would be fix `vtkSocketCommunicator` to implement all the collectives and one would not need the check in `vtkSynchronizedRenderers` anymore.
