21 #ifndef Tulip_GLLODCALCULATOR_H
22 #define Tulip_GLLODCALCULATOR_H
23 #ifndef DOXYGEN_NOTFOR_DEVEL
28 #include <tulip/BoundingBox.h>
29 #include <tulip/GlSceneVisitor.h>
30 #include <tulip/GlSimpleEntity.h>
31 #include <tulip/GlNode.h>
32 #include <tulip/GlEdge.h>
33 #include <tulip/GlLayer.h>
41 class GlGraphInputData;
43 enum RenderingEntitiesFlag {
44 RenderingSimpleEntities = 1,
48 RenderingWithoutRemove = 8
51 struct EntityLODUnit {
52 EntityLODUnit() : lod(-1) {}
53 EntityLODUnit(
const BoundingBox &boundingBox) : boundingBox(boundingBox), lod(-1) {}
54 BoundingBox boundingBox;
59 struct SimpleEntityLODUnit :
public EntityLODUnit {
60 SimpleEntityLODUnit(GlSimpleEntity *entity =
nullptr) : EntityLODUnit(), entity(entity) {}
61 SimpleEntityLODUnit(GlSimpleEntity *entity,
const BoundingBox &boundingBox)
62 : EntityLODUnit(boundingBox), entity(entity) {}
63 GlSimpleEntity *entity;
65 void init(GlSimpleEntity *e,
const BoundingBox &bb) {
72 struct ComplexEntityLODUnit :
public EntityLODUnit {
73 ComplexEntityLODUnit(
unsigned int id = UINT_MAX,
unsigned int pos = UINT_MAX)
74 : EntityLODUnit(), id(id), pos(pos) {}
75 ComplexEntityLODUnit(
unsigned int id,
unsigned int pos,
const BoundingBox &boundingBox)
76 : EntityLODUnit(boundingBox), id(id), pos(pos) {}
78 void init(
unsigned int i,
unsigned int p,
const BoundingBox &bb) {
89 std::vector<SimpleEntityLODUnit> simpleEntitiesLODVector;
90 std::vector<ComplexEntityLODUnit> nodesLODVector;
91 std::vector<ComplexEntityLODUnit> edgesLODVector;
95 typedef std::vector<LayerLODUnit> LayersLODVector;
100 class TLP_GL_SCOPE GlLODCalculator :
public GlSceneVisitor {
103 GlLODCalculator() : glScene(nullptr), inputData(nullptr), attachedLODCalculator(nullptr) {}
104 virtual ~GlLODCalculator() {}
105 virtual GlLODCalculator *clone() = 0;
110 void visit(GlSimpleEntity *entity)
override {
111 addSimpleEntityBoundingBox(entity, entity->getBoundingBox());
117 void visit(GlNode *glNode)
override {
118 addNodeBoundingBox(glNode->id, glNode->pos, glNode->getBoundingBox(inputData));
123 void visit(GlEdge *glEdge)
override {
124 addEdgeBoundingBox(glEdge->id, glEdge->pos, glEdge->getBoundingBox(inputData));
129 void visit(GlLayer *layer)
override {
130 beginNewCamera(&layer->getCamera());
136 void reserveMemoryForGraphElts(
unsigned int ,
unsigned int )
override {}
140 virtual void setScene(GlScene &scene) {
147 virtual void setInputData(
const GlGraphInputData *inputData) {
148 this->inputData = inputData;
155 virtual void setRenderingEntitiesFlag(RenderingEntitiesFlag flag) {
156 renderingEntitiesFlag = flag;
162 virtual bool needEntities() {
168 virtual void setNeedEntities(
bool) {}
172 virtual void beginNewCamera(Camera *camera) = 0;
176 virtual void addSimpleEntityBoundingBox(GlSimpleEntity *entity,
const BoundingBox &bb) = 0;
180 virtual void addNodeBoundingBox(
unsigned int id,
unsigned int pos,
const BoundingBox &bb) = 0;
184 virtual void addEdgeBoundingBox(
unsigned int id,
unsigned int pos,
const BoundingBox &bb) = 0;
189 virtual void compute(
const Vector<int, 4> &globalViewport,
190 const Vector<int, 4> ¤tViewport) = 0;
195 LayersLODVector &getResult() {
196 return layersLODVector;
202 virtual void clear() {
203 layersLODVector.clear();
206 virtual BoundingBox getSceneBoundingBox() = 0;
208 void setAttachedLODCalculator(GlLODCalculator *calculator) {
209 attachedLODCalculator = calculator;
214 const GlGraphInputData *inputData;
216 RenderingEntitiesFlag renderingEntitiesFlag;
218 LayersLODVector layersLODVector;
220 GlLODCalculator *attachedLODCalculator;