-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsigma.pas
1588 lines (1556 loc) · 67.1 KB
/
sigma.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{DEFINE Debugging} //switch on debugging mode
{$UNDEF Debugging} //switch off debugging mode
unit Sigma;
interface
uses
SysUtils, Windows, Graphics, ExtCtrls, LowHem, Dialogs, Math, Menus, Rotate,
Types, VirtDip, Forms;
type
TSigmaForm = class(TLHWin)
procedure FormCreate(Sender: TObject; const aFileName: string; const AExtension: TExtension); override;
procedure Compute(Sender: TObject); override;
procedure CalculateHistograms(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction); override;
procedure Angelier1click(Sender: TObject); override;
private
OldFile: Boolean;
procedure SetCaption(Sender: TObject; const FFilename: String);
procedure DrawFluHist(Sender: TObject);
procedure DrawMohr(Sender: TObject);
public
Skipped, NoSense, Max, MaxInterval, nDatasets, Max3, NoofBoxes, Theta: Integer;
MaxPerc, StressRatio, Max2: Single;
SFCounts: PZeroIntArray;
SFFluMohrFPLData: PFluMohrFPLDataArray;
TensAzimuth, TensPlunge : T1Sing1by3;
NoofBoxeschanged : Boolean;
end;
TSigmaFromFile = class(TSigmaForm)
procedure FormCreate(Sender: TObject; const aFileName: string; const AExtension: TExtension); override;
end;
procedure FindRighthandIndex(fIncrement, findex1, findex20, findex21: Integer; point20, point21: TPoint;
var findex3x: Integer; var fpoint3x: TPoint; var AUpward, fspecial: Boolean);
procedure AssemblePolygon(fppoints1, fppoints2, fppoints3: POpenPointArray;
startpoint, intsectpt3x0, intsectpt3x1, intsectpt3y0, intsectpt3y1: TPoint; fPolySegments,startindex1, startindex2,
intsect3x0, intsect3x1, intsect3y0, intsect3y1: integer; fupward: Boolean;
var FPolygon: POpenPointArray; var nPoints: Integer; var Aspecial: Boolean);
function DrawDihedra(var FCanvas: TCanvas; var FTensAzimuth, FTensPlunge: T1Sing1by3;
FSymbFillFlag, FSymbFillFlag2: Boolean; FFillBrush, FFillBrush2: TBrush; FPen: TPen): Boolean;
Function DrawTensor(var FCanvas: TCanvas; FCanvas2: TCanvas; FTensAzimuth, FTensPlunge : T1Sing1by3;
FSymbSize: Single; FSymbFillFlag, FSymbFillFlag2: Boolean; FFillBrush, FFillBrush2: TBrush; FPenHandle: THandle): Boolean;
implementation
uses FileOps, Draw, Tecmain, Invers, Nda, Settings;
procedure TSigmaFromFile.FormCreate(Sender: TObject; const aFileName: string; const AExtension: TExtension);
var Finished: Boolean;
iDummy: Integer;
sDummy: Single;
fInputFile: Textfile;
begin
lhFileName:=aFileName;
Finished:=False;
Skipped:=0;
try //*************read sigma123 from file**************
AssignFile(fInputFile, lhFileName);
Reset(fInputFile);
try
lhFailed:= not ReadSigma123(fInputFile, TensAzimuth, TensPlunge, StressRatio, lhz, nDatasets, Skipped);
finally
CloseFile(fInputFile);
end;
If lhFailed or FileUsed then
begin
FileFailed(Self);
Close;
Exit;
end;
If AExtension<>DIH then
begin
AssignFile(fInputFile, lhFileName);
Reset(fInputFile);
If not Eof(fInputFile) then
begin
lhz:=0;
While not Eof(fInputFile) and not lhFailed and not Finished do
begin
ReadFluMohrFPLData(fInputFile, iDummy, sDummy, sDummy, iDummy, lhFailed, Finished);
If not Finished then Inc(lhz);
end; //end of while-loop
end else lhFailed:=True;
If lhz<1 then
begin
lhFailed:=True;
OldFile:=True;
end else OldFile:=False;
If lhFailed then
begin
CloseFile(fInputFile);
FileFailed(Self);
Close;
Exit;
end;
nDatasets:=lhz;
GetMem(SFFluMohrFPLData, SizeOf(SFFluMohrFPLData^[0])*nDatasets);
CloseFile(fInputFile);
AssignFile(fInputFile, lhFileName);
Reset(fInputFile);
Finished:=False;
If not Eof(fInputFile) then //read deviation from shear stress
begin
lhz:=0;
While not Eof(fInputFile) and not lhFailed and not Finished do with SFFluMohrFPLData^[lhz] do
begin
ReadFluMohrFPLData(fInputFile, fmSense, fmDipDir, fmDip, fmfluctuation, lhFailed, Finished);
if (fmSense=0) or (fmSense=5) then Inc(Skipped);
If not Finished then Inc(lhz);
end; {end of while-loop}
end else lhFailed:=True;
CloseFile(fInputFile);
end;
except //can not open file
On EInOutError do FileUsed:=True;
end;
if not lhFailed then inherited;
end;
procedure TSigmaForm.Angelier1click(Sender: TObject);
begin
if Self is TSigmaFromFile then
begin
If (Sender=Angelier1) or (Sender=Angelier2) then
If (lhExtension=INV) or (lhExtension=DIH) then
lhPlotType:=pt_SigmaDihedra
else lhPlotType:=pt_LambdaDihedra
else
If (Sender=Hoeppener1) or (Sender=Hoeppener2) then
If (lhExtension=INV) or (lhExtension=DIH) then lhPlotType:=pt_SigmaTensor
else lhPlotType:=pt_LambdaTensor
else
if (Sender=ptAxes1) or (Sender=ptAxes2) then
lhPlotType:=pt_FluHist
else
if (Sender=Mohrcircle1) or (Sender=Mohrcircle2) then
if lhExtension=INV then
lhPlotType:=pt_MohrSigma
else if lhextension=ndf then
lhplottype:=pt_MohrLambda;
end
else if Self is TInversPlot then
begin
If (Sender=Angelier1) or (Sender=Angelier2) then lhPlotType:=pt_SigmaDihedra
else If (Sender=Hoeppener1) or (Sender=Hoeppener2) then lhPlotType:=pt_SigmaTensor
else if (Sender=ptAxes1) or (Sender=ptAxes2) then lhPlotType:=pt_FluHist
else if (Sender=Mohrcircle1) or (Sender=Mohrcircle2) then lhPlotType:=pt_MohrSigma;
end
else if Self is TNDAPlot then
begin
If (Sender=Angelier1) or (Sender=Angelier2) then lhPlotType:=pt_LambdaDihedra
else If (Sender=Hoeppener1) or (Sender=Hoeppener2) then lhPlotType:=pt_LambdaTensor
else if (Sender=ptAxes1) or (Sender=ptAxes2) then lhPlotType:=pt_FluHist
else if (Sender=Mohrcircle1) or (Sender=Mohrcircle2) then lhplottype:=pt_MohrLambda;
end;
SetCaption(Sender, lhFileName);
case lhPlotType of
pt_MohrSigma, pt_MohrLambda: Number1.Visible:=True;
else Number1.Visible:=False;
end;
inherited;
if not lhFailed then SigmadihedraOn:=Angelier1.checked;
if SetForm<>nil then SetForm.Initialize(Self);
end;
procedure TSigmaForm.SetCaption(Sender: TObject; const FFilename: String);
begin
If Self is TSigmaFromFile then
begin
if (lhplottype=pt_SigmaDihedra) or (lhplottype=pt_SigmaTensor) then
Caption := 'Sigma123 - [' +ExtractFileName(FFilename) +']'
else if (lhplottype=pt_lambdaDihedra) or (lhplottype=pt_lambdaTensor) then
Caption := 'Lambda123 - [' +ExtractFileName(FFilename) +']'
else if lhplottype=pt_FluHist then
Caption := 'Fluctuation histogram - [' +ExtractFileName(FFilename) +']'
else if (lhplottype=pt_MohrSigma) or (lhplottype=pt_MohrLambda) then
Caption := 'Mohr´s circle - [' +ExtractFileName(FFilename) +']'
end
else
If Self is TInversPlot then
Caption := 'Inverse-calculation - [' +ExtractFileName(FFilename) +']'
else
If Self is TNDAPlot then
Caption := 'NDA-calculation - [' +ExtractFileName(FFilename) +']';
end;
procedure TSigmaForm.FormCreate(Sender: TObject; const aFileName: string; const AExtension: TExtension);
var MyFlag: Boolean;
begin
If SetForm<>nil then
begin
if Sender<>SetForm.ApplyBtn then NoofBoxes:=FluHIntervals;
end else NoofBoxes:=10;
PlotType1.Enabled:=True;
PlotType2.Enabled:=True;
Angelier1.Caption:='&Dihedra';
Angelier2.Caption:=Angelier1.Caption;
Hoeppener1.Caption:='&Stress axes';
Hoeppener2.Caption:=Hoeppener1.Caption;
ptAxes1.Caption:='&Fluct.-histogr.';
ptAxes2.Caption:=ptAxes1.Caption;
Number1.Visible:=False;
if SetForm<>nil then
MyFlag:=Sender<>SetForm.ApplyBtn
else Myflag:=True;
if MyFlag then
begin
if Self is TSigmafromFile then
begin
If Sender=TecMainWin.Dihedra3 then Angelier1.checked:=True
else if Sender=TecMainWin.Stressaxes1 then angelier1.checked:=False;
end
else Angelier1.checked:=SigmadihedraOn;
Angelier2.Checked:=Angelier1.Checked;
Hoeppener1.checked:= not Angelier1.checked;
Hoeppener2.Checked:=Hoeppener1.Checked;
IF AExtension<>DIH then
begin
MohrCircle1.Visible:=True;
MohrCircle1.Enabled:=True;
MohrCircle2.Visible:=True;
MohrCircle2.Enabled:=True;
end
else
begin
ptAxes1.Visible:=False;
ptAxes1.Enabled:=False;
ptAxes2.Visible:=False;
ptAxes2.Enabled:=False;
end;
If Sender=TecMainWin.FluctHistogram1 then
begin
ptAxes1.Checked:=True;
ptAxes2.Checked:=ptAxes1.checked;
end
else If Sender=TecMainWin.Mohrcircle1 then
begin
Mohrcircle1.Checked:=True;
Mohrcircle2.Checked:=Mohrcircle1.checked;
Number1.Visible:=True;
end;
If Angelier1.Checked then
begin
If Self is TSigmaFromFile then
case AExtension of
INV, DIH: lhPlotType:=pt_SigmaDihedra;
NDF: lhPlotType:=pt_LambdaDihedra;
end
else
If Self is TInversPlot then lhPlotType:=pt_SigmaDihedra
else If Self is TNDAPlot then lhPlotType:=pt_LambdaDihedra;
end
else if Hoeppener1.Checked then
begin
If Self is TSigmaFromFile then
case AExtension of
INV, DIH: lhPlotType:=pt_SigmaTensor;
NDF: lhPlotType:=pt_LambdaTensor;
end
else
If Self is TInversPlot then lhPlotType:=pt_SigmaTensor
else If Self is TNDAPlot then lhPlotType:=pt_LambdaTensor;
end
else if ptAxes1.checked then lhplottype:=pt_fluhist
else if Mohrcircle1.checked then
case AExtension of
INV: lhPlotType:=pt_MohrSigma;
NDF: lhPlotType:=pt_MohrLambda;
end;
end; //if sender <>ApplyBtn
SetCaption(Sender, aFileName);
inherited;
end;
procedure TSigmaForm.CalculateHistograms(Sender: TObject);
var x,i: Integer;
sinuserror: Single;
hit: Boolean;
begin
NoSense:=0;
Max:= 0;
MaxInterval:=0;
GetMem(SFCounts,SizeOf(SFCounts^[0])*(NoOfBoxes+1));
for x:= 0 to NoofBoxes-1 do SFCounts^[x]:=0;
For i:=0 to nDatasets-1 do with SFFluMohrFPLData^[i] do
begin
If (fmSense<>0) and (fmSense<>5) or (Self is tinversplot) or (lhextension=inv) then
begin
If fmFluctuation>=0 then
begin
SinusError:=Sin(DegToRad(fmFluctuation));
hit := False;
x := 0;
while (x<=NoofBoxes-1) and not hit do
begin
IF (SinusError>=x/NoofBoxes) AND (SinusError<(x+1)/NoofBoxes) THEN
begin
Inc(SFCounts^[x]);
hit := True;
end;
IF Max<SFCounts^[x] THEN
begin
Max := SFCounts^[x];
MaxInterval:=x;
end;
Inc(X);
end;
end;
end else Inc(NoSense);
end; //end of for-loop
end;
procedure TSigmaForm.Compute(Sender: TObject);
const
{constants to draw symbols}
TriangleSizeRate=0.020; {Rate of size of linear triangle related to radius of diagram}
var dummy, dumy,triangleheight: Integer;
textdummy: String;
xpoints: array[0..2] of TPoint;
begin
Screen.Cursor := CrHourGlass;
try
PrepareMetCan(lhMetCan, LHMetafile, LHEnhMetafile,lhWriteWMF);
SetBackground(Sender, lhMetCan.Handle);
If not lhFailed then
begin
//MetCan.Pen:=lhPen;
IF (lhPlotType=pt_SigmaTensor) or (lhPlotType=pt_LambdaTensor) then
begin
North;
DrawTensor(lhMetCan, Canvas, TensAzimuth, TensPlunge, lhSymbSize,
lhSymbFillFlag, lhSymbFillFlag2, lhFillBrush, lhFillBrush2, lhPen.Handle);
end
else
If lhPlotType=pt_FluHist then
begin
CalculateHistograms(Sender);
DrawFluHist(Sender);
FreeMem(SFCounts,SizeOf(SFCounts^[0])*(NoOfBoxes+1));
end
else if (lhPlotType=pt_SigmaDihedra) or (lhPlotType=pt_LambdaDihedra) then
begin
If not DrawDihedra(lhMetCan, TensAzimuth, TensPlunge, lhSymbFillFlag, lhSymbFillFlag2, lhFillBrush, lhFillBrush2, lhPen) then
begin
Screen.Cursor:=crDefault;
lhFailed:=True;
SigmaDihedraOn:=False;
messagedlg('Plot failed.',mtError,[mbOk],0);
Exit;
end;
North;
end
else if (lhPlotType=pt_MohrSigma) or (lhPlotType=pt_MohrLambda) then
DrawMohr(Sender);
//Write Explanation
dummy:=6-lhMetCan.Font.Height;
If not lhCopyMode and not lhPasteMode then
begin
If Label1.Checked then
begin
lhMetCan.Pen:=lhPen;
IF (lhPlotType=pt_SigmaTensor) or (lhPlotType=pt_LambdaTensor) then with lhMetCan do
begin
dumy:=Round(lhSymbSize);//Round(Radius*LinearCircleRate);
triangleheight:=Round(Radius*Sqrt(3)*lhSymbSize/320);
if lhSymbFillFlag then Brush := lhFillBrush;
Ellipse(CenterX+160-dumy, labeltop+dummy div 2-dumy,
CenterX+160+dumy, labeltop+dummy div 2+dumy);
xpoints[0].x:=CenterX+160-triangleheight;
xpoints[0].y:=labeltop+5*dummy div 2+dumy;
xpoints[1].x:=CenterX+160+triangleheight;
xpoints[1].y:=xpoints[0].y;
xpoints[2].x:=CenterX+160;
xpoints[2].y:=labeltop+5*dummy div 2-dumy;
if lhSymbFillFlag2 then Brush := lhFillBrush2
else Brush.Style:=bsClear;
Polygon(xpoints);
if lhSymbFillFlag or lhsymbfillflag2 then Brush.Style := bsClear;
Rectangle(CenterX+160-dumy, labeltop+3*dummy div 2-dumy,
CenterX+160+dumy, labeltop+3*dummy div 2+dumy);
Case lhPlotType of
pt_SigmaDihedra, pt_SigmaTensor: Textdummy:='Sigma';
pt_LambdaDihedra, pt_LambdaTensor: Textdummy:='Lambda';
end;
For dumy:=0 to 2 do
TextOut(CenterX+180, labeltop+dummy*dumy, Textdummy+IntToStr(dumy+1));
end;
If (lhPlotType=pt_SigmaDihedra) or (lhPlotType=pt_LambdaDihedra) then
begin
dumy:=10;
lhMetCan.Pen.Style:=psSolid;
if lhsymbfillflag then SelectObject(lhMetCan.Handle,lhFillbrush.Handle)
else lhMetCan.Brush.Style:=bsclear;
lhMetCan.Rectangle(CenterX+160-dumy, labeltop+2*dummy div 2-dumy,
CenterX+160+dumy, labeltop+2*dummy div 2+dumy);
if lhsymbfillflag2 then SelectObject(lhMetCan.Handle,lhFillbrush2.Handle)
else lhMetCan.Brush.Style:=bsclear;
lhMetCan.Rectangle(CenterX+160-dumy, labeltop+5*dummy div 2-dumy,
CenterX+160+dumy, labeltop+5*dummy div 2+dumy);
lhMetCan.Brush.Style:=bsclear;
lhMetCan.TextOut(CenterX+180, labeltop+2*dummy div 2-dumy, 'Compressive');
lhMetCan.TextOut(CenterX+180, labeltop+5*dummy div 2-dumy, 'Tensile');
end;
lhMetCan.Brush.Style:=bsClear;
If not lhCopyMode and not lhPasteMode then with lhMetCan do
begin
Case lhPlotType of
pt_MohrSigma, pt_MohrLambda:
else TextOut(labelleft,labeltop,lhLabel1);
end;
Case lhPlotType of
pt_SigmaTensor, pt_SigmaDihedra: TextOut(labelleft,labeltop+dummy,'Sigma123');
pt_LambdaTensor, pt_LambdaDihedra: TextOut(labelleft,labeltop+dummy,'Lambda123');
end;
end
else with lhMetCan do
begin
TextOut(labelleft,labeltop,lhLabel1);
TextOut(labelleft,labeltop+dummy,'Stresst axes');
end;
end;
end;
GlobalFailed:=False;
end;
finally
lhMetCan.Free;
Screen.Cursor := CrDefault;
end;
inherited;
If Self is TSigmaFromFile then //read stress data from file
begin
If (lhPlotType=pt_SigmaDihedra) or (lhPlotType=pt_SigmaTensor) then
begin
lhPlotInfo:=lhPlotInfo+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#13#10;
If lhextension<>dih then lhPlotInfo:=lhPlotInfo+'Sense substituted: '
else lhPlotInfo:=lhPlotInfo+'Datasets Skipped: ';
lhPlotInfo:=lhPlotInfo+IntToStr(Skipped)+#13#10+
'Sigma1: '+FloatToString(TensAzimuth[1], 3,0)+' / '+FloatToString(TensPlunge[1],2,0)+#13#10+
'Sigma2: '+FloatToString(TensAzimuth[2], 3,0)+' / '+FloatToString(TensPlunge[2],2,0)+#13#10+
'Sigma3: '+FloatToString(TensAzimuth[3], 3,0)+' / '+FloatToString(TensPlunge[3],2,0);
If lhextension<>dih then lhPlotInfo:=lhPlotInfo+#13#10+'Stress ratio: '+FloatToString(StressRatio, 1,4);
end
else
If (lhPlotType=pt_LambdaDihedra) or (lhPlotType=pt_LambdaTensor) then
lhPlotInfo:=lhPlotInfo+#13#10+
'Lambda1: '+FloatToString(TensAzimuth[1], 3,0)+' / '+FloatToString(TensPlunge[1],2,0)+#13#10+
'Lambda2: '+FloatToString(TensAzimuth[2], 3,0)+' / '+FloatToString(TensPlunge[2],2,0)+#13#10+
'Lambda3: '+FloatToString(TensAzimuth[3], 3,0)+' / '+FloatToString(TensPlunge[3],2,0)+#13#10+
'Strain ratio: '+FloatToString(StressRatio, 1,4)+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#13#10+
'Datasets Skipped: '+IntToStr(Skipped)
else IF lhPlotType=pt_FluHist then lhPlotInfo:=lhPlotInfo+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#13#10+
'Intervals: '+IntToStr(NoOfBoxes)+#$D#$A+
'Maximum: '+IntToStr(Max)+' counts ('+FloatToString(MaxPerc,2,1)+
' %) in interval '+IntToStr(MaxInterval+1)
else if (lhplottype=pt_mohrsigma) or (lhplottype=pt_mohrlambda) then
begin
lhPlotInfo:=lhPlotInfo+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#13#10;
IF lhPlotType=pt_MohrSigma then lhPlotInfo:=lhPlotInfo+
'Datasets substituted: '+IntToStr(NoSense)+#13#10+'Stress ratio: '
else lhPlotInfo:=lhPlotInfo+'Datasets Skipped: '+IntToStr(NoSense)+#13#10'Strain ratio: ';
lhPlotInfo:=lhPlotInfo+FloatToString(StressRatio, 1,4);
end;
end
else //Sigma calculation
begin
If Self is TInversPlot then
begin
if (lhplottype=pt_sigmadihedra) or (lhplottype=pt_sigmatensor) then lhPlotInfo:=lhPlotInfo+#13#10+
'Sigma1: '+FloatToString(TensAzimuth[1], 3,0)+' / '+FloatToString(TensPlunge[1],2,0)+#13#10+
'Sigma2: '+FloatToString(TensAzimuth[2], 3,0)+' / '+FloatToString(TensPlunge[2],2,0)+#13#10+
'Sigma3: '+FloatToString(TensAzimuth[3], 3,0)+' / '+FloatToString(TensPlunge[3],2,0)+#13#10+
'Stress ratio: '+FloatToString(StressRatio, 1,4)+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#$D#$A+
'Sense substituted: '+IntToStr(Skipped)+#13#10+
'Negative sense expected for '+IntToStr((Self as TStressTensorPlot).negative)+' datasets'
else if lhplottype=pt_fluhist then lhPlotInfo:=lhPlotInfo+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#13#10+
'Intervals: '+IntToStr(NoOfBoxes)+#$D#$A+
'Maximum: '+IntToStr(Max)+' counts ('+FloatToString(MaxPerc,2,1)+
' %) in interval '+IntToStr(MaxInterval+1)
else if lhplottype=pt_mohrsigma then lhPlotInfo:=lhPlotInfo+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#13#10+
'Datasets substituted: '+IntToStr(Skipped)+#13#10+
'Stress ratio: '+FloatToString(StressRatio, 1,4);
end
else If Self is TNDAPlot then
begin
if (lhplottype=pt_lambdadihedra) or (lhplottype=pt_lambdatensor) then lhPlotInfo:=lhPlotInfo+#13#10+
'Lambda1: '+FloatToString(TensAzimuth[1], 3,0)+' / '+FloatToString(TensPlunge[1],2,0)+#13#10+
'Lambda2: '+FloatToString(TensAzimuth[2], 3,0)+' / '+FloatToString(TensPlunge[2],2,0)+#13#10+
'Lambda3: '+FloatToString(TensAzimuth[3], 3,0)+' / '+FloatToString(TensPlunge[3],2,0)+#13#10+
'Theta: '+IntToStr(Theta)+' °'+#13#10+
'Strain ratio: '+FloatToString(StressRatio, 1,4)+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#$D#$A+
'Datasets Skipped: '+IntToStr(Skipped)+#13#10+
'Negative sense expected for '+IntToStr((Self as TStressTensorPlot).negative)+' datasets'
else if lhplottype=pt_fluhist then lhPlotInfo:=lhPlotInfo+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#13#10+
'Datasets Skipped: '+IntToStr(Skipped)+#13#10+
'Intervals: '+IntToStr(NoOfBoxes)+#$D#$A+
'Maximum: '+IntToStr(Max)+' counts ('+FloatToString(MaxPerc,2,1)+
' %) in interval '+IntToStr(MaxInterval+1)
else if lhplottype=pt_mohrlambda then
lhPlotInfo:=lhPlotInfo+#13#10+
'Datasets total: '+IntToStr(nDatasets)+#13#10+
'Datasets Skipped: '+IntToStr(Skipped)+#13#10+
'Strain ratio: '+FloatToString(StressRatio, 1,4);
end;
lhPlotInfo:=lhPlotInfo+#13#10+(Self as TStresstensorplot).StressTenPlotInfo;
end;
end;
procedure FindRighthandIndex(fIncrement, findex1, findex20, findex21: Integer; point20, point21: TPoint;
var findex3x: Integer; var fpoint3x: TPoint; var AUpward, fspecial: Boolean);
var index20, index21: Integer;
begin
index20:=findex20;
index21:=findex21;
if findex20<findex1 then Inc(index20, fIncrement);
if findex21<findex1 then Inc(index21, fIncrement);
if (index20-findex1>index21-findex1) then
if ((index20-findex1<>fIncrement div 2) and (index21-findex1<>0)) and
((index21-findex1<>fIncrement div 2) and (index20-findex1<>0)) then
begin
findex3x:=findex21;
fpoint3x:=point21;
Aupward:=False;
fspecial:=False;
end
else
begin
findex3x:= findex20;
fpoint3x:=point20;
Aupward:=True;
fspecial:=True;
end
else
begin
if ((index20-findex1<>fIncrement div 2) and (index21-findex1<>0)) and
((index21-findex1<>fIncrement div 2) and (index20-findex1<>0)) then
begin
findex3x:= findex20;
fpoint3x:=point20;
Aupward:=True;
fspecial:=False;
end
else
begin
findex3x:=findex21;
fpoint3x:=point21;
Aupward:=True;
fspecial:=True;
end;
end;
end;
procedure AssemblePolygon(fppoints1, fppoints2, fppoints3: POpenPointArray;
startpoint, intsectpt3x0, intsectpt3x1, intsectpt3y0, intsectpt3y1: TPoint; fPolySegments,startindex1, startindex2,
intsect3x0, intsect3x1, intsect3y0, intsect3y1: integer; fupward: Boolean;
var FPolygon: POpenPointArray; var nPoints: Integer; var Aspecial: Boolean);
var pt, i, intsect3xx: Integer;
intsectpt3xx: TPoint;
upward: Boolean;
begin
npoints:=0;
fpolygon^[0]:=startpoint;
Inc(npoints);
pt:=npoints;
if fupward then
begin
For i:=startindex1+1 to fPolySegments-1 do
begin
fpolygon^[i-startindex1+pt-1]:= fppoints1^[i];
Inc(nPoints);
end;
fpolygon^[nPoints]:=intsectpt3x1;
end
else
begin
For i:=startindex1 downto 0 do
begin
fpolygon^[startindex1+pt-i]:= fppoints1^[i];
Inc(nPoints);
end;
fpolygon^[nPoints]:=intsectpt3x0;
end;
Inc(nPoints);
pt:=nPoints;
if fupward then
begin
FindRighthandIndex(fPolySegments*4, intsect3x1, intsect3y0,intsect3y1, intsectpt3y0, intsectpt3y1,
intsect3xx, intsectpt3xx, upward, Aspecial);
if Aspecial then
begin
if startindex1>0 then
begin
npoints:=0;
Startpoint:=intsectpt3x0;
fpolygon^[npoints]:= Startpoint;
Inc(npoints);
pt:=npoints;
For i:=0 to fPolySegments-1 do
begin
fpolygon^[i+pt]:= fppoints1^[i];
Inc(nPoints);
end;
fpolygon^[nPoints]:=intsectpt3x1;
Inc(nPoints);
pt:=nPoints;
end;
if Sqr(fpolygon^[pt-1].x-fppoints2^[0].x)+Sqr(fpolygon^[pt-1].y-fppoints2^[0].y)<
Sqr(fpolygon^[pt-1].x-fppoints2^[fPolySegments].x)+Sqr(fpolygon^[pt-1].y-fppoints2^[fPolySegments].y) then
For i:=0 to fPolySegments-1 do
begin
fpolygon^[pt+i]:= fppoints2^[i];
Inc(nPoints);
end
else
For i:=fPolySegments downto 0 do
begin
fpolygon^[pt+fPolySegments-i]:= fppoints2^[i];
Inc(nPoints);
end;
end
else
begin
if intsect3xx<intsect3x1 then intsect3xx:=intsect3xx+fPolySegments*4;
For i:=intsect3x1+1 to intsect3xx do
begin
fpolygon^[pt-1-intsect3x1+i]:= fppoints3^[i mod (fPolySegments*4)];
Inc(nPoints);
end;
end;
end
else
begin
FindRighthandIndex(fPolySegments*4, intsect3x0, intsect3y0,intsect3y1, intsectpt3y0, intsectpt3y1,
intsect3xx, intsectpt3xx, upward, Aspecial);
if intsect3xx<intsect3x0 then intsect3xx:=intsect3xx+fPolySegments*4;
For i:=intsect3x0+1 to intsect3xx do
begin
fpolygon^[pt-1-intsect3x0+i]:= fppoints3^[i mod (fPolySegments*4)];
Inc(nPoints);
end;
end;
pt:=nPoints;
if Aspecial then
begin
if not fupward then
begin
fpolygon^[npoints]:=intsectpt3xx;
Inc(npoints);
pt:=nPoints;
For i:=fPolySegments-1 downto startindex1+1 do
begin
fpolygon^[fPolySegments-1+pt-i]:= fppoints1^[i];
Inc(nPoints);
end;
end;
end
else
begin
fpolygon^[nPoints]:=intsectpt3xx;
Inc(nPoints);
pt:=npoints;
if upward then
For i:=0 to startindex2 do
begin
fpolygon^[pt+i]:= fppoints2^[i];
Inc(nPoints);
end
else
For i:=fPolySegments downto startindex2+1 do
begin
fpolygon^[pt+fPolySegments-i]:= fppoints2^[i];
Inc(nPoints);
end;
end;
fpolygon^[nPoints]:=Startpoint;
end;
function DrawDihedra(var FCanvas: TCanvas; var FTensAzimuth, FTensPlunge: T1Sing1by3;
FSymbFillFlag, FSymbFillFlag2: Boolean; FFillBrush, FFillBrush2: TBrush; FPen: TPen): Boolean;
var h, xxx, yyy, degdipdir, x, y, rr, openwidth, rp, m1, b1, m2, b2, xs, ys, alpha : Single;
APolysegments, i, j, z1, z2, z3, z4, lhz: Integer;
PPoints1, PPoints2, PPoints3, PPGpoints1, PPGpoints2, PPGpoints3, PPGpoints4 : POpenPointArray;
PGPoints1, PGPoints2, PGPoints3, PGPoints4, intsectcount, points, points1, points2, points3,
intsect12, intsect21, intsect310, intsect311, intsect320, intsect321: Integer;
Sigma2, intsectpt12, intsectPt310, intsectPt311, intsectPt320, intsectPt321: TPoint;
FAzimuth, FPlunge: T1Sing1by2;
sensechanged, special: Boolean;
errorbuffer: array[1..3] of Single;
index: array[1..3] of integer;
ferror: array[1..4,1..3] of Single;
PenStore: HDC;
mylogpen: tlogpen;
textdummy: string;
const fsymbolsize: integer= 10;
begin
Result:=False;
Rot(False, 45,FTensAzimuth[2],FTensPlunge[2],FTensAzimuth[1],FTensPlunge[1], FAzimuth[1], FPlunge[1], SenseChanged);
FlaechLin(FTensAzimuth[2],FTensPlunge[2],FAzimuth[1],FPlunge[1], True, FAzimuth[1],FPlunge[1]);
{$IFDEF Debugging}
//GreatCircle2(FCanvas.Handle,FCanvas,CenterX,CenterY,Radius,FAzimuth[1], FPlunge[1] ,lhz,
// False, FPen.Handle, myLogPen);
{$ENDIF}
Rot(False, -45,FTensAzimuth[2],FTensPlunge[2],FTensAzimuth[1],FTensPlunge[1], FAzimuth[2], FPlunge[2], SenseChanged);
FlaechLin(FTensAzimuth[2],FTensPlunge[2],FAzimuth[2],FPlunge[2], True, FAzimuth[2],FPlunge[2]);
{$IFDEF Debugging}
//GreatCircle2(FCanvas.Handle,FCanvas,CenterX,CenterY,Radius,FAzimuth[2], FPlunge[2],lhz,
// False, fPen.Handle, myLogPen);
FCanvas.Brush:=FFillBrush;
{$ENDIF}
//*******Find the two nearest polygon-indices for the intersecting point*****
//FindNearPolyIndex(FCanvas,FTensAzimuth,FTensPlunge, lhsymbsize,FAzimuth, FPlunge,
// Radius, CenterX, CenterY, lhFillbrush);
//*****Calculate X- and Y-position of intersecting point*********************
if Abs(FTensPlunge[2]) >= 89 then FTensPlunge[2]:=89.99*Sgn(FTensPlunge[2]);
h := Radius*SQRT2*Sin(DegToRad(90-FTensPlunge[2])/2);
xxx:=Centerx+h*Sin(DegToRad(FTensAzimuth[2]));
yyy:=CenterY-h*Cos(DegToRad(FTensAzimuth[2]));
{$IFDEF Debugging}
ellipse(FCanvas.handle,round(xxx-fsymbolsize), round(yyy-fsymbolsize), round(xxx+fsymbolsize),
round(yyy+fsymbolsize));
{$ENDIF}
if polysegments<21 then APolySegments:=polysegments
else APolySegments:=20;
GetMem(PPoints1,SizeOf(PPoints1^[0])*(APolySegments+1));
GetMem(PPoints2,SizeOf(PPoints2^[0])*(APolySegments+1));
GetMem(PPoints3,SizeOf(PPoints3^[0])*(4*APolySegments+1));
intsectPt310.x:=0;
intsectPt311.x:=0;
intsectPt320.x:=0;
intsectPt321.x:=0;
intsectPt12.x:=0;
//try
For i:=1 to 2 do
begin
DegDipDir:= DegToRad(FAzimuth[i]-90);
if FPlunge[i]>=90 then FPlunge[i]:=89.9;
If FPlunge[i]<90 then
begin
h:=Radius*SQRT2*Sin(DegToRad((90-FPlunge[i]))/2);
DegDipDir:=-DegDipDir;
X:=CenterX-(Radius*Radius-h*h)/2/h*Cos(DegDipDir);
Y:=CenterY+(Radius*Radius-h*h)/2/h*Sin(DegDipDir);
RR:=(h*h + Radius * Radius)/2/h;
OpenWidth:=ArcSin(Radius/RR);
DegDipDir:=DegToRad(FAzimuth[i]);
For points:= 0 to APolySegments do
begin
Case i of
1: begin
PPoints1^[points].x:=Round(X+RR*Sin(DegDipDir-OpenWidth*(1-2*points/APolySegments)));
PPoints1^[points].y:=Round(Y-RR*Cos(DegDipDir-OpenWidth*(1-2*points/APolySegments)));
end;
2: begin
PPoints2^[points].x:=Round(X+RR*Sin(DegDipDir-OpenWidth*(1-2*points/APolySegments)));
PPoints2^[points].y:=Round(Y-RR*Cos(DegDipDir-OpenWidth*(1-2*points/APolySegments)));
end;
end;
end;
end;
end; //for
//****find intersecting point between two polygons which are the great circles****
intsectcount:=0;
For points1:= 0 to APolySegments-1 do
begin
if PPoints1^[points1+1].x<>PPoints1^[points1].x then
begin
m1:=(PPoints1^[points1+1].y-PPoints1^[points1].y)/(PPoints1^[points1+1].x-PPoints1^[points1].x);
b1:=PPoints1^[points1].y-PPoints1^[points1].x*m1;
end;
For points2:= 0 to APolySegments-1 do
begin
if PPoints2^[points2+1].x<>PPoints2^[points2].x then
begin
m2:=(PPoints2^[points2+1].y-PPoints2^[points2].y)/(PPoints2^[points2+1].x-PPoints2^[points2].x);
b2:=PPoints2^[points2].y-PPoints2^[points2].x*m2;
if PPoints1^[points1+1].x<>PPoints1^[points1].x then
begin
If m1<>m2 then
begin
xs:=(b2-b1)/(m1-m2);
ys:=(b2*m1-b1*m2)/(m1-m2);
end
else
begin
xs:=0;
ys:=0;
end;
end
else
begin //limes for delta x1=0
xs:=PPoints1^[points1].x;
ys:=b2+m2*PPoints1^[points1].x;
end;
end
else
begin
if PPoints1^[points1+1].x<>PPoints1^[points1].x then
begin //limes for delta x2=0
xs:=PPoints2^[points2].x;
ys:=b1+m1*PPoints2^[points2].x;
end
else
begin
xs:=0;
ys:=0;
end;
end;
if (Abs(xs-PPoints1^[points1].x) <= Abs(PPoints1^[points1+1].x-PPoints1^[points1].x))
and (Abs(xs-PPoints1^[points1+1].x) <= Abs(PPoints1^[points1+1].x-PPoints1^[points1].x))
and (Abs(ys-PPoints1^[points1].y) <= Abs(PPoints1^[points1+1].y-PPoints1^[points1].y))
and (Abs(ys-PPoints1^[points1+1].y) <= Abs(PPoints1^[points1+1].y-PPoints1^[points1].y))
and (Abs(xs-PPoints2^[points2].x) <= Abs(PPoints2^[points2+1].x-PPoints2^[points2].x))
and (Abs(xs-PPoints2^[points2+1].x) <= Abs(PPoints2^[points2+1].x-PPoints2^[points2].x))
and (Abs(ys-PPoints2^[points2].y) <= Abs(PPoints2^[points2+1].y-PPoints2^[points2].y))
and (Abs(ys-PPoints2^[points2+1].y) <= Abs(PPoints2^[points2+1].y-PPoints2^[points2].y))
and (intsectpt12.x=0) then
begin
{$IFDEF Debugging}
Ellipse(FCanvas.Handle, round(xs)-5, round(ys)-5, round(xs)+5, round(ys)+5);
TextDummy:=IntToStr(points1)+','+IntToStr(points2);
fcanvas.brush.style:=bsclear;
Textout(FCanvas.Handle, round(xs), round(ys), pchar(TextDummy),Length(TextDummy));
{$ENDIF}
intsect12:=points1;
intsect21:=points2;
intsectpt12.x:=round(xs);
intsectpt12.y:=round(ys);
Inc(intsectcount);
end;
end; //For
end; //for
alpha:=Pi/APolySegments/2;
for points3:=0 to 4*APolySegments do
begin
PPoints3^[points3].x:=CenterX+Round(Radius*Cos(alpha*points3));
PPoints3^[points3].y:=CenterY+Round(Radius*Sin(alpha*points3));
end;
//****find intersecting points between great circles and surrounding circle****
for i:=1 to 2 do
For points:= 0 to APolySegments-1 do
begin
if (points=0) or (points=APolySegments-1) then
begin
case i of
1: if PPoints1^[points+1].x<>PPoints1^[points].x then
begin
m1:=(PPoints1^[points+1].y-PPoints1^[points].y)/(PPoints1^[points+1].x-PPoints1^[points].x);
b1:=PPoints1^[points].y-PPoints1^[points].x*m1;
end;
2: if PPoints2^[points+1].x<>PPoints2^[points].x then
begin
m1:=(PPoints2^[points+1].y-PPoints2^[points].y)/(PPoints2^[points+1].x-PPoints2^[points].x);
b1:=PPoints2^[points].y-PPoints2^[points].x*m1;
end;
end; //case
For points3:= 0 to 4*APolySegments-1 do
begin
case i of
1: if PPoints1^[points+1].x<>PPoints1^[points].x then
begin
if PPoints3^[points3+1].x<>PPoints3^[points3].x then
begin
m2:=(PPoints3^[points3+1].y-PPoints3^[points3].y)/(PPoints3^[points3+1].x-PPoints3^[points3].x);
b2:=PPoints3^[points3].y-PPoints3^[points3].x*m2;
If m1<>m2 then
begin
xs:=(b2-b1)/(m1-m2);
ys:=(b2*m1-b1*m2)/(m1-m2);
end
else
begin
xs:=0;
ys:=0;
end;
end
else
begin //limes for delta x3=0
xs:=PPoints3^[points3].x;
ys:=b1+m1*PPoints3^[points3].x;
end
end
else
begin
if PPoints3^[points3+1].x<>PPoints3^[points3].x then
begin
m2:=(PPoints3^[points3+1].y-PPoints3^[points3].y)/(PPoints3^[points3+1].x-PPoints3^[points3].x);
b2:=PPoints3^[points3].y-PPoints3^[points3].x*m2;
xs:=PPoints1^[points].x;
ys:=b2+m2*PPoints1^[points].x;
end
else
begin
xs:=0;
ys:=0;
end;
end;
2: if PPoints2^[points+1].x<>PPoints2^[points].x then
begin
if PPoints3^[points3+1].x<>PPoints3^[points3].x then
begin
m2:=(PPoints3^[points3+1].y-PPoints3^[points3].y)/(PPoints3^[points3+1].x-PPoints3^[points3].x);
b2:=PPoints3^[points3].y-PPoints3^[points3].x*m2;
If m1<>m2 then
begin
xs:=(b2-b1)/(m1-m2);
ys:=(b2*m1-b1*m2)/(m1-m2);
end
else
begin
xs:=0;
ys:=0;
end;
end
else
begin //limes for delta x3=0
xs:=PPoints3^[points3].x;
ys:=b1+m1*PPoints3^[points3].x;
end
end
else
begin
if PPoints3^[points3+1].x<>PPoints3^[points3].x then
begin
m2:=(PPoints3^[points3+1].y-PPoints3^[points3].y)/(PPoints3^[points3+1].x-PPoints3^[points3].x);
b2:=PPoints3^[points3].y-PPoints3^[points3].x*m2;
xs:=PPoints2^[points].x;
ys:=b2+m2*PPoints2^[points].x;
end
else
begin
xs:=0;
ys:=0;
end;
end;
end; //case
case i of
1: if (Abs(trunc(xs-PPoints1^[points].x)) <= Abs(PPoints1^[points+1].x-PPoints1^[points].x))
and (Abs(trunc(xs-PPoints1^[points+1].x)) <= Abs(PPoints1^[points+1].x-PPoints1^[points].x))
and (Abs(trunc(ys-PPoints1^[points].y)) <= Abs(PPoints1^[points+1].y-PPoints1^[points].y))
and (Abs(trunc(ys-PPoints1^[points+1].y)) <= Abs(PPoints1^[points+1].y-PPoints1^[points].y))
and (Abs(trunc(xs-PPoints3^[points3].x)) <= Abs(PPoints3^[points3+1].x-PPoints3^[points3].x))
and (Abs(trunc(xs-PPoints3^[points3+1].x)) <= Abs(PPoints3^[points3+1].x-PPoints3^[points3].x))
and (Abs(trunc(ys-PPoints3^[points3].y)) <= Abs(PPoints3^[points3+1].y-PPoints3^[points3].y))
and (Abs(trunc(ys-PPoints3^[points3+1].y)) <= Abs(PPoints3^[points3+1].y-PPoints3^[points3].y)) then
begin
if points=0 then
begin
if intsectpt310.x=0 then
begin
{$IFDEF Debugging}
Ellipse(FCanvas.Handle, round(xs)-5, round(ys)-5, round(xs)+5, round(ys)+5);
TextDummy:=inttostr(i)+','+IntToStr(points)+','+IntToStr(points3);
fcanvas.brush.style:=bsclear;
Textout(FCanvas.Handle, round(xs), round(ys), pchar(TextDummy),Length(TextDummy));
{$ENDIF}
intsectPt310.x:=round(xs);
intsectPt310.y:=round(ys);
intsect310:=points3;
Inc(intsectcount);
end;
end
else
begin
if intsectpt311.x=0 then
begin
{$IFDEF Debugging}
Ellipse(FCanvas.Handle, round(xs)-5, round(ys)-5, round(xs)+5, round(ys)+5);
TextDummy:=inttostr(i)+','+IntToStr(points)+','+IntToStr(points3);
fcanvas.brush.style:=bsclear;
Textout(FCanvas.Handle, round(xs), round(ys), pchar(TextDummy),Length(TextDummy));
{$ENDIF}
intsectPt311.x:=round(xs);
intsectPt311.y:=round(ys);
intsect311:=points3;
Inc(intsectcount);
end;
end;
end; //case i=1
2: if (Abs(trunc(xs-PPoints2^[points].x)) <= Abs(PPoints2^[points+1].x-PPoints2^[points].x))
and (Abs(trunc(xs-PPoints2^[points+1].x)) <= Abs(PPoints2^[points+1].x-PPoints2^[points].x))
and (Abs(trunc(ys-PPoints2^[points].y)) <= Abs(PPoints2^[points+1].y-PPoints2^[points].y))