3D Piping

Jun 24, 2012 at 4:07 PM

Awesome job on Helix3D.

I'm searching for guidance or best practices on a project I'm working on.

In my application, I have an ObservableCollection of pipe segments, which describe length, diameter, inclination from vertical and azimuth from north. I need to iterate thru this collection (note: collection will number in the hundreds and sometimes thousands of segments), and build the pipe system, one segment at a time. Each 3D pipe segment will eventually be re-colored according to some calculation and hopefully each pipe segment object will contain the numerical results of the calculations performed on each segment. I will need to click or hover over the segment in the 3D view, and display the numerical results per segment in a wpf control.

Anyone have thoughts or suggestions?

Thanks in advance.

Jun 25, 2012 at 6:33 AM

You should add the pipes to the 3D model yourself (I don't think ItemsControl will work in a Viewport3D), and modify the 3D model when the observable collection changes.

I would suggest the following

  • Use a ModelUIElement3D for each pipe to make the segments clickable.
  • Use the HelixToolkit's MeshBuilder to create the pipe geometry (as in PipeVisual3D).
  • Create a Transform3D to set the position and orientation (you can also set the start and endpoints, but if you use a transform you can easily change position/orientation later).
  • Create a Material to define the color (see HelixToolkit's MaterialHelper.CreateMaterial)

If performance is not good enough, you should combine all pipes into a common geometry and use texture coordinates and a gradient brush material to set the colors.


Use of the MeshBuilder:

var builder = new MeshBuilder(false,false);
builder.AddPipe(this.Point1, this.Point2, this.InnerDiameter, this.Diameter, this.ThetaDiv);
return builder.ToMesh();

(returns a MeshGeometry3D)

Jun 25, 2012 at 9:22 AM



I am also trying to add 1000+ Visual3D objects to a viewport and would be interested in the most efficient way to do this.


I am currently binding to an observable collection as shown in the MVVM demo and just adding each Visual3D individually in a loop. This is firing a collection changed event for each call to the Add method. Is there a better way accomplish a bulk add?



Jun 26, 2012 at 3:54 AM

See http://msdn.microsoft.com/en-us/library/bb613553.aspx

Combine objects that can share the same material.

Yes, you should avoid the collection change event when initializing your collection - don't bind it to the visual tree before it has been initialized.

Jun 26, 2012 at 6:34 PM

Thanks for the reply. I have another question, though.

As mentioned in my initial post, I need the ability to hover over or clicka pipe segment in order to obtain properties of that segment, ie: length, temperature, pressure, etc. I also need to draw a sem-transparent 3D element (basically another pipe segment) around the segment, thus creating a pipe within a pipe. However, I need to "click" the inner pipe to obtain it's properties. The outer pipe will no doubt hinder hit-test on the inner pipe, correct? So, I'm wondering how to select the inner pipe when clicking. Maybe 1) propogate the inner pipes properties to the outer pipe or 2) allow a pipe segment to have children pipe segments.

Any suggestions?

BTW, I am just barely getting started with Helix 3D.


Jun 27, 2012 at 12:42 PM

See http://msdn.microsoft.com/en-us/library/ms608753.aspx and http://msdn.microsoft.com/en-us/library/system.windows.media.media3d.rayhittestresult.aspx

These will give you all hits in the model!