Memosa-FVM  0.2
VectorArrayWriter< T, N > Class Template Reference

#include <ArrayWriter.h>

Inheritance diagram for VectorArrayWriter< T, N >:
Collaboration diagram for VectorArrayWriter< T, N >:

Public Types

typedef Vector< T, N > ElementType
 
typedef Array< ElementTypeArrayType
 
typedef NumTypeTraits< T >
::T_BuiltIn 
T_BuiltIn
 
typedef NumTypeTraits< T >
::T_Scalar 
T_Scalar
 

Public Member Functions

 VectorArrayWriter (const bool binary, const int vectorComponent, const int atypeComponent)
 
virtual void write (FILE *fp, const ArrayType &array, const int iBeg, int count, const Array< bool > *mask=0)
 
- Public Member Functions inherited from ArrayWriter
 ArrayWriter (const bool binary, const int vectorComponent, const int atypeComponent)
 
virtual ~ArrayWriter ()
 
template<class T >
void writeFloats (FILE *fp, const T *data, const int count, const int stride, const Array< bool > *mask=0)
 

Additional Inherited Members

- Protected Attributes inherited from ArrayWriter
const bool _binary
 
const int _vectorComponent
 
const int _atypeComponent
 

Detailed Description

template<class T, int N>
class VectorArrayWriter< T, N >

Definition at line 92 of file ArrayWriter.h.

Member Typedef Documentation

template<class T, int N>
typedef Array<ElementType> VectorArrayWriter< T, N >::ArrayType

Definition at line 96 of file ArrayWriter.h.

template<class T, int N>
typedef Vector<T,N> VectorArrayWriter< T, N >::ElementType

Definition at line 95 of file ArrayWriter.h.

template<class T, int N>
typedef NumTypeTraits<T>::T_BuiltIn VectorArrayWriter< T, N >::T_BuiltIn

Definition at line 97 of file ArrayWriter.h.

template<class T, int N>
typedef NumTypeTraits<T>::T_Scalar VectorArrayWriter< T, N >::T_Scalar

Definition at line 98 of file ArrayWriter.h.

Constructor & Destructor Documentation

template<class T, int N>
VectorArrayWriter< T, N >::VectorArrayWriter ( const bool  binary,
const int  vectorComponent,
const int  atypeComponent 
)
inline

Definition at line 100 of file ArrayWriter.h.

101  :
102  ArrayWriter(binary,vectorComponent,atypeComponent)
103  {}
ArrayWriter(const bool binary, const int vectorComponent, const int atypeComponent)
Definition: ArrayWriter.h:15

Member Function Documentation

template<class T, int N>
virtual void VectorArrayWriter< T, N >::write ( FILE *  fp,
const ArrayType array,
const int  iBeg,
int  count,
const Array< bool > *  mask = 0 
)
inlinevirtual

Definition at line 105 of file ArrayWriter.h.

References ArrayWriter::_atypeComponent, ArrayWriter::_vectorComponent, Array< T >::getData(), Array< T >::getLength(), and ArrayWriter::writeFloats().

Referenced by FluentDataExporter< T >::writeVectorField().

108  {
109  const int length = array.getLength();
110  if (count == -1)
111  count = length;
112  else if (count+iBeg > length)
113  throw CException("invalid count ");
114 
115 
116  ElementType *dataArray = (ElementType*)(array.getData());
117  T_Scalar *dataScalar = (T_Scalar*)(dataArray+iBeg);
118 
119  int stride = 1;
120 
121  if (_vectorComponent == -2)
122  {
123  T_BuiltIn *data = (T_BuiltIn*)(dataScalar);
124 
125  // write all components in coupled order
126 
127 #ifdef USING_ATYPE_TANGENT
128  if ((_atypeComponent == 0) || (_atypeComponent == 1))
129  {
130  data += _atypeComponent;
131  stride = 2;
132  }
133  else
134  throw CException("invalid component for Tangent");
135 #endif
136  if (mask)
137  throw CException("masked write not implemented");
138  writeFloats(fp,data,count*N,stride,0);
139  }
140  else
141  {
142  // write all components in sequential order
143  int ndBeg=0;
144  int ndEnd=N;
145 
146  if (_vectorComponent >= 0 && _vectorComponent <N)
147  {
148  // restrict to just one component
149  ndBeg=_vectorComponent;
150  ndEnd=ndBeg+1;
151  }
152  else if (_vectorComponent != -1)
153  {
154  throw CException("invalid vector component");
155  }
156 
157  stride = N;
158 
159  for(int nd=ndBeg; nd<ndEnd; nd++)
160  {
161  T_BuiltIn *nddata = (T_BuiltIn*) (dataScalar+nd);
162 
163 #ifdef USING_ATYPE_TANGENT
164  if ((_atypeComponent == 0) || (_atypeComponent == 1))
165  {
166  nddata += _atypeComponent;
167  stride = N*2;
168  }
169  else
170  throw CException("invalid component for Tangent");
171 #endif
172  writeFloats(fp,nddata,count,stride,mask);
173  }
174  }
175  }
Vector< T, N > ElementType
Definition: ArrayWriter.h:95
void writeFloats(FILE *fp, const T *data, const int count, const int stride, const Array< bool > *mask=0)
Definition: ArrayWriter.h:25
const int _atypeComponent
Definition: ArrayWriter.h:44
NumTypeTraits< T >::T_Scalar T_Scalar
Definition: ArrayWriter.h:98
const int _vectorComponent
Definition: ArrayWriter.h:43
NumTypeTraits< T >::T_BuiltIn T_BuiltIn
Definition: ArrayWriter.h:97

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