1 /*********************************************************************
2 Copyright 2013 Karl Jones
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
27 http://p.sf.net/kdis/UserGuide
28 *********************************************************************/
30 #include "./LinearSegmentParameter.h"
33 using namespace DATA_TYPE
;
34 using namespace UTILS
;
36 //////////////////////////////////////////////////////////////////////////
38 //////////////////////////////////////////////////////////////////////////
40 LinearSegmentParameter::LinearSegmentParameter() :
48 m_ModificationUnion
.m_ui8Modifications
= 0;
51 //////////////////////////////////////////////////////////////////////////
53 LinearSegmentParameter::LinearSegmentParameter( KDataStream
& stream
)
58 //////////////////////////////////////////////////////////////////////////
60 LinearSegmentParameter::LinearSegmentParameter( KUINT8 SegNum
, KUINT8 Mod
, const LinearObjectAppearance
& A
,
61 const WorldCoordinates
& Loc
, const EulerAngles
& Ori
,
62 KUINT16 Length
, KUINT16 Width
, KUINT16 Height
, KUINT16 Depth
) :
63 m_ui8SegNum( SegNum
),
67 m_ui16Length( Length
),
69 m_ui16Height( Height
),
73 m_ModificationUnion
.m_ui8Modifications
= Mod
;
76 //////////////////////////////////////////////////////////////////////////
78 LinearSegmentParameter::~LinearSegmentParameter()
82 //////////////////////////////////////////////////////////////////////////
84 void LinearSegmentParameter::SetSegmentNumber( KUINT8 N
)
89 //////////////////////////////////////////////////////////////////////////
91 KUINT8
LinearSegmentParameter::GetSegmentNumber() const
96 //////////////////////////////////////////////////////////////////////////
98 void LinearSegmentParameter::SetModification( KUINT8 M
)
100 m_ModificationUnion
.m_ui8Modifications
= M
;
103 //////////////////////////////////////////////////////////////////////////
105 KUINT8
LinearSegmentParameter::GetModification() const
107 return m_ModificationUnion
.m_ui8Modifications
;
110 //////////////////////////////////////////////////////////////////////////
112 void LinearSegmentParameter::SetModificationLocation( KBOOL M
/*= true*/ )
114 m_ModificationUnion
.m_ui8LocBit
= M
;
117 //////////////////////////////////////////////////////////////////////////
119 KBOOL
LinearSegmentParameter::IsModificationLocation() const
121 return m_ModificationUnion
.m_ui8LocBit
;
124 //////////////////////////////////////////////////////////////////////////
126 void LinearSegmentParameter::SetModificationOrientation( KBOOL M
/*= true*/ )
128 m_ModificationUnion
.m_ui8OriBit
= M
;
131 //////////////////////////////////////////////////////////////////////////
133 KBOOL
LinearSegmentParameter::IsModificationOrientation() const
135 return m_ModificationUnion
.m_ui8OriBit
;
138 //////////////////////////////////////////////////////////////////////////
140 void LinearSegmentParameter::SetLinearObjectAppearance( const LinearObjectAppearance
& L
)
145 //////////////////////////////////////////////////////////////////////////
147 const LinearObjectAppearance
& LinearSegmentParameter::GetLinearObjectAppearance() const
152 //////////////////////////////////////////////////////////////////////////
154 LinearObjectAppearance
& LinearSegmentParameter::GetLinearObjectAppearance()
159 //////////////////////////////////////////////////////////////////////////
161 void LinearSegmentParameter::SetLocation( const WorldCoordinates
& L
)
166 //////////////////////////////////////////////////////////////////////////
168 const WorldCoordinates
& LinearSegmentParameter::GetLocation() const
173 //////////////////////////////////////////////////////////////////////////
175 WorldCoordinates
& LinearSegmentParameter::GetLocation()
180 //////////////////////////////////////////////////////////////////////////
182 void LinearSegmentParameter::SetOrientation( const EulerAngles
& O
)
187 //////////////////////////////////////////////////////////////////////////
189 const EulerAngles
& LinearSegmentParameter::GetOrientation() const
194 //////////////////////////////////////////////////////////////////////////
196 EulerAngles
& LinearSegmentParameter::GetOrientation()
201 //////////////////////////////////////////////////////////////////////////
203 void LinearSegmentParameter::SetLength( KUINT16 L
)
208 //////////////////////////////////////////////////////////////////////////
210 KUINT16
LinearSegmentParameter::GetLength() const
215 //////////////////////////////////////////////////////////////////////////
217 void LinearSegmentParameter::SetWidth( KUINT16 W
)
222 //////////////////////////////////////////////////////////////////////////
224 KUINT16
LinearSegmentParameter::GetWidth() const
229 //////////////////////////////////////////////////////////////////////////
231 void LinearSegmentParameter::SetHeight( KUINT16 H
)
236 //////////////////////////////////////////////////////////////////////////
238 KUINT16
LinearSegmentParameter::GetHeight() const
243 //////////////////////////////////////////////////////////////////////////
245 void LinearSegmentParameter::SetDepth( KUINT16 D
)
250 //////////////////////////////////////////////////////////////////////////
252 KUINT16
LinearSegmentParameter::GetDepth() const
257 //////////////////////////////////////////////////////////////////////////
259 KString
LinearSegmentParameter::GetAsString() const
263 ss
<< "LinearSegmentParameter:\n"
264 << "\tSegment Number: " << ( KUINT16
)m_ui8SegNum
<< "\n"
265 << "\tModification:\n"
266 << "\t\tLocation: " << ( KUINT16
)m_ModificationUnion
.m_ui8LocBit
<< "\n"
267 << "\t\tOrientation: " << ( KUINT16
)m_ModificationUnion
.m_ui8OriBit
<< "\n"
268 << IndentString( m_ObjApr
.GetAsString(), 1 )
269 << "\tLocation: " << m_Loc
.GetAsString()
270 << "\tOrientation: " << m_Ori
.GetAsString()
271 << "\tLength: " << m_ui16Length
<< "\n"
272 << "\tWidth: " << m_ui16Width
<< "\n"
273 << "\tHeight: " << m_ui16Height
<< "\n"
274 << "\tDepth: " << m_ui16Depth
<< "\n";
279 //////////////////////////////////////////////////////////////////////////
281 void LinearSegmentParameter::Decode( KDataStream
& stream
)
283 if( stream
.GetBufferSize() < LINEAR_SEGMENT_PARAMETER_SIZE
)throw KException( __FUNCTION__
, NOT_ENOUGH_DATA_IN_BUFFER
);
285 stream
>> m_ui8SegNum
286 >> m_ModificationUnion
.m_ui8Modifications
287 >> KDIS_STREAM m_ObjApr
297 //////////////////////////////////////////////////////////////////////////
299 KDataStream
LinearSegmentParameter::Encode() const
303 LinearSegmentParameter::Encode( stream
);
308 //////////////////////////////////////////////////////////////////////////
310 void LinearSegmentParameter::Encode( KDataStream
& stream
) const
312 stream
<< m_ui8SegNum
313 << m_ModificationUnion
.m_ui8Modifications
314 << KDIS_STREAM m_ObjApr
324 //////////////////////////////////////////////////////////////////////////
326 KBOOL
LinearSegmentParameter::operator == ( const LinearSegmentParameter
& Value
) const
328 if( m_ui8SegNum
!= Value
.m_ui8SegNum
) return false;
329 if( m_ModificationUnion
.m_ui8Modifications
!= Value
.m_ModificationUnion
.m_ui8Modifications
) return false;
330 if( m_ObjApr
!= Value
.m_ObjApr
) return false;
331 if( m_Loc
!= Value
.m_Loc
) return false;
332 if( m_Ori
!= Value
.m_Ori
) return false;
333 if( m_ui16Length
!= Value
.m_ui16Length
) return false;
334 if( m_ui16Width
!= Value
.m_ui16Width
) return false;
335 if( m_ui16Height
!= Value
.m_ui16Height
) return false;
336 if( m_ui16Depth
!= Value
.m_ui16Depth
) return false;
340 //////////////////////////////////////////////////////////////////////////
342 KBOOL
LinearSegmentParameter::operator != ( const LinearSegmentParameter
& Value
) const
344 return !( *this == Value
);
347 //////////////////////////////////////////////////////////////////////////