dan::Object<iDataPlugin::iDataPluginApp> adapter(NIL);

dan::Vector<dan::Object<iDataPlugin::IPGDataBase> > databaselist = adapter->getCurrentDataBases();
if (databaselist.size() == 0)
{
return;
}
QMap<QString, dan::Object<iDataPlugin::IPGDataBase> > databasemap;
QMap<QString, dan::Vector<dan::Object<iDataPlugin::IPGLayer> > > databaselayermap;
for (int i = 0; i < databaselist.size(); ++i)
{
dan::Object<iDataPlugin::IPGDataBase> database;
database = databaselist[i];
databasemap.insert(SDFUN::ds2qs(database->DbFilename()), database);
dan::Vector<dan::Object<iDataPlugin::IPGLayer> > layerlist = database->getLayerlist();
databaselayermap.insert(SDFUN::ds2qs(database->DbFilename()), layerlist);
}

SelectLayerdlg dlg(databasemap, databaselayermap, 2);
if (QDialog::Rejected == dlg.exec())
{
return;
}
auto its = dlg.Sel_databasemap.begin();
for (; its != dlg.Sel_databasemap.end(); ++its)
{
dan::Object<iDataPlugin::IPGDataBase> dataBase = its.value();

//iDataDataBase *curdb = new iDataDataBase(its.value());
dan::Vector<dan::Object<iDataPlugin::IPGLayer> > layerlistsel = dlg.Sel_databaselayermap.value(its.key());
for (int i = 0; i < layerlistsel.size(); ++i)
{
dan::Object<iDataPlugin::IPGLayer> ipglayer = layerlistsel.at(i);
dan::Object<iDataPlugin::IPGLayer> copyLayer = dataBase->copyLayer(ipglayer, dan::DString("%1_SharpAngleChecked").arg(ipglayer->layerName()), false);
if (copyLayer == NULL)
continue;
dan::Object<iDataPlugin::IPGEntityCursor> layercursor = ipglayer->getEntitys();
dan::Object<iDataPlugin::IPGEntity> pent = layercursor->next();
dan::Vector<dan::Object<iDataPlugin::IPGTempEntity>>tempEnts;

while (pent.valid())
{
int checkResult = 2;
dan::Vector<dan::Vector<dan::Point3DF> > pentNodesPoint = pent->getNodes();
for (int m = 1; m < pentNodesPoint.size(); m++)
{
for (int j = 1; j < pentNodesPoint[i].size()-2; j++)
{
QPointF pointA, pointB, pointC;
pointA.setX(pentNodesPoint[m][j].x());
pointA.setY(pentNodesPoint[m][j].y());
pointB.setX(pentNodesPoint[m][j + 1].x());
pointB.setY(pentNodesPoint[m][j + 1].y());
pointC.setX(pentNodesPoint[m][j + 2].x());
pointC.setY(pentNodesPoint[m][j + 2].y());
QLineF lineAB, LineBC;
lineAB.setP1(pointA);
lineAB.setP2(pointB);
LineBC.setP1(pointB);
LineBC.setP2(pointC);
double angleAC = lineAB.angle(LineBC); // angleAC为三个点的角度;
if (angleAC < 5) //小于1度则认为是尖角;
{
checkResult = 0;
}
}
}
if (checkResult == 0)
{
dan::Object<iDataPlugin::IPGTempEntity>tempEnt(NIL);
tempEnt->setType(iDataPlugin::EntityType_Polygon);
tempEnt->setNodes(pent->getNodes());
tempEnt->setXDatas(pent->getXDatas());
tempEnts.push_back(tempEnt);
if (tempEnts.size() >= 5000)
{
dataBase->appendEntityToDatabase(copyLayer, tempEnts);
tempEnts.clear();
}
}
pent = layercursor->next();
}
if (tempEnts.size() >= 0)
{
dataBase->appendEntityToDatabase(copyLayer, tempEnts);
tempEnts.clear();
}


}
}
QMessageBox::about(NULL, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("筛选完毕"));