|
|
@@ -141,9 +141,9 @@ namespace OTSIMGPROC {
|
|
|
|
|
|
return TRUE;
|
|
|
}
|
|
|
- std::vector<CPoint> CFieldMgr::GetUnmeasuredFieldCentrePoints(std::vector<CPoint> a_listMeasuredFieldCentrePoints)
|
|
|
+ std::vector<CPoint> CFieldMgr::GetUnmeasuredFieldCentrePoints(std::vector<CPoint> a_listMeasuredFieldCentrePoints,int distributionMode)
|
|
|
{
|
|
|
- std::vector<CPoint> allPoints = CalculateFieldCentrePoints();
|
|
|
+ std::vector<CPoint> allPoints = CalculateFieldCentrePoints(distributionMode);
|
|
|
std::vector<CPoint> unmeasuredPoints;
|
|
|
for(auto p:allPoints)
|
|
|
if (!IsInMeasuredFieldList(p,a_listMeasuredFieldCentrePoints))
|
|
|
@@ -154,17 +154,17 @@ namespace OTSIMGPROC {
|
|
|
return unmeasuredPoints;
|
|
|
}
|
|
|
|
|
|
- std::vector<CPoint> CFieldMgr::GetFieldCentrePoints()
|
|
|
+ std::vector<CPoint> CFieldMgr::GetFieldCentrePoints(int distributionMode)
|
|
|
{
|
|
|
- auto m_listFieldCentrePoints = CalculateFieldCentrePoints();
|
|
|
+ auto m_listFieldCentrePoints = CalculateFieldCentrePoints(distributionMode);
|
|
|
return m_listFieldCentrePoints;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- int CFieldMgr::GetTotalFields()
|
|
|
+ int CFieldMgr::GetTotalFields(int distributionMode)
|
|
|
{
|
|
|
- auto m_listFieldCentrePoints = CalculateFieldCentrePoints();
|
|
|
+ auto m_listFieldCentrePoints = CalculateFieldCentrePoints(distributionMode);
|
|
|
return (int)m_listFieldCentrePoints.size();
|
|
|
}
|
|
|
|
|
|
@@ -254,7 +254,7 @@ namespace OTSIMGPROC {
|
|
|
|
|
|
|
|
|
// calculate field centre points list
|
|
|
- std::vector<CPoint> CFieldMgr::CalculateFieldCentrePoints()
|
|
|
+ std::vector<CPoint> CFieldMgr::CalculateFieldCentrePoints(int distributionMode)
|
|
|
{
|
|
|
// field centre points list
|
|
|
std::vector<CPoint> m_listFieldCentrePoints;
|
|
|
@@ -354,11 +354,30 @@ namespace OTSIMGPROC {
|
|
|
{
|
|
|
for (auto itr : mapCenterPoint)
|
|
|
{
|
|
|
- if (IsInMeasureArea(itr.second, sizeImage))
|
|
|
+ switch (distributionMode)
|
|
|
{
|
|
|
- m_listFieldCentrePoints.push_back(itr.second);
|
|
|
-
|
|
|
+ case 0://center in
|
|
|
+ if (IsCenterInMeasureArea(itr.second, sizeImage))
|
|
|
+ {
|
|
|
+ m_listFieldCentrePoints.push_back(itr.second);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1://partly in , field will cover all the measure area
|
|
|
+ if (IsPartlyInMeasureArea(itr.second, sizeImage))
|
|
|
+ {
|
|
|
+ m_listFieldCentrePoints.push_back(itr.second);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2://totally in, field is totally in the measure area
|
|
|
+ if (IsTotallyInMeasureArea(itr.second, sizeImage))
|
|
|
+ {
|
|
|
+ m_listFieldCentrePoints.push_back(itr.second);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -499,7 +518,7 @@ namespace OTSIMGPROC {
|
|
|
}
|
|
|
|
|
|
// test if field is in or partly in the measure domain area
|
|
|
- BOOL CFieldMgr::IsInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize)
|
|
|
+ BOOL CFieldMgr::IsCenterInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize)
|
|
|
{
|
|
|
// check measure area parameter
|
|
|
ASSERT(m_pMeasureArea);
|
|
|
@@ -517,76 +536,109 @@ namespace OTSIMGPROC {
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
- //// get measure field centre
|
|
|
- //CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
|
|
|
+
|
|
|
|
|
|
- //// move to left top postion.
|
|
|
- //a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
|
|
|
+ // this field is not in the area , return FALSE.
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ // test if field is in or partly in the measure domain area
|
|
|
+ BOOL CFieldMgr::IsPartlyInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize)
|
|
|
+ {
|
|
|
+ // check measure area parameter
|
|
|
+ ASSERT(m_pMeasureArea);
|
|
|
+ if (!m_pMeasureArea)
|
|
|
+ {
|
|
|
+ // shouldn't happen
|
|
|
+ LogErrorTrace(__FILE__, __LINE__, _T("IsInDomainArea: invalid measure area parameter."));
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
|
|
|
- //// rectangle of the field
|
|
|
- //CRect rectFiled(a_poiField, a_sizeImageSize);
|
|
|
+ // test field centre point first
|
|
|
+ if (m_pMeasureArea->PtInDomain(a_poiField))
|
|
|
+ {
|
|
|
+ // centre in the measure domain area, return TRUE
|
|
|
+ return TRUE;
|
|
|
+ }
|
|
|
|
|
|
- //// check field position
|
|
|
- //if (rectFiled.left <= poiMsrAreaCentre.x && rectFiled.right >= poiMsrAreaCentre.x)
|
|
|
- //{
|
|
|
- // // centre column field or centre field
|
|
|
- // return TRUE;
|
|
|
- //}
|
|
|
- //else if (rectFiled.top <= poiMsrAreaCentre.y && rectFiled.bottom >= poiMsrAreaCentre.y)
|
|
|
- //{
|
|
|
- // // centre row field?
|
|
|
- // return TRUE;
|
|
|
- //}
|
|
|
- //else if ( rectFiled.right <= poiMsrAreaCentre.x)
|
|
|
- //{
|
|
|
- // // on the left side
|
|
|
-
|
|
|
- // //up
|
|
|
- // if (rectFiled.top >= poiMsrAreaCentre.y)
|
|
|
- // {
|
|
|
- // // on the top left side, need to test the bottom right corner
|
|
|
- // if (m_pMeasureArea->PtInDomain(CPoint(rectFiled.right, rectFiled.top)))
|
|
|
- // {
|
|
|
- // return TRUE;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if(rectFiled.bottom <= poiMsrAreaCentre.y) //down//
|
|
|
- // {
|
|
|
- // // on the bottom left side, need to test the top right corner
|
|
|
- // if (m_pMeasureArea->PtInDomain(rectFiled.BottomRight()))
|
|
|
- // {
|
|
|
- // return TRUE;
|
|
|
- // }
|
|
|
- // }
|
|
|
+ // get measure field centre
|
|
|
+ CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
|
|
|
|
|
|
- //}
|
|
|
- //else if(rectFiled.left >= poiMsrAreaCentre.x)
|
|
|
- //{
|
|
|
- // // on the right side
|
|
|
+ // move to left top postion.
|
|
|
+ a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
|
|
|
|
|
|
- // //up
|
|
|
- // if (rectFiled.top >= poiMsrAreaCentre.y)
|
|
|
- // {
|
|
|
- // // on the top left side, need to test the bottom right corner
|
|
|
- // if (m_pMeasureArea->PtInDomain(rectFiled.TopLeft()))
|
|
|
- // {
|
|
|
- // return TRUE;
|
|
|
- // }
|
|
|
- // }
|
|
|
- // else if (rectFiled.bottom <= poiMsrAreaCentre.y) //down//
|
|
|
- // {
|
|
|
- // // on the bottom left side, need to test the top right corner
|
|
|
- // if (m_pMeasureArea->PtInDomain(CPoint(rectFiled.left, rectFiled.bottom)))
|
|
|
- // {
|
|
|
- // return TRUE;
|
|
|
- // }
|
|
|
- // }
|
|
|
+ // rectangle of the field
|
|
|
+ CRect rectFiled(a_poiField, a_sizeImageSize);
|
|
|
+
|
|
|
+ if (m_pMeasureArea->PtInDomain(CPoint(rectFiled.right, rectFiled.top)))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- //}
|
|
|
+ if (m_pMeasureArea->PtInDomain(rectFiled.BottomRight()))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_pMeasureArea->PtInDomain(rectFiled.TopLeft()))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_pMeasureArea->PtInDomain(CPoint(rectFiled.left, rectFiled.bottom)))
|
|
|
+ {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // check field position
|
|
|
+
|
|
|
|
|
|
// this field is not in the area , return FALSE.
|
|
|
return FALSE;
|
|
|
}
|
|
|
+ BOOL CFieldMgr::IsTotallyInMeasureArea(CPoint a_poiField, CSize a_sizeImageSize)
|
|
|
+ {
|
|
|
+ // check measure area parameter
|
|
|
+ ASSERT(m_pMeasureArea);
|
|
|
+ if (!m_pMeasureArea)
|
|
|
+ {
|
|
|
+ // shouldn't happen
|
|
|
+ LogErrorTrace(__FILE__, __LINE__, _T("IsInDomainArea: invalid measure area parameter."));
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // get measure field centre
|
|
|
+ CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
|
|
|
+
|
|
|
+ // move to left top postion.
|
|
|
+ a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
|
|
|
+
|
|
|
+ // rectangle of the field
|
|
|
+ CRect rectFiled(a_poiField, a_sizeImageSize);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if (!m_pMeasureArea->PtInDomain(CPoint(rectFiled.right, rectFiled.top)))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!m_pMeasureArea->PtInDomain(rectFiled.BottomRight()))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!m_pMeasureArea->PtInDomain(rectFiled.TopLeft()))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (!m_pMeasureArea->PtInDomain(CPoint(rectFiled.left, rectFiled.bottom)))
|
|
|
+ {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
// test if field is in the measured field centre points list
|
|
|
BOOL CFieldMgr::IsInMeasuredFieldList(CPoint a_poiField, std::vector<CPoint> m_listHaveMeasuredFieldCentrePoints)
|