virtual ::libmaus2::autoarray::AutoArray<uint64_t> depthArray() const { ::std::vector < uint64_t > B; depthVector(B); ::libmaus2::autoarray::AutoArray<uint64_t> A(B.size()); ::std::copy ( B.begin(), B.end(), A.get()); return A; }
/** * Compute Building Footprint Polygon **/ bool computeBuildingFootprintPolygon(float maxFrontage, float maxDepth, std::vector<int> &frontEdges, std::vector<int> &rearEdges, std::vector<int> &sideEdges, Loop3D &buildableAreaCont, Loop3D &buildingFootprint) { if( (maxFrontage < 1.0f) || (maxDepth < 1.0f) ){ buildingFootprint = buildableAreaCont; return true; } buildingFootprint.clear(); int frontageIdx = -1; int frontageIdxNext; int baSz = buildableAreaCont.size(); if(baSz < 3){ return false; } float curLength; float maxBALength = -FLT_MAX; int thisIdx; int nextIdx; bool orientedCW = Polygon3D::reorientFace(buildableAreaCont, true); for(int i=0; i<frontEdges.size(); ++i){ //std::cout << "i: " << i << " FESz: " << frontEdges.size() << "\n"; std::fflush(stdout); thisIdx = frontEdges.at(i); if(orientedCW){ nextIdx = (thisIdx-1+baSz)%baSz; } else { nextIdx = (thisIdx+1)%baSz; } curLength = (buildableAreaCont.at(thisIdx)-buildableAreaCont.at(nextIdx)).lengthSquared(); if(curLength > maxBALength){ maxBALength = curLength; frontageIdx = thisIdx; frontageIdxNext = nextIdx; } } maxBALength = sqrt(maxBALength); if(frontageIdx == -1){ return false; } //std::cout << "f: " << frontageIdx << " n: " << frontageIdxNext << " s: " << buildableAreaCont.size() << "\n"; std::fflush(stdout); QVector3D frontPtA, frontPtB; QVector3D rearPtA, rearPtB; QVector3D frontageCenter = 0.5f*(buildableAreaCont.at(frontageIdx) + buildableAreaCont.at(frontageIdxNext)); QVector3D frontageVector = (buildableAreaCont.at(frontageIdx)- buildableAreaCont.at(frontageIdxNext)).normalized(); QVector3D depthVector(frontageVector.y(), -frontageVector.x(), frontageVector.z()); float actualFrontage = std::min<float>(maxFrontage, maxBALength); float actualDepth = maxDepth + maxDepth*((qrand()*0.1f)/RAND_MAX-0.05f);//misctools::genRand(-0.05, 0.05) frontPtA = frontageCenter - 0.5*actualFrontage*frontageVector; frontPtB = frontageCenter + 0.5*actualFrontage*frontageVector; rearPtA = frontPtA + depthVector*actualDepth; rearPtB = frontPtB + depthVector*actualDepth; buildingFootprint.push_back(rearPtA); buildingFootprint.push_back(rearPtB); buildingFootprint.push_back(frontPtB); buildingFootprint.push_back(frontPtA); printf("buildingFootprint %d\n",buildingFootprint.size()); return true; }