<?xl version="0.1" encoding="Shift-JIS" ?>

<Export target="netmapper">

<Define> ^arg1 (Local (Arg 1)) </Define>

<Define> ^map (NewEnvironment (CurrentEnvironment)) </Define>

<Define> ^map-in-default () </Define>

<Define> ^target-ptr () </Define>
<Define> ^src-ptr () </Define>

<map type="raw">

<DefineDefault Order="Normal"> ^sym
	<set> ^map-in-default (cons sym map-in-default) </set>
</DefineDefault>

<Define> ^point-map ()
<Arguments>
	^n ^p1 ^p2
</Arguments>
<Sequence> ()
	<set> ^target-ptr (cons (List p1 p2) target-ptr) </set>
	<set> ^src-ptr (cons p1 src-ptr) </set>
</Sequence>
</Define>

</map>

<Load option="exec"> ^arg1 </Load>

<Define> ^output (+ (CutString arg1 0
		(- (StringLength arg1) 4))
		".map")
</Define>

<Define> ^map-in-default (Reverse map-in-default) </Define>
<Define> ^target-ptr (Reverse target-ptr) </Define>

^map-in-default

^target-ptr

<Define> ^a (AffenFitter target-ptr) </Define>

<Define> ^aa
	<List> ^'horizontal-affen
			(List 'List
				(cons 'List (GE (GE a 0) 0))
				(cons 'List (GE (GE a 0) 1)))
			(cons 'List (GE a 1))
	</List>
</Define>

<Define> ^mr (MinimumRectangle src-ptr) </Define>

<Define> ^width
	(- (GE (GE mr 1) 0)
		(GE (GE mr 0) 0))
</Define>

<Define> ^height
	(- (GE (GE mr 1) 1)
		(GE (GE mr 0) 1))
</Define>

<Define> ^ins1 (List
		(- (GE (GE mr 0) 0) (* width 2))
		(- (GE (GE mr 0) 1) (* height 2)))
</Define>

<Define> ^ins2 (List
		(+ (GE (GE mr 1) 0) (* width 2))
		(- (GE (GE mr 0) 1) (* height 2)))
</Define>

<Define> ^ins3 (List
		(+ (GE (GE mr 1) 0) (* width 2))
		(+ (GE (GE mr 1) 1) (* height 2)))
</Define>

<Define> ^ins4 (List
		(- (GE (GE mr 0) 0) (* width 2))
		(+ (GE (GE mr 1) 1) (* height 2)))
</Define>

<Define> ^co-ins1 (List ins1 (ApplyAffen a ins1)) </Define>
<Define> ^co-ins2 (List ins2 (ApplyAffen a ins2)) </Define>
<Define> ^co-ins3 (List ins3 (ApplyAffen a ins3)) </Define>
<Define> ^co-ins4 (List ins4 (ApplyAffen a ins4)) </Define>


<Define> ^target-ptr
		(cons co-ins1
		(cons co-ins2
		(cons co-ins3
		(cons co-ins4
			target-ptr))))
</Define>



<Save	oflag="creat:trunc" mode="0644"
	option="xl"
	format.mode="xml"
	format.indent="on"
	format.multiroot="off"
	format.text="off"
	encoding="Shift_JIS">
	^output
	(cons 'map
	(append map-in-default
		(append <List> ^aa </List>
		(GenMap  ()
			target-ptr))))
</Save>

</Export>
