diff --git a/tests/fixtures/smtpad-bottom-layer.json b/tests/fixtures/smtpad-bottom-layer.json new file mode 100644 index 0000000..c01a521 --- /dev/null +++ b/tests/fixtures/smtpad-bottom-layer.json @@ -0,0 +1,788 @@ +[ + { + "type": "source_project_metadata", + "source_project_metadata_id": "source_project_metadata_0", + "software_used_string": "@tscircuit/core@0.0.801" + }, + { + "type": "source_group", + "source_group_id": "source_group_0", + "is_subcircuit": true, + "was_automatically_named": true, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_0", + "name": "pin1", + "pin_number": 1, + "port_hints": ["pin1", "anode", "pos", "left", "1"], + "source_component_id": "source_component_0", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_1", + "name": "pin2", + "pin_number": 2, + "port_hints": ["pin2", "cathode", "neg", "right", "2"], + "source_component_id": "source_component_0", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_component", + "source_component_id": "source_component_0", + "ftype": "simple_resistor", + "name": "U1", + "supplier_part_numbers": { + "jlcpcb": ["C25089", "C138031", "C162907"] + }, + "resistance": 20, + "display_resistance": "20Ω", + "are_pins_interchangeable": true, + "source_group_id": "source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_2", + "name": "pin1", + "pin_number": 1, + "port_hints": ["pin1", "anode", "pos", "left", "1"], + "source_component_id": "source_component_1", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_3", + "name": "pin2", + "pin_number": 2, + "port_hints": ["pin2", "cathode", "neg", "right", "2"], + "source_component_id": "source_component_1", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_component", + "source_component_id": "source_component_1", + "ftype": "simple_resistor", + "name": "U2", + "supplier_part_numbers": { + "jlcpcb": ["C25077", "C2906862", "C25139"] + }, + "resistance": 10, + "display_resistance": "10Ω", + "are_pins_interchangeable": true, + "source_group_id": "source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_4", + "name": "pin1", + "pin_number": 1, + "port_hints": ["pin1", "anode", "pos", "left", "1"], + "source_component_id": "source_component_2", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_5", + "name": "pin2", + "pin_number": 2, + "port_hints": ["pin2", "cathode", "neg", "right", "2"], + "source_component_id": "source_component_2", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_component", + "source_component_id": "source_component_2", + "ftype": "simple_resistor", + "name": "U3", + "supplier_part_numbers": { + "jlcpcb": ["C25077", "C2906862", "C25139"] + }, + "resistance": 10, + "display_resistance": "10Ω", + "are_pins_interchangeable": true, + "source_group_id": "source_group_0" + }, + { + "type": "source_board", + "source_board_id": "source_board_0", + "source_group_id": "source_group_0" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_0", + "message": "Port pin1 on U1 is missing a trace", + "source_component_id": "source_component_0", + "source_port_id": "source_port_0", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_1", + "message": "Port pin2 on U1 is missing a trace", + "source_component_id": "source_component_0", + "source_port_id": "source_port_1", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_2", + "message": "Port pin1 on U2 is missing a trace", + "source_component_id": "source_component_1", + "source_port_id": "source_port_2", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_3", + "message": "Port pin2 on U2 is missing a trace", + "source_component_id": "source_component_1", + "source_port_id": "source_port_3", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_4", + "message": "Port pin1 on U3 is missing a trace", + "source_component_id": "source_component_2", + "source_port_id": "source_port_4", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_5", + "message": "Port pin2 on U3 is missing a trace", + "source_component_id": "source_component_2", + "source_port_id": "source_port_5", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "schematic_component", + "schematic_component_id": "schematic_component_0", + "center": { + "x": 0, + "y": 0 + }, + "size": { + "width": 1.1, + "height": 0.388910699999999 + }, + "source_component_id": "source_component_0", + "is_box_with_pins": true, + "symbol_name": "boxresistor_right", + "symbol_display_value": "20Ω", + "schematic_group_id": "schematic_group_0" + }, + { + "type": "schematic_component", + "schematic_component_id": "schematic_component_1", + "center": { + "x": 0, + "y": -1.588910699999999 + }, + "size": { + "width": 1.1, + "height": 0.388910699999999 + }, + "source_component_id": "source_component_1", + "is_box_with_pins": true, + "symbol_name": "boxresistor_right", + "symbol_display_value": "10Ω", + "schematic_group_id": "schematic_group_0" + }, + { + "type": "schematic_component", + "schematic_component_id": "schematic_component_2", + "center": { + "x": 0, + "y": -3.177821399999998 + }, + "size": { + "width": 1.1, + "height": 0.388910699999999 + }, + "source_component_id": "source_component_2", + "is_box_with_pins": true, + "symbol_name": "boxresistor_right", + "symbol_display_value": "10Ω", + "schematic_group_id": "schematic_group_0" + }, + { + "type": "schematic_group", + "schematic_group_id": "schematic_group_0", + "is_subcircuit": true, + "subcircuit_id": "subcircuit_source_group_0", + "name": "unnamed_board1", + "center": { + "x": 0, + "y": 0 + }, + "width": 0, + "height": 0, + "schematic_component_ids": [], + "source_group_id": "source_group_0" + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_0", + "schematic_component_id": "schematic_component_0", + "center": { + "x": -0.55, + "y": 0 + }, + "source_port_id": "source_port_0", + "facing_direction": "left", + "distance_from_component_edge": 0.4, + "pin_number": 1, + "display_pin_label": "anode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_1", + "schematic_component_id": "schematic_component_0", + "center": { + "x": 0.55, + "y": 0 + }, + "source_port_id": "source_port_1", + "facing_direction": "right", + "distance_from_component_edge": 0.4, + "pin_number": 2, + "display_pin_label": "cathode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_2", + "schematic_component_id": "schematic_component_1", + "center": { + "x": -0.55, + "y": -1.588910699999999 + }, + "source_port_id": "source_port_2", + "facing_direction": "left", + "distance_from_component_edge": 0.4, + "pin_number": 1, + "display_pin_label": "anode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_3", + "schematic_component_id": "schematic_component_1", + "center": { + "x": 0.55, + "y": -1.588910699999999 + }, + "source_port_id": "source_port_3", + "facing_direction": "right", + "distance_from_component_edge": 0.4, + "pin_number": 2, + "display_pin_label": "cathode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_4", + "schematic_component_id": "schematic_component_2", + "center": { + "x": -0.55, + "y": -3.177821399999998 + }, + "source_port_id": "source_port_4", + "facing_direction": "left", + "distance_from_component_edge": 0.4, + "pin_number": 1, + "display_pin_label": "anode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_5", + "schematic_component_id": "schematic_component_2", + "center": { + "x": 0.55, + "y": -3.177821399999998 + }, + "source_port_id": "source_port_5", + "facing_direction": "right", + "distance_from_component_edge": 0.4, + "pin_number": 2, + "display_pin_label": "cathode", + "is_connected": false + }, + { + "type": "pcb_component", + "pcb_component_id": "pcb_component_0", + "center": { + "x": -3, + "y": 0 + }, + "width": 0.54, + "height": 1.6600000000000001, + "layer": "bottom", + "rotation": 90, + "source_component_id": "source_component_0", + "subcircuit_id": "subcircuit_source_group_0", + "do_not_place": false, + "obstructs_within_bounds": true + }, + { + "type": "pcb_component", + "pcb_component_id": "pcb_component_1", + "center": { + "x": 3, + "y": 0 + }, + "width": 1.5599999999999996, + "height": 0.6400000000000001, + "layer": "bottom", + "rotation": 180, + "source_component_id": "source_component_1", + "subcircuit_id": "subcircuit_source_group_0", + "do_not_place": false, + "obstructs_within_bounds": true + }, + { + "type": "pcb_component", + "pcb_component_id": "pcb_component_2", + "center": { + "x": 0, + "y": 0 + }, + "width": 0.5400000000000003, + "height": 1.6600000000000001, + "layer": "bottom", + "rotation": 270, + "source_component_id": "source_component_2", + "subcircuit_id": "subcircuit_source_group_0", + "do_not_place": false, + "obstructs_within_bounds": true + }, + { + "type": "pcb_board", + "pcb_board_id": "pcb_board_0", + "center": { + "x": 0, + "y": 0 + }, + "thickness": 1.4, + "num_layers": 2, + "width": 10, + "height": 10, + "material": "fr4" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_0", + "pcb_component_id": "pcb_component_0", + "pcb_port_id": "pcb_port_0", + "layer": "bottom", + "shape": "rect", + "width": 0.64, + "height": 0.54, + "port_hints": ["1", "left"], + "is_covered_with_solder_mask": false, + "x": -3, + "y": 0.51, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_0", + "layer": "bottom", + "shape": "rect", + "width": 0.44799999999999995, + "height": 0.378, + "x": -3, + "y": 0.51, + "pcb_component_id": "pcb_component_0", + "pcb_smtpad_id": "pcb_smtpad_0", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_1", + "pcb_component_id": "pcb_component_0", + "pcb_port_id": "pcb_port_1", + "layer": "bottom", + "shape": "rect", + "width": 0.64, + "height": 0.54, + "port_hints": ["2", "right"], + "is_covered_with_solder_mask": false, + "x": -3, + "y": -0.51, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_1", + "layer": "bottom", + "shape": "rect", + "width": 0.44799999999999995, + "height": 0.378, + "x": -3, + "y": -0.51, + "pcb_component_id": "pcb_component_0", + "pcb_smtpad_id": "pcb_smtpad_1", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_path", + "pcb_silkscreen_path_id": "pcb_silkscreen_path_0", + "pcb_component_id": "pcb_component_0", + "layer": "bottom", + "route": [ + { + "x": -3.7199999999999998, + "y": -0.51 + }, + { + "x": -3.7199999999999998, + "y": 0.98 + }, + { + "x": -2.28, + "y": 0.98 + }, + { + "x": -2.2800000000000002, + "y": -0.51 + } + ], + "stroke_width": 0.1, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_text", + "pcb_silkscreen_text_id": "pcb_silkscreen_text_0", + "anchor_alignment": "center", + "anchor_position": { + "x": -4.22, + "y": 7.470345474798854e-17 + }, + "font": "tscircuit2024", + "font_size": 0.4, + "layer": "bottom", + "text": "U1", + "ccw_rotation": 270, + "pcb_component_id": "pcb_component_0", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_2", + "pcb_component_id": "pcb_component_1", + "pcb_port_id": "pcb_port_2", + "layer": "bottom", + "shape": "rect", + "width": 0.54, + "height": 0.64, + "port_hints": ["1", "left"], + "is_covered_with_solder_mask": false, + "x": 2.49, + "y": 6.245698675651501e-17, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_2", + "layer": "bottom", + "shape": "rect", + "width": 0.378, + "height": 0.44799999999999995, + "x": 2.49, + "y": 6.245698675651501e-17, + "pcb_component_id": "pcb_component_1", + "pcb_smtpad_id": "pcb_smtpad_2", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_3", + "pcb_component_id": "pcb_component_1", + "pcb_port_id": "pcb_port_3", + "layer": "bottom", + "shape": "rect", + "width": 0.54, + "height": 0.64, + "port_hints": ["2", "right"], + "is_covered_with_solder_mask": false, + "x": 3.51, + "y": -6.245698675651501e-17, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_3", + "layer": "bottom", + "shape": "rect", + "width": 0.378, + "height": 0.44799999999999995, + "x": 3.51, + "y": -6.245698675651501e-17, + "pcb_component_id": "pcb_component_1", + "pcb_smtpad_id": "pcb_smtpad_3", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_path", + "pcb_silkscreen_path_id": "pcb_silkscreen_path_1", + "pcb_component_id": "pcb_component_1", + "layer": "bottom", + "route": [ + { + "x": 3.51, + "y": -0.7200000000000001 + }, + { + "x": 2.02, + "y": -0.7199999999999999 + }, + { + "x": 2.02, + "y": 0.7200000000000001 + }, + { + "x": 3.5100000000000002, + "y": 0.7199999999999999 + } + ], + "stroke_width": 0.1, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_text", + "pcb_silkscreen_text_id": "pcb_silkscreen_text_1", + "anchor_alignment": "center", + "anchor_position": { + "x": 3, + "y": -1.22 + }, + "font": "tscircuit2024", + "font_size": 0.4, + "layer": "bottom", + "text": "U2", + "ccw_rotation": 0, + "pcb_component_id": "pcb_component_1", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_4", + "pcb_component_id": "pcb_component_2", + "pcb_port_id": "pcb_port_4", + "layer": "bottom", + "shape": "rect", + "width": 0.64, + "height": 0.54, + "port_hints": ["1", "left"], + "is_covered_with_solder_mask": false, + "x": -9.368548013477251e-17, + "y": -0.51, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_4", + "layer": "bottom", + "shape": "rect", + "width": 0.44799999999999995, + "height": 0.378, + "x": -9.368548013477251e-17, + "y": -0.51, + "pcb_component_id": "pcb_component_2", + "pcb_smtpad_id": "pcb_smtpad_4", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_5", + "pcb_component_id": "pcb_component_2", + "pcb_port_id": "pcb_port_5", + "layer": "bottom", + "shape": "rect", + "width": 0.64, + "height": 0.54, + "port_hints": ["2", "right"], + "is_covered_with_solder_mask": false, + "x": 9.368548013477251e-17, + "y": 0.51, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_5", + "layer": "bottom", + "shape": "rect", + "width": 0.44799999999999995, + "height": 0.378, + "x": 9.368548013477251e-17, + "y": 0.51, + "pcb_component_id": "pcb_component_2", + "pcb_smtpad_id": "pcb_smtpad_5", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_path", + "pcb_silkscreen_path_id": "pcb_silkscreen_path_2", + "pcb_component_id": "pcb_component_2", + "layer": "bottom", + "route": [ + { + "x": 0.7200000000000001, + "y": 0.5099999999999999 + }, + { + "x": 0.7199999999999998, + "y": -0.9800000000000001 + }, + { + "x": -0.7200000000000002, + "y": -0.9799999999999999 + }, + { + "x": -0.7199999999999999, + "y": 0.5100000000000001 + } + ], + "stroke_width": 0.1, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_text", + "pcb_silkscreen_text_id": "pcb_silkscreen_text_2", + "anchor_alignment": "center", + "anchor_position": { + "x": 1.22, + "y": -2.241103642439656e-16 + }, + "font": "tscircuit2024", + "font_size": 0.4, + "layer": "bottom", + "text": "U3", + "ccw_rotation": 90, + "pcb_component_id": "pcb_component_2", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_0", + "pcb_component_id": "pcb_component_0", + "layers": ["bottom"], + "subcircuit_id": "subcircuit_source_group_0", + "x": -3, + "y": 0.51, + "source_port_id": "source_port_0" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_1", + "pcb_component_id": "pcb_component_0", + "layers": ["bottom"], + "subcircuit_id": "subcircuit_source_group_0", + "x": -3, + "y": -0.51, + "source_port_id": "source_port_1" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_2", + "pcb_component_id": "pcb_component_1", + "layers": ["bottom"], + "subcircuit_id": "subcircuit_source_group_0", + "x": 2.49, + "y": 6.245698675651501e-17, + "source_port_id": "source_port_2" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_3", + "pcb_component_id": "pcb_component_1", + "layers": ["bottom"], + "subcircuit_id": "subcircuit_source_group_0", + "x": 3.51, + "y": -6.245698675651501e-17, + "source_port_id": "source_port_3" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_4", + "pcb_component_id": "pcb_component_2", + "layers": ["bottom"], + "subcircuit_id": "subcircuit_source_group_0", + "x": -9.368548013477251e-17, + "y": -0.51, + "source_port_id": "source_port_4" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_5", + "pcb_component_id": "pcb_component_2", + "layers": ["bottom"], + "subcircuit_id": "subcircuit_source_group_0", + "x": 9.368548013477251e-17, + "y": 0.51, + "source_port_id": "source_port_5" + }, + { + "type": "cad_component", + "cad_component_id": "cad_component_0", + "position": { + "x": -3, + "y": 0, + "z": -0.7 + }, + "rotation": { + "x": 0, + "y": 180, + "z": 0 + }, + "pcb_component_id": "pcb_component_0", + "source_component_id": "source_component_0", + "footprinter_string": "0402" + }, + { + "type": "cad_component", + "cad_component_id": "cad_component_1", + "position": { + "x": 3, + "y": 0, + "z": -0.7 + }, + "rotation": { + "x": 0, + "y": 180, + "z": 180 + }, + "pcb_component_id": "pcb_component_1", + "source_component_id": "source_component_1", + "footprinter_string": "0402" + }, + { + "type": "cad_component", + "cad_component_id": "cad_component_2", + "position": { + "x": 0, + "y": 0, + "z": -0.7 + }, + "rotation": { + "x": 0, + "y": 180, + "z": 0 + }, + "pcb_component_id": "pcb_component_2", + "source_component_id": "source_component_2", + "footprinter_string": "0402" + } +] diff --git a/tests/fixtures/smtpad-top-layer.json b/tests/fixtures/smtpad-top-layer.json new file mode 100644 index 0000000..020e4a5 --- /dev/null +++ b/tests/fixtures/smtpad-top-layer.json @@ -0,0 +1,788 @@ +[ + { + "type": "source_project_metadata", + "source_project_metadata_id": "source_project_metadata_0", + "software_used_string": "@tscircuit/core@0.0.801" + }, + { + "type": "source_group", + "source_group_id": "source_group_0", + "is_subcircuit": true, + "was_automatically_named": true, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_0", + "name": "pin1", + "pin_number": 1, + "port_hints": ["pin1", "anode", "pos", "left", "1"], + "source_component_id": "source_component_0", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_1", + "name": "pin2", + "pin_number": 2, + "port_hints": ["pin2", "cathode", "neg", "right", "2"], + "source_component_id": "source_component_0", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_component", + "source_component_id": "source_component_0", + "ftype": "simple_resistor", + "name": "U1", + "supplier_part_numbers": { + "jlcpcb": ["C25089", "C138031", "C162907"] + }, + "resistance": 20, + "display_resistance": "20Ω", + "are_pins_interchangeable": true, + "source_group_id": "source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_2", + "name": "pin1", + "pin_number": 1, + "port_hints": ["pin1", "anode", "pos", "left", "1"], + "source_component_id": "source_component_1", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_3", + "name": "pin2", + "pin_number": 2, + "port_hints": ["pin2", "cathode", "neg", "right", "2"], + "source_component_id": "source_component_1", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_component", + "source_component_id": "source_component_1", + "ftype": "simple_resistor", + "name": "U2", + "supplier_part_numbers": { + "jlcpcb": ["C25077", "C2906862", "C25139"] + }, + "resistance": 10, + "display_resistance": "10Ω", + "are_pins_interchangeable": true, + "source_group_id": "source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_4", + "name": "pin1", + "pin_number": 1, + "port_hints": ["pin1", "anode", "pos", "left", "1"], + "source_component_id": "source_component_2", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_port", + "source_port_id": "source_port_5", + "name": "pin2", + "pin_number": 2, + "port_hints": ["pin2", "cathode", "neg", "right", "2"], + "source_component_id": "source_component_2", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "source_component", + "source_component_id": "source_component_2", + "ftype": "simple_resistor", + "name": "U3", + "supplier_part_numbers": { + "jlcpcb": ["C25077", "C2906862", "C25139"] + }, + "resistance": 10, + "display_resistance": "10Ω", + "are_pins_interchangeable": true, + "source_group_id": "source_group_0" + }, + { + "type": "source_board", + "source_board_id": "source_board_0", + "source_group_id": "source_group_0" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_0", + "message": "Port pin1 on U1 is missing a trace", + "source_component_id": "source_component_0", + "source_port_id": "source_port_0", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_1", + "message": "Port pin2 on U1 is missing a trace", + "source_component_id": "source_component_0", + "source_port_id": "source_port_1", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_2", + "message": "Port pin1 on U2 is missing a trace", + "source_component_id": "source_component_1", + "source_port_id": "source_port_2", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_3", + "message": "Port pin2 on U2 is missing a trace", + "source_component_id": "source_component_1", + "source_port_id": "source_port_3", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_4", + "message": "Port pin1 on U3 is missing a trace", + "source_component_id": "source_component_2", + "source_port_id": "source_port_4", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "source_pin_missing_trace_warning", + "source_pin_missing_trace_warning_id": "source_pin_missing_trace_warning_5", + "message": "Port pin2 on U3 is missing a trace", + "source_component_id": "source_component_2", + "source_port_id": "source_port_5", + "subcircuit_id": "subcircuit_source_group_0", + "warning_type": "source_pin_missing_trace_warning" + }, + { + "type": "schematic_component", + "schematic_component_id": "schematic_component_0", + "center": { + "x": 0, + "y": 0 + }, + "size": { + "width": 1.1, + "height": 0.388910699999999 + }, + "source_component_id": "source_component_0", + "is_box_with_pins": true, + "symbol_name": "boxresistor_right", + "symbol_display_value": "20Ω", + "schematic_group_id": "schematic_group_0" + }, + { + "type": "schematic_component", + "schematic_component_id": "schematic_component_1", + "center": { + "x": 0, + "y": -1.588910699999999 + }, + "size": { + "width": 1.1, + "height": 0.388910699999999 + }, + "source_component_id": "source_component_1", + "is_box_with_pins": true, + "symbol_name": "boxresistor_right", + "symbol_display_value": "10Ω", + "schematic_group_id": "schematic_group_0" + }, + { + "type": "schematic_component", + "schematic_component_id": "schematic_component_2", + "center": { + "x": 0, + "y": -3.177821399999998 + }, + "size": { + "width": 1.1, + "height": 0.388910699999999 + }, + "source_component_id": "source_component_2", + "is_box_with_pins": true, + "symbol_name": "boxresistor_right", + "symbol_display_value": "10Ω", + "schematic_group_id": "schematic_group_0" + }, + { + "type": "schematic_group", + "schematic_group_id": "schematic_group_0", + "is_subcircuit": true, + "subcircuit_id": "subcircuit_source_group_0", + "name": "unnamed_board1", + "center": { + "x": 0, + "y": 0 + }, + "width": 0, + "height": 0, + "schematic_component_ids": [], + "source_group_id": "source_group_0" + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_0", + "schematic_component_id": "schematic_component_0", + "center": { + "x": -0.55, + "y": 0 + }, + "source_port_id": "source_port_0", + "facing_direction": "left", + "distance_from_component_edge": 0.4, + "pin_number": 1, + "display_pin_label": "anode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_1", + "schematic_component_id": "schematic_component_0", + "center": { + "x": 0.55, + "y": 0 + }, + "source_port_id": "source_port_1", + "facing_direction": "right", + "distance_from_component_edge": 0.4, + "pin_number": 2, + "display_pin_label": "cathode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_2", + "schematic_component_id": "schematic_component_1", + "center": { + "x": -0.55, + "y": -1.588910699999999 + }, + "source_port_id": "source_port_2", + "facing_direction": "left", + "distance_from_component_edge": 0.4, + "pin_number": 1, + "display_pin_label": "anode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_3", + "schematic_component_id": "schematic_component_1", + "center": { + "x": 0.55, + "y": -1.588910699999999 + }, + "source_port_id": "source_port_3", + "facing_direction": "right", + "distance_from_component_edge": 0.4, + "pin_number": 2, + "display_pin_label": "cathode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_4", + "schematic_component_id": "schematic_component_2", + "center": { + "x": -0.55, + "y": -3.177821399999998 + }, + "source_port_id": "source_port_4", + "facing_direction": "left", + "distance_from_component_edge": 0.4, + "pin_number": 1, + "display_pin_label": "anode", + "is_connected": false + }, + { + "type": "schematic_port", + "schematic_port_id": "schematic_port_5", + "schematic_component_id": "schematic_component_2", + "center": { + "x": 0.55, + "y": -3.177821399999998 + }, + "source_port_id": "source_port_5", + "facing_direction": "right", + "distance_from_component_edge": 0.4, + "pin_number": 2, + "display_pin_label": "cathode", + "is_connected": false + }, + { + "type": "pcb_component", + "pcb_component_id": "pcb_component_0", + "center": { + "x": -3, + "y": 0 + }, + "width": 0.54, + "height": 1.6600000000000001, + "layer": "top", + "rotation": 90, + "source_component_id": "source_component_0", + "subcircuit_id": "subcircuit_source_group_0", + "do_not_place": false, + "obstructs_within_bounds": true + }, + { + "type": "pcb_component", + "pcb_component_id": "pcb_component_1", + "center": { + "x": 3, + "y": 0 + }, + "width": 1.5599999999999996, + "height": 0.6400000000000001, + "layer": "top", + "rotation": 180, + "source_component_id": "source_component_1", + "subcircuit_id": "subcircuit_source_group_0", + "do_not_place": false, + "obstructs_within_bounds": true + }, + { + "type": "pcb_component", + "pcb_component_id": "pcb_component_2", + "center": { + "x": 0, + "y": 0 + }, + "width": 0.5400000000000003, + "height": 1.6600000000000001, + "layer": "top", + "rotation": 270, + "source_component_id": "source_component_2", + "subcircuit_id": "subcircuit_source_group_0", + "do_not_place": false, + "obstructs_within_bounds": true + }, + { + "type": "pcb_board", + "pcb_board_id": "pcb_board_0", + "center": { + "x": 0, + "y": 0 + }, + "thickness": 1.4, + "num_layers": 2, + "width": 10, + "height": 10, + "material": "fr4" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_0", + "pcb_component_id": "pcb_component_0", + "pcb_port_id": "pcb_port_0", + "layer": "top", + "shape": "rect", + "width": 0.64, + "height": 0.54, + "port_hints": ["1", "left"], + "is_covered_with_solder_mask": false, + "x": -3, + "y": -0.51, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_0", + "layer": "top", + "shape": "rect", + "width": 0.44799999999999995, + "height": 0.378, + "x": -3, + "y": -0.51, + "pcb_component_id": "pcb_component_0", + "pcb_smtpad_id": "pcb_smtpad_0", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_1", + "pcb_component_id": "pcb_component_0", + "pcb_port_id": "pcb_port_1", + "layer": "top", + "shape": "rect", + "width": 0.64, + "height": 0.54, + "port_hints": ["2", "right"], + "is_covered_with_solder_mask": false, + "x": -3, + "y": 0.51, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_1", + "layer": "top", + "shape": "rect", + "width": 0.44799999999999995, + "height": 0.378, + "x": -3, + "y": 0.51, + "pcb_component_id": "pcb_component_0", + "pcb_smtpad_id": "pcb_smtpad_1", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_path", + "pcb_silkscreen_path_id": "pcb_silkscreen_path_0", + "pcb_component_id": "pcb_component_0", + "layer": "top", + "route": [ + { + "x": -3.7199999999999998, + "y": 0.51 + }, + { + "x": -3.72, + "y": -0.98 + }, + { + "x": -2.2800000000000002, + "y": -0.98 + }, + { + "x": -2.2800000000000002, + "y": 0.51 + } + ], + "stroke_width": 0.1, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_text", + "pcb_silkscreen_text_id": "pcb_silkscreen_text_0", + "anchor_alignment": "center", + "anchor_position": { + "x": -4.22, + "y": 7.470345474798854e-17 + }, + "font": "tscircuit2024", + "font_size": 0.4, + "layer": "top", + "text": "U1", + "ccw_rotation": 90, + "pcb_component_id": "pcb_component_0", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_2", + "pcb_component_id": "pcb_component_1", + "pcb_port_id": "pcb_port_2", + "layer": "top", + "shape": "rect", + "width": 0.54, + "height": 0.64, + "port_hints": ["1", "left"], + "is_covered_with_solder_mask": false, + "x": 3.51, + "y": -6.245698675651501e-17, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_2", + "layer": "top", + "shape": "rect", + "width": 0.378, + "height": 0.44799999999999995, + "x": 3.51, + "y": -6.245698675651501e-17, + "pcb_component_id": "pcb_component_1", + "pcb_smtpad_id": "pcb_smtpad_2", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_3", + "pcb_component_id": "pcb_component_1", + "pcb_port_id": "pcb_port_3", + "layer": "top", + "shape": "rect", + "width": 0.54, + "height": 0.64, + "port_hints": ["2", "right"], + "is_covered_with_solder_mask": false, + "x": 2.49, + "y": 6.245698675651501e-17, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_3", + "layer": "top", + "shape": "rect", + "width": 0.378, + "height": 0.44799999999999995, + "x": 2.49, + "y": 6.245698675651501e-17, + "pcb_component_id": "pcb_component_1", + "pcb_smtpad_id": "pcb_smtpad_3", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_path", + "pcb_silkscreen_path_id": "pcb_silkscreen_path_1", + "pcb_component_id": "pcb_component_1", + "layer": "top", + "route": [ + { + "x": 2.4899999999999998, + "y": -0.7199999999999999 + }, + { + "x": 3.98, + "y": -0.7200000000000001 + }, + { + "x": 3.98, + "y": 0.7199999999999999 + }, + { + "x": 2.49, + "y": 0.7200000000000001 + } + ], + "stroke_width": 0.1, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_text", + "pcb_silkscreen_text_id": "pcb_silkscreen_text_1", + "anchor_alignment": "center", + "anchor_position": { + "x": 3, + "y": -1.22 + }, + "font": "tscircuit2024", + "font_size": 0.4, + "layer": "top", + "text": "U2", + "ccw_rotation": 180, + "pcb_component_id": "pcb_component_1", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_4", + "pcb_component_id": "pcb_component_2", + "pcb_port_id": "pcb_port_4", + "layer": "top", + "shape": "rect", + "width": 0.64, + "height": 0.54, + "port_hints": ["1", "left"], + "is_covered_with_solder_mask": false, + "x": 9.368548013477251e-17, + "y": 0.51, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_4", + "layer": "top", + "shape": "rect", + "width": 0.44799999999999995, + "height": 0.378, + "x": 9.368548013477251e-17, + "y": 0.51, + "pcb_component_id": "pcb_component_2", + "pcb_smtpad_id": "pcb_smtpad_4", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_smtpad", + "pcb_smtpad_id": "pcb_smtpad_5", + "pcb_component_id": "pcb_component_2", + "pcb_port_id": "pcb_port_5", + "layer": "top", + "shape": "rect", + "width": 0.64, + "height": 0.54, + "port_hints": ["2", "right"], + "is_covered_with_solder_mask": false, + "x": -9.368548013477251e-17, + "y": -0.51, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_solder_paste", + "pcb_solder_paste_id": "pcb_solder_paste_5", + "layer": "top", + "shape": "rect", + "width": 0.44799999999999995, + "height": 0.378, + "x": -9.368548013477251e-17, + "y": -0.51, + "pcb_component_id": "pcb_component_2", + "pcb_smtpad_id": "pcb_smtpad_5", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_path", + "pcb_silkscreen_path_id": "pcb_silkscreen_path_2", + "pcb_component_id": "pcb_component_2", + "layer": "top", + "route": [ + { + "x": 0.7199999999999999, + "y": -0.5100000000000001 + }, + { + "x": 0.7200000000000002, + "y": 0.9799999999999999 + }, + { + "x": -0.7199999999999998, + "y": 0.9800000000000001 + }, + { + "x": -0.7200000000000001, + "y": -0.5099999999999999 + } + ], + "stroke_width": 0.1, + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_silkscreen_text", + "pcb_silkscreen_text_id": "pcb_silkscreen_text_2", + "anchor_alignment": "center", + "anchor_position": { + "x": 1.22, + "y": -2.241103642439656e-16 + }, + "font": "tscircuit2024", + "font_size": 0.4, + "layer": "top", + "text": "U3", + "ccw_rotation": 270, + "pcb_component_id": "pcb_component_2", + "subcircuit_id": "subcircuit_source_group_0" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_0", + "pcb_component_id": "pcb_component_0", + "layers": ["top"], + "subcircuit_id": "subcircuit_source_group_0", + "x": -3, + "y": -0.51, + "source_port_id": "source_port_0" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_1", + "pcb_component_id": "pcb_component_0", + "layers": ["top"], + "subcircuit_id": "subcircuit_source_group_0", + "x": -3, + "y": 0.51, + "source_port_id": "source_port_1" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_2", + "pcb_component_id": "pcb_component_1", + "layers": ["top"], + "subcircuit_id": "subcircuit_source_group_0", + "x": 3.51, + "y": -6.245698675651501e-17, + "source_port_id": "source_port_2" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_3", + "pcb_component_id": "pcb_component_1", + "layers": ["top"], + "subcircuit_id": "subcircuit_source_group_0", + "x": 2.49, + "y": 6.245698675651501e-17, + "source_port_id": "source_port_3" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_4", + "pcb_component_id": "pcb_component_2", + "layers": ["top"], + "subcircuit_id": "subcircuit_source_group_0", + "x": 9.368548013477251e-17, + "y": 0.51, + "source_port_id": "source_port_4" + }, + { + "type": "pcb_port", + "pcb_port_id": "pcb_port_5", + "pcb_component_id": "pcb_component_2", + "layers": ["top"], + "subcircuit_id": "subcircuit_source_group_0", + "x": -9.368548013477251e-17, + "y": -0.51, + "source_port_id": "source_port_5" + }, + { + "type": "cad_component", + "cad_component_id": "cad_component_0", + "position": { + "x": -3, + "y": 0, + "z": 0.7 + }, + "rotation": { + "x": 0, + "y": 0, + "z": 180 + }, + "pcb_component_id": "pcb_component_0", + "source_component_id": "source_component_0", + "footprinter_string": "0402" + }, + { + "type": "cad_component", + "cad_component_id": "cad_component_1", + "position": { + "x": 3, + "y": 0, + "z": 0.7 + }, + "rotation": { + "x": 0, + "y": 0, + "z": 0 + }, + "pcb_component_id": "pcb_component_1", + "source_component_id": "source_component_1", + "footprinter_string": "0402" + }, + { + "type": "cad_component", + "cad_component_id": "cad_component_2", + "position": { + "x": 0, + "y": 0, + "z": 0.7 + }, + "rotation": { + "x": 0, + "y": 0, + "z": 180 + }, + "pcb_component_id": "pcb_component_2", + "source_component_id": "source_component_2", + "footprinter_string": "0402" + } +] diff --git a/tests/repro/__snapshots__/bottom-layer-components-bottom-view.snap.png b/tests/repro/__snapshots__/bottom-layer-components-bottom-view.snap.png new file mode 100644 index 0000000..d0a0570 Binary files /dev/null and b/tests/repro/__snapshots__/bottom-layer-components-bottom-view.snap.png differ diff --git a/tests/repro/__snapshots__/top-layer-components-top-view.snap.png b/tests/repro/__snapshots__/top-layer-components-top-view.snap.png new file mode 100644 index 0000000..21b6750 Binary files /dev/null and b/tests/repro/__snapshots__/top-layer-components-top-view.snap.png differ diff --git a/tests/repro/repro1-smtpad-bottom-layer.test.ts b/tests/repro/repro1-smtpad-bottom-layer.test.ts new file mode 100644 index 0000000..8f05d10 --- /dev/null +++ b/tests/repro/repro1-smtpad-bottom-layer.test.ts @@ -0,0 +1,42 @@ +import { test, expect } from "bun:test" +import { renderGLTFToPNGBufferFromGLBBuffer } from "poppygl" +import { convertCircuitJsonToGltf } from "../../lib/index" +import type { CircuitJson } from "circuit-json" +import * as fs from "node:fs" +import * as path from "node:path" + +test("bottom-layer-components-bottom-view", async () => { + const bottomLayerPath = path.join( + __dirname, + "../fixtures/smtpad-bottom-layer.json", + ) + + const circuitData = fs.readFileSync(bottomLayerPath, "utf-8") + const circuitJson: CircuitJson = JSON.parse(circuitData) + + // Convert circuit to GLTF (GLB format for rendering) + const glbResult = await convertCircuitJsonToGltf(circuitJson, { + format: "glb", + boardTextureResolution: 512, + includeModels: true, + showBoundingBoxes: false, + }) + + // Ensure we got a valid GLB buffer + expect(glbResult).toBeInstanceOf(ArrayBuffer) + expect((glbResult as ArrayBuffer).byteLength).toBeGreaterThan(0) + + // Custom camera to view from BELOW the board + const cameraOptions = { + position: { x: 15, y: -15, z: -15 }, // Position below and to the side + target: { x: 0, y: 0, z: 0 }, // Look at board center + up: { x: 0, y: 1, z: 0 }, + fov: 50, + width: 800, + height: 600, + } + + expect( + renderGLTFToPNGBufferFromGLBBuffer(glbResult as ArrayBuffer, cameraOptions), + ).toMatchPngSnapshot(import.meta.path, "bottom-layer-components-bottom-view") +}) diff --git a/tests/repro/repro2-smtpad-top-layer.test.ts b/tests/repro/repro2-smtpad-top-layer.test.ts new file mode 100644 index 0000000..022b45c --- /dev/null +++ b/tests/repro/repro2-smtpad-top-layer.test.ts @@ -0,0 +1,39 @@ +import { test, expect } from "bun:test" +import { renderGLTFToPNGBufferFromGLBBuffer } from "poppygl" +import { convertCircuitJsonToGltf } from "../../lib/index" +import type { CircuitJson } from "circuit-json" +import * as fs from "node:fs" +import * as path from "node:path" + +test("top-layer-components-top-view", async () => { + const topLayerPath = path.join(__dirname, "../fixtures/smtpad-top-layer.json") + + const circuitData = fs.readFileSync(topLayerPath, "utf-8") + const circuitJson: CircuitJson = JSON.parse(circuitData) + + // Convert circuit to GLTF (GLB format for rendering) + const glbResult = await convertCircuitJsonToGltf(circuitJson, { + format: "glb", + boardTextureResolution: 512, + includeModels: true, + showBoundingBoxes: false, + }) + + // Ensure we got a valid GLB buffer + expect(glbResult).toBeInstanceOf(ArrayBuffer) + expect((glbResult as ArrayBuffer).byteLength).toBeGreaterThan(0) + + // Custom camera to view from BELOW the board + const cameraOptions = { + position: { x: 15, y: -15, z: 15 }, // Position below and to the side + target: { x: 0, y: 0, z: 0 }, // Look at board center + up: { x: 0, y: 1, z: 0 }, + fov: 50, + width: 800, + height: 600, + } + + expect( + renderGLTFToPNGBufferFromGLBBuffer(glbResult as ArrayBuffer, cameraOptions), + ).toMatchPngSnapshot(import.meta.path, "top-layer-components-top-view") +})