Esempio n. 1
0
char HNumericBundle::save(const ABundleAttribute * d)
{
    if(!hasNamedAttr(".longname"))
		addStringAttr(".longname", d->longName().size());
	writeStringAttr(".longname", d->longName());
	
	int sz = d->size();
	if(!hasNamedAttr(".bundle_sz"))
		addIntAttr(".bundle_sz");
	writeIntAttr(".bundle_sz", &sz);
	
	int nt = d->numericType();
	if(!hasNamedAttr(".bundle_num_typ"))
		addIntAttr(".bundle_num_typ");

	writeIntAttr(".bundle_num_typ", &nt);
	
	int l = d->dataLength();
	if(!hasNamedData(".raw"))
	    addCharData(".raw", l);
		
	writeCharData(".raw", l, (char *)d->value());

    return 1;
}
Esempio n. 2
0
char HMesh::saveFaceTag(BaseMesh * mesh, const std::string & tagName, const std::string & dataName)
{
	if(!hasNamedData(dataName.c_str()))
		addCharData(dataName.c_str(), mesh->getNumFaces());
	
	std::cout<<"write face tag"<<tagName;
	writeCharData(dataName.c_str(),  mesh->getNumFaces(), mesh->perFaceTag(tagName));
	return 1;
}
Esempio n. 3
0
void HAnimationCurve::saveKeys(AAnimationCurve * curve, int n)
{
	if(n<1) return;
	AAnimationKey * data = new AAnimationKey[n];
	int i = 0;
	for(;i<n;i++)
		data[i] = curve->key(i);
	
	if(!hasNamedData(".key_data"))
		addCharData(".key_data", n * sizeof(AAnimationKey));
		
	writeCharData(".key_data", n * sizeof(AAnimationKey), (char *)data);
	delete[] data;
}
Esempio n. 4
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);
}