KDIS  2-8-x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Gridded_Data_PDU.h
Go to the documentation of this file.
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 
8 1. Redistributions of source code must retain the above copyright notice, this
9  list of conditions and the following disclaimer.
10 2. Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
29 
30 /********************************************************************
31  class: Gridded_Data_PDU
32  DIS: (6) 1278.1a - 1998
33  created: 06/10/2009
34  author: Karl Jones
35 
36  purpose: Information about global, spatially varying environmental effects
37  shall be communicated using one or more Gridded Data PDUs.
38 
39  size: 512 bits / 64 octets - Min size
40 *********************************************************************/
41 
42 #pragma once
43 
44 #include "./../Header.h"
45 #include "./../../DataTypes/EntityIdentifier.h"
46 #include "./../../DataTypes/EnvironmentType.h"
47 #include "./../../DataTypes/EulerAngles.h"
48 #include "./../../DataTypes/GridAxisIrregular.h"
49 #include "./../../DataTypes/GridDataType0.h"
50 #include "./../../DataTypes/GridDataType1.h"
51 #include "./../../DataTypes/GridDataType2.h"
52 #include "./../../Extras/KRef_Ptr.h"
53 #include <vector>
54 
55 namespace KDIS {
56 
57 namespace DATA_TYPE {
58 
59 // Some PDU specific data types.
62 
63 } // END namespace DATA_TYPE
64 
65 namespace PDU {
66 
68 {
69 protected:
70 
72 
74 
76 
78 
80 
82 
84 
86 
88 
90 
92 
94 
95  KUINT16 m_ui16Padding1; // 24 bits unused for alignment of Grid Axis Descriptor
97 
98  std::vector<KDIS::DATA_TYPE::GridAxisDescriptor> m_vpGridAxisDesc;
99 
100  std::vector<KDIS::DATA_TYPE::GridDataPtr> m_vGridData;
101 
102 public:
103 
104  static const KUINT16 GRIDDED_DATA_PDU_SIZE = 64; // Min size
105 
107 
108  Gridded_Data_PDU( KDataStream & stream ) throw( KException );
109 
110  Gridded_Data_PDU( const Header & H, KDataStream & stream ) throw( KException );
111 
112  Gridded_Data_PDU( const KDIS::DATA_TYPE::EntityIdentifier & EnvironmentalProcessID, KUINT16 FieldNumber, KUINT16 PduNum,
114  const KDIS::DATA_TYPE::EnvironmentType & ET, const KDIS::DATA_TYPE::EulerAngles & Ori, KUINT64 SampleTime );
115 
116  virtual ~Gridded_Data_PDU();
117 
118  //************************************
119  // FullName: KDIS::PDU::Gridded_Data_PDU::SetEnvironmentalProcessID
120  // KDIS::PDU::Gridded_Data_PDU::GetEnvironmentalProcessID
121  //!Description: Identifies the environmental simulation application issuing the PDU.
122  //! This field is also known as "Environmental Simulation ID" in DIS version 7.
123  // Parameter: const EntityIdentifier & ID
124  //************************************
125  void SetEnvironmentalProcessID( const KDIS::DATA_TYPE::EntityIdentifier & ID );
126  const KDIS::DATA_TYPE::EntityIdentifier & GetEnvironmentalProcessID() const;
127  KDIS::DATA_TYPE::EntityIdentifier & GetEnvironmentalProcessID();
128 
129  //************************************
130  // FullName: KDIS::PDU::Gridded_Data_PDU::SetFieldNumber
131  // KDIS::PDU::Gridded_Data_PDU::GetFieldNumber
132  //!Description: Specifies a unique identifier for each environmental variable transmitted
133  //! during an exercise.
134  // Parameter: KUINT16 FN
135  //************************************
136  void SetFieldNumber( KUINT16 FN );
137  KUINT16 GetFieldNumber() const;
138 
139  //************************************
140  // FullName: KDIS::PDU::Gridded_Data_PDU::SetPDUNumber
141  // KDIS::PDU::Gridded_Data_PDU::GetPDUNumber
142  //!Description: Specifies an index number of the current PDU within the total number
143  //! of PDUs used to transmit the environmental data.
144  //! SetPDUNumberAndTotal will throw an exception if Num is greater than Total.
145  //! No error checking is done if you use the 2 separate accessors SetPDUNumber
146  //! and SetPDUTotal so be careful not to make the PDU number greater than the total.
147  // Parameter: KUINT16 PN
148  //************************************
149  void SetPDUNumber( KUINT16 PN );
150  KUINT16 GetPDUNumber() const;
151  void SetPDUNumberAndTotal( KUINT16 Num, KUINT16 Total ) throw( KException );
152 
153  //************************************
154  // FullName: KDIS::PDU::Gridded_Data_PDU::SetPDUTotal
155  // KDIS::PDU::Gridded_Data_PDU::GetPDUTotal
156  //!Description: Specifies the total number of PDUs used to transmit this environmental data.
157  //! This value should not be less than PDU number.
158  // Parameter: KUINT16 PT
159  //************************************
160  void SetPDUTotal( KUINT16 PT );
161  KUINT16 GetPDUTotal() const;
162 
163  //************************************
164  // FullName: KDIS::PDU::Gridded_Data_PDU::SetCoordinateSystem
165  // KDIS::PDU::Gridded_Data_PDU::GetCoordinateSystem
166  //!Description: Specifies the coordinate system of the grid for the environmental
167  //! data contained in the Gridded Data PDU.
168  // Parameter: CoordinateSystem CS
169  //************************************
170  void SetCoordinateSystem( KDIS::DATA_TYPE::ENUMS::CoordinateSystem CS );
171  KDIS::DATA_TYPE::ENUMS::CoordinateSystem GetCoordinateSystem() const;
172 
173  //************************************
174  // FullName: KDIS::PDU::Gridded_Data_PDU::Decode
175  //!Description: Number of grid axis in the PDU.
176  //! e.g. three grid axes for an x, y, z coordinate system.
177  //************************************
178  KUINT8 GetNumberAxis() const;
179 
180  //************************************
181  // FullName: KDIS::PDU::Gridded_Data_PDU::SetConstantGrid
182  // KDIS::PDU::Gridded_Data_PDU::GetConstantGrid
183  //!Description: Specifies whether the domain grid axes are identical to those of the previous
184  //! domain update grid for the environmental data sample contained in the PDU
185  // Parameter: ConstantGrid CG
186  //************************************
187  void SetConstantGrid( KDIS::DATA_TYPE::ENUMS::ConstantGrid CG );
188  KDIS::DATA_TYPE::ENUMS::ConstantGrid GetConstantGrid() const;
189 
190  //************************************
191  // FullName: KDIS::PDU::Gridded_Data_PDU::SetEnvironmentType
192  // KDIS::PDU::Gridded_Data_PDU::GetEnvironmentType
193  //!Description: DIS enumeration identifying the type of environmental effect being described.
194  // Parameter: const EnvironmentType & ET
195  //************************************
196  void SetEnvironmentType( const KDIS::DATA_TYPE::EnvironmentType & ET );
197  const KDIS::DATA_TYPE::EnvironmentType & GetEnvironmentType() const;
198  KDIS::DATA_TYPE::EnvironmentType & GetEnvironmentType();
199 
200  //************************************
201  // FullName: KDIS::PDU::Gridded_Data_PDU::SetOrientation
202  // KDIS::PDU::Gridded_Data_PDU::GetOrientation
203  //!Description: Specifies the orientation of the data grid.
204  // Parameter: const EulerAngles & O
205  //************************************
206  void SetOrientation( const KDIS::DATA_TYPE::EulerAngles & O );
207  const KDIS::DATA_TYPE::EulerAngles & GetOrientation() const;
208  KDIS::DATA_TYPE::EulerAngles & GetOrientation();
209 
210  //************************************
211  // FullName: KDIS::PDU::Gridded_Data_PDU::SetSampleTime
212  // KDIS::PDU::Gridded_Data_PDU::GetSampleTime
213  //!Description: Specifies the valid time of the environmental data sample contained in the PDU.
214  // Parameter: KUINT64 ST
215  //************************************
216  void SetSampleTime( KUINT64 ST );
217  KUINT64 GetSampleTime() const;
218 
219  //************************************
220  // FullName: KDIS::PDU::Gridded_Data_PDU::SetTotalValues
221  // KDIS::PDU::Gridded_Data_PDU::GetTotalValues
222  //!Description: Specifies the total number of data values for all PDUs for an environmental
223  //! sample. This total includes vector-valued environmental data and equals the
224  //! product of the vector dimension and the total number of grid points.
225  // Parameter: KUINT32 TV
226  //************************************
227  void SetTotalValues( KUINT32 TV );
228  KUINT32 GetTotalValues() const;
229 
230  //************************************
231  // FullName: KDIS::PDU::Gridded_Data_PDU::SetVectorDimension
232  // KDIS::PDU::Gridded_Data_PDU::GetVectorDimension
233  //!Description: This field shall specify the total number of data values at each grid point and
234  //! accommodates scalar or vector-valued environmental data.
235  //! Vector Dimension shall be one for scalar data, and shall be greater than one when
236  //! multiple enumerated environmental data values are sent for each grid location
237  //! (e.g., u, v, w wind components have V = 3). (I.E Number of GridData values).
238  // Parameter: KUINT8 VD
239  //************************************
240  void SetVectorDimension( KUINT8 VD );
241  KUINT8 GetVectorDimension() const;
242 
243  //************************************
244  // FullName: KDIS::PDU::Gridded_Data_PDU::AddGridAxisDescriptor
245  // KDIS::PDU::Gridded_Data_PDU::SetGridAxisDescriptors
246  // KDIS::PDU::Gridded_Data_PDU::GetSetGridAxisDescriptors
247  //!Description: Specifies the detailed information about the grid dimensions (axes)
248  //! and coordinates for environmental state variables.
249  //! More than one Grid Data record is allowed in a single Gridded Data PDU
250  //! corresponding to each enumerated sample type.
251  // Parameter: const GridAxisDescriptor & GAD, const vector<GridAxisDescriptor> & GADS
252  //************************************
253  void AddGridAxisDescriptor( const KDIS::DATA_TYPE::GridAxisDescriptor & GAD );
254  void SetGridAxisDescriptors( const std::vector<KDIS::DATA_TYPE::GridAxisDescriptor> & GADS );
255  const std::vector<KDIS::DATA_TYPE::GridAxisDescriptor> & GetSetGridAxisDescriptors() const;
256 
257  //************************************
258  // FullName: KDIS::PDU::Gridded_Data_PDU::AddGridData
259  // KDIS::PDU::Gridded_Data_PDU::SetGridData
260  // KDIS::PDU::Gridded_Data_PDU::GetGridData
261  //!Description: Specifies the environmental state data at the grid locations specified by
262  //! parameters in the Grid Axis Descriptor record.
263  // Parameter: const GridDataPtr & GD, const vector<GridDataPtr> & GD
264  //************************************
265  void AddGridData( const KDIS::DATA_TYPE::GridDataPtr & GD );
266  void SetGridData( const std::vector<KDIS::DATA_TYPE::GridDataPtr> & GD );
267  const std::vector<KDIS::DATA_TYPE::GridDataPtr> & GetGridData() const;
268 
269  //************************************
270  // FullName: KDIS::PDU::Gridded_Data_PDU::GetAsString
271  //!Description: Returns a string representation of the PDU.
272  //************************************
273  virtual KString GetAsString() const;
274 
275  //************************************
276  // FullName: KDIS::PDU::Gridded_Data_PDU::Decode
277  //!Description: Convert From Network Data.
278  // Parameter: KDataStream & stream
279  // Parameter: bool ignoreHeader = false - Decode the header from the stream?
280  //************************************
281  virtual void Decode( KDataStream & stream, bool ignoreHeader = false ) throw( KException );
282 
283  //************************************
284  // FullName: KDIS::PDU::Gridded_Data_PDU::Encode
285  //!Description: Convert To Network Data.
286  // Parameter: KDataStream & stream
287  //************************************
288  virtual KDataStream Encode() const;
289  virtual void Encode( KDataStream & stream ) const;
290 
291  KBOOL operator == ( const Gridded_Data_PDU & Value ) const;
292  KBOOL operator != ( const Gridded_Data_PDU & Value ) const;
293 };
294 
295 } // END namespace PDU
296 } // END namespace KDIS
KDIS::DATA_TYPE::EulerAngles m_Ori
Definition: Gridded_Data_PDU.h:87
unsigned int KUINT32
Definition: KDefines.h:103
KUINT16 m_ui16Padding1
Definition: Gridded_Data_PDU.h:95
KUINT8 m_ui8NumAxis
Definition: Gridded_Data_PDU.h:81
KDIS::UTILS::KRef_Ptr< GridData > GridDataPtr
Definition: Gridded_Data_PDU.h:61
Definition: Gridded_Data_PDU.h:67
KUINT16 m_ui16FieldNum
Definition: Gridded_Data_PDU.h:73
unsigned short int KUINT16
Definition: KDefines.h:101
KUINT8 m_ui8Padding1
Definition: Gridded_Data_PDU.h:96
ConstantGrid
Definition: EnumSyntheticEnviroment.h:135
KUINT16 m_ui16PDUNum
Definition: Gridded_Data_PDU.h:75
Definition: EnvironmentType.h:46
std::vector< KDIS::DATA_TYPE::GridDataPtr > m_vGridData
Definition: Gridded_Data_PDU.h:100
KDIS::UTILS::KRef_Ptr< GridAxisRegular > GridAxisDescriptor
Definition: Gridded_Data_PDU.h:60
Definition: KDefines.h:182
Definition: KDataStream.h:48
unsigned long long KUINT64
Definition: KDefines.h:105
bool KBOOL
Definition: KDefines.h:119
KUINT32 m_ui32TotalValues
Definition: Gridded_Data_PDU.h:91
Definition: EulerAngles.h:46
std::vector< KDIS::DATA_TYPE::GridAxisDescriptor > m_vpGridAxisDesc
Definition: Gridded_Data_PDU.h:98
CoordinateSystem
Definition: EnumSyntheticEnviroment.h:113
std::string KString
Definition: KDefines.h:116
KUINT8 m_ui8ConstGrid
Definition: Gridded_Data_PDU.h:83
KUINT16 m_ui16PDUTotal
Definition: Gridded_Data_PDU.h:77
KDIS::DATA_TYPE::EntityIdentifier m_EnvProcID
Definition: Gridded_Data_PDU.h:71
Definition: EntityIdentifier.h:49
KDIS::DATA_TYPE::EnvironmentType m_EnvType
Definition: Gridded_Data_PDU.h:85
KUINT8 m_ui8VecDim
Definition: Gridded_Data_PDU.h:93
Definition: Header7.h:142
unsigned char KUINT8
Definition: KDefines.h:99
KUINT16 m_ui16CordSys
Definition: Gridded_Data_PDU.h:79
KUINT64 m_ui64SampleTime
Definition: Gridded_Data_PDU.h:89
#define KDIS_EXPORT
Definition: KDefines.h:82
Definition: KRef_Ptr.h:73