diff --git a/Source/smokeview/IOboundary.c b/Source/smokeview/IOboundary.c index a2763ffec0..164687105d 100644 --- a/Source/smokeview/IOboundary.c +++ b/Source/smokeview/IOboundary.c @@ -1518,8 +1518,8 @@ float UpdateBoundaryHist(patchdata *patchj){ else{ int error_code; - ReadGeomData(patchi, NULL, UPDATE_HIST, ALL_FRAMES, NULL, &error_code); - ReadGeomData(patchi, NULL, UNLOAD, ALL_FRAMES, NULL, &error_code); + ReadGeomData(patchi, NULL, UPDATE_HIST, ALL_FRAMES, NULL, 0, &error_code); + ReadGeomData(patchi, NULL, UNLOAD, ALL_FRAMES, NULL, 0, &error_code); } } if(hist_updated == 1){ @@ -2646,7 +2646,7 @@ FILE_SIZE ReadBoundary(int ifile, int load_flag, int *errorcode){ UpdateBoundaryHist(patchi); #endif } - return_filesize=ReadGeomData(patchi,NULL, load_flag,ALL_FRAMES, NULL, errorcode); + return_filesize=ReadGeomData(patchi,NULL, load_flag,ALL_FRAMES, NULL, 1, errorcode); } else{ ASSERT(ifile>=0&&ifilefile); + if(file_size == 0)return 0; + + header_size = 2*(4 + 4 + 4); + frame_size = 12; // time + frame_size += 24; // nval1, nval2, nval3, nval4 + nvars_per_frame = patchi->geominfo->geomlistinfo_0->ntriangles; + frame_size += 8 + nvars_per_frame * sizeof(float); // data + if(frame_size > 0){ + ntimes_local = (file_size - header_size) / frame_size; + } + if(geom_offset_flag != NULL && *geom_offset_flag == GET_GEOM_OFFSETS){ + *nvars = ntimes_local * nvars_per_frame; + } + else{ + *nvars = nvars_per_frame; + ntimes_local = 1; + if(geom_offsets != NULL)geom_offsets[0] = header_size; + } + if(geom_offsets!=NULL&&geom_offset_flag != NULL && *geom_offset_flag == BUILD_GEOM_OFFSETS){ + for(i = 0;i < ntimes_local;i++){ + geom_offsets[i] = header_size + i * frame_size; + } + } + return ntimes_local; +} -int GetGeomDataSize(char *filename, int *nvars, float *tmin, float *tmax, int time_frame, - int *geom_offsets, int *geom_offset_flag, int *error){ +/* ------------------ GetGeomDataSize ------------------------ */ +int GetGeomDataSize(char *filename, int *nvars, int time_frame, int *geom_offsets, int *geom_offset_flag, int *error){ float time; int one, version; int nvert_s, nvert_d, nface_s, nface_d; FILE *stream=NULL; int returncode=0; int nvars_local, ntimes_local; - int first = 1; int iframe; int geom_offset_index=0, geom_offset = 0, frame_start; *error=1; - *tmin = 0.0; - *tmax = 1.0; *nvars = 0; if(filename==NULL)return 0; stream = fopen(filename,"rb"); @@ -2429,13 +2460,6 @@ int GetGeomDataSize(char *filename, int *nvars, float *tmin, float *tmax, int ti if(geom_offset_flag!=NULL&&*geom_offset_flag==BUILD_GEOM_OFFSETS)geom_offsets[geom_offset_index] = geom_offset; FORTREAD(&time, 4, 1, stream); geom_offset += (4+4+4); - if(time_frame==ALL_FRAMES||time_frame==iframe){ - if(first==1){ - first = 0; - *tmin = time; - } - *tmax = time; - } if(returncode==0)break; FORTREAD(nvals, 4, 4, stream); geom_offset += (4+4*4+4); @@ -2590,7 +2614,7 @@ FILE_SIZE GetGeomData(char *filename, int ntimes, int nvals, float *times, int * /* ------------------ ReadGeomData ------------------------ */ -FILE_SIZE ReadGeomData(patchdata *patchi, slicedata *slicei, int load_flag, int time_frame, float *time_value, int *errorcode){ +FILE_SIZE ReadGeomData(patchdata *patchi, slicedata *slicei, int load_flag, int time_frame, float *time_value, int flag, int *errorcode){ char *file; int ntimes_local; int i; @@ -2599,7 +2623,6 @@ FILE_SIZE ReadGeomData(patchdata *patchi, slicedata *slicei, int load_flag, int int error; FILE_SIZE return_filesize = 0; float total_time; - float tmin_local, tmax_local; int *geom_offsets=NULL, geom_offset_flag; if(patchi->structured == YES)return 0; @@ -2646,7 +2669,12 @@ FILE_SIZE ReadGeomData(patchdata *patchi, slicedata *slicei, int load_flag, int geom_offset_flag = GET_GEOM_OFFSETS; } - ntimes_local = GetGeomDataSize(file, &nvals, &tmin_local, &tmax_local, time_frame, geom_offsets, &geom_offset_flag, &error); + if(flag==1){ + ntimes_local = GetGeomDataSizeFixed(patchi, &nvals, time_frame, geom_offsets, &geom_offset_flag, &error); + } + else{ + ntimes_local = GetGeomDataSize(file, &nvals, time_frame, geom_offsets, &geom_offset_flag, &error); + } if(time_value!=NULL){ if(geom_offset_flag>0){ @@ -2724,7 +2752,7 @@ FILE_SIZE ReadGeomData(patchdata *patchi, slicedata *slicei, int load_flag, int FREEMEMORY(colorlabelpatch); } if(NewMemory((void **)&colorlabelpatch, MAXRGB * sizeof(char *)) == 0){ - ReadGeomData(patchi, NULL, UNLOAD, time_frame, time_value, &error); + ReadGeomData(patchi, NULL, UNLOAD, time_frame, time_value, 0, &error); return 0; } for (n = 0; n < MAXRGB; n++){ @@ -2732,7 +2760,7 @@ FILE_SIZE ReadGeomData(patchdata *patchi, slicedata *slicei, int load_flag, int } for (n = 0; n < nrgb; n++){ if(NewMemory((void **)&colorlabelpatch[n], 11) == 0){ - ReadGeomData(patchi, NULL, UNLOAD, time_frame, time_value, &error); + ReadGeomData(patchi, NULL, UNLOAD, time_frame, time_value, 0, &error); return 0; } } @@ -2743,10 +2771,12 @@ FILE_SIZE ReadGeomData(patchdata *patchi, slicedata *slicei, int load_flag, int label = patchi->label.shortlabel; GetMinMax(BOUND_PATCH, label, &set_valmin, &valmin, &set_valmax, &valmax); + int convert = 0; + if(patchi->patch_filetype != PATCH_GEOMETRY_BOUNDARY && patchi->patch_filetype != PATCH_GEOMETRY_SLICE)convert = 0; GetBoundaryColors3(patchi, patchi->geom_vals, 0, patchi->geom_nvals, patchi->geom_ivals, &valmin, &valmax, nrgb, colorlabelpatch, colorvaluespatch, boundarylevels256, - &patchi->extreme_min, &patchi->extreme_max, 1); + &patchi->extreme_min, &patchi->extreme_max, convert); if(cache_boundary_data==0){ FREEMEMORY(patchi->geom_vals); } diff --git a/Source/smokeview/IOiso.c b/Source/smokeview/IOiso.c index 1236235474..3a3839c46a 100644 --- a/Source/smokeview/IOiso.c +++ b/Source/smokeview/IOiso.c @@ -347,10 +347,8 @@ FILE_SIZE ReadIsoGeom(int ifile, int load_flag, int *geom_frame_index, int *erro int filesize; int ntimes_local; float *valptr; - float tmin_local, tmax_local; - - ntimes_local = GetGeomDataSize(isoi->tfile, &isoi->geom_nvals, &tmin_local, &tmax_local, ALL_FRAMES, NULL, NULL, &error); + ntimes_local = GetGeomDataSize(isoi->tfile, &isoi->geom_nvals, ALL_FRAMES, NULL, NULL, &error); if(isoi->geom_nvals>0&&ntimes_local>0){ NewMemoryMemID((void **)&isoi->geom_nstatics, ntimes_local*sizeof(int), isoi->memory_id); diff --git a/Source/smokeview/IOscript.c b/Source/smokeview/IOscript.c index 17096cc04e..d5575ff767 100644 --- a/Source/smokeview/IOscript.c +++ b/Source/smokeview/IOscript.c @@ -2176,7 +2176,7 @@ int GetNSliceGeomFrames(scriptdata *scripti){ if(slicei->slice_filetype==SLICE_GEOM){ int nvals, error; - slicei->nframes = GetGeomDataSize(slicei->file, &nvals, &scripti->fval2, &scripti->fval3, ALL_FRAMES, NULL, NULL, &error); + slicei->nframes = GetGeomDataSize(slicei->file, &nvals, ALL_FRAMES, NULL, NULL, &error); } else{ slicei->nframes = GetNSliceFrames(slicei->file, &scripti->fval2, &scripti->fval3); diff --git a/Source/smokeview/IOslice.c b/Source/smokeview/IOslice.c index 70d6660fc0..ef5bd88957 100644 --- a/Source/smokeview/IOslice.c +++ b/Source/smokeview/IOslice.c @@ -1296,7 +1296,7 @@ FILE_SIZE ReadVSlice(int ivslice, int time_frame, float *time_value, int flag, i display=u->display; if(u->loaded==1){ if(u->slice_filetype == SLICE_GEOM){ - return_filesize = ReadGeomData(u->patchgeom, u, UNLOAD, time_frame, time_value, errorcode); + return_filesize = ReadGeomData(u->patchgeom, u, UNLOAD, time_frame, time_value, 0, errorcode); } else{ return_filesize+=ReadSlice(u->file, vd->iu, time_frame,NULL,UNLOAD, DEFER_SLICECOLOR, errorcode); @@ -1312,7 +1312,7 @@ FILE_SIZE ReadVSlice(int ivslice, int time_frame, float *time_value, int flag, i display=v->display; if(v->loaded==1){ if(v->slice_filetype == SLICE_GEOM){ - return_filesize = ReadGeomData(v->patchgeom, v, UNLOAD, time_frame, time_value, errorcode); + return_filesize = ReadGeomData(v->patchgeom, v, UNLOAD, time_frame, time_value, 0, errorcode); } else{ return_filesize+=ReadSlice(v->file, vd->iv, time_frame,NULL,UNLOAD, DEFER_SLICECOLOR, errorcode); @@ -1328,7 +1328,7 @@ FILE_SIZE ReadVSlice(int ivslice, int time_frame, float *time_value, int flag, i display=w->display; if(w->loaded==1){ if(w->slice_filetype == SLICE_GEOM){ - return_filesize = ReadGeomData(w->patchgeom, w, UNLOAD, time_frame, time_value, errorcode); + return_filesize = ReadGeomData(w->patchgeom, w, UNLOAD, time_frame, time_value, 0, errorcode); } else{ return_filesize+=ReadSlice(w->file, vd->iw, time_frame,NULL,UNLOAD, DEFER_SLICECOLOR, errorcode); @@ -1344,7 +1344,7 @@ FILE_SIZE ReadVSlice(int ivslice, int time_frame, float *time_value, int flag, i display=val->display; if(val->loaded==1){ if(val->slice_filetype == SLICE_GEOM){ - return_filesize = ReadGeomData(val->patchgeom, val, UNLOAD, time_frame, time_value, errorcode); + return_filesize = ReadGeomData(val->patchgeom, val, UNLOAD, time_frame, time_value, 0, errorcode); } else{ return_filesize+=ReadSlice(val->file, vd->ival, time_frame,NULL,UNLOAD, set_slicecolor, errorcode); @@ -1373,7 +1373,7 @@ FILE_SIZE ReadVSlice(int ivslice, int time_frame, float *time_value, int flag, i vd->u=u; if(scriptoutstream==NULL||script_defer_loading==0){ if(u->slice_filetype == SLICE_GEOM){ - return_filesize += ReadGeomData(u->patchgeom, u, LOAD, time_frame, time_value, errorcode); + return_filesize += ReadGeomData(u->patchgeom, u, LOAD, time_frame, time_value, 0, errorcode); } else{ return_filesize += ReadSlice(u->file, vd->iu, time_frame,time_value, flag, set_slicecolor, errorcode); @@ -1400,7 +1400,7 @@ FILE_SIZE ReadVSlice(int ivslice, int time_frame, float *time_value, int flag, i vd->v=v; if(scriptoutstream==NULL||script_defer_loading==0){ if(v->slice_filetype == SLICE_GEOM){ - return_filesize += ReadGeomData(v->patchgeom, v, LOAD, time_frame, time_value, errorcode); + return_filesize += ReadGeomData(v->patchgeom, v, LOAD, time_frame, time_value, 0, errorcode); } else{ return_filesize += ReadSlice(v->file, vd->iv, time_frame,time_value,flag, set_slicecolor, errorcode); @@ -1428,7 +1428,7 @@ FILE_SIZE ReadVSlice(int ivslice, int time_frame, float *time_value, int flag, i vd->w=w; if(scriptoutstream==NULL||script_defer_loading==0){ if(w->slice_filetype == SLICE_GEOM){ - return_filesize += ReadGeomData(w->patchgeom, w, LOAD, time_frame, time_value, errorcode); + return_filesize += ReadGeomData(w->patchgeom, w, LOAD, time_frame, time_value, 0, errorcode); } else{ return_filesize += ReadSlice(w->file, vd->iw, time_frame,time_value,flag, set_slicecolor, errorcode); @@ -1457,7 +1457,7 @@ FILE_SIZE ReadVSlice(int ivslice, int time_frame, float *time_value, int flag, i vd->val=val; if(scriptoutstream==NULL||script_defer_loading==0){ if(val->slice_filetype == SLICE_GEOM){ - return_filesize += ReadGeomData(val->patchgeom, val, LOAD, time_frame, time_value, errorcode); + return_filesize += ReadGeomData(val->patchgeom, val, LOAD, time_frame, time_value, 0, errorcode); } else{ return_filesize += ReadSlice(val->file, vd->ival, time_frame,time_value,flag, set_slicecolor, errorcode); diff --git a/Source/smokeview/c_api.c b/Source/smokeview/c_api.c index 7a695d33f6..a9aa1f7e97 100644 --- a/Source/smokeview/c_api.c +++ b/Source/smokeview/c_api.c @@ -1714,7 +1714,7 @@ void unloadslice(int value) { if (slicei->slice_filetype == SLICE_GEOM) { ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, - &errorcode); + 0, &errorcode); } else { ReadSlice("", value, ALL_FRAMES, NULL, UNLOAD, SET_SLICECOLOR, &errorcode); @@ -1730,7 +1730,7 @@ void unloadslice(int value) { slicei = sliceinfo + i; if (slicei->slice_filetype == SLICE_GEOM) { ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, - &errorcode); + 0, &errorcode); } else { ReadSlice("", i, ALL_FRAMES, NULL, UNLOAD, DEFER_SLICECOLOR, &errorcode); @@ -1755,7 +1755,7 @@ void unloadslice(int value) { slicei = sliceinfo + unload_index; if (slicei->slice_filetype == SLICE_GEOM) { ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, - &errorcode); + 0, &errorcode); } else { ReadSlice("", unload_index, ALL_FRAMES, NULL, UNLOAD, SET_SLICECOLOR, &errorcode); @@ -1785,7 +1785,7 @@ int unloadall() { if (slicei->loaded == 1) { if (slicei->slice_filetype == SLICE_GEOM) { ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, - &errorcode); + 0, &errorcode); } else { ReadSlice(slicei->file, i, ALL_FRAMES, NULL, UNLOAD, DEFER_SLICECOLOR, &errorcode); diff --git a/Source/smokeview/menus.c b/Source/smokeview/menus.c index 25bd47a6b6..3c92fcef1d 100644 --- a/Source/smokeview/menus.c +++ b/Source/smokeview/menus.c @@ -3289,7 +3289,7 @@ void ReloadAllSliceFiles(void){ i = slicei-sliceinfo; if(slicei->slice_filetype == SLICE_GEOM){ - load_size+=ReadGeomData(slicei->patchgeom, slicei, LOAD, ALL_FRAMES, NULL, &errorcode); + load_size+=ReadGeomData(slicei->patchgeom, slicei, LOAD, ALL_FRAMES, NULL, 0, &errorcode); } else{ load_size+=ReadSlice(slicei->file, i, ALL_FRAMES, NULL, LOAD, DEFER_SLICECOLOR, &errorcode); @@ -3334,7 +3334,7 @@ void LoadUnloadMenu(int value){ slicei = sliceinfo + i; if(slicei->loaded == 1){ if(slicei->slice_filetype == SLICE_GEOM){ - ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, &errorcode); + ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, 0, &errorcode); } else{ ReadSlice(slicei->file, i, ALL_FRAMES, NULL, UNLOAD, DEFER_SLICECOLOR, &errorcode); @@ -4385,7 +4385,7 @@ void UnloadSliceMenu(int value){ slicei = sliceinfo+value; if(slicei->slice_filetype==SLICE_GEOM){ - ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, &errorcode); + ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, 0, &errorcode); } else{ ReadSlice("", value, ALL_FRAMES, NULL, UNLOAD, SET_SLICECOLOR, &errorcode); @@ -4401,7 +4401,7 @@ void UnloadSliceMenu(int value){ slicei = sliceinfo+i; if(slicei->slice_filetype == SLICE_GEOM){ - ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, &errorcode); + ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, 0, &errorcode); } else{ ReadSlice("",i, ALL_FRAMES, NULL, UNLOAD,DEFER_SLICECOLOR,&errorcode); @@ -4425,7 +4425,7 @@ void UnloadSliceMenu(int value){ slicei = sliceinfo+unload_index; if(slicei->slice_filetype==SLICE_GEOM){ - ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, &errorcode); + ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, 0, &errorcode); } else{ ReadSlice("", unload_index, ALL_FRAMES, NULL, UNLOAD, SET_SLICECOLOR, &errorcode); @@ -4797,7 +4797,7 @@ FILE_SIZE LoadSlicei(int set_slicecolor, int value, int time_frame, float *time_ if(fed_colorbar != NULL&&fed_colorbar - colorbarinfo == colorbartype)reset_colorbar = 1; if(slicei->slice_filetype == SLICE_GEOM){ - return_filesize = ReadGeomData(slicei->patchgeom, slicei, LOAD, time_frame, time_value, &errorcode); + return_filesize = ReadGeomData(slicei->patchgeom, slicei, LOAD, time_frame, time_value, 0, &errorcode); } else{ return_filesize = ReadSlice(slicei->file, value, time_frame, time_value, LOAD, set_slicecolor, &errorcode); @@ -4837,7 +4837,7 @@ FILE_SIZE LoadAllSliceFiles(int last_slice, char *submenulabel, int dir, int *fc set_slicecolor = DEFER_SLICECOLOR; if(i==last_slice)set_slicecolor = SET_SLICECOLOR; if(slicei->slice_filetype==SLICE_GEOM){ - load_size += ReadGeomData(slicei->patchgeom, slicei, LOAD, ALL_FRAMES, NULL, &errorcode); + load_size += ReadGeomData(slicei->patchgeom, slicei, LOAD, ALL_FRAMES, NULL, 0, &errorcode); } else{ load_size += ReadSlice(slicei->file, i, ALL_FRAMES, NULL, LOAD, set_slicecolor, &errorcode); @@ -4875,7 +4875,7 @@ void LoadSliceMenu(int value){ slicei = sliceinfo + i; if(slicei->loaded == 1){ if(slicei->slice_filetype == SLICE_GEOM){ - ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, &errorcode); + ReadGeomData(slicei->patchgeom, slicei, UNLOAD, ALL_FRAMES, NULL, 0, &errorcode); } else{ ReadSlice("",i, ALL_FRAMES, NULL, UNLOAD, DEFER_SLICECOLOR, &errorcode); @@ -5168,7 +5168,7 @@ void LoadMultiSliceMenu(int value){ if(dir!=0&&dir!=slicei->idir)continue; if(dir!=0&&slicei->volslice==1)continue; if(slicei->slice_filetype == SLICE_GEOM){ - load_size += ReadGeomData(slicei->patchgeom, slicei, LOAD, ALL_FRAMES, NULL, &errorcode); + load_size += ReadGeomData(slicei->patchgeom, slicei, LOAD, ALL_FRAMES, NULL, 0, &errorcode); } else{ load_size += ReadSlice(slicei->file,i, ALL_FRAMES, NULL, LOAD,SET_SLICECOLOR,&errorcode); diff --git a/Source/smokeview/smokeheaders.h b/Source/smokeview/smokeheaders.h index c79d90cde7..f5f50d9a96 100644 --- a/Source/smokeview/smokeheaders.h +++ b/Source/smokeview/smokeheaders.h @@ -75,7 +75,7 @@ EXTERNCPP void SetTimeState(void); EXTERNCPP void SetCurrentViewPoint(char *viewpoint_label); -EXTERNCPP int GetGeomDataSize(char *file, int *nvals, float *tmin, float *tmax, int time_frame, +EXTERNCPP int GetGeomDataSize(char *file, int *nvals, int time_frame, int *geom_offsets, int *geom_offset_flag, int *error); EXTERNCPP FILE_SIZE GetGeomData(char *filename, int ntimes, int nvals, float *times, int *nstatics, int *ndynamics, float *vals, int time_frame, float *time_value, int *geom_offsets, int *error); @@ -320,7 +320,7 @@ EXTERNCPP int IsSmokeComponentPresent(smoke3ddata *smoke3di); EXTERNCPP void GetSliceDataBounds(slicedata *sd, float *pmin, float *pmax); EXTERNCPP void UpdateAllSliceColors(int slicetype, int *errorcode); EXTERNCPP void UpdateSliceBounds(void); -EXTERNCPP FILE_SIZE ReadGeomData(patchdata *patchi, slicedata *slicei, int load_flag, int time_frame, float *time_value, int *errorcode); +EXTERNCPP FILE_SIZE ReadGeomData(patchdata *patchi, slicedata *slicei, int load_flag, int time_frame, float *time_value, int flag, int *errorcode); EXTERNCPP void UpdateWhereFaceVolumes(void); EXTERNCPP void UpdateTimebarOverlap(void); EXTERNCPP void UpdateRenderRadioButtons(int width_low, int height_low, int width_high, int height_high);