core 1.5.0
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
peclet::core::geom::SceneBuilder< Real > Class Template Reference

Owns a scene under construction and hands out a non-owning SceneView over it. More...

#include <scene_builder.hpp>

Public Member Functions

int addLeaf (int kind, std::initializer_list< Real > params, Transform< Real > tr={})
 Analytic leaf. params follows the per-kind layout documented on ShapeKind.
 
int addNode (const ShapeNode< Real > &n)
 Analytic leaf from a prebuilt node (the runtime-parameter sibling of addLeaf, for callers whose parameters arrive as data – the Python binding).
 
int addGrid (const std::vector< float > &samples, int nx, int ny, int nz, Vec3< Real > origin, Vec3< Real > spacing, GridExtension ext, Transform< Real > tr={})
 Sampled field: copies samples into the shared pool, registers a descriptor, returns the node index.
 
int addUnion (int a, int b, Transform< Real > tr={})
 
int addIntersection (int a, int b, Transform< Real > tr={})
 
int addDifference (int a, int b, Transform< Real > tr={})
 a MINUS b.
 
int addInstance (int shapeRoot, Transform< Real > tr={}, Vec3< Real > linVel={0, 0, 0}, Vec3< Real > angVel={0, 0, 0}, Vec3< Real > center={std::numeric_limits< Real >::quiet_NaN(), std::numeric_limits< Real >::quiet_NaN(), std::numeric_limits< Real >::quiet_NaN()}, int materialId=-1)
 Place a tree in the world.
 
SceneView< Real > view () const
 Non-owning view over this builder's arrays. Invalidated by any further add*.
 
const std::vector< ShapeNode< Real > > & nodes () const
 
const std::vector< GridDesc< Real > > & grids () const
 
const std::vector< float > & samples () const
 
const std::vector< Instance< Real > > & instances () const
 
int addReframed (int root, const Transform< Real > &W)
 Deep-copy the subtree rooted at root and pre-compose transform W onto the COPIED root, so the new tree evaluates as eval_new(p) = eval_old(toLocal(W, p)).
 
Instance< Real > & instanceRef (int i)
 Mutable access to one placed instance – how a MOVING scene advances: a driver updates the transform (and linVel/angVel/center) in place and re-derives the geometry, instead of re-encoding and re-decoding the whole scene every step.
 
void encode (std::vector< int > &nodeInts, std::vector< Real > &nodeReals, std::vector< int > &instInts, std::vector< Real > &instReals) const
 

Static Public Member Functions

static Transform< Real > composeTransform (const Transform< Real > &A, const Transform< Real > &B)
 Compose two transforms so that toLocal(C, p) == toLocal(B, toLocal(A, p)) – i.e.
 
static SceneBuilder decode (const std::vector< int > &nodeInts, const std::vector< Real > &nodeReals, const std::vector< int > &instInts, const std::vector< Real > &instReals, const std::vector< GridDesc< Real > > &grids, const std::vector< float > &pool)
 Rebuild from the flat encoding (grids and the sample pool are carried across verbatim).
 

Detailed Description

template<class Real>
class peclet::core::geom::SceneBuilder< Real >

Owns a scene under construction and hands out a non-owning SceneView over it.

Every add* returns the new NODE INDEX, so composing a tree reads bottom-up: const int shaft = b.addLeaf(kHollowCylinder, {0.3, 3.0, 0.3}); const int blade = b.addLeaf(kBox, {0.9, 0.1, 0.25}, {{1.0, 0.5, 0.0}}); const int stirrer = b.addUnion(shaft, blade); b.addInstance(stirrer, {}, /*angVel=*‍/{0, 10.0, 0}); // spinning about y

Definition at line 146 of file scene_builder.hpp.

Member Function Documentation

◆ addLeaf()

template<class Real >
int peclet::core::geom::SceneBuilder< Real >::addLeaf ( int  kind,
std::initializer_list< Real >  params,
Transform< Real >  tr = {} 
)
inline

Analytic leaf. params follows the per-kind layout documented on ShapeKind.

Definition at line 149 of file scene_builder.hpp.

◆ addNode()

template<class Real >
int peclet::core::geom::SceneBuilder< Real >::addNode ( const ShapeNode< Real > &  n)
inline

Analytic leaf from a prebuilt node (the runtime-parameter sibling of addLeaf, for callers whose parameters arrive as data – the Python binding).

CSG kinds refused; use addUnion etc.

Definition at line 166 of file scene_builder.hpp.

References peclet::core::geom::kCsgBase, peclet::core::geom::kGrid, and peclet::core::geom::ShapeNode< Real >::kind.

◆ addGrid()

template<class Real >
int peclet::core::geom::SceneBuilder< Real >::addGrid ( const std::vector< float > &  samples,
int  nx,
int  ny,
int  nz,
Vec3< Real >  origin,
Vec3< Real >  spacing,
GridExtension  ext,
Transform< Real >  tr = {} 
)
inline

Sampled field: copies samples into the shared pool, registers a descriptor, returns the node index.

The caller never computes a pool offset.

Definition at line 177 of file scene_builder.hpp.

◆ addUnion()

template<class Real >
int peclet::core::geom::SceneBuilder< Real >::addUnion ( int  a,
int  b,
Transform< Real >  tr = {} 
)
inline

Definition at line 203 of file scene_builder.hpp.

◆ addIntersection()

template<class Real >
int peclet::core::geom::SceneBuilder< Real >::addIntersection ( int  a,
int  b,
Transform< Real >  tr = {} 
)
inline

Definition at line 204 of file scene_builder.hpp.

◆ addDifference()

template<class Real >
int peclet::core::geom::SceneBuilder< Real >::addDifference ( int  a,
int  b,
Transform< Real >  tr = {} 
)
inline

a MINUS b.

Definition at line 208 of file scene_builder.hpp.

◆ addInstance()

template<class Real >
int peclet::core::geom::SceneBuilder< Real >::addInstance ( int  shapeRoot,
Transform< Real >  tr = {},
Vec3< Real >  linVel = {0, 0, 0},
Vec3< Real >  angVel = {0, 0, 0},
Vec3< Real >  center = {std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN(), std::numeric_limits<Real>::quiet_NaN()},
int  materialId = -1 
)
inline

Place a tree in the world.

Returns the instance index. center: the centre of rotation for angVel. NaN (the default) = follows the body — consumers rotate about the translation and re-anchor it when the body moves; any finite point = PINNED there in world coordinates, the origin included.

Definition at line 214 of file scene_builder.hpp.

◆ view()

◆ nodes()

template<class Real >
const std::vector< ShapeNode< Real > > & peclet::core::geom::SceneBuilder< Real >::nodes ( ) const
inline

◆ grids()

◆ samples()

template<class Real >
const std::vector< float > & peclet::core::geom::SceneBuilder< Real >::samples ( ) const
inline

◆ instances()

template<class Real >
const std::vector< Instance< Real > > & peclet::core::geom::SceneBuilder< Real >::instances ( ) const
inline

◆ composeTransform()

template<class Real >
static Transform< Real > peclet::core::geom::SceneBuilder< Real >::composeTransform ( const Transform< Real > &  A,
const Transform< Real > &  B 
)
inlinestatic

Compose two transforms so that toLocal(C, p) == toLocal(B, toLocal(A, p)) – i.e.

C applies A first, then B. Worked out from toLocal(T, p) = invR_T (p - t_T) / s_T: C.R = R_A R_B, C.s = s_A s_B, C.t = t_A + R_A s_A t_B.

Definition at line 255 of file scene_builder.hpp.

References peclet::core::mulQuat(), peclet::core::rotate(), peclet::core::geom::Transform< Real >::rotation, peclet::core::geom::Transform< Real >::scale, and peclet::core::geom::Transform< Real >::translation.

Referenced by peclet::core::geom::SceneBuilder< Real >::addReframed().

◆ addReframed()

template<class Real >
int peclet::core::geom::SceneBuilder< Real >::addReframed ( int  root,
const Transform< Real > &  W 
)
inline

Deep-copy the subtree rooted at root and pre-compose transform W onto the COPIED root, so the new tree evaluates as eval_new(p) = eval_old(toLocal(W, p)).

THE reframing move: with W = (t = R^T(-com), R = R_principal^T, s = 1) from bodyProperties, the copied tree's canonical frame IS the principal body frame – COM at the origin, axes principal – exactly, with no resampling and the original subtree untouched (other users keep it as-is).

Definition at line 272 of file scene_builder.hpp.

References peclet::core::geom::SceneBuilder< Real >::composeTransform(), and peclet::core::geom::kCsgBase.

◆ instanceRef()

template<class Real >
Instance< Real > & peclet::core::geom::SceneBuilder< Real >::instanceRef ( int  i)
inline

Mutable access to one placed instance – how a MOVING scene advances: a driver updates the transform (and linVel/angVel/center) in place and re-derives the geometry, instead of re-encoding and re-decoding the whole scene every step.

Nodes stay immutable: only the placement moves.

Definition at line 315 of file scene_builder.hpp.

◆ encode()

template<class Real >
void peclet::core::geom::SceneBuilder< Real >::encode ( std::vector< int > &  nodeInts,
std::vector< Real > &  nodeReals,
std::vector< int > &  instInts,
std::vector< Real > &  instReals 
) const
inline

◆ decode()

template<class Real >
static SceneBuilder peclet::core::geom::SceneBuilder< Real >::decode ( const std::vector< int > &  nodeInts,
const std::vector< Real > &  nodeReals,
const std::vector< int > &  instInts,
const std::vector< Real > &  instReals,
const std::vector< GridDesc< Real > > &  grids,
const std::vector< float > &  pool 
)
inlinestatic

The documentation for this class was generated from the following file: