# vtkPlanes is empty when using GetPlanes

**URL:** https://discourse.vtk.org/t/vtkplanes-is-empty-when-using-getplanes/6662
**Category:** Support
**Created:** [September 20, 2021, 1:26pm UTC](https://discourse.vtk.org/t/vtkplanes-is-empty-when-using-getplanes/6662 "2021-09-20T13:26:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![AhmedAlshawi](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@AhmedAlshawi](https://discourse.vtk.org/u/AhmedAlshawi)
#### Post date: [September 20, 2021, 1:26pm UTC](https://discourse.vtk.org/t/vtkplanes-is-empty-when-using-getplanes/6662/1 "2021-09-20T13:26:01Z")

</div>

Hi. I am trying to use vtkBoxWidget2 to clip an unstructured grid. Within my vtkBoxCallback, I initiate the `planes` variable and then grab the planes from the vtkBoxRepresentation.

However, the `planes` variable is always empty, and I have no idea why. So when I then do `m_actor->GetMapper()->SetClippingPlanes(planes)`, my actor just disappears because the `planes` variable is just empty with just zeros.

When debugging, I can clearly see that the vtkBoxRepresentation has the right planes in there.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/5/5883790be45e9c0e29d66ad192f00e5515561c72.png)

But when grabbing them, the `planes` variable is empty.

 ![image](https://discourse.vtk.org/uploads/default/original/2X/b/bda508f930aa22835d3d683654b603ac2bf9e3d5.png)

Does anyone know why this is?

Thanks a lot!

---

<div class="post-metadata">

### Author: ![AhmedAlshawi](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@AhmedAlshawi](https://discourse.vtk.org/u/AhmedAlshawi)
#### Post date: [September 20, 2021, 3:29pm UTC](https://discourse.vtk.org/t/vtkplanes-is-empty-when-using-getplanes/6662/2 "2021-09-20T15:29:38Z")

</div>

Incase this helps others in the future, I had not set `SetInsideOut` to true (1). Setting this prior to getting the planes works perfectly.

Here is the code:

```auto
namespace {

    class vtkBoxCallback : public vtkCommand
    {
        public:
            static vtkBoxCallback* New()
            {
                return new vtkBoxCallback;
            }

            vtkSmartPointer<vtkActor> m_actor;

            void SetActor(vtkSmartPointer<vtkActor> actor)
            {
                m_actor = actor;
            }

            virtual void Execute(vtkObject* caller, unsigned long, void*)
            {
                vtkSmartPointer<vtkBoxWidget2> boxWidget =
                      dynamic_cast<vtkBoxWidget2*>(caller);

                vtkNew<vtkPlanes> planes;

                vtkSmartPointer<vtkBoxRepresentation> boxRep =
                        dynamic_cast<vtkBoxRepresentation*>(boxWidget->GetRepresentation());

                boxRep->SetInsideOut(1);

                boxRep->GetPlanes(planes);

                this->m_actor->GetMapper()->SetClippingPlanes(planes);
            }

            vtkBoxCallback()
            {
                //none
            }

    }; // vtkBoxCallback

} // namespace

```

---

<div class="post-metadata">

### Author: ![Jacky\_Joy](https://discourse.vtk.org/user_avatar/discourse.vtk.org/jacky_joy/32/4801_2.png) [@Jacky\_Joy](https://discourse.vtk.org/u/Jacky_Joy)
#### Post date: [March 18, 2022, 1:42pm UTC](https://discourse.vtk.org/t/vtkplanes-is-empty-when-using-getplanes/6662/4 "2022-03-18T13:42:05Z")

</div>

> [@AhmedAlshawi](#):
>
> Incase this helps others in the future, I had not set `SetInsideOut` to true (1). Setting this prior to getting the planes works perfectly.
> 
> Here is the code:
> 
> ```auto
> namespace {
> 
> class vtkBoxCallback : public vtkCommand
> {
> public:
> static vtkBoxCallback* New()
> {
> return new vtkBoxCallback;
> }
> 
> vtkSmartPointer<vtkActor> m_actor;
> 
> void SetActor(vtkSmartPointer<vtkActor> actor)
> {
> m_actor = actor;
> }
> 
> virtual void Execute(vtkObject* caller, unsigned long, void*)
> {
> vtkSmartPointer<vtkBoxWidget2> boxWidget =
> dynamic_cast<vtkBoxWidget2*>(caller);
> 
> vtkNew<vtkPlanes> planes;
> 
> vtkSmartPointer<vtkBoxRepresentation> boxRep =
> dynamic_cast<vtkBoxRepresentation*>(boxWidget->GetRepresentation());
> 
> boxRep->SetInsideOut(1);
> 
> boxRep->GetPlanes(planes);
> 
> this->m_actor->GetMapper()->SetClippingPlanes(planes);
> }
> 
> vtkBoxCallback()
> {
> //none
> }
> 
> }; // vtkBoxCallback
> https://creditcardsupportx.com/baby-r-us-credit-card
> https://creditcardsupportx.com/lord-and-taylor-credit-card
> https://creditcardsupportx.com/pep-boys-credit-card
> } // namespace
> 
> ```

thanks my issue has been fixed.
