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 LinksHome Page > Programming Samples and Tutorials > .NET Samples > Visual Basic Samples > Patchwork
Patchwork VB .NET Sample

Patchwork Visual Basic .NET Sample

Description

Implementation

All KernelCAD related functionality is implemented inside the Patchwork form 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 in UpdateObjectInfo() for the current object with the help of IModel.GetSection. ISurface interface then queried from the ISection. and stored in m_iSurface member of the class.

m_iList array keeps three lists, namely lists of all vertices, edges and patches in the surface. Index of the element coincides with its dimension. These are obtained in UpdateObjectInfo() with calls to methods of ISurface.

UpdatePatchInfo() method is supposed to be called when the current patch has changed to update all related information. Elements stored in a list are interpreted by the Visual Studio as IntPtr type. The actual type of the element, as described by documentation is IPatch. This conversion is performed with a call to System.Runtime.InteropServices.Marshal.GetObjectForIUnknown(p) .NET method. The resulting IPatch reference is stored in m_iCurElem(2) member.

Array of edges in the patch are retrieved in the same UpdatePatchInfo() with a call to IPatch.GetEdges method and stored in m_iArrEdges member.

The m_iCurElem array, which declared as Object type stores IVertex, IKCLine and IPatch interfaces for the current element in the surface.

UpdateCurrentEdgeInfo() applies work similar to UpdatePatchInfo() to edges of the surface. m_bBrowseAll member indicates the current user selection: whether the next edge should be taken from the m_iList(1) list of all edges in the surface or from the array of the patch edges m_iArrEdges.

UpdateCurrentVertexInfo() does work similar to UpdateCurrentEdgeInfo() for vertices. The method also obtains coordinates of the vertex with a call to IVertex.GetVertexCoord() via GetPoint method of the Patchwork class and stores it in m_curVertex variable.

Current selection is highlighted in 3D by OnClientDraw handler of the ClientDraw event. The current patch is rendered using IGraphicItem interface stored in m_iGraphicItemPatch variable. IGraphicItem is queried from IPatch interface m_iCurElem(2). Note how the color of the patch was set with m_iDraw.Color(1.0, 1.0, 0.0, 1.0) prior the IGraphicItem.Draw call. The current edge and the current vertex are rendered by using appropriate methods of IDraw.