wx_BGI_Graphics
Classic BGI-compatible graphics API with modern OpenGL extension API
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
bgi::DdsScene Class Reference

In-memory DDS scene graph. More...

#include <bgi_dds.h>

Public Member Functions

std::shared_ptr< DdsObjectappend (std::shared_ptr< DdsObject > obj)
 Assigns an auto-generated ID to obj and appends it to the scene.
 
std::shared_ptr< DdsObjectappendWithId (std::shared_ptr< DdsObject > obj)
 Appends an object that already has its id field set (used during deserialization to restore the original ID strings).
 
void clearAll ()
 Clears ALL objects (cameras, UCS, drawing objects).
 
void clearDrawingObjects ()
 Clears all drawing-primitive objects (type not Camera, Ucs, WorldExtentsObj).
 
void compact ()
 Physically removes soft-deleted entries from order and index.
 
int count () const
 Returns the number of non-deleted objects in the scene.
 
int countDrawing () const
 Returns the number of non-deleted drawing-primitive objects only.
 
 DdsScene ()=default
 
 DdsScene (const DdsScene &)=delete
 
std::shared_ptr< DdsObjectfindById (const std::string &id) const
 Returns the object with the given id, or nullptr if not found / deleted.
 
std::shared_ptr< DdsObjectfindByLabel (const std::string &label) const
 Returns the first non-deleted object whose label equals label, or nullptr if none found.
 
std::string findIdByLabel (const std::string &label) const
 Returns the ID of the first non-deleted object with the given label, or "".
 
template<typename Fn >
void forEach (Fn &&fn) const
 Calls fn(DdsObject&) for every non-deleted object in insertion order.
 
template<typename Fn >
void forEachDrawing (Fn &&fn) const
 Calls fn(DdsObject&) for non-deleted drawing-primitive objects only.
 
template<typename Fn >
void forEachRenderRoot (Fn &&fn) const
 Calls fn(DdsObject&) for top-level render roots only.
 
std::string idAt (int index) const
 Returns the insertion-order ID at position index (0-based).
 
DdsSceneoperator= (const DdsScene &)=delete
 
bool remove (const std::string &id)
 Soft-deletes the object with the given id.
 
 ~DdsScene ()=default
 

Data Fields

std::unordered_map< std::string, std::shared_ptr< DdsObject > > index
 
uint64_t nextId {1}
 
std::vector< std::string > order
 
uint64_t revision {1}
 

Detailed Description

In-memory DDS scene graph.

Maintains two parallel collections for O(1) direct access and O(n) sequential traversal:

Deletion is soft: objects are marked deleted so stable IDs are preserved. Call compact() to physically remove soft-deleted entries.

Thread safety: the caller (camera_api, ucs_api, dds_api, …) is responsible for holding gMutex before calling any DdsScene method.

Constructor & Destructor Documentation

◆ DdsScene() [1/2]

bgi::DdsScene::DdsScene ( )
default

◆ ~DdsScene()

bgi::DdsScene::~DdsScene ( )
default

◆ DdsScene() [2/2]

bgi::DdsScene::DdsScene ( const DdsScene )
delete

Member Function Documentation

◆ append()

std::shared_ptr< DdsObject > bgi::DdsScene::append ( std::shared_ptr< DdsObject obj)

Assigns an auto-generated ID to obj and appends it to the scene.

◆ appendWithId()

std::shared_ptr< DdsObject > bgi::DdsScene::appendWithId ( std::shared_ptr< DdsObject obj)

Appends an object that already has its id field set (used during deserialization to restore the original ID strings).

Updates nextId if the id's numeric value exceeds the current counter.

◆ clearAll()

void bgi::DdsScene::clearAll ( )

Clears ALL objects (cameras, UCS, drawing objects).

◆ clearDrawingObjects()

void bgi::DdsScene::clearDrawingObjects ( )

Clears all drawing-primitive objects (type not Camera, Ucs, WorldExtentsObj).

Camera and UCS objects remain in the scene.

◆ compact()

void bgi::DdsScene::compact ( )

Physically removes soft-deleted entries from order and index.

◆ count()

int bgi::DdsScene::count ( ) const

Returns the number of non-deleted objects in the scene.

◆ countDrawing()

int bgi::DdsScene::countDrawing ( ) const

Returns the number of non-deleted drawing-primitive objects only.

◆ findById()

std::shared_ptr< DdsObject > bgi::DdsScene::findById ( const std::string &  id) const

Returns the object with the given id, or nullptr if not found / deleted.

◆ findByLabel()

std::shared_ptr< DdsObject > bgi::DdsScene::findByLabel ( const std::string &  label) const

Returns the first non-deleted object whose label equals label, or nullptr if none found.

◆ findIdByLabel()

std::string bgi::DdsScene::findIdByLabel ( const std::string &  label) const

Returns the ID of the first non-deleted object with the given label, or "".

◆ forEach()

template<typename Fn >
void bgi::DdsScene::forEach ( Fn &&  fn) const
inline

Calls fn(DdsObject&) for every non-deleted object in insertion order.

◆ forEachDrawing()

template<typename Fn >
void bgi::DdsScene::forEachDrawing ( Fn &&  fn) const
inline

Calls fn(DdsObject&) for non-deleted drawing-primitive objects only.

◆ forEachRenderRoot()

template<typename Fn >
void bgi::DdsScene::forEachRenderRoot ( Fn &&  fn) const
inline

Calls fn(DdsObject&) for top-level render roots only.

Any object referenced as a child/operand of Transform / SetUnion / SetIntersection / SetDifference is skipped here and is expected to render through its owning composite node instead of as an independent root.

◆ idAt()

std::string bgi::DdsScene::idAt ( int  index) const

Returns the insertion-order ID at position index (0-based).

Skips soft-deleted entries. Returns "" if out of range.

◆ operator=()

DdsScene & bgi::DdsScene::operator= ( const DdsScene )
delete

◆ remove()

bool bgi::DdsScene::remove ( const std::string &  id)

Soft-deletes the object with the given id.

Returns true on success.

Field Documentation

◆ index

std::unordered_map<std::string, std::shared_ptr<DdsObject> > bgi::DdsScene::index

◆ nextId

uint64_t bgi::DdsScene::nextId {1}

◆ order

std::vector<std::string> bgi::DdsScene::order

◆ revision

uint64_t bgi::DdsScene::revision {1}

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