Patchwork C++ Sample
Description
Implementation
All DG Kernel related functionality is implemented inside the PatchworkDlg
dialogue
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 in
UpdateObjectInfo() for the current object with the help of
IModel.GetEntity.
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
void* type. The actual type of the element, as described by
documentation is
IPatch. The
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 IUnknown* 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.
|