void filesave(char *temp) { FILE *tmp; NODE *arg; int save_yield_flag; if (::FindWindow(NULL, "Editor")) { MainWindowx->CommandWindow->MessageBox("Did you know you have an edit session running?\n\nAny changes in this edit session are not being saved.", "Information", MB_OK | MB_ICONQUESTION); } arg = cons(make_strnode(temp, NULL, strlen(temp), STRING, strnzcpy), NIL); tmp = writestream; writestream = open_file(car(arg), "w+"); if (writestream != NULL) { save_yield_flag = yield_flag; yield_flag = 0; lsetcursorwait(); setcar(arg, cons(lcontents(), NIL)); lpo(car(arg)); fclose(writestream); IsDirty = 0; lsetcursorarrow(); yield_flag = save_yield_flag; } else err_logo(FILE_ERROR, make_static_strnode("Could not open file")); writestream = tmp; }
int main(int argc,char* argv[]) { /* Parse the command line: */ size_t memoryCache=128; const char* lidarFileName=0; float neighborhoodRadius=1.0f; unsigned int minNumNeighbors=3; const char* outlierFileName="Outliers.bin"; for(int i=1;i<argc;++i) { if(argv[i][0]=='-') { if(strcasecmp(argv[i]+1,"cache")==0) { ++i; memoryCache=size_t(atoi(argv[i])); } else if(strcasecmp(argv[i]+1,"radius")==0) { ++i; neighborhoodRadius=float(atof(argv[i])); } else if(strcasecmp(argv[i]+1,"minNeighbors")==0) { ++i; minNumNeighbors=(unsigned int)atoi(argv[i]); } } else if(lidarFileName==0) lidarFileName=argv[i]; else if(outlierFileName==0) outlierFileName=argv[i]; } if(lidarFileName==0) { std::cerr<<"No LiDAR file name provided"<<std::endl; return 1; } /* Open the LiDAR octree file: */ LidarProcessOctree lpo(lidarFileName,memoryCache*size_t(1024*1024)); /* Open the outlier file: */ IO::SeekableFilePtr outlierFile(IO::openSeekableFile(outlierFileName,IO::File::WriteOnly)); outlierFile->setEndianness(Misc::LittleEndian); /* Write a bogus file header: */ outlierFile->write<unsigned int>(0); /* Process the LiDAR file: */ OutlierSaver os(lpo,neighborhoodRadius,minNumNeighbors,outlierFile); lpo.processPoints(os); /* Finalize the outlier file: */ outlierFile->setWritePosAbs(0); outlierFile->write<unsigned int>(os.getNumOutliers()); std::cout<<os.getNumOutliers()<<" outlier points written to "<<outlierFileName<<std::endl; return 0; }
int main(int argc,char* argv[]) { LidarProcessOctree lpo(argv[1],512*1024*1024); #if 0 Misc::Timer t; { // BinaryPointSaver bps(argv[2]); double scale[3]={0.001,0.001,0.001}; double offset[3]; for(int i=0;i<3;++i) offset[i]=lpo.getDomain().getCenter(i); LasPointSaver lps(argv[2],scale,offset); // PointCounter pc; Box box(Box::Point(2.04446e6,617053.0,-1000.0),Box::Point(2.04446e6+100.0,617053.0+100.0,1000.0)); lpo.processPointsInBox(box,lps); // std::cout<<lps.getNumPoints()<<std::endl; } t.elapse(); std::cout<<"Done in "<<t.getTime()*1000.0<<" ms"<<std::endl; #elif 0 PointSaver ps(argv[2]); Box box=Box::full; for(int i=0;i<2;++i) { box.min[i]=atof(argv[3+i]); box.max[i]=atof(argv[5+i]); } lpo.processPointsInBox(box,ps); #elif 0 PointCounter pc; lpo.processPoints(pc); std::cout<<pc.getNumPoints()<<std::endl; #else Scalar radius=Scalar(0.1); PointDensityCalculator pdc(lpo,radius,4); #if 0 Box box; box.min=Point(930,530,0); box.max=Point(970,570,100); lpo.processPointsInBox(box,pdc); #else // lpo.processPoints(pdc); lpo.processNodesPostfix(pdc); #endif std::cout<<"Number of processed points: "<<pdc.numPoints<<std::endl; std::cout<<"Total number of found neighbors: "<<pdc.totalNumNeighbors<<std::endl; std::cout<<"Total number of loaded octree nodes: "<<lpo.getNumSubdivideCalls()<<", "<<lpo.getNumLoadedNodes()<<std::endl; std::cout<<"Average point density in 1/m^3: "<<pdc.totalNumNeighbors/(pdc.numPoints*4.0/3.0*3.141592654*radius*radius*radius)<<std::endl; #endif return 0; }
int main(int argc,char* argv[]) { LidarProcessOctree lpo(argv[1],512*1024*1024); Misc::Timer t; size_t numLeafPoints=0; for(LidarProcessOctree::PointIterator pIt=lpo.beginNodes();pIt!=lpo.endNodes();++pIt) ++numLeafPoints; t.elapse(); std::cout<<numLeafPoints<<" leaf points, "; std::cout<<"done in "<<t.getTime()*1000.0<<" ms"<<std::endl; return 0; }
NODE *lsave(NODE *arg) { FILE *tmp; tmp = writestream; writestream = open_file(car(arg), "w+"); if (writestream != NULL) { setcar(arg, cons(lcontents(), NIL)); lpo(car(arg)); fclose(writestream); } else err_logo(FILE_ERROR, make_static_strnode("Could not open file")); writestream = tmp; return(UNBOUND); }
int main(int argc,char* argv[]) { const char* fileName=0; Scalar radius=Scalar(0); int cacheSize=512; for(int i=1;i<argc;++i) { if(argv[i][0]=='-') { if(strcasecmp(argv[i]+1,"radius")==0) { ++i; radius=Scalar(atof(argv[i])); } else if(strcasecmp(argv[i]+1,"cache")==0) { ++i; cacheSize=atoi(argv[i]); } } else if(fileName==0) fileName=argv[i]; } if(fileName==0) { std::cerr<<"No file name provided"<<std::endl; return 1; } /* Create a processing octree: */ LidarProcessOctree lpo(fileName,size_t(cacheSize)*size_t(1024*1024)); /* Calculate normal vectors for all points in the octree: */ std::string normalFileName=fileName; normalFileName.push_back('/'); normalFileName.append("Normals"); NodeNormalCalculator nodeNormalCalculator(lpo,radius,normalFileName.c_str()); std::cout<<"Calculating normal vectors... 0%"<<std::flush; lpo.processNodesPostfix(nodeNormalCalculator); std::cout<<std::endl; return 0; }
NODE *lsave(NODE *arg) { FILE *tmp; NODE *name; if (arg == NIL) name = save_name; else name = car(arg); tmp = writestream; if (name != NIL) { writestream = open_file(name, "w+"); if (writestream != NULL) { lpo(cons(lcontents(NIL), NIL)); fclose(writestream); need_save = 0; save_name = name; } else err_logo(CANT_OPEN_ERROR, car(arg)); } else err_logo(NOT_ENOUGH, NIL); writestream = tmp; return(UNBOUND); }
int main(int argc,char* argv[]) { const char* lidarFileName=0; size_t octreeCacheSize=512; size_t imageCacheSize=512; const char* colorFileName=0; std::vector<Image2D*> images; for(int i=1;i<argc;++i) { if(argv[i][0]=='-') { if(strcasecmp(argv[i]+1,"octreeCache")==0) { ++i; octreeCacheSize=size_t(atoi(argv[i])); } else if(strcasecmp(argv[i]+1,"imageCache")==0) { ++i; imageCacheSize=size_t(atoi(argv[i])); } } else if(lidarFileName==0) lidarFileName=argv[i]; else if(colorFileName==0) colorFileName=argv[i]; else { /* Load an image: */ Image2D* newImage=new Image2D(argv[i]); images.push_back(newImage); } } if(lidarFileName==0) { std::cerr<<"No LiDAR file name provided"<<std::endl; return 1; } if(colorFileName==0) colorFileName="Colors"; if(images.empty()) { std::cerr<<"No images provided"<<std::endl; return 1; } /* Create a processing octree: */ LidarProcessOctree lpo(lidarFileName,octreeCacheSize*size_t(1024*1024)); std::cout<<"LiDAR coordinate offset: "<<lpo.getOffset()[0]<<", "<<lpo.getOffset()[1]<<", "<<lpo.getOffset()[2]<<std::endl; /* Assign colors to all points in the octree: */ std::string lidarColorFileName=lidarFileName; lidarColorFileName.push_back('/'); lidarColorFileName.append(colorFileName); NodeColorSampler nodeColorSampler(lpo,images,imageCacheSize*size_t(1024*1024),lidarColorFileName.c_str()); std::cout<<"Assigning colors... 0%"<<std::flush; lpo.processNodesPostfix(nodeColorSampler); std::cout<<std::endl; std::cout<<nodeColorSampler.getNumAssignedColors()<<" LiDAR points re-colored"<<std::endl; std::cout<<nodeColorSampler.getImageCacher().getNumPageInRequests()<<" images paged into main memory during processing"<<std::endl; /* Delete all images: */ for(std::vector<Image2D*>::iterator iIt=images.begin();iIt!=images.end();++iIt) delete *iIt; return 0; }
void loadPointSet(const char* lidarFileName,unsigned int memCacheSize,const char* pointFileName,Scalar filterRadius,int numLobes,const Vector& pointOffset) { /* Create a color and coordinate node to receive points: */ SceneGraph::ColorNode* color=new SceneGraph::ColorNode; SceneGraph::CoordinateNode* coord=new SceneGraph::CoordinateNode; /* Create the point set node: */ SceneGraph::PointSetNode* pointSet=new SceneGraph::PointSetNode; pointSet->color.setValue(color); pointSet->coord.setValue(coord); pointSet->pointSize.setValue(5); pointSet->update(); SceneGraph::ShapeNode* shape=new SceneGraph::ShapeNode; shape->geometry.setValue(pointSet); shape->update(); getSceneGraphRoot().children.appendValue(shape); getSceneGraphRoot().update(); /* Create a temporary LiDAR processing octree to calculate point elevations: */ LidarProcessOctree lpo(lidarFileName,size_t(memCacheSize)*size_t(1024*1024)); /* Open the point file: */ IO::AutoFile pointFile(IO::openFile(pointFileName)); IO::ValueSource pointSource(*pointFile); pointSource.setWhitespace(""); pointSource.setPunctuation(",\n"); pointSource.setQuotes("\""); /* Read the header line: */ int valueCol=-1; int posCol[2]={-1,-1}; for(int col=0;!pointSource.eof()&&pointSource.peekc()!='\n';++col) { std::string columnHeader=pointSource.readString(); if(columnHeader=="DamageID1") valueCol=col; else if(columnHeader=="POINT_X") posCol[0]=col; else if(columnHeader=="POINT_Y") posCol[1]=col; if(pointSource.peekc()==',') pointSource.skipString(); } /* Go to the next line: */ pointSource.skipString(); /* Read all points: */ while(!pointSource.eof()) { /* Read the current line: */ double value=0.0; double pos[2]={0.0,0.0}; for(int col=0;!pointSource.eof()&&pointSource.peekc()!='\n';++col) { if(col==valueCol) value=pointSource.readNumber(); else if(col==posCol[0]) pos[0]=pointSource.readNumber(); else if(col==posCol[1]) pos[1]=pointSource.readNumber(); else pointSource.skipString(); if(pointSource.peekc()==',') pointSource.skipString(); } /* Calculate the current point's elevation: */ LidarRadialElevationSampler les(pos,filterRadius,numLobes); lpo.processPointsInBox(les.getBox(),les); if(les.getAbsWeightSum()>0.0) { /* Add the point to the coordinate node: */ SceneGraph::Point p; for(int i=0;i<2;++i) p[i]=SceneGraph::Scalar(pos[i]-double(pointOffset[i])); p[2]=SceneGraph::Scalar(les.getValue()-double(pointOffset[2])); coord->point.appendValue(p); if(value<2.5) color->color.appendValue(SceneGraph::Color(1.0f,0.0f,0.0f)); else if(value<3.5) color->color.appendValue(SceneGraph::Color(1.0f,0.5f,0.0f)); else if(value<4.5) color->color.appendValue(SceneGraph::Color(0.5f,1.0f,0.0f)); else if(value<5.5) color->color.appendValue(SceneGraph::Color(0.0f,1.0f,0.0f)); else color->color.appendValue(SceneGraph::Color(0.0f,1.0f,0.0f)); } /* Go to the next line: */ pointSource.skipString(); } color->update(); coord->update(); }
int main(int argc,char* argv[]) { /* Process command line: */ const char* lidarFile=0; const char* asciiFile=0; int cacheSize=512; bool haveBox=false; double box[6]; for(int i=1;i<argc;++i) { if(argv[i][0]=='-') { if(strcasecmp(argv[i]+1,"cache")==0) { ++i; cacheSize=atoi(argv[i]); } else if(strcasecmp(argv[i]+1,"box")==0) { haveBox=true; for(int j=0;j<6;++j) { ++i; box[j]=Box::Scalar(atof(argv[i])); } } else std::cerr<<"Ignoring command line option "<<argv[i]<<std::endl; } else if(lidarFile==0) lidarFile=argv[i]; else if(asciiFile==0) asciiFile=argv[i]; else std::cerr<<"Ignoring command line argument "<<argv[i]<<std::endl; } if(lidarFile==0) { std::cerr<<"No input LiDAR file name provided"<<std::endl; return 1; } if(asciiFile==0) { std::cerr<<"No output ASCII file name provided"<<std::endl; return 1; } /* Open the input and output files: */ LidarProcessOctree lpo(lidarFile,size_t(cacheSize)*1024*1024); PointSaver ps(lpo.getOffset(),asciiFile); /* Process the LiDAR file: */ if(haveBox) { /* Transform the box to LiDAR coordinates: */ Box lbox; for(int i=0;i<3;++i) { lbox.min[i]=Box::Scalar(box[i]-lpo.getOffset()[i]); lbox.max[i]=Box::Scalar(box[3+i]-lpo.getOffset()[i]); lpo.processPointsInBox(lbox,ps); } } else lpo.processPoints(ps); /* Print statistics: */ std::cout<<ps.getNumPoints()<<" points saved"<<std::endl; return 0; }
int main(int argc,char* argv[]) { /* Process command line: */ const char* lidarFile=0; const char* asciiFile=0; int cacheSize=512; Box box=Box::full; for(int i=1;i<argc;++i) { if(argv[i][0]=='-') { if(strcasecmp(argv[i]+1,"cache")==0) { ++i; cacheSize=atoi(argv[i]); } else if(strcasecmp(argv[i]+1,"box")==0) { Box::Point min,max; for(int j=0;j<3;++j) { ++i; min[j]=Box::Scalar(atof(argv[i])); } for(int j=0;j<3;++j) { ++i; max[j]=Box::Scalar(atof(argv[i])); } box=Box(min,max); } else std::cerr<<"Ignoring command line option "<<argv[i]<<std::endl; } else if(lidarFile==0) lidarFile=argv[i]; else if(asciiFile==0) asciiFile=argv[i]; else std::cerr<<"Ignoring command line argument "<<argv[i]<<std::endl; } if(lidarFile==0) { std::cerr<<"No input LiDAR file name provided"<<std::endl; return 1; } if(asciiFile==0) { std::cerr<<"No output ASCII file name provided"<<std::endl; return 1; } /* Open the input and output files: */ LidarProcessOctree lpo(lidarFile,size_t(cacheSize)*1024*1024); PointSaver ps(asciiFile); /* Process the LiDAR file: */ lpo.processPointsInBox(box,ps); /* Print statistics: */ std::cout<<ps.getNumPoints()<<" points saved"<<std::endl; return 0; }