#include "stdafx.h" #include "PosXrayInfo.h" namespace OTSDATA { // CPosXrayInfo // constructor CPosXrayInfo::CPosXrayInfo() { // initialization Init(); } // copy constructor CPosXrayInfo::CPosXrayInfo(const CPosXrayInfo& a_oSource) { // can't copy itself if (&a_oSource == this) { return; } // copy data over Duplicate(a_oSource); } // copy constructor CPosXrayInfo::CPosXrayInfo(CPosXrayInfo* a_poSource) { // input check ASSERT(a_poSource); if (!a_poSource) { return; } // can't copy itself if (a_poSource == this) { return; } // copy data over Duplicate(*a_poSource); } // =operator CPosXrayInfo& CPosXrayInfo::operator=(const CPosXrayInfo& a_oSource) { // cleanup Cleanup(); // copy the class data over Duplicate(a_oSource); // return class return *this; } // ==operator BOOL CPosXrayInfo::operator==(const CPosXrayInfo& a_oSource) { // size matches? int nSize = (int)m_listElementQuantifyData.size(); if (nSize != (int)a_oSource.m_listElementQuantifyData.size()) { return FALSE; } // list matches? for (int i = 0; i < nSize; ++i) { if (!(*(m_listElementQuantifyData[i].get()) == *(a_oSource.m_listElementQuantifyData[i].get()))) { return FALSE; } } // return test result return m_poiPosition == a_oSource.m_poiPosition && m_nIndex == a_oSource.m_nIndex && m_nFieldId == a_oSource.m_nFieldId && m_nPartTagId == a_oSource.m_nPartTagId && m_nFeatureId == a_oSource.m_nFeatureId; } // detractor CPosXrayInfo::~CPosXrayInfo() { Cleanup(); } // CPosXrayInfo member functions // public // serialization /*void CPosXrayInfo::Serialize(bool isStoring, tinyxml2::XMLDocument * classDoc, tinyxml2::XMLElement * rootNode) { xmls::xPoint xpoiPosition; xmls::xLong xnIndex; xmls::xLong xnFieldId; xmls::xLong xnPartTagId; xmls::xLong xnFeatureId; xmls::Slo slo; slo.Register("Position",&xpoiPosition); slo.Register("Index", &xnIndex); slo.Register("FieldId", &xnFieldId); slo.Register("PartTagId", &xnPartTagId); slo.Register("FeatureId", &xnFeatureId); if (isStoring) { xpoiPosition = m_poiPosition; xnIndex = m_nIndex; xnFieldId = m_nFieldId; xnPartTagId = m_nPartTagId; xnFeatureId = m_nFeatureId; slo.Serialize(true, classDoc, rootNode); } else { slo.Serialize(false, classDoc, rootNode); m_poiPosition = xpoiPosition.value(); m_nIndex = xnIndex.value(); m_nFieldId = xnFieldId.value(); m_nPartTagId = xnPartTagId.value(); m_nFeatureId = xnFeatureId.value(); } }*/ // element quantify data void CPosXrayInfo::SetElementQuantifyData(CElementChemistriesList& a_listElementQuantifyData) { m_listElementQuantifyData.clear(); for (auto poElementChemistry : a_listElementQuantifyData) { //CElementChemistryPtr poElementChemistryNew(new CElementChemistry(poElementChemistry.get())); CElementChemistryPtr poElementChemistryNew=poElementChemistry; m_listElementQuantifyData.push_back(poElementChemistryNew); } m_nElementNum = (int)m_listElementQuantifyData.size(); } void CPosXrayInfo::AddElementQuantifyData(CElementChemistryPtr a_ElementQuantifyData) { //m_listElementQuantifyData.clear(); /*for (auto poElementChemistry : a_listElementQuantifyData) {*/ //CElementChemistryPtr poElementChemistryNew(new CElementChemistry(poElementChemistry.get())); //CElementChemistryPtr poElementChemistryNew = poElementChemistry; m_listElementQuantifyData.push_back(a_ElementQuantifyData); //} m_nElementNum = (int)m_listElementQuantifyData.size(); } void CPosXrayInfo::NormalizeXrayQuantifyData() { if (m_listElementQuantifyData.empty()) { return; } double dTotalPercent = 0; for (auto poElementChemistry : m_listElementQuantifyData) { dTotalPercent += poElementChemistry->GetPercentage(); } if (dTotalPercent > MIN_DOUBLE_VALUE) { dTotalPercent /= 100; for (auto poElementChemistry : m_listElementQuantifyData) { poElementChemistry->SetPercentage(poElementChemistry->GetPercentage() /dTotalPercent); } } } // protected // cleanup void CPosXrayInfo::Cleanup() { // nothing needs to be done at the moment m_listElementQuantifyData.clear(); m_nElementNum = (int)m_listElementQuantifyData.size(); } // initialization void CPosXrayInfo::Init() { m_poiPosition = CPoint(0, 0); m_nIndex = -1; m_nFieldId = -1; m_nPartTagId = -1; m_nFeatureId = -1; m_listElementQuantifyData.clear(); m_nElementNum = (int)m_listElementQuantifyData.size(); } // duplication void CPosXrayInfo::Duplicate(const CPosXrayInfo& a_oSource) { // initialization Init(); // copy data over m_poiPosition = a_oSource.m_poiPosition; m_nIndex = a_oSource.m_nIndex; m_nFieldId = a_oSource.m_nFieldId; m_nPartTagId = a_oSource.m_nPartTagId; m_nFeatureId = a_oSource.m_nFeatureId; for (auto poElementChemistry : a_oSource.m_listElementQuantifyData) { CElementChemistryPtr poElementChemistryNew(new CElementChemistry(poElementChemistry.get())); m_listElementQuantifyData.push_back(poElementChemistryNew); } m_nElementNum = (int)m_listElementQuantifyData.size(); } }