chore(include): changed include files from .h to .hpp
[KDIS.git] / include / KDIS / PDU / Synthetic_Environment / Gridded_Data_PDU.hpp
blob21517e97d7b955eea02f77faa71c8da3149afbc8
1 /*********************************************************************
2 Copyright 2013 Karl Jones
3 All rights reserved.
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
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.
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.
25 For Further Information Please Contact me at
26 Karljj1@yahoo.com
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 /********************************************************************
31 class: Gridded_Data_PDU
32 DIS: (6) 1278.1a - 1998
33 created: 06/10/2009
34 author: Karl Jones
36 purpose: Information about global, spatially varying environmental effects
37 shall be communicated using one or more Gridded Data PDUs.
39 size: 512 bits / 64 octets - Min size
40 *********************************************************************/
42 #pragma once
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>
55 namespace KDIS {
57 namespace DATA_TYPE {
59 // Some PDU specific data types.
60 typedef KDIS::UTILS::KRef_Ptr<GridAxisRegular> GridAxisDescriptor;
61 typedef KDIS::UTILS::KRef_Ptr<GridData> GridDataPtr;
63 } // END namespace DATA_TYPE
65 namespace PDU {
67 class KDIS_EXPORT Gridded_Data_PDU : public Header
69 protected:
71 KDIS::DATA_TYPE::EntityIdentifier m_EnvProcID;
73 KUINT16 m_ui16FieldNum;
75 KUINT16 m_ui16PDUNum;
77 KUINT16 m_ui16PDUTotal;
79 KUINT16 m_ui16CordSys;
81 KUINT8 m_ui8NumAxis;
83 KUINT8 m_ui8ConstGrid;
85 KDIS::DATA_TYPE::EnvironmentType m_EnvType;
87 KDIS::DATA_TYPE::EulerAngles m_Ori;
89 KUINT64 m_ui64SampleTime;
91 KUINT32 m_ui32TotalValues;
93 KUINT8 m_ui8VecDim;
95 KUINT16 m_ui16Padding1; // 24 bits unused for alignment of Grid Axis Descriptor
96 KUINT8 m_ui8Padding1;
98 std::vector<KDIS::DATA_TYPE::GridAxisDescriptor> m_vpGridAxisDesc;
100 std::vector<KDIS::DATA_TYPE::GridDataPtr> m_vGridData;
102 public:
104 static const KUINT16 GRIDDED_DATA_PDU_SIZE = 64; // Min size
106 Gridded_Data_PDU();
108 Gridded_Data_PDU( KDataStream & stream ) ;
110 Gridded_Data_PDU( const Header & H, KDataStream & stream ) ;
112 Gridded_Data_PDU( const KDIS::DATA_TYPE::EntityIdentifier & EnvironmentalProcessID, KUINT16 FieldNumber, KUINT16 PduNum,
113 KUINT16 PduTotal, KDIS::DATA_TYPE::ENUMS::CoordinateSystem CS, KDIS::DATA_TYPE::ENUMS::ConstantGrid CG,
114 const KDIS::DATA_TYPE::EnvironmentType & ET, const KDIS::DATA_TYPE::EulerAngles & Ori, KUINT64 SampleTime );
116 virtual ~Gridded_Data_PDU();
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();
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;
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 ) ;
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;
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;
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;
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;
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();
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();
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;
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;
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;
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;
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;
269 //************************************
270 // FullName: KDIS::PDU::Gridded_Data_PDU::GetAsString
271 // Description: Returns a string representation of the PDU.
272 //************************************
273 virtual KString GetAsString() const;
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 ) ;
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;
291 KBOOL operator == ( const Gridded_Data_PDU & Value ) const;
292 KBOOL operator != ( const Gridded_Data_PDU & Value ) const;
295 } // END namespace PDU
296 } // END namespace KDIS