// Proto file representing the EDB Layout class

syntax = "proto3";

// Package
package ansys.api.edb.v1;

// Imports
import "ansys/api/edb/v1/edb_messages.proto";
import "ansys/api/edb/v1/refs.proto";
import "ansys/api/edb/v1/layout_obj.proto";
import "ansys/api/edb/v1/edb_defs.proto";
import "ansys/api/edb/v1/polygon_data.proto";

// Cell service definition
service LayoutService {
  // Gets the cell of the provided layout
  rpc GetCell (EDBObjMessage) returns (EDBObjMessage) {}

  // Gets the layer collection of the layout
  rpc GetLayerCollection (EDBObjMessage) returns (EDBObjMessage) {}

  // Sets the layer collection of the layout
  rpc SetLayerCollection (SetLayerCollectionMessage) returns (google.protobuf.Empty) {}

  // Gets the layout objects that belong to the layout
  rpc GetItems (LayoutObjTargetMessage) returns (EDBObjCollectionMessage) {}
  rpc StreamItems (LayoutObjTargetMessage) returns (stream EDBObjCollectionMessage) {}

  // Get expanded extent from nets
  rpc GetExpandedExtentFromNets (LayoutExpandedExtentMessage) returns (PolygonDataMessage) {}

  // Convert primitives to via
  rpc ConvertPrimitivesToVias(LayoutConvertP2VMessage) returns (google.protobuf.Empty) {}

  // Gets if the port reference terminals are connected
  rpc ArePortReferenceTerminalsConnected (EDBObjMessage) returns (LayoutPortRefTerminalsConnectedMessage) {}

  // Gets list of zone primitives
  rpc GetZonePrimitives (EDBObjMessage) returns (EDBObjCollectionMessage) {}
  rpc StreamZonePrimitives (EDBObjMessage) returns (stream EDBObjCollectionMessage) {}

  // Set fixed zone primitives
  rpc SetFixedZonePrimitives (PointerPropertyMessage) returns (google.protobuf.Empty) {}

  // Get fixed zone primitive
  rpc GetFixedZonePrimitive (EDBObjMessage) returns (EDBObjMessage) {}

  // Get board bend definitions
  rpc GetBoardBendDefs (EDBObjMessage) returns (EDBObjCollectionMessage) {}
  rpc StreamBoardBendDefs (EDBObjMessage) returns (stream EDBObjCollectionMessage) {}

  // Synchronize bend manager
  rpc SynchronizeBendManager (EDBObjMessage) returns (google.protobuf.Empty) {}

  // Get the layout instance of the layout
  rpc GetLayoutInstance (EDBObjMessage) returns (EDBObjMessage) {}

  // Reconstruct arcs on layer
  rpc ReconstructArcs (GeometrySimplificationSettingsMessage) returns (google.protobuf.Empty) {}

  // Union primitives on layer
  rpc UnitePrimitives (LayerRefPropertyMessage) returns (google.protobuf.Empty) {}
  
  // Create via groups on layer
  rpc GroupVias (ViaGroupingSettingsMessage) returns (google.protobuf.Empty) {}
  
  // Snap vias on layer
  rpc SnapVias (ViaSnappingSettingsMessage) returns (google.protobuf.Empty) {}

  // Snap primitives on layer
  rpc SnapPrimitives (GeometrySimplificationSettingsWithOptionMessage) returns (google.protobuf.Empty) {}

  // Create mesh region
  rpc CreateMeshRegion(CreateMeshRegionMessage) returns (google.protobuf.Empty) {}
}

message SetLayerCollectionMessage {
  EDBObjMessage layout = 1;
  EDBObjMessage layer_collection = 2;
}

message LayerLookupMessage {
  EDBObjMessage layout = 1;
  LayerRefMessage layer = 2;
}

message LayoutExpandedExtentMessage {
  EDBObjMessage layout = 1;
  EDBObjCollectionMessage nets = 2;
  GeometryExtentType etype = 3;
  float expansion_factor = 4;
  bool expansion_factor_unitless = 5;
  bool use_round_corner = 6;
  uint64 num_increments = 7;
}

message LayoutConvertP2VMessage {
  EDBObjMessage layout = 1;
  EDBObjCollectionMessage primitives = 2;
  bool is_pins = 3;
}

message LayoutPortRefTerminalsConnectedMessage {
  bool is_connected = 1;
  repeated google.protobuf.StringValue error_ports = 2;
}

message GeometrySimplificationSettingsMessage {
  LayerRefPropertyMessage layout_layer = 1;
  ValueMessage tolerance = 2;
}

message GeometrySimplificationSettingsWithOptionMessage {
  GeometrySimplificationSettingsMessage geom_simplification_settings = 1;
  bool option = 2;
}

message ViaSimplificationSettingsMessage {
  GeometrySimplificationSettingsWithOptionMessage geom_simplification_settings_with_option = 1;
  bool simplification_method = 2;
}

message ViaGroupingSettingsMessage {
  ViaSimplificationSettingsMessage via_simplification_settings = 1;
  bool persistent = 2;
}

message ViaSnappingSettingsMessage {
  ViaSimplificationSettingsMessage via_simplification_settings = 1;
  ValueMessage prim_snapping_tol = 2;
}

message CreateMeshRegionMessage {
	EDBObjMessage layout = 1;
	ValueMessage xy_exp = 2;
	ValueMessage pos_z_exp = 3;
	ValueMessage neg_z_exp = 4;
	bool use_active_nets = 5;
	bool incl_ref = 6;
	GeometryExtentType ext = 7;
	uint64 num_x_partitions = 8;
	uint64 num_y_partitions = 9;
}