KernelCAD Documentation

DInsight Home
Skip Navigation Links.
Start page
Quick Start
Installation
Overview of the software
What is new
Collapse KernelCAD ModelsKernelCAD Models
Collapse KernelCAD ComponentsKernelCAD Components
KernelCAD Control
KernelCAD .NET Control
Methods and Properties
Menu
Model Explorer
Birds Eye View
Programming
Direct User Access
Direct Operations
Interface Queries
Printing Support
Data Types
Modes of KernelCAD Control
DIObjectGenerator class
Properties
FlatObjectArray Poperty
Context
64 bit development
Dual Mode
Initialisation Context
Overlay Editor
Memory Management
Input validation
Collapse Advanced functionalityAdvanced functionality
Collapse InterfacesInterfaces
Alphabetical list
I3DGrid
I3DBugger
I3Dpt
IAxiBase
IAxis
IBoolSection
IBoolSectionEx
IBoundary
IColor
IConstraint
IData
IDiffSurface_KC
IDIFont
IDraw
IDrawUtil
IDraw2
IElem
IElement
IKCLine
ILightSource
ILocation
ILocationEx
IMaterial
IMetrics
IMetrics2
IModel
IModel2
IModelEx
IPatch
IKCPathCollisionDetector
IProfiles
IPropertyArray
IPropertyArray2
IStdShape
IStrip
ISurface
IText
ITexture
ITransform
IUnknown
Collapse Open Cascade TechnologyOpen Cascade Technology
Collapse DataData
Collapse MovementMovement
Collapse FramesFrames
Collapse Oriented ObjectsOriented Objects
Collapse SectionsSections
Collapse GeneralGeneral
Collapse Topological InterfacesTopological Interfaces
Collapse Viewing InterfacesViewing Interfaces
Collapse Lines And CurvesLines And Curves
Collapse Symmetry InterfacesSymmetry Interfaces
Collapse Clipping plane interfacesClipping plane interfaces
Collapse AlgorithmsAlgorithms
Collapse 2D Geometry2D Geometry
Collapse Programming Samples and TutorialsProgramming Samples and Tutorials
Collapse OverviewOverview
Collapse DeploymentDeployment
Collapse .NET Samples.NET Samples
Collapse C++ SamplesC++ Samples
Collapse Visual Basic SamplesVisual Basic Samples
Collapse Delphi SamplesDelphi Samples
Collapse 3D Debugger3D Debugger
Collapse DeploymentDeployment
Licensing
Model Viewer
Open C++ Source
Technical Support
Skip Navigation Links
VB .NET Metrics Sample

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 KernelCAD related functionality is implemented inside the MetricsForm class. The KernelCAD related data is initialized inside InitModelInfo() method, which uses GetModel method of the KernelCAD control to obtain the root interface of the hierarchy. ISection interfaces, representing generic KernelCAD object, are obtained for the first two top level objects of the model with the help of IModel.GetSection and stored in m_iSectionFrom and m_iSectionTo 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.