Commit bcd5c65a authored by Edward Vigmond's avatar Edward Vigmond
Browse files

Display Ln elements contained in .elem files

parent 8961ebc7
......@@ -6,7 +6,7 @@ FLTK_INC := $(shell fltk-config --use-gl --cxxflags)
FLTK_LD_FLAGS := $(shell fltk-config --use-images --use-gl --ldflags)
COMMON_INC := -I. -O0 -g -DOBJ_CLASS -D_REENTRANT -MMD -DNOMINMAX -fopenmp
HDF5=1
#HDF5=1
ifdef HDF5
LIB_CH5 := (HDF5_ROOT)/lib/libch5.a
LIB_HDF5 := -lch5 -lhdf5 -lhdf5_hl
......
......@@ -143,6 +143,7 @@ bool Model::read( const char* fnt, bool base1, bool no_elems )
LOG_TIMER_RESET;
_cnnx = new Connection( &pt );
_cnnx->read( fn );
add_cnnx_from_elem( fn );
LOG_TIMER("Read Connections");
_cable = new ContCable( &pt );
......@@ -463,6 +464,45 @@ void Model::determine_regions()
}
/** add surface by selecting 2D elements from .elem file
*
* A surface will be created for each different region specified.
* Also, all elements withoyut a region specified will form a surface.
*
* \param base model name
*/
int Model::add_cnnx_from_elem( string fname )
{
/* determine file name */
gzFile in;
if ( (in=gzopen( (fname+="elem").c_str(), "r" )) == NULL )
if ((in=gzopen( (fname+=".gz").c_str(), "r" )) == NULL ) {
return -1;
}
// Count the number of surface elements in each surface
char buff[bufsize];
gzgets(in,buff,bufsize); // throw away first line
gzFileBuffer file(in);
int numcx=0, *cnnx=NULL;
while ( file.gets(buff,bufsize) != Z_NULL ) {
char etype[10],reg[10];
if( !strncmp(buff,"Ln",2) ) {
if( !(numcx%10000) )
cnnx = (int *)realloc( cnnx, (numcx/10000+1)*2*sizeof(int) );
if(sscanf( buff,"%s %d %d %s", etype, cnnx+2*numcx, cnnx+2*numcx+1, reg)<5 )
strcpy(reg,"EMPTY");
} else
continue; //ignore volume elements
}
_cnnx->add( numcx, cnnx );
free( cnnx );
return numcx;
}
/** add surface by selecting 2D elements from .elem file
*
* A surface will be created for each different region specified.
......
......@@ -32,6 +32,7 @@ class Model
int add_surface_from_tri( const char * );
int add_surface_from_surf( const char * );
int add_region_surfaces( void );
int add_cnnx_from_elem( string );
inline int reg_first( int s, Object_t t ){return _region[s]->first(t); }
Surfaces* surface(int s){ return _surface[s]; }
void surfKill( int s );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment