Home Page > Programming Samples and Tutorials > .NET Samples > Delphi Samples > Patch Sample
Delphi Patch Sample
Patch Delphi Sample
Source code for Patch sample is available in Samples\Delphi
folder of the installation directory. We suggest to
copy Patch folder to location outside the installation directory if you are going to compile
the project. Patch is an application, which
displays a model consisting of a single patch of surface using KernelCAD ActiveX control and allows
modification of geometrical parameters of the
model.
See also: C++ Patch Tutorial,
C# Patch Tutorial
Visual Basic .NET Patch Tutorial,
All samples
Running Patch Sample
Patch application loads ArcPatch.glm model located in the models folder. The
dialog displays parameters which can be modified to assign any valid shape to a
model with single cross-sectional element (Elements).
Two edges of ArcPatch.glm are not of the same type. To be able to compare behavior, the first edge (the right one) consists of arcs. The second edge
consists of straight line elements. The first edit box "Cross-section
position" specifies z coordinate for cross-sectional plane where all other
parameter modifications will be applied. The next four edit boxes allow to
modify coordinates of edge in the cross-section plane. Note that type of
modifications is different depending if is the cross-section position is at the end (
z=0 or z=10 ) or anywhere in the middle of the axial range.
Modifying the model
To enter new value of properties press "Apply" button. If entered values are
valid the model will change in 3D.
Implementation
All the work is done inside PatchFrm.frm module. In Form_Load() Sub line
m_iModel := AxKernCADnet1.GetModel();
retrieves m_iModel IModel interface (See
Interface List
), from which all other interfaces
are accessed. Interface to the current
section is kept into m_iSection member. It is obtained in the same
procedure using call
m_iSection := m_iModel.GetSection(0);
This model is assumed to have a single section.
The same Form_Load() Sub acquires IAxiBase
interface using call
m_iAxiBase := ( m_iSection as KernCADnet.IAxiBase );
Next, with the help of GetKnotValue method of IAxiBase interface we
obtain range of z values for the section.
Last job in Form_Load(() is to acquire IStrip
pointer from m_iSection. IStrip interface m_iStrip is
implemented by object which represents cross-section segment strip.
UpdateSurfaceInfo() method updates current cross-section
position of the model by calling SetCrossPosition method of IAxiBase. The
same function also retrieves IElement interfaces to both edge objects with
m_iElemEdge1 := m_iStrip.GetElement(0, false);
m_iElemEdge2 := m_iStrip.GetElement(1, false);
Edge of the patch in cross-section is a point, so it should have
two parameters. Values of those are obtained in UpdatePage() with:
m_dX1 := m_iElemEdge1.GetParam(0);
, ...
Line
m_iElemPatch := m_iStrip.GetElement(0, true);
from UpdateSurfaceInfo() retrieves IElement
interface implemented by the surface patch itself. In cross-section it is an
arc. It has single parameter - radius. We have already
accessed objects of the arc ends with m_iIElemEdge(k) interfaces.
Geometry changes are done in ApplyClick() method through calls
to SetParam method of IElement interface. Call to UpdateSurface method of the
control carries out recalculation of surface for the modified model.
|