AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb
[REQUEST] Add `openvdb/GridFwd.h` (and friends?) providing forward declarations.
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 774
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 34
Description
### Is your feature request related to a problem? Please describe.
Being nearly all headers, OpenVBD is expensive to `#include`. There are places I pass around `OpenVDB` classes where I'd like to be able to just have them forward-declared so I can name them.
Using `-ftime-trace` on clang, and `speedscope` or `chrome://tracing` to view, I'm seeing over a second to `#include `.
### Describe the solution you'd like
Something like `openvdb/TypesFwd.h` or `openvdb/GridFwd.h` or `openvdb/openvdbFwd.h` containing forward-declarations of at least the named grid types... So to get `MaskGrid`
```
#include
using Index32 = std::int32_t;
using Index = Index32;
template
class LeafNode;
template
class InternalNode;
template
class RootNode;
template
class Tree;
class ValueMask;
namespace tree {
template
struct Tree4 {
using Type = Tree, N2>, N1>>>;
};
}
using MaskTree = tree::Tree4::Type;
template class Grid;
using MaskGrid = Grid;
```
### Describe alternatives you've considered
In my own codebase I've done
```
// This is inherited rather than a using declaration so we can forward-declare it elsewhere.
struct VolumeGrid : openvdb::MaskGrid {
using openvdb::MaskGrid::MaskGrid;
};
```
instead of `using VolumeGrid = openvdb::MaskGrid;` to allow me to forward-declare `VolumeGrid`.
### Additional context
Beyond this, since `Grid` is really a shared pointer to a tree, it may be possible to reduce what `Grid.h` includes (or add a `GridMinimal.h`) which defines `Grid` but doesn't include tree or much else.
Contributor guide
Research direction
Start by comparing the declarations and dependencies in openvdb/Grid.h with the proposed openvdb/GridFwd.h, TypesFwd.h, openvdbFwd.h, or GridMinimal.h. Verify which named grid types can be forward-declared without including the full tree implementation, then confirm that code can name those types without Grid.h and that the include-time cost is reduced.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- developer-experience, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100