Re: Mathematica Graphics - speed bottleneck

• To: mathgroup at smc.vnet.net
• Subject: [mg97690] Re: Mathematica Graphics - speed bottleneck
• From: Yves Klett <yves.klett at googlemail.com>
• Date: Thu, 19 Mar 2009 02:08:27 -0500 (EST)
• References: <gpqgbo\$5sm\$1@smc.vnet.net>

```Robert,

if you have lots of Point, Line, Tube or Polygon primitives, you can
really speed up the rendering by combining them together into
multi-argument primitives, like

(*slow rendering*)
{Line[{{1, 1, -1}, {2, 2, 1}}], Line[{{3, 3, -1}, {4, 4, 1}}]}

(*faster rendering*)
Line[{{{1, 1, -1}, {2, 2, 1}}, {{3, 3, -1}, {4, 4, 1}}}]

One quick hack to do this for e.g. Lines:

(*replace consecutive Line primitives by a multi-argument line*)
ToMultiPrimitives[g_] :=
g /. {a___, b : Longest[_Line ..], c___} :> {a, Line[{b}[[All, 1]]],
c}
ToMultiPrimitives[{Line[{{1, 1, -1}, {2, 2, 1}}],
Line[{{3, 3, -1}, {4, 4, 1}}]}]

{Line[{{{1, 1, -1}, {2, 2, 1}}, {{3, 3, -1}, {4, 4, 1}}}]}

If you have lots of individual coloring, then you should use
VertexColors, because these can be incorporated into the muli-argument
primitives. The example above can be modified to do such stuff. If you
know the structure of your arguments, then you can do it much more
efficiently than using ReplaceAll and Longest etc..

Regards,
Yves

robert prince-wright schrieb:
> Mathematica 7. has lured me back into using Mathematica at work and I am wondering if it really has reached a point where it can be used to deploy applications / solutions. I had some success with one small application but found the graphics became a bottleneck which slowed to a grinding halt when applied to a real problem. Key culprits were the vector field plotting functions, and Graphics3D's ability to manipulate objects comprising hundreds of tubes. It was fine for tens but not hundreds. This led me to wonder if there are alternative approaches. I recall LiveGraphics3D but it seems to have stopped at v5. Basically I want to manipulate 3D graphics through use of DynamicModule, Sliders, etc. and see the changes in realtime (as opposed to geological time!)
>
> Any thoughts?
>
>
>
>

```

• Prev by Date: Re: Filling Between Surfaces
• Next by Date: Re: Return a value from function
• Previous by thread: Mathematica Graphics - speed bottleneck
• Next by thread: Re: Mathematica Graphics - speed bottleneck