// (c) 2025 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.
syntax = "proto3";

package ansys.api.speos.simulation.v1.templates;

message Weight {
	double minimum_energy_percentage = 1; // The Minimum energy percentage parameter defines the minimum energy ratio to continue to propagate a ray with weight. 1 = 100%.
}

// Default Colorimetric Standard
enum EnumColorimetricStandard {
	CIE_1931 = 0; // 2 degrees CIE Standard Colorimetric Observer Data.
	CIE_1964 = 1; // 10 degrees CIE Standard Colorimetric Observer Data.
}

message DirectMCSimulationTemplate {
	double geom_distance_tolerance = 2; // Maximum distance in mm to consider two faces as tangent
	int32 max_impact = 3; // To define a value to determine the maximum number of ray impacts during propagation. When a ray has interacted N times with the geometry, the propagation of the ray stops.
	Weight weight = 4; // To activate Weight. The Weight represents the ray energy. In real life, a ray looses some energy (power) when it interacts with an object.
	EnumColorimetricStandard colorimetric_standard = 5; // To define the Colorimetric Standard
	bool dispersion = 6; // To activate the dispersion calculation. 
	bool fast_transmission_gathering = 7; // To accelerate the simulation by neglecting the light refraction that occurs when the light is being transmitted through a transparent surface. 
	string ambient_material_uri = 8; // To select an ambient material *.material  
}

message InverseMCSimulationTemplate {
	double geom_distance_tolerance = 2; // Maximum distance in mm to consider two faces as tangent.
	int32 max_impact = 3; // To define a value to determine the maximum number of ray impacts during propagation. When a ray has interacted N times with the geometry, the propagation of the ray stops. 
	Weight weight = 4; // To activate Weight. The Weight represents the ray energy. In real life, a ray looses some energy (power) when it interacts with an object.
	EnumColorimetricStandard colorimetric_standard = 5; // To define the Colorimetric Standard 
	bool dispersion = 6; // To activate the dispersion calculation. 
	bool splitting = 7; // To split each propagated ray into several paths at their first impact after leaving the observer point.
	uint32 number_of_gathering_rays_per_source = 8; // This number pilots the number of shadow rays to target at each source.
	uint32 maximum_gathering_error = 9; // Deprecated - Better use maximum_gathering_error_percentage.
	double maximum_gathering_error_percentage = 12; // This value defines the level below which a source can be neglected. 0, the default value means that no approximation will be done. 
	bool fast_transmission_gathering = 10; // To accelerate the simulation by neglecting the light refraction that occurs when the light is being transmitted through a transparent surface.
	string ambient_material_uri = 11; // To select an ambient material *.material  
}

// Simulation template with its basic characteristics
message SimulationTemplate {
	string name = 3; // Simulation name
	string description = 4; // Simulation description
	map<string, string> metadata = 7; // User defined metadata
	oneof simulation_template {
		DirectMCSimulationTemplate direct_mc_simulation_template = 1;
		InverseMCSimulationTemplate inverse_mc_simulation_template = 2;
		Interactive interactive_simulation_template = 5;
	}

	message Interactive {
		double geom_distance_tolerance = 1; // Maximum distance in mm to consider two faces as tangent.
		int32 max_impact = 2; // Defines a value to determine the maximum number of ray impacts during propagation. When a ray has interacted N times with the geometry, the propagation of the ray stops.
		Weight weight = 3; // Activates Weight. Highly recommended to fill
		EnumColorimetricStandard colorimetric_standard = 4; // Default Colorimetric Standard
		string ambient_material_uri = 5; // To define the environment in which the light will propagate (water, fog, smoke etc.). It is expressed in a .material file
	}
}

service SimulationTemplatesManager {
	// Create a SimulationTemplate
	rpc Create(Create_Request) returns (Create_Response) {}
	// Read a SimulationTemplate
	rpc Read(Read_Request) returns (Read_Response) {}
	// Update a SimulationTemplate
	rpc Update(Update_Request) returns (Update_Response) {}
	// Delete a SimulationTemplate
	rpc Delete(Delete_Request) returns (Delete_Response) {}
	// List all SimulationTemplates in manager
	rpc List(List_Request) returns (List_Response) {}
}

// Request to create a SimulationTemplate in SimulationTemplatesManager
message Create_Request {
	SimulationTemplate simulation_template = 1; // SimulationTemplate containing its basic characteristics
}
message Create_Response {
	string guid = 1; // Guid of the SimulationTemplate created in SimulationTemplatesManager
}
// Request to read a SimulationTemplate in SimulationTemplatesManager
message Read_Request {
	string guid = 1; // Guid of the SimulationTemplate to be read
}
message Read_Response {
	SimulationTemplate simulation_template = 1; // SimulationTemplate corresponding to the guid given in Read_Request
}
// Request to update a SimulationTemplate in SimulationTemplatesManager
message Update_Request {
	string guid = 1; // Guid of the SimulationTemplate to be updated
	SimulationTemplate simulation_template = 2; // SimulationTemplate that will be used for the update
}
message Update_Response {
}
// Request to delete a SimulationTemplate in SimulationTemplatesManager
message Delete_Request {
	string guid = 1; // Guid of the SimulationTemplate to be deleted
}
message Delete_Response {}

message List_Request {
}
message List_Response {
	repeated string guids = 1; // Guids of the SimulationTemplates in SimulationTemplatesManager
}
