- removed some unecessary files & code
- debug output now controlled globally by elbeem debug level (BLENDER_ELBEEMDEBUG environment var), also for fluidsimBake and read/writeBobj - debug output is written to file for WIN32 - added "for" and "vector" etc. defines for MSVC6 (I couldnt get hold of the compiler itself, so not tested yet)
This commit is contained in:
@@ -5,7 +5,7 @@ Import('user_options_dict');
|
||||
print "Including El'Beem Fluid Simulation..."
|
||||
elbeem_env = library_env.Copy();
|
||||
elbeem_env.Append(CPPDEFINES= 'NOGUI');
|
||||
elbeem_env.Append(CPPDEFINES= 'ELBEEM_BLENDER=1');
|
||||
elbeem_env.Append(CPPDEFINES= [('ELBEEM_BLENDER',1)] );
|
||||
|
||||
elbeem_env.Append (CPPPATH = user_options_dict['PNG_INCLUDE'])
|
||||
elbeem_env.Append (CPPPATH = user_options_dict['Z_INCLUDE'])
|
||||
@@ -26,11 +26,8 @@ Sources = [
|
||||
"intern/lbminterface.cpp",
|
||||
"intern/ntl_blenderdumper.cpp",
|
||||
"intern/ntl_bsptree.cpp",
|
||||
"intern/ntl_geometrybox.cpp",
|
||||
"intern/ntl_geometrymodel.cpp",
|
||||
"intern/ntl_geometryobject.cpp",
|
||||
"intern/ntl_geometrysphere.cpp",
|
||||
"intern/ntl_image.cpp",
|
||||
"intern/ntl_lightobject.cpp",
|
||||
"intern/ntl_ray.cpp",
|
||||
"intern/ntl_raytracer.cpp",
|
||||
|
7
intern/elbeem/extern/LBM_fluidsim.h
vendored
7
intern/elbeem/extern/LBM_fluidsim.h
vendored
@@ -63,6 +63,13 @@ struct DerivedMesh *getFluidsimDerivedMesh(struct Object *srcob, int useRenderPa
|
||||
// WARNING - implemented in intern/elbeem/blendercall.cpp
|
||||
int performElbeemSimulation(char *cfgfilename);
|
||||
|
||||
// implemented in intern/elbeem/utilities.cpp
|
||||
/* set elbeem debug output level (0=off to 10=full on) */
|
||||
void elbeemSetDebugLevel(int level);
|
||||
/* elbeem debug output function */
|
||||
void elbeemDebugOut(char *msg);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@@ -1,290 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
|
||||
* Copyright 2003,2004 Nils Thuerey
|
||||
*
|
||||
* Array class definitions
|
||||
*
|
||||
*****************************************************************************/
|
||||
#ifndef ARRAYS_H
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* array handling "cutting off" access along the border */
|
||||
template<class T>
|
||||
class ArrayCutoffBc {
|
||||
public:
|
||||
//! constructor
|
||||
ArrayCutoffBc() :
|
||||
mpVal( NULL ), mElemSize( sizeof(T) ),
|
||||
mAllocSize(0),
|
||||
mSizex(0), mSizey(0), mSizez(0)
|
||||
{ };
|
||||
//! destructor
|
||||
virtual ~ArrayCutoffBc() {
|
||||
if((mpVal)&&(mAllocSize>0)) delete[] mpVal;
|
||||
mpVal = NULL;
|
||||
}
|
||||
|
||||
//! init sizes
|
||||
void initializeArray(int setx, int sety, int setz) {
|
||||
mSizex = setx;
|
||||
mSizey = sety;
|
||||
mSizez = setz;
|
||||
}
|
||||
|
||||
//! allocate a new array
|
||||
inline void allocate() {
|
||||
int size = mSizex*mSizey*mSizez;
|
||||
if(size == mAllocSize) return; // dont reallocate
|
||||
T* newval = new T[size];
|
||||
for(int i=0;i<size;i++) newval[i] = (T)(0.0);
|
||||
mpVal = (unsigned char *)newval;
|
||||
mAllocSize = size;
|
||||
};
|
||||
|
||||
//! set the scalar field pointer
|
||||
inline void setValuePointer(T *pnt, int elem) { mpVal = (unsigned char *)pnt; mElemSize = elem; };
|
||||
|
||||
//! internal array index calculator
|
||||
inline int arrayIndex(int x, int y, int z) {
|
||||
if(x<0) x=0;
|
||||
if(y<0) y=0;
|
||||
if(z<0) z=0;
|
||||
if(x>mSizex-1) x=mSizex-1;
|
||||
if(y>mSizey-1) y=mSizey-1;
|
||||
if(z>mSizez-1) z=mSizez-1;
|
||||
return z*mSizex*mSizey + y*mSizex + x;
|
||||
}
|
||||
//! phi access function
|
||||
inline T& getValue(int x, int y, int z) {
|
||||
unsigned char *bpnt = &mpVal[ arrayIndex(x,y,z)*mElemSize ];
|
||||
return *((T*)bpnt);
|
||||
//return mpPhi[ z*mSizex*mSizey + y*mSizex + x];
|
||||
}
|
||||
//! return relative offset in direction dir (x=0,y=1,z=2)
|
||||
inline T& getOffset(T *base,int off, int dir) {
|
||||
unsigned char *basep = (unsigned char *)base;
|
||||
int multiplier = 1;
|
||||
if(dir==1) multiplier=mSizex;
|
||||
if(dir==2) multiplier=mSizex*mSizey;
|
||||
// check boundary
|
||||
unsigned char *bpnt = (basep+ ((off*multiplier)*mElemSize) );
|
||||
if(bpnt<mpVal) bpnt = basep;
|
||||
if(bpnt>= (unsigned char *)&getValue(mSizex-1,mSizey-1,mSizez-1) ) bpnt = basep;
|
||||
return *((T*)bpnt);
|
||||
}
|
||||
|
||||
//! perform trilinear interpolation of array values
|
||||
inline T interpolateValueAt(LbmFloat x, LbmFloat y, LbmFloat z) {
|
||||
const LbmFloat gsx=1.0, gsy=1.0, gsz=1.0;
|
||||
int i= (int)x;
|
||||
int j= (int)y;
|
||||
int k= (int)z;
|
||||
|
||||
int in = i+1;
|
||||
int jn = j+1;
|
||||
int kn = k+1;
|
||||
if(in>=mSizex) in = mSizex-1;
|
||||
if(jn>=mSizey) jn = mSizey-1;
|
||||
if(kn>=mSizez) kn = mSizez-1;
|
||||
|
||||
LbmVec mStart(0.0); // TODO remove?
|
||||
LbmFloat x1 = mStart[0]+ (LbmFloat)(i)*gsx;
|
||||
LbmFloat x2 = mStart[0]+ (LbmFloat)(in)*gsx;
|
||||
LbmFloat y1 = mStart[1]+ (LbmFloat)(j)*gsy;
|
||||
LbmFloat y2 = mStart[1]+ (LbmFloat)(jn)*gsy;
|
||||
LbmFloat z1 = mStart[2]+ (LbmFloat)(k)*gsz;
|
||||
LbmFloat z2 = mStart[2]+ (LbmFloat)(kn)*gsz;
|
||||
|
||||
if(mSizez==1) {
|
||||
z1=0.0; z2=1.0;
|
||||
k = kn = 0;
|
||||
}
|
||||
|
||||
T v1, v2, v3, v4, v5, v6, v7, v8;
|
||||
v1 = getValue(i ,j ,k );
|
||||
v2 = getValue(in ,j ,k );
|
||||
v3 = getValue(i ,jn ,k );
|
||||
v4 = getValue(in ,jn ,k );
|
||||
v5 = getValue(i ,j ,kn );
|
||||
v6 = getValue(in ,j ,kn );
|
||||
v7 = getValue(i ,jn ,kn );
|
||||
v8 = getValue(in ,jn ,kn );
|
||||
|
||||
T val =
|
||||
( v1 *(x2-x)* (y2-y)* (z2-z) +
|
||||
v2 *(x-x1)* (y2-y)* (z2-z) +
|
||||
v3 *(x2-x)* (y-y1)* (z2-z) +
|
||||
v4 *(x-x1)* (y-y1)* (z2-z) +
|
||||
v5 *(x2-x)* (y2-y)* (z-z1) +
|
||||
v6 *(x-x1)* (y2-y)* (z-z1) +
|
||||
v7 *(x2-x)* (y-y1)* (z-z1) +
|
||||
v8 *(x-x1)* (y-y1)* (z-z1)
|
||||
) * (1.0/(gsx*gsy*gsz)) ;
|
||||
return val;
|
||||
}
|
||||
|
||||
//! get size of an element
|
||||
inline int getElementSize(){ return mElemSize; }
|
||||
//! get array sizes
|
||||
inline int getSizeX(){ return mSizex; }
|
||||
inline int getSizeY(){ return mSizey; }
|
||||
inline int getSizeZ(){ return mSizez; }
|
||||
//! get array pointer
|
||||
inline T* getPointer(){ return (T*)mpVal; }
|
||||
|
||||
//! testing, gnuplot dump (XY plane for k=Z/2)
|
||||
void dumpToFile(std::string filebase, int id, int nr) {
|
||||
std::ostringstream filename;
|
||||
filename << filebase << "_"<< id <<"_"<< nr <<".dump";
|
||||
std::ofstream outfile( filename.str().c_str() );
|
||||
for(int k=mSizez/2; k<=mSizez/2; k++) {
|
||||
for(int j=0; j<mSizey; j++) {
|
||||
for(int i=0; i<mSizex; i++) {
|
||||
outfile <<i<<" "<<j<<" " << getValue(i,j,k)<<" " <<std::endl;
|
||||
}
|
||||
outfile << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
//! testing, grid text dump (XY plane for k=Z/2)
|
||||
void dumpToGridFile(std::string filebase, int id, int nr) {
|
||||
std::ostringstream filename;
|
||||
filename << filebase << "_"<< id <<"_"<< nr <<".dump";
|
||||
std::ofstream outfile( filename.str().c_str() );
|
||||
for(int k=mSizez/2; k<=mSizez/2; k++) {
|
||||
for(int j=0; j<mSizey; j++) {
|
||||
for(int i=0; i<mSizex; i++) {
|
||||
outfile <<getValue(i,j,k)<<"\t";
|
||||
}
|
||||
outfile << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
//! pointer for the value field (unsigned char for adding element size)
|
||||
unsigned char *mpVal;
|
||||
//! element offset in array
|
||||
int mElemSize;
|
||||
//! store allocated size
|
||||
int mAllocSize;
|
||||
|
||||
//! Sizes of the scal array in each dimension
|
||||
int mSizex,mSizey,mSizez;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
/* array handling "cutting off" access along the border */
|
||||
template<class T>
|
||||
class ArrayPlain {
|
||||
public:
|
||||
//! constructor
|
||||
ArrayPlain() :
|
||||
mpVal( NULL ), mElemSize( sizeof(T) ),
|
||||
mAllocSize(0),
|
||||
mSizex(0), mSizey(0), mSizez(0)
|
||||
{ };
|
||||
//! destructor
|
||||
virtual ~ArrayPlain() {
|
||||
if((mpVal)&&(mAllocSize>0)) delete[] mpVal;
|
||||
mpVal = NULL;
|
||||
}
|
||||
|
||||
//! init sizes
|
||||
void initializeArray(int setx, int sety, int setz) {
|
||||
mSizex = setx;
|
||||
mSizey = sety;
|
||||
mSizez = setz;
|
||||
}
|
||||
|
||||
//! allocate a new array
|
||||
inline void allocate() {
|
||||
int size = mSizex*mSizey*mSizez;
|
||||
if(size == mAllocSize) return; // dont reallocate
|
||||
T* newval = new T[size];
|
||||
for(int i=0;i<size;i++) newval[i] = (T)(0.0);
|
||||
mpVal = (unsigned char *)newval;
|
||||
mAllocSize = size;
|
||||
};
|
||||
|
||||
//! set the scalar field pointer
|
||||
inline void setValuePointer(T *pnt, int elem) { mpVal = (unsigned char *)pnt; mElemSize = elem; };
|
||||
|
||||
//! phi access function
|
||||
inline T& getValue(const int x, const int y, const int z) const {
|
||||
unsigned char *bpnt = &mpVal[ (z*mSizex*mSizey + y*mSizex + x)*mElemSize ];
|
||||
return *((T*)bpnt);
|
||||
}
|
||||
//! return relative offset in direction dir (x=0,y=1,z=2)
|
||||
inline T& getOffset(T *base,int off, int dir) {
|
||||
unsigned char *basep = (unsigned char *)base;
|
||||
int multiplier = 1;
|
||||
if(dir==1) multiplier=mSizex;
|
||||
if(dir==2) multiplier=mSizex*mSizey;
|
||||
// check boundary
|
||||
unsigned char *bpnt = (basep+ ((off*multiplier)*mElemSize) );
|
||||
if(bpnt<mpVal) bpnt = basep;
|
||||
if(bpnt>= (unsigned char *)&getValue(mSizex-1,mSizey-1,mSizez-1) ) bpnt = basep;
|
||||
return *((T*)bpnt);
|
||||
}
|
||||
|
||||
//! get size of an element
|
||||
inline int getElementSize(){ return mElemSize; }
|
||||
//! get array sizes
|
||||
inline int getSizeX(){ return mSizex; }
|
||||
inline int getSizeY(){ return mSizey; }
|
||||
inline int getSizeZ(){ return mSizez; }
|
||||
//! get array pointer
|
||||
inline T* getPointer(){ return (T*)mpVal; }
|
||||
|
||||
//! testing, gnuplot dump (XY plane for k=Z/2)
|
||||
void dumpToFile(std::string filebase, int id, int nr) {
|
||||
std::ostringstream filename;
|
||||
filename << filebase << "_"<< id <<"_"<< nr <<".dump";
|
||||
std::ofstream outfile( filename.str().c_str() );
|
||||
for(int k=mSizez/2; k<=mSizez/2; k++) {
|
||||
for(int j=0; j<mSizey; j++) {
|
||||
for(int i=0; i<mSizex; i++) {
|
||||
outfile <<i<<" "<<j<<" " << getValue(i,j,k)<<" " <<std::endl;
|
||||
}
|
||||
outfile << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
//! testing, grid text dump (XY plane for k=Z/2)
|
||||
void dumpToGridFile(std::string filebase, int id, int nr) {
|
||||
std::ostringstream filename;
|
||||
filename << filebase << "_"<< id <<"_"<< nr <<".dump";
|
||||
std::ofstream outfile( filename.str().c_str() );
|
||||
for(int k=mSizez/2; k<=mSizez/2; k++) {
|
||||
for(int j=0; j<mSizey; j++) {
|
||||
for(int i=0; i<mSizex; i++) {
|
||||
outfile <<getValue(i,j,k)<<"\t";
|
||||
}
|
||||
outfile << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
//! pointer for the value field (unsigned char for adding element size)
|
||||
unsigned char *mpVal;
|
||||
//! element offset in array
|
||||
int mElemSize;
|
||||
//! store allocated size
|
||||
int mAllocSize;
|
||||
|
||||
//! Sizes of the scal array in each dimension
|
||||
int mSizex,mSizey,mSizez;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define ARRAYS_H
|
||||
#endif
|
||||
|
@@ -23,9 +23,11 @@ int performElbeemSimulation(char *cfgfilename) {
|
||||
gDebugLevel = atoi(getenv(strEnvName));
|
||||
if(gDebugLevel< 0) gDebugLevel = 0;
|
||||
if(gDebugLevel>10) gDebugLevel = 0; // only use valid values
|
||||
if(gDebugLevel>0) fprintf(stderr, "Using envvar '%s'='%s', debugLevel set to: %d\n",strEnvName, getenv(strEnvName), gDebugLevel);
|
||||
if(gDebugLevel>0) debMsgStd("performElbeemSimulation",DM_NOTIFY,"Using envvar '"<<strEnvName<<"'='"<<getenv(strEnvName)<<"', debugLevel set to: "<<gDebugLevel<<"\n", 1);
|
||||
}
|
||||
if(gDebugLevel>0) fprintf(GEN_userstream, "Running El'Beem from Blender with file '%s', debugLevel:%d ...\n",cfgfilename,gDebugLevel);
|
||||
//if(gDebugLevel>0) {
|
||||
debMsgStd("performElbeemSimulation",DM_NOTIFY,"Running El'Beem from Blender with file '"<< cfgfilename <<"', debugLevel:"<<gDebugLevel<<" ...\n", 2);
|
||||
//}
|
||||
// load given file in command line mode
|
||||
ntlBlenderDumper elbeem(cfgfilename, true);
|
||||
if(SIMWORLD_OK()) {
|
||||
@@ -33,7 +35,7 @@ int performElbeemSimulation(char *cfgfilename) {
|
||||
myTime_t timestart = getTime();
|
||||
elbeem.renderAnimation();
|
||||
myTime_t timeend = getTime();
|
||||
if(gDebugLevel>0) fprintf(GEN_userstream, "El'Beem simulation done, time: %f seconds.\n", ((timeend-timestart)/(double)1000.0) );
|
||||
debMsgStd("performElbeemSimulation",DM_NOTIFY, "El'Beem simulation done, time: "<<((timeend-timestart)/(double)1000.0) <<" seconds.\n", 2 );
|
||||
} else {
|
||||
}
|
||||
return 1;
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
/* A Bison parser, made by GNU Bison 1.875d. */
|
||||
/* A Bison parser, made by GNU Bison 2.0. */
|
||||
|
||||
/* Skeleton parser for Yacc-like parsing with Bison,
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
@@ -38,99 +38,100 @@
|
||||
KW_COMPARELBM = 264,
|
||||
KW_ANIFRAMETIME = 265,
|
||||
KW_DEBUGMODE = 266,
|
||||
KW_P_RELAXTIME = 267,
|
||||
KW_P_REYNOLDS = 268,
|
||||
KW_P_VISCOSITY = 269,
|
||||
KW_P_SOUNDSPEED = 270,
|
||||
KW_P_DOMAINSIZE = 271,
|
||||
KW_P_FORCE = 272,
|
||||
KW_P_TIMELENGTH = 273,
|
||||
KW_P_STEPTIME = 274,
|
||||
KW_P_TIMEFACTOR = 275,
|
||||
KW_P_ANIFRAMETIME = 276,
|
||||
KW_P_ANISTART = 277,
|
||||
KW_P_SURFACETENSION = 278,
|
||||
KW_P_ACTIVATE = 279,
|
||||
KW_P_DEACTIVATE = 280,
|
||||
KW_P_DENSITY = 281,
|
||||
KW_P_CELLSIZE = 282,
|
||||
KW_P_GSTAR = 283,
|
||||
KW_PFSPATH = 284,
|
||||
KW_PARTLINELENGTH = 285,
|
||||
KW_PARTICLES = 286,
|
||||
KW_FRAMESPERSEC = 287,
|
||||
KW_RAYTRACING = 288,
|
||||
KW_PAROPEN = 289,
|
||||
KW_PARCLOSE = 290,
|
||||
KW_FILENAME = 291,
|
||||
KW_PMCAUSTICS = 292,
|
||||
KW_MAXRAYDEPTH = 293,
|
||||
KW_CAUSTICDIST = 294,
|
||||
KW_CAUSTICPHOT = 295,
|
||||
KW_SHADOWMAPBIAS = 296,
|
||||
KW_TREEMAXDEPTH = 297,
|
||||
KW_TREEMAXTRIANGLES = 298,
|
||||
KW_RESOLUTION = 299,
|
||||
KW_ANTIALIAS = 300,
|
||||
KW_EYEPOINT = 301,
|
||||
KW_ANISTART = 302,
|
||||
KW_ANIFRAMES = 303,
|
||||
KW_FRAMESKIP = 304,
|
||||
KW_LOOKAT = 305,
|
||||
KW_UPVEC = 306,
|
||||
KW_FOVY = 307,
|
||||
KW_ASPECT = 308,
|
||||
KW_AMBIENCE = 309,
|
||||
KW_BACKGROUND = 310,
|
||||
KW_DEBUGPIXEL = 311,
|
||||
KW_TESTMODE = 312,
|
||||
KW_OPENGLATTR = 313,
|
||||
KW_BLENDERATTR = 314,
|
||||
KW_ATTRIBUTE = 315,
|
||||
KW_OBJATTR = 316,
|
||||
KW_EQUALS = 317,
|
||||
KW_DEFINEATTR = 318,
|
||||
KW_ATTREND = 319,
|
||||
KW_GEOMETRY = 320,
|
||||
KW_TYPE = 321,
|
||||
KW_GEOTYPE_BOX = 322,
|
||||
KW_GEOTYPE_FLUID = 323,
|
||||
KW_GEOTYPE_OBJMODEL = 324,
|
||||
KW_GEOTYPE_SPHERE = 325,
|
||||
KW_CASTSHADOWS = 326,
|
||||
KW_RECEIVESHADOWS = 327,
|
||||
KW_VISIBLE = 328,
|
||||
KW_BOX_END = 329,
|
||||
KW_BOX_START = 330,
|
||||
KW_POLY = 331,
|
||||
KW_NUMVERTICES = 332,
|
||||
KW_VERTEX = 333,
|
||||
KW_NUMPOLYGONS = 334,
|
||||
KW_ISOSURF = 335,
|
||||
KW_FILEMODE = 336,
|
||||
KW_INVERT = 337,
|
||||
KW_MATERIAL = 338,
|
||||
KW_MATTYPE_PHONG = 339,
|
||||
KW_MATTYPE_BLINN = 340,
|
||||
KW_NAME = 341,
|
||||
KW_AMBIENT = 342,
|
||||
KW_DIFFUSE = 343,
|
||||
KW_SPECULAR = 344,
|
||||
KW_MIRROR = 345,
|
||||
KW_TRANSPARENCE = 346,
|
||||
KW_REFRACINDEX = 347,
|
||||
KW_TRANSADDITIVE = 348,
|
||||
KW_TRANSATTCOL = 349,
|
||||
KW_FRESNEL = 350,
|
||||
KW_LIGHT = 351,
|
||||
KW_ACTIVE = 352,
|
||||
KW_COLOUR = 353,
|
||||
KW_POSITION = 354,
|
||||
KW_LIGHT_OMNI = 355,
|
||||
KW_CAUSTICPHOTONS = 356,
|
||||
KW_CAUSTICSTRENGTH = 357,
|
||||
KW_SHADOWMAP = 358,
|
||||
KW_CAUSTICSMAP = 359
|
||||
KW_DEBUGLEVEL = 267,
|
||||
KW_P_RELAXTIME = 268,
|
||||
KW_P_REYNOLDS = 269,
|
||||
KW_P_VISCOSITY = 270,
|
||||
KW_P_SOUNDSPEED = 271,
|
||||
KW_P_DOMAINSIZE = 272,
|
||||
KW_P_FORCE = 273,
|
||||
KW_P_TIMELENGTH = 274,
|
||||
KW_P_STEPTIME = 275,
|
||||
KW_P_TIMEFACTOR = 276,
|
||||
KW_P_ANIFRAMETIME = 277,
|
||||
KW_P_ANISTART = 278,
|
||||
KW_P_SURFACETENSION = 279,
|
||||
KW_P_ACTIVATE = 280,
|
||||
KW_P_DEACTIVATE = 281,
|
||||
KW_P_DENSITY = 282,
|
||||
KW_P_CELLSIZE = 283,
|
||||
KW_P_GSTAR = 284,
|
||||
KW_PFSPATH = 285,
|
||||
KW_PARTLINELENGTH = 286,
|
||||
KW_PARTICLES = 287,
|
||||
KW_FRAMESPERSEC = 288,
|
||||
KW_RAYTRACING = 289,
|
||||
KW_PAROPEN = 290,
|
||||
KW_PARCLOSE = 291,
|
||||
KW_FILENAME = 292,
|
||||
KW_PMCAUSTICS = 293,
|
||||
KW_MAXRAYDEPTH = 294,
|
||||
KW_CAUSTICDIST = 295,
|
||||
KW_CAUSTICPHOT = 296,
|
||||
KW_SHADOWMAPBIAS = 297,
|
||||
KW_TREEMAXDEPTH = 298,
|
||||
KW_TREEMAXTRIANGLES = 299,
|
||||
KW_RESOLUTION = 300,
|
||||
KW_ANTIALIAS = 301,
|
||||
KW_EYEPOINT = 302,
|
||||
KW_ANISTART = 303,
|
||||
KW_ANIFRAMES = 304,
|
||||
KW_FRAMESKIP = 305,
|
||||
KW_LOOKAT = 306,
|
||||
KW_UPVEC = 307,
|
||||
KW_FOVY = 308,
|
||||
KW_ASPECT = 309,
|
||||
KW_AMBIENCE = 310,
|
||||
KW_BACKGROUND = 311,
|
||||
KW_DEBUGPIXEL = 312,
|
||||
KW_TESTMODE = 313,
|
||||
KW_OPENGLATTR = 314,
|
||||
KW_BLENDERATTR = 315,
|
||||
KW_ATTRIBUTE = 316,
|
||||
KW_OBJATTR = 317,
|
||||
KW_EQUALS = 318,
|
||||
KW_DEFINEATTR = 319,
|
||||
KW_ATTREND = 320,
|
||||
KW_GEOMETRY = 321,
|
||||
KW_TYPE = 322,
|
||||
KW_GEOTYPE_BOX = 323,
|
||||
KW_GEOTYPE_FLUID = 324,
|
||||
KW_GEOTYPE_OBJMODEL = 325,
|
||||
KW_GEOTYPE_SPHERE = 326,
|
||||
KW_CASTSHADOWS = 327,
|
||||
KW_RECEIVESHADOWS = 328,
|
||||
KW_VISIBLE = 329,
|
||||
KW_BOX_END = 330,
|
||||
KW_BOX_START = 331,
|
||||
KW_POLY = 332,
|
||||
KW_NUMVERTICES = 333,
|
||||
KW_VERTEX = 334,
|
||||
KW_NUMPOLYGONS = 335,
|
||||
KW_ISOSURF = 336,
|
||||
KW_FILEMODE = 337,
|
||||
KW_INVERT = 338,
|
||||
KW_MATERIAL = 339,
|
||||
KW_MATTYPE_PHONG = 340,
|
||||
KW_MATTYPE_BLINN = 341,
|
||||
KW_NAME = 342,
|
||||
KW_AMBIENT = 343,
|
||||
KW_DIFFUSE = 344,
|
||||
KW_SPECULAR = 345,
|
||||
KW_MIRROR = 346,
|
||||
KW_TRANSPARENCE = 347,
|
||||
KW_REFRACINDEX = 348,
|
||||
KW_TRANSADDITIVE = 349,
|
||||
KW_TRANSATTCOL = 350,
|
||||
KW_FRESNEL = 351,
|
||||
KW_LIGHT = 352,
|
||||
KW_ACTIVE = 353,
|
||||
KW_COLOUR = 354,
|
||||
KW_POSITION = 355,
|
||||
KW_LIGHT_OMNI = 356,
|
||||
KW_CAUSTICPHOTONS = 357,
|
||||
KW_CAUSTICSTRENGTH = 358,
|
||||
KW_SHADOWMAP = 359,
|
||||
KW_CAUSTICSMAP = 360
|
||||
};
|
||||
#endif
|
||||
#define DT_INTEGER 258
|
||||
@@ -142,112 +143,113 @@
|
||||
#define KW_COMPARELBM 264
|
||||
#define KW_ANIFRAMETIME 265
|
||||
#define KW_DEBUGMODE 266
|
||||
#define KW_P_RELAXTIME 267
|
||||
#define KW_P_REYNOLDS 268
|
||||
#define KW_P_VISCOSITY 269
|
||||
#define KW_P_SOUNDSPEED 270
|
||||
#define KW_P_DOMAINSIZE 271
|
||||
#define KW_P_FORCE 272
|
||||
#define KW_P_TIMELENGTH 273
|
||||
#define KW_P_STEPTIME 274
|
||||
#define KW_P_TIMEFACTOR 275
|
||||
#define KW_P_ANIFRAMETIME 276
|
||||
#define KW_P_ANISTART 277
|
||||
#define KW_P_SURFACETENSION 278
|
||||
#define KW_P_ACTIVATE 279
|
||||
#define KW_P_DEACTIVATE 280
|
||||
#define KW_P_DENSITY 281
|
||||
#define KW_P_CELLSIZE 282
|
||||
#define KW_P_GSTAR 283
|
||||
#define KW_PFSPATH 284
|
||||
#define KW_PARTLINELENGTH 285
|
||||
#define KW_PARTICLES 286
|
||||
#define KW_FRAMESPERSEC 287
|
||||
#define KW_RAYTRACING 288
|
||||
#define KW_PAROPEN 289
|
||||
#define KW_PARCLOSE 290
|
||||
#define KW_FILENAME 291
|
||||
#define KW_PMCAUSTICS 292
|
||||
#define KW_MAXRAYDEPTH 293
|
||||
#define KW_CAUSTICDIST 294
|
||||
#define KW_CAUSTICPHOT 295
|
||||
#define KW_SHADOWMAPBIAS 296
|
||||
#define KW_TREEMAXDEPTH 297
|
||||
#define KW_TREEMAXTRIANGLES 298
|
||||
#define KW_RESOLUTION 299
|
||||
#define KW_ANTIALIAS 300
|
||||
#define KW_EYEPOINT 301
|
||||
#define KW_ANISTART 302
|
||||
#define KW_ANIFRAMES 303
|
||||
#define KW_FRAMESKIP 304
|
||||
#define KW_LOOKAT 305
|
||||
#define KW_UPVEC 306
|
||||
#define KW_FOVY 307
|
||||
#define KW_ASPECT 308
|
||||
#define KW_AMBIENCE 309
|
||||
#define KW_BACKGROUND 310
|
||||
#define KW_DEBUGPIXEL 311
|
||||
#define KW_TESTMODE 312
|
||||
#define KW_OPENGLATTR 313
|
||||
#define KW_BLENDERATTR 314
|
||||
#define KW_ATTRIBUTE 315
|
||||
#define KW_OBJATTR 316
|
||||
#define KW_EQUALS 317
|
||||
#define KW_DEFINEATTR 318
|
||||
#define KW_ATTREND 319
|
||||
#define KW_GEOMETRY 320
|
||||
#define KW_TYPE 321
|
||||
#define KW_GEOTYPE_BOX 322
|
||||
#define KW_GEOTYPE_FLUID 323
|
||||
#define KW_GEOTYPE_OBJMODEL 324
|
||||
#define KW_GEOTYPE_SPHERE 325
|
||||
#define KW_CASTSHADOWS 326
|
||||
#define KW_RECEIVESHADOWS 327
|
||||
#define KW_VISIBLE 328
|
||||
#define KW_BOX_END 329
|
||||
#define KW_BOX_START 330
|
||||
#define KW_POLY 331
|
||||
#define KW_NUMVERTICES 332
|
||||
#define KW_VERTEX 333
|
||||
#define KW_NUMPOLYGONS 334
|
||||
#define KW_ISOSURF 335
|
||||
#define KW_FILEMODE 336
|
||||
#define KW_INVERT 337
|
||||
#define KW_MATERIAL 338
|
||||
#define KW_MATTYPE_PHONG 339
|
||||
#define KW_MATTYPE_BLINN 340
|
||||
#define KW_NAME 341
|
||||
#define KW_AMBIENT 342
|
||||
#define KW_DIFFUSE 343
|
||||
#define KW_SPECULAR 344
|
||||
#define KW_MIRROR 345
|
||||
#define KW_TRANSPARENCE 346
|
||||
#define KW_REFRACINDEX 347
|
||||
#define KW_TRANSADDITIVE 348
|
||||
#define KW_TRANSATTCOL 349
|
||||
#define KW_FRESNEL 350
|
||||
#define KW_LIGHT 351
|
||||
#define KW_ACTIVE 352
|
||||
#define KW_COLOUR 353
|
||||
#define KW_POSITION 354
|
||||
#define KW_LIGHT_OMNI 355
|
||||
#define KW_CAUSTICPHOTONS 356
|
||||
#define KW_CAUSTICSTRENGTH 357
|
||||
#define KW_SHADOWMAP 358
|
||||
#define KW_CAUSTICSMAP 359
|
||||
#define KW_DEBUGLEVEL 267
|
||||
#define KW_P_RELAXTIME 268
|
||||
#define KW_P_REYNOLDS 269
|
||||
#define KW_P_VISCOSITY 270
|
||||
#define KW_P_SOUNDSPEED 271
|
||||
#define KW_P_DOMAINSIZE 272
|
||||
#define KW_P_FORCE 273
|
||||
#define KW_P_TIMELENGTH 274
|
||||
#define KW_P_STEPTIME 275
|
||||
#define KW_P_TIMEFACTOR 276
|
||||
#define KW_P_ANIFRAMETIME 277
|
||||
#define KW_P_ANISTART 278
|
||||
#define KW_P_SURFACETENSION 279
|
||||
#define KW_P_ACTIVATE 280
|
||||
#define KW_P_DEACTIVATE 281
|
||||
#define KW_P_DENSITY 282
|
||||
#define KW_P_CELLSIZE 283
|
||||
#define KW_P_GSTAR 284
|
||||
#define KW_PFSPATH 285
|
||||
#define KW_PARTLINELENGTH 286
|
||||
#define KW_PARTICLES 287
|
||||
#define KW_FRAMESPERSEC 288
|
||||
#define KW_RAYTRACING 289
|
||||
#define KW_PAROPEN 290
|
||||
#define KW_PARCLOSE 291
|
||||
#define KW_FILENAME 292
|
||||
#define KW_PMCAUSTICS 293
|
||||
#define KW_MAXRAYDEPTH 294
|
||||
#define KW_CAUSTICDIST 295
|
||||
#define KW_CAUSTICPHOT 296
|
||||
#define KW_SHADOWMAPBIAS 297
|
||||
#define KW_TREEMAXDEPTH 298
|
||||
#define KW_TREEMAXTRIANGLES 299
|
||||
#define KW_RESOLUTION 300
|
||||
#define KW_ANTIALIAS 301
|
||||
#define KW_EYEPOINT 302
|
||||
#define KW_ANISTART 303
|
||||
#define KW_ANIFRAMES 304
|
||||
#define KW_FRAMESKIP 305
|
||||
#define KW_LOOKAT 306
|
||||
#define KW_UPVEC 307
|
||||
#define KW_FOVY 308
|
||||
#define KW_ASPECT 309
|
||||
#define KW_AMBIENCE 310
|
||||
#define KW_BACKGROUND 311
|
||||
#define KW_DEBUGPIXEL 312
|
||||
#define KW_TESTMODE 313
|
||||
#define KW_OPENGLATTR 314
|
||||
#define KW_BLENDERATTR 315
|
||||
#define KW_ATTRIBUTE 316
|
||||
#define KW_OBJATTR 317
|
||||
#define KW_EQUALS 318
|
||||
#define KW_DEFINEATTR 319
|
||||
#define KW_ATTREND 320
|
||||
#define KW_GEOMETRY 321
|
||||
#define KW_TYPE 322
|
||||
#define KW_GEOTYPE_BOX 323
|
||||
#define KW_GEOTYPE_FLUID 324
|
||||
#define KW_GEOTYPE_OBJMODEL 325
|
||||
#define KW_GEOTYPE_SPHERE 326
|
||||
#define KW_CASTSHADOWS 327
|
||||
#define KW_RECEIVESHADOWS 328
|
||||
#define KW_VISIBLE 329
|
||||
#define KW_BOX_END 330
|
||||
#define KW_BOX_START 331
|
||||
#define KW_POLY 332
|
||||
#define KW_NUMVERTICES 333
|
||||
#define KW_VERTEX 334
|
||||
#define KW_NUMPOLYGONS 335
|
||||
#define KW_ISOSURF 336
|
||||
#define KW_FILEMODE 337
|
||||
#define KW_INVERT 338
|
||||
#define KW_MATERIAL 339
|
||||
#define KW_MATTYPE_PHONG 340
|
||||
#define KW_MATTYPE_BLINN 341
|
||||
#define KW_NAME 342
|
||||
#define KW_AMBIENT 343
|
||||
#define KW_DIFFUSE 344
|
||||
#define KW_SPECULAR 345
|
||||
#define KW_MIRROR 346
|
||||
#define KW_TRANSPARENCE 347
|
||||
#define KW_REFRACINDEX 348
|
||||
#define KW_TRANSADDITIVE 349
|
||||
#define KW_TRANSATTCOL 350
|
||||
#define KW_FRESNEL 351
|
||||
#define KW_LIGHT 352
|
||||
#define KW_ACTIVE 353
|
||||
#define KW_COLOUR 354
|
||||
#define KW_POSITION 355
|
||||
#define KW_LIGHT_OMNI 356
|
||||
#define KW_CAUSTICPHOTONS 357
|
||||
#define KW_CAUSTICSTRENGTH 358
|
||||
#define KW_SHADOWMAP 359
|
||||
#define KW_CAUSTICSMAP 360
|
||||
|
||||
|
||||
|
||||
|
||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||
#line 85 "src/cfgparser.yy"
|
||||
#line 87 "src/cfgparser.yy"
|
||||
typedef union YYSTYPE {
|
||||
int intValue;
|
||||
float floatValue;
|
||||
char *charValue;
|
||||
} YYSTYPE;
|
||||
/* Line 1285 of yacc.c. */
|
||||
#line 251 "bld-std-gcc40/src/cfgparser.hpp"
|
||||
/* Line 1318 of yacc.c. */
|
||||
#line 253 "bld-std-gcc40/src/cfgparser.hpp"
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
# define YYSTYPE_IS_DECLARED 1
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
|
@@ -9,9 +9,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
//#include "globals.h"
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
// region of interest global vars
|
||||
// currently used by e.g. fsgr solver
|
||||
@@ -48,4 +45,3 @@ char* usageString =
|
||||
-o : single frame output to given file\n\
|
||||
\n ";
|
||||
|
||||
|
||||
|
@@ -7,15 +7,12 @@
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
// IMPL ----------------------------------------------------------------------------------------
|
||||
#include "isosurface.h"
|
||||
#include "mcubes_tables.h"
|
||||
#include "ntl_scene.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#define MCUBES_MAXPOLNUM 10000
|
||||
#define MCUBES_MAXVERTNUM 30000
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +30,7 @@ IsoSurface::IsoSurface(double iso, double blend) :
|
||||
|
||||
mStart(0.0), mEnd(0.0), mDomainExtent(0.0),
|
||||
mInitDone(false),
|
||||
mLoopSubdivs(0), mSmoothSurface(0.0), mSmoothNormals(0.0),
|
||||
mSmoothSurface(0.0), mSmoothNormals(0.0),
|
||||
mAcrossEdge(), mAdjacentFaces()
|
||||
{
|
||||
}
|
||||
@@ -325,14 +322,11 @@ void IsoSurface::triangulate( void )
|
||||
// if(mSmoothNormals<=0.0) { smoothNormals(mSmoothSurface*0.5); }
|
||||
smoothSurface(mSmoothSurface);
|
||||
}
|
||||
for(int i=0; i<mLoopSubdivs; i++) {
|
||||
subdivide();
|
||||
}
|
||||
if(mSmoothNormals>0.0) {
|
||||
smoothNormals(mSmoothNormals);
|
||||
}
|
||||
myTime_t tritimeend = getTime();
|
||||
debMsgStd("IsoSurface::triangulate",DM_MSG,"Took "<< ((tritimeend-tritimestart)/(double)1000.0)<<"s) " , 10 );
|
||||
debMsgStd("IsoSurface::triangulate",DM_MSG,"took "<< ((tritimeend-tritimestart)/(double)1000.0)<<"s, ss="<<mSmoothSurface<<" sm="<<mSmoothNormals , 10 );
|
||||
}
|
||||
|
||||
|
||||
@@ -422,15 +416,7 @@ void IsoSurface::getTriangles( vector<ntlTriangle> *triangles,
|
||||
|
||||
|
||||
inline ntlVec3Gfx IsoSurface::getNormal(int i, int j,int k) {
|
||||
// WARNING - this assumes a security boundary layer...
|
||||
/*
|
||||
if(i<=0) i=1;
|
||||
if(j<=0) j=1;
|
||||
if(k<=0) k=1;
|
||||
if(i>=(mSizex-1)) i=mSizex-2;
|
||||
if(j>=(mSizex-1)) j=mSizex-2;
|
||||
if(k>=(mSizex-1)) k=mSizex-2; // */
|
||||
|
||||
// WARNING - this requires a security boundary layer...
|
||||
ntlVec3Gfx ret(0.0);
|
||||
ret[0] = *getData(i-1,j ,k ) -
|
||||
*getData(i+1,j ,k );
|
||||
@@ -441,282 +427,6 @@ inline ntlVec3Gfx IsoSurface::getNormal(int i, int j,int k) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define RECALCNORMALS 0
|
||||
|
||||
// Subdivide a mesh allways loop
|
||||
void IsoSurface::subdivide()
|
||||
{
|
||||
mAdjacentFaces.clear();
|
||||
mAcrossEdge.clear();
|
||||
|
||||
//void TriMesh::need_adjacentfaces()
|
||||
{
|
||||
vector<int> numadjacentfaces(mPoints.size());
|
||||
//errMsg("SUBDIV ADJFA1", " "<<mPoints.size()<<" - "<<numadjacentfaces.size() );
|
||||
for (int i = 0; i < (int)mIndices.size()/3; i++) {
|
||||
numadjacentfaces[mIndices[i*3 + 0]]++;
|
||||
numadjacentfaces[mIndices[i*3 + 1]]++;
|
||||
numadjacentfaces[mIndices[i*3 + 2]]++;
|
||||
}
|
||||
|
||||
mAdjacentFaces.resize(mPoints.size());
|
||||
for (int i = 0; i < (int)mPoints.size(); i++)
|
||||
mAdjacentFaces[i].reserve(numadjacentfaces[i]);
|
||||
|
||||
for (int i = 0; i < (int)mIndices.size()/3; i++) {
|
||||
for (int j = 0; j < 3; j++)
|
||||
mAdjacentFaces[mIndices[i*3 + j]].push_back(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Find the face across each edge from each other face (-1 on boundary)
|
||||
// If topology is bad, not necessarily what one would expect...
|
||||
//void TriMesh::need_across_edge()
|
||||
{
|
||||
mAcrossEdge.resize(mIndices.size(), -1);
|
||||
|
||||
for (int i = 0; i < (int)mIndices.size()/3; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
if (mAcrossEdge[i*3 + j] != -1)
|
||||
continue;
|
||||
int v1 = mIndices[i*3 + ((j+1)%3)];
|
||||
int v2 = mIndices[i*3 + ((j+2)%3)];
|
||||
const vector<int> &a1 = mAdjacentFaces[v1];
|
||||
const vector<int> &a2 = mAdjacentFaces[v2];
|
||||
for (int k1 = 0; k1 < (int)a1.size(); k1++) {
|
||||
int other = a1[k1];
|
||||
if (other == i)
|
||||
continue;
|
||||
vector<int>::const_iterator it =
|
||||
std::find(a2.begin(), a2.end(), other);
|
||||
if (it == a2.end())
|
||||
continue;
|
||||
|
||||
//int ind = (faces[other].indexof(v1)+1)%3;
|
||||
int ind = -1;
|
||||
if( mIndices[other*3+0] == (unsigned int)v1 ) ind = 0;
|
||||
else if( mIndices[other*3+1] == (unsigned int)v1 ) ind = 1;
|
||||
else if( mIndices[other*3+2] == (unsigned int)v1 ) ind = 2;
|
||||
ind = (ind+1)%3;
|
||||
|
||||
if ( (int)mIndices[other*3 + ((ind+1)%3)] != v2)
|
||||
continue;
|
||||
mAcrossEdge[i*3 + j] = other;
|
||||
mAcrossEdge[other*3 + ind] = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//errMsg("SUBDIV ACREDG", "Done.\n");
|
||||
}
|
||||
|
||||
//errMsg("SUBDIV","start");
|
||||
// Introduce new vertices
|
||||
int nf = (int)mIndices.size() / 3;
|
||||
|
||||
//vector<TriMesh::Face> newverts(nf, TriMesh::Face(-1,-1,-1));
|
||||
vector<int> newverts(nf*3); //, TriMesh::Face(-1,-1,-1));
|
||||
for(int j=0; j<(int)newverts.size(); j++) newverts[j] = -1;
|
||||
|
||||
int old_nv = (int)mPoints.size();
|
||||
mPoints.reserve(4 * old_nv);
|
||||
vector<int> newvert_count(old_nv + 3*nf); // wichtig...?
|
||||
//errMsg("NC", newvert_count.size() );
|
||||
|
||||
for (int i = 0; i < nf; i++) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
int ae = mAcrossEdge[i*3 + j];
|
||||
if (newverts[i*3 + j] == -1 && ae != -1) {
|
||||
if (mAcrossEdge[ae*3 + 0] == i)
|
||||
newverts[i*3 + j] = newverts[ae*3 + 0];
|
||||
else if (mAcrossEdge[ae*3 + 1] == i)
|
||||
newverts[i*3 + j] = newverts[ae*3 + 1];
|
||||
else if (mAcrossEdge[ae*3 + 2] == i)
|
||||
newverts[i*3 + j] = newverts[ae*3 + 2];
|
||||
}
|
||||
if (newverts[i*3 + j] == -1) {
|
||||
IsoLevelVertex ilv;
|
||||
ilv.v = ntlVec3Gfx(0.0);
|
||||
ilv.n = ntlVec3Gfx(0.0);
|
||||
mPoints.push_back(ilv);
|
||||
newverts[i*3 + j] = (int)mPoints.size() - 1;
|
||||
if (ae != -1) {
|
||||
if (mAcrossEdge[ae*3 + 0] == i)
|
||||
newverts[ae*3 + 0] = newverts[i*3 + j];
|
||||
else if (mAcrossEdge[ae*3 + 1] == i)
|
||||
newverts[ae*3 + 1] = newverts[i*3 + j];
|
||||
else if (mAcrossEdge[ae*3 + 2] == i)
|
||||
newverts[ae*3 + 2] = newverts[i*3 + j];
|
||||
}
|
||||
}
|
||||
if(ae != -1) {
|
||||
mPoints[newverts[i*3 + j]].v +=
|
||||
mPoints[ mIndices[i*3 + ( j )] ].v * 0.25f + // j = 0,1,2?
|
||||
mPoints[ mIndices[i*3 + ((j+1)%3)] ].v * 0.375f +
|
||||
mPoints[ mIndices[i*3 + ((j+2)%3)] ].v * 0.375f;
|
||||
#if RECALCNORMALS==0
|
||||
mPoints[newverts[i*3 + j]].n +=
|
||||
mPoints[ mIndices[i*3 + ( j )] ].n * 0.25f + // j = 0,1,2?
|
||||
mPoints[ mIndices[i*3 + ((j+1)%3)] ].n * 0.375f +
|
||||
mPoints[ mIndices[i*3 + ((j+2)%3)] ].n * 0.375f;
|
||||
#endif // RECALCNORMALS==0
|
||||
} else {
|
||||
mPoints[newverts[i*3 + j]].v +=
|
||||
mPoints[ mIndices[i*3 + ((j+1)%3)] ].v * 0.5f +
|
||||
mPoints[ mIndices[i*3 + ((j+2)%3)] ].v * 0.5f ;
|
||||
#if RECALCNORMALS==0
|
||||
mPoints[newverts[i*3 + j]].n +=
|
||||
mPoints[ mIndices[i*3 + ((j+1)%3)] ].n * 0.5f +
|
||||
mPoints[ mIndices[i*3 + ((j+2)%3)] ].n * 0.5f ;
|
||||
#endif // RECALCNORMALS==0
|
||||
}
|
||||
|
||||
newvert_count[newverts[i*3 + j]]++;
|
||||
}
|
||||
}
|
||||
for (int i = old_nv; i < (int)mPoints.size(); i++) {
|
||||
if (!newvert_count[i])
|
||||
continue;
|
||||
float scale = 1.0f / newvert_count[i];
|
||||
mPoints[i].v *= scale;
|
||||
|
||||
#if RECALCNORMALS==0
|
||||
//mPoints[i].n *= scale;
|
||||
//normalize( mPoints[i].n );
|
||||
#endif // RECALCNORMALS==0
|
||||
}
|
||||
|
||||
// Update old vertices
|
||||
for (int i = 0; i < old_nv; i++) {
|
||||
ntlVec3Gfx bdyavg(0.0), nbdyavg(0.0);
|
||||
ntlVec3Gfx norm_bdyavg(0.0), norm_nbdyavg(0.0); // N
|
||||
int nbdy = 0, nnbdy = 0;
|
||||
int naf = (int)mAdjacentFaces[i].size();
|
||||
if (!naf)
|
||||
continue;
|
||||
for (int j = 0; j < naf; j++) {
|
||||
int af = mAdjacentFaces[i][j];
|
||||
|
||||
int afi = -1;
|
||||
if( mIndices[af*3+0] == (unsigned int)i ) afi = 0;
|
||||
else if( mIndices[af*3+1] == (unsigned int)i ) afi = 1;
|
||||
else if( mIndices[af*3+2] == (unsigned int)i ) afi = 2;
|
||||
|
||||
int n1 = (afi+1) % 3;
|
||||
int n2 = (afi+2) % 3;
|
||||
if (mAcrossEdge[af*3 + n1] == -1) {
|
||||
bdyavg += mPoints[newverts[af*3 + n1]].v;
|
||||
#if RECALCNORMALS==0
|
||||
//norm_bdyavg += mPoints[newverts[af*3 + n1]].n;
|
||||
#endif // RECALCNORMALS==0
|
||||
nbdy++;
|
||||
} else {
|
||||
nbdyavg += mPoints[newverts[af*3 + n1]].v;
|
||||
#if RECALCNORMALS==0
|
||||
//norm_nbdyavg += mPoints[newverts[af*3 + n1]].n;
|
||||
#endif // RECALCNORMALS==0
|
||||
nnbdy++;
|
||||
}
|
||||
if (mAcrossEdge[af*3 + n2] == -1) {
|
||||
bdyavg += mPoints[newverts[af*3 + n2]].v;
|
||||
#if RECALCNORMALS==0
|
||||
//norm_bdyavg += mPoints[newverts[af*3 + n2]].n;
|
||||
#endif // RECALCNORMALS==0
|
||||
nbdy++;
|
||||
} else {
|
||||
nbdyavg += mPoints[newverts[af*3 + n2]].v;
|
||||
#if RECALCNORMALS==0
|
||||
//norm_nbdyavg += mPoints[newverts[af*3 + n2]].n;
|
||||
#endif // RECALCNORMALS==0
|
||||
nnbdy++;
|
||||
}
|
||||
}
|
||||
|
||||
float alpha;
|
||||
ntlVec3Gfx newpt;
|
||||
if (nbdy) {
|
||||
newpt = bdyavg / (float) nbdy;
|
||||
alpha = 0.5f;
|
||||
} else if (nnbdy) {
|
||||
newpt = nbdyavg / (float) nnbdy;
|
||||
if (nnbdy == 6)
|
||||
alpha = 1.05;
|
||||
else if (nnbdy == 8)
|
||||
alpha = 0.86;
|
||||
else if (nnbdy == 10)
|
||||
alpha = 0.7;
|
||||
else
|
||||
alpha = 0.6;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
mPoints[i].v *= 1.0f - alpha;
|
||||
mPoints[i].v += newpt * alpha;
|
||||
|
||||
#if RECALCNORMALS==0
|
||||
//mPoints[i].n *= 1.0f - alpha;
|
||||
//mPoints[i].n += newpt * alpha;
|
||||
#endif // RECALCNORMALS==0
|
||||
}
|
||||
|
||||
// Insert new faces
|
||||
mIndices.reserve(4*nf);
|
||||
for (int i = 0; i < nf; i++) {
|
||||
mIndices.push_back( mIndices[i*3 + 0]);
|
||||
mIndices.push_back( newverts[i*3 + 2]);
|
||||
mIndices.push_back( newverts[i*3 + 1]);
|
||||
|
||||
mIndices.push_back( mIndices[i*3 + 1]);
|
||||
mIndices.push_back( newverts[i*3 + 0]);
|
||||
mIndices.push_back( newverts[i*3 + 2]);
|
||||
|
||||
mIndices.push_back( mIndices[i*3 + 2]);
|
||||
mIndices.push_back( newverts[i*3 + 1]);
|
||||
mIndices.push_back( newverts[i*3 + 0]);
|
||||
|
||||
mIndices[i*3+0] = newverts[i*3+0];
|
||||
mIndices[i*3+1] = newverts[i*3+1];
|
||||
mIndices[i*3+2] = newverts[i*3+2];
|
||||
}
|
||||
|
||||
// recalc normals
|
||||
#if RECALCNORMALS==1
|
||||
{
|
||||
int nf = (int)mIndices.size()/3, nv = (int)mPoints.size();
|
||||
for (int i = 0; i < nv; i++) {
|
||||
mPoints[i].n = ntlVec3Gfx(0.0);
|
||||
}
|
||||
for (int i = 0; i < nf; i++) {
|
||||
const ntlVec3Gfx &p0 = mPoints[mIndices[i*3+0]].v;
|
||||
const ntlVec3Gfx &p1 = mPoints[mIndices[i*3+1]].v;
|
||||
const ntlVec3Gfx &p2 = mPoints[mIndices[i*3+2]].v;
|
||||
ntlVec3Gfx a = p0-p1, b = p1-p2, c = p2-p0;
|
||||
float l2a = normNoSqrt(a), l2b = normNoSqrt(b), l2c = normNoSqrt(c);
|
||||
|
||||
ntlVec3Gfx facenormal = cross(a, b);
|
||||
|
||||
mPoints[mIndices[i*3+0]].n += facenormal * (1.0f / (l2a * l2c));
|
||||
mPoints[mIndices[i*3+1]].n += facenormal * (1.0f / (l2b * l2a));
|
||||
mPoints[mIndices[i*3+2]].n += facenormal * (1.0f / (l2c * l2b));
|
||||
}
|
||||
|
||||
for (int i = 0; i < nv; i++) {
|
||||
normalize(mPoints[i].n);
|
||||
}
|
||||
}
|
||||
#else // RECALCNORMALS==1
|
||||
for (int i = 0; i < (int)mPoints.size(); i++) {
|
||||
normalize(mPoints[i].n);
|
||||
}
|
||||
#endif // RECALCNORMALS==1
|
||||
|
||||
//errMsg("SUBDIV","done nv:"<<mPoints.size()<<" nf:"<<mIndices.size() );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -732,8 +442,6 @@ void IsoSurface::subdivide()
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
// Diffuse a vector field at 1 vertex, weighted by
|
||||
// a gaussian of width 1/sqrt(invsigma2)
|
||||
void IsoSurface::diffuseVertexField(ntlVec3Gfx *field, const int pointerScale, int v, float invsigma2, ntlVec3Gfx &flt)
|
||||
@@ -777,8 +485,6 @@ void IsoSurface::diffuseVertexField(ntlVec3Gfx *field, const int pointerScale, i
|
||||
flt /= sum_w;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void IsoSurface::smoothSurface(float sigma)
|
||||
{
|
||||
int nv = mPoints.size();
|
||||
|
@@ -11,12 +11,9 @@
|
||||
|
||||
#include "ntl_geometryobject.h"
|
||||
#include "ntl_bsptree.h"
|
||||
//class LbmSolver3D;
|
||||
|
||||
|
||||
|
||||
/* access some 3d array */
|
||||
//#define ISOLEVEL_INDEX(ii,ij,ik) ((S::mSizex*S::mSizey*(ik))+(S::mSizex*(ij))+((ii)))
|
||||
#define ISOLEVEL_INDEX(ii,ij,ik) ((mSizex*mSizey*(ik))+(mSizex*(ij))+((ii)))
|
||||
|
||||
/* struct for a small cube in the scalar field */
|
||||
@@ -34,7 +31,6 @@ typedef struct {
|
||||
|
||||
//! class to triangulate a scalar field, e.g. for
|
||||
// the fluid surface, templated by scalar field access object
|
||||
//template<class S>
|
||||
class IsoSurface :
|
||||
public ntlGeometryObject //, public S
|
||||
{
|
||||
@@ -89,8 +85,6 @@ class IsoSurface :
|
||||
//! initialized?
|
||||
bool mInitDone;
|
||||
|
||||
//! no. of refinement steps
|
||||
int mLoopSubdivs;
|
||||
//! amount of surface smoothing
|
||||
float mSmoothSurface;
|
||||
//! amount of normal smoothing
|
||||
@@ -116,7 +110,6 @@ class IsoSurface :
|
||||
//! set iso level value for surface reconstruction
|
||||
inline void setIsolevel(double set) { mIsoValue = set; };
|
||||
//! set loop subdiv num
|
||||
inline void setLoopSubdivs(int set) { mLoopSubdivs = set; };
|
||||
inline void setSmoothSurface(float set) { mSmoothSurface = set; };
|
||||
inline void setSmoothNormals(float set) { mSmoothNormals = set; };
|
||||
|
||||
@@ -161,118 +154,6 @@ class IsoSurface :
|
||||
|
||||
|
||||
|
||||
class TriMesh {
|
||||
public:
|
||||
// Types
|
||||
struct Face {
|
||||
int v[3];
|
||||
|
||||
Face() {}
|
||||
Face(const int &v0, const int &v1, const int &v2)
|
||||
{ v[0] = v0; v[1] = v1; v[2] = v2; }
|
||||
Face(const int *v_)
|
||||
{ v[0] = v_[0]; v[1] = v_[1]; v[2] = v_[2]; }
|
||||
int &operator[] (int i) { return v[i]; }
|
||||
const int &operator[] (int i) const { return v[i]; }
|
||||
operator const int * () const { return &(v[0]); }
|
||||
operator const int * () { return &(v[0]); }
|
||||
operator int * () { return &(v[0]); }
|
||||
int indexof(int v_) const
|
||||
{
|
||||
return (v[0] == v_) ? 0 :
|
||||
(v[1] == v_) ? 1 :
|
||||
(v[2] == v_) ? 2 : -1;
|
||||
}
|
||||
};
|
||||
|
||||
struct BBox {
|
||||
public:
|
||||
BBox() {};
|
||||
ntlVec3Gfx min, max;
|
||||
ntlVec3Gfx center() const { return (min+max)*0.5f; }
|
||||
ntlVec3Gfx size() const { return max - min; }
|
||||
};
|
||||
|
||||
struct BSphere {
|
||||
ntlVec3Gfx center;
|
||||
float r;
|
||||
};
|
||||
|
||||
// Enums
|
||||
enum tstrip_rep { TSTRIP_LENGTH, TSTRIP_TERM };
|
||||
|
||||
// The basics: vertices and faces
|
||||
vector<ntlVec3Gfx> vertices;
|
||||
vector<Face> faces;
|
||||
|
||||
// Triangle strips
|
||||
vector<int> tstrips;
|
||||
|
||||
// Other per-vertex properties
|
||||
//vector<Color> colors;
|
||||
vector<float> confidences;
|
||||
vector<unsigned> flags;
|
||||
unsigned flag_curr;
|
||||
|
||||
// Computed per-vertex properties
|
||||
vector<ntlVec3Gfx> normals;
|
||||
vector<ntlVec3Gfx> pdir1, pdir2;
|
||||
vector<float> curv1, curv2;
|
||||
//vector< Vec<4,float> > dcurv;
|
||||
vector<ntlVec3Gfx> cornerareas;
|
||||
vector<float> pointareas;
|
||||
|
||||
// Bounding structures
|
||||
BBox bbox;
|
||||
BSphere bsphere;
|
||||
|
||||
// Connectivity structures:
|
||||
// For each vertex, all neighboring vertices
|
||||
vector< vector<int> > neighbors;
|
||||
// For each vertex, all neighboring faces
|
||||
vector< vector<int> > adjacentfaces;
|
||||
// For each face, the three faces attached to its edges
|
||||
// (for example, across_edge[3][2] is the number of the face
|
||||
// that's touching the edge opposite vertex 2 of face 3)
|
||||
vector<Face> across_edge;
|
||||
|
||||
// Compute all this stuff...
|
||||
void need_tstrips();
|
||||
void convert_strips(tstrip_rep rep);
|
||||
void need_faces();
|
||||
void need_normals();
|
||||
void need_pointareas();
|
||||
void need_curvatures();
|
||||
void need_dcurv();
|
||||
void need_bbox();
|
||||
void need_bsphere();
|
||||
void need_neighbors();
|
||||
void need_adjacentfaces();
|
||||
void need_across_edge();
|
||||
|
||||
// Input and output
|
||||
static TriMesh *read(const char *filename);
|
||||
void write(const char *filename);
|
||||
|
||||
// Statistics
|
||||
// XXX - Add stuff here
|
||||
float feature_size();
|
||||
|
||||
// Useful queries
|
||||
// XXX - Add stuff here
|
||||
bool is_bdy(int v)
|
||||
{
|
||||
if (neighbors.empty()) need_neighbors();
|
||||
if (adjacentfaces.empty()) need_adjacentfaces();
|
||||
return neighbors[v].size() != adjacentfaces[v].size();
|
||||
}
|
||||
|
||||
// Debugging printout, controllable by a "verbose"ness parameter
|
||||
static int verbose;
|
||||
static void set_verbose(int);
|
||||
static int dprintf(const char *format, ...);
|
||||
};
|
||||
|
||||
#define ISOSURFACE_H
|
||||
#endif
|
||||
|
||||
|
@@ -249,7 +249,7 @@ class LbmModelLBGK : public DQ , public LbmSolverInterface {
|
||||
// virtual destructor
|
||||
virtual ~LbmModelLBGK() {};
|
||||
//! id string of solver
|
||||
std::string getIdString() { return DQ::getIdString() + std::string("lbgk]"); }
|
||||
string getIdString() { return DQ::getIdString() + string("lbgk]"); }
|
||||
|
||||
/*! calculate length of velocity vector */
|
||||
static inline LbmFloat getVelVecLen(int l, LbmFloat ux,LbmFloat uy,LbmFloat uz) {
|
||||
|
@@ -12,7 +12,6 @@
|
||||
|
||||
#ifndef LBMFSGRSOLVER_H
|
||||
#include "utilities.h"
|
||||
#include "arrays.h"
|
||||
#include "lbmdimensions.h"
|
||||
#include "lbmfunctions.h"
|
||||
#include "ntl_scene.h"
|
||||
@@ -56,10 +55,11 @@ ERROR - define model first!
|
||||
#define USE_LES 1
|
||||
|
||||
//! order of interpolation (1/2)
|
||||
#define INTORDER 1
|
||||
#define INTORDER 2
|
||||
|
||||
//! order of interpolation (0=always current/1=interpolate/2=always other)
|
||||
#define TIMEINTORDER 0
|
||||
//#define TIMEINTORDER 0
|
||||
// TODO remove interpol t param, also interTime
|
||||
|
||||
//! refinement border method (1 = small border / 2 = larger)
|
||||
#define REFINEMENTBORDER 1
|
||||
@@ -86,7 +86,6 @@ ERROR - define model first!
|
||||
#define COMPRESSGRIDS 0
|
||||
#endif
|
||||
|
||||
|
||||
//! threshold for level set fluid generation/isosurface
|
||||
#define LS_FLUIDTHRESHOLD 0.5
|
||||
|
||||
@@ -366,7 +365,6 @@ class LbmFsgrSolver :
|
||||
|
||||
//! Mcubes object for surface reconstruction
|
||||
IsoSurface *mpPreviewSurface;
|
||||
int mLoopSubdivs;
|
||||
float mSmoothSurface;
|
||||
float mSmoothNormals;
|
||||
|
||||
@@ -453,8 +451,6 @@ class LbmFsgrSolver :
|
||||
|
||||
/*! LES C_smago paramter for finest grid */
|
||||
float mInitialCsmago;
|
||||
/*! LES C_smago paramter for coarser grids */
|
||||
float mInitialCsmagoCoarse;
|
||||
/*! LES stats for non OPT3D */
|
||||
LbmFloat mDebugOmegaRet;
|
||||
|
||||
@@ -1194,7 +1190,7 @@ class LbmFsgrSolver :
|
||||
if(RFLAG_NB(lev, i,j,k,SRCS(lev),l)&CFBnd) { errMsg("???", "bnd-err-nobndfl"); D::mPanic=1; \
|
||||
} else { m[l] = QCELL_NBINV(lev, i, j, k, SRCS(lev), l, l); } \
|
||||
} \
|
||||
f__printf(stderr,"QSDM at %d,%d,%d lcsmqo=%25.15f, lcsmomega=%f \n", i,j,k, lcsmqo,lcsmomega ); \
|
||||
errMsg("T","QSDM at %d,%d,%d lcsmqo=%25.15f, lcsmomega=%f \n", i,j,k, lcsmqo,lcsmomega ); \
|
||||
rho=m[0]; ux = mLevel[lev].gravity[0]; uy = mLevel[lev].gravity[1]; uz = mLevel[lev].gravity[2]; \
|
||||
ux = mLevel[lev].gravity[0]; uy = mLevel[lev].gravity[1]; uz = mLevel[lev].gravity[2]; \
|
||||
D::collideArrays( m, rho,ux,uy,uz, OMEGA(lev), mLevel[lev].lcsmago , &mDebugOmegaRet ); \
|
||||
@@ -1242,7 +1238,7 @@ LbmFsgrSolver<D>::LbmFsgrSolver() :
|
||||
mNumProblems(0),
|
||||
mAvgMLSUPS(0.0), mAvgMLSUPSCnt(0.0),
|
||||
mpPreviewSurface(NULL),
|
||||
mLoopSubdivs(0), mSmoothSurface(0.0), mSmoothNormals(0.0),
|
||||
mSmoothSurface(0.0), mSmoothNormals(0.0),
|
||||
mTimeAdap(false),
|
||||
mOutputSurfacePreview(0), mPreviewFactor(0.25),
|
||||
mFVHeight(0.0), mFVArea(1.0), mUpdateFVHeight(false),
|
||||
@@ -1258,7 +1254,7 @@ LbmFsgrSolver<D>::LbmFsgrSolver() :
|
||||
mIsoWeightMethod(2),
|
||||
mMaxRefine(1),
|
||||
mDfScaleUp(-1.0), mDfScaleDown(-1.0),
|
||||
mInitialCsmago(0.04), mInitialCsmagoCoarse(1.0), mDebugOmegaRet(0.0),
|
||||
mInitialCsmago(0.04), mDebugOmegaRet(0.0),
|
||||
mNumInvIfTotal(0), mNumFsgrChanges(0),
|
||||
mDisableStandingFluidInit(0),
|
||||
mForceTadapRefine(-1)
|
||||
@@ -1371,12 +1367,18 @@ LbmFsgrSolver<D>::parseAttrList()
|
||||
|
||||
mIsoWeightMethod= D::mpAttrs->readInt("isoweightmethod", mIsoWeightMethod, "SimulationLbm","mIsoWeightMethod", false );
|
||||
mInitSurfaceSmoothing = D::mpAttrs->readInt("initsurfsmooth", mInitSurfaceSmoothing, "SimulationLbm","mInitSurfaceSmoothing", false );
|
||||
mLoopSubdivs = D::mpAttrs->readInt("loopsubdivs", mLoopSubdivs, "SimulationLbm","mLoopSubdivs", false );
|
||||
mSmoothSurface = D::mpAttrs->readFloat("smoothsurface", mSmoothSurface, "SimulationLbm","mSmoothSurface", false );
|
||||
mSmoothNormals = D::mpAttrs->readFloat("smoothnormals", mSmoothNormals, "SimulationLbm","mSmoothNormals", false );
|
||||
|
||||
mInitialCsmago = D::mpAttrs->readFloat("csmago", mInitialCsmago, "SimulationLbm","mInitialCsmago", false );
|
||||
// deprecated!
|
||||
float mInitialCsmagoCoarse = 0.0;
|
||||
mInitialCsmagoCoarse = D::mpAttrs->readFloat("csmago_coarse", mInitialCsmagoCoarse, "SimulationLbm","mInitialCsmagoCoarse", false );
|
||||
#if USE_LES==1
|
||||
#else // USE_LES==1
|
||||
debMsgStd("LbmFsgrSolver", DM_WARNING, "LES model switched off!",2);
|
||||
mInitialCsmago = 0.0;
|
||||
#endif // USE_LES==1
|
||||
|
||||
// refinement
|
||||
mMaxRefine = D::mpAttrs->readInt("maxrefine", mMaxRefine ,"LbmFsgrSolver", "mMaxRefine", true);
|
||||
@@ -1440,7 +1442,7 @@ LbmFsgrSolver<D>::initLevelOmegas()
|
||||
// if(strstr(D::getName().c_str(),"Debug")) mLevel[i].lcsmago = mLevel[mMaxRefine].lcsmago * (LbmFloat)(mMaxRefine-i)*0.5+1.0;
|
||||
//if(strstr(D::getName().c_str(),"Debug")) mLevel[i].lcsmago = mLevel[mMaxRefine].lcsmago * ((LbmFloat)(mMaxRefine-i)*1.0 + 1.0 );
|
||||
//if(strstr(D::getName().c_str(),"Debug")) mLevel[i].lcsmago = 0.99;
|
||||
mLevel[i].lcsmago = mInitialCsmagoCoarse;
|
||||
mLevel[i].lcsmago = mInitialCsmago;
|
||||
mLevel[i].lcsmago_sqr = mLevel[i].lcsmago*mLevel[i].lcsmago;
|
||||
mLevel[i].lcnu = (2.0* (1.0/mLevel[i].omega)-1.0) * (1.0/6.0);
|
||||
}
|
||||
@@ -1529,7 +1531,6 @@ LbmFsgrSolver<D>::initialize( ntlTree* /*tree*/, vector<ntlGeometryObject*>* /*o
|
||||
<<"LBM_EPSILON="<<LBM_EPSILON <<" "
|
||||
<<"FSGR_STRICT_DEBUG="<<FSGR_STRICT_DEBUG <<" "
|
||||
<<"INTORDER="<<INTORDER <<" "
|
||||
<<"TIMEINTORDER="<<TIMEINTORDER <<" "
|
||||
<<"REFINEMENTBORDER="<<REFINEMENTBORDER <<" "
|
||||
<<"OPT3D="<<OPT3D <<" "
|
||||
<<"COMPRESSGRIDS="<<COMPRESSGRIDS<<" "
|
||||
@@ -1683,7 +1684,6 @@ LbmFsgrSolver<D>::initialize( ntlTree* /*tree*/, vector<ntlGeometryObject*>* /*o
|
||||
|
||||
// init isosurf
|
||||
D::mpIso->setIsolevel( D::mIsoValue );
|
||||
D::mpIso->setLoopSubdivs( mLoopSubdivs );
|
||||
// approximate feature size with mesh resolution
|
||||
float featureSize = mLevel[ mMaxRefine ].nodeSize*0.5;
|
||||
D::mpIso->setSmoothSurface( mSmoothSurface * featureSize );
|
||||
@@ -1856,11 +1856,6 @@ LbmFsgrSolver<D>::initialize( ntlTree* /*tree*/, vector<ntlGeometryObject*>* /*o
|
||||
performRefinement(lev);
|
||||
performCoarsening(lev);
|
||||
coarseRestrictFromFine(lev);
|
||||
|
||||
//while( performRefinement(lev) | performCoarsening(lev)){
|
||||
//coarseRestrictFromFine(lev);
|
||||
//debMsgStd("LbmFsgrSolver::initialize",DM_MSG,"Coarsening level "<<lev<<".",8);
|
||||
//}
|
||||
}
|
||||
D::markedClearList();
|
||||
myTime_t fsgrtend = getTime();
|
||||
@@ -2659,29 +2654,16 @@ LbmFsgrSolver<D>::stepMain()
|
||||
if(lev==mMaxRefine) {
|
||||
// always advance fine level...
|
||||
fineAdvance();
|
||||
//performRefinement(lev-1); // TEST here?
|
||||
} else {
|
||||
performRefinement(lev); // TEST here?
|
||||
performCoarsening(lev); // TEST here?
|
||||
performRefinement(lev);
|
||||
performCoarsening(lev);
|
||||
coarseRestrictFromFine(lev);
|
||||
coarseAdvance(lev);
|
||||
//performRefinement(lev-1); // TEST here?
|
||||
}
|
||||
#if FSGR_OMEGA_DEBUG==1
|
||||
errMsg("LbmFsgrSolver::step","LES stats l="<<lev<<" omega="<<mLevel[lev].omega<<" avgOmega="<< (mLevel[lev].avgOmega/mLevel[lev].avgOmegaCnt) );
|
||||
mLevel[lev].avgOmega = 0.0; mLevel[lev].avgOmegaCnt = 0.0;
|
||||
#endif // FSGR_OMEGA_DEBUG==1
|
||||
|
||||
LbmFloat interTime = -10.0;
|
||||
#if TIMEINTORDER==1
|
||||
interTime = 0.5;
|
||||
if( D::mStepCnt & (1<<(mMaxRefine-lev)) ) interTime = 0.0;
|
||||
// TEST influence... interTime = 0.0;
|
||||
#elif TIMEINTORDER==2
|
||||
interTime = 1.0;
|
||||
#else // TIMEINTORDER==0
|
||||
interTime = 0.0;
|
||||
#endif // TIMEINTORDER==1
|
||||
levsteps++;
|
||||
}
|
||||
mCurrentMass += mLevel[lev].lmass;
|
||||
@@ -2857,7 +2839,7 @@ LbmFsgrSolver<D>::stepMain()
|
||||
uz += (D::dfDvecZ[l]*m);
|
||||
}
|
||||
//errMsg("DEBUG"," "<<PRINT_IJK <<" rho="<<rho<<" vel="<<PRINT_VEC(ux,uy,uz) );
|
||||
f__printf(stdout,"D %d,%d rho=%+'.5f vel=[%+'.5f,%+'.5f] \n", i,j, rho, ux,uy );
|
||||
errMsg(stdout,"D %d,%d rho=%+'.5f vel=[%+'.5f,%+'.5f] \n", i,j, rho, ux,uy );
|
||||
}
|
||||
} // DEBUG */
|
||||
|
||||
@@ -3525,7 +3507,7 @@ LbmFsgrSolver<D>::mainLoop(int lev)
|
||||
|
||||
#if COMPRESSGRIDS==1
|
||||
#if PARALLEL==1
|
||||
//fprintf(stderr," (id=%d k=%d) ",id,k);
|
||||
//frintf(stderr," (id=%d k=%d) ",id,k);
|
||||
# pragma omp barrier
|
||||
#endif // PARALLEL==1
|
||||
#else // COMPRESSGRIDS==1
|
||||
@@ -3809,13 +3791,6 @@ errMsg("coarseRestrictFromFine", "TCRFF_DFDEBUG2 test df/dir num!");
|
||||
for(int n=0;(n<D::cDirNum); n++) {
|
||||
mGaussw[n] = mGaussw[n]/totGaussw;
|
||||
}
|
||||
//totGaussw = 1.0/totGaussw;
|
||||
|
||||
//if(!D::mInitDone) {
|
||||
//errMsg("coarseRestrictFromFine", "TCRFF_DFDEBUG2 test pre init");
|
||||
//mGaussw[0] = 1.0;
|
||||
//for(int n=1;(n<D::cDirNum); n++) { mGaussw[n] = 0.0; }
|
||||
//}
|
||||
|
||||
//restrict
|
||||
for(int k= getForZMin1(); k< getForZMax1(lev); ++k) {
|
||||
@@ -3978,7 +3953,7 @@ LbmFsgrSolver<D>::performRefinement(int lev) {
|
||||
if((lev<0) || ((lev+1)>mMaxRefine)) return false;
|
||||
bool change = false;
|
||||
//bool nbsok;
|
||||
// TIMEINTORDER ?
|
||||
// FIXME remove TIMEINTORDER ?
|
||||
LbmFloat interTime = 0.0;
|
||||
// update curr from other, as streaming afterwards works on curr
|
||||
// thus read only from srcSet, modify other
|
||||
|
@@ -614,7 +614,7 @@ void LbmSolverInterface::markedClearList() {
|
||||
|
||||
|
||||
// 32k
|
||||
std::string convertSingleFlag2String(CellFlagType cflag) {
|
||||
string convertSingleFlag2String(CellFlagType cflag) {
|
||||
CellFlagType flag = cflag;
|
||||
if(flag == CFUnused ) return string("cCFUnused");
|
||||
if(flag == CFEmpty ) return string("cCFEmpty");
|
||||
@@ -649,7 +649,7 @@ std::string convertSingleFlag2String(CellFlagType cflag) {
|
||||
}
|
||||
|
||||
//! helper function to convert flag to string (for debuggin)
|
||||
std::string convertCellFlagType2String( CellFlagType cflag ) {
|
||||
string convertCellFlagType2String( CellFlagType cflag ) {
|
||||
int flag = cflag;
|
||||
|
||||
const int jmax = sizeof(CellFlagType)*8;
|
||||
|
@@ -224,7 +224,7 @@ class CellIdentifierInterface {
|
||||
virtual ~CellIdentifierInterface() {};
|
||||
|
||||
//! return node as string (with some basic info)
|
||||
virtual std::string getAsString() = 0;
|
||||
virtual string getAsString() = 0;
|
||||
|
||||
//! compare cids
|
||||
virtual bool equal(CellIdentifierInterface* other) = 0;
|
||||
@@ -504,13 +504,13 @@ class LbmSolverInterface
|
||||
ntlRenderGlobals *mpGlob;
|
||||
|
||||
// list for marked cells
|
||||
std::vector<CellIdentifierInterface *> mMarkedCells;
|
||||
vector<CellIdentifierInterface *> mMarkedCells;
|
||||
int mMarkedCellIndex;
|
||||
};
|
||||
|
||||
|
||||
//! helper function to convert flag to string (for debuggin)
|
||||
std::string convertCellFlagType2String( CellFlagType flag );
|
||||
std::string convertSingleFlag2String(CellFlagType cflag);
|
||||
string convertCellFlagType2String( CellFlagType flag );
|
||||
string convertSingleFlag2String(CellFlagType cflag);
|
||||
|
||||
#endif // LBMINTERFACE_H
|
||||
|
@@ -1,302 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
|
||||
* Copyright 2003,2004 Nils Thuerey
|
||||
*
|
||||
* A simple box object
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include "ntl_geometrybox.h"
|
||||
#include "ntl_ray.h"
|
||||
#include "ntl_scene.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Default Constructor
|
||||
*****************************************************************************/
|
||||
ntlGeometryBox::ntlGeometryBox( void ) :
|
||||
ntlGeometryObject(),
|
||||
mvStart( 0.0 ),
|
||||
mvEnd( 1.0 ),
|
||||
mRefinement(0)
|
||||
{
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Init Constructor
|
||||
*****************************************************************************/
|
||||
/*ntlGeometryBox::ntlGeometryBox( ntlVec3Gfx start, ntlVec3Gfx end ) :
|
||||
ntlGeometryObject(),
|
||||
mvStart( start ),
|
||||
mvEnd( end ),
|
||||
mRefinement(0)
|
||||
{
|
||||
}*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Init refinement attribute */
|
||||
/*****************************************************************************/
|
||||
void ntlGeometryBox::initialize(ntlRenderGlobals *glob) {
|
||||
ntlGeometryObject::initialize(glob);
|
||||
//READATTR(ntlGeometryBox, mRefinement, refine, Int, false);
|
||||
mRefinement = mpAttrs->readInt("refine", mRefinement,"ntlGeometryBox", "mRefinement", false);
|
||||
|
||||
checkBoundingBox(mvStart,mvEnd, "ntlGeometryBox::initialize");
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
*****************************************************************************/
|
||||
void
|
||||
ntlGeometryBox::getTriangles( vector<ntlTriangle> *triangles,
|
||||
vector<ntlVec3Gfx> *vertices,
|
||||
vector<ntlVec3Gfx> *normals, int objectId )
|
||||
{
|
||||
int doBack = 1;
|
||||
int doFront = 1;
|
||||
int doTop = 1;
|
||||
int doBottom = 1;
|
||||
int doLeft = 1;
|
||||
int doRight = 1;
|
||||
|
||||
/*int mRefinement = 0;
|
||||
string refineAttr("refine");
|
||||
if(mpAttrs->exists(refineAttr)) {
|
||||
mRefinement = mpAttrs->find(refineAttr)->getAsInt();
|
||||
//debugOut("GeoBox Ref set to '"<< mpAttrs->find(refineAttr)->getCompleteString() <<"' " , 3);
|
||||
mpAttrs->find(refineAttr)->setUsed(true);
|
||||
}*/
|
||||
|
||||
if(mRefinement==0) {
|
||||
gfxReal s0 = mvStart[0];
|
||||
gfxReal s1 = mvStart[1];
|
||||
gfxReal s2 = mvStart[2];
|
||||
gfxReal e0 = mvEnd[0];
|
||||
gfxReal e1 = mvEnd[1];
|
||||
gfxReal e2 = mvEnd[2];
|
||||
ntlVec3Gfx p1,p2,p3;
|
||||
ntlVec3Gfx n1,n2,n3;
|
||||
|
||||
/* front plane */
|
||||
if(doFront) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, 0.0, -1.0 );
|
||||
p1 = ntlVec3Gfx( s0, s1, s2 );
|
||||
p3 = ntlVec3Gfx( e0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, e1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, s2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* back plane k */
|
||||
if(doBack) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, 0.0, 1.0 );
|
||||
p1 = ntlVec3Gfx( s0, s1, e2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* bottom plane k */
|
||||
if(doBottom) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, -1.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( e0, s1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, s1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, s1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* top plane k */
|
||||
if(doTop) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, 1.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( e0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, e1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, e1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* left plane k */
|
||||
if(doLeft) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( -1.0, 0.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( s0, s1, e2 );
|
||||
p3 = ntlVec3Gfx( s0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, e1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( s0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* right plane k */
|
||||
if(doRight) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 1.0, 0.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( e0, e1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( e0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
} else {
|
||||
// refined box
|
||||
gfxReal S0 = mvStart[0];
|
||||
gfxReal S1 = mvStart[1];
|
||||
gfxReal S2 = mvStart[2];
|
||||
gfxReal v0 = (mvEnd[0]-mvStart[0])/(gfxReal)(mRefinement+1);
|
||||
gfxReal v1 = (mvEnd[1]-mvStart[1])/(gfxReal)(mRefinement+1);
|
||||
gfxReal v2 = (mvEnd[2]-mvStart[2])/(gfxReal)(mRefinement+1);
|
||||
ntlVec3Gfx p1,p2,p3;
|
||||
ntlVec3Gfx n1,n2,n3;
|
||||
|
||||
for(int i=0; i<=mRefinement; i++)
|
||||
for(int j=0; j<=mRefinement; j++) {
|
||||
gfxReal s0 = S0 + i*v0;
|
||||
gfxReal s1 = S1 + j*v1;
|
||||
gfxReal s2 = S2;
|
||||
gfxReal e0 = S0 + (i+1.0)*v0;
|
||||
gfxReal e1 = S1 + (j+1.0)*v1;
|
||||
/* front plane */
|
||||
if(doFront) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, 0.0, -1.0 );
|
||||
p1 = ntlVec3Gfx( s0, s1, s2 );
|
||||
p3 = ntlVec3Gfx( e0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, e1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, s2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
} // i,j
|
||||
for(int i=0; i<=mRefinement; i++)
|
||||
for(int j=0; j<=mRefinement; j++) {
|
||||
gfxReal s0 = S0 + i*v0;
|
||||
gfxReal s1 = S1 + j*v1;
|
||||
gfxReal e0 = S0 + (i+1.0)*v0;
|
||||
gfxReal e1 = S1 + (j+1.0)*v1;
|
||||
gfxReal e2 = S2 + (mRefinement+1.0)*v2;
|
||||
/* back plane k */
|
||||
if(doBack) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, 0.0, 1.0 );
|
||||
p1 = ntlVec3Gfx( s0, s1, e2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<=mRefinement; i++)
|
||||
for(int j=0; j<=mRefinement; j++) {
|
||||
|
||||
gfxReal s0 = S0 + i*v0;
|
||||
gfxReal s1 = S1;
|
||||
gfxReal s2 = S2 + j*v2;
|
||||
gfxReal e0 = S0 + (i+1.0)*v0;
|
||||
gfxReal e2 = S2 + (j+1.0)*v2;
|
||||
/* bottom plane k */
|
||||
if(doBottom) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, -1.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( e0, s1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, s1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, s1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<=mRefinement; i++)
|
||||
for(int j=0; j<=mRefinement; j++) {
|
||||
|
||||
gfxReal s0 = S0 + i*v0;
|
||||
gfxReal s2 = S2 + j*v2;
|
||||
gfxReal e0 = S0 + (i+1.0)*v0;
|
||||
gfxReal e1 = S1 + (mRefinement+1.0)*v1;
|
||||
gfxReal e2 = S2 + (j+1.0)*v2;
|
||||
/* top plane k */
|
||||
if(doTop) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, 1.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( e0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, e1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, e1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<=mRefinement; i++)
|
||||
for(int j=0; j<=mRefinement; j++) {
|
||||
gfxReal s0 = S0;
|
||||
gfxReal s1 = S1 + i*v1;
|
||||
gfxReal s2 = S2 + j*v2;
|
||||
gfxReal e1 = S1 + (i+1.0)*v1;
|
||||
gfxReal e2 = S2 + (j+1.0)*v2;
|
||||
/* left plane k */
|
||||
if(doLeft) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( -1.0, 0.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( s0, s1, e2 );
|
||||
p3 = ntlVec3Gfx( s0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, e1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( s0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<=mRefinement; i++)
|
||||
for(int j=0; j<=mRefinement; j++) {
|
||||
gfxReal s1 = S1 + i*v1;
|
||||
gfxReal s2 = S2 + j*v2;
|
||||
gfxReal e0 = S0 + (mRefinement+1.0)*v0;
|
||||
gfxReal e1 = S1 + (i+1.0)*v1;
|
||||
gfxReal e2 = S2 + (j+1.0)*v2;
|
||||
/* right plane k */
|
||||
if(doRight) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 1.0, 0.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( e0, e1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( e0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
}
|
||||
|
||||
} // do ref
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,63 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
|
||||
* Copyright 2003,2004 Nils Thuerey
|
||||
*
|
||||
* A simple box object
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef NTL_GEOBOX_HH
|
||||
#define NTL_GEOBOX_HH
|
||||
|
||||
#include "ntl_geometryobject.h"
|
||||
|
||||
|
||||
/*! A simple box object generatedd by 12 triangles */
|
||||
class ntlGeometryBox : public ntlGeometryObject
|
||||
{
|
||||
|
||||
public:
|
||||
/* Init constructor */
|
||||
ntlGeometryBox( void );
|
||||
/* Init constructor */
|
||||
//ntlGeometryBox( ntlVec3Gfx start, ntlVec3Gfx end );
|
||||
|
||||
//! Return type id
|
||||
virtual int getTypeId() { return GEOCLASSTID_BOX; }
|
||||
|
||||
virtual void getTriangles( vector<ntlTriangle> *triangles,
|
||||
vector<ntlVec3Gfx> *vertices,
|
||||
vector<ntlVec3Gfx> *normals, int objectId );
|
||||
|
||||
/*! for easy GUI detection get start of axis aligned bounding box, return NULL of no BB */
|
||||
virtual inline ntlVec3Gfx *getBBStart() { return &mvStart; }
|
||||
virtual inline ntlVec3Gfx *getBBEnd() { return &mvEnd; }
|
||||
|
||||
/*! Init refinement attribute */
|
||||
virtual void initialize(ntlRenderGlobals *glob);
|
||||
|
||||
private:
|
||||
|
||||
/*! Start and end points of box */
|
||||
ntlVec3Gfx mvStart, mvEnd;
|
||||
|
||||
/*! refinement factor */
|
||||
int mRefinement;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/* Access methods */
|
||||
/*! Access start vector */
|
||||
inline ntlVec3Gfx getStart( void ){ return mvStart; }
|
||||
inline void setStart( const ntlVec3Gfx &set ){ mvStart = set; }
|
||||
/*! Access end vector */
|
||||
inline ntlVec3Gfx getEnd( void ){ return mvEnd; }
|
||||
inline void setEnd( const ntlVec3Gfx &set ){ mvEnd = set; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@@ -35,14 +35,14 @@ class ntlGeometryShader :
|
||||
virtual int postGeoConstrInit(ntlRenderGlobals *glob) { glob=NULL; /*unused*/ return 0; };
|
||||
|
||||
/*! Get start iterator for all objects */
|
||||
virtual std::vector<ntlGeometryObject *>::iterator getObjectsBegin() { return mObjects.begin(); }
|
||||
virtual vector<ntlGeometryObject *>::iterator getObjectsBegin() { return mObjects.begin(); }
|
||||
/*! Get end iterator for all objects */
|
||||
virtual std::vector<ntlGeometryObject *>::iterator getObjectsEnd() { return mObjects.end(); }
|
||||
virtual vector<ntlGeometryObject *>::iterator getObjectsEnd() { return mObjects.end(); }
|
||||
|
||||
protected:
|
||||
|
||||
//! vector for the objects
|
||||
std::vector<ntlGeometryObject *> mObjects;
|
||||
vector<ntlGeometryObject *> mObjects;
|
||||
|
||||
};
|
||||
|
||||
|
@@ -1,229 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
|
||||
* Copyright 2003,2004 Nils Thuerey
|
||||
*
|
||||
* A simple sphere object
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include "ntl_geometrysphere.h"
|
||||
#include "ntl_ray.h"
|
||||
#include "ntl_scene.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Default Constructor
|
||||
*****************************************************************************/
|
||||
ntlGeometrySphere::ntlGeometrySphere() :
|
||||
ntlGeometryObject(),
|
||||
mvCenter( 0.0 ),
|
||||
mRadius( 1.0 ),
|
||||
mRefPolar(5), mRefAzim(5)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Init attributes */
|
||||
/*****************************************************************************/
|
||||
void ntlGeometrySphere::initialize(ntlRenderGlobals *glob) {
|
||||
ntlGeometryObject::initialize(glob);
|
||||
|
||||
mvCenter = vec2G(mpAttrs->readVec3d("center", vec2D(mvCenter) ,"ntlGeometrySphere", "mvCenter", false));
|
||||
mRadius = mpAttrs->readFloat("radius", mRadius ,"ntlGeometrySphere", "mRadius", false);
|
||||
mRefPolar = mpAttrs->readInt ("refpolar", mRefPolar,"ntlGeometrySphere", "mRefPolar", false);
|
||||
mRefAzim = mpAttrs->readInt ("refazim", mRefAzim ,"ntlGeometrySphere", "mRefAzim", false);
|
||||
if(mRefPolar<1) mRefPolar = 1;
|
||||
if(mRefAzim<1) mRefAzim = 1;
|
||||
mRefAzim *= 4;
|
||||
|
||||
mvBBStart = mvCenter - ntlVec3Gfx(mRadius);
|
||||
mvBBEnd = mvCenter + ntlVec3Gfx(mRadius);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ntlVec3Gfx getSphereCoord(gfxReal radius, gfxReal phi, gfxReal theta) {
|
||||
return ntlVec3Gfx(
|
||||
radius * cos(theta) * sin(phi),
|
||||
radius * sin(theta) * sin(phi),
|
||||
radius * cos(phi)
|
||||
);
|
||||
};
|
||||
|
||||
void
|
||||
ntlGeometrySphere::getTriangles( vector<ntlTriangle> *triangles,
|
||||
vector<ntlVec3Gfx> *vertices,
|
||||
vector<ntlVec3Gfx> *normals, int objectId )
|
||||
{
|
||||
|
||||
gfxReal phiD = 0.5* M_PI/ (gfxReal)mRefPolar;
|
||||
gfxReal thetaD = 2.0* M_PI/ (gfxReal)mRefAzim;
|
||||
gfxReal phi = 0.0;
|
||||
for(int i=0; i<mRefPolar; i++) {
|
||||
gfxReal theta = 0.0;
|
||||
for(int j=0; j<mRefAzim; j++) {
|
||||
ntlVec3Gfx p1,p2,p3;
|
||||
ntlVec3Gfx n1,n2,n3;
|
||||
|
||||
p1 = getSphereCoord(mRadius, phi , theta );
|
||||
p2 = getSphereCoord(mRadius, phi+phiD, theta );
|
||||
p3 = getSphereCoord(mRadius, phi+phiD, theta+thetaD );
|
||||
n1 = getNormalized(p1);
|
||||
n2 = getNormalized(p2);
|
||||
n3 = getNormalized(p3);
|
||||
//n3 = n2 = n1;
|
||||
p1 += mvCenter;
|
||||
p2 += mvCenter;
|
||||
p3 += mvCenter;
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
|
||||
n1[2] *= -1.0;
|
||||
n2[2] *= -1.0;
|
||||
n3[2] *= -1.0;
|
||||
p1[2] -= mvCenter[2];
|
||||
p2[2] -= mvCenter[2];
|
||||
p3[2] -= mvCenter[2];
|
||||
p1[2] *= -1.0;
|
||||
p2[2] *= -1.0;
|
||||
p3[2] *= -1.0;
|
||||
p1[2] += mvCenter[2];
|
||||
p2[2] += mvCenter[2];
|
||||
p3[2] += mvCenter[2];
|
||||
sceneAddTriangle( p1,p3,p2, n1,n3,n2, ntlVec3Gfx(0.0), 1 );
|
||||
|
||||
p1 = getSphereCoord(mRadius, phi , theta );
|
||||
p3 = getSphereCoord(mRadius, phi , theta+thetaD );
|
||||
p2 = getSphereCoord(mRadius, phi+phiD, theta+thetaD );
|
||||
n1 = getNormalized(p1);
|
||||
n2 = getNormalized(p2);
|
||||
n3 = getNormalized(p3);
|
||||
//n3 = n2 = n1;
|
||||
p1 += mvCenter;
|
||||
p2 += mvCenter;
|
||||
p3 += mvCenter;
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
|
||||
n1[2] *= -1.0;
|
||||
n2[2] *= -1.0;
|
||||
n3[2] *= -1.0;
|
||||
p1[2] -= mvCenter[2];
|
||||
p2[2] -= mvCenter[2];
|
||||
p3[2] -= mvCenter[2];
|
||||
p1[2] *= -1.0;
|
||||
p2[2] *= -1.0;
|
||||
p3[2] *= -1.0;
|
||||
p1[2] += mvCenter[2];
|
||||
p2[2] += mvCenter[2];
|
||||
p3[2] += mvCenter[2];
|
||||
sceneAddTriangle( p1,p3,p2, n1,n3,n2, ntlVec3Gfx(0.0), 1 );
|
||||
|
||||
theta += thetaD;
|
||||
}
|
||||
phi += phiD;
|
||||
}
|
||||
|
||||
int doBack = 0;
|
||||
int doFront = 0;
|
||||
int doTop = 0;
|
||||
int doBottom = 0;
|
||||
int doLeft = 0;
|
||||
int doRight = 0;
|
||||
ntlVec3Gfx mvStart = mvBBStart;
|
||||
ntlVec3Gfx mvEnd = mvBBEnd;
|
||||
|
||||
gfxReal s0 = mvStart[0];
|
||||
gfxReal s1 = mvStart[1];
|
||||
gfxReal s2 = mvStart[2];
|
||||
gfxReal e0 = mvEnd[0];
|
||||
gfxReal e1 = mvEnd[1];
|
||||
gfxReal e2 = mvEnd[2];
|
||||
ntlVec3Gfx p1,p2,p3;
|
||||
ntlVec3Gfx n1,n2,n3;
|
||||
|
||||
/* front plane */
|
||||
if(doFront) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, 0.0, -1.0 );
|
||||
p1 = ntlVec3Gfx( s0, s1, s2 );
|
||||
p3 = ntlVec3Gfx( e0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, e1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, s2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* back plane k */
|
||||
if(doBack) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, 0.0, 1.0 );
|
||||
p1 = ntlVec3Gfx( s0, s1, e2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* bottom plane k */
|
||||
if(doBottom) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, -1.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( e0, s1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, s1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, s1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* top plane k */
|
||||
if(doTop) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 0.0, 1.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( e0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, e1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, e1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* left plane k */
|
||||
if(doLeft) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( -1.0, 0.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( s0, s1, e2 );
|
||||
p3 = ntlVec3Gfx( s0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( s0, e1, s2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( s0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( s0, e1, e2 );
|
||||
p2 = ntlVec3Gfx( s0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
/* right plane k */
|
||||
if(doRight) {
|
||||
n1 = n2 = n3 = ntlVec3Gfx( 1.0, 0.0, 0.0 );
|
||||
p1 = ntlVec3Gfx( e0, e1, e2 );
|
||||
p3 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
p1 = ntlVec3Gfx( e0, e1, s2 );
|
||||
p3 = ntlVec3Gfx( e0, s1, s2 );
|
||||
p2 = ntlVec3Gfx( e0, s1, e2 );
|
||||
sceneAddTriangle( p1,p2,p3, n1,n2,n3, ntlVec3Gfx(0.0), 1 );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,65 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
|
||||
* Copyright 2003,2004 Nils Thuerey
|
||||
*
|
||||
* A simple sphere object
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef NTL_GEOSPHERE_H
|
||||
|
||||
#include "ntl_geometryobject.h"
|
||||
|
||||
|
||||
/*! A simple box object generatedd by 12 triangles */
|
||||
class ntlGeometrySphere : public ntlGeometryObject
|
||||
{
|
||||
|
||||
public:
|
||||
/* Init constructor */
|
||||
ntlGeometrySphere( void );
|
||||
|
||||
//! Return type id
|
||||
virtual int getTypeId() { return GEOCLASSTID_SPHERE; }
|
||||
|
||||
virtual void getTriangles( vector<ntlTriangle> *triangles,
|
||||
vector<ntlVec3Gfx> *vertices,
|
||||
vector<ntlVec3Gfx> *normals, int objectId );
|
||||
|
||||
/*! for easy GUI detection get start of axis aligned bounding box, return NULL of no BB */
|
||||
virtual inline ntlVec3Gfx *getBBStart() { return &mvBBStart; }
|
||||
virtual inline ntlVec3Gfx *getBBEnd() { return &mvBBEnd; }
|
||||
|
||||
/*! Init refinement attribute */
|
||||
virtual void initialize(ntlRenderGlobals *glob);
|
||||
|
||||
private:
|
||||
|
||||
/*! Center of the sphere */
|
||||
ntlVec3Gfx mvCenter;
|
||||
|
||||
/*! radius */
|
||||
gfxReal mRadius;
|
||||
|
||||
/*! refinement factor along polar angle */
|
||||
int mRefPolar;
|
||||
/*! refinement factor per segment (azimuthal angle) */
|
||||
int mRefAzim;
|
||||
|
||||
/*! Start and end points of bounding box */
|
||||
ntlVec3Gfx mvBBStart, mvBBEnd;
|
||||
|
||||
public:
|
||||
|
||||
/* Access methods */
|
||||
/*! Access start vector */
|
||||
inline ntlVec3Gfx getCenter( void ){ return mvCenter; }
|
||||
inline void setCenter( const ntlVec3Gfx &set ){ mvCenter = set; }
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#define NTL_GEOSPHERE_H
|
||||
#endif
|
@@ -1,13 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
|
||||
* Copyright 2003,2004 Nils Thuerey
|
||||
*
|
||||
* a templated image class
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#include "ntl_image.h"
|
||||
|
||||
|
||||
|
@@ -1,167 +0,0 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* El'Beem - Free Surface Fluid Simulation with the Lattice Boltzmann Method
|
||||
* Copyright 2003,2004 Nils Thuerey
|
||||
*
|
||||
* a templated image class
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef NTL_IMAGE_HH
|
||||
#define NTL_IMAGE_HH
|
||||
|
||||
#include "ntl_vector3dim.h"
|
||||
#include "utilities.h"
|
||||
|
||||
|
||||
template<class Value>
|
||||
class ntlImage
|
||||
{
|
||||
public:
|
||||
/*! Default constructor */
|
||||
ntlImage();
|
||||
/*! Init constructor */
|
||||
ntlImage(int x,int y, Value def);
|
||||
/*! Destructor, delete contents */
|
||||
~ntlImage();
|
||||
|
||||
/*! Write the image to a ppm file */
|
||||
void writePpm(const char* name);
|
||||
|
||||
/*! normalize values into range 0..1 */
|
||||
void normalize( void );
|
||||
|
||||
/*! Get a pixel from the image */
|
||||
inline Value get(int x, int y) { return mpC[y*mSizex+x]; }
|
||||
|
||||
/*! Set a pixel in the image */
|
||||
inline void set(int x, int y, Value setv) { mpC[y*mSizex+x] = setv; }
|
||||
|
||||
protected:
|
||||
private:
|
||||
|
||||
/*! size in x dimension */
|
||||
int mSizex;
|
||||
|
||||
/*! size in y dimension */
|
||||
int mSizey;
|
||||
|
||||
/*! Image contents */
|
||||
Value *mpC;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/*! Default constructor */
|
||||
template<class Value>
|
||||
ntlImage<Value>::ntlImage()
|
||||
{
|
||||
mSizex = 0;
|
||||
mSizey = 0;
|
||||
mpC = NULL;
|
||||
}
|
||||
|
||||
/*! Init constructor */
|
||||
template<class Value>
|
||||
ntlImage<Value>::ntlImage(int x,int y,Value def)
|
||||
{
|
||||
mSizex = x;
|
||||
mSizey = y;
|
||||
mpC = new Value[x*y];
|
||||
|
||||
for(int i=0;i<(x*y);i++) mpC[i] = def;
|
||||
}
|
||||
|
||||
/*! Destructor, delete contents */
|
||||
template<class Value>
|
||||
ntlImage<Value>::~ntlImage()
|
||||
{
|
||||
if(mpC != NULL) {
|
||||
delete [] mpC;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*! Write the image to a ppm file */
|
||||
template<class Value>
|
||||
void ntlImage<Value>::writePpm(const char* name)
|
||||
{
|
||||
/* write file */
|
||||
/* open output file */
|
||||
FILE *outfile;
|
||||
if ( (outfile = fopen(name,"w")) == NULL ) {
|
||||
errorOut( "ntlImage::writePpm ERROR: Open out file failed "<<name<<"!\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
int maxColVal = 255;
|
||||
|
||||
/* write ppm header */
|
||||
fprintf(outfile,"P3\n%d %d\n%d\n",mSizex,mSizey, maxColVal );
|
||||
|
||||
/* get min max values */
|
||||
Value min = mpC[0];
|
||||
Value max = mpC[0];
|
||||
for(int j=0;j<(mSizey*mSizex);j++) {
|
||||
if(mpC[j]<min) min = mpC[j];
|
||||
if(mpC[j]>max) max = mpC[j];
|
||||
}
|
||||
|
||||
/* check colors for overflow */
|
||||
for(int j=0;j<mSizey;j++) {
|
||||
for(int i=0;i<mSizex;i++) {
|
||||
|
||||
Value grey;
|
||||
if(max-min>0) {
|
||||
grey = 1.0-(mpC[j*mSizex+i]-min)/(max-min);
|
||||
} else { grey = 1.0; }
|
||||
//mpC[j*mSizex+i] /= max;
|
||||
ntlColor col = ntlColor(grey,grey,grey);
|
||||
unsigned int cCol[3];
|
||||
for (unsigned int cc=0; cc<3; cc++) {
|
||||
if(col[cc] <= 0.0)
|
||||
cCol[cc] = 0;
|
||||
else if(col[cc] >= 1.0)
|
||||
cCol[cc] = maxColVal;
|
||||
else
|
||||
cCol[cc] = (unsigned int)(maxColVal * col[cc]);
|
||||
}
|
||||
|
||||
/* write pixel to ppm file */
|
||||
fprintf(outfile,"%4d %4d %4d ",cCol[0],cCol[1],cCol[2]);
|
||||
|
||||
} /* foreach x */
|
||||
|
||||
fprintf(outfile,"\n");
|
||||
} /* foreach y */
|
||||
|
||||
/* clean up */
|
||||
fclose(outfile);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*! Write the image to a ppm file */
|
||||
template<class Value>
|
||||
void ntlImage<Value>::normalize( void )
|
||||
{
|
||||
/* get min max values */
|
||||
Value min = mpC[0];
|
||||
Value max = mpC[0];
|
||||
for(int j=0;j<(mSizey*mSizex);j++) {
|
||||
if(mpC[j]<min) min = mpC[j];
|
||||
if(mpC[j]>max) max = mpC[j];
|
||||
}
|
||||
|
||||
/* check colors for overflow */
|
||||
for(int j=0;j<mSizey;j++) {
|
||||
for(int i=0;i<mSizex;i++) {
|
||||
Value grey = 1.0-(mpC[j*mSizex+i]-min)/(max-min);
|
||||
mpC[j*mSizex+i] = grey;
|
||||
} /* foreach x */
|
||||
} /* foreach y */
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -12,7 +12,6 @@
|
||||
|
||||
#include "ntl_vector3dim.h"
|
||||
#include "ntl_material.h"
|
||||
#include "ntl_image.h"
|
||||
class ntlRay;
|
||||
class ntlRenderGlobals;
|
||||
class ntlGeometryObject;
|
||||
@@ -66,10 +65,6 @@ public:
|
||||
/*! Access the omni light position */
|
||||
void setPosition(ntlVec3Gfx set) { mvPosition = set; }
|
||||
ntlVec3Gfx getPosition() const { return mvPosition; }
|
||||
/*! Init the shadow map */
|
||||
void setShadowMap(int setx, int sety, int sampling) { mUseShadowMap = true; mSMSizeX = setx; mSMSizeY = sety; mSMSampling = sampling; }
|
||||
/*! Init the caustics map */
|
||||
void setCausticsMap(int setx, int sety ) { mUseCausticsMap = true; mCMSizeX = setx; mCMSizeY = sety; }
|
||||
|
||||
|
||||
protected:
|
||||
@@ -88,30 +83,6 @@ protected:
|
||||
/*! light position */
|
||||
ntlVec3Gfx mvPosition;
|
||||
|
||||
/*! shadow map active? */
|
||||
int mUseShadowMap;
|
||||
|
||||
/*! shadow map size */
|
||||
int mSMSizeX;
|
||||
int mSMSizeY;
|
||||
|
||||
/*! Sampling value for shadow map filtering */
|
||||
int mSMSampling;
|
||||
|
||||
/*! Images for shadow map */
|
||||
ntlImage<gfxReal> *mpShadowMap[6];
|
||||
|
||||
|
||||
/*! caustics map active? */
|
||||
int mUseCausticsMap;
|
||||
|
||||
/*! caustics map size */
|
||||
int mCMSizeX;
|
||||
int mCMSizeY;
|
||||
|
||||
/*! Images for caustics map */
|
||||
ntlImage<char> *mpCausticsMap[6];
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
@@ -116,6 +116,7 @@ ntlRay::~ntlRay()
|
||||
#define MIDDLE 2
|
||||
|
||||
//! intersect ray with AABB
|
||||
#ifndef ELBEEM_BLENDER
|
||||
void ntlRay::intersectFrontAABB(ntlVec3Gfx mStart, ntlVec3Gfx mEnd, gfxReal &t, ntlVec3Gfx &retnormal,ntlVec3Gfx &retcoord) const
|
||||
{
|
||||
char inside = true; /* inside box? */
|
||||
@@ -203,8 +204,6 @@ void ntlRay::intersectFrontAABB(ntlVec3Gfx mStart, ntlVec3Gfx mEnd, gfxReal &t,
|
||||
retcoord = coord;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//! intersect ray with AABB
|
||||
void ntlRay::intersectBackAABB(ntlVec3Gfx mStart, ntlVec3Gfx mEnd, gfxReal &t, ntlVec3Gfx &retnormal,ntlVec3Gfx &retcoord) const
|
||||
{
|
||||
@@ -289,10 +288,7 @@ void ntlRay::intersectBackAABB(ntlVec3Gfx mStart, ntlVec3Gfx mEnd, gfxReal &t, n
|
||||
retnormal = normal;
|
||||
retcoord = coord;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // ELBEEM_BLENDER
|
||||
|
||||
//! intersect ray with AABB
|
||||
void ntlRay::intersectCompleteAABB(ntlVec3Gfx mStart, ntlVec3Gfx mEnd, gfxReal &tmin, gfxReal &tmax) const
|
||||
@@ -445,6 +441,7 @@ void ntlRay::intersectCompleteAABB(ntlVec3Gfx mStart, ntlVec3Gfx mEnd, gfxReal &
|
||||
*****************************************************************************/
|
||||
const ntlColor ntlRay::shade() //const
|
||||
{
|
||||
#ifndef ELBEEM_BLENDER
|
||||
ntlGeometryObject *closest = NULL;
|
||||
gfxReal minT = GFX_REAL_MAX;
|
||||
vector<ntlLightObject*> *lightlist = mpGlob->getLightList();
|
||||
@@ -457,7 +454,6 @@ const ntlColor ntlRay::shade() //const
|
||||
//return ntlColor(0.0);
|
||||
}
|
||||
|
||||
|
||||
/* find closes object that intersects */
|
||||
ntlTriangle *tri = NULL;
|
||||
ntlVec3Gfx normal;
|
||||
@@ -468,8 +464,6 @@ const ntlColor ntlRay::shade() //const
|
||||
|
||||
/* object hit... */
|
||||
if (closest != NULL) {
|
||||
//return( ntlColor(1.0) );
|
||||
//normal = tri->getNormal(); // no normal smoothing
|
||||
|
||||
ntlVec3Gfx triangleNormal = tri->getNormal();
|
||||
if( equal(triangleNormal, ntlVec3Gfx(0.0)) ) errorOut("ntlRaytracer warning: trinagle normal= 0 "); // DEBUG
|
||||
@@ -485,11 +479,11 @@ const ntlColor ntlRay::shade() //const
|
||||
/* ... -> do reflection */
|
||||
ntlVec3Gfx intersectionPosition(mOrigin + (mDirection * (minT)) );
|
||||
ntlMaterial *clossurf = closest->getMaterial();
|
||||
if(mpGlob->getDebugOut() > 5) {
|
||||
/*if(mpGlob->getDebugOut() > 5) {
|
||||
errorOut("Ray hit: at "<<intersectionPosition<<" n:"<<normal<<" dn:"<<valDN<<" ins:"<<intersectionInside<<" cl:"<<((unsigned int)closest) );
|
||||
errorOut(" t1:"<<mpGlob->getScene()->getVertex(tri->getPoints()[0])<<" t2:"<<mpGlob->getScene()->getVertex(tri->getPoints()[1])<<" t3:"<<mpGlob->getScene()->getVertex(tri->getPoints()[2]) );
|
||||
errorOut(" trin:"<<tri->getNormal() );
|
||||
}
|
||||
} // debug */
|
||||
|
||||
/* current transparence and reflectivity */
|
||||
gfxReal currTrans = clossurf->getTransparence();
|
||||
@@ -635,12 +629,10 @@ const ntlColor ntlRay::shade() //const
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* add highlights (should not be affected by transparence as the diffuse reflections */
|
||||
currentColor += highlightColor;
|
||||
|
||||
/* attentuate as a last step*/
|
||||
//if(currTrans > RAY_THRESHOLD) {
|
||||
/* check if we're on the inside or outside */
|
||||
if(intersectionInside) {
|
||||
gfxReal kr,kg,kb; /* attentuation */
|
||||
@@ -657,6 +649,7 @@ const ntlColor ntlRay::shade() //const
|
||||
return ntlColor(currentColor);
|
||||
}
|
||||
|
||||
#endif // ELBEEM_BLENDER
|
||||
/* no object hit -> ray goes to infinity */
|
||||
return mpGlob->getBackgroundCol();
|
||||
}
|
||||
|
@@ -25,11 +25,8 @@
|
||||
|
||||
|
||||
/* external parser functions from cfgparser.cxx */
|
||||
//#include "cfgparse_functions.h"
|
||||
|
||||
/* parse given file as config file */
|
||||
void parseFile(string filename);
|
||||
|
||||
/* set pointers for parsing */
|
||||
void setPointers( ntlRenderGlobals *setglob);
|
||||
|
||||
@@ -237,23 +234,14 @@ int ntlRaytracer::renderVisualization( bool multiThreaded )
|
||||
warnMsg("ntlRaytracer::advanceSims","World state error... stopping" );
|
||||
setStopRenderVisualization( true );
|
||||
}
|
||||
//? mSimulationTime = (*mpSims)[mFirstSim]->getCurrentTime();
|
||||
//debMsgStd("ntlRaytracer::renderVisualization : single step mode ", 10);
|
||||
//debMsgStd("", 10 );
|
||||
}
|
||||
|
||||
#ifndef NOGUI
|
||||
// save frame
|
||||
if(mpOpenGLRenderer) mpOpenGLRenderer->saveAnimationFrame( mSimulationTime );
|
||||
#endif // NOGUI
|
||||
|
||||
// for non-threaded check events
|
||||
if(!multiThreaded) {
|
||||
//if(gpElbeemFrame->ElbeemWindow->visible()) {
|
||||
//if (!Fl::check()) break; // returns immediately
|
||||
//}
|
||||
Fl::check();
|
||||
//gpElbeemFrame->SceneDisplay->doIdleRedraw();
|
||||
gpElbeemFrame->SceneDisplay->doOnlyForcedRedraw();
|
||||
}
|
||||
|
||||
@@ -277,12 +265,11 @@ int ntlRaytracer::singleStepVisualization( void )
|
||||
if(mpOpenGLRenderer) mpOpenGLRenderer->saveAnimationFrame( mSimulationTime );
|
||||
Fl::check();
|
||||
gpElbeemFrame->SceneDisplay->doOnlyForcedRedraw();
|
||||
#endif // NOGUI
|
||||
|
||||
mThreadRunning = false;
|
||||
#ifndef NOGUI
|
||||
stopSimulationRestoreGui();
|
||||
#endif
|
||||
#else
|
||||
mThreadRunning = false;
|
||||
#endif // NOGUI
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -294,8 +281,6 @@ int ntlRaytracer::singleStepVisualization( void )
|
||||
*****************************************************************************/
|
||||
int ntlRaytracer::advanceSims()
|
||||
{
|
||||
//gfxReal currTime[ mpSims->size() ];
|
||||
|
||||
bool done = false;
|
||||
bool allPanic = true;
|
||||
double targetTime = mSimulationTime + (*mpSims)[mFirstSim]->getFrameTime();
|
||||
@@ -313,7 +298,6 @@ int ntlRaytracer::advanceSims()
|
||||
if((*mpSims)[i]->getPanic()) allPanic = true; // do any panic now!?
|
||||
//debMsgStd("ntlRaytracer::advanceSims",DM_MSG, " sim "<<i<<" c"<<(*mpSims)[i]->getCurrentTime()<<" p"<<(*mpSims)[i]->getPanic()<<" t"<<targetTime, 10); // debug // timedebug
|
||||
}
|
||||
//if((*mpSims)[mFirstSim]->getCurrentTime() < targetTime) done = false;
|
||||
if( (targetTime - (*mpSims)[mFirstSim]->getCurrentTime()) > LBM_TIME_EPSILON) done=false;
|
||||
if(allPanic) done = true;
|
||||
}
|
||||
@@ -371,6 +355,7 @@ void ntlRaytracer::singleStepSims(double targetTime) {
|
||||
*****************************************************************************/
|
||||
int ntlRaytracer::renderScene( void )
|
||||
{
|
||||
#ifndef ELBEEM_BLENDER
|
||||
char nrStr[5]; /* nr conversion */
|
||||
//std::ostringstream outfilename(""); /* ppm file */
|
||||
std::ostringstream outfn_conv(""); /* converted ppm with other suffix */
|
||||
@@ -723,6 +708,7 @@ int ntlRaytracer::renderScene( void )
|
||||
debMsgStd("ntlRaytracer::renderScene",DM_NOTIFY, "Single frame mode done...", 1 );
|
||||
return 1;
|
||||
}
|
||||
#endif // ELBEEM_BLENDER
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -11,10 +11,6 @@
|
||||
#include "ntl_scene.h"
|
||||
#include "ntl_geometryobject.h"
|
||||
#include "ntl_geometryshader.h"
|
||||
//#include <sys/times.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
|
@@ -19,13 +19,23 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
using std::map;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// hack for crappy MSVC6.0 compiler
|
||||
#ifdef _MSC_VER
|
||||
#define for if(false); else for
|
||||
#define map std::map
|
||||
#define vector std::vector
|
||||
#define string std::string
|
||||
#else // MSVC6
|
||||
// for proper compilers...
|
||||
using std::map;
|
||||
using std::vector;
|
||||
using std::string;
|
||||
#endif // MSVC6
|
||||
|
||||
#ifdef __APPLE_CC__
|
||||
// apple
|
||||
#else
|
||||
|
@@ -72,7 +72,7 @@ int convertString2Int(const char *str, int alt)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//! helper function that converts a flag field to a readable integer
|
||||
std::string convertFlags2String(int flags) {
|
||||
string convertFlags2String(int flags) {
|
||||
std::ostringstream ret;
|
||||
ret <<"(";
|
||||
int max = sizeof(int)*8;
|
||||
@@ -154,33 +154,18 @@ myTime_t getTime()
|
||||
QueryPerformanceCounter(&liLastTime);
|
||||
ret = (INT)( ((double)liLastTime.QuadPart / liTimerFrequency.QuadPart)*1000 ); // - mFirstTime;
|
||||
#else
|
||||
//fprintf(stderr, " Tp s%lu us%lu \n", tv.tv_sec, tv.tv_usec );
|
||||
//clock_t ct = clock();
|
||||
//ret = ct*1000/CLOCKS_PER_SEC;
|
||||
//fprintf(stderr, " Tp s%lu cps%lu us%lu \n", ct,CLOCKS_PER_SEC, ret );
|
||||
|
||||
/*struct tms tt;
|
||||
times(&tt);
|
||||
//ret = tt.tms_utime/(CLOCKS_PER_SEC/1000);
|
||||
ret = tt.tms_utime*10;
|
||||
//fprintf(stderr, " Tp s%lu cps%lu us%lu %d %d \n", tt.tms_cutime,CLOCKS_PER_SEC, ret, sizeof(clock_t), tt.tms_cutime );
|
||||
//fprintf(stderr, " Tp s%d cps%d us%d %d %d \n", tt.tms_utime,CLOCKS_PER_SEC, ret, sizeof(clock_t), clock() );
|
||||
// */
|
||||
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
tz.tz_minuteswest = 0;
|
||||
tz.tz_dsttime = 0;
|
||||
gettimeofday(&tv,&tz);
|
||||
ret = (tv.tv_sec*1000)+(tv.tv_usec/1000); //-mFirstTime;
|
||||
//fprintf(stderr, " Tp s%lu us%lu \n", tv.tv_sec, tv.tv_usec );
|
||||
#endif
|
||||
//cout << " Tret " << ret <<endl;
|
||||
return (myTime_t)ret;
|
||||
}
|
||||
//-----------------------------------------------------------------------------
|
||||
// convert time to readable string
|
||||
std::string getTimeString(myTime_t usecs) {
|
||||
string getTimeString(myTime_t usecs) {
|
||||
std::ostringstream ret;
|
||||
//myTime_t us = usecs % 1000;
|
||||
myTime_t ms = usecs / (60*1000);
|
||||
@@ -198,7 +183,7 @@ std::string getTimeString(myTime_t usecs) {
|
||||
}
|
||||
|
||||
//! helper to check if a bounding box was specified in the right way
|
||||
bool checkBoundingBox(ntlVec3Gfx s, ntlVec3Gfx e, std::string checker) {
|
||||
bool checkBoundingBox(ntlVec3Gfx s, ntlVec3Gfx e, string checker) {
|
||||
if( (s[0]>e[0]) ||
|
||||
(s[1]>e[1]) ||
|
||||
(s[2]>e[2]) ) {
|
||||
@@ -213,22 +198,22 @@ bool checkBoundingBox(ntlVec3Gfx s, ntlVec3Gfx e, std::string checker) {
|
||||
//-----------------------------------------------------------------------------
|
||||
// debug message output
|
||||
|
||||
static std::string col_black ( "\033[0;30m");
|
||||
static std::string col_dark_gray ( "\033[1;30m");
|
||||
static std::string col_bright_gray ( "\033[0;37m");
|
||||
static std::string col_red ( "\033[0;31m");
|
||||
static std::string col_bright_red ( "\033[1;31m");
|
||||
static std::string col_green ( "\033[0;32m");
|
||||
static std::string col_bright_green ( "\033[1;32m");
|
||||
static std::string col_bright_yellow ( "\033[1;33m");
|
||||
static std::string col_yellow ( "\033[0;33m");
|
||||
static std::string col_cyan ( "\033[0;36m");
|
||||
static std::string col_bright_cyan ( "\033[1;36m");
|
||||
static std::string col_purple ( "\033[0;35m");
|
||||
static std::string col_bright_purple ( "\033[1;35m");
|
||||
static std::string col_neutral ( "\033[0m");
|
||||
static std::string col_std = col_bright_gray;
|
||||
void messageOutputFunc(std::string from, int id, std::string msg, myTime_t interval) {
|
||||
static string col_black ( "\033[0;30m");
|
||||
static string col_dark_gray ( "\033[1;30m");
|
||||
static string col_bright_gray ( "\033[0;37m");
|
||||
static string col_red ( "\033[0;31m");
|
||||
static string col_bright_red ( "\033[1;31m");
|
||||
static string col_green ( "\033[0;32m");
|
||||
static string col_bright_green ( "\033[1;32m");
|
||||
static string col_bright_yellow ( "\033[1;33m");
|
||||
static string col_yellow ( "\033[0;33m");
|
||||
static string col_cyan ( "\033[0;36m");
|
||||
static string col_bright_cyan ( "\033[1;36m");
|
||||
static string col_purple ( "\033[0;35m");
|
||||
static string col_bright_purple ( "\033[1;35m");
|
||||
static string col_neutral ( "\033[0m");
|
||||
static string col_std = col_bright_gray;
|
||||
void messageOutputFunc(string from, int id, string msg, myTime_t interval) {
|
||||
if(interval>0) {
|
||||
myTime_t currTime = getTime();
|
||||
if((currTime - globalIntervalTime)>interval) {
|
||||
@@ -276,7 +261,6 @@ void messageOutputFunc(std::string from, int id, std::string msg, myTime_t inter
|
||||
default:
|
||||
// this shouldnt happen...
|
||||
sout << col_red << " --- messageOutputFunc error: invalid id ("<<id<<") --- aborting... \n\n" << col_std;
|
||||
//xit(1); // unecessary?
|
||||
break;
|
||||
}
|
||||
sout <<" "<< msg << col_std;
|
||||
@@ -289,30 +273,38 @@ void messageOutputFunc(std::string from, int id, std::string msg, myTime_t inter
|
||||
sout << "\n"; // add newline for output
|
||||
}
|
||||
|
||||
#ifdef ELBEEM_BLENDER
|
||||
fprintf(GEN_userstream, "%s",sout.str().c_str() );
|
||||
if(id!=DM_DIRECT) fflush(GEN_userstream);
|
||||
#else
|
||||
//#ifdef ELBEEM_BLENDER
|
||||
#ifdef WIN32
|
||||
// debug level is >0 anyway, so write to file...
|
||||
// TODO generate some reasonable path?
|
||||
FILE *logf = fopen("elbeem_debug_log.txt","a+");
|
||||
// dont complain anymore here...
|
||||
if(logf) {
|
||||
fprintf(logf, "%s",sout.str().c_str() );
|
||||
fclose(logf);
|
||||
}
|
||||
#else // WIN32
|
||||
fprintf(stdout, "%s",sout.str().c_str() );
|
||||
if(id!=DM_DIRECT) fflush(stdout);
|
||||
#endif
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
bool debugOutInterTest(myTime_t interval) {
|
||||
myTime_t currTime = getTime();
|
||||
if((currTime - globalIntervalTime)>interval) {
|
||||
globalIntervalTime = getTime();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// helper functions from external program using elbeem lib (e.g. Blender)
|
||||
/* elbeem debug output function */
|
||||
extern "C"
|
||||
void elbeemDebugOut(char *msg) {
|
||||
// external messages default to debug level 5...
|
||||
if(gDebugLevel<5) return;
|
||||
// delegate to messageOutputFunc
|
||||
messageOutputFunc("[External]",DM_MSG,msg,0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// save exit function
|
||||
|
||||
/* set elbeem debug output level (0=off to 10=full on) */
|
||||
extern "C"
|
||||
void elbeemSetDebugLevel(int level) {
|
||||
if(level<0) level=0;
|
||||
if(level>10) level=10;
|
||||
gDebugLevel=level;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -12,24 +12,18 @@
|
||||
typedef unsigned long myTime_t;
|
||||
|
||||
//! helper function that converts a string to integer
|
||||
int convertString2Int(const char *string, int alt);
|
||||
int convertString2Int(const char *str, int alt);
|
||||
|
||||
//! helper function that converts a flag field to a readable integer
|
||||
std::string convertFlags2String(int flags);
|
||||
|
||||
// output streams
|
||||
#ifdef ELBEEM_BLENDER
|
||||
extern "C" FILE* GEN_errorstream;
|
||||
extern "C" FILE* GEN_userstream;
|
||||
#endif // ELBEEM_BLENDER
|
||||
string convertFlags2String(int flags);
|
||||
|
||||
//! get the current system time
|
||||
myTime_t getTime();
|
||||
//! convert time to readable string
|
||||
std::string getTimeString(myTime_t usecs);
|
||||
string getTimeString(myTime_t usecs);
|
||||
|
||||
//! helper to check if a bounding box was specified in the right way
|
||||
bool checkBoundingBox(ntlVec3Gfx s, ntlVec3Gfx e, std::string checker);
|
||||
bool checkBoundingBox(ntlVec3Gfx s, ntlVec3Gfx e, string checker);
|
||||
|
||||
|
||||
/* debugging outputs , debug level 0 (off) to 10 (max) */
|
||||
@@ -66,7 +60,7 @@ extern "C" char gWorldStringState[256];
|
||||
#define DM_ERROR 5
|
||||
#define DM_DIRECT 6
|
||||
#define DM_FATAL 7
|
||||
void messageOutputFunc(std::string from, int id, std::string msg, myTime_t interval);
|
||||
void messageOutputFunc(string from, int id, string msg, myTime_t interval);
|
||||
|
||||
/* debugging messages defines */
|
||||
#ifdef DEBUG
|
||||
|
@@ -1988,7 +1988,6 @@ static void fluidsimDM_release(DerivedMesh *dm)
|
||||
}
|
||||
|
||||
DerivedMesh *getFluidsimDerivedMesh(Object *srcob, int useRenderParams, float *extverts, float *nors) {
|
||||
//fprintf(stderr,"getFluidsimDerivedMesh call (obid '%s', rp %d)\n", srcob->id.name, useRenderParams); // debug
|
||||
int i;
|
||||
Mesh *mesh = NULL; // srcob->ata;
|
||||
FluidsimDerivedMesh *fsdm;
|
||||
@@ -1998,6 +1997,8 @@ DerivedMesh *getFluidsimDerivedMesh(Object *srcob, int useRenderParams, float *e
|
||||
int curFrame = G.scene->r.cfra - 1; /* start with 0 */
|
||||
char filename[FILE_MAXFILE],filepath[FILE_MAXFILE+FILE_MAXDIR];
|
||||
char curWd[FILE_MAXDIR];
|
||||
char debugStrBuffer[256];
|
||||
//snprintf(debugStrBuffer,256,"getFluidsimDerivedMesh call (obid '%s', rp %d)\n", srcob->id.name, useRenderParams); // debug
|
||||
|
||||
if(!useRenderParams) {
|
||||
displaymode = srcob->fluidsimSettings->guiDisplayMode;
|
||||
@@ -2005,7 +2006,9 @@ DerivedMesh *getFluidsimDerivedMesh(Object *srcob, int useRenderParams, float *e
|
||||
displaymode = srcob->fluidsimSettings->renderDisplayMode;
|
||||
}
|
||||
|
||||
//fprintf(stderr,"getFluidsimDerivedMesh call (obid '%s', rp %d, dm %d)\n", srcob->id.name, useRenderParams, displaymode); // debug
|
||||
snprintf(debugStrBuffer,256,"getFluidsimDerivedMesh call (obid '%s', rp %d, dm %d)\n", srcob->id.name, useRenderParams, displaymode); // debug
|
||||
elbeemDebugOut(debugStrBuffer); // debug
|
||||
|
||||
if((displaymode==1) || (G.obedit==srcob)) {
|
||||
mesh = srcob->data;
|
||||
return getMeshDerivedMesh(mesh , srcob, NULL);
|
||||
@@ -2022,7 +2025,7 @@ DerivedMesh *getFluidsimDerivedMesh(Object *srcob, int useRenderParams, float *e
|
||||
BLI_getwdN(curWd);
|
||||
BLI_make_file_string(G.sce, filepath, srcob->fluidsimSettings->surfdataDir, filename);
|
||||
|
||||
//fprintf(stderr,"getFluidsimDerivedMesh call (obid '%s', rp %d, dm %d) %s \n", srcob->id.name, useRenderParams, displaymode, filepath); // debug
|
||||
//snprintf(debugStrBuffer,256,"getFluidsimDerivedMesh call (obid '%s', rp %d, dm %d) %s \n", srcob->id.name, useRenderParams, displaymode, filepath); // debug
|
||||
mesh = readBobjgz(filepath, (Mesh*)(srcob->data) );
|
||||
if(!mesh) {
|
||||
// display org. object upon failure
|
||||
@@ -2035,7 +2038,7 @@ DerivedMesh *getFluidsimDerivedMesh(Object *srcob, int useRenderParams, float *e
|
||||
// force all edge draw
|
||||
for(i=0;i<mesh->totedge;i++) {
|
||||
//mesh->medge[i].flag = ME_EDGEDRAW;
|
||||
//fprintf(stderr,"me %d = %d\n",i,mesh->medge[i].flag);
|
||||
//snprintf(debugStrBuffer,256,"me %d = %d\n",i,mesh->medge[i].flag);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2087,7 +2090,8 @@ DerivedMesh *getFluidsimDerivedMesh(Object *srcob, int useRenderParams, float *e
|
||||
|
||||
void writeBobjgz(char *filename, struct Object *ob)
|
||||
{
|
||||
const int debugBobjWrite = 0;
|
||||
// const int debugBobjWrite = 0; // now handled by global debug level
|
||||
char debugStrBuffer[256];
|
||||
int wri,i,j;
|
||||
float wrf;
|
||||
gzFile gzf;
|
||||
@@ -2098,17 +2102,20 @@ void writeBobjgz(char *filename, struct Object *ob)
|
||||
MFace *mface = NULL;
|
||||
|
||||
if(!ob->data || (ob->type!=OB_MESH)) {
|
||||
fprintf(stderr,"Writing GZ_BOBJ Invalid object %s ...\n", ob->id.name);
|
||||
snprintf(debugStrBuffer,256,"Writing GZ_BOBJ Invalid object %s ...\n", ob->id.name);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
return;
|
||||
}
|
||||
if((ob->size[0]<0.0) || (ob->size[0]<0.0) || (ob->size[0]<0.0) ) {
|
||||
fprintf(stderr,"\nfluidSim::writeBobjgz:: Warning object %s has negative scaling - check triangle ordering...?\n\n", ob->id.name);
|
||||
snprintf(debugStrBuffer,256,"\nfluidSim::writeBobjgz:: Warning object %s has negative scaling - check triangle ordering...?\n\n", ob->id.name);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
}
|
||||
|
||||
if(debugBobjWrite) fprintf(stderr,"Writing GZ_BOBJ '%s' ... ",filename);
|
||||
snprintf(debugStrBuffer,256,"Writing GZ_BOBJ '%s' ... ",filename); elbeemDebugOut(debugStrBuffer);
|
||||
gzf = gzopen(filename, "wb9");
|
||||
if (!gzf) {
|
||||
fprintf(stderr,"writeBobjgz::error - Unable to open file for writing '%s'\n", filename);
|
||||
snprintf(debugStrBuffer,256,"writeBobjgz::error - Unable to open file for writing '%s'\n", filename);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2116,7 +2123,7 @@ void writeBobjgz(char *filename, struct Object *ob)
|
||||
dlm = dm->convertToDispListMesh(dm, 1);
|
||||
mface = dlm->mface;
|
||||
|
||||
if(sizeof(wri)!=4) { fprintf(stderr,"Writing GZ_BOBJ, Invalid int size %d...\n", wri); return; } // paranoia check
|
||||
if(sizeof(wri)!=4) { snprintf(debugStrBuffer,256,"Writing GZ_BOBJ, Invalid int size %d...\n", wri); elbeemDebugOut(debugStrBuffer); return; } // paranoia check
|
||||
wri = dlm->totvert;
|
||||
gzwrite(gzf, &wri, sizeof(wri));
|
||||
for(i=0; i<wri;i++) {
|
||||
@@ -2158,7 +2165,7 @@ void writeBobjgz(char *filename, struct Object *ob)
|
||||
face[1] = mface[i].v2;
|
||||
face[2] = mface[i].v3;
|
||||
face[3] = mface[i].v4;
|
||||
//fprintf(stderr,"F %s %d = %d,%d,%d,%d \n",ob->id.name, i, face[0],face[1],face[2],face[3] );
|
||||
//snprintf(debugStrBuffer,256,"F %s %d = %d,%d,%d,%d \n",ob->id.name, i, face[0],face[1],face[2],face[3] ); elbeemDebugOut(debugStrBuffer);
|
||||
|
||||
gzwrite(gzf, &(face[0]), sizeof( face[0] ));
|
||||
gzwrite(gzf, &(face[1]), sizeof( face[1] ));
|
||||
@@ -2174,13 +2181,15 @@ void writeBobjgz(char *filename, struct Object *ob)
|
||||
if(dlm) displistmesh_free(dlm);
|
||||
dm->release(dm);
|
||||
|
||||
if(debugBobjWrite) fprintf(stderr,"done. #Vertices: %d, #Triangles: %d\n", dlm->totvert, dlm->totface );
|
||||
snprintf(debugStrBuffer,256,"done. #Vertices: %d, #Triangles: %d\n", dlm->totvert, dlm->totface );
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
}
|
||||
|
||||
/* read .bobj.gz file into a fluidsimDerivedMesh struct */
|
||||
Mesh* readBobjgz(char *filename, Mesh *orgmesh) //, fluidsimDerivedMesh *fsdm)
|
||||
{
|
||||
int wri,i,j;
|
||||
char debugStrBuffer[256];
|
||||
float wrf;
|
||||
Mesh *newmesh;
|
||||
const int debugBobjRead = 0;
|
||||
@@ -2217,29 +2226,29 @@ Mesh* readBobjgz(char *filename, Mesh *orgmesh) //, fluidsimDerivedMesh *fsdm)
|
||||
newmesh->medge = NULL;
|
||||
|
||||
|
||||
if(debugBobjRead) fprintf(stderr,"Reading '%s' GZ_BOBJ... ",filename);
|
||||
snprintf(debugStrBuffer,256,"Reading '%s' GZ_BOBJ... ",filename); elbeemDebugOut(debugStrBuffer);
|
||||
gzf = gzopen(filename, "rb");
|
||||
// gzf = fopen(filename, "rb");
|
||||
// debug: fread(b,c,1,a) = gzread(a,b,c)
|
||||
if (!gzf) {
|
||||
//fprintf(stderr,"readBobjgz::error - Unable to open file for reading '%s'\n", filename); // DEBUG
|
||||
//snprintf(debugStrBuffer,256,"readBobjgz::error - Unable to open file for reading '%s'\n", filename); // DEBUG
|
||||
MEM_freeN(newmesh);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//if(sizeof(wri)!=4) { fprintf(stderr,"Reading GZ_BOBJ, Invalid int size %d...\n", wri); return NULL; } // paranoia check
|
||||
//if(sizeof(wri)!=4) { snprintf(debugStrBuffer,256,"Reading GZ_BOBJ, Invalid int size %d...\n", wri); return NULL; } // paranoia check
|
||||
gotBytes = gzread(gzf, &wri, sizeof(wri));
|
||||
newmesh->totvert = wri;
|
||||
newmesh->mvert = MEM_callocN(sizeof(MVert)*newmesh->totvert, "fluidsimDerivedMesh_bobjvertices");
|
||||
if(debugBobjRead) fprintf(stderr,"#vertices %d ", newmesh->totvert); //DEBUG
|
||||
if(debugBobjRead){ snprintf(debugStrBuffer,256,"#vertices %d ", newmesh->totvert); elbeemDebugOut(debugStrBuffer); } //DEBUG
|
||||
for(i=0; i<newmesh->totvert;i++) {
|
||||
//if(debugBobjRead) fprintf(stderr,"V %d = ",i);
|
||||
//if(debugBobjRead) snprintf(debugStrBuffer,256,"V %d = ",i);
|
||||
for(j=0; j<3; j++) {
|
||||
gotBytes = gzread(gzf, &wrf, sizeof( wrf ));
|
||||
newmesh->mvert[i].co[j] = wrf;
|
||||
//if(debugBobjRead) fprintf(stderr,"%25.20f ", wrf);
|
||||
//if(debugBobjRead) snprintf(debugStrBuffer,256,"%25.20f ", wrf);
|
||||
}
|
||||
//if(debugBobjRead) fprintf(stderr,"\n");
|
||||
//if(debugBobjRead) snprintf(debugStrBuffer,256,"\n");
|
||||
}
|
||||
|
||||
// should be the same as Vertices.size
|
||||
@@ -2248,7 +2257,7 @@ Mesh* readBobjgz(char *filename, Mesh *orgmesh) //, fluidsimDerivedMesh *fsdm)
|
||||
// complain #vertices has to be equal to #normals, reset&abort
|
||||
MEM_freeN(newmesh->mvert);
|
||||
MEM_freeN(newmesh);
|
||||
fprintf(stderr,"Reading GZ_BOBJ, #normals=%d, #vertices=%d, aborting...\n", wri,newmesh->totvert );
|
||||
snprintf(debugStrBuffer,256,"Reading GZ_BOBJ, #normals=%d, #vertices=%d, aborting...\n", wri,newmesh->totvert );
|
||||
return NULL;
|
||||
}
|
||||
for(i=0; i<newmesh->totvert;i++) {
|
||||
@@ -2263,7 +2272,7 @@ Mesh* readBobjgz(char *filename, Mesh *orgmesh) //, fluidsimDerivedMesh *fsdm)
|
||||
gotBytes = gzread(gzf, &wri, sizeof(wri));
|
||||
newmesh->totface = wri;
|
||||
newmesh->mface = MEM_callocN(sizeof(MFace)*newmesh->totface, "fluidsimDerivedMesh_bobjfaces");
|
||||
if(debugBobjRead) fprintf(stderr,"#faces %d ", newmesh->totface); // DEBUG
|
||||
if(debugBobjRead){ snprintf(debugStrBuffer,256,"#faces %d ", newmesh->totface); elbeemDebugOut(debugStrBuffer); } //DEBUG
|
||||
fsface = newmesh->mface;
|
||||
for(i=0; i<newmesh->totface; i++) {
|
||||
int face[4];
|
||||
@@ -2280,8 +2289,8 @@ Mesh* readBobjgz(char *filename, Mesh *orgmesh) //, fluidsimDerivedMesh *fsdm)
|
||||
}
|
||||
|
||||
/*if(debugBobjRead) {
|
||||
for(i=0; i<newmesh->totvert; i++) { fprintf(stderr,"V %d = %f,%f,%f \n",i, newmesh->mvert[i].co[0],newmesh->mvert[i].co[1],newmesh->mvert[i].co[2] ); }
|
||||
for(i=0; i<newmesh->totface; i++) { fprintf(stderr,"F %d = %d,%d,%d,%d \n",i, fsface[i].v1,fsface[i].v2,fsface[i].v3,fsface[i].v4); }
|
||||
for(i=0; i<newmesh->totvert; i++) { snprintf(debugStrBuffer,256,"V %d = %f,%f,%f \n",i, newmesh->mvert[i].co[0],newmesh->mvert[i].co[1],newmesh->mvert[i].co[2] ); }
|
||||
for(i=0; i<newmesh->totface; i++) { snprintf(debugStrBuffer,256,"F %d = %d,%d,%d,%d \n",i, fsface[i].v1,fsface[i].v2,fsface[i].v3,fsface[i].v4); }
|
||||
} // debug */
|
||||
// correct triangles with v3==0 for blender, cycle verts
|
||||
for(i=0; i<newmesh->totface; i++) {
|
||||
@@ -2298,10 +2307,10 @@ Mesh* readBobjgz(char *filename, Mesh *orgmesh) //, fluidsimDerivedMesh *fsdm)
|
||||
fsface[i].mat_nr = mat_nr;
|
||||
fsface[i].flag = flag;
|
||||
fsface[i].edcode = ME_V1V2 | ME_V2V3 | ME_V3V1;
|
||||
//fprintf(stderr,"%d : %d,%d,%d\n", i,fsface[i].mat_nr, fsface[i].flag, fsface[i].edcode );
|
||||
//snprintf(debugStrBuffer,256,"%d : %d,%d,%d\n", i,fsface[i].mat_nr, fsface[i].flag, fsface[i].edcode );
|
||||
}
|
||||
|
||||
if(debugBobjRead) fprintf(stderr," done\n");
|
||||
snprintf(debugStrBuffer,256," (%d,%d) done\n", newmesh->totvert,newmesh->totface); elbeemDebugOut(debugStrBuffer); //DEBUG
|
||||
return newmesh;
|
||||
}
|
||||
|
||||
|
@@ -225,15 +225,17 @@ void fluidsimBake(struct Object *ob)
|
||||
int origFrame = G.scene->r.cfra;
|
||||
char blendDir[FILE_MAXDIR], blendFile[FILE_MAXFILE];
|
||||
char curWd[FILE_MAXDIR];
|
||||
char debugStrBuffer[256];
|
||||
int dirExist = 0;
|
||||
const int maxRes = 200;
|
||||
int debugBake = 0;
|
||||
|
||||
const char *strEnvName = "BLENDER_ELBEEMDEBUG"; // from blendercall.cpp
|
||||
if(getenv(strEnvName)) {
|
||||
int dlevel = atoi(getenv(strEnvName));
|
||||
if((dlevel>0) && (dlevel<=10)) debugBake = 1;
|
||||
if(debugBake) fprintf(stderr,"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName);
|
||||
elbeemSetDebugLevel(dlevel);
|
||||
//if((dlevel>0) && (dlevel<=10)) debugBake = 1;
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
}
|
||||
|
||||
/* check if there's another domain... */
|
||||
@@ -241,7 +243,8 @@ void fluidsimBake(struct Object *ob)
|
||||
if((obit->fluidsimFlag & OB_FLUIDSIM_ENABLE)&&(obit->type==OB_MESH)) {
|
||||
if(obit->fluidsimSettings->type == OB_FLUIDSIM_DOMAIN) {
|
||||
if(obit != ob) {
|
||||
fprintf(stderr,"fluidsimBake::warning - More than one domain!\n");
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::warning - More than one domain!\n");
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -252,10 +255,12 @@ void fluidsimBake(struct Object *ob)
|
||||
/* rough check of settings... */
|
||||
if(fssDomain->resolutionxyz>maxRes) {
|
||||
fssDomain->resolutionxyz = maxRes;
|
||||
fprintf(stderr,"fluidsimBake::warning - Resolution (%d) > %d^3, this requires more than 600MB of memory... restricting to %d^3 for now.\n", fssDomain->resolutionxyz, maxRes, maxRes);
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::warning - Resolution (%d) > %d^3, this requires more than 600MB of memory... restricting to %d^3 for now.\n", fssDomain->resolutionxyz, maxRes, maxRes);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
}
|
||||
if(fssDomain->previewresxyz > fssDomain->resolutionxyz) {
|
||||
fprintf(stderr,"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", fssDomain->previewresxyz , fssDomain->resolutionxyz);
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", fssDomain->previewresxyz , fssDomain->resolutionxyz);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
fssDomain->previewresxyz = fssDomain->resolutionxyz;
|
||||
}
|
||||
// set adaptive coarsening according to resolutionxyz
|
||||
@@ -270,7 +275,8 @@ void fluidsimBake(struct Object *ob)
|
||||
} else {
|
||||
fssDomain->maxRefine = 0;
|
||||
}
|
||||
if(debugBake) fprintf(stderr,"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , fssDomain->maxRefine );
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , fssDomain->maxRefine );
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
|
||||
// prepare names...
|
||||
strcpy(curWd, G.sce);
|
||||
@@ -284,7 +290,8 @@ void fluidsimBake(struct Object *ob)
|
||||
BLI_splitdirstring(blendDir, blendFile);
|
||||
// todo... strip .blend
|
||||
snprintf(fsDomain->fluidsimSettings->surfdataPrefix,FILE_MAXFILE,"%s_%s", blendFile, fsDomain->id.name);
|
||||
fprintf(stderr,"fluidsimBake::error - warning resetting output prefix to '%s'\n", fsDomain->fluidsimSettings->surfdataPrefix);
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::error - warning resetting output prefix to '%s'\n", fsDomain->fluidsimSettings->surfdataPrefix);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
}
|
||||
|
||||
// check selected directory
|
||||
@@ -306,7 +313,8 @@ void fluidsimBake(struct Object *ob)
|
||||
if((strlen(fsDomain->fluidsimSettings->surfdataDir)<1) || (!dirExist)) {
|
||||
// invalid dir, reset to current
|
||||
strcpy(fsDomain->fluidsimSettings->surfdataDir, "//");
|
||||
fprintf(stderr,"fluidsimBake::error - warning resetting output dir to '%s'\n", fsDomain->fluidsimSettings->surfdataDir);
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::error - warning resetting output dir to '%s'\n", fsDomain->fluidsimSettings->surfdataDir);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
}
|
||||
|
||||
// dump data for frame 0
|
||||
@@ -319,7 +327,8 @@ void fluidsimBake(struct Object *ob)
|
||||
// start writing
|
||||
fileCfg = fopen(fnameCfgPath, "w");
|
||||
if(!fileCfg) {
|
||||
fprintf(stderr,"fluidsimBake::error - Unable to open file for writing '%s'\n", fnameCfgPath);
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::error - Unable to open file for writing '%s'\n", fnameCfgPath);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -390,7 +399,10 @@ void fluidsimBake(struct Object *ob)
|
||||
|
||||
MTC_Mat4CpyMat4(domainMat, fsDomain->obmat);
|
||||
if(!Mat4Invert(invDomMat, domainMat)) {
|
||||
fprintf(stderr,"fluidsimBake::error - Invalid obj matrix?\n"); exit(1);
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::error - Invalid obj matrix?\n");
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
// FIXME add fatal msg
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(fileCfg, blendattrString,
|
||||
@@ -546,7 +558,7 @@ void fluidsimBake(struct Object *ob)
|
||||
char bobjPath[FILE_MAXFILE+FILE_MAXDIR];
|
||||
|
||||
for(obit= G.main->object.first; obit; obit= obit->id.next) {
|
||||
//fprintf(stderr,"DEBUG object name=%s, type=%d ...\n", obit->id.name, obit->type); // DEBUG
|
||||
//{ snprintf(debugStrBuffer,256,"DEBUG object name=%s, type=%d ...\n", obit->id.name, obit->type); elbeemDebugOut(debugStrBuffer); } // DEBUG
|
||||
if( (obit->fluidsimFlag & OB_FLUIDSIM_ENABLE) &&
|
||||
(obit->type==OB_MESH) &&
|
||||
(obit->fluidsimSettings->type != OB_FLUIDSIM_DOMAIN)
|
||||
@@ -568,19 +580,21 @@ void fluidsimBake(struct Object *ob)
|
||||
}
|
||||
|
||||
/* fluid material */
|
||||
fprintf(fileCfg, " material { \n");
|
||||
fprintf(fileCfg, " type= phong; \n");
|
||||
fprintf(fileCfg, " name= \"fluidblue\"; \n");
|
||||
fprintf(fileCfg, " diffuse= 0.3 0.5 0.9; \n");
|
||||
fprintf(fileCfg, " ambient= 0.1 0.1 0.1; \n");
|
||||
fprintf(fileCfg, " specular= 0.2 10.0; \n");
|
||||
fprintf(fileCfg, " } \n");
|
||||
fprintf(fileCfg,
|
||||
" material { \n"
|
||||
" type= phong; \n"
|
||||
" name= \"fluidblue\"; \n"
|
||||
" diffuse= 0.3 0.5 0.9; \n"
|
||||
" ambient= 0.1 0.1 0.1; \n"
|
||||
" specular= 0.2 10.0; \n"
|
||||
" } \n" );
|
||||
|
||||
|
||||
|
||||
fprintf(fileCfg, "} // end raytracing\n");
|
||||
fclose(fileCfg);
|
||||
if(debugBake) fprintf(stderr,"fluidsimBake::msg: Wrote %s\n", fnameCfg);
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::msg: Wrote %s\n", fnameCfg);
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
|
||||
// perform simulation
|
||||
{
|
||||
@@ -593,7 +607,8 @@ void fluidsimBake(struct Object *ob)
|
||||
// DEBUG for win32 debugging, dont use threads...
|
||||
#endif // WIN32
|
||||
if(!simthr) {
|
||||
fprintf(stderr,"fluidsimBake::error: Unable to create thread... running without one.\n");
|
||||
snprintf(debugStrBuffer,256,"fluidsimBake::error: Unable to create thread... running without one.\n");
|
||||
elbeemDebugOut(debugStrBuffer);
|
||||
set_timecursor(0);
|
||||
performElbeemSimulation(fnameCfgPath);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user