% Remember to use the lgrind style

\Head{}
\File{A1\_i.pas}{2006}{4}{24}{17:52}{37685}
\L{\LB{\K{unit}_\V{a1\_i};}}
\L{\LB{}}
\L{\LB{\K{interface}}}
\L{\LB{}}
\L{\LB{\K{uses}}}
\L{\LB{}\Tab{2}{\V{Windows},_\V{Messages},_\V{SysUtils},_\V{Classes},_\V{Graphics},_\V{Controls},_\V{Forms},_\V{Dialogs},}}
\L{\LB{}\Tab{2}{\V{StdCtrls},_\V{ExtCtrls},\V{math},_\V{ComCtrls};}}
\L{\LB{}}
\L{\LB{\K{const}_\V{inf}=\N{1.0}/\N{0.0};}}
\L{\LB{}\Tab{6}{\V{epsilon}=\N{1e}\-\N{10};}\Tab{31}{\C{}//Kleinste_berücksichtigte_Differenz\CE{}}}
\L{\LB{\K{type}}}
\L{\LB{}\Tab{2}{\V{ppointf}=\5\V{tpointf};}}
\L{\LB{}\Tab{2}{\V{tpointf}=\K{record}}\Tab{31}{\C{}//Ein_Punkt_des_Museums\CE{}}}
\L{\LB{}\Tab{4}{\V{x},\V{y}:_\V{double};}\Tab{31}{\C{}//Seine_Koordinten\CE{}}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{}\Tab{2}{\V{TSeenPos}=\K{record}}\Tab{31}{\C{}//Eine_sichtbarer_Punkt_auf_einer_Linie\CE{}}}
\L{\LB{}\Tab{6}{\V{where}:_\V{double}}\Tab{24}{;}\Tab{35}{\C{}//Position_auf_der_Linie_(0:_Start,_1:_Ende)\CE{}}}
\L{\LB{}\Tab{6}{\V{seeRight}:_\V{boolean};}\Tab{31}{\C{}//liegt_das_Segment_in_Richtung_Ende\CE{}}}
\L{\LB{}\Tab{6}{\V{hiddenRaySide}:_\V{integer};}\Tab{31}{\C{}//begrenzte_Seite_des_Strahl_zu_diesem_Punkt\CE{}}}
\L{\LB{}\Tab{6}{\V{from},\V{wherePos}:\V{tpointf};}\Tab{31}{\C{}//Strahlstartposition_und_getroffener_Punkt\CE{}}}
\L{\LB{}\Tab{4}{\K{end};}}
\L{\LB{}\Tab{2}{\V{TSeenArray}=\K{array}_\K{of}_\V{TSeenPos};\C{}//Mehrere_getroffene_Punkte_(wird_sortiert)\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{PLine}=\5\V{TLine};}}
\L{\LB{}\Tab{2}{\V{TLine}=\K{record}}}
\L{\LB{}\Tab{4}{\V{start}:_\V{tpointf};}\Tab{31}{\C{}//Startpunkt_der_Linie\CE{}}}
\L{\LB{}\Tab{4}{\V{dir}:_\V{tpointf};}\Tab{31}{\C{}//Richtung_der_Linie\CE{}}}
\L{\LB{}\Tab{4}{\V{left},\V{right}:\V{PLine};}\Tab{31}{\C{}//vorherige_und_nächste_Linie\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\V{sees}:\K{array}_\K{of}_\V{TSeenPos};}\Tab{31}{\C{}//auf_der_Linie_getroffene_Punkte\CE{}}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{}\Tab{2}{\V{TPolygon}=\K{array}_\K{of}_\V{TLine};}\Tab{31}{\C{}//Ein_Polygon_=_eine_Liniefolge\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{TRayHitPoints}=\K{record}}\Tab{31}{\C{}//Informationen_über_die_Treffpunkte_eines_Strahls\CE{}}}
\L{\LB{}\Tab{4}{\V{poly},_\V{line}:_\V{integer};}\Tab{31}{\C{}//Getroffenes_Polygon_und_dort_getroffene_Linie\CE{}}}
\L{\LB{}\Tab{4}{\V{where},_\V{when}:_\V{double};}\Tab{31}{\C{}//Position_des_Treffpunktes_auf_dem_Strahl_und_der_Linie\CE{}}}
\L{\LB{}\Tab{4}{\V{between}:_\K{array}_\K{of}_\K{record}}\Tab{38}{\C{}//Passierte_Ecken\CE{}}}
\L{\LB{}\Tab{15}{\V{poly},_\V{point}:_\V{integer};}\Tab{38}{\C{}//getroffenes_Polygon_und_getroffener_Punkt\CE{}}}
\L{\LB{}\Tab{15}{\V{side}:_\V{integer};}\Tab{38}{\C{}//Seite_der_Eckpunkte_(beide_sind_auf_derselben)\CE{}}}
\L{\LB{}\Tab{15}{\V{when}:_\V{double};}\Tab{38}{\C{}//Position_auf_dem_Strahl\CE{}}}
\L{\LB{}\Tab{13}{\K{end};}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{}\Tab{2}{\V{TmuseumForm}_=_\V{class}(\V{TForm})}}
\L{\LB{}\Tab{4}{\V{Panel1}:_\V{TPanel};}}
\L{\LB{}\Tab{4}{\V{outputPaintBox}:_\V{TPaintBox};}}
\L{\LB{}\Tab{4}{\V{Label1}:_\V{TLabel};}}
\L{\LB{}\Tab{4}{\V{museumFileName}:_\V{TEdit};}}
\L{\LB{}\Tab{4}{\V{loadMuseum}:_\V{TButton};}}
\L{\LB{}\Tab{4}{\V{Label2}:_\V{TLabel};}}
\L{\LB{}\Tab{4}{\V{wayFileName}:_\V{TEdit};}}
\L{\LB{}\Tab{4}{\V{loadWay}:_\V{TButton};}}
\L{\LB{}\Tab{4}{\V{fillSeenAreas}:_\V{TCheckBox};}}
\L{\LB{}\Tab{4}{\V{drawBorderedSeenAreas}:_\V{TCheckBox};}}
\L{\LB{}\Tab{4}{\V{loadWayProbability}:_\V{TButton};}}
\L{\LB{}\Tab{4}{\V{Label3}:_\V{TLabel};}}
\L{\LB{}\Tab{4}{\V{wayProbabilityFileName}:_\V{TEdit};}}
\L{\LB{}\Tab{4}{\V{polygonalMode}:_\V{TRadioButton};}}
\L{\LB{}\Tab{4}{\V{probabilityMode}:_\V{TRadioButton};}}
\L{\LB{}\Tab{4}{\V{Panel2}:_\V{TPanel};}}
\L{\LB{}\Tab{4}{\V{showWayProbability}:_\V{TRadioButton};}}
\L{\LB{}\Tab{4}{\V{showVisibility}:_\V{TRadioButton};}}
\L{\LB{}\Tab{4}{\V{ProgressBar1}:_\V{TProgressBar};}}
\L{\LB{}\Tab{4}{\V{progress}:_\V{TLabel};}}
\index{loadMuseumClick}\Proc{loadMuseumClick}\L{\LB{}\Tab{4}{\K{procedure}_\V{loadMuseumClick}(\V{Sender}:_\V{TObject});}}
\index{FormCreate}\Proc{FormCreate}\L{\LB{}\Tab{4}{\K{procedure}_\V{FormCreate}(\V{Sender}:_\V{TObject});}}
\index{outputPaintBoxPaint}\Proc{outputPaintBoxPaint}\L{\LB{}\Tab{4}{\K{procedure}_\V{outputPaintBoxPaint}(\V{Sender}:_\V{TObject});}}
\index{loadWayClick}\Proc{loadWayClick}\L{\LB{}\Tab{4}{\K{procedure}_\V{loadWayClick}(\V{Sender}:_\V{TObject});}}
\index{FormMouseWheel}\Proc{FormMouseWheel}\L{\LB{}\Tab{4}{\K{procedure}_\V{FormMouseWheel}(\V{Sender}:_\V{TObject};_\V{Shift}:_\V{TShiftState};}}
\L{\LB{}\Tab{6}{\V{WheelDelta}:_\V{Integer};_\V{MousePos}:_\V{TPoint};_\K{var}_\V{Handled}:_\V{Boolean});}}
\index{outputPaintBoxMouseDown}\Proc{outputPaintBoxMouseDown}\L{\LB{}\Tab{4}{\K{procedure}_\V{outputPaintBoxMouseDown}(\V{Sender}:_\V{TObject};_\V{Button}:_\V{TMouseButton};}}
\L{\LB{}\Tab{6}{\V{Shift}:_\V{TShiftState};_\V{X},_\V{Y}:_\V{Integer});}}
\index{outputPaintBoxMouseMove}\Proc{outputPaintBoxMouseMove}\L{\LB{}\Tab{4}{\K{procedure}_\V{outputPaintBoxMouseMove}(\V{Sender}:_\V{TObject};_\V{Shift}:_\V{TShiftState};_\V{X},}}
\L{\LB{}\Tab{6}{\V{Y}:_\V{Integer});}}
\index{fillSeenAreasClick}\Proc{fillSeenAreasClick}\L{\LB{}\Tab{4}{\K{procedure}_\V{fillSeenAreasClick}(\V{Sender}:_\V{TObject});}}
\index{loadWayProbabilityClick}\Proc{loadWayProbabilityClick}\L{\LB{}\Tab{4}{\K{procedure}_\V{loadWayProbabilityClick}(\V{Sender}:_\V{TObject});}}
\L{\LB{}\Tab{2}{\K{private}}}
\L{\LB{}\Tab{4}{\C{}\{_Private-Deklarationen_\}\CE{}}}
\L{\LB{}\Tab{4}{\V{clickPos},_\V{oldnullpoint}:\V{tpoint};}}
\L{\LB{}\Tab{2}{\K{public}}}
\L{\LB{}\Tab{4}{\C{}\{_Public-Deklarationen_\}\CE{}}}
\L{\LB{}\Tab{4}{\V{zoom}:_\V{double};}\Tab{48}{\C{}//Zoomfaktor_für_die_Ausgabe\CE{}}}
\L{\LB{}\Tab{4}{\V{nullpoint}:\V{tpoint};}\Tab{48}{\C{}//Verschiebungsfaktor}\Tab{71}{\3\CE{}}}
\L{\LB{}\Tab{4}{\V{museum}:_\K{array}_\K{of}_\V{TPolygon};}\Tab{48}{\C{}//Das_geladene_Museum\CE{}}}
\L{\LB{}\Tab{4}{\V{museumSize}:_\V{tpointf};}\Tab{48}{\C{}//Größe_des_Museums_\CE{}}}
\L{\LB{}\Tab{4}{\V{guardsWay}:_\V{TPolygon};}\Tab{48}{\C{}//Der_Weg_des_Wächters\CE{}}}
\L{\LB{}\Tab{4}{\V{seenAreas}:_\K{array}_\K{of}_\K{array}[\N{0}\V{.\,.3}]_\K{of}_\V{tpointf};_\C{}//alle_sichtbaren_Bereiche\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\V{invSeeProbability}:_\K{array}_\K{of}_\K{array}_\K{of}_\V{double};}}
\L{\LB{}\Tab{4}{\V{invWayProbability}:_\K{array}_\K{of}_\K{array}_\K{of}_\V{double};}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\C{}//Berechnet_die_von_einem_Punkt_aus_sichtbaren_Segmente\CE{}}}
\index{lookFromPoint}\Proc{lookFromPoint}\L{\LB{}\Tab{4}{\K{procedure}_\V{lookFromPoint}(\K{const}_\V{p}:_\V{tpointf});}}
\L{\LB{}\Tab{4}{\C{}//Berechnet_die_von_einer_Linie_aus_sichtbaren_Segmente\CE{}}}
\index{lookFromWayLine}\Proc{lookFromWayLine}\L{\LB{}\Tab{4}{\K{procedure}_\V{lookFromWayLine}(\K{var}_\V{line}:_\V{TLine});}}
\L{\LB{}\Tab{4}{\C{}//Wandelt_die_getroffenen_Segmentpunkte_in_sichtbare_Bereiche_um\CE{}}}
\index{convertLookPoints}\Proc{convertLookPoints}\L{\LB{}\Tab{4}{\K{procedure}_\V{convertLookPoints};}}
\L{\LB{}\Tab{4}{\C{}//Berechnet,_alle_von_einem_Weg_aus_sichtbaren_Bereiche\CE{}}}
\index{lookAround}\Proc{lookAround}\L{\LB{}\Tab{4}{\K{procedure}_\V{lookAround}();}}
\L{\LB{}\Tab{2}{\K{end};}}
\ProcCont{convertLookPoints}\L{\LB{}}
\L{\LB{\K{var}}}
\L{\LB{}\Tab{2}{\V{museumForm}:_\V{TmuseumForm};}}
\L{\LB{}}
\L{\LB{\K{implementation}}}
\L{\LB{}}
\L{\LB{\C{}\{\$R_*.DFM\}\CE{}}}
\L{\LB{}}
\L{\LB{\C{}//===================File_I/O================\CE{}}}
\L{\LB{\C{}//Lädt_ein_Polgon_mit_einer_gegeben_Anzahl_von_Punkten_und_sucht_die_minimalen\CE{}}}
\L{\LB{\C{}//und_maximalen_Koordinaten\CE{}}}
\index{loadPolygon}\Proc{loadPolygon}\L{\LB{\K{function}_\V{loadPolygon}(\K{var}_\V{f}:_\V{TextFile};_\V{len}:_\V{integer};_\V{min},\V{max}:_\V{ppointf}):\V{TPolygon};}}
\L{\LB{\N{4var}_\V{i},\V{j}:\V{integer};}}
\L{\LB{}\Tab{4}{\V{s}:\V{string};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{SetLength}(\V{result},\V{len});}\Tab{37}{\C{}//Speicher_vorreservieren\CE{}}}
\L{\LB{}\Tab{2}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{len}\-\N{1}_\K{do}_\K{begin}}}
\L{\LB{}\Tab{4}{\V{Readln}(\V{f},\V{s});}\Tab{37}{\C{}//Zeile_lesen\CE{}}}
\L{\LB{}\Tab{4}{\V{j}:=\V{pos}(\S{}{'}_{'}\SE{},\V{s});}\Tab{37}{\C{}//Trennzeichen_zweischen_zwei_Koord._suchen\CE{}}}
\L{\LB{}\Tab{4}{\K{with}_\V{result}[\V{i}]\V{.start}_\K{do}_\K{begin}}}
\L{\LB{}\Tab{6}{\V{x}:=\V{StrToFloat}(\V{copy}(\V{s},\N{1},\V{j}\-\N{1}));}\Tab{37}{\C{}//erste_Koordinate_lesen\CE{}}}
\L{\LB{}\Tab{6}{\V{delete}(\V{s},\N{1},\V{j});}\Tab{37}{\C{}//sie_zusammen_mit_dem_Trennzeichen_löschen\CE{}}}
\L{\LB{}\Tab{6}{\V{y}:=\V{StrToFloat}(\V{s});}\Tab{37}{\C{}//zweite_Koordinate_lesen\CE{}}}
\L{\LB{}\Tab{6}{\K{if}_\V{max}\<\>\K{nil}_\K{then}_\K{begin}}\Tab{37}{\C{}//äußerste_Koordinaten_suchen\CE{}}}
\L{\LB{}\Tab{8}{\K{if}_(\V{x}\>\V{max.X})_\K{then}_\V{max.X}:=\V{x};}}
\L{\LB{}\Tab{8}{\K{if}_(\V{y}\>\V{max.Y})_\K{then}_\V{max.Y}:=\V{y};}}
\L{\LB{}\Tab{6}{\K{end};}}
\ProcCont{convertLookPoints}\L{\LB{}\Tab{6}{\K{if}_\V{min}\<\>\K{nil}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{8}{\K{if}_(\V{x}\<\V{min.X})_\K{then}_\V{min.X}:=\V{x};}}
\L{\LB{}\Tab{8}{\K{if}_(\V{y}\<\V{min.Y})_\K{then}_\V{min.Y}:=\V{y};}}
\L{\LB{}\Tab{6}{\K{end};}}
\ProcCont{lookFromWayLine}\L{\LB{}\Tab{4}{\K{end};}}
\ProcCont{lookFromPoint}\L{\LB{}\Tab{4}{\K{if}_\V{i}\<\>\N{0}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{6}{\V{result}[\V{i}]\V{.left}:=@\V{result}[\V{i}\-\N{1}];}\Tab{37}{\C{}//Zeiger_auf_vorherige_Linie_setzten\CE{}}}
\L{\LB{}\Tab{6}{\V{result}[\V{i}\-\N{1}]\V{.right}:=@\V{result}[\V{i}];_\C{}//Dort_einen_auf_diese_setzen\CE{}}}
\L{\LB{}\Tab{6}{\V{result}[\V{i}\-\N{1}]\V{.dir.x}:=\V{result}[\V{i}]\V{.start.x}\-\V{result}[\V{i}\-\N{1}]\V{.start.x};_\C{}//Richtung\CE{}}}
\L{\LB{}\Tab{6}{\V{result}[\V{i}\-\N{1}]\V{.dir.y}:=\V{result}[\V{i}]\V{.start.y}\-\V{result}[\V{i}\-\N{1}]\V{.start.y};_\C{}//}\Tab{68}{berechnen\CE{}}}
\L{\LB{}\Tab{4}{\K{end};}}
\ProcCont{loadWayProbabilityClick}\L{\LB{}\Tab{2}{\K{end};}}
\ProcCont{fillSeenAreasClick}\L{\LB{}\Tab{2}{\C{}//Dasselbe_wie_am_Ende_der_for-Schleife_für_die_ersten_Linie_(Nachfolger_der_letzten)\CE{}}}
\L{\LB{}\Tab{2}{\V{result}[\V{len}\-\N{1}]\V{.right}:=@\V{result}[\N{0}];}}
\L{\LB{}\Tab{2}{\V{result}[\N{0}]\V{.left}:=@\V{result}[\V{len}\-\N{1}];}}
\L{\LB{}\Tab{2}{\V{result}[\V{len}\-\N{1}]\V{.dir.x}:=\V{result}[\N{0}]\V{.start.x}\-\V{result}[\V{len}\-\N{1}]\V{.start.x};}}
\L{\LB{}\Tab{2}{\V{result}[\V{len}\-\N{1}]\V{.dir.y}:=\V{result}[\N{0}]\V{.start.y}\-\V{result}[\V{len}\-\N{1}]\V{.start.y};}}
\L{\LB{\K{end};}}
\ProcCont{outputPaintBoxMouseMove}\L{\LB{}}
\L{\LB{\C{}//Es_wurde_auf_den_Button_zum_Laden_des_Museums_geklickt\CE{}}}
\index{TmuseumForm.loadMuseumClick}\Proc{TmuseumForm.loadMuseumClick}\L{\LB{\K{procedure}_\V{TmuseumForm.loadMuseumClick}(\V{Sender}:_\V{TObject});}}
\L{\LB{\K{var}_\V{museumFile}:_\V{TextFile};}}
\L{\LB{}\Tab{4}{\V{s}:\V{string};}}
\L{\LB{}\Tab{4}{\V{maxP},\V{minP}:_\V{tpointf};}}
\L{\LB{}\Tab{4}{\V{i},\V{j}:_\V{integer};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{SetLength}(\V{museum},\N{0});}}
\L{\LB{}\Tab{2}{\C{}//Koordinatengrenzen_mit_maximalen_Grenzen_besetzten\CE{}}}
\L{\LB{}\Tab{2}{\V{maxP.x}:=\-\V{inf};\V{maxP.y}:=\-\V{inf};}}
\L{\LB{}\Tab{2}{\V{minP.x}:=\V{inf};\V{minP.y}:=\V{inf};}}
\L{\LB{}\Tab{2}{\C{}//Datei_laden\CE{}}}
\L{\LB{}\Tab{2}{\V{AssignFile}(\V{museumFile},\V{museumFileName.Text});}}
\L{\LB{}\Tab{2}{\V{reset}(\V{museumFile});}}
\L{\LB{}\Tab{2}{\K{repeat}}}
\L{\LB{}\Tab{4}{\V{Readln}(\V{museumfile},\V{s});_\C{}//erste_Zeile_eines_Polygones_lesen\CE{}}}
\L{\LB{}\Tab{4}{\K{if}_\V{lowercase}(\V{copy}(\V{s},\N{1},\N{8}))=\S{}{'}polygon_{'}\SE{}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{6}{\V{delete}(\V{s},\N{1},\N{8});}\Tab{42}{\C{}//\3polygon_\3_abschneiden\CE{}}}
\L{\LB{}\Tab{6}{\V{SetLength}(\V{museum},\V{length}(\V{museum})+\N{1});_\C{}//Neues_Polygon_anhängen\CE{}}}
\L{\LB{}\Tab{6}{\C{}//Polygon_in_nun_reservierten_Speicher_laden\CE{}}}
\L{\LB{}\Tab{6}{\V{museum}[\V{high}(\V{museum})]:=\V{loadPolygon}(\V{museumFile},\V{strtoint}(\V{s}),@\V{minP},@\V{maxP})}}
\L{\LB{}\Tab{4}{\K{end}_\K{else}_\V{raise}_\V{Exception.create}(\S{}{'}Can{'}\SE{}\S{}{'}t_understand_\3{'}\SE{}+\V{s}+\S{}{'}\3{'}\SE{});_\C{}//falsches_Format\CE{}}}
\ProcCont{outputPaintBoxMouseMove}\L{\LB{}\Tab{2}{\K{until}_\V{eof}(\V{museumFile});}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{CloseFile}(\V{museumFile});}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{museumSize.x}:=\V{maxP.X}\-\V{minP.X};}}
\L{\LB{}\Tab{2}{\V{museumSize.y}:=\V{maxP.y}\-\V{minP.y};}}
\L{\LB{}\Tab{2}{\K{if}_\V{polygonalMode.checked}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{4}{\C{}//Wenn_der_Algortihmus_durch_Polygonenanalyse_arbeitet_soll,\CE{}}}
\L{\LB{}\Tab{4}{\C{}//wird_einfach_ein_passender_Zoomfaktor_gewählt\CE{}}}
\L{\LB{}\Tab{4}{\V{zoom}:=\V{min}(\V{outputPaintBox.ClientHeight}/(\V{maxP.Y}\-\V{minP.Y}),}}
\L{\LB{}\Tab{14}{\V{outputPaintBox.ClientWidth}/(\V{maxP.X}\-\V{minP.X}));}}
\L{\LB{}\Tab{2}{\K{end}_\K{else}_\K{begin}}}
\ProcCont{outputPaintBoxMouseDown}\L{\LB{}\Tab{4}{\V{zoom}:=\V{max}(\V{museumSize.x},\V{museumSize.y});}}
\L{\LB{}\Tab{4}{\C{}//Sonst_werden_vorher_die_Koordinaten,_in_den_0_-_1_Bereich_gemappt\CE{}}}
\L{\LB{}\Tab{4}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{museum})_\K{do}}}
\L{\LB{}\Tab{6}{\K{for}_\V{j}:=\N{0}_\K{to}_\V{high}(\V{museum}[\V{i}])_\K{do}_\K{begin}}}
\L{\LB{}\Tab{8}{\V{museum}[\V{i},\V{j}]\V{.start.x}:=(\V{museum}[\V{i},\V{j}]\V{.start.x}\-\V{minP.x})/\V{zoom};}}
\L{\LB{}\Tab{8}{\V{museum}[\V{i},\V{j}]\V{.start.y}:=(\V{museum}[\V{i},\V{j}]\V{.start.y}\-\V{minP.y})/\V{zoom};}}
\L{\LB{}\Tab{8}{\V{museum}[\V{i},\V{j}]\V{.dir.x}:=(\V{museum}[\V{i},\V{j}]\V{.dir.x})/\V{zoom};}}
\L{\LB{}\Tab{8}{\V{museum}[\V{i},\V{j}]\V{.dir.y}:=(\V{museum}[\V{i},\V{j}]\V{.dir.y})/\V{zoom};}}
\L{\LB{}\Tab{6}{\K{end};}}
\ProcCont{FormMouseWheel}\L{\LB{}\Tab{4}{\V{zoom}:=\V{min}(\V{outputPaintBox.ClientHeight},\V{outputPaintBox.ClientWidth});}}
\L{\LB{}\Tab{2}{\K{end};}}
\ProcCont{loadWayClick}\L{\LB{}\Tab{2}{\V{nullpoint.x}:=\N{0};}}
\L{\LB{}\Tab{2}{\V{nullpoint.y}:=\N{0};}}
\L{\LB{}\Tab{2}{\V{Refresh};}}
\L{\LB{\K{end};}}
\ProcCont{outputPaintBoxPaint}\L{\LB{}}
\L{\LB{\C{}//Einen_Rundgang_laden\CE{}}}
\index{TmuseumForm.loadWayClick}\Proc{TmuseumForm.loadWayClick}\L{\LB{\K{procedure}_\V{TmuseumForm.loadWayClick}(\V{Sender}:_\V{TObject});}}
\L{\LB{\K{var}}\Tab{5}{\V{f}:_\V{TextFile};}}
\L{\LB{}\Tab{5}{\V{len}:_\V{integer};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{AssignFile}(\V{f},\V{wayFileName.Text});}}
\L{\LB{}\Tab{2}{\V{reset}(\V{f});}}
\L{\LB{}\Tab{2}{\V{Readln}(\V{f},\V{len});}\Tab{40}{\C{}//Anzahl_der_Punkte_einlesen\CE{}}}
\L{\LB{}\Tab{2}{\V{guardsWay}:=\V{loadPolygon}(\V{f},\V{len},\K{nil},\K{nil});\C{}//Rundgang_einlesen\CE{}}}
\L{\LB{}\Tab{2}{\V{CloseFile}(\V{f});}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{lookAround};}\Tab{40}{\C{}//Sichtbarkeit_berechnen\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{Refresh};}}
\L{\LB{\K{end};}}
\ProcCont{outputPaintBoxPaint}\L{\LB{}}
\L{\LB{\C{}//===================Ausgabe=================\CE{}}}
\index{TmuseumForm.outputPaintBoxPaint}\Proc{outputPaintBoxPaint}\L{\LB{\K{procedure}_\V{TmuseumForm.outputPaintBoxPaint}(\V{Sender}:_\V{TObject});}}
\L{\LB{}\Tab{2}{\C{}//Einen_Punkt_im_Koordinatensystem_des_Museums_ins_Ausgabesystem_umwandeln\CE{}}}
\index{transform}\Proc{transform}\L{\LB{}\Tab{2}{\K{function}_\V{transform}(\K{const}_\V{p}:\V{tpointf}):_\V{tpoint};}}
\L{\LB{}\Tab{2}{\K{begin}}}
\L{\LB{}\Tab{4}{\V{result.x}:=\V{round}(\V{p.x}*\V{zoom})+\V{nullpoint.x};}}
\L{\LB{}\Tab{4}{\V{result.y}:=\V{round}(\-\V{p.y}*\V{zoom})+\V{outputPaintBox.ClientHeight}+\V{nullpoint.y};}}
\L{\LB{}\Tab{2}{\K{end};}}
\ProcCont{outputPaintBoxPaint}\L{\LB{}\Tab{2}{\C{}//Ein_Polygon_zeichnen\CE{}}}
\index{drawPolygon}\Proc{drawPolygon}\L{\LB{}\Tab{2}{\K{procedure}_\V{drawPolygon}(\K{const}_\V{p}:\V{TPolygon});}}
\L{\LB{}\Tab{2}{\K{var}_\V{transformedPoly}:_\K{array}_\K{of}_\V{tpoint};}}
\L{\LB{}\Tab{6}{\V{i}:\V{integer};}}
\L{\LB{}\Tab{2}{\K{begin}}}
\L{\LB{}\Tab{4}{\V{SetLength}(\V{transformedPoly},\V{length}(\V{p}));}}
\L{\LB{}\Tab{4}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{p})_\K{do}}}
\L{\LB{}\Tab{6}{\V{transformedPoly}[\V{i}]:=\V{transform}(\V{p}[\V{i}]\V{.start});}}
\L{\LB{}\Tab{4}{\V{outputPaintBox.Canvas.Polygon}(\V{transformedPoly})}}
\L{\LB{}\Tab{2}{\K{end};}}
\ProcCont{outputPaintBoxPaint}\L{\LB{\K{var}_\V{i},\V{j}:\V{integer};}}
\L{\LB{}\Tab{4}{\V{temp}:_\K{array}[\N{0}\V{.\,.3}]_\K{of}_\V{tpoint};}}
\L{\LB{}\Tab{4}{\V{tempColor}:_\V{integer};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\K{if}_\V{length}(\V{museum})_=_\N{0}_\K{then}_\K{exit};}\Tab{39}{\C{}//Kein_Museum_geladen_=\>_schüss\CE{}}}
\L{\LB{}\Tab{2}{\K{with}_\V{outputPaintBox.Canvas}_\K{do}_\K{begin}}}
\L{\LB{}\Tab{4}{\K{if}_\V{polygonalMode.Checked}_\K{then}_\K{begin}_\C{}//Im_Polygonanalysemodus\CE{}}}
\L{\LB{}\Tab{6}{\V{pen.Width}:=\N{1};}\Tab{40}{\C{}//werden_die_Museumspolygone_gefüllt\CE{}}}
\L{\LB{}\Tab{6}{\V{pen.color}:=\V{clBlack};}}
\L{\LB{}\Tab{6}{\V{pen.Style}:=\V{psSolid};}}
\L{\LB{}\Tab{6}{\V{brush.Color}:=\V{clSilver};}}
\L{\LB{}\Tab{6}{\V{drawPolygon}(\V{museum}[\N{0}]);}\Tab{40}{\C{}//Hauptpolygon_zeichnen\CE{}}}
\L{\LB{}\Tab{6}{\V{brush.Color}:=\V{clGray};}}
\L{\LB{}\Tab{6}{\K{for}_\V{i}:=\N{1}_\K{to}_\V{high}(\V{museum})_\K{do}}\Tab{40}{\C{}//Löcher_zeichnen\CE{}}}
\L{\LB{}\Tab{8}{\V{drawPolygon}(\V{museum}[\V{i}]);}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\C{}//Sichtbare_Bereiche_ausgeben\CE{}}}
\L{\LB{}\Tab{6}{\K{if}_\V{fillSeenAreas.Checked}_\K{then}_\V{brush.Color}:=\N{\$A6D9AD}_\C{}//füllen\CE{}}}
\L{\LB{}\Tab{6}{\K{else}_\V{brush.Style}:=\V{bsClear};}\Tab{57}{}}
\L{\LB{}\Tab{6}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{seenAreas})_\K{do}_\K{begin}}}
\L{\LB{}\Tab{8}{\K{if}_\V{drawBorderedSeenAreas.Checked}_\K{then}_\K{begin}}\Tab{57}{\C{}//umranden\CE{}}}
\L{\LB{}\Tab{10}{\V{pen.Width}:=\N{1};}}
\L{\LB{}\Tab{10}{\V{pen.Color}:=\V{clGray};}}
\L{\LB{}\Tab{8}{\K{end}_\K{else}_\V{pen.Style}:=\V{psClear};}}
\ProcCont{outputPaintBoxPaint}\L{\LB{}}
\L{\LB{}\Tab{8}{\C{}//Polygon_umrechnen_und_zeichnen\CE{}}}
\L{\LB{}\Tab{8}{\K{for}_\V{j}:=\N{0}_\K{to}_\N{3}_\K{do}}}
\L{\LB{}\Tab{10}{\V{temp}[\V{j}]:=\V{transform}(\V{seenAreas}[\V{i},\V{j}]);}}
\L{\LB{}\Tab{8}{\V{Polygon}(\V{temp});}}
\L{\LB{}}
\L{\LB{}\Tab{8}{\C{}//Treffpunkte_auf_der_Linie\CE{}}}
\L{\LB{}\Tab{8}{\V{pen.Style}:=\V{psSolid};}}
\L{\LB{}\Tab{8}{\V{pen.Width}:=\N{2};}}
\L{\LB{}\Tab{8}{\V{pen.Color}:=\V{clRed};}}
\L{\LB{}\Tab{8}{\V{moveto}(\V{temp}[\N{1}]\V{.x},\V{temp}[\N{1}]\V{.y});}}
\L{\LB{}\Tab{8}{\V{LineTo}(\V{temp}[\N{2}]\V{.x},\V{temp}[\N{2}]\V{.y});}}
\L{\LB{}\Tab{6}{\K{end};}}
\ProcCont{FormCreate}\L{\LB{}}
\L{\LB{}\Tab{6}{\V{pen.Width}:=\N{1};}}
\L{\LB{}\Tab{6}{\V{pen.Color}:=\V{clBlack};}}
\L{\LB{}\Tab{6}{\V{brush.Style}:=\V{bsClear};}}
\L{\LB{}\Tab{6}{\V{drawPolygon}(\V{guardsWay});}}
\L{\LB{}\Tab{4}{\K{end}_\K{else}_\K{begin}}}
\ProcCont{loadMuseumClick}\L{\LB{}\Tab{6}{\K{if}_\V{showWayProbability.Checked}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{8}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{invWayProbability})_\K{do}}}
\L{\LB{}\Tab{10}{\K{for}_\V{j}:=\N{0}_\K{to}_\V{high}(\V{invWayProbability}[\V{i}])_\K{do}_\K{begin}}}
\L{\LB{}\Tab{12}{\V{tempColor}:=\V{min}(\N{255},\V{max}(\N{0},\V{round}(\V{invWayProbability}[\V{i},\V{j}]*\N{255})));}}
\L{\LB{}\Tab{12}{\V{Pixels}[\V{i}+\V{nullpoint.x},\V{j}+\V{nullpoint.y}+\V{outputPaintBox.ClientHeight}\-\V{length}(\V{invSeeProbability})];}}
\L{\LB{}\Tab{14}{:=\V{rgb}(\V{tempColor},\V{tempColor},\V{tempColor});}}
\L{\LB{}\Tab{10}{\K{end};}}
\L{\LB{}\Tab{6}{\K{end}_\K{else}_\K{if}_\V{showVisibility.Checked}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{8}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{invSeeProbability})_\K{do}}}
\L{\LB{}\Tab{10}{\K{for}_\V{j}:=\N{0}_\K{to}_\V{high}(\V{invSeeProbability}[\V{i}])_\K{do}_\K{begin}}}
\L{\LB{}\Tab{12}{\V{tempColor}:=\V{min}(\N{255},\V{max}(\N{0},\V{round}(\V{invSeeProbability}[\V{i},\V{j}]*\N{255})));}}
\L{\LB{}\Tab{12}{\V{Pixels}[\V{i}+\V{nullpoint.x},\V{j}+\V{nullpoint.y}+\V{outputPaintBox.ClientHeight}\-\V{length}(\V{invSeeProbability})]}}
\L{\LB{}\Tab{14}{:=\V{rgb}(\V{tempColor},\V{tempColor},\V{tempColor});}}
\L{\LB{}\Tab{10}{\K{end};}}
\L{\LB{}\Tab{6}{\K{end}_\K{else}}}
\L{\LB{}\Tab{6}{\V{pen.Width}:=\N{1};}}
\L{\LB{}\Tab{6}{\V{pen.color}:=\V{clRed};}}
\L{\LB{}\Tab{6}{\V{pen.Style}:=\V{psSolid};}}
\L{\LB{}\Tab{6}{\V{brush.style}:=\V{bsClear};}}
\L{\LB{}\Tab{6}{\V{drawPolygon}(\V{museum}[\N{0}]);}}
\L{\LB{}\Tab{6}{\K{for}_\V{i}:=\N{1}_\K{to}_\V{high}(\V{museum})_\K{do}}}
\L{\LB{}\Tab{8}{\V{drawPolygon}(\V{museum}[\V{i}]);}}
\L{\LB{}\Tab{4}{\K{end};}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//==================LOGIK=================\CE{}}}
\L{\LB{\C{}//Gibt_zurück,_auf_welcher_Seite_vom_Strahl_pos,dir_der_Punkt_p_liegt.\CE{}}}
\L{\LB{\C{}//-1:_links,_0:_auf_dem_Strahl,_1:_rechts\CE{}}}
\index{whichSide}\Proc{whichSide}\L{\LB{\K{function}_\V{whichSide}(\K{const}_\V{pos},\V{dir}:_\V{tpointf};_\K{const}_\V{p}:\V{tpointf}):_\V{integer};}}
\L{\LB{\K{var}_\V{temp}:\V{double};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\C{}//Feststellen_auf_welchwer_Seite_die_Punkte_liegen\CE{}}}
\L{\LB{}\Tab{2}{\C{}//pos1_zum_Nullpunkt_verschieben;\CE{}}}
\L{\LB{}\Tab{2}{\C{}//Koordintensystem_so_verzerren,_dass_dir_auf_die_y-Achse_fällt\CE{}}}
\L{\LB{}\Tab{2}{\V{Result}:=\N{0};}}
\L{\LB{}\Tab{2}{\K{if}_\V{abs}(\V{dir.y})\<\V{epsilon}_\K{then}_\K{begin}_\C{}//verzerren_geht_nicht,_einfacher_Vergleich\CE{}}}
\L{\LB{}\Tab{4}{\K{if}_\V{p.y}\<\V{pos.y}_\K{then}_\V{result}:=\N{1}}}
\L{\LB{}\Tab{4}{\K{else}_\K{if}_\V{p.y}\>\V{pos.y}_\K{then}_\V{result}:=\-\N{1};}}
\L{\LB{}\Tab{4}{\K{if}_\V{dir.x}\<\V{epsilon}_\K{then}_\V{Result}:=\-\V{result};}}
\L{\LB{}\Tab{2}{\K{end}_\K{else}_\K{begin}}}
\L{\LB{}\Tab{4}{\C{}//x\_new(x,y)_=_x_-_y_*_dir1.x_/_dir1.y\CE{}}}
\L{\LB{}\Tab{4}{\C{}//=\>_x\_new(dir1.x,dir1.y)_=_0\CE{}}}
\L{\LB{}\Tab{4}{\V{temp}:=((\V{p.x}_\-_\V{pos.x})_\-_(\V{p.y}_\-_\V{pos.y})_*_\V{dir.x}_/_\V{dir.y});}}
\L{\LB{}\Tab{4}{\K{if}_\V{temp}\>\V{epsilon}_\K{then}_\V{result}:=\N{1}}}
\L{\LB{}\Tab{4}{\K{else}_\K{if}_\V{temp}\<\!\-\V{epsilon}_\K{then}_\V{result}:=\-\N{1};}}
\L{\LB{}\Tab{4}{\K{if}_\V{dir.y}\<\N{0}_\K{then}_\V{result}:=\-\V{result};}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//Überprüft_auf_welcher_Seite_von_der_Linie_a--b_der_Punkt_p_liegt\CE{}}}
\index{whichLineSide}\Proc{whichLineSide}\L{\LB{\K{function}_\V{whichLineSide}(\K{const}_\V{a},\V{b}:_\V{tpointf};_\K{const}_\V{p}:\V{tpointf}):_\V{integer};}}
\L{\LB{\K{var}_\V{dir}:_\V{tpointf};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{dir.x}:=\V{a.x}\-\V{b.x};_\V{dir.y}:=\V{a.y}\-\V{b.y};_\C{}//Richtung_für_einen_Strahl\CE{}}}
\L{\LB{}\Tab{2}{\V{Result}:=\V{whichSide}(\V{a},\V{dir},\V{p});}\Tab{34}{\C{}//auf_bekanntes_Problem_zurückleiten}\Tab{100}{\CE{}}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//Berechnet_die_Treffer_eines_Strahl_mit_einem_Polygon_\CE{}}}
\index{findRayHitPoints}\Proc{findRayHitPoints}\L{\LB{\K{procedure}_\V{findRayHitPoints}(\V{polys}:\K{array}_\K{of}_\V{TPolygon};_\K{const}_\V{start},\V{dir}:\V{tpointf};\V{out}_\V{result}:\V{TRayHitPoints});}}
\L{\LB{\K{var}_\V{poly},\V{line}:\V{integer};}\Tab{32}{\C{}//Momentan_zu_überprüfende_Linie\CE{}}}
\L{\LB{}\Tab{4}{\V{lineStart},\V{lineDir}:_\V{ppointf};_\C{}//Start_und_Richtung_dieser_Linie\CE{}}}
\L{\LB{}\Tab{4}{\V{u},\V{v}:_\V{double};}\Tab{32}{\C{}//Position_des_Treffpunkts_auf_dem_Strahl_und_der_Linie\CE{}}}
\L{\LB{}\Tab{4}{\V{p1Side},\V{p2Side}:\V{integer};}\Tab{32}{\C{}//Strahlseite_auf_der_an_einen_Punkt_grenzende_Linien_sind\CE{}}}
\L{\LB{}\Tab{4}{\V{i}:\V{integer};}\Tab{32}{\C{}//Loopindex}\Tab{101}{\CE{}}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{result.when}:=\V{inf};}\Tab{32}{\C{}//Maximaler_Abstand_\CE{}}}
\L{\LB{}\Tab{2}{\V{SetLength}(\V{result.between},\N{0});}}
\L{\LB{}\Tab{2}{\K{for}_\V{poly}:=\N{0}_\K{to}_\V{high}(\V{polys})_\K{do}}}
\L{\LB{}\Tab{4}{\K{for}_\V{line}:=\N{0}_\K{to}_\V{high}(\V{polys}[\V{poly}])_\K{do}_\K{begin}}}
\L{\LB{}\Tab{6}{\V{lineStart}:=@\V{polys}[\V{poly},\V{line}]\V{.start};_\C{}//Zeiger_für_einfacheren_Zugriff\CE{}}}
\L{\LB{}\Tab{6}{\V{lineDir}:=@\V{polys}[\V{poly},\V{line}]\V{.dir};}}
\L{\LB{}\Tab{6}{\C{}//Regel_für_Schnittpunkte:\CE{}}}
\L{\LB{}\Tab{6}{\C{}\{}\Tab{11}{start+_u*dir_=_linestart_+_v*linedir,_0\<=v\<=1_\}\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\K{if}_\V{abs}(\V{dir.x}*\V{lineDir.y}_\-_\V{dir.y}*\V{lineDir.x})_\<_\V{epsilon}_\K{then}}}
\L{\LB{}\Tab{8}{\K{continue};_\C{}//parallel_von_Linien_und_Strahlen_ignorieren_(siehe_Doku)_\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\C{}//Position_des_Punktes_auf_der_Linie_berechnen\CE{}}}
\L{\LB{}\Tab{6}{\V{v}_:=_(\V{dir.x}*(\V{start.y}_\-_\V{linestart.y})_+_\V{dir.y}*(\V{linestart.x}_\-_\V{start.x}))/}}
\L{\LB{}\Tab{6}{(\V{dir.x}*\V{lineDir.y}_\-_\V{dir.y}*\V{lineDir.x});}}
\L{\LB{}\Tab{6}{\C{}//Abbrechen,_falls_außerhalb_der_Linie\CE{}}}
\L{\LB{}\Tab{6}{\K{if}_\V{abs}(\V{v})\<\V{epsilon}_\K{then}_\V{v}:=\N{0};}}
\L{\LB{}\Tab{6}{\K{if}_\V{abs}(\V{v}\-\N{1})\<\V{epsilon}_\K{then}_\V{v}:=\N{1};}}
\L{\LB{}\Tab{6}{\K{if}_(\V{v}\<\N{0})_\K{or}_(\V{v}\>\N{1})_\K{then}_\K{continue};}}
\L{\LB{}\Tab{6}{\C{}//Position_auf_dem_Strahl_berechnen\CE{}}}
\L{\LB{}\Tab{6}{\V{u}_:=_(\V{lineDir.x}*(\V{start.y}_\-_\V{linestart.y})_+_\V{lineDir.y}*(\V{linestart.x}_\-_\V{start.x}))/}}
\L{\LB{}\Tab{20}{(\V{dir.x}*\V{lineDir.y}_\-_\V{dir.y}*\V{lineDir.x});}}
\L{\LB{}\Tab{6}{\C{}//Abbrechen,_falls_hinter_dem_Strahl\CE{}}}
\L{\LB{}\Tab{6}{\K{if}_\V{abs}(\V{u}\-\N{1})\<\V{epsilon}_\K{then}_\V{u}:=\N{1};}}
\L{\LB{}\Tab{6}{\K{if}_(\V{u}\>\V{result.when})_\K{or}_(\V{u}\<\V{epsilon})_\K{then}_\K{continue};}}
\L{\LB{}\Tab{6}{\C{}//Startpunkt_getroffen\CE{}}}
\L{\LB{}\Tab{6}{\K{if}_\V{v}=\N{0}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{8}{\C{}//Berechnen_auf_welcher_Seite_des_Strahls_die_angrenzenden_Linie_sind\CE{}}}
\L{\LB{}\Tab{8}{\V{p1Side}:=\V{whichSide}(\V{start},\V{dir},\V{polys}[\V{poly},\V{line}]\V{.left}\5\V{.start});}}
\L{\LB{}\Tab{8}{\V{p2Side}:=\V{whichSide}(\V{start},\V{dir},\V{polys}[\V{poly},\V{line}]\V{.right}\5\V{.start});}}
\L{\LB{}\Tab{8}{\K{if}_(\V{p1Side}=\V{p2Side})_\K{and}_(\V{p1Side}\<\>\N{0})_\K{then}_\K{begin}_\C{}//gleiche_Seite_=\>_Zacke\CE{}}}
\L{\LB{}\Tab{10}{\C{}//=\>_der_Strahl_wird_nicht_geblockt,_nur_Strahlen,_die_neben_ihm_wären\CE{}}}
\L{\LB{}\Tab{10}{\C{}//Passende_Position_im_sortierten_between-Array_suchen\CE{}}}
\L{\LB{}\Tab{10}{\V{i}:=\V{high}(\V{result.between});}}
\L{\LB{}\Tab{10}{\K{while}_(\V{i}\>=\N{0})_\K{and}_(\V{result.between}[\V{i}]\V{.when}\>\V{result.when})_\K{do}}}
\L{\LB{}\Tab{12}{\V{dec}(\V{i});}}
\L{\LB{}\Tab{10}{\V{inc}(\V{i});}}
\L{\LB{}\Tab{10}{\C{}//Punkt_einfügen\CE{}}}
\L{\LB{}\Tab{10}{\V{SetLength}(\V{result.between},\V{length}(\V{result.between})+\N{1});}}
\L{\LB{}\Tab{10}{\V{move}(\V{result.between}[\V{i}],\V{result.between}[\V{i}+\N{1}],(\V{high}(\V{result.between})\-\V{i})*\V{sizeof}(\V{result.between}[\N{0}]));}}
\L{\LB{}\Tab{10}{\V{result.between}[\V{i}]\V{.poly}:=\V{poly};}}
\L{\LB{}\Tab{10}{\V{result.between}[\V{i}]\V{.point}:=\V{line};}}
\L{\LB{}\Tab{10}{\V{result.between}[\V{i}]\V{.side}:=\V{p1Side};}}
\L{\LB{}\Tab{10}{\V{result.between}[\V{i}]\V{.when}:=\V{u};}}
\L{\LB{}\Tab{10}{\K{continue};_\C{}//nächste_Linie_testen\CE{}}}
\L{\LB{}\Tab{8}{\K{end};}}
\L{\LB{}\Tab{6}{\K{end}_\K{else}_\K{if}_\V{v}=\N{1}_\K{then}_\K{continue};_\C{}//wird_später_behandelt\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\C{}//Kollision_mit_Polygonenseite\CE{}}}
\L{\LB{}\Tab{6}{\V{result.poly}:=\V{poly};}}
\L{\LB{}\Tab{6}{\V{result.line}:=\V{line};}}
\L{\LB{}\Tab{6}{\V{result.when}:=\V{u};}}
\L{\LB{}\Tab{6}{\V{result.where}:=\V{v};}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\C{}//Alle_Zacken_löschen,_die_hinter_der_Seite_liegen\CE{}}}
\L{\LB{}\Tab{6}{\V{i}:=\V{high}(\V{result.between});}}
\L{\LB{}\Tab{6}{\K{while}_(\V{i}\>=\N{0})_\K{and}_(\V{result.between}[\V{i}]\V{.when}\>\V{u})_\K{do}}}
\L{\LB{}\Tab{8}{\V{dec}(\V{i});}}
\L{\LB{}\Tab{6}{\V{setlength}(\V{result.between},\V{i}+\N{1});}}
\L{\LB{}\Tab{4}{\K{end};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//Speichert_einen_getroffenen_Punkt\CE{}}}
\L{\LB{\C{}//Im_wesentlichen_werden_die_übergebenen_Parameter_einfach_kopiert,_nur_wird\CE{}}}
\L{\LB{\C{}//sichergestellt,_dass_das_seen-Array_sortiert_ist\CE{}}}
\index{addSeePoint}\Proc{addSeePoint}\L{\LB{\K{procedure}_\V{addSeePoint}(\K{var}_\V{line}:\V{TLine};_\K{const}_\V{where}:_\V{double};_\K{const}_\V{seeRight}:_\V{boolean};}}
\L{\LB{}\Tab{38}{\K{const}_\V{hiddenRaySide}:_\V{integer};_\K{const}_\V{from}:\V{tpointf});}}
\L{\LB{\K{var}_\V{i}:\V{integer};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\K{with}_\V{line}_\K{do}_\K{begin}}}
\L{\LB{}\Tab{4}{\C{}//Suchen_der_passenden_Position\CE{}}}
\L{\LB{}\Tab{4}{\V{i}:=\V{high}(\V{sees});}}
\L{\LB{}\Tab{4}{\K{while}_(\V{i}\>=\N{0})_\K{and}_(\V{sees}[\V{i}]\V{.where}\>\V{where})_\K{do}}}
\L{\LB{}\Tab{6}{\V{dec}(\V{i});}}
\L{\LB{}\Tab{4}{\V{SetLength}(\V{sees},\V{length}(\V{sees})+\N{1});}}
\L{\LB{}\Tab{4}{\K{if}_(\V{i}=\-\N{1})_\K{and}_(\V{sees}[\N{0}]\V{.where}\<=\V{where})_\K{then}_\V{i}:=\V{high}(\V{sees})}}
\L{\LB{}\Tab{4}{\K{else}_\V{inc}(\V{i});}}
\L{\LB{}\Tab{4}{\C{}//alle_Einträge_nach_rechts_verschieben\CE{}}}
\L{\LB{}\Tab{4}{\V{move}(\V{sees}[\V{i}],\V{sees}[\V{i}+\N{1}],(\V{high}(\V{sees})\-\V{i})*\V{sizeof}(\V{sees}[\V{i}]));}}
\L{\LB{}\Tab{4}{\C{}//Parameter_kopieren\CE{}}}
\L{\LB{}\Tab{4}{\V{sees}[\V{i}]\V{.where}:=\V{where};}}
\L{\LB{}\Tab{4}{\V{sees}[\V{i}]\V{.seeRight}:=\V{seeRight};}}
\L{\LB{}\Tab{4}{\V{sees}[\V{i}]\V{.hiddenRaySide}:=\V{hiddenRaySide};}}
\L{\LB{}\Tab{4}{\V{sees}[\V{i}]\V{.from}:=\V{from};}}
\L{\LB{}\Tab{4}{\V{sees}[\V{i}]\V{.wherePos.x}:=\V{start.x}+\V{where}*\V{dir.x};}}
\L{\LB{}\Tab{4}{\V{sees}[\V{i}]\V{.wherePos.y}:=\V{start.y}+\V{where}*\V{dir.y};}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//Diese_Prozedur_wird_aufgerufen,_wenn_der_Strahl_den_Startpunkt_von_line_getroffen\CE{}}}
\L{\LB{\C{}//hat_und_festgestellt_werden_muss,_welche_Linie_sichtbar_ist.\CE{}}}
\L{\LB{\C{}//Entweder_line,_die_den_Punkt_nun_mal_als_Startpunkt_hat,_line.left\5,_die_den_Punkt\CE{}}}
\L{\LB{\C{}//als_Endpunkt_hat,_oder_beide.\CE{}}}
\L{\LB{\C{}//Eine_Linie_ist_dann_sichtbar,_wenn_der_Startpunkt_des_Strahles_auf_der_selben\CE{}}}
\L{\LB{\C{}//Linienseite_liegt,_wie_der_andere_Punkt_der_anderen_Linie\CE{}}}
\index{searchVisibleLine}\Proc{searchVisibleLine}\L{\LB{\K{procedure}_\V{searchVisibleLine}(\K{const}_\V{raystart}:_\V{tpointf};_\K{var}_\V{line}:_\V{TLine});}}
\L{\LB{\K{var}_\V{rayfromline1},}}
\L{\LB{}\Tab{4}{\V{rayfromline2}:_\V{integer};_\C{}//Seite_des_Strahlenstart_von_einer_der_Linie\CE{}}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\C{}//Fesstellen_auf_welcher_Seite,_der_an_den_Startpunkt_von_line_angrenzenden\CE{}}}
\L{\LB{}\Tab{2}{\C{}//Linien,_jeweils_der_Strahlstartpunkt_liegt\CE{}}}
\L{\LB{}\Tab{2}{\V{rayfromline2}:=\V{whichSide}(\V{line.start},\V{line.dir},\V{raystart});}}
\L{\LB{}\Tab{2}{\V{rayfromline1}:=\V{whichSide}(\V{line.left}\5\V{.start},\V{line.left}\5\V{.dir},\V{raystart});}}
\L{\LB{}\Tab{2}{\K{if}_\V{rayfromline1}=\V{rayfromline2}_\K{then}_\K{begin}_\C{}//Keine_Linie_wird_von_der_nderen_verdeckt\CE{}}}
\L{\LB{}\Tab{5}{\V{addSeePoint}(\V{line},\N{0},\V{true},\N{0},\V{raystart});}}
\L{\LB{}\Tab{5}{\V{addSeePoint}(\V{line.left}\5,\N{1},\V{false},\N{0},\V{raystart});}}
\L{\LB{}\Tab{2}{\K{end}_\K{else}_\K{if}_\V{whichSide}(\V{line.start},\V{line.dir},\V{line.left}\5\V{.start})\<\>\V{rayfromline2}_\K{then}}}
\L{\LB{}\Tab{5}{\C{}//line_trennt_line.left_vom_Strahl\CE{}}}
\L{\LB{}\Tab{5}{\V{addSeePoint}(\V{line},\N{0},\V{true},\N{0},\V{raystart})}}
\L{\LB{}\Tab{2}{\K{else}_\K{if}_\V{whichSide}(\V{line.left}\5\V{.start},\V{line.left}\5\V{.dir},\V{line.right}\5\V{.start})\<\>\V{rayfromline1}_\K{then}}}
\L{\LB{}\Tab{5}{\C{}//line.left_trennt_line_vom_Strahl\CE{}}}
\L{\LB{}\Tab{5}{\V{addSeePoint}(\V{line.left}\5,\N{1},\V{false},\N{0},\V{raystart})}}
\L{\LB{}\Tab{2}{\K{else}_\C{}//Keine_Linie_sichtbar_\CE{}}}
\L{\LB{}\Tab{5}{\V{raise}_\V{Exception.Create}(\S{}{'}Invisible_point{'}\SE{});}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//Überprüfen,_ob_der_Punkt_p_in_dem_Dreieck_a--b--c_liegt\CE{}}}
\L{\LB{\C{}//Da_ein_Dreieck_immer_konvex_ist,_muss_dafür_nur_überprüft_werden,\CE{}}}
\L{\LB{\C{}//ob_p_in_Bezug_auf_jede_Dreieckseite_auf_derselben_Seite_liegt\CE{}}}
\index{isPointInTri}\Proc{isPointInTri}\L{\LB{\K{function}_\V{isPointInTri}(\K{const}_\V{a},\V{b},\V{c},\V{p}:\V{tpointf}):\V{boolean};}}
\L{\LB{\K{var}_\V{s1},\V{s2},\V{s3}:_\V{integer};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{Result}:=\V{false};}}
\L{\LB{}\Tab{2}{\V{s1}:=\V{whichLineSide}(\V{a},\V{b},\V{p});}}
\L{\LB{}\Tab{2}{\V{s2}:=\V{whichLineSide}(\V{b},\V{c},\V{p});}}
\L{\LB{}\Tab{2}{\K{if}_\V{s1}\<\>\V{s2}_\K{then}_\K{exit};}}
\L{\LB{}\Tab{2}{\V{s3}:=\V{whichLineSide}(\V{c},\V{a},\V{p});}}
\L{\LB{}\Tab{2}{\V{result}:=(\V{s1}=\V{s3});}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//Überprüfen,_ob_der_Punkt_p_im_Viereck_a--b--c--d_liegt.\CE{}}}
\L{\LB{\C{}//Dabei_werden_die_Fälle_unterschieden,_dass_sich_das_Viereck_selbst_schneiden\CE{}}}
\L{\LB{\C{}//und_dass_es_konkav_ist._\CE{}}}
\index{isPointInQuad}\Proc{isPointInQuad}\L{\LB{\K{function}_\V{isPointInQuad}(\K{const}_\V{a},\V{b},\V{c},\V{d},\V{p}:\V{tpointf}):\V{boolean};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\K{if}_\V{whichLineSide}(\V{a},\V{b},\V{c})\<\>\V{whichLineSide}(\V{a},\V{b},\V{d})_\K{then}_\K{begin}}}
\L{\LB{}\Tab{4}{\C{}//a--b_und_c--d_schneiden_sich\CE{}}}
\L{\LB{}\Tab{4}{\C{}//Das_Viereck_lässt_sich_in_zwei_Bereiche_aufteilen:\CE{}}}
\L{\LB{}\Tab{6}{\C{}//a--b--c_geschnitten_mit_b--c--d\CE{}}}
\L{\LB{}\Tab{6}{\C{}//a--c--d_geschnitten_mit_a--b--d\CE{}}}
\L{\LB{}\Tab{4}{\V{Result}:=(\V{isPointInTri}(\V{a},\V{b},\V{c},\V{p})_\K{and}_\V{isPointInTri}(\V{b},\V{c},\V{d},\V{p}))_\K{or}}}
\L{\LB{}\Tab{12}{(\V{isPointInTri}(\V{a},\V{c},\V{d},\V{p})_\K{and}_\V{isPointInTri}(\V{a},\V{b},\V{d},\V{p}));}}
\L{\LB{}\Tab{2}{\K{end}_\K{else}_\K{if}_\V{whichLineSide}(\V{a},\V{d},\V{b})\<\>\V{whichLineSide}(\V{a},\V{d},\V{c})_\K{then}_\K{begin}}}
\L{\LB{}\Tab{4}{\C{}//a--d_und_b--c_schneiden_sich\CE{}}}
\L{\LB{}\Tab{4}{\C{}//Das_Viereck_lässt_sich_in_zwei_Bereiche_aufteilen:\CE{}}}
\L{\LB{}\Tab{6}{\C{}//a--b--c_geschnitten_mit_a--b--d\CE{}}}
\L{\LB{}\Tab{6}{\C{}//a--c--d_geschnitten_mit_b--c--d\CE{}}}
\L{\LB{}\Tab{4}{\V{Result}:=(\V{isPointInTri}(\V{a},\V{b},\V{c},\V{p})_\K{and}_\V{isPointInTri}(\V{a},\V{b},\V{d},\V{p}))_\K{or}}}
\L{\LB{}\Tab{12}{(\V{isPointInTri}(\V{a},\V{c},\V{d},\V{p})_\K{and}_\V{isPointInTri}(\V{b},\V{c},\V{d},\V{p}));}}
\L{\LB{}\Tab{2}{\K{end}_\K{else}_\K{if}_\V{whichLineSide}(\V{a},\V{c},\V{b})=\V{whichLineSide}(\V{a},\V{c},\V{d})_\K{then}_\K{begin}}}
\L{\LB{}\Tab{4}{\C{}//konkav,_da_die_Digonale_a--c_außerhalb_liegt\CE{}}}
\L{\LB{}\Tab{4}{\C{}//}\Tab{8}{=\>_Aufteilung_entlang_der_Diagonalen_b--d\CE{}}}
\L{\LB{}\Tab{4}{\V{Result}:=(\V{isPointInTri}(\V{a},\V{b},\V{d},\V{p})_\K{and}_\V{isPointInTri}(\V{b},\V{c},\V{d},\V{p}));}}
\L{\LB{}\Tab{2}{\K{end}_\K{else}_\K{begin}}}
\L{\LB{}\Tab{4}{\C{}//entweder_konvex,_oder_konkav_mit_b--d_außerhalb\CE{}}}
\L{\LB{}\Tab{4}{\C{}//}\Tab{8}{=\>_Aufteilung_entlang_der_Diagonalen_a--c_ist_möglich\CE{}}}
\L{\LB{}\Tab{4}{\V{Result}:=(\V{isPointInTri}(\V{a},\V{b},\V{c},\V{p})_\K{and}_\V{isPointInTri}(\V{a},\V{b},\V{d},\V{p}));}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//Berechnet_alle_Segmente_die_man_vom_Punkt_p_aus_sehen_kann.\CE{}}}
\index{TmuseumForm.lookFromPoint}\Proc{TmuseumForm.lookFromPoint}\L{\LB{\K{procedure}_\V{TmuseumForm.lookFromPoint}(\K{const}_\V{p}:_\V{tpointf});}}
\L{\LB{\K{var}_\V{i},\V{j},\V{k}:\V{integer};}\Tab{32}{\C{}//loop-Counter\CE{}}}
\L{\LB{}\Tab{4}{\V{dir}:_\V{tpointf};}\Tab{32}{\C{}//Richtung_des_Strahls\CE{}}}
\L{\LB{}\Tab{4}{\V{rayHit}:\V{TRayHitPoints};}\Tab{32}{\C{}//Informationen_über_die_Strahlentreffer\CE{}}}
\L{\LB{}\Tab{4}{\V{hideLeft},\V{hideRight}:\V{boolean};_\C{}//liegt_auf_einer_der_beiden_Seiten_eine_Zacke\CE{}}}
\L{\LB{}\Tab{4}{\V{hiddenside}:_\V{integer};}\Tab{32}{\C{}//Seite_auf_der_die_einzigste_Zacke_liegt\CE{}}}
\L{\LB{}\Tab{4}{\V{pointSide}:_\V{integer};}\Tab{32}{\C{}//Seite_auf_der_die_Linie_an_einem_getroffenen_Punkt_liegt\CE{}}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{museum})_\K{do}}}
\L{\LB{}\Tab{4}{\K{for}_\V{j}:=\N{0}_\K{to}_\V{high}(\V{museum}[\V{i}])_\K{do}_\K{begin}}}
\L{\LB{}\Tab{6}{\C{}//Für_jeden_Punkt_wird_die_Richtung_dorthin_berechnet\CE{}}}
\L{\LB{}\Tab{6}{\V{dir.x}:=\V{museum}[\V{i},\V{j}]\V{.start.x}\-\V{p.x};}}
\L{\LB{}\Tab{6}{\V{dir.y}:=\V{museum}[\V{i},\V{j}]\V{.start.y}\-\V{p.y};}}
\L{\LB{}\Tab{6}{\C{}//Und_der_Strahl_wird_losgesendet\CE{}}}
\L{\LB{}\Tab{6}{\V{findRayHitPoints}(\V{museum},\V{p},\V{dir},\V{rayHit});}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\K{if}_\V{rayHit.when}=\V{inf}_\K{then}_\V{raise}_\V{Exception.create}(\S{}{'}Hasn{'}\SE{}\S{}{'}t_hit_something{'}\SE{});}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\C{}//Ist_links_oder_rechts_eine_Zacke\CE{}}}
\L{\LB{}\Tab{6}{\V{hideLeft}:=\V{false};_\V{hideRight}:=\V{false};}}
\L{\LB{}\Tab{6}{\K{for}_\V{k}:=\N{0}_\K{to}_\V{high}(\V{rayHit.between})_\K{do}}}
\L{\LB{}\Tab{8}{\K{case}_\V{rayHit.between}[\V{k}]\V{.side}_\K{of}}}
\L{\LB{}\Tab{10}{\-\N{1}:_\V{hideLeft}:=\V{true};_\C{}//Zacke_links\CE{}}}
\L{\LB{}\Tab{10}{\N{1}:_\V{hideRight}:=\V{true};_\C{}//Zacke_rechts\CE{}}}
\L{\LB{}\Tab{10}{\N{0}:_\V{raise}_\V{Exception.Create}(\S{}{'}Ray_isn{'}\SE{}\S{}{'}t_stopped,_after_point_collision{'}\SE{});}}
\L{\LB{}\Tab{8}{\K{end};}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\K{if}_\V{hideLeft}_\K{then}_\C{}//Zacke_links\CE{}}}
\L{\LB{}\Tab{8}{\K{for}_\V{k}:=\N{0}_\K{to}_\V{high}(\V{rayhit.between})_\K{do}}}
\L{\LB{}\Tab{10}{\K{if}_\V{rayHit.between}[\V{k}]\V{.side}=\-\N{1}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{12}{\K{with}_\V{rayhit.between}[\V{k}]_\K{do}}}
\L{\LB{}\Tab{14}{\V{searchVisibleLine}(\V{p},\V{museum}[\V{poly},\V{point}]);\C{}//Eckpunkt_ist_sichtbar\CE{}}}
\L{\LB{}\Tab{12}{\K{break};}}
\L{\LB{}\Tab{10}{\K{end};}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\K{if}_\V{hideRight}_\K{then}_\C{}//Zacke_rechts\CE{}}}
\L{\LB{}\Tab{8}{\K{for}_\V{k}:=\N{0}_\K{to}_\V{high}(\V{rayhit.between})_\K{do}}}
\L{\LB{}\Tab{10}{\K{if}_\V{rayHit.between}[\V{k}]\V{.side}=\N{1}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{12}{\K{with}_\V{rayhit.between}[\V{k}]_\K{do}}}
\L{\LB{}\Tab{14}{\V{searchVisibleLine}(\V{p},\V{museum}[\V{poly},\V{point}]);\C{}//Eckpunkt_ist_sichtbar\CE{}}}
\L{\LB{}\Tab{12}{\K{break};}}
\L{\LB{}\Tab{10}{\K{end};}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\K{if}_\V{hideLeft}_\K{and}_\V{hideRight}_\K{then}_\K{continue};_\C{}//Links_und_rechts_eine_Zacke\CE{}}}
\L{\LB{}\Tab{47}{\C{}//_=\>_abbruch,_nur_Zacken_sieht_man\CE{}}}
\L{\LB{}\Tab{6}{\C{}//Seite_suchen,_auf_der_eine_Zacke_ist\CE{}}}
\L{\LB{}\Tab{6}{\K{if}_\V{hideleft}_\K{then}_\V{hiddenside}:=\-\N{1}}}
\L{\LB{}\Tab{6}{\K{else}_\K{if}_\V{hideright}_\K{then}_\V{hiddenside}:=\N{1}}}
\L{\LB{}\Tab{6}{\K{else}_\V{hiddenside}:=\N{0};}}
\L{\LB{}}
\L{\LB{}\Tab{6}{\K{if}_\V{rayHit.where}=\N{0}_\K{then}_\K{begin}_\C{}//Ecke_getroffen\CE{}}}
\L{\LB{}\Tab{8}{\C{}//Auf_welcher_Seite_liegt_die_eine_angrenzende_Linie\CE{}}}
\L{\LB{}\Tab{8}{\V{pointSide}:=\V{whichSide}(\V{p},\V{dir},\V{museum}[\V{rayhit.poly},\V{rayhit.Line}]\V{.right}\5\V{.start});}}
\L{\LB{}\Tab{8}{\C{}//Wird_diese_Seite_nicht_verdeckt\CE{}}}
\L{\LB{}\Tab{8}{\K{if}_(\V{pointSide}\<\>\V{hiddenSide})_\K{or}_(\V{hiddenSide}=\N{0})_\K{then}}}
\L{\LB{}\Tab{10}{\K{with}_\V{museum}[\V{rayHit.poly},\V{rayHit.line}]_\K{do}_\C{}//Seite_ist_sichtbar\CE{}}}
\L{\LB{}\Tab{12}{\V{addSeePoint}(\V{museum}[\V{rayHit.poly},\V{rayHit.line}],\N{0},\V{true},\V{hiddenside},\V{p});}}
\L{\LB{}}
\L{\LB{}\Tab{8}{\C{}//Wird_die_andere_Seite_nicht_verdeckt\CE{}}}
\L{\LB{}\Tab{8}{\K{if}_(\-\V{pointSide}\<\>\V{hiddenSide})_\K{or}_(\V{hiddenSide}=\N{0})_\K{then}}}
\L{\LB{}\Tab{10}{\K{with}_\V{museum}[\V{rayHit.poly},\V{rayHit.line}]\V{.Left}\5_\K{do}_\C{}//ist_sie_auch_sichtbar\CE{}}}
\L{\LB{}\Tab{12}{\V{addSeePoint}(\V{museum}[\V{rayhit.poly},\V{rayHit.line}]\V{.Left}\5,\N{1},\V{false},\V{hiddenside},\V{p});}}
\L{\LB{}\Tab{6}{\K{end}_\K{else}_\K{begin}_\C{}//Kante_getroffen\CE{}}}
\L{\LB{}\Tab{8}{\K{if}_\K{not}_(\V{hideleft}_\K{or}_\V{hideRight})_\K{then}_\K{continue};_\C{}//Strahl_ist_nutzlos\CE{}}}
\L{\LB{}\Tab{8}{\C{}//feststellen_auf_welcher_Seite_der_Startpunkt_liegt\CE{}}}
\L{\LB{}\Tab{8}{\C{}//Das_Segment_liegt_in_Linienrichtung,_wenn_der_Startpunkt_verdeckt_wird\CE{}}}
\L{\LB{}\Tab{8}{\V{addSeePoint}(\V{museum}[\V{rayHit.poly},\V{rayHit.line}],}}
\L{\LB{}\Tab{20}{\V{rayHit.where},}}
\L{\LB{}\Tab{20}{\V{whichSide}(\V{p},\V{dir},\V{museum}[\V{rayhit.poly},\V{rayhit.Line}]\V{.start})=\V{hiddenSide},}}
\L{\LB{}\Tab{20}{\V{hiddenside},\V{p});}}
\L{\LB{}\Tab{6}{\K{end};}}
\L{\LB{}\Tab{4}{\K{end};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\C{}//Berechnet_alle_Segmente,_die_man_von_einer_Weglinie_aus_sehen_kann\CE{}}}
\index{TmuseumForm.lookFromWayLine}\Proc{TmuseumForm.lookFromWayLine}\L{\LB{\K{procedure}_\V{TmuseumForm.lookFromWayLine}(\K{var}_\V{line}:_\V{TLine});}}
\L{\LB{\K{var}_\V{p1},\V{l1},\V{p2},\V{l2}:_\V{integer};}\Tab{37}{\C{}//Polygon_und_Linien_loop-Variablen\CE{}}}
\L{\LB{}\Tab{4}{\V{u},\V{v}:_\V{double};}\Tab{37}{\C{}//Position_des_getroffenen_Punktes_(Strahl,Linie)\CE{}}}
\L{\LB{}\Tab{4}{\V{raystart},\V{waystart},\V{waydir}:\V{ppointf};\C{}//Strahlstart,_Weglinienstart,_Wegrichtung\CE{}}}
\L{\LB{}\Tab{4}{\V{raydir},\V{wayhit}:_\V{tpointf};}\Tab{37}{\C{}//Strahlrichtung_und_getroffener_Punkt_auf_der_Weglini\CE{}}}
\L{\LB{}\Tab{4}{\V{divisor}:_\V{double};}\Tab{37}{\C{}//zwischengespeicherter_Nenner\CE{}}}
\L{\LB{}\Tab{4}{\V{hitInfo}:_\V{TRayHitPoints};}\Tab{37}{\C{}//Informationen_über_die_Treffer_eines_Strahls\CE{}}}
\L{\LB{}\Tab{4}{\V{side1},\V{side2},\V{tempside}:_\V{integer};}}
\L{\LB{_\K{begin}}}
\L{\LB{}\Tab{3}{\C{}//Sichtbarkeit_von_den_Linienecken_berechnen\CE{}}}
\L{\LB{}\Tab{3}{\V{lookFromPoint}(\V{line.start});}}
\L{\LB{}\Tab{3}{\V{lookFromPoint}(\V{line.right}\5\V{.start});}}
\L{\LB{}}
\L{\LB{}\Tab{3}{\C{}//Schönere_Namen_geben\CE{}}}
\L{\LB{}\Tab{3}{\V{waystart}:=@\V{line.start};}}
\L{\LB{}\Tab{3}{\V{waydir}:=@\V{line.dir};}}
\L{\LB{}\Tab{3}{\K{for}_\V{p1}:=\N{0}_\K{to}_\V{high}(\V{museum})_\K{do}}}
\L{\LB{}\Tab{4}{\K{for}_\V{p2}:=\N{0}_\K{to}_\V{high}(\V{museum})_\K{do}}}
\L{\LB{}\Tab{5}{\K{if}_\V{p1}\<=\V{p2}_\K{then}}}
\L{\LB{}\Tab{6}{\K{for}_\V{l1}:=\N{0}_\K{to}_\V{high}(\V{museum}[\V{p1}])_\K{do}}}
\L{\LB{}\Tab{7}{\K{for}_\V{l2}:=\N{0}_\K{to}_\V{high}(\V{museum}[\V{p2}])_\K{do}_\K{begin}}}
\L{\LB{}\Tab{9}{\K{if}_(\V{p1}=\V{p2})_\K{and}_(\V{l1}+\N{1}\>=\V{l2})_\K{then}_\K{continue};}}
\L{\LB{}\Tab{10}{\C{}//Jetzt_sind_zwei_Punkte_museum[p1,l1].start_und_.\,.\,.p2,l2.\,.\,._gewählt\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\C{}//Strahlvektoren_vom_ersten_zum_zweiten_Punkt_speichern\CE{}}}
\L{\LB{}\Tab{9}{\V{raystart}:=@\V{museum}[\V{p1},\V{l1}]\V{.start};}}
\L{\LB{}\Tab{9}{\V{raydir.x}:=\V{museum}[\V{p2},\V{l2}]\V{.start.x}\-\V{raystart.x};}}
\L{\LB{}\Tab{9}{\V{raydir.y}:=\V{museum}[\V{p2},\V{l2}]\V{.start.y}\-\V{raystart.y};}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\C{}//Position_der_Linien_an_den_Punkten_überprüfen\CE{}}}
\L{\LB{}\Tab{9}{\V{side1}:=\V{whichSide}(\V{raystart}\5,\V{raydir},\V{museum}[\V{p1},\V{l1}]\V{.left}\5\V{.start});}}
\L{\LB{}\Tab{9}{\V{tempside}:=\V{whichSide}(\V{raystart}\5,\V{raydir},\V{museum}[\V{p1},\V{l1}]\V{.right}\5\V{.start});}}
\L{\LB{}\Tab{9}{\K{if}_(\V{side1}\<\>\V{tempside})_\K{then}_\V{side1}:=\N{0};_\C{}//Keine_Zacke_an_Punkt_1\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\V{side2}:=\V{whichSide}(\V{raystart}\5,\V{raydir},\V{museum}[\V{p2},\V{l2}]\V{.left}\5\V{.start});}}
\L{\LB{}\Tab{9}{\V{tempside}:=\V{whichSide}(\V{raystart}\5,\V{raydir},\V{museum}[\V{p2},\V{l2}]\V{.right}\5\V{.start});}}
\L{\LB{}\Tab{9}{\K{if}_(\V{side2}\<\>\V{tempside})_\K{then}_\V{side2}:=\N{0};_\C{}//Keine_Zacke_an_Punkt_2\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\K{if}_(\V{side1}=\V{side2})_\K{and}_(\V{side1}\<\>\N{0})_\K{then}}}
\L{\LB{}\Tab{11}{\K{continue};_\C{}//Strahl_ist_nutzlos,_da_zwei_Zacken_auf_derselben_Seite\CE{}}}
\L{\LB{}\Tab{59}{}}
\L{\LB{}\Tab{9}{\C{}//Schnittpunkt_mit_dem_Weg_berechnen_(siehe_findRayHitPoints)\CE{}}}
\L{\LB{}\Tab{9}{\V{divisor}:=\V{raydir.x}*\V{wayDir.y}_\-_\V{raydir.y}*\V{wayDir.x};}}
\L{\LB{}\Tab{9}{\K{if}_\V{abs}(\V{divisor})\<\V{epsilon}_\K{then}_\K{continue};}}
\L{\LB{}\Tab{9}{\V{v}_:=_(\V{raydir.x}*(\V{raystart.y}_\-_\V{waystart.y})_+_\V{raydir.y}*(\V{waystart.x}_\-_\V{raystart.x}))/\V{divisor};}}
\L{\LB{}\Tab{9}{\K{if}_(\V{v}\<=\N{0})_\K{or}_(\V{v}\>=\N{1})_\K{then}_\K{continue};}}
\L{\LB{}\Tab{9}{\V{u}_:=_(\V{wayDir.x}*(\V{raystart.y}_\-_\V{waystart.y})_+_\V{wayDir.y}*(\V{waystart.x}_\-_\V{raystart.x}))/\V{divisor};}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\K{if}_\V{u}\<\N{0}_\K{then}_\K{begin}_\C{}//Strahl_verläuft_falschherum\CE{}}}
\L{\LB{}\Tab{11}{\C{}//Startpunkt_wechseln\CE{}}}
\L{\LB{}\Tab{11}{\V{raystart}:=@\V{museum}[\V{p2},\V{l2}]\V{.start};}}
\L{\LB{}\Tab{11}{\C{}//Richtung_invertieren\CE{}}}
\L{\LB{}\Tab{11}{\V{raydir.x}:=\-\V{raydir.x};}}
\L{\LB{}\Tab{11}{\V{raydir.y}:=\-\V{raydir.y};}}
\L{\LB{}\Tab{11}{\C{}//Neue_Position_in_Anbetracht_der_beiden_Änderungen_berechnen\CE{}}}
\L{\LB{}\Tab{11}{\V{u}:=\-\V{u}+\N{1};}}
\L{\LB{}\Tab{11}{\C{}//Zackeninformationen_über_die_beiden_Punkte_tauschen\CE{}}}
\L{\LB{}\Tab{11}{\V{tempside}:=\-\V{side1};}}
\L{\LB{}\Tab{11}{\V{side1}:=\-\V{side2};}}
\L{\LB{}\Tab{11}{\V{side2}:=\V{tempside};}}
\L{\LB{}\Tab{9}{\K{end};}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\C{}//Einen_Strahl_in_Richtung_des_Weges_aus_senden\CE{}}}
\L{\LB{}\Tab{9}{\V{findRayHitPoints}(\V{museum},\V{raystart}\5,\V{raydir},\V{hitInfo});}}
\L{\LB{}\Tab{9}{\K{if}_(\V{hitInfo.when}\<\V{u})_\K{or}_(\V{hitInfo.when}\<\N{1})_\K{then}}}
\L{\LB{}\Tab{11}{\K{continue};_\C{}//Strahl_zu_früh_unterbrochen\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\C{}//Vorhin_auf_der_Weglinie_getroffenen_Punkt_ausrechnen\CE{}}}
\L{\LB{}\Tab{9}{\V{wayhit.x}:=\V{raystart}\5\V{.x}+\V{u}*\V{raydir.x};}}
\L{\LB{}\Tab{9}{\V{wayhit.y}:=\V{raystart}\5\V{.y}+\V{u}*\V{raydir.y};}}
\L{\LB{}\Tab{9}{\C{}//Die_beiden_gewählten_Punkte_sind_von_diesem_Punkt_aus_sichtbar\CE{}}}
\L{\LB{}\Tab{9}{\V{searchVisibleLine}(\V{wayhit},\V{museum}[\V{p1},\V{l1}]);}}
\L{\LB{}\Tab{9}{\V{searchVisibleLine}(\V{wayhit},\V{museum}[\V{p2},\V{l2}]);}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\K{if}_(\V{side1}=\N{0})\K{or}(\V{side2}=\N{0})_\K{then}_\K{continue};_\C{}//Alle_Punkte_sind_berücksichtigt\CE{}}}
\L{\LB{}\Tab{9}{\K{if}_\V{u}\<\N{1}_\K{then}_\K{continue};_\C{}//Weglinie_kommt_zu_früh\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\C{}//Strahl_in_die_andere_Richtung_senden\CE{}}}
\L{\LB{}\Tab{9}{\V{raydir.x}:=\-\V{raydir.x};}}
\L{\LB{}\Tab{9}{\V{raydir.y}:=\-\V{raydir.y};}}
\L{\LB{}\Tab{9}{\C{}//und_Kollision_mit_dem_Polygon_berechnen\CE{}}}
\L{\LB{}\Tab{9}{\V{findRayHitPoints}(\V{museum},\V{raystart}\5,\V{raydir},\V{hitInfo});}}
\L{\LB{}}
\L{\LB{}\Tab{9}{\C{}//Sichtbaren_Punkt_speichern\CE{}}}
\L{\LB{}\Tab{9}{\C{}//Das_Segment_liegt_auf_der_anderen_Seite,_als_der_zweite_Punkt,_also\CE{}}}
\L{\LB{}\Tab{9}{\C{}//wenn_der_Startpunkt_der_Linie_auf_derselben_Seite_wie_dieser_Punkt_liegt,\CE{}}}
\L{\LB{}\Tab{9}{\C{}//zeigt_das_Segment_in_Richtung_des_Endes_der_Linie\CE{}}}
\L{\LB{}\Tab{9}{\V{addSeePoint}(\V{museum}[\V{hitinfo.poly},\V{hitinfo.line}],_\V{hitinfo.where},}}
\L{\LB{}\Tab{21}{\V{whichSide}(\V{raystart}\5,\V{raydir},\V{museum}[\V{hitinfo.poly},\V{hitinfo.Line}]\V{.start})_\>\N{0}=(\V{side2}\>\N{0}),}}
\L{\LB{}\Tab{21}{\V{side1},\V{wayhit});}}
\L{\LB{}\Tab{7}{\K{end};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//Berechnet_die_sichtbaren_Bereiche_aus_den_sichtbaren_Segmenten\CE{}}}
\index{TmuseumForm.convertLookPoints}\Proc{TmuseumForm.convertLookPoints}\L{\LB{\K{procedure}_\V{TmuseumForm.convertLookPoints};}}
\L{\LB{\K{var}_\V{i},\V{j},\V{k},\V{l},\V{m},\V{n},\V{o}:\V{integer};}\Tab{28}{\C{}//loop-Variablen_(Schachtelung_ist_sehr_übersichtlich)\CE{}}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\V{border1Start},\V{border1End},\V{border2Start},\V{border2End}:_\V{integer};}}
\L{\LB{}}
\L{\LB{}\Tab{4}{\V{raydir}:\V{tpointf};}}
\L{\LB{}\Tab{4}{\V{nextLoop}:_\V{boolean};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{border2Start}:=\-\N{1};}\Tab{21}{\V{border1End}:=\-\N{1};_\C{}//wegen_warnung_über_fehlende_initialisierung\CE{}}}
\L{\LB{}\Tab{2}{\C{}//Es_wird_der_größtmögliche_sichtbare_Bereich_gewählt.\CE{}}}
\L{\LB{}\Tab{2}{\C{}//Das_heißt_bei_mehreren_aufeinanderfolgenden_nach_rechts_blickenden_Punkten\CE{}}}
\L{\LB{}\Tab{2}{\C{}//wird_der_erste_genommen,_bei_nach_links_blickenden_dagegen_der_letzte\CE{}}}
\L{\LB{}\Tab{2}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{museum})_\K{do}}}
\L{\LB{}\Tab{4}{\K{for}_\V{j}:=\N{0}_\K{to}_\V{high}(\V{museum}[\V{i}])_\K{do}}}
\L{\LB{}\Tab{6}{\C{}//Linie_auswählen\CE{}}}
\L{\LB{}\Tab{6}{\K{with}_\V{museum}[\V{i},\V{j}]_\K{do}_\K{begin}}}
\L{\LB{}\Tab{8}{\K{if}_\V{length}(\V{sees})=\N{0}_\K{then}_\K{continue};_\C{}//Keine_sichtbaren_Punkte_=\>_Weiter\CE{}}}
\L{\LB{}\Tab{8}{\K{if}_\V{length}(\V{sees})=\N{1}_\K{then}_\K{begin}_\C{}//Macht_keinen_Sinn_=\>_Abbruch\CE{}}}
\L{\LB{}\Tab{10}{\V{setlength}(\V{seenAreas},\N{0});}}
\L{\LB{}\Tab{10}{\K{exit};}}
\L{\LB{}\Tab{8}{\K{end};}}
\L{\LB{}\Tab{8}{\V{k}:=\N{0};}}
\L{\LB{}\Tab{8}{\K{while}_\V{k}\<=\V{high}(\V{sees})_\K{do}_\K{begin}}}
\L{\LB{}\Tab{10}{\V{border2End}:=\V{high}(\V{sees});}}
\L{\LB{}\Tab{10}{\V{border1Start}:=\V{k};_\C{}//erster_nach_rechts_blickender_Punkt_(Startpunkt)\CE{}}}
\L{\LB{}\Tab{10}{\K{for}_\V{l}:=\V{k}+\N{1}_\K{to}_\V{high}(\V{sees})_\K{do}}}
\L{\LB{}\Tab{12}{\K{if}_\K{not}_\V{sees}[\V{l}]\V{.seeRight}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{14}{\V{border1End}:=\V{l}\-\N{1};_\C{}//letzter_Startpunkt\CE{}}}
\L{\LB{}\Tab{14}{\V{border2Start}:=\V{l};_\C{}//erster_nach_links_blickender_(Endpunkt)\CE{}}}
\L{\LB{}\Tab{14}{\K{break};}}
\L{\LB{}\Tab{12}{\K{end};}}
\L{\LB{}\Tab{10}{\K{if}_\V{border1End}\<\V{border1Start}_\K{then}_\K{begin}_\C{}//Macht_keinen_Sinn_=\>_Abbruch\CE{}}}
\L{\LB{}\Tab{12}{\V{setlength}(\V{seenAreas},\N{0});}}
\L{\LB{}\Tab{12}{\K{exit};}}
\L{\LB{}\Tab{10}{\K{end};}}
\L{\LB{}\Tab{10}{\K{for}_\V{l}:=\V{border1End}+\N{1}_\K{to}_\V{high}(\V{sees})_\K{do}}}
\L{\LB{}\Tab{12}{\K{if}_\V{sees}[\V{l}]\V{.seeRight}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{14}{\V{border2End}:=\V{l}\-\N{1};_\C{}//letzer_Endpunkt\CE{}}}
\L{\LB{}\Tab{14}{\K{break};}}
\L{\LB{}\Tab{12}{\K{end};}}
\L{\LB{}\Tab{10}{\V{k}:=\V{border2End}+\N{1};}}
\L{\LB{}}
\L{\LB{}\Tab{10}{\K{for}_\V{l}:=\V{border1Start}_\K{to}_\V{border1End}_\K{do}_\C{}//Je_einen_Startpunkt\CE{}}}
\L{\LB{}\Tab{12}{\K{for}_\V{m}:=\V{border2Start}_\K{to}_\V{border2End}_\K{do}_\K{begin}_\C{}//und_Endpunkt_auswählen\CE{}}}
\L{\LB{}\Tab{14}{\K{if}_(\V{abs}(\V{sees}[\V{l}]\V{.from.x}\-\V{sees}[\V{m}]\V{.from.x})\>\V{epsilon})_\K{or}}}
\L{\LB{}\Tab{17}{(\V{abs}(\V{sees}[\V{l}]\V{.from.y}\-\V{sees}[\V{m}]\V{.from.y})\>\V{epsilon})_\K{then}_\K{begin}}}
\L{\LB{}\Tab{16}{\C{}//Wenn_kein_Dreieck,_dann,_Sichtbarkeitstests_durchführen\CE{}}}
\L{\LB{}\Tab{16}{\C{}//Strahl_von_dem_Punkt,_von_dem_aus_der_Startpunkt_sichtbar_ist\CE{}}}
\L{\LB{}\Tab{16}{\C{}//zum_Startpunkt_erstellen\CE{}}}
\L{\LB{}\Tab{16}{\V{raydir.x}:=\V{sees}[\V{l}]\V{.wherePos.x}\-\V{sees}[\V{l}]\V{.from.x};}}
\L{\LB{}\Tab{16}{\V{raydir.y}:=\V{sees}[\V{l}]\V{.wherePos.y}\-\V{sees}[\V{l}]\V{.from.y};}}
\L{\LB{}\Tab{16}{\C{}//Liegt,_der_andere_Blickpunkt_auf_derselben_Seite,_wie_die\CE{}}}
\L{\LB{}\Tab{16}{\C{}//blockierende_Zacke,_so_ist_der_Bereich_nicht_komplett_sichtbar\CE{}}}
\L{\LB{}\Tab{16}{\K{if}_\V{sees}[\V{l}]\V{.hiddenRaySide}=}}
\L{\LB{}\Tab{19}{\V{whichSide}(\V{sees}[\V{l}]\V{.from},\V{raydir},\V{sees}[\V{m}]\V{.from})_\K{then}_\K{continue};}}
\L{\LB{}\Tab{16}{\C{}//Liegt,_der_andere_Blickpunkt_auf_derselben_Seite,_wie_der_von\CE{}}}
\L{\LB{}\Tab{16}{\C{}//dort_gesehene_Endpunkt,_so_ist_der_Bereich_nicht_komplett_sichtbar\CE{}}}
\L{\LB{}\Tab{16}{\K{if}_\V{whichSide}(\V{sees}[\V{l}]\V{.from},\V{raydir},\V{sees}[\V{m}]\V{.wherePos})=}}
\L{\LB{}\Tab{19}{\V{whichSide}(\V{sees}[\V{l}]\V{.from},\V{raydir},\V{sees}[\V{m}]\V{.from})_\K{then}_\K{continue};}}
\L{\LB{}\Tab{16}{\C{}//Die_gleichen_Tests_für_den_Endpunkt_ausführen\CE{}}}
\L{\LB{}\Tab{16}{\V{raydir.x}:=\V{sees}[\V{m}]\V{.wherePos.x}\-\V{sees}[\V{m}]\V{.from.x};}}
\L{\LB{}\Tab{16}{\V{raydir.y}:=\V{sees}[\V{m}]\V{.wherePos.y}\-\V{sees}[\V{m}]\V{.from.y};}}
\L{\LB{}\Tab{16}{\K{if}_\V{sees}[\V{m}]\V{.hiddenRaySide}=}}
\L{\LB{}\Tab{19}{\V{whichSide}(\V{sees}[\V{m}]\V{.from},\V{raydir},\V{sees}[\V{l}]\V{.from})_\K{then}_\K{continue};}}
\L{\LB{}\Tab{16}{\K{if}_\V{whichSide}(\V{sees}[\V{m}]\V{.from},\V{raydir},\V{sees}[\V{l}]\V{.wherePos})=}}
\L{\LB{}\Tab{19}{\V{whichSide}(\V{sees}[\V{m}]\V{.from},\V{raydir},\V{sees}[\V{l}]\V{.from})_\K{then}_\K{continue};}}
\L{\LB{}}
\L{\LB{}\Tab{16}{\C{}//Haben_die_bisherigen_Tests_nichts_erbracht,_so_muss_für_jede\CE{}}}
\L{\LB{}\Tab{16}{\C{}//Ecke_des_Polygon_überprüft_werden,_ob_sie_innerhalb_des_neuen\CE{}}}
\L{\LB{}\Tab{16}{\C{}//Bereichs_wäre\CE{}}}
\L{\LB{}\Tab{16}{\V{nextLoop}:=\V{false};}}
\L{\LB{}\Tab{16}{\K{for}_\V{n}:=\N{0}_\K{to}_\V{high}(\V{museum})_\K{do}}}
\L{\LB{}\Tab{18}{\K{for}_\V{o}:=\N{0}_\K{to}_\V{high}(\V{museum}[\V{n}])_\K{do}}}
\L{\LB{}\Tab{20}{\K{if}_\V{isPointInQuad}(\V{sees}[\V{l}]\V{.from},\V{sees}[\V{l}]\V{.wherePos},\V{sees}[\V{m}]\V{.wherePos},\V{sees}[\V{m}]\V{.from},}}
\L{\LB{}\Tab{30}{\V{museum}[\V{n},\V{o}]\V{.start})_\K{then}_\K{begin}}}
\L{\LB{}\Tab{22}{\V{nextLoop}:=\V{true};_\C{}//Leider_ist_die_Ecke_drin_=\>_nächste_Kombination\CE{}}}
\L{\LB{}\Tab{22}{\K{break};}}
\L{\LB{}\Tab{20}{\K{end};}}
\L{\LB{}\Tab{16}{\K{if}_\V{nextLoop}_\K{then}_\K{continue};}}
\L{\LB{}\Tab{14}{\K{end};}}
\L{\LB{}}
\L{\LB{}\Tab{14}{\C{}//Bereich_hat_die_Tests_bestanden_und_ist_somit_sichtbar.\CE{}}}
\L{\LB{}\Tab{14}{\V{SetLength}(\V{seenAreas},\V{length}(\V{seenAreas})+\N{1});}}
\L{\LB{}\Tab{14}{\V{seenAreas}[\V{high}(\V{seenAreas})][\N{0}]:=\V{sees}[\V{l}]\V{.from};}}
\L{\LB{}\Tab{14}{\V{seenAreas}[\V{high}(\V{seenAreas})][\N{1}]:=\V{sees}[\V{l}]\V{.wherePos};}}
\L{\LB{}\Tab{14}{\V{seenAreas}[\V{high}(\V{seenAreas})][\N{2}]:=\V{sees}[\V{m}]\V{.wherePos};}}
\L{\LB{}\Tab{14}{\V{seenAreas}[\V{high}(\V{seenAreas})][\N{3}]:=\V{sees}[\V{m}]\V{.from};}}
\L{\LB{}\Tab{12}{\K{end};}}
\L{\LB{}\Tab{8}{\K{end};}}
\L{\LB{}\Tab{8}{\C{}//Bisherige_Segmente_löschen\CE{}}}
\L{\LB{}\Tab{8}{\V{setlength}(\V{sees},\N{0});}}
\L{\LB{}\Tab{6}{\K{end};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\C{}//\CE{}}}
\index{TmuseumForm.lookAround}\Proc{TmuseumForm.lookAround}\L{\LB{\K{procedure}_\V{TmuseumForm.lookAround}();}}
\L{\LB{\K{var}_\V{i}:\V{integer};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{setlength}(\V{seenAreas},\N{0});}}
\L{\LB{}\Tab{2}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{guardsway})_\K{do}}}
\L{\LB{}\Tab{2}{\K{begin}}}
\L{\LB{}\Tab{4}{\V{lookFromWayLine}(\V{guardsway}[\V{i}]);}}
\L{\LB{}\Tab{4}{\V{convertLookPoints};}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{\C{}//==============Sonstiges_(GUI)====================\CE{}}}
\index{TmuseumForm.FormMouseWheel}\Proc{TmuseumForm.FormMouseWheel}\L{\LB{\K{procedure}_\V{TmuseumForm.FormMouseWheel}(\V{Sender}:_\V{TObject};_\V{Shift}:_\V{TShiftState};}}
\L{\LB{}\Tab{2}{\V{WheelDelta}:_\V{Integer};_\V{MousePos}:_\V{TPoint};_\K{var}_\V{Handled}:_\V{Boolean});}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\K{if}_\V{WheelDelta}\<\N{0}_\K{then}_\V{zoom}:=\V{zoom}/(\N{1.01}*(\V{WheelDelta}/\N{60}))}}
\L{\LB{}\Tab{2}{\K{else}_\V{zoom}:=\-\V{zoom}*\N{1.01}*\V{WheelDelta}/\N{60};}}
\L{\LB{}\Tab{2}{\V{Refresh};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\index{TmuseumForm.outputPaintBoxMouseDown}\Proc{outputPaintBoxMouseDown}\L{\LB{\K{procedure}_\V{TmuseumForm.outputPaintBoxMouseDown}(\V{Sender}:_\V{TObject};_\V{Button}:_\V{TMouseButton};}}
\L{\LB{}\Tab{2}{\V{Shift}:_\V{TShiftState};_\V{X},_\V{Y}:_\V{Integer});}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{clickPos.x}:=\V{x};}}
\L{\LB{}\Tab{2}{\V{clickPos.y}:=\V{y};}}
\L{\LB{}\Tab{2}{\V{oldnullpoint}:=\V{nullpoint};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\index{TmuseumForm.outputPaintBoxMouseMove}\Proc{outputPaintBoxMouseMove}\L{\LB{\K{procedure}_\V{TmuseumForm.outputPaintBoxMouseMove}(\V{Sender}:_\V{TObject};_\V{Shift}:_\V{TShiftState};_\V{X},}}
\L{\LB{}\Tab{2}{\V{Y}:_\V{Integer});}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\K{if}_\V{ssleft}_\K{in}_\V{shift}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{4}{\V{nullpoint.x}:=\V{oldnullpoint.x}+\V{x}\-\V{clickPos.x};}}
\L{\LB{}\Tab{4}{\V{nullpoint.y}:=\V{oldnullpoint.y}+\V{y}\-\V{clickPos.y};}}
\L{\LB{}\Tab{4}{\V{Refresh};}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{}\Tab{2}{\K{if}_\V{zoom}\<\>\N{0}_\K{then}}}
\L{\LB{}\Tab{2}{\V{Caption}:=\S{}{'}BWINF_24.2.1_{'}\SE{}+\V{floatToStr}((\V{x}\-\V{nullpoint.x})/\V{zoom})+\S{}{'}:{'}\SE{}+}}
\L{\LB{}\Tab{27}{\V{floattostr}(\-(\V{y}\-\V{outputPaintBox.ClientHeight}\-\V{nullpoint.y})/\V{zoom});}}
\L{\LB{\K{end};}}
\L{\LB{}}
\index{TmuseumForm.fillSeenAreasClick}\Proc{TmuseumForm.fillSeenAreasClick}\L{\LB{\K{procedure}_\V{TmuseumForm.fillSeenAreasClick}(\V{Sender}:_\V{TObject});}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{Refresh};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\index{TmuseumForm.FormCreate}\Proc{TmuseumForm.FormCreate}\L{\LB{\K{procedure}_\V{TmuseumForm.FormCreate}(\V{Sender}:_\V{TObject});}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{SetLength}(\V{museum},\N{0});}}
\L{\LB{}\Tab{2}{\V{DecimalSeparator}:=\S{}{'}.{'}\SE{};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\index{TmuseumForm.loadWayProbabilityClick}\Proc{loadWayProbabilityClick}\L{\LB{\K{procedure}_\V{TmuseumForm.loadWayProbabilityClick}(\V{Sender}:_\V{TObject});}}
\L{\LB{\K{var}_\V{guardWay}:_\V{tbitmap};}}
\index{drawPolygon}\Proc{drawPolygon}\L{\LB{}\Tab{2}{\K{procedure}_\V{drawPolygon}(\K{const}_\V{p}:\V{TPolygon});}}
\L{\LB{}\Tab{2}{\K{var}_\V{transformedPoly}:_\K{array}_\K{of}_\V{tpoint};}}
\L{\LB{}\Tab{6}{\V{i}:\V{integer};}}
\L{\LB{}\Tab{2}{\K{begin}}}
\L{\LB{}\Tab{4}{\V{SetLength}(\V{transformedPoly},\V{length}(\V{p}));}}
\L{\LB{}\Tab{4}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{p})_\K{do}_\K{begin}}}
\L{\LB{}\Tab{6}{\V{transformedPoly}[\V{i}]\V{.x}:=\V{round}(\V{p}[\V{i}]\V{.start.x}*\V{zoom});}}
\L{\LB{}\Tab{6}{\V{transformedPoly}[\V{i}]\V{.y}:=\V{guardWay.height}\-\V{round}(\V{p}[\V{i}]\V{.start.y}*\V{zoom});}}
\L{\LB{}\Tab{4}{\K{end};}}
\ProcCont{loadWayProbabilityClick}\L{\LB{}\Tab{4}{\V{guardWay.Canvas.Polygon}(\V{transformedPoly})}}
\L{\LB{}\Tab{2}{\K{end};}}
\L{\LB{\K{var}}}
\L{\LB{}\Tab{4}{\V{x},\V{y},\V{x2},\V{y2},\V{i},\V{j}:\V{integer};}}
\L{\LB{}\Tab{4}{\V{maxp},\V{posp}:\V{integer};}}
\L{\LB{}\Tab{4}{\V{pos},\V{pos2}:\V{tpointf};}}
\L{\LB{}\Tab{4}{\V{hitinfo}:_\V{TRayHitPoints};}}
\L{\LB{}\Tab{4}{\V{visible}:_\V{boolean};}}
\L{\LB{}\Tab{4}{\V{seeWidth}:_\V{double};}}
\L{\LB{\K{begin}}}
\L{\LB{}\Tab{2}{\V{guardWay}:=\V{TBitmap.create};}}
\L{\LB{}\Tab{2}{\V{guardWay.LoadFromFile}(\V{wayProbabilityFileName.text});}}
\L{\LB{}\Tab{2}{\V{zoom}:=\V{guardWay.width};}}
\L{\LB{}\Tab{2}{\K{if}_\V{zoom}\<\>\V{guardWay.height}_\K{then}_\V{raise}_\V{Exception.Create}(\S{}{'}nicht_quadratisch{'}\SE{});}}
\L{\LB{}\Tab{2}{\V{SetLength}(\V{invWayProbability},\V{guardWay.width},\V{guardWay.height});}}
\L{\LB{}\Tab{2}{\V{SetLength}(\V{invSeeProbability},\V{guardWay.width},\V{guardWay.height});}}
\L{\LB{}\Tab{2}{\K{for}_\V{x}:=\N{0}_\K{to}_\V{guardWay.width}\-\N{1}_\K{do}}}
\L{\LB{}\Tab{4}{\K{for}_\V{y}:=\N{0}_\K{to}_\V{guardWay.height}\-\N{1}_\K{do}}}
\L{\LB{}\Tab{6}{\V{invWayProbability}[\V{x},\V{y}]:=\V{getrvalue}(\V{guardWay.Canvas.Pixels}[\V{x},\V{y}])_/_\N{255};}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{guardWay.Canvas.brush.color}:=\V{clRed};}}
\L{\LB{}\Tab{2}{\V{guardWay.Canvas.pen.style}:=\V{psClear};}}
\L{\LB{}\Tab{2}{\V{guardWay.Canvas.pen.width}:=\N{1};}}
\L{\LB{}\Tab{2}{\V{guardWay.Canvas.pen.Style}:=\V{psSolid};}}
\L{\LB{}\Tab{2}{\V{guardWay.Canvas.FillRect}(\V{rect}(\N{0},\N{0},\V{guardWay.width},\V{guardWay.height}));}}
\L{\LB{}\Tab{2}{\V{guardWay.Canvas.brush.color}:=\V{clWhite};}}
\L{\LB{}\Tab{2}{\V{drawPolygon}(\V{museum}[\N{0}]);}}
\L{\LB{}\Tab{2}{\V{guardWay.Canvas.brush.color}:=\V{clRed};}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\K{for}_\V{i}:=\N{1}_\K{to}_\V{high}(\V{museum})_\K{do}}}
\L{\LB{}\Tab{4}{\V{drawPolygon}(\V{museum}[\V{i}]);}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\K{for}_\V{x}:=\N{0}_\K{to}_\V{high}(\V{invWayProbability})_\K{do}}}
\L{\LB{}\Tab{4}{\K{for}_\V{y}:=\N{0}_\K{to}_\V{high}(\V{invWayProbability}[\V{x}])_\K{do}}}
\L{\LB{}\Tab{6}{\K{if}_\V{guardWay.Canvas.Pixels}[\V{x},\V{y}]_=_\V{clred}_\K{then}}}
\L{\LB{}\Tab{8}{\V{invWayProbability}[\V{x},\V{y}]:=\N{2};}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{guardWay.free};}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\K{for}_\V{x}:=\N{0}_\K{to}_\V{high}(\V{invSeeProbability})_\K{do}}}
\L{\LB{}\Tab{4}{\K{for}_\V{y}:=\N{0}_\K{to}_\V{high}(\V{invSeeProbability}[\V{x}])_\K{do}}}
\L{\LB{}\Tab{6}{\V{invSeeProbability}[\V{x},\V{y}]:=\N{1};}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{seeWidth}:=\V{sqr}(\N{4}/\V{Max}(\V{museumsize.x},\V{museumsize.Y}));}}
\L{\LB{}}
\L{\LB{}\Tab{2}{\V{maxp}:=\V{length}(\V{invSeeProbability})*\V{length}(\V{invSeeProbability}[\N{0}]);}}
\L{\LB{}\Tab{2}{\V{ProgressBar1.Max}:=\V{maxp};}}
\L{\LB{}\Tab{2}{\K{for}_\V{x}:=\N{0}_\K{to}_\V{high}(\V{invSeeProbability})}\Tab{39}{\K{do}}}
\L{\LB{}\Tab{4}{\K{for}_\V{y}:=\N{0}_\K{to}_\V{high}(\V{invSeeProbability}[\V{x}])\K{do}_\K{begin}}}
\L{\LB{}\Tab{6}{\V{posp}:=\V{x}*\V{length}(\V{invSeeProbability}[\N{0}])+\V{y};}}
\L{\LB{}\Tab{6}{\V{ProgressBar1.Position}:=\V{posp};}}
\L{\LB{}\Tab{6}{\V{progress.Caption}:=\V{inttostr}(\V{posp})+\S{}{'}/{'}\SE{}+\V{inttostr}(\V{maxp});}}
\L{\LB{}\Tab{6}{\V{Application.ProcessMessages};}}
\L{\LB{}\Tab{6}{\K{if}_\V{invWayProbability}[\V{x},\V{y}]_\<_\N{1}_\K{then}_\K{begin}}}
\L{\LB{}\Tab{8}{\V{pos.x}:=\V{x}/\V{high}(\V{invSeeProbability});}}
\L{\LB{}\Tab{8}{\V{pos.y}:=\N{1}\-\V{y}/\V{high}(\V{invSeeProbability}[\V{x}]);}}
\L{\LB{}\Tab{8}{\V{setlength}(\V{seenAreas},\N{0});}}
\L{\LB{}\Tab{8}{\V{try}}}
\L{\LB{}\Tab{10}{\V{lookFromPoint}(\V{pos});}}
\L{\LB{}\Tab{10}{\V{convertLookPoints};}}
\L{\LB{}\Tab{8}{\V{except}}}
\L{\LB{}\Tab{10}{\K{continue};}}
\L{\LB{}\Tab{8}{\K{end};}}
\L{\LB{}\Tab{8}{\K{for}_\V{x2}:=\N{0}_\K{to}_\V{high}(\V{invSeeProbability})_\K{do}}}
\L{\LB{}\Tab{10}{\K{for}_\V{y2}:=\N{0}_\K{to}_\V{high}(\V{invSeeProbability}[\V{x}])_\K{do}_\K{begin}}}
\L{\LB{}\Tab{12}{\K{if}_(\V{x}=\V{x2})\K{and}(\V{y}=\V{y2})_\K{then}_\K{begin}}}
\L{\LB{}\Tab{14}{\V{invSeeProbability}[\V{x2},\V{y2}]:=\V{invSeeProbability}[\V{x},\V{y}]*\V{invWayProbability}[\V{x},\V{y}];}}
\L{\LB{}\Tab{14}{\K{continue};}}
\L{\LB{}\Tab{12}{\K{end};}}
\L{\LB{}\Tab{12}{\K{if}_\V{invWayProbability}[\V{x2},\V{y2}]_=_\N{2}_\K{then}_\K{continue};}}
\L{\LB{}\Tab{12}{\V{pos2.x}:=\V{x2}/\V{high}(\V{invSeeProbability});}}
\L{\LB{}\Tab{12}{\V{pos2.y}:=\N{1}\-\V{y2}/\V{high}(\V{invSeeProbability});}}
\L{\LB{}\Tab{12}{\K{if}_\V{sQr}(\V{pos.x}\-\V{pos2.x})+\V{sQr}(\V{pos.y}\-\V{pos2.y})\>\V{seeWidth}_\K{then}_\K{continue};}}
\L{\LB{}}
\L{\LB{}\Tab{12}{\V{visible}:=\V{false};}}
\L{\LB{}\Tab{12}{\K{for}_\V{i}:=\N{0}_\K{to}_\V{high}(\V{seenAreas})_\K{do}}}
\L{\LB{}\Tab{14}{\K{if}_\V{isPointInTri}(\V{seenAreas}[\V{i},\N{0}],\V{seenAreas}[\V{i},\N{1}],}}
\L{\LB{}\Tab{31}{\V{seenAreas}[\V{i},\N{2}],\V{pos2})_\K{then}_\K{begin}}}
\L{\LB{}\Tab{16}{\V{visible}:=\V{true};}}
\L{\LB{}\Tab{16}{\K{break};}}
\L{\LB{}\Tab{14}{\K{end};}}
\L{\LB{}}
\L{\LB{}\Tab{12}{\K{if}_\V{visible}_\K{then}}}
\L{\LB{}\Tab{14}{\V{invSeeProbability}[\V{x2},\V{y2}]:=\V{invSeeProbability}[\V{x},\V{y}]*(}}
\L{\LB{}\Tab{17}{\V{max}(\N{0},\V{min}(\N{1},\V{invWayProbability}[\V{x},\V{y}]+(\V{sQr}(\V{pos.x}\-\V{pos2.x})+\V{sQr}(\V{pos.y}\-\V{pos2.y}))/\V{seeWidth}))}}
\L{\LB{}\Tab{38}{);}}
\L{\LB{}\Tab{10}{\K{end};}}
\L{\LB{}\Tab{6}{\K{end};}}
\L{\LB{}\Tab{4}{\K{end};}}
\L{\LB{}\Tab{2}{\V{Refresh};}}
\L{\LB{\K{end};}}
\L{\LB{}}
\L{\LB{\K{end.}}}
