ITechnology_DG Interface
ITechnology_DG Interface
- GetTechnologyName
- GetGlobalObjectPointer
- GetPointer
- GetInterface
- Execute
- SetTechnologyToAppCallback
The interface provides access to technologies used in KernelCAD. It is intended for advanced C++ deveopment where some modification of open source of a third party component is required. It queries major global objects from the component, maps them to KernelCAD entities when possible and establishes communication both ways between KernelCAD based application and the third party component
The interface can be queried from IGlobalAPI_KC with
ITechnology_DG* iTechnology = NULL;
iKcApi->GetTechnology("OCCT", &iTechnology);
Or
iKcApi->GetTechnology("Ogre", &iTechnology);
See also OCCT Bridge sample, Ogre Bridge sample
POSNT type below must be considered as (cast to) void*
HRESULT GetTechnologyName(BSTR* name)
Returns name of this technology ("OCCT" or "Ogre" in this version).
HRESULT GetGlobalObjectPointer(char* type, POSNT* pp)
Parameters
type - [in] Type of the item requested. See remarks
pp - [out,retval] The requested pointer. See remarks
- Remarks:
Returns pointer to the specified object in the technolgy. There are no object obtainable in this way in the OCCT technology. For Ogre technology the only valid opion for type is "Root", in which case the returned value is Ogre::Root* pointer of the only Ogre::Root object.
HRESULT GetPointer(IUnknown* objectFrom, char* interfaceNameFrom, char* requestedPointer, POSNT* outPointer)
Parameters
objectFrom - [in] KernelCAD object, which has acces to the requested pointer
interfaceNameFrom - [in] The actual name of the objectFrom interface
requestedPointer - [in] Specifies (enumerates) the requested pointer. See remarks
outPointer - [out,retval] The requested pointer
- Remarks:
Maps KernelCAD objects to the technology. Returns pointer to the specified object in the technolgy. objectFrom specifies either KernelCAD view or a specific KernelCAD item, which owns or can be mapped to the requested object. Valid options for input and type of retun are listed below:
OCCT Technology
objectFrom |
interfaceNameFrom |
requestedPointer |
Returned type |
IView* |
"IView" |
"TDocStd_Application" |
Handle_AIS_TDocStd_Application* |
IView* |
"IView" |
"TDocStd_Document" |
Handle_TDocStd_Document* |
IView* |
"IView" |
"V3d_Viewer" |
Handle_V3d_Viewer* |
IView* |
"IView" |
"AIS_InteractiveContext" |
Handle_AIS_InteractiveContext* |
ISection* |
"ISection" |
"TopoDS_Shape" |
TopoDS_Shape* |
ISection* |
"ISection" |
"AIS_Shape" |
Handle_AIS_Shape* |
When requestedPointer is "TDocStd_Application" the returned pointer must be dereferenced immediately and stored like:
POSNT p = NULL;
iTechnology->GetPointer(iView, "IView", "TDocStd_Application", &p);
Handle_TDocStd_Application hApp = *((Handle_TDocStd_Application*)p);
See OcctBridgeView::DoTest() in OCCT Bridge sample
Ogre Technology
objectFrom |
interfaceNameFrom |
requestedPointer |
Returned type |
IView* |
"IView" |
"RenderWindow" |
Ogre::RenderWindow* |
IView* |
"IView" |
"SceneManager" |
Ogre::SceneManager* |
IView* |
"IView" |
"Camera" |
Ogre::Camera* |
IView* |
"IView" |
"RenderSystem" |
Ogre::RenderSystem* |
IView* |
"IView" |
"RootSceneNode" |
Ogre::RootSceneNode* |
Example:
POSNT p = NULL;
iTechnology->GetPointer(iView, "IView", "Camera", &p);
Ogre::Camera* cam = (Ogre::Camera*)p;
See OcctBridgeView::DoTest() in Ogre Bridge sample
HRESULT GetInterface(POSNT pointer, char* pointerType, char* interfaceName, IUnknown** interf)
Parameters
pointer - [in] Pointer to an object in the technology
pointerType - [in] Specifies (enumerates) type of the technology object
interfaceName - [in] Name of the KernelCAD interface to be obtained.
interf - [out,retval] The requested interface
- Remarks:
Returns the specified KernelCAD interface. The method provides reverse mapping of the technology to KernelCAD, where possible. pointer points to an object in the technology. Valid options for input and type of the retun are listed below:
OCCT Technology
pointer |
pointerType |
interfaceName |
Returned interf |
TopoDS_Shape* |
"TopoDS_Shape" |
"ISection" |
ISection* |
Ogre Technology
pointer |
pointerType |
interfaceName |
Returned interf |
SceneNode* |
"SceneNode" |
"ISection" |
ISection* |
SceneNode* |
"SceneNode" |
"IItem" |
IItem* |
Renderable* |
"Renderable" |
"ISection" |
ISection* |
Renderable* |
"Renderable" |
"IItem" |
IItem* |
HRESULT Execute(char* operation, __int64 param0, __int64 param1)
Parameters
operation,param0,param1 - [in] User-defined generic parameters. See remarks
- Remarks:
The method provides a way for the KernelCAD based application to call functionality implemented in the technology modules directly. KernelCAD passes the call to the technology object (see below) without any other action.
OCCT Technology
The call is passed to OcctDgBridge::ExecuteDg(const char* operation, __int64 param0, __int64 param1) method of the OcctDgBridge theOcctDgBridge; global object. The implementation of the method and definition of theOcctDgBridge are located in KernelCAD\ThirdParty\OCCT\src\TDocStd\OcctDgBridge.cxx added to ApplicationFramework\TKLCAF project of the KernelCAD\ThirdParty\OCCT\adm\msvc\vc12\OCCT.sln solution.
The default implementation of OcctDgBridge::ExecuteDg() is used only by the OCCT Bridge sample and can be safely replaced with any custom code
Ogre Technology
The call is passed to the Root::ExecuteDg(const String& operation, __int64 param0, __int64 param1) method of the Ogre::Root class in KernelCAD\ThirdParty\Ogre\ogre\ogremain\src\ogreroot.cpp
The default implementation of Root::ExecuteDg() is used only by the Ogre Bridge sample and can be safely replaced with any custom code
HRESULT SetTechnologyToAppCallback(bool(*func)(__int64 implementationObj, const char* operation, __int64 param0, __int64 param1), __int64 implementnObj)
Parameters
func - [in] Pointer to a callback function, implemented in KernelCAD based application
implementnObj - [in] Any pass through parameter. Its value will be passed as the first parameter to any func calls;
- Remarks:
The method provides a way for KernelCAD-based applications to receive calls from modified technology code. To use this functionality:
- Implement funct in your KernelCAD-based application
- Call this method on start of your application
- Call OcctDgBridge::ExecuteApplicationCallbackDg() (OCCT) or Root::ExecuteDg() (Ogre) (See remarks for the Execute method above) from your technology customisation code
The implementnObj parameter is provided for convenience. The suggested use is for identofication of the objects, which implements the callback in case a global function is not convenient. See the Bridge examples. It is not used by KernelCAD.
|