299 lines
6.7 KiB
C++
299 lines
6.7 KiB
C++
#include "stdafx.h"
|
|
|
|
#include "InterStruct.h"
|
|
#include "RoolBackNew.h"
|
|
#include "CADEntEdgeAdapter.h"
|
|
|
|
|
|
void CCADEntEdgeAdapter::AddInterStruct(CInterStruct *pInter)
|
|
{
|
|
m_arInterStruct.append(pInter);
|
|
}
|
|
|
|
|
|
// 一条路边被截取为多段interStruct;重新生成该路边的时候,每段保留与否
|
|
// 与判断保留与否相关的标记有以下:
|
|
// DongFlag:该路段是否被处理了。
|
|
// Attached:该路段为相关路段,即两端同时和当前道路相交,
|
|
// InRoadFlag:该路段在当前道路的内部
|
|
void CCADEntEdgeAdapter::ReCreate()
|
|
{
|
|
if (!NeedReCreate())
|
|
return;
|
|
|
|
this->RoolBackErase();
|
|
|
|
int iarLen = (int)m_arInterStruct.length();
|
|
int i = 0;
|
|
for ( i = iarLen - 1; i >= 0; i--)
|
|
{
|
|
if (m_arInterStruct[i]->IsShort())
|
|
m_arInterStruct.removeAt(i);
|
|
}
|
|
|
|
// 设置处于道路中间的done标记,
|
|
// 如果道路中间的道路两端都没有设置done标记,该段道路需要绘制。
|
|
iarLen = (int)m_arInterStruct.length();
|
|
i = 0;
|
|
for (i = 0; i < iarLen; i++)
|
|
{
|
|
if (!m_arInterStruct[i]->IsInRoad())
|
|
continue;
|
|
else
|
|
{
|
|
bool bPrevDone = false, bNextDone = false;
|
|
if (i > 0)
|
|
bPrevDone = m_arInterStruct[i -1]->IsDone();
|
|
if (i < iarLen - 1)
|
|
bNextDone = m_arInterStruct[i + 1]->IsDone();
|
|
|
|
if (!bPrevDone && !bNextDone)
|
|
m_arInterStruct[i]->SetDoneFlag(true);
|
|
}
|
|
}
|
|
|
|
// 检测AttachInter,执行合并,并且对非inRoadStruct设置done标记
|
|
for (i = iarLen - 1; i >= 0; i--)
|
|
{
|
|
if (m_arInterStruct[i]->AttachedStruct() != NULL)
|
|
{
|
|
ASSERT(m_arInterStruct[i]->AttachedStruct() == m_arInterStruct[i-1]);
|
|
|
|
m_arInterStruct[i]->CombinAttachInterStruct();
|
|
m_arInterStruct[i]->SetDoneFlag(true);
|
|
m_arInterStruct.removeAt(--i);
|
|
}
|
|
}
|
|
|
|
iarLen = (int)m_arInterStruct.length();
|
|
|
|
AcAryInterStructPointer arInterStructDump;
|
|
CInterStruct *pCurr = NULL;
|
|
// 合并绘制道路,并且添加到arInterStructDump;
|
|
for (i = 0; i < iarLen; i++)
|
|
{
|
|
if (pCurr == NULL)
|
|
{
|
|
if (m_arInterStruct[i]->IsDone() || !m_arInterStruct[i]->IsInRoad())
|
|
{ // 当前没有pCurr,
|
|
pCurr = m_arInterStruct[i];
|
|
arInterStructDump.append(pCurr);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_arInterStruct[i]->IsDone() || !m_arInterStruct[i]->IsInRoad())
|
|
{
|
|
if (!pCurr->CombinInterStrcutInSequence(m_arInterStruct[i]))
|
|
{
|
|
pCurr = m_arInterStruct[i];
|
|
arInterStructDump.append(m_arInterStruct[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pCurr = NULL;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 生成
|
|
for (iarLen = (int)arInterStructDump.length(), i = 0; i < iarLen; i++)
|
|
{
|
|
arInterStructDump[i]->SimpleCreate();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CLineCADEntEdgeAdapter::RoolBackErase()
|
|
{
|
|
RoolBackAddRemoveData(&m_lineEnt);
|
|
}
|
|
|
|
void CArcCADEntEdgeAdapter::RoolBackErase()
|
|
{
|
|
RoolBackAddRemoveData(&m_arcEnt);
|
|
}
|
|
|
|
void CArcCADEntEdgeAdapter::ReCreateForLandScape()
|
|
{
|
|
if (!NeedReCreate())
|
|
return;
|
|
|
|
this->RoolBackErase();
|
|
|
|
int iarLen = (int)m_arInterStruct.length();
|
|
int i = 0;
|
|
for ( i = iarLen - 1; i >= 0; i--)
|
|
{
|
|
if (m_arInterStruct[i]->IsShort())
|
|
m_arInterStruct.removeAt(i);
|
|
}
|
|
|
|
// 设置处于道路中间的done标记,
|
|
// 如果道路中间的道路两端都没有设置done标记,该段道路需要绘制。
|
|
iarLen = (int)m_arInterStruct.length();
|
|
i = 0;
|
|
for (i = 0; i < iarLen; i++)
|
|
{
|
|
if (!m_arInterStruct[i]->IsInRoad())
|
|
continue;
|
|
else
|
|
{
|
|
bool bPrevDone = false, bNextDone = false;
|
|
if (i > 0)
|
|
bPrevDone = m_arInterStruct[i -1]->IsDone();
|
|
if (i < iarLen - 1)
|
|
bNextDone = m_arInterStruct[i + 1]->IsDone();
|
|
|
|
if (!bPrevDone && !bNextDone)
|
|
m_arInterStruct[i]->SetDoneFlag(true);
|
|
}
|
|
}
|
|
|
|
// 检测AttachInter,执行合并,并且对非inRoadStruct设置done标记
|
|
for (i = iarLen - 1; i >= 0; i--)
|
|
{
|
|
if (m_arInterStruct[i]->AttachedStruct() != NULL)
|
|
{
|
|
ASSERT(m_arInterStruct[i]->AttachedStruct() == m_arInterStruct[i-1]);
|
|
|
|
m_arInterStruct[i]->CombinAttachInterStruct();
|
|
m_arInterStruct[i]->SetDoneFlag(true);
|
|
m_arInterStruct.removeAt(--i);
|
|
}
|
|
}
|
|
|
|
iarLen = (int)m_arInterStruct.length();
|
|
|
|
AcAryInterStructPointer arInterStructDump;
|
|
CInterStruct *pCurr = NULL;
|
|
// 合并绘制道路,并且添加到arInterStructDump;
|
|
for (i = 0; i < iarLen; i++)
|
|
{
|
|
if (pCurr == NULL)
|
|
{
|
|
if (m_arInterStruct[i]->IsDone() || !m_arInterStruct[i]->IsInRoad())
|
|
{ // 当前没有pCurr,
|
|
pCurr = m_arInterStruct[i];
|
|
pCurr->SetGroupId(m_GroupId);
|
|
pCurr->SetIsVisible(m_bIsVisible);
|
|
arInterStructDump.append(pCurr);
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_arInterStruct[i]->IsDone() || !m_arInterStruct[i]->IsInRoad())
|
|
{
|
|
if (!pCurr->CombinInterStrcutInSequence(m_arInterStruct[i]))
|
|
{
|
|
pCurr = m_arInterStruct[i];
|
|
pCurr->SetGroupId(m_GroupId);
|
|
pCurr->SetIsVisible(m_bIsVisible);
|
|
arInterStructDump.append(m_arInterStruct[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pCurr = NULL;
|
|
}
|
|
}
|
|
}
|
|
for (iarLen = (int)arInterStructDump.length(), i = 0; i < iarLen; i++)
|
|
{
|
|
((CArcInterStruct*)arInterStructDump[i])->SimpleCreateForLandScape();
|
|
}
|
|
}
|
|
|
|
void CLineCADEntEdgeAdapter::ReCreateForLandScape()
|
|
{
|
|
if (!NeedReCreate())
|
|
return;
|
|
|
|
this->RoolBackErase();
|
|
|
|
int iarLen = (int)m_arInterStruct.length();
|
|
int i = 0;
|
|
for ( i = iarLen - 1; i >= 0; i--)
|
|
{
|
|
if (m_arInterStruct[i]->IsShort())
|
|
m_arInterStruct.removeAt(i);
|
|
}
|
|
|
|
// 设置处于道路中间的done标记,
|
|
// 如果道路中间的道路两端都没有设置done标记,该段道路需要绘制。
|
|
iarLen = (int)m_arInterStruct.length();
|
|
i = 0;
|
|
for (i = 0; i < iarLen; i++)
|
|
{
|
|
if (!m_arInterStruct[i]->IsInRoad())
|
|
continue;
|
|
else
|
|
{
|
|
bool bPrevDone = false, bNextDone = false;
|
|
if (i > 0)
|
|
bPrevDone = m_arInterStruct[i -1]->IsDone();
|
|
if (i < iarLen - 1)
|
|
bNextDone = m_arInterStruct[i + 1]->IsDone();
|
|
|
|
if (!bPrevDone && !bNextDone)
|
|
m_arInterStruct[i]->SetDoneFlag(true);
|
|
}
|
|
}
|
|
|
|
// 检测AttachInter,执行合并,并且对非inRoadStruct设置done标记
|
|
for (i = iarLen - 1; i >= 0; i--)
|
|
{
|
|
if (m_arInterStruct[i]->AttachedStruct() != NULL)
|
|
{
|
|
ASSERT(m_arInterStruct[i]->AttachedStruct() == m_arInterStruct[i-1]);
|
|
|
|
m_arInterStruct[i]->CombinAttachInterStruct();
|
|
m_arInterStruct[i]->SetDoneFlag(true);
|
|
m_arInterStruct.removeAt(--i);
|
|
}
|
|
}
|
|
|
|
iarLen = (int)m_arInterStruct.length();
|
|
|
|
AcAryInterStructPointer arInterStructDump;
|
|
CInterStruct *pCurr = NULL;
|
|
// 合并绘制道路,并且添加到arInterStructDump;
|
|
for (i = 0; i < iarLen; i++)
|
|
{
|
|
if (pCurr == NULL)
|
|
{
|
|
if (m_arInterStruct[i]->IsDone() || !m_arInterStruct[i]->IsInRoad())
|
|
{ // 当前没有pCurr,
|
|
pCurr = m_arInterStruct[i];
|
|
pCurr->SetGroupId(m_GroupId);
|
|
pCurr->SetIsVisible(m_bIsVisible);
|
|
arInterStructDump.append(pCurr);
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_arInterStruct[i]->IsDone() || !m_arInterStruct[i]->IsInRoad())
|
|
{
|
|
if (!pCurr->CombinInterStrcutInSequence(m_arInterStruct[i]))
|
|
{
|
|
pCurr = m_arInterStruct[i];
|
|
pCurr->SetGroupId(m_GroupId);
|
|
pCurr->SetIsVisible(m_bIsVisible);
|
|
arInterStructDump.append(m_arInterStruct[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pCurr = NULL;
|
|
}
|
|
}
|
|
}
|
|
for (iarLen = (int)arInterStructDump.length(), i = 0; i < iarLen; i++)
|
|
{
|
|
((CLineInterStruct*)arInterStructDump[i])->SimpleCreateForLandScape();
|
|
}
|
|
} |