//#  eulerN -- program for statistical estimation of Euler characteristic of a 3-dimensional body
//#  given as a sufficiently dense "volumetric" point sampling
//#
//#  Copyright (c) 2005-2007 Bradford Jones, Konstantin Rybnikov, Karen Daniels, Daniel Klain
//#  Release 2: 1 June 2007 
//#
//#  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, or (at your option) any
//#  later version: http://www.gnu.org/licenses/gpl.txt.
//#
//#  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 for more details.
//#-----------------------------------------------------------------------------


#ifndef EULER2DREEB
#define EULER2DREEB
	#include <vector>
	#include <algorithm>
	#include <math.h>
	#include "d2point.h"
	#include <stack>
	using namespace std;

struct coordinates
{
	float x;
	float y;
	coordinates();
	coordinates(float, float);
};
////////////////////////////////////////////////////////////////////////
/* represents empty spaces in graph, used by the strip data structure */
struct block
{
	bool isNull;
	float lowerbound;
	float upperbound;
	bool isExplored;
	vector<block*> adjacencyList;
	block(float, float);
};
////////////////////////////////////////////////////////////////////////
/* determines if two numeric intervals overlap eachother */ //
bool overlap (float low1, float high1, float low2, float high2);

////////////////////////////////////////////////////////////////////////
/* strip data structure */
struct strip
{
	float top;
	float bottom;
	vector<block*> holes;
	strip();
	strip(float, float);
	~strip();
	void insertHole(float low, float high) { holes.push_back(new block(low, high)); }
	int searchAdjacent(float low1, float high1);
	//int searchHelper(float low1, float high1, int l, int u);
};

///////////////////////////////////////////////////////////////////////
int processVisit(block* root);
int processGraph(vector<block*> &result);
void modelData (vector<strip*> &dataModel, const vector<d2point> &pointCloud, vector<double> &stripWidth, bool modelhole, math_vector &direction);
int count(vector<d2point> &pointCloud, vector<double> &stripWidth, bool modelhole, math_vector &direction);
int Euler2dreeb (vector<d2point>& pointcloud, vector<double> &stripwidths, int numdirections2d, vector<math_vector> &directions2d);

#endif
