void Shape::readPolygon(OGRPolygon* poPolygon, ShapeObject& shapeObject) { int nInteriorRings = poPolygon->getNumInteriorRings(); shapeObject.parts.resize(nInteriorRings + 1); OGRLinearRing* ring = poPolygon->getExteriorRing(); readRing(ring, shapeObject.parts[0]); for (int j = 0; j < nInteriorRings; ++j) { OGRLinearRing* ring = poPolygon->getInteriorRing(j); readRing(ring, shapeObject.parts[j + 1]); } }
/** * 複数のポリゴンから成るオブジェクトを読み込む。 * 今の実装は、正確には対応していない。オブジェクトのpartsに順次格納していくだけ。 * そのため、アプリケーション側でparts[0]しか使わない場合、まずい。 */ void Shape::readMultiPolygon(OGRMultiPolygon* poMultiPolygon, ShapeObject& shapeObject) { int numGeometries = poMultiPolygon->getNumGeometries(); int partsIndex = 0; for (int i = 0; i < numGeometries; ++i) { OGRGeometry* geo = poMultiPolygon->getGeometryRef(i); if (wkbFlatten(geo->getGeometryType()) == wkbPolygon) { OGRPolygon* poPolygon = (OGRPolygon*)geo; int nInteriorRings = poPolygon->getNumInteriorRings(); shapeObject.parts.resize(shapeObject.parts.size() + nInteriorRings + 1); OGRLinearRing* ring = poPolygon->getExteriorRing(); readRing(ring, shapeObject.parts[partsIndex++]); for (int j = 0; j < nInteriorRings; ++j) { OGRLinearRing* ring = poPolygon->getInteriorRing(j); readRing(ring, shapeObject.parts[partsIndex++]); } } } }
// Format for reading. int main(int argc, char** argv) { std::ifstream infile(argv[1]); ResPolyRing* R = readRing(infile); SchreyerFrame S(R); loadSchreyerFrame(infile, S); infile.close(); #if 0 int v; for (int i=0; i<50; i++) for (int j=0; j<50; j++) kk.add(v,i,j); ResPolyRing R(G, M); // TODO: need degrees of variables... // Possibly need different term orders // read Groebner basis // FreeModule F(R, ncomps, degrees); std::vector<poly> GB; // read in GB somehow, or should the SchreyerResolution provide // a set of routines to read in the GB? C.startGB(nelems); C.startGenerator(nterms); C.term(intcoeff, nparts); C.exponent(var,exp); C.endGB(); SchreyerResolution C(R, GB); // set Schreyer frame #0 // set Schreyer frame #1 // compute the rest of the frame // compute the maps in the res, possibly parallel. // compute the ranks of the matrices, obtaining minimal betti numbers. // WARNING: need to worry about entire degree 0 complex? #endif return 0; }