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

package ansys.api.speos.lpf.v2;

// service to read lpf file - server can handle one reading - call CloseLpfFileName then InitLpfFileName to start another reading.
service LpfFileReader_Mono {
	// Init the lpf file with its path - returns nothing
	rpc InitLpfFileName(InitLpfFileName_Request_Mono) returns (InitLpfFileName_Response) {}
	// Get information about the lpf file, for example number of traces, number of xmps...
	rpc GetInformation(GetInformation_Request_Mono) returns (GetInformation_Response) {}
	// Close the lpf file - returns nothing
	rpc CloseLpfFileName(CloseLpfFileName_Request_Mono) returns (CloseLpfFileName_Response) {}
	// Read lpf file and get all the ray paths
	rpc Read(Read_Request_Mono) returns (stream RayPath) {}
	// Compute a unique face id from bodyContextId and faceId
	rpc ComputeUniqueFaceId(ComputeUniqueFaceId_Request_Mono) returns (ComputeUniqueFaceId_Response) {}
}

// service to read lpf file - server can handle several reading.
service LpfFileReader_Multi {
	// Create a lpf file reader - returns its guid
	rpc Create(Create_Request_Multi) returns (Create_Response) {}
	// Init the lpf file with its path - returns nothing
	rpc InitLpfFileName(InitLpfFileName_Request_Multi) returns (InitLpfFileName_Response) {}
	// Get information about the lpf file, for example number of traces, number of xmps...
	rpc GetInformation(GetInformation_Request_Multi) returns (GetInformation_Response) {}
	// Close the lpf file - returns nothing
	rpc CloseLpfFileName(CloseLpfFileName_Request_Multi) returns (CloseLpfFileName_Response) {}
	// Read lpf file and get all the ray paths
	rpc Read(Read_Request_Multi) returns (stream RayPath) {}
	// Compute a unique face id from bodyContextId and faceId
	rpc ComputeUniqueFaceId(ComputeUniqueFaceId_Request_Multi) returns (ComputeUniqueFaceId_Response) {}
	// Delete a lpf file reader - returns nothing
	rpc Delete(Delete_Request_Multi) returns (Delete_Response) {}
}

message Create_Request_Multi{
}
message Create_Response{
	string lpf_reader_guid = 1; 
}

message InitLpfFileName_Request_Mono {
	string lpf_file_uri = 1; // This can be uri returned by the server when uploading the file, or a local path (in this case the file has to be accessible by the server)
}
message InitLpfFileName_Request_Multi {
	string lpf_reader_guid = 1;
	string lpf_file_uri = 2;  // This can be uri returned by the server when uploading the file, or a local path (in this case the file has to be accessible by the server)
}
message InitLpfFileName_Response {
}

message GetInformation_Request_Mono {
}
message GetInformation_Request_Multi {
	string lpf_reader_guid = 1;
}
message GetInformation_Response {
	int64 nb_of_traces = 1;
	uint32 nb_of_xmps = 2;
	bool has_sensor_contributions = 3;
	// The sensor position in the repeated field sensor_names gives the sensor_id
	repeated string sensor_names = 4;
}

message CloseLpfFileName_Request_Mono{
}
message CloseLpfFileName_Request_Multi{
	string lpf_reader_guid = 1;
}
message CloseLpfFileName_Response{
}

message Read_Request_Mono {
}
message Read_Request_Multi {
	string lpf_reader_guid = 1;
}

message RayPath {
	repeated TripletFloat impacts = 1;
	repeated double wavelengths = 2;
	repeated uint32 body_context_ids = 3;
	repeated uint32 unique_face_ids = 4;

	enum PhotonStatus {
		StatusAbsorbed = 0;
		StatusSpecularTransmitted = 1;
		StatusGaussianTransmitted = 2;
		StatusLambertianTransmitted = 3;
		StatusVolumicDiffused = 4;
		StatusJustEmitted = 5;
		StatusDiracTransmitted = 6;
		StatusError = 7;
		StatusErrorVolumicBodyNotClosed = 8;
		StatusErrorVolumeConflict = 9;
		StatusError2DTangency = 10;
		StatusError2DIntersect3DWarning = 11;
		StatusErrorNonOpticalMaterial = 12;
		StatusErrorIntersection = 13;
		StatusErrorNonOpticalMaterialAtEmission = 14;
		StatusError3DTextureSupportTangency = 15;
		StatusLast = 16;
		StatusFirst = -7;
		StatusDiracReflected = -6;
		StatusReserved = -5;
		StatusGrinStep = -4;
		StatusLambertianReflected = -3;
		StatusGaussianReflected = -2;
		StatusSpecularReflected = -1;
	}
	repeated PhotonStatus interaction_statuses = 6;

	TripletFloat lastDirection = 5;

	message SensorContribution {
		// The sensor_id corresponds to the position of the sensor in the repeated field GetInformation_Response::sensor_names
		uint32 sensor_id = 1;
		DoubletDouble coordinates = 2;
	}
	repeated SensorContribution sensor_contributions = 7;
}

message TripletFloat {
	float x = 1;
	float y = 2;
	float z = 3;
}

message DoubletDouble {
	double x = 1;
	double y = 2;
}

message ComputeUniqueFaceId_Request_Mono {
	uint32 body_context_id = 1;
	uint32 face_id = 2;
}
message ComputeUniqueFaceId_Request_Multi {
	string lpf_reader_guid = 1;
	uint32 body_context_id = 2;
	uint32 face_id = 3;
}
message ComputeUniqueFaceId_Response {
	uint32 unique_face_id = 1;
}

message Delete_Request_Multi{
	string lpf_reader_guid = 1;
}
message Delete_Response{
}