#ifndef NXS_NEXUS_MT_H #define NXS_NEXUS_MT_H #include #include #include #include "nexusbase.h" #include "queuepserver.h" #include "borderserver.h" #include "prefetch.h" namespace nxs { typedef std::vector Frag; struct Node { std::vector in; std::vector out; std::vector frags; float error; bool visited; bool current; // bool pushed; }; struct TNode { float error; Node *node; TNode(Node *n, float e): node(n), error(e) {} bool operator<(const TNode &n) { return error < n.error; } }; class Metric { public: std::vector *index; float GetError(Node *node); float GetError(Frag &frag); virtual float GetError(unsigned int cell) = 0; virtual void GetView() {} }; class FlatMetric: public Metric { public: void GetView() {} float GetError(unsigned int cell); }; class DeltaMetric: public Metric { public: vcg::Point3f delta; void GetView() {} float GetError(unsigned int cell); }; class FrustumMetric: public Metric { public: vcg::Frustumf frustum; void GetView() { frustum.GetView(); } float GetError(unsigned int cell); }; /* class Policy { public: float error; int ram_used; int ram_size; vector *entries; void Init(); bool Expand(TNode &node); void NodeVisited(Node *node); };*/ class NexusMt: public NexusBase { public: //Vertex buffer object mode enum Vbo { VBO_AUTO, //autodetect best size VBO_OFF, //no vertex buffer object VBO_FIXED }; //user supplied size enum MetricKind { FRUSTUM, //screen error extraction GEOMETRY, //geometry error extraction DELTA }; //delta error enum Mode { POINTS, SMOOTH, XRAY, HIDDEN_LINE, FLAT_WIRE, FLAT, PATCHES }; enum Component { COLOR = 0x1, NORMAL = 0x2, TEXTURE = 0x4, DATA = 0x8}; Vbo vbo_mode; Metric *metric; float target_error; vcg::Frustumf frustum; unsigned int extraction_max; //total extraxtion (even culled parts) unsigned int extraction_used; unsigned int draw_max; //only visible parts unsigned int draw_used; unsigned int disk_max; //max not in ram loadable size unsigned int disk_used; Mode mode; unsigned int components; bool use_normals; bool use_colors; bool use_textures; bool use_data; //statistics: unsigned int tri_rendered; unsigned int tri_total; vector todraw; std::vector visited; std::vector sequence; QueuePServer patches; BorderServer borders; Prefetch prefetch; NexusMt(); ~NexusMt(); bool Load(const std::string &filename); void Close(); bool InitGL(Vbo mode = VBO_AUTO, unsigned int vbo_size = 64000000); void Render(); void SetMetric(MetricKind kind); void SetError(float error); void SetExtractionSize(unsigned int ram_size); void SetPrefetchSize(unsigned int size); void SetVboSize(unsigned int vbo_size); bool SetMode(Mode mode); bool SetComponent(Component c, bool on); bool SetComponents(unsigned int mask); void Draw(std::vector &selected); void Draw(unsigned int cell, QueuePServer::Data &data); void Extract(std::vector &selected); protected: std::vector nodes; bool Expand(TNode &node); void NodeVisited(Node *node); void LoadHistory(); void ClearHistory(); void VisitNode(Node *node, std::vector &heap); void UnvisitNode(Node *node, std::vector &heap); void Select(std::vector &selected); Patch &LoadPatch(unsigned int p); }; } #endif