/*
3D VERTEX MODEL OF DROSOPHILA VENTRAL FURROW FORMATION
BY OLEG POLYAKOV | PRINCETON UNIVERSITY | 2008 - 2013

This model was developed to study the process of ventral furrow formation in Drosophila Melanogaster.

This is the Three-dimensional simulation of ventral furrow formation.

Each cell is approximated by 8 verticies - 4 for the apical surface and 4 for the basal surface. They are connected by the lateral edges.

The volumes of the cells are mainainted constant while a portion of the surface constricts to zero.

This was an attempt to build a 3-D simulation of the ventral furrow. This program was never completed and not used in the publication of the model.
*/



#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;

#include "Record_Functions.h"
#include "F_par.h"
#include "auxlrs.h"

int main() {
	
#include "a_par_0.h"
#include "b_par_4.h"
	
	//=====================================================================================================================================
	// Initialize variables
#include "create_variables.h"
	//=====================================================================================================================================
	// Initialize data
#include "init.h"
	
	//=====================================================================================================================================
	// Record Initial Data
	Record_Init(Nx, Ny, Nv, Nc, K_par, O_par, other_par, p);
	Record_Verticies(Vx, Vy, Vz, V_cells, Nv, 'o', p);
	Record_Cells(C_apver, C_bsver, Nc, p);
	Record_Verticies(Yolk_x, Yolk_y, Yolk_z, V_cells, Nv, 'y', p);
	Record_Cell_data(Cell_Apical, Cell_Basal, Cell_Volume, Cell_Lengths_1, Cell_Lengths_2, Cell_Lengths_3, Cell_Lengths_4, Yolk_volumes, Nc, count++, p);
	Record_Cell_Parameters(A_K_cell, B_K_cell, V_K_cell, L_K_cell, K_yolk, Nc, p);
	//=====================================================================================================================================
	
	// Time Loop for different scenarios
	//*
	//#include "time_loop.h"
	//#include "time_loop_isotropic_A0.h"
	//#include "time_loop_isotropic_A0_zero_change.h"
	#include "time_loop_init.h"
	//#include "time_loop_isotropic_A0_zero_change_backtracking.h"
	#include "time_loop_Apical_Force.h"
	
	// Record the final position of the verticies
	Record_Verticies(Vx, Vy, Vz, V_cells, Nv, 'n', p);
	Record_Grad(V_grad, Nv, p);
	Record_Cell_data(Cell_Apical, Cell_Basal, Cell_Volume, Cell_Lengths_1, Cell_Lengths_2, Cell_Lengths_3, Cell_Lengths_4, Yolk_volumes, Nc, count++, p);
	
	for (i=0; i<Nc; i++) {
		
		for (k=0; k<4; k++) {
			AP[k][0] = Vx[C_apver[i][k]]; AP[k][1] = Vy[C_apver[i][k]]; AP[k][2] = Vz[C_apver[i][k]];
			BS[k][0] = Vx[C_bsver[i][k]]; BS[k][1] = Vy[C_bsver[i][k]]; BS[k][2] = Vz[C_bsver[i][k]];
		}
		
		A_0 = A_from_cell(AP, BS);
		B_0 = B_from_cell(AP, BS);
		V_0 = V_from_cell(AP, BS);
		L_0 = sqrt(pow(AP[0][0] - BS[0][0], 2) + pow(AP[0][1] - BS[0][1], 2) + pow(AP[0][2] - BS[0][2], 2));
		
		cout << "For cell " << i << " A = " << A_0 << " B_0 = " << B_0 << " V_0 = " << V_0 << " L_0 = " << L_0 << endl;
	}
	
	
	return 0;
}
