#ifndef _LARGE_SCALE_SCENE_H_
#define _LARGE_SCALE_SCENE_H_


#include "geometry_common.h"
#include "color.h"
#include "geometry_types.h"
#include "geometry_global.h"
#include "../basic/active_object.h"
#include "vertex.h"


class SceneGraph;
class VertexGroup;

class GEOMETRY_API PointSet : public ActiveObject
{
public:
	PointSet(SceneGraph* sg = nil) ;
	~PointSet() { clear(); }

	static std::string title() { return "[PointSet]: "; }

	void clear() ;
	void changed();

	PointSet* copy() const ;

	int nb_vertices() { return nb_vrtices_; }

	Vertex** vertices() { return vertices_; }
	void set_vertices(Vertex** pts, int num) ;

	const Bbox3f& bbox() const ;
	void set_bbox(const Bbox3f& box) { 
		bbox_ = box;
		bbox_exist_ = true;
	}

	void draw(bool draw_normals, int normal_skip = 5, bool fast = false, int max_num = 200000) ;

	//////////////////////////////////////////////////////////////////////////

	std::vector<VertexGroup*>& vertex_groups()             { return vertex_groups_; }
	const std::vector<VertexGroup*>& vertex_groups() const { return vertex_groups_; }
	void clear_vertex_groups() ;

	void add_vertex_group(VertexGroup* g) ;
	void delete_vertex_group(VertexGroup* g) ;  // deallocate memory

	void remove_vertex_group(VertexGroup* g) ; // just remove from the list

	// merge into one new group, remove the children from point set, return the new group
	VertexGroup* merge_some_vertex_groups(const std::vector<VertexGroup*>& groups);
	void break_some_parent_groups(const std::vector<VertexGroup*>& groups);

	//////////////////////////////////////////////////////////////////////////

	void assign_color_by_normal();
	void assign_color_by_height();

	bool has_normals() const       { return normals_exist_; }
	void set_normals_exist(bool b) { normals_exist_ = b;    }

	bool has_curvature() const { return curvature_exist_; }
	void set_curvature_exist(bool b) { curvature_exist_ = b; }

private:
	Vertex**	vertices_;

	int			nb_vrtices_;

	mutable	Bbox3f	bbox_;
	mutable	bool    bbox_exist_;

	bool        	normals_exist_;
	bool			curvature_exist_;

	std::vector<VertexGroup*>	vertex_groups_;
};


#endif // _LARGE_SCALE_SCENE_H_
