Ejemplo n.º 1
0
char HPolygonalUV::save(APolygonalUV * poly)
{
	int nuv = poly->numCoords();
	if(!hasNamedAttr(".nuv"))
		addIntAttr(".nuv");
	
	writeIntAttr(".nuv", &nuv);
	
	int nind = poly->numIndices();
	if(!hasNamedAttr(".nind"))
		addIntAttr(".nind");
	
	writeIntAttr(".nind", &nind);
	
	if(!hasNamedData(".ucoord"))
	    addFloatData(".ucoord", nuv);
	
	writeFloatData(".ucoord", nuv, (float *)poly->ucoord());
	
	if(!hasNamedData(".vcoord"))
	    addFloatData(".vcoord", nuv);
	
	writeFloatData(".vcoord", nuv, (float *)poly->vcoord());
		
	if(!hasNamedData(".uvid"))
	    addIntData(".uvid", nind);
	
	writeIntData(".uvid", nind, (int *)poly->indices());

	return 1;
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
	fitsfile* fptr;
	//char filename[] = "guppi_56590_B1133+16_0003_0001.fits";
	char filename[] = "~/pulsar_data/B0329.fits";
	int status = 0;
	float realDm = 26.8;
	double psrFreq = 1.399541539;
	int i,j; //for loop
	int sampNum;


	fits_open_file(&fptr,filename,READONLY,&status);
	
	//初始化fits文件信息
	struct Fitsinfo* fi = (struct Fitsinfo*)malloc(sizeof(struct Fitsinfo));
	initFitsInfo(fptr,fi,realDm,&status);
	sampNum = fi->nSBLK*fi->nROW;
	//初始化保存所有流量数据的二维数组
	/*
	unsigned char** ptr = (unsigned char**)malloc(fi->nROW*fi->nSBLK*sizeof(unsigned char*));
	for (i=0; i<fi->nROW*fi->nSBLK; i++) {
		ptr[i] = (unsigned char*)malloc(fi->nCHAN*sizeof(unsigned char));
	}
	initTotalData(fptr,fi,ptr,&status);
	*/

	//初始化合适的频道
	unsigned char** ptr = (unsigned char**)malloc(fi->nROW*fi->nSBLK*sizeof(unsigned char*));
	for (i=0; i<fi->nROW*fi->nSBLK; i++) {
		ptr[i] = (unsigned char*)malloc((fi->highF-fi->lowF+1)*sizeof(unsigned char));
	}
	initSuitData(fptr,fi,ptr,&status);
	//给需要处理的某两个通道分配空间	
    	struct FreqData* fdm = (struct FreqData*)malloc(sizeof(struct FreqData));
	fdm->data = (int*)malloc(sizeof(int)*fi->nSBLK*fi->nROW);
	struct FreqData** fd = (struct FreqData**)malloc(DMNUM*sizeof(struct FreqData*));	
	for (i=0; i<DMNUM; i++) {
		fd[i] = (struct FreqData*)malloc(sizeof(struct FreqData));
		fd[i]->data = (int*)malloc(sizeof(int)*fi->nSBLK*fi->nROW);
		//addSuitFreqData(fptr,fd[i],fdm,ptr,fi->dmArr[i],fi,&status);
		addSuitFreqDataWithZeroDm(fptr,fd[i],fdm,ptr,fi->dmArr[i],fi,&status);
	}
	for (i=0; i<fi->nROW*fi->nSBLK; i++) {
		free(ptr[i]);
	}
	free(ptr);

	/* draw fd[DMNUM/2]->data */
	/* draw fd[DMNUM/2]->data */
	if (cpgbeg(0, "/xs", 1, 1) != 1) {
		return EXIT_FAILURE;
	}
	float ns = fi->nROW * fi->nSBLK;
	float *x_coor, *data_adm;
	x_coor = (float *)malloc(sizeof(float) * fi->nROW * fi->nSBLK);
	data_adm = (float *)malloc(sizeof(float) * ns);
	for (i = 0; i < fi->nROW * fi->nSBLK; i++) {
		*(x_coor + i) = i;
		*(data_adm  + i) = (float)fd[DMNUM/2]->data[i];
	}
	
	cpgpage();
	cpgenv(0.0, fi->nROW * fi->nSBLK, -5000.0f, 5000.0f, 0, 1);
	
	cpgline(ns, x_coor, data_adm);
	cpgbbuf();
	cpgend();
	return EXIT_SUCCESS;
	
	float aveData[20000] = {0};
	writeIntData("26.8.dat",26.8,fd[DMNUM/2]->data,fi->nSBLK*fi->nROW);
	calcAveArr(aveData,fd[DMNUM/2]->data,2000000,100);
	writeFloatData("ave26.8.dat",26.8,aveData,20000);
	int foldData[20000] = {0};
	fold(foldData,fd[DMNUM/2]->data,fi->tBIN,psrFreq,fi->nSBLK*fi->nROW);

	writeHistogramData(fd,fi);
	
	

	fits_close_file(fptr,&status);

}
Ejemplo n.º 3
0
char HMesh::save(BaseMesh * mesh)
{
	mesh->verbose();
	
	int nv = mesh->getNumVertices();
	if(!hasNamedAttr(".nv"))
		addIntAttr(".nv");
	
	writeIntAttr(".nv", &nv);
	
	int nf = mesh->getNumPolygons();
	if(!hasNamedAttr(".nf"))
		addIntAttr(".nf");
	
	writeIntAttr(".nf", &nf);
		
	int nfv = mesh->getNumPolygonFaceVertices();
	if(!hasNamedAttr(".nfv"))
		addIntAttr(".nfv");
	
	writeIntAttr(".nfv", &nfv);
	
	int nuv = mesh->getNumUVs();
	if(!hasNamedAttr(".nuv"))
		addIntAttr(".nuv");
	
	writeIntAttr(".nuv", &nuv);
	
	int nuvid = mesh->getNumUVIds();
	if(!hasNamedAttr(".nuvid"))
		addIntAttr(".nuvid");
	
	writeIntAttr(".nuvid", &nuvid);
	
	if(!hasNamedData(".p"))
	    addVector3Data(".p", nv);
	
	writeVector3Data(".p", nv, mesh->getVertices());
		
	if(!hasNamedData(".polyc"))
	    addIntData(".polyc", nf);
	
	writeIntData(".polyc", nf, (int *)mesh->getPolygonCounts());
	
	if(!hasNamedData(".polyv"))
	    addIntData(".polyv", nfv);
	
	std::cout<<" polyv[0]"<<mesh->getPolygonIndices()[0]<<"\n";
	std::cout<<" polyv["<<nfv<<"-1]"<<mesh->getPolygonIndices()[nfv - 1]<<"\n";
	writeIntData(".polyv", nfv, (int *)mesh->getPolygonIndices());
	
	if(!hasNamedData(".us"))
		addFloatData(".us", nuv);
		
	writeFloatData(".us", nuv, mesh->getUs());
	
	if(!hasNamedData(".vs"))
		addFloatData(".vs", nuv);
		
	writeFloatData(".vs", nuv, mesh->getVs());
	
	if(!hasNamedData(".uvids"))
		addIntData(".uvids", nuvid);
		
	writeIntData(".uvids", nuvid, (int *)mesh->getUvIds());

	return 1;
}