📄 polygon.cpp
字号:
///////////////////////////////////////////////////////////
// Polygon.cpp
// Implementation of the Class Polygon
// Created on: 18-二月-2009 17:17:22
// Original author: pangyj
///////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "Polygon.h"
#include "Layer.h"
#include "Line2D.h"
Polygon::~Polygon(){
}
Polygon::Polygon(const lit_list<Point2D> & vertexPts):GeometryPrimitive(){
}
Polygon::Polygon():GeometryPrimitive(){
}
const lit_list<Point2D> & Polygon::AddvertexAt(int pos, Point2D& pt){
return lVertexPts;
}
ErrorStatus Polygon::read(fstream& f){
return eOk;
}
ErrorStatus Polygon::vertexPts(lit_list<Point2D> & pts){
return eOk;
}
ErrorStatus Polygon::write(fstream& f){
return eOk;
}
void Polygon::list()const
{
cout<<"========================="<<endl;
cout <<"type = Polygon ";
GeometryPrimitive::list();
EntityObject::list();
lit_node<Point2D> *pCurNode = lVertexPts.get_head();
int i = 0;
cout<< "vertex pts = " << lVertexPts.count()<<endl;
while (pCurNode)
{
cout<<i<<" ("<<pCurNode->get_value().x<<","<<pCurNode->get_value().y<<")"<<endl;
++i;
pCurNode = pCurNode->next();
}
}
ErrorStatus Polygon::explode(lit_list<unsigned long> & ids)
{
Layer * pLayer = NULL;
if (curModelSpace()->open((EntityObject*&)pLayer,uLayerId,forRead) != eOk)
{
ids.clear();
return eOk;
}
//////////////////////////////////////////////////////////////////////////
lit_node<Point2D> *pt = this->lVertexPts.get_head();
Point2D sPt,ePt;
sPt = pt->get_value();
while (pt != lVertexPts.get_tail())
{
pt = pt->next();
ePt = pt->get_value();
Line2D * pLine = new Line2D(ePt,sPt);
if (pLine)
{
unsigned long lineId = NULLID;
if ((lineId = curModelSpace()->AddObjectToModelSpace((EntityObject*&)pLine)) == NULLID)
{
ids.clear();
return eError;
}
pLine->layerId(uLayerId);
ids.addNode(lineId);
pLayer->AddSubEntity(lineId);
}
sPt = ePt;
}
sPt = lVertexPts.get_head()->get_value();
ePt = lVertexPts.get_tail()->get_value();
Line2D * pLine = new Line2D(ePt,sPt);
if (pLine)
{
unsigned long lineId = NULLID;
if ((lineId = curModelSpace()->AddObjectToModelSpace((EntityObject*&)pLine)) == NULLID)
{
ids.clear();
return eError;
}
pLine->layerId(uLayerId);
ids.addNode(lineId);
pLayer->AddSubEntity(lineId);
}
curModelSpace()->erase(uLayerId);
return eOk;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -