/* $Id: boxes.h,v 1.1.1.1 1996/10/02 10:35:48 roitzsch Exp $ */

#ifndef BOXES_H
#define BOXES_H


#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>

#include "general.h"
#include "plot.h"
#include "boxdefs.h"
#include "mzibutil.h"

#ifndef nil
#define nil Null
#endif

//-------------------------------------------------------------------------


class Boxes
{

  public:

    Boxes(char* inFile=0, char* inFileStream=0);
    ~Boxes();

    int CreateGrid (char* inFileStream, double threshold);
    int RefineRed ();
    int RefineBlue();
    int Refine_Triangles (int greenP, int max_tries, int blueMode, 
			  Real threshhold);
    int write (char* outFile);


    // boxgraph.cc :

    void Draw(int type=X11, char* caption=0);

    void DrawInit (Plot& plot);
    void DrawBoundary(Plot& plot);

    void DrawBoxes(Plot& plot, int index);
    void DrawAreas(Plot& plot);
    void DrawTriangles(Plot& plot);

    void DrawGreen(Plot& plot);
    void DrawPoints(Plot& plot, int index);


  private:

    /*-----------------  private member functions  --------------------*/


    		// triangulate.cc

    edge* search_edge(point* p1,point* p2);
    int Read_Boxes(char* tp);
    int Refine_Edges();
    int Refine_Edge(edge* ed);
    int Refine_Red(triangle* t);

    int Generate_Coarse_Triangles();
    int Dump_Triangulation(char* out_name);
    int Write_Triangulation(char* out_name, int greenClosure, int tosca_P);
    int Try_Blue(triangle* t, int no);
    int Refine_Green(triangle* t);
    void MarkInnerBound();
    int mRefineCmd(int refMode);


    		// boxgraph.cc :

    void SetMinMax(Plot& plot);
    void Compute_Min_Max();
    void DrawBoxIndex(Plot& plot, box *b, double w, double h);
    point*  Find_PM(edge* ed);


    point* 	first_point,  *last_point;
    edge*  	first_edge ,  *last_edge ;
    triangle* 	first_triangle , *last_triangle ;
    box*  	first_box ,  *last_box ;
    int 	new_point_counter, new_edge_counter,
    		new_triangle_counter, new_boxes_counter,
    		ref_level;

    int 	point_list, edge_list, triangle_list, box_list;
    int 	triangulation_exists,
    		file_name_extended, already_saved;

    int 	refinementSteps;
    int 	greenClosure; 
    int 	goon;

    char 	Init_Global_buffer[255];
    char*	globBuf;
    
    int 	stat_ind;
    int		infoBoxes;

			// triangulate.cc:
    		
    Real 	blueThreshold;

    			// boxgraph.cc:   		

    Real  xmin, xmax, ymin, ymax;
    int   ixOrig, iyOrig;		// origin (lower left c.)

};

#endif


syntax highlighted by Code2HTML, v. 0.9.1