Created
December 24, 2013 09:58
-
-
Save andikan/8111095 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vector<Point*> Mesh::getSimplifiedPointEdgeSet(vector<Point*> &edgePoints) | |
| { | |
| vector<Point*> simplePointEdgeSet; | |
| vector<Point*> tempPoints; | |
| bool existJointPoint = false; | |
| cout << "edgePoints : " << edgePoints.size() / 2 << endl; | |
| for(int i=0; i<edgePoints.size(); i++) | |
| { | |
| vector<Point*> neighborPoints; | |
| neighborPoints = getNeighborPoint(edgePoints[i], edgePoints); | |
| if(neighborPoints.size() > 2) | |
| { | |
| for(int j=0; j<neighborPoints.size(); j++) | |
| { | |
| findNextSimplifiedPointEdge(simplePointEdgeSet, edgePoints, neighborPoints[j], edgePoints[i], edgePoints[i], tempPoints); | |
| } | |
| existJointPoint = true; | |
| break; | |
| } | |
| } | |
| if(!existJointPoint) | |
| { | |
| for(int i=0; i<edgePoints.size(); i++) | |
| { | |
| vector<Point*> neighborPoints = getNeighborPoint(edgePoints[i], edgePoints); | |
| if(neighborPoints.size() == 1) | |
| { | |
| findNextSimplifiedPointEdge(simplePointEdgeSet, edgePoints, neighborPoints[0], edgePoints[i], edgePoints[i], tempPoints); | |
| break; | |
| } | |
| } | |
| } | |
| return simplePointEdgeSet; | |
| } | |
| void Mesh::findNextSimplifiedPointEdge(std::vector<Point*> &simplePointEdgeSet, std::vector<Point*> &edgePoints, Point* currentPoint, | |
| Point* prevPoint, Point* prevJointPoint, std::vector<Point*> &tempPoints) | |
| { | |
| vector<Point*> neighborPoints; | |
| neighborPoints = getNeighborPoint(currentPoint, edgePoints); | |
| // current is joint point | |
| if(neighborPoints.size() > 2) | |
| { | |
| if(tempPoints.size() < 5) | |
| { | |
| simplePointEdgeSet.push_back(prevJointPoint); | |
| simplePointEdgeSet.push_back(currentPoint); | |
| } | |
| else | |
| { | |
| simplePointEdgeSet.push_back(prevJointPoint); | |
| // simplePointEdgeSet.push_back(tempPoints[(tempPoints.size()/2)]); | |
| // simplePointEdgeSet.push_back(tempPoints[(tempPoints.size()/2)]); | |
| simplePointEdgeSet.push_back(currentPoint); | |
| } | |
| tempPoints.clear(); | |
| for(int i=0; i<neighborPoints.size(); i++) | |
| { | |
| if(!neighborPoints[i]->isEqualTo(prevPoint)) | |
| { | |
| findNextSimplifiedPointEdge(simplePointEdgeSet, edgePoints, neighborPoints[i], currentPoint, currentPoint, tempPoints); | |
| } | |
| } | |
| return; | |
| } | |
| // current is sleeve point | |
| else if(neighborPoints.size() == 2) | |
| { | |
| tempPoints.push_back(currentPoint); | |
| for(int i=0; i<neighborPoints.size(); i++) | |
| { | |
| if(!neighborPoints[i]->isEqualTo(prevPoint)) | |
| { | |
| findNextSimplifiedPointEdge(simplePointEdgeSet, edgePoints, neighborPoints[i], currentPoint, prevJointPoint, tempPoints); | |
| } | |
| } | |
| return; | |
| } | |
| // current is terminal point | |
| else if(neighborPoints.size() == 1) | |
| { | |
| if(tempPoints.size() < 8) | |
| { | |
| simplePointEdgeSet.push_back(prevJointPoint); | |
| simplePointEdgeSet.push_back(currentPoint); | |
| } | |
| else | |
| { | |
| simplePointEdgeSet.push_back(prevJointPoint); | |
| simplePointEdgeSet.push_back(tempPoints[(tempPoints.size()/2)-1]); | |
| simplePointEdgeSet.push_back(tempPoints[(tempPoints.size()/2)-1]); | |
| simplePointEdgeSet.push_back(currentPoint); | |
| } | |
| tempPoints.clear(); | |
| return; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // get new joint point edges set | |
| std::vector<Point*> getSimplifiedPointEdgeSet(std::vector<Point*> &edgePoints); | |
| void findNextSimplifiedPointEdge(std::vector<Point*> &simplePointEdgeSet, std::vector<Point*> &edgePoints, Point* currentPoint, | |
| Point* prevPoint, Point* prevJointPoint, std::vector<Point*> &tempPoints); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment