예제 #1
0
// loads the input map files (filename1 and filename2) in the two vectors (positions1 and positions2).
// returns FALSE if the files failed to load, TRUE otherwise.
bool loadMaps(char* filename1, char* filename2,
		std::vector<Eigen::Vector3d> * positions1,
		std::vector<Eigen::Vector3d> * positions2) {
	std::ifstream * f1 = new std::ifstream(filename1);
	std::ifstream * f2 = new std::ifstream(filename2);

	if (!f1->is_open()) {
		//		std::cout << "error opening file << " << filename1 << "\nExiting...\n";
		return false;
	}
	if (!f2->is_open()) {
		//		std::cout << "error opening file << " << filename2 << "\nExiting...\n";
		return false;
	}

	readMapFile(std::string(filename1), positions1);
	readMapFile(std::string(filename2), positions2);

	return true;
}
예제 #2
0
파일: map.cpp 프로젝트: TarekTaha/robotics
/*! Constructor of the Map Class:
 * @param filename is the file name of the image map to open.
 * @param pixelRes is the underlying pixel/m resolution of the map.
 * @param negate_in specifies if the white pixels are empty or occupied in the map.
 */
Map::Map(char* filename, float pixelRes,bool negate_in):
negate(negate_in),
pixbuf(NULL),
width(0),
height(0),
mapRes(pixelRes),
grid(NULL),
mapFileName(filename)
{
	readMapFile(filename); 
};
예제 #3
0
FileMap::FileMap(const eString& path, const eString& file, const eString& type )
: mapPath( path )
, mapFile(file)
, isDirty( false )
, initDone(false)
{
    if (type=="rt_uk")
        readRadioTimesChannels();

	readMapFile(type != "rt_uk");
    initDone = true;
}
예제 #4
0
static void
getMapping(const char *         const rmapFileName,
           const unsigned int * const lumahist,
           xelval               const maxval,
           unsigned int         const pixelCount,
           gray **              const lumamapP) {
/*----------------------------------------------------------------------------
  Calculate the luminosity mapping table which gives the
  histogram-equalized luminosity for each original luminosity.
-----------------------------------------------------------------------------*/
    gray * lumamap;

    lumamap = pgm_allocrow(maxval+1);

    if (rmapFileName)
        readMapFile(rmapFileName, maxval, lumamap);
    else
        computeMap(lumahist, maxval, pixelCount, lumamap);

    *lumamapP = lumamap;
}
예제 #5
0
int main(int argc, char* argv[])
{
  t_Node    *ptTree = NULL;
  FILE      *ifp    = NULL;
  t_Params  tParams;
  t_Data    tData;
  t_Map     tMap;
  t_Node     **aptSplit = (t_Node **) malloc(MAX_SPLIT*sizeof(t_Node *));
  int        nSplit = 0;
  double     dMaxDepth = 0.0, dSplitDepth = 0.0, dDepth = 0.0;
  int        iL = 0, nLast = 0, nCount = 0, i = 0, j = 0;
  int*       anLast = NULL;
  char szDir[MAX_WORD_LENGTH];
  char szTreeFile[MAX_WORD_LENGTH];
  char szDatFile[MAX_WORD_LENGTH];
  char szListFile[MAX_WORD_LENGTH];
  FILE* tfp = NULL, *dfp = NULL, *lfp = NULL;

  getCommandLineParams(&tParams, argc, argv);

  readData(&tData, tParams.szDatFile);

  readMapFile(&tMap, tParams.szMapFile);

  ifp = fopen(tParams.szTreeFile, "r");

  if(ifp){
    addElement(&ptTree, ifp);

    fclose(ifp);
  }
  else{
    printf("Failed to open tree file\n");
  }
  
  setLeaves(ptTree);

  treeSplitEven(ptTree, tParams.nSplit, aptSplit, &nSplit);

  for(i = 0; i < nSplit; i++){

    countLeaves(aptSplit[i],&(aptSplit[i]->nN));

    if(aptSplit[i]->nN < tParams.nMinSize){
      nLast += aptSplit[i]->nN;
    }

    aptSplit[i]->anLeaves = (int *) malloc(sizeof(int)*aptSplit[i]->nN);
    
    nCount = 0;
    
    getLeaves(aptSplit[i],aptSplit[i]->anLeaves, &nCount);
  }

  maxDepth(ptTree, &dMaxDepth);

  setDepth(ptTree, 0.0);

  /*sort on number of leaves*/
  //void qsort(void* field, size_t nElements, size_t sizeOfAnElement,
  //                 int(_USERENTRY *cmpFunc)(const void*, const void*));


  qsort(aptSplit,nSplit,sizeof(t_Node*),compNode);

  i = 0;
  while(i < nSplit && aptSplit[i]->nN >= tParams.nMinSize){

    sprintf(szDir, "C%03d",i);
    
    mkdir(szDir, S_IRWXU);

    sprintf(szTreeFile,"%s/%s%s",szDir,szDir,TREE_SUFFIX);
    sprintf(szDatFile,"%s/%s%s",szDir,szDir,DAT_SUFFIX);
    sprintf(szListFile,"%s/%s%s",szDir,szDir,LIST_SUFFIX);

    printf("%d %d %f\n",i,aptSplit[i]->nN,dMaxDepth - aptSplit[i]->dDepth);


    tfp = fopen(szTreeFile, "w");

    if(tfp){
      writeTree(aptSplit[i], tfp);
      fprintf(tfp, ";\n");
      fclose(tfp);
    }

    dfp = fopen(szDatFile, "w");

    if(dfp){
      writeData(dfp, &tData, aptSplit[i]->nN, aptSplit[i]->anLeaves, &tMap);
    
      fclose(dfp);
    }

    nCount=0;
    renumberLeaves(aptSplit[i], &nCount);

    lfp = fopen(szListFile, "w");

    if(lfp){
      writeList(lfp, aptSplit[i], dMaxDepth - aptSplit[i]->dDepth);
    
      fclose(lfp);
    }
    i++;
  }
  
  if(nLast > 0){
    anLast = (int *) malloc(sizeof(int)*nLast);
    nCount = 0;
    printf("%d %d\n",i,nLast);
    iL = i;
    for(; i < nSplit; i++){
      for(j = 0; j < aptSplit[i]->nN; j++){
	anLast[nCount + j] = aptSplit[i]->anLeaves[j];
      }
      nCount += aptSplit[i]->nN;
    }

    if(nCount > 0){
      sprintf(szDir, "C%03d+",iL);
  
      mkdir(szDir, S_IRWXU);

      sprintf(szTreeFile,"%s/%s%s",szDir,szDir,TREE_SUFFIX);
      sprintf(szDatFile,"%s/%s%s",szDir,szDir,DAT_SUFFIX);
      sprintf(szListFile,"%s/%s%s",szDir,szDir,LIST_SUFFIX);

      dfp = fopen(szDatFile, "w");

      if(dfp){
	writeData(dfp, &tData, nLast, anLast, &tMap);
    
	fclose(dfp);
      }
    }

    free(anLast);
  }
  exit(EXIT_SUCCESS);
}