Home Page > Programming Samples and Tutorials > Visual Basic Samples > Morph
Morph VB Sample
Morph Sample
Source code for Profile sample is available in Samples\VB folder of the installation directory. Morph sample demonstrates direct manipulation of
an object surface using set of meshing interfaces. It also implements runtime
creation of a meshed object without referring to any model file.
See also IMesh, C# .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 vertex. Correspondent pair of buttons
allow browsing through the set of all vertexes. The current vertex is displayed
in 3D as a
thick red dot.
Update buttons allow modification of vertices.
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 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.
|