Generic considerations

Every EDA software has a different data model. Pcb-rnd's model is one of the most flexible ones. When an I/O plugin is written for pcb-rnd, it operates on the intersection (or overlap) of the two models. Very often some aspects of the other model is a subset of pcb-rnd's model.

The goal is to implement any import or export conversion in a way that most details are preserved. This document offers guidelines for that.

Import: thru-hole padstack

Decision tree, depending on what the other model offers:

1. highly restricted
	1.1. all layers have the same shape (e.g. gEDA/pcb)
		-> use pcb_pstk_new_compat_via()
	1.2. different shapes on different layers
		-> construct the padstack
2. generic 
	2.1. single hole, per layer type shapes
		-> construct the padstack
	2.2. multiple holes
		2.2.1. padstack is a terminal
			-> use heavy terminal instead
		2.2.2. padstack is a via
			-> split up to multiple objects; preferrably multiple padstacks
			   (e.g. pcb_pstk_vect2pstk())
			-> or convert to a subcircuit with a single heavy terminal
	2.3. non-round holes (slots)
		2.2.1. padstack is a terminal
			-> use heavy terminal
		2.2.2. padstack is a via
			-> split up to multiple objects; preferrably multiple padstacks
			   (e.g. pcb_pstk_vect2pstk())
			-> or convert to a subcircuit with a single heavy terminal

Import: smd padstack

Decision tree, depending on what the other model offers:

1. one shape per layer per layer type
	1.1. restricted model (e.g. paste implied)
		-> construct the padstack, reproduce all implications
	1.2. generic model (different shapes on different layers, e.g. mask != paste)
		-> construct the padstack, using the shapes provided
2. multiple shapes per layer type
	2.1. padstack is a terminal
		-> use heavy terminal
	2.2. padstack is not a terminal (shouldn't happen)
		-> convert to a subcircuit with a single heavy terminal

Import: footprints

Footprints shall be converted to subcircuits. Use padstacks for terminals wherever possible, revert to heavy terminal only if the input terminal can not be represented as a padstack.

If possible, reproduce the refdes or value text as well, using DYNTEXT. See also: pcb_subc_add_refdes_text()

Shall preserve rotation and offset info on the aux layer. See also: pcb_subc_create-aux().

Decision tree, depending on what the other model offers:

1. local lib of footprints, referencing
	-> not supported; instantiate each subcircuit as new
2. each footprint is a copy
	-> instantiate each subcircuit

Export: smd or thru-hole padstack

Decision tree, depending on what the other model offers:

1. highly restricted
	-> write a function that checks whether a padstack can be exported
	   example: pcb_pstk_export_compat_via()
	   On failure, throw an error, don't do partial conversion
2. generic
	-> construct the output padstack

Export: footprints

Decision tree, depending on what the other model offers:

1. local lib of footprints, referencing
	-> use the uid and a hash table to find out whether the subc is already in
	   the lib
2. each footprint is a copy
	-> export each subc