Efficient Representation of Many Primitives

Primitives which can take multiple elements.

Some primitives have multi-element forms that can be processed and rendered more quickly by the Wolfram System front end than the equivalent individual primitives. For large numbers of primitives, using the multi-element forms can also significantly reduce the sizes of notebook files. Notebooks that use multi-element forms can be less than half the size of those that do not, and render up to ten times faster.

Here is a multipoint random distribution:

Graphics[Point[Table[RandomReal[NormalDistribution[0,1],2],{10000}]]]

Primitive for sharing coordinate data among primitives.

When many primitives share the same coordinate data, as in meshes and graphs, further efficiency can be gained by using (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]) to factor out the coordinate data. The output of the Wolfram Language's surface- and graph-plotting functions typically use this representation.

Here is a structure of points and lines that share coordinates:

Graphics[GraphicsComplex[{{0,0},{0,1},{1,1},{1,0},{.5,.5}}, {Line[{{1,2,3},{5,4}}],Red,PointSize[.05],Point[{1,2,3,4,5}]}]]

In addition to being efficient, (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]) is useful interactively. Primitives that share coordinates stay connected when one of them is dragged.

Because the output of (RefLink[GraphPlot, paclet:ref/GraphPlot]) is a (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]), the graph stays connected when any part of it is dragged:

GraphPlot[Table[i->Mod[(i^2)-199,10],{i,1,22}]]

Any primitive may be used within a (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]), and (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]) can be used in both 2D and 3D graphics. Within (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]), coordinate positions in primitives are replaced by indices into the coordinate data in the (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]).

This (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]) combines several types of primitives:

Graphics3D[GraphicsComplex[Table[{i,i,i},{i,1,5}], {
Sphere[4,1.5],
Text[Style[∫f[x]\[DifferentialD]x,36],4],
Point[Range[5]]
}]]

(RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]) is especially useful for representing meshes of polygons. By using (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]), numerical errors that could cause gaps between adjacent polygons are avoided.

The output of (RefLink[Plot3D, paclet:ref/Plot3D]) is a (RefLink[GraphicsComplex, paclet:ref/GraphicsComplex]):

Plot3D[Sin[x] y^2,{x,0,22},{y,0,4}]