[從頭讀歷史] 第307節 星球戰爭 BC2699 至 BC2600(公元前27世紀)

來源:本網整理

1、古代:170萬年前-1840年中國古代史經歷了以下幾個階段:原始社會(170萬年前-公元前2070年)、奴隸社會(公元前2070年-公元前476年)和封建社會。其中封建社會可分為五個階段:戰國、秦、漢是封建社會形成和初步發展階段。三國、兩晉、南北朝,是封建國家分裂和民族大融合的階段。隋唐五代時期是封建社會的繁榮階段。遼、宋、夏、金、元,是民族融合進一步加強和封建經濟繼續發展的階段。明、清,是統一的多民族國家鞏固和封建制度漸趨衰落階段。2、近代:1840年-1949年中國近代史是從第一次鴉片戰爭1840年到1949年南京國民黨政權覆亡為止、中華人民共和國成立的歷史。歷經清王朝晚期、中華民國臨時政府時期、北洋軍閥時期和國民政府時期,是中國半殖民地半封建社會逐漸形成到瓦解的歷史。中國近代史,是一部充滿災難、落后挨打的屈辱史,是一部中國人民探索救國之路,實現自由、民主的探索史,是一部中華民族抵抗侵略,打倒帝國主義以實現民族解放、打倒封建主義以實現人民富強的斗爭史。中國近代史可以分為兩個階段。第一個階段是從1840年鴉片戰爭到1919年五四運動前夕,是舊民主主義革命階段;第二個階段是從1919年五四運動到1949年中華人民共和國成立前夕,是新民主主義革命階段。3、現代:1949至今中國現代史是指1949年10月中華人民共和國成立至今的歷史,分為新民主主義社會與社會主義社會兩大歷史階段。這一時期也是中國人民建立政權、鞏固政權、探索與發展中國,使中國走向富強、民主、自立的一段發展史。擴展資料中國各歷史階段的劃分依據以生產力發展水平為主,包括政治制度,文化水平,以及某個重大歷史事件為輔。1840年鴉片戰爭結束了我國幾千年來的封建社會制度,中國開始淪為半殖民地半封建社會,遭受列強的侵略;1949年中華人民共和國成立,民族獨立和解放,是劃分近代和現代的依據。參考資料:百度百科-中國歷史年表www.13333515.buzz防采集請勿采集本網。

劇情提要:

最初的時候是原始時期戰爭,所謂原始時期,指的是約公元前30世紀—前22世紀。

在那里生活看守著這些歷史保存下來,政府為達到目的發動了戰爭,那些人還沒來的急反擊就被政府全部消滅了,為了隱藏他們的邪惡之心把這一百年所有的資料全部銷毀》這可能就是政府為什么不讓太多人知道歷史

公元前27世紀,沒有發生什么有記錄的戰爭。

緬懷先烈 銘記歷史 歷史的車輪滾滾向前,載著中華兒女炎黃子孫,一路上坎坎坷坷,曲曲折折。在這條不凡的道路上,留下的深深車轍永遠記載著那段刻骨銘心的崢嶸歲月,永遠記載著那些永垂不朽的

正劇開始:

綠燈部隊和兩位超人一起前來阻止,三個超人一同穿過原氪星所在地的紅色太陽,全都失去了大部分能力。在地球上,集合起來的反派們發動總攻,同英雄們展開了混戰。擴展資料《無限危機》的介紹 《無限地球

星歷2016年07月18日 11:40:04, 銀河系厄爾斯星球中華帝國江南行省。

鄧稼先 鄧稼先(1924年6月25日~1986年7月29日),身高183厘米,安徽懷寧人,著名核物理學家,中國科學院院士。一位偉大而倍受尊敬的物理學大師,我們每一位中國人都應該銘記的為祖國奉獻出一生的

[工程師阿偉]正在和[機器小偉]一起研究[星球戰爭 BC2699 至 BC2600(公元前27世紀)]。

你想知道以前的還是現在的?也沒說清楚!喬丹,“大鳥”… 去NBA官方網站或許有你想知道的東西

神農氏來找阿偉閑聊,談到他準備去攻打河北,那里有一個部落不服他。那個部落叫什么名字,

他沒有說。可能名字神馬的不是很重要吧。

然后神農氏嘆了口氣說,路途遙遠,要想去那里必須要有車,我費了很多心思,花了高價,

才從黑市上買到兩張車輛的制造圖紙。對方還不附說明書,意思是讓阿偉幫他參詳一下。

阿偉點頭同意,于是神農掏出了第一張圖紙:

<span style="font-size:18px;">///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/BowyerWatson.cpp#include "Point.h"#include "Line.h"#include "Triangle.h"#include "BowyerWatson.h"CBowyerWatson* CBowyerWatson::m_pBowyerWatson = NULL;CBowyerWatson::CBowyerWatson(){ClearBowyerWatson();}CBowyerWatson::~CBowyerWatson(){ClearBowyerWatson();}CBowyerWatson* CBowyerWatson::GetInstance(){if( !m_pBowyerWatson )m_pBowyerWatson = new CBowyerWatson;return m_pBowyerWatson;}void CBowyerWatson::ClearBowyerWatson(){m_bUpdateDrawFlag = false;std::list<CPoint*>::iterator iter_point =m_lstBowyerWatsonPointList.begin();while (iter_point != m_lstBowyerWatsonPointList.end()){std::list<CPoint*>::iterator iter_pointNext = iter_point;iter_pointNext++;SAFE_DELETE(*iter_point);m_lstBowyerWatsonPointList.erase(iter_point);iter_point = iter_pointNext;}//Pointstd::list<CLine*>::iterator iter_line =m_lstBowyerWatsonLineList.begin();while (iter_line != m_lstBowyerWatsonLineList.end()){std::list<CLine*>::iterator iter_lineNext = iter_line;iter_lineNext++;SAFE_DELETE(*iter_line);m_lstBowyerWatsonLineList.erase(iter_line);iter_line = iter_lineNext;}//linestd::list<CTriangle*>::iterator iter_triangle =m_lstBowyerWatsonTriangleList.begin();while (iter_triangle != m_lstBowyerWatsonTriangleList.end()){std::list<CTriangle*>::iterator iter_triangleNext = iter_triangle;iter_triangleNext++;SAFE_DELETE(*iter_triangle);m_lstBowyerWatsonTriangleList.erase(iter_triangle);iter_triangle = iter_triangleNext;}//Triangleiter_point = m_lstAddPointList.begin();while (iter_point != m_lstAddPointList.end()){std::list<CPoint*>::iterator iter_pointNext = iter_point;iter_pointNext++;SAFE_DELETE(*iter_point);m_lstAddPointList.erase(iter_point);iter_point = iter_pointNext;}//Point}void CBowyerWatson::CreateHelperPoint(CPoint pt1, CPoint pt2, CPoint pt3, CPoint pt4){mHelperPoints[0] = pt1;mHelperPoints[1] = pt2;mHelperPoints[2] = pt3;mHelperPoints[3] = pt4;//加入輔助點4個AddBowyerWatsonPoint(pt1);AddBowyerWatsonPoint(pt2);AddBowyerWatsonPoint(pt3);AddBowyerWatsonPoint(pt4);//加入輔助窗體的5條邊CLine line1 = CLine(pt1,pt2);CLine line2 = CLine(pt2,pt3);CLine line3 = CLine(pt3,pt4);CLine line4 = CLine(pt4,pt1);CLine line5 = CLine(pt2,pt4);AddBowyerWatsonLine(line1);AddBowyerWatsonLine(line2);AddBowyerWatsonLine(line3);AddBowyerWatsonLine(line4);AddBowyerWatsonLine(line5);//加入輔助三角形2個CTriangle tg1 = CTriangle(pt1,pt2,pt4);CTriangle tg2 = CTriangle(pt2,pt3,pt4);AddBowyerWatsonTriangle(tg1);AddBowyerWatsonTriangle(tg2);}void CBowyerWatson::AddNewPoint(CPoint pt){bool existflag = false;std::list<CPoint*>::iterator iter_point = m_lstAddPointList.begin();for ( ;iter_point != m_lstAddPointList.end();iter_point++){if (pt == (**iter_point)){existflag = true;}}if (!existflag){CPoint* newPoint = new CPoint(pt.x,pt.y);m_lstAddPointList.push_back(newPoint);}}void CBowyerWatson::UpdateNewPoint(){std::list<CPoint*>::iterator iter_point = m_lstAddPointList.begin();while (iter_point != m_lstAddPointList.end()){ProcessNewPoint(**iter_point);std::list<CPoint*>::iterator iter_pointNext = iter_point;iter_pointNext++;SAFE_DELETE(*iter_point);m_lstAddPointList.erase(iter_point);iter_point = iter_pointNext;}//Point//剔除輔助邊std::list<CLine*>::iterator iter = m_lstBowyerWatsonLineList.begin();while(iter != m_lstBowyerWatsonLineList.end()){CLine line = (**iter);if (line.CheckPointExist(mHelperPoints[0]) || line.CheckPointExist(mHelperPoints[1]) || \line.CheckPointExist(mHelperPoints[2]) || line.CheckPointExist(mHelperPoints[3])){std::list<CLine*>::iterator iter_next = iter;iter_next++;SAFE_DELETE(*iter);m_lstBowyerWatsonLineList.erase(iter);iter = iter_next;}else{iter++;}}//剔除輔助三角形std::list<CTriangle*>::iterator iter_triangle = m_lstBowyerWatsonTriangleList.begin();while(iter_triangle != m_lstBowyerWatsonTriangleList.end()){CTriangle triangle = (**iter_triangle);if (triangle.CheckPointExist(mHelperPoints[0]) || triangle.CheckPointExist(mHelperPoints[1]) || \triangle.CheckPointExist(mHelperPoints[2]) || triangle.CheckPointExist(mHelperPoints[3])){std::list<CTriangle*>::iterator iter_nextTriangle = iter_triangle;iter_nextTriangle++;SAFE_DELETE(*iter_triangle);m_lstBowyerWatsonTriangleList.erase(iter_triangle);iter_triangle = iter_nextTriangle;}else{iter_triangle++;}}}void CBowyerWatson::AddBowyerWatsonPoint(CPoint pt){bool existflag = false;std::list<CPoint*>::iterator iter_point = m_lstBowyerWatsonPointList.begin();for ( ;iter_point != m_lstBowyerWatsonPointList.end();iter_point++){if (pt == (**iter_point)){existflag = true;}}if (!existflag){CPoint* newPoint = new CPoint(pt.x,pt.y);m_lstBowyerWatsonPointList.push_back(newPoint);}}void CBowyerWatson::AddBowyerWatsonLine(CLine line){bool existflag = false;std::list<CLine*>::iterator iter_line = m_lstBowyerWatsonLineList.begin();for ( ;iter_line != m_lstBowyerWatsonLineList.end();iter_line++){if (line == (**iter_line)){existflag = true;}}if (!existflag){CLine* newLine = new CLine(line.p1,line.p2);m_lstBowyerWatsonLineList.push_back(newLine);}}void CBowyerWatson::DelBowyerWatsonLine(CLine line){std::list<CLine*>::iterator iter_line =m_lstBowyerWatsonLineList.begin();while (iter_line != m_lstBowyerWatsonLineList.end()){if (line == (**iter_line)){SAFE_DELETE(*iter_line);m_lstBowyerWatsonLineList.erase(iter_line);break;}elseiter_line++;}//linestd::list<CTriangle*>::iterator iter_Triangle =m_lstBowyerWatsonTriangleList.begin();while (iter_Triangle != m_lstBowyerWatsonTriangleList.end()){if ((*iter_Triangle)->l1 == line || (*iter_Triangle)->l2 == line || (*iter_Triangle)->l3 == line ){SAFE_DELETE(*iter_Triangle);m_lstBowyerWatsonTriangleList.erase(iter_Triangle);break;}elseiter_Triangle++;}//Triangle}void CBowyerWatson::AddBowyerWatsonTriangle(CTriangle triangle){bool existflag = false;std::list<CTriangle*>::iterator iter_Triangle = m_lstBowyerWatsonTriangleList.begin();for ( ;iter_Triangle != m_lstBowyerWatsonTriangleList.end();iter_Triangle++){if (triangle == (**iter_Triangle)){existflag = true;}}if (!existflag){CTriangle* newTriangle = new CTriangle(triangle.p1,triangle.p2,triangle.p3);m_lstBowyerWatsonTriangleList.push_back(newTriangle);}}void CBowyerWatson::DelBowyerWatsonTriangle(CTriangle triangle){std::list<CTriangle*>::iterator iter_Triangle =m_lstBowyerWatsonTriangleList.begin();while (iter_Triangle != m_lstBowyerWatsonTriangleList.end()){if (triangle == (**iter_Triangle)){SAFE_DELETE(*iter_Triangle);m_lstBowyerWatsonTriangleList.erase(iter_Triangle);return;}elseiter_Triangle++;}//line}void CBowyerWatson::ProcessNewPoint(CPoint pt){std::list<CLine*>lineList ;std::list<CTriangle*> triangleList;std::vector<CTriangle*> commonTriangleVector;std::list<CLine*>::iterator iter_line =m_lstBowyerWatsonLineList.begin();for(;iter_line != m_lstBowyerWatsonLineList.end();iter_line++){CLine* newline = new CLine();memcpy(newline, *iter_line, sizeof(CLine));lineList.push_back(newline);}std::list<CTriangle*>::iterator iter_triangle =m_lstBowyerWatsonTriangleList.begin();for(;iter_triangle != m_lstBowyerWatsonTriangleList.end();iter_triangle++){CTriangle* newtriangle = new CTriangle();memcpy(newtriangle, *iter_triangle, sizeof(CTriangle));triangleList.push_back(newtriangle);}iter_triangle = triangleList.begin();while (iter_triangle != triangleList.end()){//是否存在三角形外接圓內if ((*iter_triangle)->CheckInCircle(pt)){commonTriangleVector.push_back(*iter_triangle);}iter_triangle++;}// triangleif (commonTriangleVector.size() == 1){std::vector<CTriangle*>::iterator iter_v =commonTriangleVector.begin();//////////////////////////////////刪除三角形DelBowyerWatsonTriangle(**iter_v);///////////////////////////////////連接三角形三點CLine line1 = CLine(pt,(*iter_v)->p1);CLine line2 = CLine(pt,(*iter_v)->p2);CLine line3 = CLine(pt,(*iter_v)->p3);AddBowyerWatsonLine(line1);AddBowyerWatsonLine(line2);AddBowyerWatsonLine(line3);//加入新三角形if (CheckTriangleLinesExist(pt, (*iter_v)->p1, (*iter_v)->p2)){CTriangle tg1 = CTriangle(pt,(*iter_v)->p1,(*iter_v)->p2);AddBowyerWatsonTriangle(tg1);}if (CheckTriangleLinesExist(pt, (*iter_v)->p2, (*iter_v)->p3)){CTriangle tg2 = CTriangle(pt,(*iter_v)->p2,(*iter_v)->p3);AddBowyerWatsonTriangle(tg2);}if (CheckTriangleLinesExist(pt, (*iter_v)->p3, (*iter_v)->p1)){CTriangle tg3 = CTriangle(pt,(*iter_v)->p3,(*iter_v)->p1);AddBowyerWatsonTriangle(tg3);}}if (commonTriangleVector.size() > 1){for (int i = 0;i < (commonTriangleVector.size()-1);i++){for (int j = i+1;j <commonTriangleVector.size();j++){CTriangle* trg1 =*(commonTriangleVector.begin() + i);CTriangle* trg2 =*(commonTriangleVector.begin() +j);CLine* commonLine = trg1->FindCommonLine(*trg2);if (commonLine != NULL){//////////////////////////////////刪除影響三角形DelBowyerWatsonTriangle(*trg1);DelBowyerWatsonTriangle(*trg2);//刪除公共邊DelBowyerWatsonLine(*commonLine);///////////////////////////////////連接三角形三點CLine line1_1 = CLine(pt,trg1->p1);CLine line1_2 = CLine(pt,trg1->p2);CLine line1_3 = CLine(pt,trg1->p3);CLine line2_1 = CLine(pt,trg2->p1);CLine line2_2 = CLine(pt,trg2->p2);CLine line2_3 = CLine(pt,trg2->p3);AddBowyerWatsonLine(line1_1);AddBowyerWatsonLine(line1_2);AddBowyerWatsonLine(line1_3);AddBowyerWatsonLine(line2_1);AddBowyerWatsonLine(line2_2);AddBowyerWatsonLine(line2_3);//加入新三角形if (CheckTriangleLinesExist(pt, trg1->p1, trg1->p2)){CTriangle tg1 = CTriangle(pt, trg1->p1, trg1->p2);AddBowyerWatsonTriangle(tg1);}if (CheckTriangleLinesExist(pt, trg1->p2, trg1->p3)){CTriangle tg2 = CTriangle(pt,trg1->p2,trg1->p3);AddBowyerWatsonTriangle(tg2);}if (CheckTriangleLinesExist(pt, trg1->p3, trg1->p1)){CTriangle tg3 = CTriangle(pt, trg1->p3, trg1->p1);AddBowyerWatsonTriangle(tg3);}if (CheckTriangleLinesExist(pt, trg2->p1, trg2->p2)){CTriangle tg1 = CTriangle(pt, trg2->p1, trg2->p2);AddBowyerWatsonTriangle(tg1);}if (CheckTriangleLinesExist(pt, trg2->p2, trg2->p3)){CTriangle tg2 = CTriangle(pt,trg2->p2,trg2->p3);AddBowyerWatsonTriangle(tg2);}if (CheckTriangleLinesExist(pt, trg2->p3, trg2->p1)){CTriangle tg3 = CTriangle(pt, trg2->p3, trg2->p1);AddBowyerWatsonTriangle(tg3);}}}}}AddBowyerWatsonPoint(pt);iter_line =lineList.begin();while (iter_line != lineList.end()){std::list<CLine*>::iterator iter_lineNext = iter_line;iter_lineNext++;SAFE_DELETE(*iter_line);lineList.erase(iter_line);iter_line = iter_lineNext;}//lineiter_triangle =triangleList.begin();while (iter_triangle != triangleList.end()){std::list<CTriangle*>::iterator iter_triangleNext = iter_triangle;iter_triangleNext++;SAFE_DELETE(*iter_triangle);triangleList.erase(iter_triangle);iter_triangle = iter_triangleNext;}//Triangle}bool CBowyerWatson::CheckTriangleLinesExist(CPoint pt1, CPoint pt2, CPoint pt3){bool exist_line1 = false;bool exist_line2 = false;bool exist_line3 = false;CLine line1 = CLine(pt1, pt2);CLine line2 = CLine(pt2, pt3);CLine line3 = CLine(pt3, pt1);std::list<CLine*>::iterator iter_line = m_lstBowyerWatsonLineList.begin();for ( ;iter_line != m_lstBowyerWatsonLineList.end();iter_line++){if (line1 == (**iter_line)){exist_line1 = true;continue;}if (line2 == (**iter_line)){exist_line2 = true;continue;}if (line3 == (**iter_line)){exist_line3 = true;}}if (exist_line1 && exist_line2 && exist_line3){return true;}return false;}void CBowyerWatson::DrawMesh(){std::list<CLine*>::iterator iter = m_lstBowyerWatsonLineList.begin(); for ( ;iter != m_lstBowyerWatsonLineList.end();iter++){//(*iter)->p1.x, (*iter)->p1.y//(*iter)->p2.x, (*iter)->p2.y}}void CBowyerWatson::Update(){if (m_bUpdateDrawFlag){DrawMesh();}}///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/BowyerWatson.h#ifndef __CBOWYER_WATSON_H__#define __CBOWYER_WATSON_H__#include <list> #include <vector>class CPoint;class CLine;class CTriangle;class CBowyerWatson{public:CBowyerWatson();~CBowyerWatson();staticCBowyerWatson* GetInstance();voidClearBowyerWatson();voidCreateHelperPoint(CPoint pt1, CPoint pt2, CPoint pt3, CPoint pt4);voidAddNewPoint(CPoint pt);voidUpdateNewPoint();voidAddBowyerWatsonPoint(CPoint pt);voidAddBowyerWatsonLine(CLine line);voidDelBowyerWatsonLine(CLine line);voidAddBowyerWatsonTriangle(CTriangle triangle);voidDelBowyerWatsonTriangle(CTriangle triangle);voidProcessNewPoint(CPoint pt);boolCheckTriangleLinesExist(CPoint pt1, CPoint pt2, CPoint pt3);voidDrawMesh();voidSetUpdateDrawFlag(bool flag){m_bUpdateDrawFlag = flag;};voidUpdate();const std::list<CLine*>& GetBowyerWatsonLines(){return m_lstBowyerWatsonLineList;};const std::list<CTriangle*>& GetBowyerWatsonTriangles(){return m_lstBowyerWatsonTriangleList;};private:std::list<CPoint*>m_lstBowyerWatsonPointList;std::list<CLine*>m_lstBowyerWatsonLineList;std::list<CTriangle*>m_lstBowyerWatsonTriangleList;std::list<CPoint*>m_lstAddPointList;CPoint mHelperPoints[4];static CBowyerWatson* m_pBowyerWatson;boolm_bUpdateDrawFlag;};#endif///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/Line.cpp#include "Line.h"#include "Point.h"float CLine::Point2LineDistance(CPoint pt){float a = p2.y - p1.y;float b = p1.x - p2.x;float c = p2.x*p1.y - p1.x*p2.y;float dis = fabs(a*pt.x + b*pt.y + c)/sqrt(a*a + b*b);return dis;}bool CLine::operator ==(const CLine& l){if (l.p1.x == p1.x && l.p1.y == p1.y &&l.p2.x == p2.x && l.p2.y == p2.y){return true;}if (l.p2.x == p1.x && l.p2.y == p1.y &&l.p1.x == p2.x && l.p1.y == p2.y){return true;}return false;}CLine& CLine::operator =(const CLine& l){p1 = l.p1;p2 = l.p2;return *this;}///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/Line.h#ifndef __CLINEH__#define __CLINEH__#include "Point.h"class CLine{public:CPoint p1;CPoint p2;CLine(){};CLine(CPoint pt1, CPoint pt2){p1.x = pt1.x;p1.y = pt1.y;p2.x = pt2.x;p2.y = pt2.y;};bool CheckPointExist(CPoint pt){if (pt == p1 || pt == p2){return true;}return false;};float Point2LineDistance(CPoint pt);bool operator ==(const CLine& l);CLine& operator =(const CLine& l);};#endif///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/Main.cpp 原版#include<iostream> #include <map> #include "Line.h"#include "Point.h"#include "Triangle.h"#include "BowyerWatson.h"using namespace std; void main(){cout<<"********************* Bowyer_Watson_algorithm ****************** "<<endl;cout<<"********************* 本程序目標為實現Bowyer_Watson算法 ******************"<<endl;cout<<"********************* 如有遇到BUG請聯系作者 ******************"<<endl;cout<<"********************* email: [email protected] ******************"<<endl;cout<<"********************* Blog: blog.csdn.net/zzzzyu ******************"<<endl;cout<<endl<<endl;CBowyerWatson::GetInstance()->ClearBowyerWatson();CBowyerWatson::GetInstance()->CreateHelperPoint(CPoint(0,0),CPoint(0,100),CPoint(100,100),CPoint(100,0));CBowyerWatson::GetInstance()->AddNewPoint(CPoint(25,25));CBowyerWatson::GetInstance()->AddNewPoint(CPoint(35,50));CBowyerWatson::GetInstance()->AddNewPoint(CPoint(40,48));CBowyerWatson::GetInstance()->AddNewPoint(CPoint(50,25));CBowyerWatson::GetInstance()->AddNewPoint(CPoint(50,40));CBowyerWatson::GetInstance()->UpdateNewPoint();const std::list<CLine*> lineList = CBowyerWatson::GetInstance()->GetBowyerWatsonLines();std::list<CLine*>::const_iterator ite_line = lineList.begin(); for ( ;ite_line != lineList.end();ite_line++){cout<<"line : ("<<(*ite_line)->p1.x<<" "<<(*ite_line)->p1.y<<") " \<<"("<<(*ite_line)->p2.x<<" "<<(*ite_line)->p2.y<<")"<<endl;}cout<<endl<<endl;const std::list<CTriangle*> triangleList = CBowyerWatson::GetInstance()->GetBowyerWatsonTriangles();std::list<CTriangle*>::const_iterator iter_triangle = triangleList.begin(); for ( ;iter_triangle != triangleList.end();iter_triangle++){cout<<"Triangle : ("<<(*iter_triangle)->p1.x<<" "<<(*iter_triangle)->p1.y<<") " \<<(*iter_triangle)->p2.x<<" "<<(*iter_triangle)->p2.y<<") " \<<"("<<(*iter_triangle)->p3.x<<" "<<(*iter_triangle)->p3.y<<")"<<endl;}cout<<"Lines count : "<<lineList.size()<<endl;cout<<"Triangles count : "<<triangleList.size()<<endl;int ci;cin>>ci;return;} ///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/Main.cpp 改良后#include <cstdlib> #include <iostream> #include <cstring> #include <string> #include <fstream> #include <map> #include "Line.h"#include "Point.h"#include "Triangle.h"#include "BowyerWatson.h"using namespace std; void GetPoint(double &xx,double &yy,double &zz,string line)//從字符串line中解析出點的x,y,z坐標 { int flag=0; string tmp=""; char *cstr; /*這段似乎不能分析^num1, num2, num3$這種格式的輸入 for (int i=(int)line.find(',')+1;i<(int)line.size();i++) { if (line[i]==',') { cstr=new char[tmp.size()+1]; strcpy(cstr,tmp.c_str()); if (flag==0) {xx=atof(cstr);tmp.resize(0);flag++;} else if (flag==1) {yy=atof(cstr);tmp.resize(0);flag++;} continue; } tmp=tmp+line[i]; } */int xPos = 0, yPos = 0, zPos = 0; //記錄逗號分隔符位置xPos = line.find(',');tmp = line.substr(0, xPos);cstr=new char[tmp.size()+1]; strcpy(cstr,tmp.c_str()); xx=atof(cstr);tmp.resize(0);cstr = NULL;yPos = line.find(',', xPos+1);tmp = line.substr(xPos+1, (yPos-xPos-1));cstr=new char[tmp.size()+1]; strcpy(cstr,tmp.c_str()); yy=atof(cstr);tmp.resize(0);cstr = NULL; if (fabs(xx)<1.0e-6) xx=0.0; if (fabs(yy)<1.0e-6) yy=0.0; if (fabs(zz)<1.0e-6) zz=0.0; } void main(){cout<<"********************* Bowyer_Watson_algorithm ****************** "<<endl;cout<<"********************* 本程序目標為實現Bowyer_Watson算法 ******************"<<endl;cout<<"********************* 如有遇到BUG請聯系作者 ******************"<<endl;cout<<"********************* email: [email protected] ******************"<<endl;cout<<"********************* Blog: blog.csdn.net/zzzzyu ******************"<<endl;cout<<endl<<endl;CBowyerWatson::GetInstance()->ClearBowyerWatson();CBowyerWatson::GetInstance()->CreateHelperPoint(CPoint(0,0),CPoint(1000,0),CPoint(1000,1000),CPoint(0, 1000));//從文件中讀取點ifstream infile("input.txt");//打開"input.txt"文件 if (!infile)//判斷文件是否正常打開 { cout<<"Unable to input nodes!"; exit(1); } string line; double xx,yy,zz; int nodeSize; cout<<"讀取邊界點:"<<endl; for (int i=0;i<4;i++)//讀入4外邊框點 { getline(infile,line); GetPoint(xx,yy,zz,line); cout<<"["<<xx<<", "<<yy<<"], "<<endl; } getline(infile,line);//讀入節點數,用于后面循環 char *cstr; cstr=new char[line.size()+1]; strcpy(cstr,line.c_str()); nodeSize=atoi(cstr); cout<<"讀取頂點數量:"<<nodeSize<<endl;cout<<"讀取頂點:"<<endl; for (int i=0;i<nodeSize;i++)//讀入每個節點的坐標 { getline(infile,line); GetPoint(xx,yy,zz,line); cout<<"["<<xx<<", "<<yy<<"],";CBowyerWatson::GetInstance()->AddNewPoint(CPoint(xx,yy)); } infile.close(); /*CBowyerWatson::GetInstance()->AddNewPoint(CPoint(25,25));CBowyerWatson::GetInstance()->AddNewPoint(CPoint(35,50));CBowyerWatson::GetInstance()->AddNewPoint(CPoint(40,48));CBowyerWatson::GetInstance()->AddNewPoint(CPoint(50,25));CBowyerWatson::GetInstance()->AddNewPoint(CPoint(50,40));*/CBowyerWatson::GetInstance()->UpdateNewPoint();const std::list<CLine*> lineList = CBowyerWatson::GetInstance()->GetBowyerWatsonLines();std::list<CLine*>::const_iterator ite_line = lineList.begin(); cout<<endl<<"line :"<<endl;for ( ;ite_line != lineList.end();ite_line++){cout<<"[["<<(*ite_line)->p1.x<<", "<<(*ite_line)->p1.y<<"], " \<<"["<<(*ite_line)->p2.x<<", "<<(*ite_line)->p2.y<<"]], "<<endl;}cout<<endl<<endl;const std::list<CTriangle*> triangleList = CBowyerWatson::GetInstance()->GetBowyerWatsonTriangles();std::list<CTriangle*>::const_iterator iter_triangle = triangleList.begin(); cout<<"Triangle :"<<endl;for ( ;iter_triangle != triangleList.end();iter_triangle++){cout<<"[["<<(*iter_triangle)->p1.x<<", "<<(*iter_triangle)->p1.y<<"], " \<<"["<<(*iter_triangle)->p2.x<<", "<<(*iter_triangle)->p2.y<<"], " \<<"["<<(*iter_triangle)->p3.x<<", "<<(*iter_triangle)->p3.y<<"]],"<<endl;}cout<<"Lines count : "<<lineList.size()<<endl;cout<<"Triangles count : "<<triangleList.size()<<endl;int ci;cout<<"輸入任意數結束程序!"<<endl;cin>>ci;return;} ///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/Point.cpp#include "Point.h"bool CPoint::operator ==(const CPoint& p){if (p.x == x && p.y == y){return true;}return false;}CPoint& CPoint::operator =(const CPoint& p){x = p.x;y = p.y;return *this;}///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/Point.h#ifndef __CPOINTH__#define __CPOINTH__#define NULL 0 #define SAFE_DELETE(x) if( (x)!=NULL ) { delete (x); (x)=NULL; } #include <math.h> class CPoint{public:float x;float y;CPoint(){x = 0;y = 0;};static float distance(CPoint pt1 , CPoint pt2){return sqrt((pt1.x-pt2.x)*(pt1.x-pt2.x) + (pt1.y-pt2.y)*(pt1.y-pt2.y));};CPoint(float fx, float fy){x = fx;y = fy;};bool operator ==(const CPoint& p);CPoint& operator =(const CPoint& p);};#endif///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/Triangle.cpp#include "Triangle.h"#include <math.h> CTriangle::CTriangle(CPoint pt1, CPoint pt2, CPoint pt3){p1 = pt1;p2 = pt2;p3 = pt3;l1 = CLine(p1,p2);l2 = CLine(p2,p3);l3 = CLine(p3,p1);float dis1 = CPoint::distance(p1,p2);float dis2 = CPoint::distance(p2,p3);float dis3 = CPoint::distance(p3,p1);radiu = dis1*dis2*dis3/TriangleArea()/4;float c1, c2; float xA, yA, xB, yB, xC, yC; xA = p1.x; yA = p1.y; xB = p2.x; yB = p2.y; xC = p3.x; yC = p3.y; c1 = (xA * xA + yA * yA - xB * xB - yB * yB) / 2; c2 = (xA * xA + yA * yA - xC * xC - yC * yC) / 2; center.x = (c1 * (yA - yC) - c2 * (yA - yB)) / ((xA - xB) * (yA - yC) - (xA - xC) * (yA - yB)); center.y = (c1 * (xA - xC) - c2 * (xA - xB)) / ((yA - yB) * (xA - xC) - (yA - yC) * (xA - xB)); }float CTriangle::TriangleArea(){return fabs(p1.x * p2.y + p2.x * p3.y + p3.x * p1.y - p2.x * p1.y - p3.x * p2.y - p1.x * p3.y) / 2; }bool CTriangle::CheckInCircle(CPoint pt){if (CPoint::distance(center,pt) <= radiu){return true;}return false;}CLine CTriangle::FindNearestLine(CPoint pt){float dis1 = l1.Point2LineDistance(pt);float dis2 = l2.Point2LineDistance(pt);float dis3 = l3.Point2LineDistance(pt);if (dis1 <= dis2 && dis1 <= dis3){return l1;}if (dis2 <= dis1 && dis2 <= dis3){return l2;}return l3;}CLine* CTriangle::FindCommonLine(CTriangle tg){if (this->l1 == tg.l1 || this->l1 == tg.l2 || this->l1 == tg.l3){return &l1;}if (this->l2 == tg.l1 || this->l2 == tg.l2 || this->l2 == tg.l3){return &l2;}if (this->l3 == tg.l1 || this->l3 == tg.l2 || this->l3 == tg.l3){return &l3;}return NULL;}CPoint CTriangle::GetOtherPoint(CPoint pt1, CPoint pt2){if (!(p1 == pt1) && !(p1 == pt2)){return p1;}if (!(p2 == pt1) && !(p2 == pt2)){return p2;}return p3;}bool CTriangle::CheckPointExist(CPoint pt){if (pt == p1 || pt == p2 || pt == p3){return true;}return false;}bool CTriangle::operator ==(const CTriangle& t){if ((p1 == t.p1) && (p2 == t.p2) && (p3 == t.p3)){return true;}if ((p1 == t.p1) && (p3 == t.p2) && (p2 == t.p3)){return true;}if ((p2 == t.p1) && (p1 == t.p2) && (p3 == t.p3)){return true;}if ((p2 == t.p1) && (p3 == t.p2) && (p1 == t.p3)){return true;}if ((p3 == t.p1) && (p2 == t.p2) && (p1 == t.p3)){return true;}if ((p3 == t.p1) && (p1 == t.p2) && (p2 == t.p3)){return true;}return false;}///D:/360極速瀏覽器下載/Bowyer_Watson/Bowyer_Watson/Triangle.h#ifndef __CTRIANGLEH__#define __CTRIANGLEH__#include "Point.h"#include "Line.h"class CTriangle{public :CPoint p1;CPoint p2;CPoint p3;CLine l1;CLine l2;CLine l3;CPoint center;float radiu;CTriangle(){};CTriangle(CPoint pt1, CPoint pt2, CPoint pt3);bool CheckInCircle(CPoint pt);float TriangleArea();CLine FindNearestLine(CPoint pt);CLine* FindCommonLine(CTriangle tg);CPoint GetOtherPoint(CPoint pt1, CPoint pt2);bool CheckPointExist(CPoint pt);bool operator ==(const CTriangle& t);};#endif</span>

這圖紙其實設計得還很詳細,只是沒有說明書,確實有點難為神農他老人家。

阿偉念動咒語,生成了制造工藝流程:

<span style="font-size:18px;">#nmake /f winc.mak#源文件目錄和編譯輸出目錄SRCPATH = DSTPATH = .\dst#編譯器CPP = clRSC = rcLINK = link#編譯選項CPPFLAGS = /nologo /EHsc /W3 /O2 /D "WIN32" /D _X86_ /D "NDEBUG" /D "_MBCS" /cRSCFLAGS = LINKFALGS = /nologo #預定義鏈接庫LINKLIB = \user32.lib kernel32.lib gdi32.lib#平臺PLATFORM = /machine:I386 /subsystem:console#目標文件名 #前綴加地址 $(DSTPATH)/EXETARGET = $(DSTPATH)/Main.exeDLLTARGET = OBJTARGET = $(DSTPATH)/Point.obj $(DSTPATH)/Line.obj $(DSTPATH)/Triangle.obj \$(DSTPATH)/BowyerWatson.obj $(DSTPATH)/Main.objRESTARGET = #編譯規則all: create.dir \$(EXETARGET) $(DLLTARGET) $(OBJTARGET) $(RESTARGET)!if "$(EXETARGET)" != ""$(EXETARGET): $(OBJTARGET) $(RESTARGET)$(LINK) $(LINKFLAGS) $(PLATFORM) $(LINKLIB) $(OBJTARGET) $(RESTARGET) /OUT:$(EXETARGET)!endif.c{$(DSTPATH)/}.obj:$(CPP) $(CPPFLAGS) /[email protected] $<.cpp{$(DSTPATH)/}.obj:$(CPP) $(CPPFLAGS) /[email protected] $<.rc{$(DSTPATH)/}.res:$(RSC) $(RSCFLAGS) /[email protected] $<create.dir:-if not exist $(DSTPATH)\*.* mkdir $(DSTPATH)clean:-if exist $(DSTPATH)\*.obj erase $(DSTPATH)\*.obj-if exist $(DSTPATH)\*.res erase $(DSTPATH)\*.res</span>

[機器小偉]一陣忙活,生成了一張說明書:

神農看了半天,表示他不識數,只看得懂圖。

圖來:

阿偉和神農都沒有說話,神農默默地掏出了第二張圖紙:

<span style="font-size:18px;">///D:/360極速瀏覽器下載/delaunay/delaunay.cpp#include "delaunay.h" Delaunay::Delaunay(Point p1,Point p2,Point p3,Point p4) { //四個邊框點為左上->右上->右下->左下的環形順序 m_Pts.resize(4); m_Pts[0]=p1; m_Pts[1]=p2; m_Pts[2]=p3; m_Pts[3]=p4;//添加四個外邊框點 m_Edges.resize(4); Edge l1={0,1,-1}; Edge l2={1,2,-1}; Edge l3={0,3,-1}; Edge l4={2,3,-1}; m_Edges[0]=l1; m_Edges[1]=l2; m_Edges[2]=l3; m_Edges[3]=l4;//添加四個外邊框的邊 MakeTriangle(0,1,2); MakeTriangle(0,2,3);//添加初始的兩個三角形 } Delaunay::~Delaunay()//清空Delaunay類的數據成員 { m_Pts.resize(0); m_Edges.resize(0); m_Tris.resize(0); } void Delaunay::MakeTriangle(int n1,int n2,int n3) { double x_centre,y_centre,radius; Cal_Centre(x_centre,y_centre,radius,n1,n2,n3);//獲得頂點為n1,n2,n3的三角形的外接圓圓心坐標和半徑 Triangle newTriangle={{n1,n2,n3},{{n1,n2,1},{n2,n3,1},{n1,n3,1}},x_centre,y_centre,radius};//生成指定的三角形 m_Tris.push_back(newTriangle);//向m_Tris中添加新構造的三角形 int EdgeSzie=(int)m_Edges.size();//獲得目前的邊數 int flag; for (int i=0;i<3;i++) { flag=1; for(int j=0;j<EdgeSzie;j++)//通過循環判斷新構造的三角形的各邊是否已經存在于m_Edges中,如果存在則只增加該邊的計數,否則添加新邊 { if (newTriangle.s[i].left==m_Edges[j].left&&newTriangle.s[i].right==m_Edges[j].right&&m_Edges[j].count!=-1) {flag=0;m_Edges[j].count+=1;break;} else if(newTriangle.s[i].left==m_Edges[j].left&&newTriangle.s[i].right==m_Edges[j].right&&m_Edges[j].count==-1) {flag=0;break;} } if (flag==1) m_Edges.push_back(newTriangle.s[i]); } } void Delaunay::Cal_Centre(double &x_centre,double &y_centre,double &radius,int n1,int n2,int n3) { double x1,x2,x3,y1,y2,y3; x1=m_Pts[n1].x; y1=m_Pts[n1].y; x2=m_Pts[n2].x; y2=m_Pts[n2].y; x3=m_Pts[n3].x; y3=m_Pts[n3].y; x_centre=((y2-y1)*(y3*y3-y1*y1+x3*x3-x1*x1)-(y3-y1)*(y2*y2-y1*y1+x2*x2-x1*x1))/(2*(x3-x1)*(y2-y1)-2*((x2-x1)*(y3-y1)));//計算外接圓圓心的x坐標 y_centre=((x2-x1)*(x3*x3-x1*x1+y3*y3-y1*y1)-(x3-x1)*(x2*x2-x1*x1+y2*y2-y1*y1))/(2*(y3-y1)*(x2-x1)-2*((y2-y1)*(x3-x1)));//計算外接圓圓心的y坐標 radius= sqrt((x1 - x_centre)*(x1 - x_centre) + (y1 - y_centre)*(y1 - y_centre));//計算外接圓的半徑 } bool Delaunay::AddPoint(double xx,double yy,double zz) { EdgeArray BoundEdges;//BoundEdges用于存儲在刪除三角形后留下的邊框,用于構造新的三角形 Point newPoint={xx,yy,zz}; m_Pts.push_back(newPoint);//向m_Pts中添加新點 intArray badTriangle;//badTriangle用于存儲不符合空圓規則的三角形的索引號 int TriSize=(int)m_Tris.size();//獲得目前的三角形數 for (int i=0;i<TriSize;i++)//通過循環找到所有不符合空圓規則的三角形,并將其索引號存在badTriangle中 { if (inCircle(xx,yy,m_Tris[i])==true) badTriangle.push_back(i); } for (int i=0;i<(int)badTriangle.size();i++)//通過循環刪除所有不符合空圓規則的三角形,同時保留邊框 { DelTriangle(badTriangle[i],BoundEdges); for (int j=i+1;j<(int)badTriangle.size();j++) badTriangle[j]-=1; } int PtSize=(int)m_Pts.size();//獲得目前的點數 for (int i=0;i<(int)BoundEdges.size();i++)//生成新的三角形 { if (PtSize-1<BoundEdges[i].left) MakeTriangle(PtSize-1,BoundEdges[i].left,BoundEdges[i].right); else if (PtSize-1>BoundEdges[i].left && PtSize-1<BoundEdges[i].right) MakeTriangle(BoundEdges[i].left,PtSize-1,BoundEdges[i].right); else MakeTriangle(BoundEdges[i].left,BoundEdges[i].right,PtSize-1); } return true; } bool Delaunay::inCircle(double xx,double yy,Triangle currentTris)//判斷點是否在三角形的外接圓內 { double dis=sqrt((currentTris.xc-xx)*(currentTris.xc-xx)+(currentTris.yc-yy)*(currentTris.yc-yy)); if (dis>currentTris.r) return false; else return true; } void Delaunay::DelTriangle(int n,EdgeArray &BoundEdges) { for (int i=0;i<3;i++) { for (int j=0;j<(int)m_Edges.size();j++) { if (m_Edges[j].left==m_Tris[n].s[i].left&&m_Edges[j].right==m_Tris[n].s[i].right) { if (m_Edges[j].count==2)//若要刪除三角形的一邊的計數為2,則將其計數減1,并將其壓入BoundEdges容器中 { m_Edges[j].count=1; BoundEdges.push_back(m_Edges[j]); } else if (m_Edges[j].count==-1) BoundEdges.push_back(m_Edges[j]);//如果是外邊框,則直接壓入BoundEdges容器中 else if (m_Edges[j].count==1)//如果刪除三角形的一邊的計數為1,則刪除該邊,同時查看BoundEdges中是否有此邊,若有,則刪除 { for (int k=0;k<(int)BoundEdges.size();k++) { if (BoundEdges[k].left==m_Edges[j].left&&BoundEdges[k].right==m_Edges[j].right) { BoundEdges.erase(BoundEdges.begin()+k); break; } } m_Edges.erase(m_Edges.begin()+j); j--; } break; } } } m_Tris.erase(m_Tris.begin()+n);//刪除該三角形 } void Delaunay::output()//向“output.log"文件中寫入ANSYS命令流 { ofstream outfile("output.log"); if (!outfile) { cout<<"Unable to output nodes!"; exit(1); } outfile<<"/PREP7"<<endl; for (int i=0;i<(int)m_Pts.size();i++) { outfile<<"K,"<<i+1<<","<<m_Pts[i].x<<","<<m_Pts[i].y<<","<<m_Pts[i].z<<endl; } for (int i=0;i<(int)m_Edges.size();i++) { outfile<<"L,"<<m_Edges[i].left+1<<","<<m_Edges[i].right+1<<endl; } outfile.close(); } /*原版void GetPoint(double &xx,double &yy,double &zz,string line)//從字符串line中解析出點的x,y,z坐標 { int flag=0; string tmp=""; char *cstr; for (int i=(int)line.find(',')+1;i<(int)line.size();i++) { if (line[i]==',') { cstr=new char[tmp.size()+1]; strcpy(cstr,tmp.c_str()); if (flag==0) {xx=atof(cstr);tmp.resize(0);flag++;} else if (flag==1) {yy=atof(cstr);tmp.resize(0);flag++;} continue; } tmp=tmp+line[i]; } if (fabs(xx)<1.0e-6) xx=0.0; if (fabs(yy)<1.0e-6) yy=0.0; if (fabs(zz)<1.0e-6) zz=0.0; } *///改良后void GetPoint(double &xx,double &yy,double &zz,string line)//從字符串line中解析出點的x,y,z坐標 { int flag=0; string tmp=""; char *cstr; /*這段似乎不能分析^num1, num2, num3$這種格式的輸入 for (int i=(int)line.find(',')+1;i<(int)line.size();i++) { if (line[i]==',') { cstr=new char[tmp.size()+1]; strcpy(cstr,tmp.c_str()); if (flag==0) {xx=atof(cstr);tmp.resize(0);flag++;} else if (flag==1) {yy=atof(cstr);tmp.resize(0);flag++;} continue; } tmp=tmp+line[i]; } */int xPos = 0, yPos = 0, zPos = 0; //記錄逗號分隔符位置xPos = line.find(',');tmp = line.substr(0, xPos);cstr=new char[tmp.size()+1]; strcpy(cstr,tmp.c_str()); xx=atof(cstr);tmp.resize(0);cstr = NULL;yPos = line.find(',', xPos+1);tmp = line.substr(xPos+1, (yPos-xPos-1));cstr=new char[tmp.size()+1]; strcpy(cstr,tmp.c_str()); yy=atof(cstr);tmp.resize(0);cstr = NULL;//不理會z值,需要時再擴展zz = 0.0; if (fabs(xx)<1.0e-6) xx=0.0; if (fabs(yy)<1.0e-6) yy=0.0; if (fabs(zz)<1.0e-6) zz=0.0; } void Delaunay::Delete_Frame()//刪除外邊框 { EdgeArray BoundEdges; for (int i=0;i<4;i++) m_Pts.erase(m_Pts.begin()); for (int i=0;i<(int)m_Tris.size();i++) { if (m_Tris[i].v[0]==0||m_Tris[i].v[0]==1||m_Tris[i].v[0]==2||m_Tris[i].v[0]==3) { DelTriangle(i,BoundEdges); BoundEdges.resize(0); i--; } else { for (int j=0;j<3;j++) { m_Tris[i].v[j]-=4; m_Tris[i].s[j].left-=4; m_Tris[i].s[j].right-=4; } } } for (int i=0;i<4;i++) m_Edges.erase(m_Edges.begin()); for (int i=0;i<(int)m_Edges.size();i++) { m_Edges[i].left-=4; m_Edges[i].right-=4; } } void Delaunay::Boundary_Recover(int fromPoint,int toPoint)//恢復由指定點組成的邊界 { EdgeArray BoundEdges; for (int i=0;i<(int)m_Tris.size();i++) { if (m_Tris[i].v[0]>=(fromPoint-1)&&m_Tris[i].v[2]<=(toPoint-1)) { DelTriangle(i,BoundEdges); BoundEdges.resize(0); i--; } } } ///D:/360極速瀏覽器下載/delaunay/delaunay.h#ifndef DELAUNAY_H_INCLUDED #define DELAUNAY_H_INCLUDED #include <cstdlib> #include <iostream> #include <cstring> #include <string> #include <fstream> #include <math.h> #include <vector> using namespace std; typedef struct { double x; double y; double z; }Point;//定義點類 typedef vector<Point> PointArray;//定義點類的vector容器 typedef struct { int left; int right; int count;//邊的計數,如果計數為0,則刪除此邊 }Edge;//定義邊類 typedef vector<Edge> EdgeArray;//定義邊類的vector容器 typedef struct { int v[3];//三角形的三個頂點 Edge s[3];//三角形的三條邊 double xc;//三角形外接圓圓心的x坐標 double yc;//三角形外接圓圓心的y坐標 double r;//三角形外接圓的半徑 }Triangle;//定義三角形類 typedef vector<Triangle> TriangleArray;//定義三角形類的vector容器 typedef vector<int> intArray;//定義int類的vector容器 class Delaunay//定義Delaunay類 { public: Delaunay(Point p1,Point p2,Point p3,Point p4);//Delaunay類的構造函數,創建外邊框 ~Delaunay();//Delaunay類的析構函數 bool AddPoint(double xx,double yy,double zz);//向已有剖分圖形中加點的函數 void Delete_Frame();//刪除外邊框 void Boundary_Recover(int fromPoint,int toPoint);//邊界恢復 void output();//輸出ANSYS命令流文件 private: void Cal_Centre(double &x_centre,double &y_centre,double &radius,int n1,int n2,int n3);//計算三角形的外接圓圓心坐標和半徑 void MakeTriangle(int n1,int n2,int n3);//生成指定頂點的三角形 bool inCircle(double xx,double yy,Triangle currentTris);//判斷點是否在圓內 void DelTriangle(int n,EdgeArray &BoundEdges);//刪除指定的三角形 PointArray m_Pts;//m_Pts用于存儲所有點 EdgeArray m_Edges;//m_Edges用于存儲所有邊 TriangleArray m_Tris;//m_Tris用于存儲所有三角形 }; void GetPoint(double &xx,double &yy,double &zz,string line);//解析從input文件中讀取的每一行數據 #endif // DELAUNAY_H_INCLUDED ///D:/360極速瀏覽器下載/delaunay/main.cpp#include "delaunay.h" int main() { ifstream infile("input.txt");//打開"input.txt"文件 if (!infile)//判斷文件是否正常打開 { cout<<"Unable to input nodes!"; exit(1); } string line; PointArray p; double xx,yy,zz; int nodeSize; for (int i=0;i<4;i++)//讀入4外邊框點 { getline(infile,line); GetPoint(xx,yy,zz,line); Point tmp={xx,yy,zz}; p.push_back(tmp); } Delaunay MyMesh(p[0],p[1],p[2],p[3]);//實例化Delaunay類 getline(infile,line);//讀入節點數,用于后面循環 char *cstr; cstr=new char[line.size()+1]; strcpy(cstr,line.c_str()); nodeSize=atoi(cstr); for (int i=0;i<nodeSize;i++)//讀入每個節點的坐標 { getline(infile,line); GetPoint(xx,yy,zz,line); MyMesh.AddPoint(xx,yy,zz); } infile.close(); MyMesh.Delete_Frame();//刪除外邊框 /* MyMesh.Boundary_Recover(203,466); MyMesh.Boundary_Recover(467,487); MyMesh.Boundary_Recover(488,511); MyMesh.Boundary_Recover(512,537);//以上都是恢復指定邊界 */ MyMesh.output();//將相應ANSYS命令流輸出 return 0; } </span>

阿偉照樣先理出了制造工藝流程:

<span style="font-size:18px;">///D:/360極速瀏覽器下載/delaunay/winc.mak#nmake /f winc.mak#源文件目錄和編譯輸出目錄SRCPATH = DSTPATH = .\dst#編譯器CPP = clRSC = rcLINK = link#編譯選項CPPFLAGS = /nologo /EHsc /W3 /O2 /D "WIN32" /D _X86_ /D "NDEBUG" /D "_MBCS" /cRSCFLAGS = LINKFALGS = /nologo #預定義鏈接庫LINKLIB = \user32.lib kernel32.lib gdi32.lib#平臺PLATFORM = /machine:I386 /subsystem:console#目標文件名 #前綴加地址 $(DSTPATH)/EXETARGET = $(DSTPATH)/main.exeDLLTARGET = OBJTARGET = $(DSTPATH)/delaunay.obj $(DSTPATH)/main.objRESTARGET = #編譯規則all: create.dir \$(EXETARGET) $(DLLTARGET) $(OBJTARGET) $(RESTARGET)!if "$(EXETARGET)" != ""$(EXETARGET): $(OBJTARGET) $(RESTARGET)$(LINK) $(LINKFLAGS) $(PLATFORM) $(LINKLIB) $(OBJTARGET) $(RESTARGET) /OUT:$(EXETARGET)!endif.c{$(DSTPATH)/}.obj:$(CPP) $(CPPFLAGS) /[email protected] $<.cpp{$(DSTPATH)/}.obj:$(CPP) $(CPPFLAGS) /[email protected] $<.rc{$(DSTPATH)/}.res:$(RSC) $(RSCFLAGS) /[email protected] $<create.dir:-if not exist $(DSTPATH)\*.* mkdir $(DSTPATH)clean:-if exist $(DSTPATH)\*.obj erase $(DSTPATH)\*.obj-if exist $(DSTPATH)\*.res erase $(DSTPATH)\*.res</span>

這套生產線還只有一半。

神農告訴阿偉那另外半套生產線需要裝一個相當大的程序,那個名字他聽都沒聽說過。

嗯,天下數據一家親,阿偉讓神農不要著急。

<span style="font-size:18px;">#讀取ANSYS命令流文件數據def tmp2(): fin = open('input.txt', 'r'); fout = open('output.txt', 'w'); verts = []; edges = []; for line in fin.readlines(): if (line[0] == 'K'): line = line[:-1]; #去除行尾'\n' a = line.split(','); #暫時取第二項,即頂點序號,以及x, y坐標值 verts.append([float(a[2]), float(a[3])]); elif (line[0] == 'L'): line = line[:-1]; a = line.split(','); point_1 = verts[int(a[1])-1]; point_2 = verts[int(a[2])-1]; edges.append([point_1, point_2]); print('共有頂點{0}個,邊{1}條'.format(len(verts), len(edges))); fout.write('$Verts = ['); s = ''; for i in range(len(verts)): s += str(verts[i])+','; fout.write(s+']\n'); fout.write('$Edges = ['); s = ''; for i in range(len(edges)): s += str(edges[i])+','; fout.write(s+']\n'); fin.close(); fout.close();</span>

好了,程序不應該那么大,阿偉告訴神農,大的東西是不可靠的。

一陣吱吱亂響,[機器小偉]繼續出圖:

費這么半天工夫,貌似結果一樣啊。

阿偉不得不對神農說,你看,要早知的結果也就這樣,那你還不如用我的那套設計圖紙呢,雖然還有很多奇怪的地方,但總是要簡單些啊。

<span style="font-size:18px;">import geo;#### @usage Bowyer-Watson算法進行Delaunay三角剖分# @author mw# @date 2016年07月15日 星期五 10:31:36 # @param# @return####class Delaunay(): #設置頂點 #vertices是[[x_0, y_0], [x_1, y_1], ...]頂點對格式 def setVertice(self, vertices): return vertices; def sortVerticebyX(self, vertices): v_x = sorted(vertices, key = lambda a : a[0]); return v_x; def sortVerticebyY(self, vertices): v_y = sorted(vertices, key = lambda a : a[1]); return v_y; #去除重復點 def removeDup(self, vertices): v_new = []; len_1 = len(vertices); len_2 = 0; for i in range(len_1): len_2 = len(v_new); if (len_2 < 1): v_new.append(vertices[i]); else: for j in range(len_2): if v_new[j] == vertices[i]: break; if (j >= len_2-1): v_new.append(vertices[i]); return v_new; #計算邊界 def calcBound(self, vertices): len_ = len(vertices) v_x = self.sortVerticebyX(vertices); xMin = v_x[0][0]; xMax = v_x[len_-1][0]; v_y = self.sortVerticebyY(vertices); yMin = v_y[0][1]; yMax = v_y[len_-1][1]; return [xMin, xMax, yMin, yMax]; #超級三角形 def superTri(self, vertices): bound = self.calcBound(vertices); xMin = bound[0]-10; xMax = bound[1]+10; yMin = bound[2]-10; yMax = bound[3]+10; xCenter = (xMin+xMax)/2; yCenter = (yMin+yMax)/2; xR = (xMax-xMin)/2; yR = (yMax-yMin)/2; xMin_ = xCenter-2*xR; xMax_ = xCenter+2*xR; yMin_ = yMin; yMax_ = yMin + 4*yR; return [[xMin_, yMin_], [xMax_, yMin_], [xCenter, yMax_]]; #計算剖分三角形 def calcDelaunayTri(self, vertices, mode = 1): #移除重復點 vertices = self.removeDup(vertices); #按X坐標由小到大排序 vertices = self.sortVerticebyX(vertices); #頂點數量 vertNum = len(vertices); #臨時三角形存放處 tempTriArray = []; #三角形存放處 triArray = []; #邊存放處 edgeArray = []; supertri = self.superTri(vertices); tempTriArray.append(supertri); triArray.append(supertri); for i in range(vertNum): P0 = vertices[i]; tmpTriNum = len(tempTriArray); print('頂點{0} --> {1}個臨時三角形'.format(i, tmpTriNum)); edgeArray = []; tmpTri = []; for j in range(tmpTriNum): P1, P2, P3 = tempTriArray[j][0], tempTriArray[j][1], tempTriArray[j][2]; #調用geo的circle方法 circleProp = geo.circle(P1, P2, P3); #取得圓心和半徑 P_center, R = circleProp[0], circleProp[1]; #print(P_center, 'R = ', R); d = geo.distance2D(P0, P_center); if (P0[0] > P_center[0]+R): #對比點是在圓外右側的三角形,已經得到晉級確認 #由于某些時候會多出一些冗余三角形,先加入一個判斷試試能不能解決該問題 triArray.append([P1, P2, P3]); elif (d > R): #不確定的三角形,不理它 tmpTri.append([P1, P2, P3]); else: #對比點在圓內,這個三角形被淘汰 edgeArray.append([P1, P2]); edgeArray.append([P2, P3]); edgeArray.append([P3, P1]); edgeArray = self.removeDupEdge(edgeArray); edges = len(edgeArray); print('頂點{0} --> {1}條邊'.format(i, edges)); for k in range(edges): P1, P2 = edgeArray[k][0], edgeArray[k][1]; if (geo.pointInLine(P1, P2, P0) == False): tmpTri.append([P0, P1, P2]); #臨時數組已經重新安排 tempTriArray = []; tempTriArray = self.removeDupTri(tmpTri); triArray += tempTriArray; triArray = self.removeDupTri(triArray); if (mode == 0): return triArray; else: newTriArray = []; triNum = len(triArray); for i in range(triNum): tri_ = triArray[i]; relate = False; for j in range(3): if relate == True: break; for k in range(3): if tri_[j] == supertri[k]: relate = True; break; if relate == False: newTriArray.append(tri_); return newTriArray; #移除相同的三角形 def removeDupTri(self, triArray): newTriArray = []; for i in range(len(triArray)): len_ = len(newTriArray); if (len_ <= 0): newTriArray.append(triArray[i]); else: for j in range(len_): if self.judgeSameTri(newTriArray[j], triArray[i]) == True: break; if (j >= len_ -1): newTriArray.append(triArray[i]); return newTriArray; #判斷兩個三角形相同 #三角形格式[P1, P2, P3], P是頂點 def judgeSameTri(self, tri_1, tri_2): P_11, P_12, P_13, P_21, P_22, P_23 = tri_1[0], tri_1[1], tri_1[2], tri_2[0], tri_2[1], tri_2[2]; tri_1 = sorted(tri_1, key = lambda a:(a[0], a[1])); tri_2 = sorted(tri_2, key = lambda a:(a[0], a[1])); if (tri_1 == tri_2): return True; else: return False; #判斷兩個三角形有共同邊 def judge2TriHaveSameEdge(self, tri_1, tri_2): pass; #移除相同的邊,本算法的去重指的是要成對的卻除相同的邊 #而不是只允許出現一次那種 def removeDupEdge(self, edgeArray): newEdgeArray = []; ''' for i in range(len(edgeArray)): len_ = len(newEdgeArray); if (len_ <= 0): newEdgeArray.append(edgeArray[i]); else: for j in range(len_): if self.judgeSameEdge(newEdgeArray[j], edgeArray[i]) == True: newEdgeArray = newEdgeArray[:j]+newEdgeArray[j+1:]; break; if (j >= len_ -1): newEdgeArray.append(edgeArray[i]); return newEdgeArray; ''' len1 = len(edgeArray); ''' for i in range(len_): edgeArray[i] = sorted(edgeArray[i], key = lambda a:(a[0], a[1])); ''' for i in range(len(edgeArray)): len_ = len(newEdgeArray); if (len_ <= 0): newEdgeArray.append([edgeArray[i], 1]); else: for j in range(len_): if self.judgeSameEdge(newEdgeArray[j][0], edgeArray[i]) == True: newEdgeArray[j][1] += 1; break; if (j >= len_ -1): newEdgeArray.append([edgeArray[i], 1]); result = []; for i in range(len(newEdgeArray)): if (newEdgeArray[i][1] <= 1): result.append(newEdgeArray[i][0]); return result; #判斷兩條邊相同 #邊格式[P1, P2], P是頂點 def judgeSameEdge(self, edge_1, edge_2): P_11, P_12, P_21, P_22 = edge_1[0], edge_1[1], edge_2[0], edge_2[1]; if (P_11 == P_21 and P_12 == P_22) or (P_11 == P_22 and P_12 == P_21): return True; else: return False; def tmp1(): delaunay = Delaunay(); picDataArray = [[15, 7, 161, 311], [18, 7, 160, 369], [11, 8, 171, 239], [8, 10, 221, 170], [21, 10, 209, 435], [23, 13, 283, 463], [6, 14, 300, 142], [13, 14, 300, 278], [15, 14, 301, 319], [17, 15, 325, 354], [11, 16, 338, 245], [17, 17, 352, 363], [23, 17, 361, 479], [7, 18, 381, 159], [12, 18, 376, 265], [14, 18, 385, 293], [19, 18, 380, 377], [17, 19, 404, 347], [15, 20, 408, 309], [8, 21, 444, 175], [22, 21, 441, 450], [9, 24, 489, 203], [19, 24, 495, 397], [12, 26, 540, 257], [16, 26, 539, 329], ]; verts = []; mapWidth, mapHeight = 700/2, 600/2; for i in range(len(picDataArray)): x = picDataArray[i][2]; y = picDataArray[i][3]; if (abs(x-mapWidth)<=350 and abs(y-mapHeight)<=270): verts.append([x, y, 0]); print('頂點集:', verts); ''' if (len(verts) >= 3): a = delaunay.calcDelaunayTri(verts); print('寫入文件開始。>>>'); fout = open('output.txt', 'w'); print('共有頂點{0}個,共有三角形{1}個'.format(len(verts), len(a))); s = '$Verts = '; s += str(verts); fout.write(s + '\n\n\n\n'); s = '$Triangles = '; s += str(a); fout.write(s+'\n'); fout.close(); print('寫入文件完畢。'); ''' print('寫入文件開始。>>>'); fout = open('output.txt', 'w'); bound = [[0, 0, 0], [1000, 0, 0], [1000, 1000, 0], [0, 1000, 0]]; len_ = len(bound); print(len_); for i in range(len_): s = str(bound[i]); fout.write(s+'\n'); fout.write(str(len(verts))+'\n'); for i in range(len(verts)): s = str(verts[i]); fout.write(s+'\n'); fout.close(); print('寫入文件完畢。');</span>

然后,神農拿著這三套圖紙,回去召集手下生產車輛去了。

本節到此結束,欲知后事如何,請看下回分解。

本文轉載自mwsister博客,版權歸mwsister所有

鄧稼先:兩彈是他的勛章1986年,國內公開報道了“兩彈元勛”鄧稼先的名字,當年大漠上騰起蘑菇云的謎底終于揭開。當人們以感激的心情來頌揚這位功臣時,他卻平靜地辭世而去。而黨和國家授予他的“五一”勞動獎章和“兩彈一星功勛獎章”卻永遠閃耀著光芒。生平21歲便在學生運動中擔任了北大教職工聯合會主席;26歲在美國成為“娃娃博士”;取得學位后第九天便回國,進入中國科學院1958年以后神秘地“消失”。在戈壁大漠中,創造出世界上研制氫彈的最快速度。臨終前叮嚀:“不要讓人家把我們落得太遠…”鄧稼先,1924年出生于安徽懷寧縣一個書香門第之家。翌年,他隨母到北京,在擔任清華、北大哲學教授的父親身邊長大。他5歲入小學,在父親指點下打下了很好的中西文化基礎。1935年,他考入志成中學,與比他高兩班、且是清華大學院內鄰居的楊振寧結為最好的朋友。鄧稼先在校園中深受愛國救亡運動的影響,1937年北平淪陷后秘密參加抗日聚會。在父親安排下,他隨大姐去了大后方昆明,并于1941年考入西南聯合大學物理系。1945年抗戰勝利時,鄧稼先從西南聯大畢業,在昆明參加了共產黨的外圍組織“民青”,投身于爭取民主、反對國民黨賣國獨裁的斗爭。翌年,他回到北平,受聘擔任了北京大學物理系助教,并在學生運動中擔任了北大教職工聯合會主席。抱著學更多的本領以建設新中國之志,他于1947年通過了赴美研究生考試,于翌年秋進入美國印第安那州的普渡大學研究生院。由于他學習成績突出,不足兩年便讀滿學分,并通過博士論文答辯。此時他只有26歲,人稱“娃娃博士”。1950年8月,鄧稼先在美國獲得博士學位九天后,便謝絕了恩師和同校好友的挽留,毅然決定回國。同年10月,鄧稼先來到中國科學院近代物理研究所任研究員。此后的八年間,他進行了中國原子核理論的研究。1953年,他與許鹿希結婚,許鹿希是五四運動重要學生領袖、后來擔任全國人大常委會副委員長的許德珩的長女。1954年,鄧稼先加入了中國共產黨。1958年秋,二機部副部長錢三強找到鄧稼先,說“國家要放一個‘大炮仗’”,征詢他是否愿意參加這項必須嚴格保密的工作。鄧稼先義無反顧地同意,回家對妻子只說自己“要調動工作”,不能再照顧家和孩子,通信也困難。從小受愛國思想熏陶的妻子明白,丈夫肯定是從事對國家有重大意義的工作,表示堅決支持。從此,鄧稼先的名字便在刊物和對外聯絡中消失,他的身影只出現在嚴格警衛的深院和大漠戈壁。鄧稼先就任二機部第九研究所理論部主任后,先挑選了一批大學生,準備有關俄文資料和原子彈模型。1959年6月,蘇聯政府中止了原有協議,中共中央下決心自己動手,搞出原子彈、氫彈和人造衛星。鄧稼先擔任了原子彈的理論設計負責人后,一面部署同事們分頭研究計算,自己也帶頭攻關。在遇到一個蘇聯專家留下的核爆大氣壓的數字時,鄧稼先在周光召的幫助下以嚴謹的計算推翻了原有結論,從而解決了中國原子彈試驗成敗的關鍵性難題。數學家華羅庚后來稱,這是“集世界數學難題之大成”的成果。鄧稼先不僅在秘密科研院所里費盡心血,還經常到飛沙走石的戈壁試驗場。1964年10月,中國成功爆炸的第一顆原子彈,就是由他最后簽字確定了設計方案。他還率領研究人員在試驗后迅速進入爆炸現場采樣,以證實效果。他又同于敏等人投入對氫彈的研究。按照“鄧—于方案”,最后終于制成了氫彈,并于原子彈爆炸后的兩年零8個月試驗成功。這同法國用8年、美國用7年、蘇聯用4年的時間相比,創造了世界上最快的速度。1972年,鄧稼先擔任核武器研究院副院長,1979年又任院長。1984年,他在大漠深處指揮中國第二代新式核武器試驗成功。翌年,他的癌擴散已無法挽救,他在國慶節提出的要求就是去看看天安門。1986年7月16日,當時的副總理李鵬前往醫院授予他全國“五一”勞動獎章。同年7月29日,鄧稼先去世。他臨終前留下的話仍是如何在尖端武器方面努力,并叮嚀:“不要讓人家把我們落得太遠…”背景楊振寧故意問還不暴露工作性質的鄧稼先:“在美國聽人說,中國的原子彈是一個美國人幫助研制的。這是真的嗎?鄧稼先回答:“無論是原子彈,還是氫彈,都是中國人自己研制的。楊振寧激動得流出淚水鄧稼先的一生,是中國一代優秀知識分子的光輝榜樣。他在抗日救亡的呼喊中長大,在“千秋恥,終當雪,中興業,須人杰”的西南聯大校歌聲中走上科學之路。他從青少年時代起就抱定了以科技強國的宿愿,將個人的事業與民族興亡緊密相連。同時,他在黨的教育下知道了應該如何發動群眾進行科研攻關,為此而終生奮斗不惜個人的生命。中國能在那樣短的時間和那樣差的基礎上研制成“兩彈一星”(核彈、氫彈和衛星),西方人總感到不可思議。楊振寧來華探親返程之前,故意問還不暴露工作性質的鄧稼先說:“在美國聽人說,中國的原子彈是一個美國人幫助研制的。這是真的嗎?鄧稼先請示了周恩來后,寫信告訴他:“無論是原子彈,還是氫彈,都是中國人自己研制的。楊振寧看后激動得流出了淚水。正是由于中國有了這樣一批勇于奉獻的知識分子,才挺起了堅強的民族脊梁。故事他從美國歸來,帶了幾雙尼龍襪子送父親,還帶回一腦袋原子核的知識岳父支援的一點糧票,他都用來買餅干與同事們分享;他在基地度過10年單身漢生活鄧稼先于1950年夏天在美國取得博士學位后,完全可以留在那里并擁有良好的工作條件和優厚的待遇。但他毅然回來建設仍一窮二白的祖國。同年國慶節,在北京外事部門的招待會上,有人問他帶了什么回來?他說:“帶了幾雙眼下中國還不能生產的尼龍襪子送給父親,還帶了一腦袋關于原子核的知識。中國研制原子彈正值三年困難時期,尖端領域的科研人員雖有較高的糧食定量,卻因缺乏油水,仍經常饑腸響如鼓。鄧稼先從岳父那里能多少得到一點糧票的支援,卻都用來買餅干之類,在工作緊張時與同事們分享。就是在這樣艱苦的條件下,他們日夜加班。鄧稼先還強調試驗的基本原則是親臨第一線。他冒著酷暑嚴寒,在試驗場度過了整整10年的單身漢生活,有15次在現場領導核試驗,從而掌握了大量的第一手材料。搶上前去把摔破的原子彈碎片拿到手里檢驗鄧稼先雖長期擔任核試驗的領導工作,卻本著對工作極端負責任的精神,在最關鍵、最危險的時候出現在第一線。例如,核武器插雷管、鈾球加工等生死系于一發的險要時刻,他都站在操作人員身邊,既加強了管理,又給作業者以極大的鼓勵。一次,航投試驗時出現降落傘事故,原子彈墜地被摔裂。鄧稼先深知危險,卻一個人搶上前去把摔破的原子彈碎片拿到手里仔細檢驗。身為醫學教授的妻子知道他“抱”了摔裂的原子彈,在鄧稼先回北京時強拉他去檢查。結果發現在他的小便中帶有放射性物質,肝臟被損,骨髓里也侵入了放射物。隨后,鄧稼先仍堅持回核試驗基地。在步履艱難之時,他堅持要自己去裝雷管,并首次以院長的權威向周圍的人下命令:“你們還年輕,你們不能去!1985年,鄧稼先最后離開羅布泊回到北京,仍想參加會議。醫生強迫他住院并通知他已患有癌癥。他無力地倒在病床上,面對自己妻子以及國防部長張愛萍的安慰,平靜地說:“我知道這一天會來的,但沒想到它來得這樣快。中央盡了一切力量,卻無法挽救他的生命。在鄧稼先去世前不久,組織上為他個人配備了一輛專車。他只是在家人攙扶下,坐進去并轉了一小圈,表示已經享受了國家所給的待遇。在他去世13年后,1999年國慶50周年前夕,黨中央、國務院和中央軍委又向鄧稼先追授了金質的“兩彈一星功勛獎章”內容來自www.13333515.buzz請勿采集。

免責聲明 - 關于我們 - 聯系我們 - 廣告聯系 - 友情鏈接 - 幫助中心 - 頻道導航
Copyright © 2017 www.13333515.buzz All Rights Reserved
3排列五开奖结果