1 //#***************************************************************************************
2 //# filename:     ElementsAndModelsLibraryInterface.h
3 //#
4 //# author:				Johannes Gerstmayr, Yuri Vetyukov
5 //#
6 //# generated:
7 //# description:
8 //#
9 //# comments:
10 //#
11 //# Copyright (c) 2003-2013 Johannes Gerstmayr, Linz Center of Mechatronics GmbH, Austrian
12 //# Center of Competence in Mechatronics GmbH, Institute of Technical Mechanics at the
13 //# Johannes Kepler Universitaet Linz, Austria. All rights reserved.
14 //#
15 //# This file is part of HotInt.
16 //# HotInt is free software: you can redistribute it and/or modify it under the terms of
17 //# the HOTINT license. See folder 'licenses' for more details.
18 //#
19 //# bug reports are welcome!!!
20 //# WWW:		www.hotint.org
21 //# email:	bug_reports@hotint.org or support@hotint.org
22 //#***************************************************************************************
23 
24 #pragma once
25 
26 #include "mbs_interface.h"
27 
28 // instances of the objects (object factory and models library)
29 // are created and destroyed within the dll automatically
30 // when the dll is loaded/unloaded
31 
32 #define ELEMENTS_AND_MODELS_DLL_NAME "MBSElementsAndModels.dll"
33 #define OBJECT_FACTORY_ACCESS_FUNCTION_NAME "GetObjectFactory"		// no arguments
34 #define MODELS_LIBRARY_ACCESS_FUNCTION_NAME "GetModelsLibrary"		// no arguments
35 
36 // manages, creates and adds to MBS different classes of objects:
37 // Elements
38 // Sensors
39 // Nodes
40 // Loads
41 // Materials
42 // GeomElements
43 // within each class different types may be available
44 // types are identified by int type_id
45 // classes are defined by
46 
47 enum MBSObjectFactoryClass
48 {
49 	OFCElement = 1,
50 	OFCSensor,
51 	OFCNode,
52 	OFCLoad,
53 	OFCMaterial,
54 	OFCBeamProperties, //$ DR+PG 2013-01-21
55 	OFCGeomElement,
56 	OFCMaxVal	// DR: do not delete, always has to be the last entry! If you want to add new object classes, do it before (!) this entry!
57 };
58 
59 typedef enum {TAEBody = 1, TAEflexible=2, TAEconstraint=4, TAE2D = 8, TAEspecial_connector=16, TAEinput_output = 32, TAENotInRelease=64,TAE1D = 128} TAddElementType;
60 //$ DR 2013-01-21: added TAENotInRelease
61 //$ DR 2013-06-19: added TAE1D
62 
63 struct MBSObjectFactoryInterface
64 {
65 	// these functions add objects of a given class and type to mbs
66 	// the number in the corresponding array in mbs (numerical identificator) is returned
67 	// or -1 if no object could be added
68 	virtual int AddObject(MBSObjectFactoryClass objectClass, int objectTypeId) = 0;
69 	// available range types: maximal value of objectType for a given class
70 	virtual int GetAvailableTypesCount(MBSObjectFactoryClass objectClass) = 0;
71 	// name of an object type id and object type id for a given name (if exists, otherwise -1)
72 	virtual const mystr & GetTypeName(MBSObjectFactoryClass objectClass, int objectTypeId) = 0;
73 	virtual int GetObjectTypeId(MBSObjectFactoryClass objectClass, const mystr & typeName) = 0;
74 	// description for the documentation and for the user interface
75 	virtual const mystr & GetTypeDescription(MBSObjectFactoryClass objectClass, int objectTypeId) = 0;
76 	// flags - characteristic properties of the type (e.g. constraint or not, 2D/3D for elements)
77 	virtual int GetTypeFlags(MBSObjectFactoryClass objectClass, int objectTypeId) = 0;
78 	// example of the type in skript language
79 	virtual mystr GetTypeExample(MBSObjectFactoryClass objectClass, int objectTypeId) = 0;
80 	// if this function returns 1, then all experimental elements and menus, etc. are removed from Hotint
81 	virtual int ExcludeExperimentalObjects() = 0;
82 
83 	// an object factory needs mbs to be able to create objects and to add them to the collections
84 	virtual void SetMBS(MBS * mbs) = 0;
85 };
86 
87 // manages models
88 struct MBSModelsLibraryInterface
89 {
90 	struct MBSModelInterface
91 	{
~MBSModelInterfaceMBSModelsLibraryInterface::MBSModelInterface92 		virtual ~MBSModelInterface() {}
93 		virtual mystr & GetMBSModelName() = 0;
94 		virtual mystr & GetMBSModelDescription() = 0;
95 		virtual int CreateMBSModel(MBS * mbs) = 0;
96 		// the two functions below need to be overridden in case the model can re-initialize itself with different model data
HasMBSModelInitDataMBSModelsLibraryInterface::MBSModelInterface97 		virtual bool HasMBSModelInitData() { return false; }
InitializeMBSModelDataMBSModelsLibraryInterface::MBSModelInterface98 		virtual int InitializeMBSModelData(MBS * mbs) { return 0; }
99 	};
100 	virtual int GetModelsCount() = 0;
101 	virtual MBSModelInterface * GetModelInterface(int nModel) = 0;		// 1-based: nModel = 1 .. GetModelsCount()
102 
103 	// global variables need to be shared with the kernel module;
104 	// here the pointers to them are set from the kernel to the client module
105 	virtual void SetGlobalVariablesPointers(
106 		UserOutputInterface * global_uo_kernel,
107 		TArray<double> * ptrTMtspent_kernel,
108 		TArray<double> * ptrTMtstart_kernel
109 		) = 0;
110 #ifdef gencnt
111 	virtual void SetGlobalVariablesPointers(
112 		UserOutputInterface * global_uo_kernel,
113 		TArray<double> * ptrTMtspent_kernel,
114 		TArray<double> * ptrTMtstart_kernel,
115 		int *global_genvec,
116 		int *global_genmat
117 		) = 0;
118 #endif
119 };