123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- #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::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();
- }
- }
|