Esempio n. 1
0
char HAdaptiveField::load(AdaptiveField * fld)
{
    int nc = 1;
    readIntAttr(".ncells", &nc);

    float originSpan[4];
    readFloatAttr(".origin_span", originSpan);

    int ml = 7;
    readIntAttr(".max_level", &ml);

    fld->setBounding(originSpan);
    fld->setMaxLevel(ml);

    BaseBuffer dhash;
    dhash.create(nc * 16);
    readCharData(".cellHash", nc*16, dhash.data());

    IOCellHash * src = (IOCellHash *)dhash.data();
    std::cout<<"\n hadaptive field add n cells "<<nc;
    unsigned i = 0;
    for(; i<nc; i++) {
        fld->addCell(src->code, src->level, src->visited, src->index);
        src++;
    }
    std::cout<<"\n hadaptive field done load";
    return HField::load(fld);
}
Esempio n. 2
0
char HAdaptiveField::save(AdaptiveField * fld)
{
    int nc = fld->numCells();
    std::cout<<"\n hadaptivefield save n cells "<<nc;

    if(!hasNamedAttr(".ncells"))
        addIntAttr(".ncells");

    writeIntAttr(".ncells", &nc);

    if(!hasNamedAttr(".origin_span"))
        addFloatAttr(".origin_span", 4);

    float originSpan[4];
    originSpan[0] = fld->origin().x;
    originSpan[1] = fld->origin().y;
    originSpan[2] = fld->origin().z;
    originSpan[3] = fld->span();
    writeFloatAttr(".origin_span", originSpan);

    if(!hasNamedAttr(".max_level"))
        addIntAttr(".max_level");

    int ml = fld->maxLevel();
    writeIntAttr(".max_level", &ml);

    BaseBuffer dhash;
    dhash.create(nc * 16);
    IOCellHash * dst = (IOCellHash *)dhash.data();

    sdb::CellHash * c = fld->cells();
    c->begin();
    while(!c->end()) {
        dst->code = c->key();
        dst->level = c->value()->level;
        dst->visited = c->value()->visited;
        dst->index = c->value()->index;
        dst++;
        c->next();
    }

    if(!hasNamedData(".cellHash"))
        addCharData(".cellHash", nc*16);

    writeCharData(".cellHash", nc*16, dhash.data());

    return HField::save(fld);
}
Esempio n. 3
0
bool BccInterface::separate(ATriangleMesh * mesh, std::vector<AOrientedBox> & patchBoxes)
{
	std::cout<<"\n mesh n tri "<<mesh->numTriangles();
	m_patchSeparator->separate(mesh);
	const unsigned n = m_patchSeparator->numPatches();
	if(n < 2) {
		std::cout<<"\n cannot separate one continuous mesh ";
		return false;
	}
	
	std::cout<<"\n separate to "<<n<<" patches ";
	
	PrincipalComponents pca;
	BaseBuffer pos;
	m_patchSeparator->patchBegin();
	while(!m_patchSeparator->patchEnd()) {
		const unsigned np = m_patchSeparator->getPatchCvs(&pos, mesh);
		m_patchSeparator->nextPatch();
		
		patchBoxes.push_back( pca.analyze((Vector3F *)pos.data(), np) );
	}
	
	return true;
}