int llAlgPeakFinder::Exec(void) { if (!llAlg::Exec()) return 0; if (alg_list) { llAlgCollection *algs = _llAlgList()->GetAlgCollection(alg_list); if (!algs) { _llLogger()->WriteNextLine(-LOG_FATAL, "%s: alg collection [%s] not found", command_name, alg_list); return 0; } algs->AddAlg(this); } float stepsize = scan_radius/4.0f; int numfound = 0; //let us scan over the heightmap for (float x = x00+scan_radius; x < x11-scan_radius; x+=stepsize) { for (float y = y00+scan_radius; y < y11-scan_radius; y+=stepsize) { if (points->GetMinDistance(x,y) > scan_radius) { int is_highest = 1; float z = map->GetZ(x,y); //check for distance in pointlist //is this point the highest point? for (float x1 = 0; x1 < scan_radius; x1 +=stepsize) { for (float y1 = 0; y1 < scan_radius; y1 +=stepsize) { //is this point the highest point? if (map->GetZ(x+x1,y+y1)>z || map->GetZ(x-x1,y+y1)>z || map->GetZ(x+x1,y-y1)>z || map->GetZ(x-x1,y-y1)>z) { is_highest = 0; break; } } if (is_highest == 0) break; } if (is_highest) { points->AddPoint(x,y,z); numfound++; } } } } points->UseANN(); _llLogger()->WriteNextLine(-LOG_INFO, "AlgPeakFinder identified %i peaks", numfound); return 1; }
int llAlgRadial::Init(void) { if (!llAlg::Init()) return 0; if (alg_list) { llAlgCollection *algs = _llAlgList()->GetAlgCollection(alg_list); if (!algs) { _llLogger()->WriteNextLine(-LOG_FATAL, "%s: alg collection [%s] not found", command_name, alg_list); return 0; } algs->AddAlg(this); } return 1; }
int llSetHeight::Exec(void) { if (!llMapWorker::Exec()) return 0; llAlgCollection *algs = NULL; if (Used("-alg")) { algs = _llAlgList()->GetAlgCollection(alg_list); if (!algs) { _llLogger()->WriteNextLine(-LOG_FATAL, "%s: alg collection '%s' not found", command_name, alg_list); return 0; } } if (usegameunits) zmin /= map->GetZScale(); //convert to heightmap units int x1 = (int) map->GetRawX(_llUtils()->x00); int x2 = (int) map->GetRawX(_llUtils()->x11); int y1 = (int) map->GetRawY(_llUtils()->y00); int y2 = (int) map->GetRawY(_llUtils()->y11); for (int x=x1; x<=x2; x+=1) { for (int y=y1; y<=y2; y+=1) { double alg = 0.0; if (algs) { alg = algs->GetValue(map->GetCoordX(x), map->GetCoordY(y)); } if (min && map->GetElementRaw(x, y) < zmin) map->SetElementRaw(x, y, zmin + alg); else if (max && map->GetElementRaw(x, y) > zmin) map->SetElementRaw(x, y, zmin + alg); else if (!min && !max) map->SetElementRaw(x, y, zmin + alg); } } return 1; }
int llFillColorMap::Exec(void) { if (!llMapWorker::Exec()) return 0; if (!map->IsColorMap()) { _llLogger()->WriteNextLine(-LOG_ERROR, "%s: map is no color map", command_name); return 0; } llAlgCollection *algs_blue = NULL; if (Used("-algblue")) { algs_blue = _llAlgList()->GetAlgCollection(alg_list_blue); if (!algs_blue) { _llLogger()->WriteNextLine(-LOG_ERROR, "%s: alg collection '%s' not found for blue channel", command_name, alg_list_blue); return 0; } algs_blue->UpdateMaps(); } llAlgCollection *algs_red = NULL; if (Used("-algred")) { algs_red = _llAlgList()->GetAlgCollection(alg_list_red); if (!algs_red) { _llLogger()->WriteNextLine(-LOG_ERROR, "%s: alg collection '%s' not found for red channel", command_name, alg_list_red); return 0; } algs_red->UpdateMaps(); } llAlgCollection *algs_green = NULL; if (Used("-alggreen")) { algs_green = _llAlgList()->GetAlgCollection(alg_list_green); if (!algs_green) { _llLogger()->WriteNextLine(-LOG_ERROR, "%s: alg collection '%s' not found for green channel", command_name, alg_list_green); return 0; } algs_green->UpdateMaps(); } llAlgCollection *algs_alpha = NULL; if (Used("-algalpha")) { algs_alpha = _llAlgList()->GetAlgCollection(alg_list_alpha); if (!algs_alpha) { _llLogger()->WriteNextLine(-LOG_ERROR, "%s: alg collection '%s' not found for alpha channel", command_name, alg_list_alpha); return 0; } algs_alpha->UpdateMaps(); } unsigned int widthx = map->GetWidthX(); unsigned int widthy = map->GetWidthY(); for (unsigned int x=0; x<widthx; x++) { for (unsigned int y=0; y<widthy; y++) { if (algs_blue) { double f_blue = 255. * algs_blue->GetValue(map->GetCoordX(x), map->GetCoordY(y)); if (f_blue > 255.) f_blue = 255.; unsigned char blue = (unsigned char)(f_blue); map->SetBlue(x, y, blue); } else map->SetBlue(x, y, 0); if (algs_red) { double f_red = 255. * algs_red->GetValue(map->GetCoordX(x), map->GetCoordY(y)); if (f_red > 255.) f_red = 255.; unsigned char red = (unsigned char)(f_red); map->SetRed(x, y, red); } else map->SetRed(x, y, 0); if (algs_green) { double f_green = 255. * algs_green->GetValue(map->GetCoordX(x), map->GetCoordY(y)); if (f_green > 255.) f_green = 255.; unsigned char green = (unsigned char)(f_green); map->SetGreen(x, y, green); } else map->SetGreen(x, y, 0); if (algs_alpha) { double f_alpha = 255. * algs_alpha->GetValue(map->GetCoordX(x), map->GetCoordY(y)); if (f_alpha > 255.) f_alpha = 255.; unsigned char alpha = (unsigned char)(f_alpha); map->SetAlpha(x, y, alpha); } else map->SetAlpha(x, y, 0); } } return 1; }