Friday, November 21, 2014

Helix 3D Toolkit - Well Viewer Part 2

In September I wrote a post about creating a well profile viewer using Helix Toolkit.  At work the requirements were extended to include showing a tube representing the work-string inside the well-bore.  Additionally, the ability to show a color gradient denoting a set of values was also needed. I've re-factored the original code in my first post and update the Gist.

Our torque and drag model generates a list of calculated values at a regular interval of depth. These values are then mapped to the work-string inside the well-bore.  There are two interesting issues here.

The work-string is confined by the well profile in real-life, and similarly when modeling this issue our work-string path will follow the path of our well.  To code the new requirements, the base class created in the first post will be extended, and the reliance on the well profile path, will introduce temporal coupling in code.

The other interesting thing to note is that we don't have a one to one relationship with values coming from the torque and drag model being mapped to 3D points.  It might take 100 or 200 points to represent the 3D center-line of the well-bore, while the torque and drag model can return several thousand data points.   To get around this issue, the data needs to be interpolated by depth at each 3D point along the profile.

Overview of Mapping Values as Texture Coordinates in Helix Toolkit
Helix toolkit uses the concept of texture mapping to apply a skin over the 3D objects.  The concepts are explained in detail on Wikipedia.  For what we are doing the concepts can be simplified to this, the texture coordinate will determine which value from a linear brush will be applied to the geometry.  Values on a linear gradient brush range from 0 to 1, so the values being mapped will also need to be normalized into this range.    Once we have a list of texture coordinates, one for each 3D point, we can simply bind to them from our pipe in Xaml.


Here is the code.
It was requested that I provide a working example, I've placed somewhat simplified project in OneDrive that will help you get up and running.

18 comments:

  1. Really cool Don,
    Im looking to build something similar for surveys of cross country pipelines and apply some distance transform (shortest route) solving. Hope you keep us updated on this , ill be looking forward to updates :)

    ReplyDelete
    Replies
    1. Helix Toolkit has been really fun to work with, however, I'll be changing jobs soon and I'm unsure if I'll find opportunity to use WPF with Helix Toolkit at my next workplace. Perhaps I'll find a use for it in a personal project.

      Delete
  2. Don really nice example.

    I am a C++ developer & new to WPF, I am looking for similar kind of example. Can you post the complete solution for this project(All files). It will be easier for me then to compile & understand.

    ReplyDelete
    Replies
    1. Mithun, thanks for your post. This code was written while working for my previous employer, the parts that are missing are proprietary, so can not be shared. All that's missing in the above example is the logic used to build out the path that the tube follows. I've been pretty busy with work, but if you just need a compiling project that does roughly the above, I could probably put together an example for you... Let me know if that'd still be helpful?

      Delete
    2. Yeah Don, that will be very useful.
      Can you do favour for me, can you make project working by simply removing logical part of code & use hard code position array for tube . As I am new to WPF it will be tough task for me to make this sample compilable.

      Delete
    3. Mithun, I found some time to put together an example for you. Here is a link, and I'll update the post as well. http://1drv.ms/1EuBMyN

      Delete
    4. Thanks a ton Don......... :-) I will get back to you if I face any issue :)

      Delete
  3. Excellent app! One quick question - I tried to use Diameters for TUbeVisual3D instead of Diameter, but the pipe disappeared. Any pointers?

    ReplyDelete
    Replies
    1. What comes to mind immediately is that its necessary to have the same number of texture coordinates as diameters. If you have a mis-match I'm not sure anything will display.

      Delete
    2. Thanks for pointing in right direction - had to be a DoubleCollection instead of double[]. Makes sense. Awesome :)

      Delete
    3. Following along - have you had any luck with transformations. Such as pipe rotation or pipe moving up/down?

      Delete
    4. I have not done any transformations past what are automatically provided by the toolkit within the 3D viewport. Are you wanting to animate the pipe running into casing or something? That should be fairly simply done with standard animation techniques. An example of animation can be found in the Helix 3D examples project.

      Delete
    5. Yes - pipe tripping in and out. Can you point me to what you refer to as "standard animation techniques"? You mean standard WPF techniques or what are exposed by the 3D viewport?
      Thanks,

      Delete
    6. Sorry keeping busy so can't provide much more detail myself, but here is an example.
      https://github.com/helix-toolkit/helix-toolkit/blob/master/Source/Examples/WPF/ExampleBrowser/Examples/Wind/WindTurbineVisual3D.cs
      Basically, do something like this, calculate the pipe rendering in a loop. Say starting at surface draw a 100 foot long pipe, render it to the screen, wait a bit and draw a 200 foot long pipe and render it to the screen. Do that 24 times a second and you have a smooth animation.

      Delete
  4. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. The toolkit comes with a project full of examples. http://helix-toolkit.org/ You should be able to pull the source off of GitHub, build it and run the WPF examples project. It's laid out in a nice project explorer.

      Delete
  5. The onedrive link doesn't work anymore. Could you update the link, or sent me the zip file?
    Thanks.

    ReplyDelete
    Replies
    1. Hi David, I've updated the link, thanks!

      Delete