Example #1
0
/// Reconstruct an index from a piece of consecutive memory.  Unlike the
/// implementations for other type indices, this function always reads all
/// bit vectors.
int ibis::skive::read(ibis::fileManager::storage* st) {
    if (st == 0) return -1;
    if (st->begin()[5] != ibis::index::SKIVE &&
	st->begin()[5] != ibis::index::SLICE) return -3;
    clear(); // clear the current conent

    nrows = *(reinterpret_cast<uint32_t*>(st->begin()+8));
    uint32_t pos = 8+sizeof(uint32_t);
    const uint32_t nobs = *(reinterpret_cast<uint32_t*>(st->begin()+pos));
    pos += sizeof(uint32_t);
    const uint32_t card = *(reinterpret_cast<uint32_t*>(st->begin()+pos));
    pos += sizeof(uint32_t) + 7;
    pos = 8 * (pos / 8);
    int ierr = initOffsets(st, pos + sizeof(double)*card, nobs);
    if (ierr < 0)
	return ierr;

    { // limit the scope of dbl
	array_t<double> dbl(st, pos, card);
	vals.swap(dbl);
    }
    {
	pos += sizeof(double)*card + sizeof(int32_t)*(nobs+1);
	array_t<uint32_t> szt(st, pos, card);
	cnts.swap(szt);
    }

    initBitmaps(st);
    activate();
    return 0;
} // ibis::skive::read
Example #2
0
RenderableEffect::RenderableEffect(int i, std::string n,
                                   const char **data16,
                                   const char **data24,
                                   const char **data32,
                                   const char **data48,
                                   const char **data64)
    : id(i), name(n), tooltip(n), panel(nullptr), mSequenceElements(nullptr)
{
    initBitmaps(data16, data24, data32, data48, data64);
}
Example #3
0
void init() {
	//codes for initialization
	initializeCamera();
	canDrawGrid = true;
	
	//initialize the matrix
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	
	//lighting
	enableLighting();

	//give PERSPECTIVE parameters
	gluPerspective(70,	1,	0.1,	10000.0);
	//field of view in the Y (vertically)
	//aspect ratio that determines the field of view in the X direction (horizontally)
	//near distance
	//far distance
	loadCameraData(); 
	initBitmaps();
}
Example #4
0
/// Read the index contained in the file f.  This function always reads all
/// bitvectors.
int ibis::skive::read(const char* f) {
    std::string fnm;
    indexFileName(fnm, f);

    int fdes = UnixOpen(fnm.c_str(), OPEN_READONLY);
    if (fdes < 0) {
	LOGGER(ibis::gVerbose > 0)
	    << "Warning -- skive[" << col->partition()->name() << '.'
	    << col->name() << "]::read failed to open " << fnm;
	return -1; // can not do anything else
    }

    char header[8];
    IBIS_BLOCK_GUARD(UnixClose, fdes);
#if defined(_WIN32) && defined(_MSC_VER)
    (void)_setmode(fdes, _O_BINARY);
#endif
    int ierr = UnixRead(fdes, static_cast<void*>(header), 8);
    if (ierr != 8) {
	LOGGER(ibis::gVerbose > 0)
	    << "Warning -- skive[" << col->partition()->name() << '.'
	    << col->name() << "]::read failed to read 8 bytes from "
	    << fnm;
	return -2;
    }
    if (!(header[0] == '#' && header[1] == 'I' &&
	  header[2] == 'B' && header[3] == 'I' &&
	  header[4] == 'S' &&
	  (header[5] == static_cast<char>(ibis::index::SKIVE) ||
	   header[5] == static_cast<char>(ibis::index::SLICE)) &&
	  (header[6] == 8 || header[6] == 4) &&
	  header[7] == static_cast<char>(0))) {
	if (ibis::gVerbose > 0) {
	    ibis::util::logger lg;
	    lg() << "Warning -- skive[" << col->partition()->name() << '.'
		 << col->name() << "]::read the header from " << fnm << " (";
	    printHeader(lg(), header);
	    lg() << ") does not contain the expected values";
	}
	return -3;
    }

    uint32_t dim[3]; // nrows, nobs, card
    size_t begin, end;
    clear(); // clear the current content

    ierr = UnixRead(fdes, static_cast<void*>(dim), 3*sizeof(uint32_t));
    nrows = dim[0];
    // read vals
    begin = 8*((3*sizeof(uint32_t) + 15) / 8);
    end = begin + dim[2] * sizeof(double);
    {
	array_t<double> dbl(fnm.c_str(), fdes, begin, end);
	vals.swap(dbl);
    }
    // read the offsets
    begin = end;
    end += header[6] * (dim[1] + 1);
    ierr = initOffsets(fdes, header[6], begin, dim[1]);
    if (ierr < 0)
	return ierr;

    // cnts
    begin = end;
    end += sizeof(uint32_t) * dim[2];
    {
	array_t<uint32_t> szt(fnm.c_str(), fdes, begin, end);
	cnts.swap(szt);
    }
    ibis::fileManager::instance().recordPages(0, end);

    initBitmaps(fdes);
    activate();
    return 0;
} // ibis::skive::read