Kaynağa Gözat

Merge branch 'dev' into lizhongdev

gsp 3 yıl önce
ebeveyn
işleme
5bacaa8716

+ 20 - 10
OTSCPP/OTSClrInterface/ControlClr/OTSControlFunExport.cpp

@@ -224,12 +224,13 @@ namespace OTSCLRINTERFACE
 
 			listXRayPoints.push_back(pXRayPoint);
 		}
-		std::vector<BrukerSegment> listSegment;
-		std::vector<std::vector<BrukerSegment>>listFeatures;
+		
+		std::vector<BrukerFeature>listFeatures;
 		for (int i = 0; i < xraynum; i++)
 		{
 			auto feature = features[i]->GetOTSFeaturePtr();
 			auto otsSegs = feature->GetSegmentsList();
+			std::vector<BrukerSegment> listSegment;
 			for (int j = 0; j < otsSegs.size(); j++)
 			{
 				auto seg = otsSegs[j];
@@ -239,8 +240,10 @@ namespace OTSCLRINTERFACE
 				oSegment.Y = seg->GetHeight();
 				listSegment.push_back(oSegment);
 			}
-
-			listFeatures.push_back(listSegment);
+			BrukerFeature oFeature;
+			oFeature.SegmentCount = listSegment.size();
+			oFeature.pSegment = &listSegment[0];
+			listFeatures.push_back(oFeature);
 		}
 		// set get quantify info flag
 		if (bQuant)
@@ -299,12 +302,14 @@ namespace OTSCLRINTERFACE
 			CPosXrayPtr pXRayPoint = parts[i]->GetXray()->GetPosXrayPtr();
 			listXRayPoints.push_back(pXRayPoint);
 		}
-		std::vector<BrukerSegment> listSegment;
-		std::vector<std::vector<BrukerSegment>>listFeatures;
+		
+		//std::vector<std::vector<BrukerSegment>>listFeatures;
+		std::vector<BrukerFeature>listFeatures;
 		for (int i = 0; i < xraynum; i++)
 		{
 			auto feature = parts[i]->GetOTSParticlePtr()->GetFeature();
 			auto otsSegs = feature->GetSegmentsList();
+			std::vector<BrukerSegment> listSegment;
 			for (int j = 0; j < otsSegs.size(); j++)
 			{
 				auto seg = otsSegs[j];
@@ -314,8 +319,11 @@ namespace OTSCLRINTERFACE
 				oSegment.Y = seg->GetHeight();
 				listSegment.push_back(oSegment);
 			}
+			BrukerFeature oFeature;
+			oFeature.SegmentCount = listSegment.size();
+			oFeature.pSegment = &listSegment[0];
 
-			listFeatures.push_back(listSegment);
+			listFeatures.push_back(oFeature);
 		}
 		// set get quantify info flag
 		if (bQuant)
@@ -396,7 +404,7 @@ namespace OTSCLRINTERFACE
 		listXRayPoints.push_back(pXRayPoint);
 
 		std::vector<BrukerSegment> listSegment;
-		std::vector<std::vector<BrukerSegment>>listFeatures;
+		std::vector<BrukerFeature>listFeatures;
 
 		auto otsSegs = feature->GetSegmentsList();
 		for (int j = 0; j < otsSegs->Count; j++)
@@ -408,8 +416,10 @@ namespace OTSCLRINTERFACE
 			oSegment.Y = seg->GetHeight();
 			listSegment.push_back(oSegment);
 		}
-
-		listFeatures.push_back(listSegment);
+		BrukerFeature ofeature;
+		ofeature.SegmentCount = listSegment.size();
+		ofeature.pSegment = &listSegment[0];
+		listFeatures.push_back(ofeature);
 
 		bool bRet = FALSE;
 

+ 11 - 9
OTSCPP/OTSControl/Bruker/OTSBrukerImpl.cpp

@@ -3099,7 +3099,7 @@ BOOL COTSBrukerImpl::SetXRayPoints(CPosXraysList& a_listXrayPois, const DWORD a_
 	return TRUE;
 }
 
-BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<std::vector<BrukerSegment>>& a_vFeatures, DWORD a_nACTimeMS)
+BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<BrukerFeature>& a_vFeatures, DWORD a_nACTimeMS)
 {
 	// bruker dll handle check
 	ASSERT(m_pBrukerDllHandle);
@@ -3139,14 +3139,14 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<st
 
 	// added by Jieshi 23/08/2017
 	WORD* pixelTimes(new WORD[nCollectCount]);
-	BrukerFeature* features(new BrukerFeature[nCollectCount]);
+	//BrukerFeature* features(new BrukerFeature[nCollectCount]);
 	std::vector<BrukerSegment> extraSegments;
 	for (size_t i = 0; i < a_vXPoints.size(); i++)
 	{
-		features[i].SegmentCount = (long)a_vFeatures[i].size();
-		if (features[i].SegmentCount > 0)
+		//features[i].SegmentCount = (long)a_vFeatures[i].size();
+		if (a_vFeatures[i].SegmentCount > 0)
 		{
-			features[i].pSegment = &a_vFeatures[i][0];
+			//features[i].pSegment = &a_vFeatures[i][0];
 
 			// calculate pixel time
 			int nPixelCount = 0;
@@ -3162,9 +3162,9 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<st
 				nPixelCount += a_vFeatures[i][j].XCount;
 			}*/
 
-			for (int j = 0; j < features[i].SegmentCount; j++)
+			for (int j = 0; j < a_vFeatures[i].SegmentCount; j++)
 			{
-				nPixelCount += features[i].pSegment[j].XCount;
+				nPixelCount += a_vFeatures[i].pSegment[j].XCount;
 			}
 			pixelTimes[i] = (WORD)(ceil((double)a_nACTimeMS * 1000.0 / (double)nPixelCount));
 
@@ -3174,6 +3174,7 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<st
 		{
 			// will generate according to the x-ray position
 			// this shouldn't happen
+			BrukerFeature* features(new BrukerFeature[nCollectCount]);
 			extraSegments.push_back(BrukerSegment());
 			extraSegments[extraSegments.size() - 1].XStart = a_vXPoints[i]->GetPosition().x;
 			extraSegments[extraSegments.size() - 1].Y = a_vXPoints[i]->GetPosition().y;
@@ -3181,11 +3182,12 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<st
 			features[i].pSegment = &extraSegments[extraSegments.size() - 1];
 
 			pixelTimes[i] = (WORD)(a_nACTimeMS * 1000);
+			delete[] features;
 		}
 	}
 
 	// ask bruker to collect a set of x-ray data
-	if (!StartFeatureListMeasurement(nCollectCount, features, pixelTimes))
+	if (!StartFeatureListMeasurement(nCollectCount, &a_vFeatures[0], pixelTimes))
 	{
 		// failed to call StartFeatureListMeasurement method
 		LogErrorTrace(__FILE__, __LINE__, _T("COTSBrukerImpl::CollectXRayPointsByFeatures: failed to call StartFeatureListMeasurement method."));
@@ -3200,7 +3202,7 @@ BOOL COTSBrukerImpl::GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<st
 		return FALSE;
 	}
 	delete[] pixelTimes;
-	delete[] features;
+	//delete[] features;
 	// ok, return TRUE
 	return TRUE;
 }

+ 1 - 1
OTSCPP/OTSControl/Bruker/OTSBrukerImpl.h

@@ -143,7 +143,7 @@ namespace OTSController {
 		// m_bDoQuantification should be set first. 
 		BOOL GetXRayByPoints(CPosXraysList& a_listXrayPois, DWORD a_nACTimeMS);
 		BOOL SetXRayPoints(CPosXraysList& a_listXrayPois, const DWORD a_nACTimeMS);
-		BOOL GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<std::vector<BrukerSegment>>& a_vFeatures, DWORD a_nACTimeMS);
+		BOOL GetXRayByFeatures(CPosXraysList& a_vXPoints, std::vector<BrukerFeature>& a_vFeatures, DWORD a_nACTimeMS);
 		BOOL SetXRayPointsByFeature(CPosXraysList& a_vXPoints, const DWORD a_nACTimeMS);
 	protected:
 		// close client

+ 1 - 1
OTSCPP/OTSControl/Bruker/OTSEDSBrucker.cpp

@@ -249,7 +249,7 @@ namespace OTSController {
 		return TRUE;
 	}
 	BOOL COTSEDSBrucker::GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
-		std::vector<std::vector<BrukerSegment>>& a_listFeatures,
+		std::vector<BrukerFeature>& a_listFeatures,
 		const DWORD a_nXRayAQTime)
 	{
 		

+ 1 - 1
OTSCPP/OTSControl/Bruker/OTSEDSBrucker.h

@@ -48,7 +48,7 @@ namespace OTSController {
 	
 		virtual BOOL GetXRayByPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime)override;
 		virtual BOOL GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
-			std::vector<std::vector<BrukerSegment>>& a_listFeatures,
+			std::vector<BrukerFeature>& a_listFeatures,
 			const DWORD a_nXRayAQTime) override;
 		/*virtual BOOL GetXRayByFeaturesFromMultiPoint(std::vector<CPosXrayPtr>& a_listXRayPoints,
 			std::vector<std::vector<BrukerSegment>>& a_listFeatures,

+ 1 - 1
OTSCPP/OTSControl/OTSEDSBase.h

@@ -98,7 +98,7 @@ namespace OTSController
 
 		virtual BOOL GetXRayByPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime) = 0;
 		virtual BOOL GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
-			std::vector<std::vector<BrukerSegment>>& a_listFeatures,
+			std::vector<BrukerFeature>& a_listFeatures,
 			const DWORD a_nXRayAQTime) = 0;
 		BOOL GetXRayByFeaturesFromMultiPoint(std::vector<CPosXrayPtr>& a_listXRayPoints,
 			std::vector<std::vector<BrukerSegment>>& a_listFeatures,

+ 1 - 1
OTSCPP/OTSControl/Oxford/OTSEDSOxford.cpp

@@ -151,7 +151,7 @@
 			return TRUE;
 		}
 		BOOL COTSEDSOxford::GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
-			std::vector<std::vector<BrukerSegment>>& a_listFeatures,
+			std::vector<BrukerFeature>& a_listFeatures,
 			const DWORD a_nXRayAQTime)
 		{
 

+ 1 - 1
OTSCPP/OTSControl/Oxford/OTSEDSOxford.h

@@ -46,7 +46,7 @@
 
 			virtual BOOL GetXRayByPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime)override;
 			virtual BOOL GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
-				std::vector<std::vector<BrukerSegment>>& a_listFeatures,
+				std::vector<BrukerFeature>& a_listFeatures,
 				const DWORD a_nXRayAQTime) override;
 			/*virtual BOOL GetXRayByFeaturesFromMultiPoint(std::vector<CPosXrayPtr>& a_listXRayPoints,
 				std::vector<std::vector<BrukerSegment>>& a_listFeatures,

+ 10 - 7
OTSCPP/OTSControl/Oxford/OTSOxfordImpl.cpp

@@ -408,7 +408,7 @@
 	}
 
 
-	BOOL OxfordImpl::GetXRayByFeatures(CPosXraysList&a_listXrayPois, std::vector<std::vector<BrukerSegment>>& a_vFeatures, DWORD a_nXRayAQTime)
+	BOOL OxfordImpl::GetXRayByFeatures(CPosXraysList&a_listXrayPois, std::vector<BrukerFeature>& a_vFeatures, DWORD a_nXRayAQTime)
 	{
 		try
 		{
@@ -436,24 +436,27 @@
 
 			// create array of BrukerSegment
 			long nCollectCount = (long)a_listXrayPois.size();
-			
+
+
+			//convert the brukerfeature to oxfordfeature
 		   OxfordXrayData* features(new OxfordXrayData[nCollectCount]);
 
 			
 			int nTotalNum = 0;
 			for (size_t i = 0; i < a_listXrayPois.size(); i++)
 			{
-				long nSegmentCount = (long)a_vFeatures[i].size();
+				long nSegmentCount = (long)a_vFeatures[i].SegmentCount;
 				features[i].m_nChordNum = nSegmentCount;
 				long nPixelCount = 0;
 				if (nSegmentCount > 0)
 				{
+					BrukerSegment* segs = a_vFeatures[i].pSegment;
 					for (int j = 0; j < nSegmentCount; j++)
 					{
-						features[i].m_ChordList[j].m_nX = a_vFeatures[i][j].XStart;
-						features[i].m_ChordList[j].m_nY = a_vFeatures[i][j].Y;
-						features[i].m_ChordList[j].m_nLength = a_vFeatures[i][j].XCount;
-						nPixelCount += a_vFeatures[i][j].XCount;
+						features[i].m_ChordList[j].m_nX = segs[j].XStart;
+						features[i].m_ChordList[j].m_nY = segs[j].Y;
+						features[i].m_ChordList[j].m_nLength = segs[j].XCount;
+						nPixelCount += segs[j].XCount;
 					}
 
 					features[i].m_nPixelNum = nPixelCount;

+ 1 - 1
OTSCPP/OTSControl/Oxford/OTSOxfordImpl.h

@@ -78,7 +78,7 @@
 
 		// m_bDoQuantification should be set first. 
 		BOOL GetXRayByPoints(CPosXraysList& a_listXrayPois, DWORD a_nACTimeMS);	
-		BOOL GetXRayByFeatures(CPosXraysList&a_listXRayPoints, std::vector<std::vector<BrukerSegment>>& a_vFeatures, DWORD a_nXRayAQTime);
+		BOOL GetXRayByFeatures(CPosXraysList&a_listXRayPoints, std::vector<BrukerFeature>& a_vFeatures, DWORD a_nXRayAQTime);
 
     protected:
         void CloseClient(void);//there's no need to call from out ,the single instance destruction method will call it automatically.

+ 1 - 1
OTSCPP/OTSControl/Simulate/OTSEDSSim.cpp

@@ -217,7 +217,7 @@ namespace OTSController {
 		
 	}
 	BOOL COTSEDSSim::GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
-		std::vector<std::vector<BrukerSegment>>& a_listFeatures,
+		std::vector<BrukerFeature>& a_vFeatures,
 		const DWORD a_nXRayAQTime)
 	{
 		// read simulation spectrum into buffer

+ 1 - 1
OTSCPP/OTSControl/Simulate/OTSEDSSim.h

@@ -48,7 +48,7 @@ namespace OTSController {
 	
 		virtual BOOL GetXRayByPoints(std::vector<CPosXrayPtr>& a_vXRayPoints, const DWORD a_nXRayAQTime)override;
 		virtual BOOL GetXRayByFeatures(std::vector<CPosXrayPtr>& a_listXRayPoints,
-			std::vector<std::vector<BrukerSegment>>& a_listFeatures,
+			std::vector<BrukerFeature>& a_vFeatures,
 			const DWORD a_nXRayAQTime) override;
 
 		// Quatification