Geometry* ConvexHull::getConvexHull() { size_t nInputPts=inputPts.size(); if (nInputPts==0) // Return an empty geometry return geomFactory->createEmptyGeometry(); if (nInputPts==1) // Return a Point { // Copy the Coordinate from the ConstVect return geomFactory->createPoint(*(inputPts[0])); } if (nInputPts==2) // Return a LineString { // Copy all Coordinates from the ConstVect CoordinateSequence *cs = toCoordinateSequence(inputPts); return geomFactory->createLineString(cs); } // use heuristic to reduce points, if large if (nInputPts > 50 ) { reduce(inputPts); } // sort points for Graham scan. preSort(inputPts); // Use Graham scan to find convex hull. Coordinate::ConstVect cHS; grahamScan(inputPts, cHS); return lineOrPolygon(cHS); }
int main(void) { int i, j; int numOfTest=0; int numOfPoint=0; int* stack = NULL; point* p = NULL; double dis=0; //input the each informations... and memory allocation.... printf("Enter the number of the testCase : "); scanf("%d", &numOfTest); for(j=0; j<numOfTest; j++) { while(1) { printf("Enter the number of point : "); scanf("%d", &numOfPoint); if(numOfPoint<=100) { break; } printf("[ERROR] number of point <=100 \n\n"); } numOfPoint++; stack = (int*)malloc(sizeof(int)*numOfPoint); stack[0]=0; p = (point*)malloc(sizeof(point)*numOfPoint); p[0].x =0; p[0].y =0; p[0].AngWithStartPoint =0; for(i=0; i<numOfPoint; i++) { p[i].AngWithStartPoint =0; // initialization angle with start point } for(i=1; i<numOfPoint; i++) { printf("Enter the [%d]loc : ", i); scanf("%lf %lf",&p[i].x, &p[i].y); p[i].AngWithStartPoint = getAng(p[0].x, p[0].y, p[i].x, p[i].y); //set the each angle with the start point(0,0)... stack[i]=100; } // //sort by angle.. sortByAng(p, numOfPoint); // dis = grahamScan(p,numOfPoint, stack); dis +=2; //dis+=0.05; printf("\nminimum distance : %.2lf\n\n", dis); dis =0; } }