Constructive solid geometry

Revision as of 15:02, 11 April 2025 by imported>MrSwedishMeatballs (→‎Workings)
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Template:Short description

File:Csg tree.png
CSG objects can be represented by binary trees, where leaves represent primitives, and nodes represent operations. In this figure, the nodes are labeled Template:Math for intersection, Template:Math for union, and Template:Math for difference.

Constructive solid geometry (CSG; formerly called computational binary solid geometry) is a technique used in solid modeling. Constructive solid geometry allows a modeler to create a complex surface or object by using Boolean operators to combine simpler objects,<ref name="foley">Template:Citation,</ref> potentially generating visually complex objects by combining a few primitive ones.<ref>Template:Cite journal</ref><ref name="bb">Template:Citation.</ref>

In 3D computer graphics and CAD, CSG is often used in procedural modeling. CSG can also be performed on polygonal meshes, and may or may not be procedural and/or parametric.

Contrast CSG with polygon mesh modeling and box modeling.

WorkingsEdit

The simplest solid objects used for the representation are called geometric primitives. Typically they are the objects of simple shape: cuboids, cylinders, prisms, pyramids, spheres, cones.<ref name="foley"/> The set of allowable primitives is limited by each software package. Some software packages allow CSG on curved objects while other packages do not.

An object is constructed from primitives by means of allowable operations, which are typically Boolean operations on sets: union (OR), intersection (AND) and difference (NOT), as well as geometric transformations of those sets.<ref name="foley"/>

A primitive can typically be described by a procedure which accepts some number of parameters; for example, a sphere may be described by the coordinates of its center point, along with a radius value. These primitives can be combined into compound objects using operations like these:

Combining these elementary operations, it is possible to build up objects with high complexity starting from simple ones.

Ray tracingEdit

Rendering of constructive solid geometry is particularly simple when ray tracing. Ray tracers intersect a ray with both primitives that are being operated on, apply the operator to the intersection intervals along the 1D ray, and then take the point closest to the camera along the ray as being the result.

ApplicationsEdit

File:Boolean raytrace.svg
CSG operations being applied in the context of rays in a ray tracer

Constructive solid geometry has a number of practical uses. It is used in cases where simple geometric objects are desired,Template:Cn or where mathematical accuracy is important.<ref>Template:Harvtxt, p. 559.</ref> Nearly all engineering CAD packages use CSG (where it may be useful for representing tool cuts, and features where parts must fit together).

The Quake engine and Unreal Engine both use this system, as does Hammer (the native Source engine level editor), and Torque Game Engine/Torque Game Engine Advanced. CSG is popular because a modeler can use a set of relatively simple objects to create very complicated geometry.<ref name="bb"/> When CSG is procedural or parametric, the user can revise their complex geometry by changing the position of objects or by changing the Boolean operation used to combine those objects.

One of the advantages of CSG is that it can easily assure that objects are "solid" or water-tight if all of the primitive shapes are water-tight.<ref>Template:Citation.</ref> This can be important for some manufacturing or engineering computation applications. By comparison, when creating geometry based upon boundary representations, additional topological data is required, or consistency checks must be performed to assure that the given boundary description specifies a valid solid object.<ref name="foley"/>

A convenient property of CSG shapes is that it is easy to classify arbitrary points as being either inside or outside the shape created by CSG. The point is simply classified against all the underlying primitives and the resulting boolean expression is evaluated.<ref name="rt">Template:Citation.</ref> This is a desirable quality for some applications such as ray tracing.<ref name="rt"/>

Conversion from meshes to CSGEdit

With CSG models being parameterized by construction, they are often favorable over usual meshes when it comes to applications where the goal is to fabricate customized models. For such applications it can be interesting to convert already existing meshes to CSG trees. This problem of automatically converting meshes to CSG trees is called inverse CSG.

A resulting CSG tree is required to occupy the same volume in 3D space as the input mesh while having a minimal number of nodes. Simple solutions are preferred to ensure that the resulting model is easy to edit. Solving this problem is a challenge because of the large search space that has to be explored. It combines continuous parameters such as dimension and size of the primitive shapes, and discrete parameters such as the Boolean operators used to build the final CSG tree.

Deductive methods solve this problem by building a set of half-spaces that describe the interior of the geometry. These half-spaces are used to describe primitives that can be combined to get the final model.<ref>Template:Cite journal</ref>

Another approach decouples the detection of primitive shapes and the computation of the CSG tree that defines the final model. This approach exploits the ability of modern program synthesis tools to find a CSG tree with minimal complexity.<ref>Template:Cite journal</ref>

There are also approaches that use genetic algorithms to iteratively optimize an initial shape towards the shape of the desired mesh.<ref>Template:Cite journal</ref>

Notable applications with CSG supportEdit

Generic modelling languages and softwareEdit

Ray tracing and particle transportEdit

Computer-aided designEdit

Template:See also

GamingEdit

OthersEdit

  • 3Delight
  • Aqsis (as of version 0.6.0)<ref>{{#invoke:citation/CS1|citation

|CitationClass=web }}</ref>

ReferencesEdit

Template:Reflist