Marine systems simulation
CVisualDB.h
1/*
2* Class CVisualDB (SimObject)
3* Author: Biao Su
4
5* This class enables visualization of a deformable body with triangular mesh.
6*/
7
12#ifndef CVisualDB_H
13#define CVisualDB_H
14
15#include <string>
16#include <Eigen/Eigen>
17#include <iostream>
18#include <iomanip>
19#include <fstream>
20#include <algorithm>
21#include <vector>
22#include <valarray>
23
24#include "SimObject.h"
25
26#include "sfh/text.h"
27#include "sfh/math/math.h"
28#include "sfh/sim/kinematics.h"
29#include "sfh/constants.h"
30
31#ifdef FH_VISUALIZATION
32#include "sfh/ogre/C3DLine.h"
33#endif
34
35namespace Visualization {
36
37typedef Eigen::Matrix<double, 3, 1> vec3;
38typedef Eigen::Matrix<int, 3, 1> vec3i;
39typedef Eigen::Matrix<int, 2, 1> vec2i;
40typedef Eigen::Quaternion<double> quat;
41
42class CVisualDB : public SimObject
43{
44public:
45 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
46
47 // Constructor
48 CVisualDB(std::string sSimObjectName, ISimObjectCreator* pCreator);
49 virtual ~CVisualDB();
51 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot, const bool bIsMajorTimeStep) {};
52
53#ifdef FH_VISUALIZATION
54 // Initial specification of the simObject geometry for rendering.
55 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const pCreator);
56
57 // Updating the simObject for rendering the next frame.
58 virtual void RenderUpdate(const double dT, const double* const adX);
59#endif
60
61protected:
62 // Node
63 int m_NodeNum;
64 std::vector<vec3> m_NodePos;
65
66 // Input ports
67 ISignalPort** m_InPos;
68
69#ifdef FH_VISUALIZATION
70 Ogre::SceneNode* m_RenderNode;
71 Ogre::SceneManager* m_SceneMgr;
72 Ogre::ManualObject* m_Manual;
73 int m_RenderType;
74 string m_Material;
75 double m_Color[4];
76 C3DLine* m_Line;
77 std::vector<vec2i> m_LineIndex;
78 std::vector<vec3i> m_TriIndex;
79#endif
80
81};
82
83};
84
85#endif
Definition: CVisualDB.h:43
virtual void OdeFcn(const double dT, const double *const adX, double *const adXDot, const bool bIsMajorTimeStep)
Calculate the state derivatives.
Definition: CVisualDB.h:51