#pragma once
#include "nlohmann/json.hpp"
#include <gp_Trsf.hxx>
#include <gp_Ax1.hxx>

using json = nlohmann::json;

class Motion
{
public:
	Motion(json);
	Motion(const Motion& mt);
	Motion& operator=(const Motion& other);

	~Motion();

	enum MotionType
	{
		SIMPLE,
		COMPLEX,
		COMPLEX_WITH_PARAMETERS
	};

	/// <summary>
	/// get OCC tranformation object, that can be applied to shapes
	/// 
	/// </summary>
	/// <param name="time"> time of motion (usually time step) to multiply by velocity </param>
	/// <returns></returns>
	gp_Trsf getTransform(double time);

	std::vector<std::string> getDomainNames();

	void setScale(double);
	MotionType getType();
	bool isEnabled();

	std::vector<double> getVelocity();
	double getAngularVelocity();

	// _OM means old motion
	//ecalculate parameters for old motion
	// time required to know the value of initial value
	// time step required to know the size of displacement (new value)
	void calculateParameters_OM(double time, double time_step);
	json getParameters_OM();
	void readOldParameters_OM(std::string fname);
	void saveUpdatedParameters_OM(std::string fname);

private:

	struct Parameter_OM
	{
		bool is_enabled;
		std::string name;
		double velocity;
		double initial_value;
		double new_value;
		double old_value;
	};


	std::string name;
	std::vector<std::string> domain_names;
	bool is_enabled;
	double linear_velocity[3];
	double angular_velocity;
	double scale;
	MotionType type;

	std::vector< Parameter_OM> params_OM;

};