STDMETHODIMP CExample1::Compute(IAgStkRadarClutterGeometryComputeParams* computeParams)
{
EX_BEGIN_PARAMS()
EX_IN_INTERFACE_PARAM(computeParams)
EX_END_PARAMS()
HRESULT hr = S_OK;
Try
{
CComPtr pRadarLink;
EXCEPTION_HR(computeParams->get_RadarLink(&pRadarLink));
CComPtr pRadarLinkGeom;
EXCEPTION_HR(pRadarLink->get_Geometry(&pRadarLinkGeom));
CComPtr pXmtRdrPosVel;
EXCEPTION_HR(pRadarLinkGeom->get_TransmitRadarPosVelProvider(&pXmtRdrPosVel));
CartVec xmtRdrPosCBF;
EXCEPTION_HR(pXmtRdrPosVel->GetPositionCBF(&xmtRdrPosCBF.x, &xmtRdrPosCBF.y, &xmtRdrPosCBF.z));
EXCEPTION_HR(m_pCbIntersectComputeParams->SetBasePositionCBF(xmtRdrPosCBF.x, xmtRdrPosCBF.y, xmtRdrPosCBF.z));
CComPtr pPatchCollection;
EXCEPTION_HR(computeParams->get_ClutterPatches(&pPatchCollection));
VARIANT_BOOL intersectFound;
Double sinOffset = sin(AgCHALFPI - m_offsetAngle);
Double cosOffset = cos(AgCHALFPI - m_offsetAngle);
//============================== First Point Start ======================================================
CartVec pt1Cbf;
EXCEPTION_HR(pXmtRdrPosVel->ConvertBodyCartesianToCBFCartesian(cosOffset, 0.0, sinOffset, &pt1Cbf.x, &pt1Cbf.y, &pt1Cbf.z));
EXCEPTION_HR(m_pCbIntersectComputeParams->SetDirectionCBF(pt1Cbf.x, pt1Cbf.y, pt1Cbf.z));
CComPtr pIntersectResult1;
EXCEPTION_HR(pXmtRdrPosVel->ComputeCentralBodyIntersect(m_pCbIntersectComputeParams, &pIntersectResult1));
EXCEPTION_HR(pIntersectResult1->get_IntersectionFound(&intersectFound));
If(intersectFound == VARIANT_TRUE)
{
CComPtr pClutterPatch;
EXCEPTION_HR(pPatchCollection->Add(&pClutterPatch));
CartVec intersectPt;
EXCEPTION_HR(pIntersectResult1->GetIntercept1CBF(&intersectPt.x, &intersectPt.y, &intersectPt.z));
EXCEPTION_HR(pClutterPatch->SetPositionCBF(intersectPt.x, intersectPt.y, intersectPt.z));
EXCEPTION_HR(pClutterPatch->put_Area(m_patchArea));
}
//============================== Second Point Start ======================================================
CartVec pt2Cbf;
EXCEPTION_HR(pXmtRdrPosVel->ConvertBodyCartesianToCBFCartesian(-cosOffset, 0.0, sinOffset, &pt2Cbf.x, &pt2Cbf.y, &pt2Cbf.z));
EXCEPTION_HR(m_pCbIntersectComputeParams->SetDirectionCBF(pt2Cbf.x, pt2Cbf.y, pt2Cbf.z));
CComPtr pIntersectResult2;
EXCEPTION_HR(pXmtRdrPosVel->ComputeCentralBodyIntersect(m_pCbIntersectComputeParams, &pIntersectResult2));
EXCEPTION_HR(pIntersectResult2->get_IntersectionFound(&intersectFound));
If(intersectFound == VARIANT_TRUE)
{
CComPtr pClutterPatch;
EXCEPTION_HR(pPatchCollection->Add(&pClutterPatch));
CartVec intersectPt;
EXCEPTION_HR(pIntersectResult2->GetIntercept1CBF(&intersectPt.x, &intersectPt.y, &intersectPt.z));
EXCEPTION_HR(pClutterPatch->SetPositionCBF(intersectPt.x, intersectPt.y, intersectPt.z));
EXCEPTION_HR(pClutterPatch->put_Area(m_patchArea));
}
//============================== Third Point Start ======================================================
CartVec pt3Cbf;
EXCEPTION_HR(pXmtRdrPosVel->ConvertBodyCartesianToCBFCartesian(0.0, cosOffset, sinOffset, &pt3Cbf.x, &pt3Cbf.y, &pt3Cbf.z));
EXCEPTION_HR(m_pCbIntersectComputeParams->SetDirectionCBF(pt3Cbf.x, pt3Cbf.y, pt3Cbf.z));
CComPtr pIntersectResult3;
EXCEPTION_HR(pXmtRdrPosVel->ComputeCentralBodyIntersect(m_pCbIntersectComputeParams, &pIntersectResult3));
EXCEPTION_HR(pIntersectResult3->get_IntersectionFound(&intersectFound));
If(intersectFound == VARIANT_TRUE)
{
CComPtr pClutterPatch;
EXCEPTION_HR(pPatchCollection->Add(&pClutterPatch));
CartVec intersectPt;
EXCEPTION_HR(pIntersectResult3->GetIntercept1CBF(&intersectPt.x, &intersectPt.y, &intersectPt.z));
EXCEPTION_HR(pClutterPatch->SetPositionCBF(intersectPt.x, intersectPt.y, intersectPt.z));
EXCEPTION_HR(pClutterPatch->put_Area(m_patchArea));
}
//============================== Fourth Point Start ======================================================
CartVec pt4Cbf;
EXCEPTION_HR(pXmtRdrPosVel->ConvertBodyCartesianToCBFCartesian(0.0, -cosOffset, sinOffset, &pt4Cbf.x, &pt4Cbf.y, &pt4Cbf.z));
EXCEPTION_HR(m_pCbIntersectComputeParams->SetDirectionCBF(pt4Cbf.x, pt4Cbf.y, pt4Cbf.z));
CComPtr pIntersectResult4;
EXCEPTION_HR(pXmtRdrPosVel->ComputeCentralBodyIntersect(m_pCbIntersectComputeParams, &pIntersectResult4));
EXCEPTION_HR(pIntersectResult4->get_IntersectionFound(&intersectFound));
If(intersectFound == VARIANT_TRUE)
{
CComPtr pClutterPatch;
EXCEPTION_HR(pPatchCollection->Add(&pClutterPatch));
CartVec intersectPt;
EXCEPTION_HR(pIntersectResult4->GetIntercept1CBF(&intersectPt.x, &intersectPt.y, &intersectPt.z));
EXCEPTION_HR(pClutterPatch->SetPositionCBF(intersectPt.x, intersectPt.y, intersectPt.z));
EXCEPTION_HR(pClutterPatch->put_Area(m_patchArea));
}
}
Catch( HRESULT r )
{
hr = r;
}
Catch(...)
{
hr = E_FAIL;
}
Return hr;
}
|
|