Skip to content

Commit

Permalink
Fix nmrc path issues
Browse files Browse the repository at this point in the history
  • Loading branch information
billkarsh committed Oct 16, 2013
1 parent 58a8f52 commit 9efebf3
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 49 deletions.
45 changes: 26 additions & 19 deletions 1_MakeIDB/makeidb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,12 @@ class cArgs_idb {
/* Statics ------------------------------------------------------- */
/* --------------------------------------------------------------- */

static char gtopdir[2048];
static cArgs_idb gArgs;
static CTileSet TS;
static FILE* flog = NULL;
static int ismrc = false;
static char gtopdir[2048];
static cArgs_idb gArgs;
static CTileSet TS;
static vector<string> vname0;
static FILE* flog = NULL;
static int ismrc = false;



Expand Down Expand Up @@ -189,7 +190,7 @@ static void Make_nmrc_paths()

DskAbsPath( topdir, sizeof(topdir), gArgs.outdir, flog );

// fix all tiles
// save mrc names in global vector and replace them in TS

int nt = TS.vtil.size();

Expand All @@ -198,9 +199,10 @@ static void Make_nmrc_paths()
CUTile& U = TS.vtil[i];
char path[2048];

sprintf( path, "%s/%d/nmrc_%d_%d.png",
sprintf( path, "%s/%d/nmrc/nmrc_%d_%d.png",
topdir, U.z, U.z, U.id );

vname0.push_back( U.name );
U.name = path;
}
}
Expand Down Expand Up @@ -494,26 +496,31 @@ static void Make_MakeFM( const char *lyrdir, int is0, int isN )
for( int i = is0; i < isN; ++i ) {

const CUTile& U = TS.vtil[i];
char dep[2048];

ConvertSpaces( dep, U.name.c_str() );

#if 0
// target with dependency
char dep[2048];
ConvertSpaces( dep, vname0[i].c_str() );
fprintf( f, "fm/fm_%d_%d.png: %s\n", U.z, U.id, dep );
#else
// target only
fprintf( f, "fm/fm_%d_%d.png:\n", U.z, U.id );
#endif

if( gArgs.NoFolds ) {
if( ismrc ) {
fprintf( f,
"\ttiny %d %d '%s'"
" '-nmrc=nmrc/nmrc_%d_%d.png'"
" ${EXTRA}\n",
U.z, U.id, U.name.c_str(),
" -nf ${EXTRA}\n",
U.z, U.id, vname0[i].c_str(),
U.z, U.id );
}
else {
fprintf( f,
"\ttiny %d %d '%s'"
" ${EXTRA}\n",
U.z, U.id, U.name.c_str() );
" -nf ${EXTRA}\n",
U.z, U.id, vname0[i].c_str() );
}
}
else {
Expand All @@ -524,7 +531,7 @@ static void Make_MakeFM( const char *lyrdir, int is0, int isN )
" '-fm=fm/fm_%d_%d.png'"
" '-fmd=fmd/fmd_%d_%d.png'"
" ${EXTRA}\n",
U.z, U.id, U.name.c_str(),
U.z, U.id, vname0[i].c_str(),
U.z, U.id,
U.z, U.id,
U.z, U.id );
Expand All @@ -535,7 +542,7 @@ static void Make_MakeFM( const char *lyrdir, int is0, int isN )
" '-fm=fm/fm_%d_%d.png'"
" '-fmd=fmd/fmd_%d_%d.png'"
" ${EXTRA}\n",
U.z, U.id, U.name.c_str(),
U.z, U.id, vname0[i].c_str(),
U.z, U.id,
U.z, U.id );
}
Expand Down Expand Up @@ -615,18 +622,18 @@ int main( int argc, char* argv[] )
if( isrickfile )
TS.SetTileDimsFromImageFile();

TS.SortAll_z_id();

ismrc = strstr( TS.vtil[0].name.c_str(), ".mrc" ) != NULL;

if( ismrc )
Make_nmrc_paths();

TS.SortAll_z_id();

/* ----------- */
/* Diagnostics */
/* ----------- */

if( isrickfile ) {
if( isrickfile || ismrc ) {

TS.WriteTrakEM2_EZ( "PreClicks.xml",
gArgs.xml_type, gArgs.xml_min, gArgs.xml_max );
Expand Down
56 changes: 29 additions & 27 deletions 1_Script/scr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,13 @@ class CArgs_scr {
/* Statics ------------------------------------------------------- */
/* --------------------------------------------------------------- */

static char gtopdir[2048];
static CArgs_scr gArgs;
static CTileSet TS;
static FILE* flog = NULL;
static int gW = 0, // universal pic dims
gH = 0,
gZMax = 0,
ismrc = false;
static char gtopdir[2048];
static CArgs_scr gArgs;
static CTileSet TS;
static vector<string> vname0;
static FILE* flog = NULL;
static int gZMax = 0,
ismrc = false;



Expand Down Expand Up @@ -147,7 +146,7 @@ static void Make_nmrc_paths()

DskAbsPath( topdir, sizeof(topdir), gArgs.outdir, flog );

// fix all tiles
// save mrc names in global vector and replace them in TS

int nt = TS.vtil.size();

Expand All @@ -159,6 +158,7 @@ static void Make_nmrc_paths()
sprintf( path, "%s/%d/%d/nmrc_%d_%d.png",
topdir, U.z, U.id, U.z, U.id );

vname0.push_back( U.name );
U.name = path;
}
}
Expand Down Expand Up @@ -190,12 +190,15 @@ static void WriteImageparamsFile()
{
char name[2048];
FILE *f;
int w, h;

TS.GetTileDims( w, h );

sprintf( name, "%s/imageparams.txt", gArgs.outdir );

f = FileOpenOrDie( name, "w", flog );

fprintf( f, "IMAGESIZE %d %d\n", gW, gH );
fprintf( f, "IMAGESIZE %d %d\n", w, h );

fclose( f );
}
Expand Down Expand Up @@ -284,7 +287,7 @@ static void Make_ThmPairFile(
/* ABOlap -------------------------------------------------------- */
/* --------------------------------------------------------------- */

// Return area(intersection) / (gW*gH).
// Return area(intersection) / area(image).
//
// We construct the polygon enclosing the intersection in
// b-space. Its vertices comprise the set of rectangle edge
Expand Down Expand Up @@ -478,26 +481,31 @@ static void Make_MakeFM( const char *lyrdir, int is0, int isN )
for( int i = is0; i < isN; ++i ) {

const CUTile& U = TS.vtil[i];
char dep[2048];

ConvertSpaces( dep, U.name.c_str() );

#if 0
// target with dependency
char dep[2048];
ConvertSpaces( dep, vname0[i].c_str() );
fprintf( f, "%d/fm.png: %s\n", U.id, dep );
#else
// target only
fprintf( f, "%d/fm.png:\n", U.id );
#endif

if( gArgs.NoFolds ) {
if( ismrc ) {
fprintf( f,
"\ttiny %d %d '%s'"
" '-nmrc=%d/nmrc_%d_%d.png'"
" ${EXTRA}\n",
U.z, U.id, U.name.c_str(),
" -nf ${EXTRA}\n",
U.z, U.id, vname0[i].c_str(),
U.id, U.z, U.id );
}
else {
fprintf( f,
"\ttiny %d %d '%s'"
" ${EXTRA}\n",
U.z, U.id, U.name.c_str() );
" -nf ${EXTRA}\n",
U.z, U.id, vname0[i].c_str() );
}
}
else {
Expand All @@ -508,7 +516,7 @@ static void Make_MakeFM( const char *lyrdir, int is0, int isN )
" '-fm=%d/fm.png'"
" '-fmd=%d/fmd.png'"
" ${EXTRA}\n",
U.z, U.id, U.name.c_str(),
U.z, U.id, vname0[i].c_str(),
U.id, U.z, U.id,
U.id,
U.id );
Expand All @@ -519,7 +527,7 @@ static void Make_MakeFM( const char *lyrdir, int is0, int isN )
" '-fm=%d/fm.png'"
" '-fmd=%d/fmd.png'"
" ${EXTRA}\n",
U.z, U.id, U.name.c_str(),
U.z, U.id, vname0[i].c_str(),
U.id,
U.id );
}
Expand Down Expand Up @@ -850,19 +858,13 @@ int main( int argc, char* argv[] )
if( isrickfile )
TS.SetTileDimsFromImageFile();

TS.GetTileDims( gW, gH );
TS.SortAll_z_r();

ismrc = strstr( TS.vtil[0].name.c_str(), ".mrc" ) != NULL;

if( ismrc )
Make_nmrc_paths();

/* ------------------------------------------------- */
/* Within each layer, sort tiles by dist from center */
/* ------------------------------------------------- */

TS.SortAll_z_r();

/* ------------------- */
/* Handle connect mode */
/* ------------------- */
Expand Down
36 changes: 35 additions & 1 deletion 1_TopScripts/topscripts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,40 @@ static void Write_mongo()
FileScriptPerms( buf );
}

/* --------------------------------------------------------------- */
/* XMLHasMRC ----------------------------------------------------- */
/* --------------------------------------------------------------- */

// Return true if *.mrc images.
//
static bool XMLHasMRC()
{
FILE *f = FileOpenOrDie( gArgs.infile, "r", flog );
CLineScan LS;
int nfile_path = 0;
bool ismrc = false;

while( LS.Get( f ) > 0 ) {

if( strstr( LS.line, "ex.mrc\"" ) ) {
ismrc = true;
break;
}

if( nfile_path >= 10 )
break;

if( strstr( LS.line, "file_path" ) ) {
++nfile_path;
}
}

exit:
fclose( f );

return ismrc;
}

/* --------------------------------------------------------------- */
/* Write_upmongo --------------------------------------------------- */
/* --------------------------------------------------------------- */
Expand All @@ -224,7 +258,7 @@ static void Write_upmongo()
char buf[2048], inname[256];
FILE *f;

if( FileExtIsXML( gArgs.infile ) ) {
if( FileExtIsXML( gArgs.infile ) && !XMLHasMRC() ) {

const char *name = FileNamePtr( gArgs.infile ),
*dot = FileDotPtr( name );
Expand Down
4 changes: 2 additions & 2 deletions zlineends.sht
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

if [ "$1" = "-f" ]
then
for ifile in $(grep -rl $'\r' $2)
for ifile in $(grep -rl $'\r' $2/*.{c,cpp,h,txt})
do
sed -i 's|\r||g' $ifile
done
else
grep -rl $'\r' *
grep -rl $'\r' */*.{c,cpp,h,txt}
fi

0 comments on commit 9efebf3

Please sign in to comment.