Skip to content

Fix tvtk attribute with undefined _void value#362

Closed
kitchoi wants to merge 5 commits into
masterfrom
fix-vtk-position-undefined-initial-value
Closed

Fix tvtk attribute with undefined _void value#362
kitchoi wants to merge 5 commits into
masterfrom
fix-vtk-position-undefined-initial-value

Conversation

@kitchoi
Copy link
Copy Markdown
Contributor

@kitchoi kitchoi commented Apr 26, 2016

Fix #357

I also realise that for VTK 6.x and VTK 7, a number of VTK classes do not initialise *Position attributes properly. This would fix for them too.

Will lead to conflict with #358 upon merge, unfortunately

@kitchoi
Copy link
Copy Markdown
Contributor Author

kitchoi commented Apr 26, 2016

For VTK 6.3 and VTK 7.0, these are the VTK classes with ill-defined *Position attributes on initialisation.

vtkImageViewer2.GetPosition gives an initial value of _0000000003adb658_p_void
vtkWindow.GetPosition gives an initial value of _0000000003b30418_p_void
vtkAxesTransformRepresentation.GetOriginWorldPosition gives an initial value of _0000000003ae3dc0_p_void
vtkDistanceRepresentation.GetPoint1WorldPosition gives an initial value of _00007fd42638b3d0_p_void
vtkDistanceRepresentation.GetPoint2WorldPosition gives an initial value of _00007fd42638b3b0_p_void
vtkConstrainedPointHandleRepresentation.GetPosition gives an initial value of _0000000003d63c90_p_void
vtkDistanceRepresentation2D.GetPoint1WorldPosition gives an initial value of _00007fd42638b3d0_p_void
vtkDistanceRepresentation2D.GetPoint2WorldPosition gives an initial value of _00007fd42638b3b0_p_void
vtkDistanceRepresentation3D.GetPoint1WorldPosition gives an initial value of _00007fd42638b420_p_void
vtkDistanceRepresentation3D.GetPoint2WorldPosition gives an initial value of _00007fd42638b400_p_void
vtkXOpenGLRenderWindow.GetPosition gives an initial value of _0000000003ef4788_p_void

With this PR, tvtk.AxesTransformRepresentation has the following traits (for example):

    origin_world_position = traits.Either(
        traits.Array(shape=(3,), value=(0.0, 0.0, 0.0), dtype=float, enter_set=True, 
                     auto_set=False, cols=3),
        traits.String,
        help=\
        """                                                                                                                                                                                 
        Methods to Set/Get the coordinates of the two points defining                                                                                                                       
        this representation. Note that methods are available for both                                                                                                                       
        display and world coordinates.                                                                                                                                                      
        """
    )

@kitchoi
Copy link
Copy Markdown
Contributor Author

kitchoi commented Apr 26, 2016

The last commit makes this PR even more general than it started with.
Now it patches all default values that are "*****_void".
After this PR, the only ones that cannot be patched are the following (with VTK 6.3):

tvtk/tvtk_classes$ grep -R '_void"' .
../amr_information.py:    origin = traits.String(r"_0000000003560a98_p_void", enter_set=True, auto_set=False, help=\
./graph_mapper.py:    icon_size = traits.String(r"_00000000035ea2b0_p_void", enter_set=True, auto_set=False, help=\
./image_convolve.py:    kernel7x7x7 = traits.String(r"_0000000003ca50f8_p_void", enter_set=True, auto_set=False, help=\
./image_convolve.py:    kernel3x3 = traits.String(r"_0000000003ca50f8_p_void", enter_set=True, auto_set=False, help=\
./image_convolve.py:    kernel3x3x3 = traits.String(r"_0000000003ca50f8_p_void", enter_set=True, auto_set=False, help=\
./image_convolve.py:    kernel5x5x5 = traits.String(r"_0000000003ca50f8_p_void", enter_set=True, auto_set=False, help=\
./image_convolve.py:    kernel5x5 = traits.String(r"_0000000003ca50f8_p_void", enter_set=True, auto_set=False, help=\
./image_convolve.py:    kernel7x7 = traits.String(r"_0000000003ca50f8_p_void", enter_set=True, auto_set=False, help=\

Previously there were loads more.

@kitchoi kitchoi changed the title Fix tvtk Position attribute Fix tvtk attribute with undefined _void value Apr 26, 2016
Comment thread tvtk/wrapper_gen.py
PY_VER = sys.version_info[0]


def patch_default(parser, vtk_set_meth, default):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind my previous self-review.

@codecov-io
Copy link
Copy Markdown

Current coverage is 45.37%

Merging #362 into master will decrease coverage by -0.00%

@@             master       #362   diff @@
==========================================
  Files           254        254          
  Lines         22891      22916    +25   
  Methods           0          0          
  Messages          0          0          
  Branches       3028       3036     +8   
==========================================
+ Hits          10395      10397     +2   
- Misses        11762      11785    +23   
  Partials        734        734          

Sunburst

Powered by Codecov. Last updated by 2995cd9

@kitchoi
Copy link
Copy Markdown
Contributor Author

kitchoi commented Apr 27, 2016

In response to #360, I think of an alternative implementation that could fix (/work around) both problems.

@stefanoborini
Copy link
Copy Markdown
Contributor

I think this is a really dangerous workaround... if VTK is providing an uninitialised buffer we should know if it's uninitialized from an authoritative source. If there isn't, then we should throw an exception until it's certain it has been initialized.

@kitchoi
Copy link
Copy Markdown
Contributor Author

kitchoi commented Apr 28, 2016

@stefanoborini Don't worry, I am implementing something with traits.Undefined.
For now, try the following with the master branch to see what the current behaviour is

from tvtk.api import tvtk
obj = tvtk.Brush()
obj.configure_traits()  # check the "color" trait

Since I am reimplementing the wrapper_gen.py, I will close this one for now.

@kitchoi kitchoi closed this Apr 28, 2016
@kitchoi kitchoi deleted the fix-vtk-position-undefined-initial-value branch April 29, 2016 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tvtk Window Position is of wrong type on initialisation (VTK 6.2, 6.3)

3 participants