DG Kernel Documentation


Skip Navigation Links.
Start page
Quick Start
Search Page
Installation
Overview of the software
What is new
Licensing
Collapse ModelsModels
Collapse DG Kernel ComponentsDG Kernel Components
Collapse API ReferenceAPI Reference
Interface List
Vector Space
Collapse General GeometryGeneral Geometry
Collapse ModelModel
Collapse ViewView
Collapse General ComputingGeneral Computing
Collapse Samples and TutorialsSamples and Tutorials
Collapse GraphicsGraphics
Collapse Math ObjectsMath Objects
Collapse DeprecatedDeprecated
Redistribution
Model Viewer
Open Source
Support
Skip Navigation Links Search Documentation


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 DG Kernel 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).

See also:  C++ Patch TutorialC# Patch Tutorial    Visual Basic .NET Patch Tutorial,   All samples

Running Patch Sample

Patch application loads ArcPatch.mdg 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-entityal element (Elements).  Two edges of ArcPatch.mdg 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-entity position" specifies z coordinate for cross-entityal plane where all other parameter modifications will be applied. The next four edit boxes allow to modify coordinates of edge in the cross-entity plane. Note that type of modifications is different depending if is the cross-entity 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 entity is kept into m_iEntity member. It is obtained in the same procedure using call

Set m_iEntity = m_iModel.GetEntity(0)

This model is assumed to have a single entity. 

The same Form_Load() Sub acquires IAxiBase interface using call

Set m_iAxiBase = m_iEntity

Next, with the help of GetKnotValue method of IAxiBase interface we obtain range of z values for the entity.

Last job in  Form_Load(() is to acquire IStrip pointer from m_iEntity. IStrip interface m_iStrip is implemented by object which represents cross-entity segment strip.

Update_Surface_Info() Sub updates current cross-entity 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-entity 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-entity 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.