DG Kernel Documentation


Skip Navigation Links.
Start page
Quick Start
Search Page
Installation
Overview of the software
What is new
Licensing
Collapse ModelsModels
Collapse DG Kernel ComponentsDG Kernel Components
Collapse API ReferenceAPI Reference
Interface List
Vector Space
Collapse General GeometryGeneral Geometry
Collapse ModelModel
Collapse ViewView
Collapse General ComputingGeneral Computing
Collapse Samples and TutorialsSamples and Tutorials
Collapse GraphicsGraphics
Collapse Math ObjectsMath Objects
Collapse DeprecatedDeprecated
Redistribution
Model Viewer
Open Source
Support
Skip Navigation Links Search Documentation


Cannon C++ Sample

Source code for Cannon sample is available in Samples\VC  folder of the installation directory. If you are going to compile the project we suggest to copy whole VC directory to location outside of the installation folder. 

Overview

Implementation

Calculation of interentitys of each object in the model with the line of fire is done in OnFire method of the CannonDlg class. The calculation is performed with the help of IntersectObject method of ILineMetr interface. The result of the calculation is an IData interface, which gives access to array of records one per object interentity. 

On start or load of a model InitModelInfo() method retrieves array of all objects in the model irrespectively to child/parent relationship via FlatObjectArray property of the model.

In addition to the loaded model the DG Kernel Control displays model of a cannon to visualise location an direction of the line of fire. The Cannon object is created dynamically at runtime in the CreateCannon method. The cannon consists of four sub-objects. Child objects are added to the cannon object with IArray queried from m_iCannon ISection interface. Cannon itself is added to the model with IArray queried from the model (array of top level objects).

Positioning of the Cannon is done in MoveCannon, the "Apply" button handler.

Line of fire and normal at the interentity point are visualized in OnClientDraw DG Kernel event handler. The event is activated with a call RequestClientDraw(true) in OnFire method. The drawing is performed directly using IDraw interface. 

See also: Delphi Cannon Sample, All C# Samples,   All samples