Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

split smoke reading functions into shared #2027

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Build/smokeview/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bin = .

csrc = callbacks.c camera.c color2rgb.c readimage.c readgeom.c readobject.c readcad.c colortimebar.c compress.c csphere.c dmalloc.c \
drawGeometry.c file_util.c getdata.c getdatabounds.c getdatacolors.c glew.c \
histogram.c infoheader.c readlabel.c readtour.c readhvac.c \
histogram.c infoheader.c readlabel.c readtour.c readhvac.c readsmoke.c \
IOboundary.c IOgeometry.c IOhvac.c IOiso.c IOobjects.c IOpart.c IOplot2d.c IOplot3d.c \
IOscript.c IOshooter.c IOslice.c IOsmoke.c IOtour.c IOvolsmoke.c IOwui.c IOzone.c IOframe.o isobox.c \
main.c md5.c menus.c output.c readsmv.c renderhtml.c renderimage.c scontour2d.c sha1.c \
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ add_executable(smokeview
Source/shared/readcad.c
Source/shared/readhvac.c
Source/shared/readgeom.c
Source/shared/readsmoke.c
Source/shared/readobject.c
Source/shared/readtour.c
Source/shared/readlabel.c
Expand Down
42 changes: 42 additions & 0 deletions Source/shared/readsmoke.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "options.h"
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "MALLOCC.h"
#include "contourdefs.h"
#include "histogram.h"
#include "isodefs.h"
#include "readsmoke.h"
#include "smokeviewdefs.h"
#include "string_util.h"
#include "structures.h"

/* ------------------ FreeSmoke3d ------------------------ */

void FreeSmoke3D(smoke3ddata *smoke3di) {
smoke3di->lastiframe = -999;
#ifdef pp_SMOKEFRAME
FRAMEFree(smoke3di->frameinfo);
smoke3di->frameinfo = NULL;
#endif
FREEMEMORY(smoke3di->smokeframe_in);
FREEMEMORY(smoke3di->smokeframe_out);
FREEMEMORY(smoke3di->timeslist);
FREEMEMORY(smoke3di->times);
FREEMEMORY(smoke3di->times_map);
FREEMEMORY(smoke3di->use_smokeframe);
FREEMEMORY(smoke3di->nchars_compressed_smoke_full);
FREEMEMORY(smoke3di->nchars_compressed_smoke);
FREEMEMORY(smoke3di->frame_all_zeros);
FREEMEMORY(smoke3di->smoke_boxmin);
FREEMEMORY(smoke3di->smoke_boxmax);
#ifndef pp_SMOKEFRAME
FREEMEMORY(smoke3di->smoke_comp_all);
#endif
FREEMEMORY(smoke3di->smokeframe_comp_list);
FREEMEMORY(smoke3di->smokeview_tmp);
FREEMEMORY(smoke3di->smokeframe_loaded);
}
21 changes: 21 additions & 0 deletions Source/shared/readsmoke.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef READSMOKE_H_DEFINED
#define READSMOKE_H_DEFINED
#include "options.h"
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "MALLOCC.h"
#include "contourdefs.h"
#include "histogram.h"
#include "isodefs.h"
#include "shared_structures.h"
#include "smokeviewdefs.h"
#include "string_util.h"

#include "readobject.h"

void FreeSmoke3D(smoke3ddata *smoke3di);
#endif
96 changes: 96 additions & 0 deletions Source/shared/shared_structures.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,4 +424,100 @@ typedef struct {
labeldata *label_last_ptr;
} labels_collection;

/* -------------------------- smokedata ------------------------------------ */

typedef struct _smokedata {
int ncomp_total;
int *nchars_compressed, *nchars_compressed_full;
unsigned char *frame_in, *frame_out, *view_tmp, *comp_all, **frame_comp_list;
} smokedata;

/* -------------------------- smokestatedata ------------------------------- */

typedef struct {
int loaded, index;
unsigned char *color;
} smokestatedata;

/* -------------------------- smoke3ddata ---------------------------------- */

typedef struct _smoke3ddata {
int seq_id, autoload;
char *file;
char *comp_file, *reg_file;
#ifdef pp_SMOKE16
char *s16_file;
#endif
int filetype;
int skip_smoke, skip_fire;
int is_smoke, is_fire;
int loaded, request_load, finalize, display, primary_file;
int is_zlib;
#ifdef pp_SMOKE16
int is_s16;
#endif
smokestatedata *smokestate;
int blocknumber;
int type;
int is1, is2, js1, js2, ks1, ks2;
int compression_type, compression_type_temp;
flowlabels label;
char menulabel[128];
float *times;
unsigned char *times_map;
int *use_smokeframe;
int *smokeframe_loaded;
float extinct, valmin, valmax;
char cextinct[32];
#define ALPHA_X 0
#define ALPHA_Y 1
#define ALPHA_Z 2
#define ALPHA_XY 3
#define ALPHA_YZ 4
#define ALPHA_XZ 5
unsigned char *alphas_dir[6];
int fire_alpha, co2_alpha;
float fire_alphas[256], co2_alphas[256];
int *timeslist;
int ntimes, ntimes_old, ismoke3d_time, lastiframe, ntimes_full;
int nchars_uncompressed;

int ncomp_smoke_total;
int *nchars_compressed_smoke, *nchars_compressed_smoke_full;
#ifdef pp_SMOKE16
unsigned short *val16s;
float *val16_mins, *val16_maxs, *times16;
#endif
float maxval;
unsigned char *smokeframe_in, *smokeframe_out, **smokeframe_comp_list;
unsigned char *smokeview_tmp;
#ifndef pp_SMOKEFRAME
unsigned char *smoke_comp_all;
#endif
unsigned char *frame_all_zeros;
FILE_SIZE file_size;
float *smoke_boxmin, *smoke_boxmax;
smokedata smoke;
int dir;
#ifdef pp_SMOKEFRAME
framedata *frameinfo;
#endif
} smoke3ddata;

/* -------------------------- smoke3dtypedata ------------------------------ */

typedef struct _smoke3dtypedata {
char *shortlabel, *longlabel;
int type; // color based or opacity based
int menu_id;
smoke3ddata *smoke3d;
float extinction, valmin, valmax;
} smoke3dtypedata;

typedef struct {
int nsmoke3dinfo;
smoke3ddata *smoke3dinfo;
smoke3ddata **smoke3dinfo_sorted;
} smoke3d_collection;

#endif
16 changes: 8 additions & 8 deletions Source/smokeview/IOscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -2019,25 +2019,25 @@ void ScriptLoad3dSmoke(scriptdata *scripti){
int count=0;

PRINTF("script: loading smoke3d files of type: %s\n\n",scripti->cval);
for(i = 0; i < nsmoke3dinfo; i++){
for(i = 0; i < smoke3dcoll.nsmoke3dinfo; i++){
smoke3ddata *smoke3di;

smoke3di = smoke3dinfo + i;
smoke3di = smoke3dcoll.smoke3dinfo + i;
smoke3di->finalize = 0;
}
for(i = nsmoke3dinfo - 1; i >= 0; i--){
for(i = smoke3dcoll.nsmoke3dinfo - 1; i >= 0; i--){
smoke3ddata *smoke3di;

smoke3di = smoke3dinfo + i;
smoke3di = smoke3dcoll.smoke3dinfo + i;
if(MatchUpper(smoke3di->label.longlabel, scripti->cval) == MATCH){
smoke3di->finalize = 1;
break;
}
}
for(i=0;i<nsmoke3dinfo;i++){
for(i=0;i<smoke3dcoll.nsmoke3dinfo;i++){
smoke3ddata *smoke3di;

smoke3di = smoke3dinfo + i;
smoke3di = smoke3dcoll.smoke3dinfo + i;
if(MatchUpper(smoke3di->label.longlabel,scripti->cval) == MATCH){
ReadSmoke3D(ALL_SMOKE_FRAMES, i, LOAD, FIRST_TIME, &errorcode);
count++;
Expand Down Expand Up @@ -3229,10 +3229,10 @@ void ScriptLoadFile(scriptdata *scripti){
return;
}
}
for(i=0;i<nsmoke3dinfo;i++){
for(i=0;i<smoke3dcoll.nsmoke3dinfo;i++){
smoke3ddata *smoke3di;

smoke3di = smoke3dinfo + i;
smoke3di = smoke3dcoll.smoke3dinfo + i;
if(strcmp(smoke3di->file,scripti->cval)==0){
smoke3di->finalize = 1;
smoke3di->finalize = 1;
Expand Down
Loading
Loading