22 static void usage(
const char* name,
bool brief =
true )
24 std::ostream& str = brief ? std::cerr : std::cout;
26 str << name <<
": A tool to export entity set parent/child relations" << std::endl
27 <<
" for use as input to graphviz" << std::endl;
28 str <<
"Usage: " << name <<
" [-a | [-g] [-m] [-n] ] <input_file>" << std::endl
29 <<
" " << name <<
" -h" << std::endl;
30 if( brief ) exit( 1 );
31 str <<
" The default behavior is equivalent to \"-gmn\"." << std::endl
32 <<
" If any of the following options are used to specify which " << std::endl
33 <<
" sets to output, then there are no defaults. Only the " << std::endl
34 <<
" indicated sets will be output." << std::endl
35 <<
" -a : write all sets (default is only geom, mesh, and named)" << std::endl
36 <<
" -g : write geometric topology sets" << std::endl
37 <<
" -m : write material sets and boundary condition sets" << std::endl
38 <<
" -n : write named sets" << std::endl
39 <<
" -s : label surface-volume links with sense" << std::endl
40 <<
" The default link behavior is to both child links" << std::endl
41 <<
" and containment with solid lines." << std::endl
42 <<
" -P : do not write child links" << std::endl
43 <<
" -p : write child links with dashed lines" << std::endl
44 <<
" -C : do not write containment links" << std::endl
45 <<
" -c : write containment links with dashed lines" << std::endl;
60 int main(
int argc,
char* argv[] )
63 bool printGeomSets =
true;
64 bool printMeshSets =
true;
65 bool printNamedSets =
true;
67 bool geom_flag =
false, mesh_flag =
false, name_flag =
false, all_flag =
false;
68 bool no_more_flags =
false;
69 for(
int i = 1; i < argc; ++i )
71 if( no_more_flags || argv[i][0] !=
'-' )
77 for(
int j = 1; argv[i][j]; ++j )
109 no_more_flags =
true;
112 usage( argv[0],
false );
115 std::cerr <<
"Unknown flag: '" << argv[i][j] <<
"'" << std::endl;
123 std::cerr <<
"No input file specified." << std::endl;
129 printGeomSets = printMeshSets = printNamedSets =
printAnonSets =
true;
131 else if( geom_flag || mesh_flag || name_flag )
133 printGeomSets = geom_flag;
134 printMeshSets = mesh_flag;
135 printNamedSets = name_flag;
140 std::cerr <<
input_file <<
": file read failed." << std::endl;
183 std::cout <<
"digraph {" << std::endl;
185 std::cout << std::endl;
188 std::cout <<
"}" << std::endl;
197 result_sets =
subtract( result_sets, curr_sets );
198 curr_sets.
merge( result_sets );
204 if(
id ) s <<
' ' << *id;
205 s <<
"\"];" << std::endl;
217 Range vol_sets, surf_sets, curv_sets, vert_sets;
218 Range block_sets, side_sets, node_sets;
219 Range named_sets, other_sets;
240 sets.
swap( other_sets );
241 other_sets.
swap( xsect );
254 for( i = named_sets.
begin(); i != named_sets.
end(); ++i )
262 for( i = other_sets.
begin(); i != other_sets.
end(); ++i )
273 const char* label = 0 )
276 if( dashed && label )
277 s <<
" [style = dashed label = \"" << label <<
"\"]";
279 s <<
" [style = dashed]";
281 s <<
" [label = \"" << label <<
"\"]";
282 s <<
';' << std::endl;
288 const char *fstr =
"forward", *rstr =
"reverse";
297 const char* linklabel = 0;
301 linklabel = ( sense == (int)SENSE_FORWARD ) ? fstr : rstr;
314 contained =
intersect( contained, sets );