MathgeomGLS
811 строк · 21.9 Кб
1unit LevelCurves;
2
3interface
4
5uses
6Winapi.Windows,
7System.Classes,
8System.SysUtils,
9System.Math,
10System.ImageList,
11System.Actions,
12System.Variants,
13Vcl.Graphics,
14Vcl.Forms,
15Vcl.Controls,
16Vcl.Menus,
17Vcl.Dialogs,
18Vcl.StdCtrls,
19Vcl.Buttons,
20Vcl.ExtCtrls,
21Vcl.ComCtrls,
22Vcl.ImgList,
23Vcl.StdActns,
24Vcl.ActnList,
25Vcl.ToolWin,
26Vcl.DBCtrls,
27Generics.Collections,
28
29GLS.VectorTypesExt,
30GLS.Cadencer,
31GLS.Material,
32GLS.Scene,
33GLS.Objects,
34GLS.GeomObjects,
35GLS.VectorGeometry,
36GLS.VectorFileObjects,
37GLS.VectorLists,
38GLS.Coordinates,
39
40GLS.BaseClasses,
41GLS.SceneViewer,
42GLS.HUDObjects,
43GLS.WindowsFont,
44GLS.Texture,
45GLSL.UserShader,
46GLS.Color,
47GLS.Graphics,
48GLS.RenderContextInfo,
49GLS.Mesh,
50GLS.VectorTypes,
51GLS.MultiPolygon,
52GLS.AVIRecorder,
53GLS.Extrusion,
54GLS.BitmapFont,
55GLS.Context,
56GLS.State,
57GLS.TextureFormat,
58GLS.ProxyObjects,
59GLS.SpaceText,
60GLS.AsyncTimer,
61GLS.Isolines,
62
63About,
64UNcube;
65
66const
67Nx = 40; // dimension west - east
68Ny = 40; // dimenstion north west
69Nz = 40; // dimenstion height
70
71res3DmaxForm3D= 100; res3DminForm3D= 10;
72
73Kfixed = 4; // Came from a 3D code where the plane XY can move as Z[I,J,K}
74gxmin = -3;
75gxmax = 6.5;
76gymin = -4;
77gymax = 4;
78
79type
80TLevelCurvesForm = class(TForm)
81OpenDialog: TOpenDialog;
82SaveDialog: TSaveDialog;
83ToolBar1: TToolBar;
84ToolButton9: TToolButton;
85ToolButton1: TToolButton;
86ToolButton2: TToolButton;
87ToolButton3: TToolButton;
88ToolButton4: TToolButton;
89ToolButton5: TToolButton;
90ToolButton6: TToolButton;
91StatusBar: TStatusBar;
92MainMenu: TMainMenu;
93File1: TMenuItem;
94FileNewItem: TMenuItem;
95FileOpenItem: TMenuItem;
96FileSaveItem: TMenuItem;
97FileSaveAsItem: TMenuItem;
98N1: TMenuItem;
99FileExitItem: TMenuItem;
100Edit1: TMenuItem;
101CutItem: TMenuItem;
102CopyItem: TMenuItem;
103PasteItem: TMenuItem;
104Help1: TMenuItem;
105HelpAboutItem: TMenuItem;
106pnlGLscene2: TPanel;
107StaticText1: TStaticText;
108View: TGLSceneViewer;
109GLScene: TGLScene;
110GLLightSource1: TGLLightSource;
111dc_cam: TGLDummyCube;
112PlaneXY: TGLFreeForm;
113cam: TGLCamera;
114GLMaterialLibrary1: TGLMaterialLibrary;
115GLCadencer1: TGLCadencer;
116pnlDimensoesGL: TPanel;
117RGexamples: TRadioGroup;
118SeeIsolines: TCheckBox;
119TrackBarNC: TTrackBar;
120rgNodeAspect: TRadioGroup;
121Label2: TLabel;
122TrackBarPosition: TTrackBar;
123rgPlaneSelection: TRadioGroup;
124cad: TGLCadencer;
125AsyncTimer1: TGLAsyncTimer;
126RGpanning: TRadioGroup;
127DC_world: TGLDummyCube;
128DC_utils: TGLDummyCube;
129lbNL: TLabel;
130rgSplineModes: TRadioGroup;
131procedure FileNew1Execute(Sender: TObject);
132procedure FileOpen1Execute(Sender: TObject);
133procedure FileSave1Execute(Sender: TObject);
134procedure FileExit1Execute(Sender: TObject);
135procedure HelpAbout1Execute(Sender: TObject);
136procedure ViewMouseDown(Sender: TObject; Button: TMouseButton;
137Shift: TShiftState; x, y: Integer);
138procedure ViewMouseMove(Sender: TObject; Shift: TShiftState;
139x, y: Integer);
140procedure ViewMouseWheel(Sender: TObject; Shift: TShiftState;
141WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
142procedure FormKeyPress(Sender: TObject; var Key: Char);
143procedure FormCreate(Sender: TObject); // values of cut levels
144procedure DrawPlaneClick(Sender: TObject);
145procedure Use_CONREC_XY (Kfix:integer);
146procedure RGexamplesClick(Sender: TObject);
147procedure TrackBarNCChange(Sender: TObject);
148procedure rgNodeAspectClick(Sender: TObject);
149procedure FormClose(Sender: TObject; var Action: TCloseAction);
150procedure TrackBarPositionChange(Sender: TObject);
151procedure RGpanningClick(Sender: TObject);
152procedure cadProgress(Sender: TObject; const deltaTime, newTime: Double);
153procedure AsyncTimer1Timer(Sender: TObject);
154procedure FormActivate(Sender: TObject);
155procedure FormDeactivate(Sender: TObject);
156procedure rgPlaneSelectionClick(Sender: TObject);
157procedure rgSplineModesClick(Sender: TObject);
158private
159mdx, mdy: Integer;
160mx, my: Integer;
161UserAbort: Boolean;
162public
163dir: Integer;
164NC: Integer; // dimension for contour levels
165pt1AX, pt1AY, pt1AZ, pt1BX, pt1BY, pt1BZ, flap1A, flap1B: single;
166Isolines: TGLIsolines;
167procedure CreateInputData;
168end;
169
170var
171LevelCurvesForm: TLevelCurvesForm;
172Mat: TMatrixArr; // 2D - Datafield replaced by res3DPlane
173Scx: TVectorArr; // scaling vector west - east
174Scy: TVectorArr; // scaling vector north - west
175Scz: TVectorArr; // scaling vector north - west
176Hgt: TVectorArr; // vector for the countur levels
177i, j, k: Integer; // adress indexes
178mi, ma: Double; // for minimum & maximum
179Xarr, Yarr, // coord. values
180Zarr, res3DPlane: array of array of array of Double;
181Z_Kfixed: Integer;
182ncube: TGLNCube;
183
184//======================================
185implementation
186//======================================
187
188{$R *.dfm}
189
190procedure TLevelCurvesForm.FormCreate(Sender: TObject);
191begin
192SetCurrentDir(ExtractFilePath(ParamStr(0)));
193Z_Kfixed := TrackBarPosition.Position;
194Isolines := TGLIsolines.CreateAsChild(PlaneXY);
195Isolines.LineColor.Color := clrBlack;
196Isolines.LinePattern := $FFFF;
197Isolines.LineWidth := 2;
198Isolines.NodesAspect := TGLLineNodesAspect(0);
199Isolines.SplineMode := lsmSegments; //lsmBezierSpline;
200
201// using my 3D type variables . Each point in the 3D space is defined by
202// X[I,J,K] Y[I,J,K]and Z[I,J,K] . The value of the variable to map is
203// res3Dplane[I,J,K] in that point (already normalized for =0 and <=1)
204SetLength(Xarr, Nx+1 , Ny+1 , Nz+1 );
205SetLength(Yarr, Nx+1 , Ny+1 , Nz +1);
206SetLength(Zarr, Nx +1, Ny+1 , Nz+1 );
207SetLength(res3DPlane, Nx+1 , Ny+1 , Nz+1 );
208RGexamplesClick(Self);
209RGpanningClick(self);
210end;
211
212procedure TLevelCurvesForm.RGpanningClick(Sender: TObject);
213begin
214case RGpanning.ItemIndex of
2150:
216begin
217if ncube = nil then
218begin
219cad.Enabled := true;
220ncube := TGLNCube.CreateAsChild(GLScene.Objects);
221ncube.SceneViewer := View;
222ncube.FPS := 30;
223application.OnActivate := OnActivate;
224application.OnDeactivate := OnDeactivate;
225end;
226end;
2271:
228begin
229if ncube <> nil then
230begin
231if Assigned(ncube) then
232begin
233cad.Enabled := False;
234ncube.Free;
235ncube := nil;
236end;
237end;
238end;
239end;
240end;
241
242procedure TLevelCurvesForm.rgPlaneSelectionClick(Sender: TObject);
243begin
244case rgPlaneSelection.ItemIndex of
2450: begin //XY
246PlaneXY.Roll(0);
247PlaneXY.Pitch(0);
248PlaneXY.Turn(90);
249end;
2501: begin //YZ;
251PlaneXY.Roll(0);
252PlaneXY.Pitch(90);
253PlaneXY.Turn(0);
254end;
2552: begin //ZX;
256PlaneXY.Roll(90);
257PlaneXY.Pitch(0);
258PlaneXY.Turn(0);
259end;
260end;
261// rgExamplesClick(self);
262end;
263
264procedure TLevelCurvesForm.rgSplineModesClick(Sender: TObject);
265begin
266case rgSplineModes.ItemIndex of
2670: Isolines.SplineMode := lsmSegments;
2681: Isolines.SplineMode := lsmCubicSpline;
2692: Isolines.SplineMode := lsmBezierSpline;
2703: Isolines.SplineMode := lsmNURBSCurve;
2714: Isolines.SplineMode := lsmLines;
2725: Isolines.SplineMode := lsmLoop;
273end;
274end;
275
276// __________________________________________________________________________
277procedure TLevelCurvesForm.AsyncTimer1Timer(Sender: TObject);
278begin
279caption := 'naviCube: ' + View.FramesPerSecondText(2);
280View.ResetPerformanceMonitor;
281end;
282
283procedure TLevelCurvesForm.cadProgress(Sender: TObject; const deltaTime,
284newTime: Double);
285begin
286if ncube<> nil then
287begin
288if ncube.InactiveTime > 5 then begin
289if ncube.InactiveTime < 8 then
290dc_cam.TurnAngle := dc_cam.TurnAngle + (ncube.InactiveTime - 5) * deltatime * 2
291else
292dc_cam.TurnAngle := dc_cam.TurnAngle + deltatime * 6;
293end;
294View.Refresh;
295end;
296end;
297
298procedure TLevelCurvesForm.ViewMouseDown(Sender: TObject;
299Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
300begin
301mx := X;
302my := Y;
303View.SetFocus;
304end;
305
306procedure TLevelCurvesForm.ViewMouseMove(Sender: TObject;
307Shift: TShiftState; X, Y: Integer);
308var
309dx, dy: Integer;
310
311begin
312// calculate delta since last move or last mousedown
313dx := mdx - X;
314dy := mdy - Y;
315mdx := X;
316mdy := Y;
317if ssLeft in Shift then
318begin
319if ssShift in Shift then
320begin // right button with shift rotates DC1 (rotation happens around camera's axis)
321cam.RotateObject(dc_world, dy, dx);
322end
323else
324begin // right button without shift changes camera angle *** moving around the parent and target dummycube)
325cam.MoveAroundTarget(dy, dx)
326end;
327end
328else if Shift = [ssRight] then
329begin // left button moves our target and parent dummycube
330// v:=cam1.ScreenDeltaToVectorXY(dx, -dy,0.12*cam1.DistanceToTarget/cam1.FocalLength);
331// DC1.Position.Translate(v); // notify camera that its position/target has been changed
332// cam1.TransformationChanged;
333end;
334
335end;
336
337procedure TLevelCurvesForm.ViewMouseWheel(Sender: TObject;
338Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint;
339var Handled: Boolean);
340begin
341cam.AdjustDistanceToTarget(Power(1.03, WheelDelta / 300));
342end;
343
344procedure TLevelCurvesForm.FormDeactivate(Sender: TObject);
345begin
346cad.Enabled := false;
347end;
348
349procedure TLevelCurvesForm.FormActivate(Sender: TObject);
350begin
351cad.Enabled := true;
352end;
353// __________________________________________________________________________
354procedure TLevelCurvesForm.rgNodeAspectClick(Sender: TObject);
355begin
356case rgNodeAspect.ItemIndex of
3570: Isolines.NodesAspect := TGLLineNodesAspect(0);
3581: Isolines.NodesAspect := TGLLineNodesAspect(2);
3592: Isolines.NodesAspect := TGLLineNodesAspect(1);
360end;
361end;
362
363// __________________________________________________________________________
364procedure TLevelCurvesForm.RGexamplesClick(Sender: TObject);
365var I:integer ;
366begin
367CreateInputData;
368DrawPlaneClick(Self);
369end;
370
371
372procedure TLevelCurvesForm.TrackBarNCChange(Sender: TObject);
373begin
374lbNL.Caption := 'NL: '+ IntToStr(TrackBarNC.Position);
375RGexamplesClick(self);
376end;
377
378procedure TLevelCurvesForm.TrackBarPositionChange(Sender: TObject);
379begin
380RGexamplesClick(self);
381end;
382
383
384procedure TLevelCurvesForm.CreateInputData;
385var
386i, j: Integer;
387xAux, yAux: Double;
388begin
389for i := 0 to Nx - 1 Do
390// ----------------------------------- set 2d data field
391begin
392for j := 0 to Ny - 1 Do
393Begin
394for k := 0 to Nz - 1 Do
395begin
396case RGexamples.ItemIndex of
3970:
398begin
399Xarr[i, j, k] := i - Nx / 2;
400Yarr[i, j, k] := j - Ny / 2;
401Zarr[i, j, k] := Z_Kfixed;
402end;
4031:
404begin
405Xarr[i, j, k] := gxmin + i * (gxmax - gxmin) / Nx;
406Yarr[i, j, k] := gymin + j * (gymax - gymin) / Ny;
407Zarr[i, j, k] := Z_Kfixed;
408end;
4092:
410begin
411Xarr[i, j, k] := i - Nx / 2;
412Yarr[i, j, k] := j - Ny / 2;
413Zarr[i, j, k] := Z_Kfixed;
414end;
415
416end;
417end;
418end;
419end;
420
421for i := 0 to Nx - 1 do // ------ set 2d data field
422begin
423for j := 0 to Ny - 1 do
424begin
425// example of mapping xAux and yAux are the coordinates in the X and Y axis
426// and res3Dplane are normalized values ( >0 and <1) at the points to mapp
427
428xAux := Xarr[i, j, Kfixed];
429yAux := Yarr[i, j, Kfixed];
430
431case RGexamples.ItemIndex of
4320:
433begin
434res3DPlane[i, j, Kfixed] :=
435(sin(xAux / Nx * 4 * pi) * cos(yAux / Ny * 4 * pi)) +
436(sin(xAux / Nx * 2 * pi) * cos(yAux / Ny * 2 * pi)) +
437(sin(xAux / Nx * 1 * pi) * cos(yAux / Ny * 1 * pi)) +
438(sin(xAux / Nx * 0.5 * pi) * cos(yAux / Ny * 0.5 * pi)) +
439(sin(xAux / Nx * 0.25 * pi) * cos(yAux / Ny * 0.25 * pi));
440end;
4411:
442begin
443if (xAux <> 4) or (yAux <> 0) then
444res3DPlane[i, j, Kfixed] := 0.5 *
445(sin(sqrt(sqr(xAux) + sqr(yAux))) + 1 /
446sqrt(sqr(xAux - 4) + sqr(yAux)));
447end;
4482:
449begin
450xAux := 0.08 * (i - Nx / 2);
451yAux := 0.08 * (j - Ny / 2);
452res3DPlane[i, j, Kfixed] :=
453(sqr(sqr(xAux) + (yAux - 0.842) * (yAux + 0.842)) +
454sqr(xAux * (yAux - 0.842) + xAux * (yAux - 0.842)));
455end;
456end;
457end;
458end;
459end;
460
461procedure TLevelCurvesForm.DrawPlaneClick(Sender: TObject);
462var
463ResultsMesh: TGLMeshObject;
464Quads: TFGVertexIndexList;
465i, j, k, MMT: Integer;
466begin
467// reconvert to 3D variables before drawing a plane
468View.Update;
469View.Invalidate;
470///////////////////////////////////////////////////////////
471PlaneXY.MeshObjects.Clear;
472ResultsMesh := TGLMeshObject.CreateOwned(PlaneXY.MeshObjects);
473ResultsMesh.Mode := momFaceGroups;
474
475case rgPlaneSelection.ItemIndex of
4760:
477begin
478k := Kfixed;
479with ResultsMesh do
480begin
481for i := 1 to Nx do // 1 to Nx
482begin // 1 to Ny
483for j := 1 to Ny do
484begin // coloquei o deltaXwall para ficar centrado
485Vertices.Add(Xarr[i, j, k], Yarr[i, j, k], Zarr[i, j, k]);
486TexCoords.Add(res3DPlane[i, j, k], 0);
487
488end;
489end;
490Quads := TFGVertexIndexList.CreateOwned(ResultsMesh.FaceGroups);
491Quads.Mode := fgmmQuads;
492for i := 1 to Nx - 2 do
493begin
494for j := 1 to Ny - 2 do
495begin
496MMT := (i - 1) * Ny + j - 1;
497Quads.VertexIndices.Add(MMT, MMT + 1);
498Quads.VertexIndices.Add(MMT + Ny + 1, MMT + Ny);
499end;
500end;
501end;
502
503if SeeIsolines.Checked then
504Use_CONREC_XY(k)
505else
506Isolines.Nodes.Clear;
507end;
508
5091:
510begin
511i := Kfixed;
512with ResultsMesh do
513begin
514for j := 1 to Ny do // 1 to Nx
515begin // 1 to Ny
516for k := 1 to Nz do
517begin // coloquei o deltaXwall para ficar centrado
518Vertices.Add(Xarr[i, j, k], Yarr[i, j, k], Zarr[i, j, k]);
519TexCoords.Add(res3DPlane[i, j, k], 0);
520
521end;
522end;
523Quads := TFGVertexIndexList.CreateOwned(ResultsMesh.FaceGroups);
524Quads.Mode := fgmmQuads;
525for j := 1 to Ny - 2 do
526begin
527for k := 1 to Nz - 2 do
528begin
529MMT := (j - 1) * Nz + k - 1;
530Quads.VertexIndices.Add(MMT, MMT + 1);
531Quads.VertexIndices.Add(MMT + Nz + 1, MMT + Nz);
532end;
533end;
534end;
535
536if SeeIsolines.Checked then
537Use_CONREC_XY(i)
538else
539Isolines.Nodes.Clear;
540end;
541
5422:
543begin
544j := Kfixed;
545with ResultsMesh do
546begin
547for k := 1 to Nz do // 1 to Nx
548begin // 1 to Ny
549for i := 1 to Nx do
550begin // coloquei o deltaXwall para ficar centrado
551Vertices.Add(Xarr[i, j, k], Yarr[i, j, k], Zarr[i, j, k]);
552TexCoords.Add(res3DPlane[i, j, k], 0);
553
554end;
555end;
556Quads := TFGVertexIndexList.CreateOwned(ResultsMesh.FaceGroups);
557Quads.Mode := fgmmQuads;
558for k := 1 to Nz - 2 do
559begin
560for i := 1 to Nx - 2 do
561begin
562MMT := (k - 1) * Nx + i - 1;
563Quads.VertexIndices.Add(MMT, MMT + 1);
564Quads.VertexIndices.Add(MMT + Nx + 1, MMT + Nx);
565end;
566end;
567end;
568
569if SeeIsolines.Checked then
570Use_CONREC_XY(j)
571else
572Isolines.Nodes.Clear;
573end;
574end;
575PlaneXY.StructureChanged;
576end;
577
578// __________________________________________________________________________
579procedure TLevelCurvesForm.Use_CONREC_XY (Kfix:integer);
580var
581I,J,K:integer; NCL:integer; planeName:string;
582F38: TextFile;
583File38: string;
584FileIsolines: TFileName;
585IsoValuesList: TList<Real>;
586TextIso:TGlFlatText;
587begin
588File38 := ExtractFilePath(application.ExeName) + 'Isolines.txt';
589If FileExists(File38) Then
590DeleteFile(File38);
591AssignFile(F38, File38);
592Rewrite(F38);
593writeln(F38, ' Hgt[i] Nodes.Items[i].X Nodes.Items[i].Y ]');
594
595// convert 3D variables to CONREC type variables
596SetLength(Scx, Nx);
597SetLength(Scy, Ny);
598SetLength(Scz, Nz);
599
600case rgPlaneSelection.ItemIndex of
6010:
602begin
603SetLength(Mat, Nx, Ny);
604
605for i := 0 to Nx - 1 Do
606Scx[i] := Xarr[i, 0, Kfixed];
607for j := 0 to Ny - 1 Do
608Scy[j] := Yarr[0, j, Kfixed];
609
610for i := 0 to Nx - 1 Do
611begin
612for j := 0 to Ny - 1 Do
613begin
614Mat[i, j] := res3DPlane[i, j, Kfixed];
615end; // ----------------------------------------------------------------
616end;
617
618mi := 1E16;
619// ------------ Set the minimunm and maximum f of the data field
620ma := -1E16;
621
622for i := 0 to Nx - 1 Do
623begin
624for j := 0 to Ny - 1 Do
625begin
626if Mat[i, j] < mi then
627mi := Mat[i, j];
628if Mat[i, j] > ma then
629ma := Mat[i, j];
630end; // ----------------------------------------------------------------
631end;
632
633NC := TrackBarNC.Position;
634Z_Kfixed := TrackBarPosition.Position;
635SetLength(Hgt, NC);
636for i := 0 to NC - 1 Do // ----- create cut levels
637Hgt[i] := mi + i * (ma - mi) / (NC - 1);
638
639Isolines.Nodes.Clear;
640Isolines.Conrec(rgPlaneSelection.ItemIndex, PlaneXY, Mat, 0, Nx - 1, 0,
641Ny - 1, Scx, Scy, NC, Hgt, Z_Kfixed, res3DmaxForm3D, res3DminForm3D);
642end;
6431:
644begin
645SetLength(Mat, Ny, Nz);
646
647for j := 0 to Ny - 1 do
648Scy[j] := Yarr[Kfixed, j, 0];
649for k := 0 to Nz - 1 do
650Scz[k] := Zarr[Kfixed, 0, k];
651
652for j := 0 to Ny - 1 do
653begin
654for k := 0 to Nz - 1 do
655begin
656Mat[j, k] := res3DPlane[Kfixed, j, k];
657end; // ----------------------------------------------------------------
658end;
659
660mi := 1E16;
661// ------------ Set the minimunm and maximum f of the data field
662ma := -1E16;
663
664for j := 0 to Ny - 1 do
665begin
666for k := 0 to Nz - 1 do
667begin
668if Mat[j, k] < mi then
669mi := Mat[j, k];
670if Mat[j, k] > ma then
671ma := Mat[j, k];
672end; // ----------------------------------------------------------------
673end;
674
675NC := TrackBarNC.Position;
676Z_Kfixed := TrackBarPosition.Position;
677SetLength(Hgt, NC);
678for i := 0 to NC - 1 Do // ----- create cut levels
679Hgt[i] := mi + i * (ma - mi) / (NC - 1);
680
681Isolines.Nodes.Clear;
682Isolines.Conrec(rgPlaneSelection.ItemIndex, PlaneXY, Mat, 0, Ny - 1, 0,
683Nz - 1, Scy, Scz, NC, Hgt, Z_Kfixed, res3DmaxForm3D, res3DminForm3D);
684end;
6852:
686begin
687SetLength(Mat, Nz, Nx);
688
689for k := 0 to Nz - 1 do
690Scy[k] := Zarr[0, Kfixed, k];
691for i := 0 to Nx - 1 do
692Scz[i] := Xarr[i, Kfixed, 0];
693
694for k := 0 to Nz - 1 Do
695begin
696for i := 0 to Nx - 1 Do
697begin
698Mat[k, i] := res3DPlane[i, Kfixed, k];
699end; // ----------------------------------------------------------------
700end;
701
702mi := 1E16;
703// ------------ Set the minimunm and maximum f of the data field
704ma := -1E16;
705
706for k := 0 to Nz - 1 Do
707begin
708for i := 0 to Nx - 1 Do
709begin
710if Mat[k, i] < mi then
711mi := Mat[k, i];
712if Mat[k, i] > ma then
713ma := Mat[k, i];
714end; // ----------------------------------------------------------------
715end;
716
717NC := TrackBarNC.Position;
718Z_Kfixed := TrackBarPosition.Position;
719SetLength(Hgt, NC);
720for i := 0 to NC - 1 Do // ----- create cut levels
721Hgt[i] := mi + i * (ma - mi) / (NC - 1);
722Isolines.Conrec(rgPlaneSelection.ItemIndex, PlaneXY, Mat, 0, Nz - 1, 0,
723Nx - 1, Scz, Scx, NC, Hgt, Z_Kfixed, res3DmaxForm3D, res3DminForm3D);
724end;
725
726end;
727
728/// start write
729IsoValuesList := TList<Real>.Create;
730for i := 0 to Isolines.Nodes.Count - 1 do
731begin
732writeln(F38, Format('%10.2f %5.2f %5.2f',
733[Hgt[i], Isolines.Nodes.Items[i].x, Isolines.Nodes.Items[i].y]));
734end;
735
736IsoValuesList.Free;
737CloseFile(F38);
738end;
739
740procedure TLevelCurvesForm.FileSave1Execute(Sender: TObject);
741begin
742SaveDialog.Execute;
743end;
744
745
746procedure TLevelCurvesForm.FileNew1Execute(Sender: TObject);
747begin
748{ Do nothing }
749end;
750
751procedure TLevelCurvesForm.FileOpen1Execute(Sender: TObject);
752begin
753OpenDialog.Execute;
754end;
755
756
757procedure TLevelCurvesForm.FormKeyPress(Sender: TObject; var Key: Char);
758begin
759UserAbort := Key = #27;
760with dc_cam do
761case Key of
762'7': RotateAbsolute(-15, 0, 0);
763'9': RotateAbsolute(+15, 0, 0);
764'4': RotateAbsolute(0, -15, 0);
765'6': RotateAbsolute(0, +15, 0);
766'1': RotateAbsolute(0, 0, -15);
767'3': RotateAbsolute(0, 0, +15);
768end;
769end;
770
771procedure TLevelCurvesForm.FileExit1Execute(Sender: TObject);
772begin
773Close;
774end;
775
776procedure TLevelCurvesForm.HelpAbout1Execute(Sender: TObject);
777begin
778with TAboutBox.Create(Self) do
779try
780ShowModal;
781finally
782Free;
783end;
784end;
785
786procedure TLevelCurvesForm.FormClose(Sender: TObject; var Action: TCloseAction);
787var
788temp: Tcomponent;
789begin
790SetLength(Mat,0);
791SetLength(Scx,0);
792SetLength(Scy,0);
793SetLength(Scz,0);
794
795SetLength(Hgt,0);
796SetLength(Xarr,0);
797SetLength(Yarr,0);
798SetLength(Zarr,0);
799SetLength(res3DPlane,0);
800PlaneXY.MeshObjects.Clear;
801Isolines.Nodes.Clear;
802Action := caFree;
803
804for i := ComponentCount - 1 downto 0 do
805begin
806temp := Components[i]; // if (Temp is TObject) then
807RemoveComponent(temp);
808end;
809end;
810
811end.
812