Lagrange
Loading...
Searching...
No Matches
Primitive Module

Parametric primitive shape generation. More...

Classes

struct  DiscOptions
 
struct  IcosahedronOptions
 Options for generating an icosahedron mesh. More...
 
struct  OctahedronOptions
 Options for generating an octahedron mesh. More...
 
struct  RoundedConeOptions
 Options for generating a rounded cone mesh. More...
 
struct  RoundedCubeOptions
 Options for generating a rounded cube mesh. More...
 
struct  RoundedPlaneOptions
 Options for generating a rounded plane mesh. More...
 
struct  SphereOptions
 Options for generating a sphere mesh. More...
 
struct  SubdividedSphereOptions
 
struct  SweptSurfaceOptions
 
struct  TorusOptions
 Options for generating a torus mesh. More...
 
struct  PrimitiveOptions
 Common settings shared by all primitives. More...
 
class  SweepOptions< Scalar >
 Configuration class for sweep operations on 3D geometry. More...
 

Enumerations

enum class  SemanticLabel : uint8_t {
  Side = 0 , Top = 1 , Bottom = 2 , Bevel = 3 ,
  CrossSection = 4 , Unknown = 5
}
 Semantic labels are used to classify different parts of a primitive mesh. More...
 

Functions

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_disc (DiscOptions setting)
 Generates a disc mesh with the specified settings.
 
template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_icosahedron (IcosahedronOptions settings)
 Generate an icosahedron mesh.
 
template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_octahedron (OctahedronOptions settings)
 Generate an octahedron mesh.
 
template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_rounded_cone (RoundedConeOptions setting)
 Generate a rounded cone mesh.
 
template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_rounded_cube (RoundedCubeOptions setting)
 Generate a rounded cube mesh.
 
template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_rounded_plane (RoundedPlaneOptions settings)
 Generate a rounded plane mesh.
 
template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_sphere (SphereOptions setting)
 Generate a sphere mesh based on the specified settings.
 
template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_subdivided_sphere (const SurfaceMesh< Scalar, Index > &base_shape, SubdividedSphereOptions setting)
 Generate a subdivided sphere mesh from a base shape.
 
template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_swept_surface (span< const Scalar > profile, const SweepOptions< Scalar > &sweep_setting, const SweptSurfaceOptions &options={})
 Generate a swept surface from a profile curve and a sequence of transforms.
 
template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_torus (TorusOptions setting)
 Generate a torus mesh.
 

Detailed Description

Parametric primitive shape generation.

Enumeration Type Documentation

◆ SemanticLabel

enum class SemanticLabel : uint8_t
strong

#include <lagrange/primitive/SemanticLabel.h>

Semantic labels are used to classify different parts of a primitive mesh.

Enumerator
Side 

Side of the primitive, typically the lateral surface.

Top 

Top of the primitive, typically the upper cap.

Bottom 

Bottom of the primitive, typically the lower cap.

Bevel 

Bevel of the primitive, typically the rounded edges.

CrossSection 

Cross section of the primitive, typically a slice through the middle.

Unknown 

Unknown or unclassified part of the primitive.

Function Documentation

◆ generate_disc()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_disc ( DiscOptions setting)

#include <lagrange/primitive/generate_disc.h>

Generates a disc mesh with the specified settings.

The disc will be centered at setting.center, with its normal pointing along setting.normal.

Parameters
settingThe settings for the disc mesh.
Returns
A SurfaceMesh object representing the generated disc.

◆ generate_icosahedron()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_icosahedron ( IcosahedronOptions settings)

#include <lagrange/primitive/generate_icosahedron.h>

Generate an icosahedron mesh.

Creates an icosahedron mesh with the specified radius. An icosahedron is a regular polyhedron with 20 equilateral triangular faces, 30 edges, and 12 vertices. It is one of the five Platonic solids and exhibits icosahedral symmetry (Ih).

Template Parameters
ScalarThe scalar type for vertex coordinates
IndexThe index type for face indices
Parameters
settingsConfiguration parameters for the icosahedron generation
Returns
A surface mesh representing the icosahedron
Note
The function automatically calls settings.project_to_valid_range() to ensure all parameters are within valid bounds before generation.

◆ generate_octahedron()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_octahedron ( OctahedronOptions settings)

#include <lagrange/primitive/generate_octahedron.h>

Generate an octahedron mesh.

Creates an octahedron mesh with the specified radius. An octahedron is a regular polyhedron with 8 triangular faces, 12 edges, and 6 vertices. It is one of the five Platonic solids and exhibits octahedral symmetry (Oh).

Template Parameters
ScalarThe scalar type for vertex coordinates
IndexThe index type for face indices
Parameters
settingsConfiguration parameters for the octahedron generation
Returns
A surface mesh representing the octahedron
Note
The function automatically calls settings.project_to_valid_range() to ensure all parameters are within valid bounds before generation.

◆ generate_rounded_cone()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_rounded_cone ( RoundedConeOptions setting)

#include <lagrange/primitive/generate_rounded_cone.h>

Generate a rounded cone mesh.

Creates a cone mesh with optionally rounded edges at the top and bottom. The cone is centered at 1/2 of its height along its center axis. The cone can have different radii at the top and bottom, making it suitable for generating cones, cylinders, truncated cones and even sphere.

When bevel_radius_top or bevel_radius_bottom > 0, the respective edges are rounded using toroidal patches. The smoothness of the rounding is controlled by the corresponding bevel_segments parameters.

Partial cones can be generated by specifying start_sweep_angle and end_sweep_angle different from 0 and 2π respectively.

Template Parameters
ScalarThe scalar type for vertex coordinates
IndexThe index type for face indices
Parameters
settingConfiguration parameters for the rounded cone generation
Returns
A surface mesh representing the rounded cone
Note
The function automatically calls setting.project_to_valid_range() to ensure all parameters are within valid bounds before generation.
When radius_top equals radius_bottom, the result is a cylinder. When radius_top is 0, the result is a traditional cone.

◆ generate_rounded_cube()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_rounded_cube ( RoundedCubeOptions setting)

#include <lagrange/primitive/generate_rounded_cube.h>

Generate a rounded cube mesh.

Creates a cube mesh with optionally rounded edges. The cube is centered at the origin and extends from -width/2 to +width/2 along the X-axis, -height/2 to +height/2 along the Y-axis, and -depth/2 to +depth/2 along the Z-axis.

When bevel_radius > 0, the edges and corners of the cube are rounded using cylindrical and spherical patches respectively. The smoothness of the rounding is controlled by the bevel_segments parameter.

Template Parameters
ScalarThe scalar type for vertex coordinates (e.g., float, double)
IndexThe index type for face indices (e.g., uint32_t, uint64_t)
Parameters
settingConfiguration parameters for the rounded cube generation
Returns
A surface mesh representing the rounded cube
Note
The function automatically calls setting.project_to_valid_range() to ensure all parameters are within valid bounds before generation.

◆ generate_rounded_plane()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_rounded_plane ( RoundedPlaneOptions settings)

#include <lagrange/primitive/generate_rounded_plane.h>

Generate a rounded plane mesh.

The mesh will be centered at setting.center, with its normal pointing along setting.normal.

The generated mesh includes:

  • Optional normal vectors (if setting.normal_attribute_name is specified)
  • Optional UV coordinates (if setting.uv_attribute_name is specified)
  • Optional semantic labels (if setting.semantic_label_attribute_name is specified)
Template Parameters
ScalarFloating-point type for vertex coordinates.
IndexInteger type for vertex and face indices.
Parameters
settingsConfiguration options for the rounded plane generation. The settings are automatically validated and clamped to valid ranges.
Returns
A SurfaceMesh containing the generated rounded plane geometry.
See also
RoundedPlaneOptions for detailed parameter descriptions.

◆ generate_sphere()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_sphere ( SphereOptions setting)

#include <lagrange/primitive/generate_sphere.h>

Generate a sphere mesh based on the specified settings.

Template Parameters
ScalarThe scalar type of the mesh.
IndexThe index type of the mesh.
Parameters
settingThe settings for the sphere mesh generation.
Returns
A SurfaceMesh object representing the generated sphere.
Note
The function automatically calls setting.project_to_valid_range() to ensure all parameters are within valid bounds before generation.

◆ generate_subdivided_sphere()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_subdivided_sphere ( const SurfaceMesh< Scalar, Index > & base_shape,
SubdividedSphereOptions setting )

#include <lagrange/primitive/generate_subdivided_sphere.h>

Generate a subdivided sphere mesh from a base shape.

The function takes a base shape (e.g., an icosahedron or octahedron) and performs subdivision followed by normalization to create a smoother sphere mesh.

Template Parameters
ScalarThe scalar type for vertex coordinates.
IndexThe index type for face indices.
Parameters
base_shapeThe initial coarse mesh to be subdivided.
settingConfiguration parameters for the subdivided sphere generation.
Returns
A surface mesh representing the subdivided sphere.

◆ generate_swept_surface()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_swept_surface ( span< const Scalar > profile,
const SweepOptions< Scalar > & sweep_setting,
const SweptSurfaceOptions & options = {} )

#include <lagrange/primitive/generate_swept_surface.h>

Generate a swept surface from a profile curve and a sequence of transforms.

Parameters
[in]profileA simply connected 2D curve (flattened N by 2 array in row major) serving as sweep profile.
[in]sweep_settingA set of sweep settings defining the sweep path.
[in]optionsOptions for generating the swept surface.
Returns
A SurfaceMesh representing the swept surface.

◆ generate_torus()

template<typename Scalar, typename Index>
SurfaceMesh< Scalar, Index > generate_torus ( TorusOptions setting)

#include <lagrange/primitive/generate_torus.h>

Generate a torus mesh.

Creates a torus (donut-shaped) mesh with the specified parameters. The torus is centered at setting.center with its center ring parallel to the XZ plane.

Partial tori can be generated by specifying start_sweep_angle and end_sweep_angle different from 0 and 2π respectively.

Template Parameters
ScalarThe scalar type for vertex coordinates
IndexThe index type for face indices
Parameters
settingConfiguration parameters for the torus generation
Returns
A surface mesh representing the torus
Note
The function automatically calls setting.project_to_valid_range() to ensure all parameters are within valid bounds before generation.