// SpatialRelation bool SmtFan::Equals( const SmtGeometry * poOther) const { SmtFan *poFan = (SmtFan *) poOther; if( poFan == this ) return TRUE; if( poOther->GetGeometryType() != GetGeometryType() ) return FALSE; return poFan->GetArc()->Equals(m_pArc); }
void ChunkyBoneGeometry::SaveChunkyData(const ChunkyPhysics* structure, void* data) const { uint32* _data = (uint32*)data; _data[0] = Endian::HostToBig(GetGeometryType()); _data[1] = Endian::HostToBigF(body_data_.mass_); _data[2] = Endian::HostToBigF(body_data_.friction_); _data[3] = Endian::HostToBigF(body_data_.bounce_); _data[4] = body_data_.parent_? Endian::HostToBig(structure->GetIndex(body_data_.parent_)) : (unsigned)-1; _data[5] = Endian::HostToBig(body_data_.joint_type_); _data[6] = Endian::HostToBig(body_data_.is_affected_by_gravity_? 1 : 0); _data[7] = Endian::HostToBig(body_data_.bone_type_); int y = 8; for (int x = 0; (size_t)x < LEPRA_ARRAY_COUNT(body_data_.parameter_); ++x) { _data[y++] = Endian::HostToBigF(body_data_.parameter_[x]); } const int connector_types = (int)connector_array_.size(); _data[y++] = Endian::HostToBig(connector_types); for (int x = 0; x < connector_types; ++x) { _data[y++] = Endian::HostToBig(connector_array_[x]); } PackerUnicodeString::Pack((uint8*)&_data[y], material_); }
void ChunkyBoneGeometry::LoadChunkyData(ChunkyPhysics* structure, const void* data) { const uint32* _data = (const uint32*)data; deb_assert((GeometryType)Endian::BigToHost(_data[0]) == GetGeometryType()); body_data_.mass_ = Endian::BigToHostF(_data[1]); body_data_.friction_ = Endian::BigToHostF(_data[2]); body_data_.bounce_ = Endian::BigToHostF(_data[3]); int parent_index = Endian::BigToHost(_data[4]); body_data_.parent_ = (parent_index < 0)? 0 : structure->GetBoneGeometry(parent_index); body_data_.joint_type_ = (JointType)Endian::BigToHost(_data[5]); body_data_.is_affected_by_gravity_ = Endian::BigToHost(_data[6])? true : false; body_data_.bone_type_ = (BoneType)Endian::BigToHost(_data[7]); int y = 8; for (int x = 0; (size_t)x < LEPRA_ARRAY_COUNT(body_data_.parameter_); ++x) { body_data_.parameter_[x] = Endian::BigToHostF(_data[y++]); } const int connector_types = Endian::BigToHost(_data[y++]); for (int x = 0; x < connector_types; ++x) { connector_array_.push_back((ConnectorType)Endian::BigToHost(_data[y++])); } PackerUnicodeString::Unpack(material_, (uint8*)&_data[y], 100); }
CPLXMLNode *GMLFeatureClass::SerializeToXML() { CPLXMLNode *psRoot; int iProperty; /* -------------------------------------------------------------------- */ /* Set feature class and core information. */ /* -------------------------------------------------------------------- */ psRoot = CPLCreateXMLNode( NULL, CXT_Element, "GMLFeatureClass" ); CPLCreateXMLElementAndValue( psRoot, "Name", GetName() ); CPLCreateXMLElementAndValue( psRoot, "ElementPath", GetElementName() ); if( GetGeometryElement() != NULL && strlen(GetGeometryElement()) > 0 ) CPLCreateXMLElementAndValue( psRoot, "GeometryElementPath", GetGeometryElement() ); if( GetGeometryType() != 0 /* wkbUnknown */ ) { char szValue[128]; sprintf( szValue, "%d", GetGeometryType() ); CPLCreateXMLElementAndValue( psRoot, "GeometryType", szValue ); } /* -------------------------------------------------------------------- */ /* Write out dataset specific information. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psDSI; if( m_bHaveExtents || m_nFeatureCount != -1 || m_pszExtraInfo != NULL ) { psDSI = CPLCreateXMLNode( psRoot, CXT_Element, "DatasetSpecificInfo" ); if( m_nFeatureCount != -1 ) { char szValue[128]; sprintf( szValue, "%d", m_nFeatureCount ); CPLCreateXMLElementAndValue( psDSI, "FeatureCount", szValue ); } if( m_bHaveExtents ) { char szValue[128]; sprintf( szValue, "%.5f", m_dfXMin ); CPLCreateXMLElementAndValue( psDSI, "ExtentXMin", szValue ); sprintf( szValue, "%.5f", m_dfXMax ); CPLCreateXMLElementAndValue( psDSI, "ExtentXMax", szValue ); sprintf( szValue, "%.5f", m_dfYMin ); CPLCreateXMLElementAndValue( psDSI, "ExtentYMin", szValue ); sprintf( szValue, "%.5f", m_dfYMax ); CPLCreateXMLElementAndValue( psDSI, "ExtentYMax", szValue ); } if( m_pszExtraInfo ) CPLCreateXMLElementAndValue( psDSI, "ExtraInfo", m_pszExtraInfo ); } /* -------------------------------------------------------------------- */ /* emit property information. */ /* -------------------------------------------------------------------- */ for( iProperty = 0; iProperty < GetPropertyCount(); iProperty++ ) { GMLPropertyDefn *poPDefn = GetProperty( iProperty ); CPLXMLNode *psPDefnNode; const char *pszTypeName = "Unknown"; psPDefnNode = CPLCreateXMLNode( psRoot, CXT_Element, "PropertyDefn" ); CPLCreateXMLElementAndValue( psPDefnNode, "Name", poPDefn->GetName() ); CPLCreateXMLElementAndValue( psPDefnNode, "ElementPath", poPDefn->GetSrcElement() ); switch( poPDefn->GetType() ) { case GMLPT_Untyped: pszTypeName = "Untyped"; break; case GMLPT_String: pszTypeName = "String"; break; case GMLPT_Integer: pszTypeName = "Integer"; break; case GMLPT_Real: pszTypeName = "Real"; break; case GMLPT_Complex: pszTypeName = "Complex"; break; case GMLPT_IntegerList: pszTypeName = "IntegerList"; break; case GMLPT_RealList: pszTypeName = "RealList"; break; case GMLPT_StringList: pszTypeName = "StringList"; break; } CPLCreateXMLElementAndValue( psPDefnNode, "Type", pszTypeName ); if( EQUAL(pszTypeName,"String") ) { char szMaxLength[48]; sprintf(szMaxLength, "%d", poPDefn->GetWidth()); CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szMaxLength ); } if( poPDefn->GetWidth() > 0 && EQUAL(pszTypeName,"Integer") ) { char szLength[48]; sprintf(szLength, "%d", poPDefn->GetWidth()); CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szLength ); } if( poPDefn->GetWidth() > 0 && EQUAL(pszTypeName,"Real") ) { char szLength[48]; sprintf(szLength, "%d", poPDefn->GetWidth()); CPLCreateXMLElementAndValue ( psPDefnNode, "Width", szLength ); char szPrecision[48]; sprintf(szPrecision, "%d", poPDefn->GetPrecision()); CPLCreateXMLElementAndValue ( psPDefnNode, "Precision", szPrecision ); } } return psRoot; }