#pragma once #include "stdafx.h" #include "OTSParticleClr.h" #include "../OTSLog/COTSUtilityDllFunExport.h" namespace OTSCLRINTERFACE { COTSParticleClr::COTSParticleClr() { m_Particle = new COTSParticlePtr(new COTSParticle()); } COTSParticleClr::COTSParticleClr(COTSParticlePtr pParticle) // copy constructor { ASSERT(pParticle); if (!pParticle) { LogErrorTrace(__FILE__, __LINE__, _T("COTSParticleClr: Generate COTSParticleClr pointer failed.")); return; } m_Particle = new COTSParticlePtr(pParticle); } COTSParticleClr::COTSParticleClr(COTSParticleClr^ a_pSource) { auto src = a_pSource->GetOTSParticlePtr(); m_Particle = new COTSParticlePtr(new COTSParticle(src.get())); } COTSParticleClr::COTSParticleClr(COTSParticle* a_pSource) // copy constructor { ASSERT(a_pSource); if (!a_pSource) { LogErrorTrace(__FILE__, __LINE__, _T("COTSParticleClr: Generate COTSParticleClr pointer failed.")); return; } m_Particle = new COTSParticlePtr(new COTSParticle(a_pSource)); } COTSParticleClr::~COTSParticleClr() { if (m_Particle != nullptr) { delete m_Particle; m_Particle = nullptr; } } COTSParticleClr::!COTSParticleClr() { if (m_Particle != nullptr) { delete m_Particle; m_Particle = nullptr; } } COTSParticlePtr COTSParticleClr::GetOTSParticlePtr() { return *m_Particle; } System::Drawing::Rectangle^ COTSParticleClr::GetParticleRect() { COTSParticlePtr prt = *m_Particle; CRect Crec = prt->GetParticleRect(); System::Drawing::Rectangle^ r = gcnew System::Drawing::Rectangle((int)Crec.left, (int)Crec.top, (int)Crec.Width(), (int)Crec.Height()); return r; } void COTSParticleClr::SetParticleRect(System::Drawing::Rectangle^ a_rectParticle) { CRect r(a_rectParticle->Left, a_rectParticle->Top, a_rectParticle->Right, a_rectParticle->Bottom); m_Particle->get()->SetParticleRect(r); } //represent the global position of this object void COTSParticleClr::SetOTSRect(int left, int top, int right, int bottom) { COTSRect r = COTSRect(left, top, right, bottom); m_Particle->get()->SetOTSRect(r); } bool COTSParticleClr::GetOTSRect(int% left, int% top, int% right, int% bottom) { COTSRect r = m_Particle->get()->GetOTSRect(); left = r.GetTopLeft().x; right = r.GetBottomRight().x; top = r.GetTopLeft().y; bottom = r.GetBottomRight().y; return true; } int COTSParticleClr::GetType() { int nType = -1; if (m_Particle != nullptr) { nType =(int) m_Particle->get()->GetType(); } return nType; } void COTSParticleClr::SetType(int a_nType) { if (m_Particle != nullptr) { m_Particle->get()->SetType((OTS_PARTICLE_TYPE)a_nType); } } int COTSParticleClr::GetClassifyId() { int nType = -1; if (m_Particle != nullptr) { nType = m_Particle->get()->GetClassifyId(); } return nType; } void COTSParticleClr::SetClassifyId(int a_nType) { if (m_Particle != nullptr) { m_Particle->get()->SetClassifyId(a_nType); } } double COTSParticleClr::GetActualArea() { double nArea = -1; if (m_Particle != nullptr) { nArea = m_Particle->get()->GetActualArea(); } return nArea; } double COTSParticleClr::GetPixelArea() { double nArea = -1; if (m_Particle != nullptr) { nArea = m_Particle->get()->GetPixelArea(); } return nArea; } void COTSParticleClr::SetActualArea(double a_dArea) { if (m_Particle != nullptr) { m_Particle->get()->SetActualArea(a_dArea); } } BYTE COTSParticleClr::GetAveGray() { BYTE nAveGray = -1; if (m_Particle != nullptr) { nAveGray = m_Particle->get()->GetAveGray(); } return nAveGray; } void COTSParticleClr::SetAveGray(BYTE a_cAveGray) { if (m_Particle != nullptr) { m_Particle->get()->SetAveGray(a_cAveGray); } } Point^ COTSParticleClr::GetXRayPos() { Point^ XRayPosClr; if (m_Particle != nullptr) { CPoint P = m_Particle->get()->GetXRayPos(); XRayPosClr = gcnew Point(P.x, P.y); } return XRayPosClr; } void COTSParticleClr::SetXRayPos(Point^ a_pXRayPos) { ASSERT(a_pXRayPos); if (!a_pXRayPos) { LogErrorTrace(__FILE__, __LINE__, _T("SetFileVersion: invalid version.")); } if (m_Particle != nullptr) { CPoint P = CPoint(a_pXRayPos->X, a_pXRayPos->Y); m_Particle->get()->SetXRayPos(P); } } cli::array^ COTSParticleClr::GetXrayMatrixPoints() { auto ps = m_Particle->get()->GetXrayMatrixPoints(); cli::array^ matrixPs = gcnew cli::array(ps.size()); int i=0; for (auto p : ps) { System::Drawing::Point^ p1 = gcnew System::Drawing::Point(p.x, p.y); matrixPs[i] = p1; i++; } return matrixPs; } void COTSParticleClr::SetXrayMatrixPoints(cli::array^ points) { std::vector matrixPs; int L = points->Length; for (int i = 0; i < L; i++) { CPoint p = CPoint(points[i]->X, points[i]->Y); matrixPs.push_back(p); } m_Particle->get()->SetXrayMatrixPoints(matrixPs); } void COTSParticleClr::SetSEMPos(System::Drawing::Point^ a_pAbsPos) { m_Particle->get()->SetSEMPos(CPoint(a_pAbsPos->X, a_pAbsPos->Y)); } COTSFeatureClr^ COTSParticleClr::GetFeature() { COTSFeatureClr^ FeatureClr; if (m_Particle != nullptr) { COTSFeaturePtr Feature = m_Particle->get()->GetFeature(); FeatureClr = gcnew COTSFeatureClr(Feature); } return FeatureClr; } void COTSParticleClr::SetFeature(COTSFeatureClr^ a_pFeautre) { ASSERT(a_pFeautre); if (!a_pFeautre) { LogErrorTrace(__FILE__, __LINE__, _T("SetFeature: invalid feature pointer.")); return; } if (m_Particle != nullptr) { COTSFeaturePtr pSetElement = a_pFeautre->GetOTSFeaturePtr(); ASSERT(pSetElement); if (!pSetElement) { LogErrorTrace(__FILE__, __LINE__, _T("SetElement: invalid part Element pointer.")); return; } m_Particle->get()->SetFeature(pSetElement); } } void COTSParticleClr::SetXray(CPosXrayClr^ xray) { m_Particle->get()->SetXrayInfo(xray->GetPosXrayPtr()); } CPosXrayClr^ COTSParticleClr::GetXray() { auto xray = m_Particle->get()->GetXrayInfo(); if (xray != nullptr) { return gcnew CPosXrayClr(m_Particle->get()->GetXrayInfo()); } else { return gcnew CPosXrayClr(); } } int COTSParticleClr::GetParticleId() { int nTagId = -1; if (m_Particle != nullptr) { nTagId = m_Particle->get()->GetParticleId(); } return nTagId; } void COTSParticleClr::SetParticleId(int a_nTagId) { if (m_Particle != nullptr) { m_Particle->get()->SetParticleId(a_nTagId); } } int COTSParticleClr::GetAnalysisId() { int AnalysisId = -1; if (m_Particle != nullptr) { AnalysisId = m_Particle->get()->GetAnalysisId(); } return AnalysisId; } void COTSParticleClr::SetAnalysisId(int a_nAnalysisId) { if (m_Particle != nullptr) { m_Particle->get()->SetAnalysisId(a_nAnalysisId); } } int COTSParticleClr::GetFieldId() { int FieldId = -1; if (m_Particle != nullptr) { FieldId = m_Particle->get()->GetFieldId(); } return FieldId; } void COTSParticleClr::SetFieldId(int a_nFieldId) { if (m_Particle != nullptr) { m_Particle->get()->SetFieldId(a_nFieldId); } } double COTSParticleClr::CalculateSimilarity(COTSParticleClr^ part) { return m_Particle->get()->CalculateSimilarity(part->GetOTSParticlePtr()); } }