MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
StreamContentMotion Class Reference

#include <socketstreammotionelem.h>

Inheritance diagram for StreamContentMotion:
Collaboration diagram for StreamContentMotion:

Public Member Functions

 StreamContentMotion (unsigned uFlags, std::vector< const StructNode * > &n, StreamContent::Modifier *pMod)
 
virtual ~StreamContentMotion (void)
 
void Prepare (void)
 
unsigned GetNumChannels (void) const
 
std::vector< const StructNode * >
::const_iterator 
nodes_begin (void) const
 
std::vector< const StructNode * >
::const_iterator 
nodes_end (void) const
 
const unsigned uGetFlags (void) const
 
- Public Member Functions inherited from StreamContent
 StreamContent (size_t size, Modifier *pMod)
 
virtual ~StreamContent (void)
 
void * GetBuf (void) const
 
int GetSize (void) const
 
const void * GetOutBuf (void) const
 
int GetOutSize (void) const
 

Protected Attributes

unsigned uFlags
 
std::vector< const StructNode * > nodes
 
- Protected Attributes inherited from StreamContent
std::vector< char > buf
 
Modifierm_pMod
 

Additional Inherited Members

- Public Types inherited from StreamContent
enum  Type { UNKNOWN = -1, VALUES = 0, MOTION = 1, LASTTYPE }
 

Detailed Description

Definition at line 43 of file socketstreammotionelem.h.

Constructor & Destructor Documentation

StreamContentMotion::StreamContentMotion ( unsigned  uFlags,
std::vector< const StructNode * > &  n,
StreamContent::Modifier pMod 
)

Definition at line 40 of file socketstreammotionelem.cc.

References ASSERT, StreamContent::buf, StreamContent::m_pMod, nodes, GeometryData::R, StreamContent::Modifier::Set(), GeometryData::V, GeometryData::W, and GeometryData::X.

43 : StreamContent(0, pMod), uFlags(uFlags), nodes(n)
44 {
45  /* FIXME: size depends on the type of the output signals */
46  ASSERT(uFlags != 0);
47  unsigned int size = 0;
48  if (uFlags & GeometryData::X) {
49  size += sizeof(doublereal)*3;
50  }
51  if (uFlags & GeometryData::R) {
52  size += sizeof(doublereal)*9;
53  }
54  if (uFlags & GeometryData::V) {
55  size += sizeof(doublereal)*3;
56  }
57  if (uFlags & GeometryData::W) {
58  size += sizeof(doublereal)*3;
59  }
60  size *= nodes.size();
61 
62  buf.resize(size);
63  memset(&buf[0], 0, size);
64  m_pMod->Set(size, &buf[0]);
65 }
std::vector< const StructNode * > nodes
virtual void Set(size_t size, const char *buf)=0
std::vector< char > buf
#define ASSERT(expression)
Definition: colamd.c:977
Modifier * m_pMod
double doublereal
Definition: colamd.c:52
StreamContent(size_t size, Modifier *pMod)

Here is the call graph for this function:

StreamContentMotion::~StreamContentMotion ( void  )
virtual

Definition at line 67 of file socketstreammotionelem.cc.

References NO_OP.

68 {
69  NO_OP;
70 }
#define NO_OP
Definition: myassert.h:74

Member Function Documentation

unsigned StreamContentMotion::GetNumChannels ( void  ) const
virtual

Implements StreamContent.

Definition at line 152 of file socketstreammotionelem.cc.

References StreamContent::buf.

153 {
154  return buf.size()/sizeof(doublereal);
155 }
std::vector< char > buf
double doublereal
Definition: colamd.c:52
std::vector< const StructNode * >::const_iterator StreamContentMotion::nodes_begin ( void  ) const

Definition at line 158 of file socketstreammotionelem.cc.

References nodes.

Referenced by WriteStreamContentLogOutput().

159 {
160  return nodes.begin();
161 }
std::vector< const StructNode * > nodes
std::vector< const StructNode * >::const_iterator StreamContentMotion::nodes_end ( void  ) const

Definition at line 164 of file socketstreammotionelem.cc.

References nodes.

Referenced by WriteStreamContentLogOutput().

165 {
166  return nodes.end();
167 }
std::vector< const StructNode * > nodes
void StreamContentMotion::Prepare ( void  )
virtual

Implements StreamContent.

Definition at line 73 of file socketstreammotionelem.cc.

References ASSERT, StreamContent::buf, StreamContent::m_pMod, StreamContent::Modifier::Modify(), nodes, GeometryData::R, R, GeometryData::RT, uFlags, GeometryData::V, GeometryData::W, and GeometryData::X.

74 {
75  char *curbuf = &buf[0];
76  for (unsigned int i = 0; i < nodes.size(); i++) {
77  /* assign value somewhere into mailbox buffer */
78  if (uFlags & GeometryData::X) {
79  const Vec3& X = nodes[i]->GetXCurr();
80 
81  doublereal *dbuf = (doublereal *)curbuf;
82  dbuf[0] = X(1);
83  dbuf[1] = X(2);
84  dbuf[2] = X(3);
85 
86  curbuf += 3*sizeof(doublereal);
87  }
88 
89  if (uFlags & GeometryData::R) {
90  const Mat3x3& R = nodes[i]->GetRCurr();
91 
92  doublereal *dbuf = (doublereal *)curbuf;
93  dbuf[0] = R(1, 1);
94  dbuf[1] = R(1, 2);
95  dbuf[2] = R(1, 3);
96  dbuf[3] = R(2, 1);
97  dbuf[4] = R(2, 2);
98  dbuf[5] = R(2, 3);
99  dbuf[6] = R(3, 1);
100  dbuf[7] = R(3, 2);
101  dbuf[8] = R(3, 3);
102 
103  curbuf += 9*sizeof(doublereal);
104  }
105 
106  if (uFlags & GeometryData::RT) {
107  const Mat3x3& R = nodes[i]->GetRCurr();
108 
109  doublereal *dbuf = (doublereal *)curbuf;
110  dbuf[0] = R(1, 1);
111  dbuf[1] = R(2, 1);
112  dbuf[2] = R(3, 1);
113  dbuf[3] = R(1, 2);
114  dbuf[4] = R(2, 2);
115  dbuf[5] = R(3, 2);
116  dbuf[6] = R(1, 3);
117  dbuf[7] = R(2, 3);
118  dbuf[8] = R(3, 3);
119 
120  curbuf += 9*sizeof(doublereal);
121  }
122 
123  if (uFlags & GeometryData::V) {
124  const Vec3& V = nodes[i]->GetVCurr();
125 
126  doublereal *dbuf = (doublereal *)curbuf;
127  dbuf[0] = V(1);
128  dbuf[1] = V(2);
129  dbuf[2] = V(3);
130 
131  curbuf += 3*sizeof(doublereal);
132  }
133 
134  if (uFlags & GeometryData::W) {
135  const Vec3& W = nodes[i]->GetWCurr();
136 
137  doublereal *dbuf = (doublereal *)curbuf;
138  dbuf[0] = W(1);
139  dbuf[1] = W(2);
140  dbuf[2] = W(3);
141 
142  curbuf += 3*sizeof(doublereal);
143  }
144  }
145 
146  m_pMod->Modify();
147 
148  ASSERT(curbuf == &buf[buf.size()]);
149 }
virtual void Modify(void)=0
Definition: matvec3.h:98
std::vector< const StructNode * > nodes
std::vector< char > buf
#define ASSERT(expression)
Definition: colamd.c:977
Modifier * m_pMod
double doublereal
Definition: colamd.c:52
Mat3x3 R

Here is the call graph for this function:

const unsigned StreamContentMotion::uGetFlags ( void  ) const

Definition at line 170 of file socketstreammotionelem.cc.

References uFlags.

Referenced by WriteStreamContentLogOutput().

171 {
172  return uFlags;
173 }

Member Data Documentation

std::vector<const StructNode *> StreamContentMotion::nodes
protected

Definition at line 46 of file socketstreammotionelem.h.

Referenced by nodes_begin(), nodes_end(), Prepare(), and StreamContentMotion().

unsigned StreamContentMotion::uFlags
protected

Definition at line 45 of file socketstreammotionelem.h.

Referenced by Prepare(), and uGetFlags().


The documentation for this class was generated from the following files: