/*! \file Vertex.h 
 *  \brief: header file for vertex object
 */

#ifndef _VERTEX_H_
#define _VERTEX_H_

/*Headers:*/
/*{{{*/
#include "./classes.h"
#include "../shared/Exceptions/exceptions.h"
#include "../toolkits/toolkits.h"
template <class doubletype> class Vector;
template <class doubletype> class Matrix;
class Parameters;
class IoModel;
/*}}}*/

class Vertex: public Object{

	public: 
		bool       clone;
		int        domaintype;
		int        id;           // random index
		int        sid;          // "serial" id (rank of this vertex if the dataset was on 1 cpu)
		int        pid;          // "parallel" id
		IssmDouble x;
		IssmDouble y;
		IssmDouble z;
		IssmDouble sigma;        //sigma coordinate: (z-bed)/thickness
		int        connectivity; //number of vertices connected to this vertex

		/*Vertex constructors, destructors {{{*/
		Vertex();
		Vertex(int id, int sid, int i, IoModel* iomodel);
		~Vertex();
		/*}}}*/
		/*Object virtual functions definitions:{{{ */
		void  Echo();
		void  DeepEcho();
		int   Id(); 
		int   ObjectEnum();
		Object* copy();
		/*}}}*/
		/*Vertex management:*/ 
		int        Pid(void); 
		int        Sid(void); 
		int        Connectivity(void); 
		IssmDouble GetX(void); 
		IssmDouble GetY(void); 
		IssmDouble GetZ(void); 
		void       UpdatePosition(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz,Parameters* parameters,IssmDouble* thickness,IssmDouble* bed);
		void       DistributePids(int* ppidcount);
		void       OffsetPids(int pidcount);
		void       ShowTruePids(int* borderpids);
		void       UpdateClonePids(int* allborderpids);
		void       SetClone(int* minranks);
		void       ToXYZ(Matrix<IssmDouble>* matrix);
		void       VertexCoordinates(Vector<IssmDouble>* vx,Vector<IssmDouble>* vy,Vector<IssmDouble>* vz);
};

/*Methods relating to Vertex object: */
void GetVerticesCoordinates(IssmDouble* xyz,Vertex** vertices, int numvertices);

#endif  /* _VERTEX_H */
