Patch Sample

Source code for Patch sample is available in Samples\VB
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, implemented in Visual Basic 6.0 which
displays a DI model consisting of a single patch of surface using KernelCAD ActiveX control and allows to modify geometrical parameters of the
model.

Note that VB 6.0 samples require Common
Dialogs component enabled in the development environment
(details).

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
behaviour, 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

Set iModUnkn = KernelCADCtrl.GetModel

retrieves iModUnkn 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

Set 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

Set m_iAxiBase = m_iSection

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.

Update_Surface_Info() Sub 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

Set m_iElemEdge1 = m_iStrip.GetElement(0, False)

Set 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 Update_Page() with:

m_dX1 = m_iElemEdge1.GetParam(0)

, ...

Line

Set m_iElemSegment = m_iStrip.GetElement(0, True)

from Update_Surface_Info() 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_pIElemEdgek interfaces.

Geometry changes are done in ButtonApply_Click() Sub through calls
to SetParam method of IElement interface. Call to UpdateSurface method of the
control carries out recalculation of surface for the modified model.