|
|
@@ -342,11 +342,29 @@ namespace OTSIMGPROC {
|
|
|
std::vector<CPoint> ptPolygon = m_pMeasureArea->GetPolygonPoint();
|
|
|
for (auto itr : mapCenterPoint)
|
|
|
{
|
|
|
- CPoint itrPoint = itr.second;
|
|
|
- if (IsInPolygonMeasureArea(itrPoint, sizeImage, ptPolygon))
|
|
|
+
|
|
|
+ switch (distributionMode)
|
|
|
{
|
|
|
- m_listFieldCentrePoints.push_back(itr.second);
|
|
|
-
|
|
|
+ case 0://center in
|
|
|
+ if (IsInPolygonMeasureArea(itr.second, sizeImage, ptPolygon))
|
|
|
+ {
|
|
|
+ m_listFieldCentrePoints.push_back(itr.second);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 1://partly in ,all field will cover all the measure area
|
|
|
+ if (IsPartlyInPolygonMeasureArea(itr.second, sizeImage, ptPolygon))
|
|
|
+ {
|
|
|
+ m_listFieldCentrePoints.push_back(itr.second);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 2://totally in, field is totally in the measure area
|
|
|
+ if (IsTotallyInPolygonMeasureArea(itr.second, sizeImage, ptPolygon))
|
|
|
+ {
|
|
|
+ m_listFieldCentrePoints.push_back(itr.second);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -362,7 +380,7 @@ namespace OTSIMGPROC {
|
|
|
m_listFieldCentrePoints.push_back(itr.second);
|
|
|
}
|
|
|
break;
|
|
|
- case 1://partly in , field will cover all the measure area
|
|
|
+ case 1://partly in ,all field will cover all the measure area
|
|
|
if (IsPartlyInMeasureArea(itr.second, sizeImage))
|
|
|
{
|
|
|
m_listFieldCentrePoints.push_back(itr.second);
|
|
|
@@ -438,43 +456,111 @@ namespace OTSIMGPROC {
|
|
|
return TRUE;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ // this field is not in the area at all, return FALSE.
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+ BOOL CFieldMgr::IsPartlyInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon)
|
|
|
+ {
|
|
|
+ // check measure area parameter
|
|
|
+ ASSERT(m_pMeasureArea);
|
|
|
+ if (!m_pMeasureArea)
|
|
|
+ {
|
|
|
+ // shouldn't happen
|
|
|
+ LogErrorTrace(__FILE__, __LINE__, _T("IsInDomainArea: invalid measure area parameter."));
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // test field centre point first
|
|
|
+ if (PtInPolygon(a_poiField, ptPolygon))
|
|
|
+ {
|
|
|
+ // centre in the measure domain area, return TRUE
|
|
|
+ return TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
// get measure field centre
|
|
|
- //CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
|
|
|
+ CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
|
|
|
|
|
|
- //// move to left top postion.
|
|
|
- //a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
|
|
|
+ // 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);
|
|
|
+ // rectangle of the field
|
|
|
+ CRect rectFiled(a_poiField, a_sizeImageSize);
|
|
|
|
|
|
|
|
|
- // // on the top left side, need to test the bottom right corner
|
|
|
- // if (PtInPolygon(CPoint(rectFiled.right, rectFiled.top), ptPolygon))
|
|
|
- // {
|
|
|
- // return TRUE;
|
|
|
- // }
|
|
|
+ // on the top left side, need to test the bottom right corner
|
|
|
+ if (PtInPolygon(CPoint(rectFiled.right, rectFiled.top), ptPolygon))
|
|
|
+ {
|
|
|
+ return TRUE;
|
|
|
+ }
|
|
|
|
|
|
- // // on the bottom left side, need to test the top right corner
|
|
|
- // if (PtInPolygon(rectFiled.BottomRight(), ptPolygon))
|
|
|
- // {
|
|
|
- // return TRUE;
|
|
|
- // }
|
|
|
+ // on the bottom left side, need to test the top right corner
|
|
|
+ if (PtInPolygon(rectFiled.BottomRight(), ptPolygon))
|
|
|
+ {
|
|
|
+ return TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // on the top left side, need to test the bottom right corner
|
|
|
+ if (PtInPolygon(rectFiled.TopLeft(), ptPolygon))
|
|
|
+ {
|
|
|
+ return TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // on the bottom left side, need to test the top right corner
|
|
|
+ if (PtInPolygon(CPoint(rectFiled.left, rectFiled.bottom), ptPolygon))
|
|
|
+ {
|
|
|
+ return TRUE;
|
|
|
+ }
|
|
|
|
|
|
- // // on the top left side, need to test the bottom right corner
|
|
|
- // if (PtInPolygon(rectFiled.TopLeft(), ptPolygon))
|
|
|
- // {
|
|
|
- // return TRUE;
|
|
|
- // }
|
|
|
-
|
|
|
- // // on the bottom left side, need to test the top right corner
|
|
|
- // if (PtInPolygon(CPoint(rectFiled.left, rectFiled.bottom), ptPolygon))
|
|
|
- // {
|
|
|
- // return TRUE;
|
|
|
- // }
|
|
|
-
|
|
|
// this field is not in the area at all, return FALSE.
|
|
|
return FALSE;
|
|
|
}
|
|
|
+ BOOL CFieldMgr::IsTotallyInPolygonMeasureArea(CPoint a_poiField, CSize a_sizeImageSize, std::vector<CPoint> ptPolygon)
|
|
|
+ {
|
|
|
+ // check measure area parameter
|
|
|
+ ASSERT(m_pMeasureArea);
|
|
|
+ if (!m_pMeasureArea)
|
|
|
+ {
|
|
|
+ // shouldn't happen
|
|
|
+ LogErrorTrace(__FILE__, __LINE__, _T("IsInDomainArea: invalid measure area parameter."));
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 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);
|
|
|
+
|
|
|
+
|
|
|
+ // on the top left side, need to test the bottom right corner
|
|
|
+ if (!PtInPolygon(CPoint(rectFiled.right, rectFiled.top), ptPolygon))
|
|
|
+ {
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // on the bottom left side, need to test the top right corner
|
|
|
+ if (!PtInPolygon(rectFiled.BottomRight(), ptPolygon))
|
|
|
+ {
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // on the top left side, need to test the bottom right corner
|
|
|
+ if (!PtInPolygon(rectFiled.TopLeft(), ptPolygon))
|
|
|
+ {
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ // on the bottom left side, need to test the top right corner
|
|
|
+ if (!PtInPolygon(CPoint(rectFiled.left, rectFiled.bottom), ptPolygon))
|
|
|
+ {
|
|
|
+ return FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return TRUE;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//function:judge whether the point p is in the polygon ptPolygon
|
|
|
@@ -561,7 +647,7 @@ namespace OTSIMGPROC {
|
|
|
}
|
|
|
|
|
|
// get measure field centre
|
|
|
- CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
|
|
|
+ //CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
|
|
|
|
|
|
// move to left top postion.
|
|
|
a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
|
|
|
@@ -606,7 +692,7 @@ namespace OTSIMGPROC {
|
|
|
}
|
|
|
|
|
|
// get measure field centre
|
|
|
- CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
|
|
|
+ //CPoint poiMsrAreaCentre = m_pMeasureArea->GetDomainCenter();
|
|
|
|
|
|
// move to left top postion.
|
|
|
a_poiField -= CPoint(a_sizeImageSize.cx / 2, a_sizeImageSize.cy / 2);
|