2005-02-08 13:43:03 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* VCGLib o o *
|
|
|
|
* Visual and Computer Graphics Library o o *
|
|
|
|
* _ O _ *
|
|
|
|
* Copyright(C) 2004 \/)\/ *
|
|
|
|
* Visual Computing Lab /\/| *
|
|
|
|
* ISTI - Italian National Research Council | *
|
|
|
|
* \ *
|
|
|
|
* All rights reserved. *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) *
|
|
|
|
* for more details. *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
|
|
History
|
|
|
|
|
|
|
|
$Log: not supported by cvs2svn $
|
2005-02-10 10:18:20 +01:00
|
|
|
Revision 1.6 2005/02/08 12:43:03 ponchio
|
|
|
|
Added copyright
|
|
|
|
|
2005-02-08 13:43:03 +01:00
|
|
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
2005-01-14 16:41:10 +01:00
|
|
|
#ifndef NXS_EXTRACTION_H
|
|
|
|
#define NXS_EXTRACTION_H
|
|
|
|
|
2005-01-17 18:35:48 +01:00
|
|
|
#include <set>
|
2005-01-14 16:41:10 +01:00
|
|
|
#include <vector>
|
2005-01-17 18:35:48 +01:00
|
|
|
|
2005-01-14 16:41:10 +01:00
|
|
|
#include <wrap/gui/frustum.h>
|
|
|
|
|
2005-01-17 18:35:48 +01:00
|
|
|
#include "history.h"
|
|
|
|
|
2005-01-14 16:41:10 +01:00
|
|
|
namespace nxs {
|
|
|
|
|
|
|
|
class Metric;
|
|
|
|
class NexusMt;
|
|
|
|
|
2005-02-03 13:35:01 +01:00
|
|
|
struct Item {
|
|
|
|
float error;
|
|
|
|
unsigned int id;
|
|
|
|
Item(unsigned int i = 0, float e = 0): id(i), error(e) {}
|
|
|
|
bool operator<(const Item &item) const {
|
|
|
|
return error < item.error;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2005-01-14 16:41:10 +01:00
|
|
|
class Extraction {
|
|
|
|
public:
|
2005-01-17 18:35:48 +01:00
|
|
|
typedef History::Node Node;
|
|
|
|
typedef History::Link Link;
|
|
|
|
|
|
|
|
struct Cost {
|
2005-01-14 16:41:10 +01:00
|
|
|
unsigned int extr;
|
|
|
|
unsigned int draw;
|
|
|
|
unsigned int disk;
|
2005-01-17 18:35:48 +01:00
|
|
|
Cost(): extr(0), draw(0), disk(0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HeapNode {
|
|
|
|
Node *node;
|
|
|
|
float error;
|
|
|
|
|
|
|
|
HeapNode(Node *_node, float _error): node(_node), error(_error) {}
|
2005-01-14 16:41:10 +01:00
|
|
|
bool operator<(const HeapNode &node) const {
|
|
|
|
return error < node.error; }
|
2005-01-17 18:35:48 +01:00
|
|
|
bool operator>(const HeapNode &node) const {
|
|
|
|
return error > node.error; }
|
2005-01-14 16:41:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Metric *metric;
|
|
|
|
|
|
|
|
vcg::Frustumf frustum;
|
|
|
|
|
|
|
|
float target_error;
|
2005-02-10 10:18:20 +01:00
|
|
|
float max_error;
|
2005-01-14 16:41:10 +01:00
|
|
|
unsigned int extr_used, extr_max;
|
|
|
|
unsigned int draw_used, draw_max;
|
|
|
|
unsigned int disk_used, disk_max;
|
|
|
|
|
|
|
|
std::vector<bool> visited;
|
2005-02-03 13:35:01 +01:00
|
|
|
std::map<unsigned int, float> errors;
|
|
|
|
|
|
|
|
std::vector<Item> selected;
|
2005-01-17 18:35:48 +01:00
|
|
|
unsigned int draw_size; //first in selected should be drawn
|
|
|
|
|
2005-02-03 13:35:01 +01:00
|
|
|
std::vector<HeapNode> heap; //no realtime extraxtion
|
|
|
|
|
2005-01-17 18:35:48 +01:00
|
|
|
//nodes that i can expand to
|
|
|
|
std::vector<HeapNode> front;
|
|
|
|
//nodes that i can contract
|
|
|
|
std::vector<HeapNode> back;
|
|
|
|
|
|
|
|
unsigned int tot_budget;
|
2005-01-14 16:41:10 +01:00
|
|
|
|
|
|
|
Extraction();
|
|
|
|
~Extraction();
|
|
|
|
|
|
|
|
void Extract(NexusMt *mt);
|
2005-01-17 18:35:48 +01:00
|
|
|
void Update(NexusMt *mt);
|
2005-01-14 16:41:10 +01:00
|
|
|
|
|
|
|
|
2005-01-21 18:09:13 +01:00
|
|
|
protected:
|
2005-01-17 18:35:48 +01:00
|
|
|
|
2005-01-14 16:41:10 +01:00
|
|
|
void Select();
|
2005-01-17 18:35:48 +01:00
|
|
|
void Visit(Node *node);
|
2005-01-14 16:41:10 +01:00
|
|
|
|
|
|
|
bool Expand(HeapNode &node);
|
2005-01-17 18:35:48 +01:00
|
|
|
void Diff(Node *node, Cost &cost);
|
|
|
|
|
2005-01-21 19:12:45 +01:00
|
|
|
bool Refine(HeapNode node);
|
|
|
|
bool Coarse(HeapNode node);
|
2005-01-14 16:41:10 +01:00
|
|
|
|
2005-01-17 18:35:48 +01:00
|
|
|
void Init();
|
2005-01-14 16:41:10 +01:00
|
|
|
private:
|
|
|
|
NexusMt *mt;
|
2005-01-17 18:35:48 +01:00
|
|
|
Node *root;
|
|
|
|
Node *sink;
|
|
|
|
|
|
|
|
bool Visited(Node *node) {
|
|
|
|
return visited[node - root];
|
|
|
|
}
|
|
|
|
|
|
|
|
float GetRefineError(Node *node);
|
2005-01-14 16:41:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}//namespace
|
|
|
|
|
|
|
|
#endif
|