DG Kernel (ActiveX) Documentation


Skip Navigation Links.
Start page
Quick Start
Search Page
Installation
What is new
Upgrading Native Apps
Licensing
Collapse ModelsModels
Collapse DG Kernel ControlsDG Kernel Controls
Collapse API ReferenceAPI Reference
Interface List
Vector Space
Collapse General GeometryGeneral Geometry
Collapse ModelModel
Collapse ViewView
Collapse General ComputingGeneral Computing
Collapse ViewsViews
Collapse Samples and TutorialsSamples and Tutorials
Collapse GraphicsGraphics
Collapse Math ObjectsMath Objects
Collapse DeprecatedDeprecated
Redistribution
Model Viewer
Open Source
Support
Skip Navigation Links Go to DGKC docs Search Documentation


Metrics Visual Basic .NET Sample

Metrics is an .NET Windows Forms application, which demonstrates calculation of distances, and nearest points between two objects and usage of IMetrics.Dist method.

Source code for Metrics sample is available in Samples\NET\VB folder of the installation directory. It is recommended to copy the folder to location outside of the installation folder.

Description

Implementation

All DG Kernel related functionality is implemented inside the MetricsForm class. The DG Kernel related data is initialized inside InitModelInfo() method, which uses GetModel method of the DG Kernel control to obtain the root interface of the hierarchy. ISection interfaces, representing generic DG Kernel object, are obtained for the first two top level objects of the model with the help of IModel.GetEntity and stored in m_iEntityFrom and m_iEntityTo member variables.

Calculation of distance is performed in buttCalculate_Click handler, where IMetrics interfaces are queried from relevant ISection and IMetrics.Dist is called. The result of the calculation is listed by returned IRelation interface.

In this application the calculated nearest points are displayed in 3D view with line segments and points. To improve performance of rendering IRelation is converted once to a .NET List and stored in m_pairList member. This work is done by CompileNearestData Sub, where pairs of the relation are iterated through, correspondent elements of the each per object list are retrieved and converted to the actual type of IVertex.

The application uses ClientDraw event, requested in OnFormLoad Sub, to add custom drawing of shortest segments and other elements to the scene. The drawing is performed inside OnClientDraw handler. In the OnClientDraw Sub the coordinates of each vertex are obtained via IVertex.GetVertexCoord. When rendering of normals, is requested they are obtained with a IVertex.GetNormal call in DrawNormals.

Work related to the "Is Closer than" group of controls is done in OnCalculateCloserThan handler with the help of IMetrics.IsCloserThan method.

Note that movements of the current object are performed in OnMoveObject via IFrame2 rather than IFrame to make movements relative to the current axes.