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 > C# Samples > Morph
Morph .NET C# Sample

Morph Sample

Source code for Profile sample is available in Samples\NET\C#  folder of the installation directory. It is recommended to copy whole C# directory to location outside of the installation folder before loading or compilation. Morph sample demonstrates direct manipulation of an object surface using set of meshing interfaces. It also implements runtime creation of a meshed object without reading any model file from the disc.

See also IMeshC# .NET Samples, All samples

The application  

By default the application does not load any model files. It creates a simple meshed object in memory. Controls on the right hand side display all information about the current simplex, the current vertex. Correspondent pairs of buttons allow browsing through the set of all elements.  The current Simplex is displayed in 3D in a violet wire frame. The current vertex is displayed as a thick red dot. 

Update buttons allow modification of vertices  and normals.

"Browse vertices" group allows switching between browsing vertices independently or for the currently selected simplex.

When the current vertex is a singular one ( edge or corner vertex ) there are more than one normal at the point. UpDown control in the Current normal group allows selection of the current normal. The current normal is displayed in 3D with a green color.

The application allows selection of an object in the model as the current one. The current object is highlighted in 3D with a reddish color. Switch to Surface mode using Render group to see it. All information on the right is relevant for the current object only. Name of the current object is displayed at the bottom. To change the current object press "Change" button and select a different object in 3D. Clicking outside any object will make the selection empty in which case all controls on the right will be disabled.

Simplex sub menu performs delete or divide operations.

Implementation

All implementation is contained in the main form class named Morph.

Information about the mesh geometry is obtained via meshing interfaces IMesh, IMeshEx and IIterator in range of Update..() methods starting from UpdateModelInfo() method.

Drawing of the current simplex, vertex and normal is done in OnClientDraw() handler for the ClientDraw KernelCAD control event. This event is requested on load via method RequestClientDraw of the control. Actual drawing is performed with the help of IDraw interface.

The application obtains the current object of the model via GetCurrentObject method of IModel2  interface. To enable highlighting of the current object there is a call to IView2.Enable method in SetupView().

To allow user changing the current object OnChangeCurObject method calls IViewModal.SetViewMode to change the current control mode from default "View" to "Modal". Selection of a different object in 3D view triggers a KernelCAD event, which is captured in OnCurrentObjectChanged(). This method stores reference to the selected  object passed via parameter, updates relevant information via UpdateObjectInfo() and switches off modal mode to allow normal viewing.

In this application "ModelPath" property of the KernelCAD control is an empty string, which means that no model is loaded on start of the application. Instead this sample demonstrates dynamic creation of Meshed object and dynamic creation of its surface via IMeshTopol interface. It is one in CreateDefault() method.