(safe_deletevec是宏定义,如果指针不等于NULL,就删除并置NULL),就会报错,说是写入冲突,应该没有越界,可是就是想不通为什么出错,麻烦各位给些建议
short Nobone=m_sMinValue+50;
int m_nValueMax=0;
for(int i = 0; i < m_nOriImagePiece; i++)
{
int k = i*m_nWidth*m_nHeight;
for (int m = 0; m < m_nHeight; m++)
{
int v = m*m_nWidth + k;
for (int n = 0; n < m_nWidth; n++)
{
int a = ((short*)m_pProcessArray->GetDcmArray()[i]->GetData())[m_nWidth*m + n];
if (a>Nobone)
{
short m_nRadi = EDTdate[v+n];
if (m_nRadi>m_nValueMax)
m_nValueMax = m_nRadi;
}
}
}
}
m_nValueMax = m_nValueMax + 1;
short* occurs = new short[m_nValueMax];
memset(occurs , 0 ,sizeof(short)*m_nValueMax);
for(int i = 0; i < m_nOriImagePiece; i++)
{
int k = i*m_nWidth*m_nHeight;
for (int m = 0; m < m_nHeight; m++)
{
int v = m*m_nWidth + k;
for (int n = 0; n < m_nWidth; n++)
{
int a = ((short*)m_pProcessArray->GetDcmArray()[i]->GetData())[m_nWidth*m + n];
if (a>Nobone)
{
short m_nRadi = EDTdate[v+n];
occurs[m_nRadi] = 1;
}
}
}
}
numRadii = 0;
for (int i=0;i<m_nValueMax;i++)
{
if (occurs[i])
numRadii++;
}
//make an index of the distance-squared values
short* distSqIndex = new short[m_nValueMax];
memset(distSqIndex,0,sizeof(short)*m_nValueMax);
short* distSqValues = new short[numRadii];
memset(distSqValues,0,sizeof(short)*numRadii);
int indDs = 0;
for (int i=0;i<m_nValueMax;i++)
{
if (occurs[i])
{
distSqIndex[i] = indDs;
distSqValues[indDs++]=i;
}
}
Safe_DeleteVec(occurs);