00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include <renderRelation.h>
00020 #include <transformTransition.h>
00021 #include <namedNode.h>
00022 #include <geom.h>
00023 #include <geomNode.h>
00024 #include <pt_NamedNode.h>
00025 #include <nodeTransitionWrapper.h>
00026 #include <nodeAttributeWrapper.h>
00027 #include <allTransitionsWrapper.h>
00028 #include <allAttributesWrapper.h>
00029 #include <nullTransitionWrapper.h>
00030 #include <nullAttributeWrapper.h>
00031 #include <traverserVisitor.h>
00032 #include <dftraverser.h>
00033 #include <nullLevelState.h>
00034 #include <filename.h>
00035 #include <character.h>
00036
00037 #include <indent.h>
00038 #include <ipc_file.h>
00039 #include <bamWriter.h>
00040 #include <bam.h>
00041
00042
00043 template<class TW>
00044 class PrintNodes : public TraverserVisitor<TW, NullLevelState> {
00045 public:
00046 PrintNodes() {
00047 _indent_level = 0;
00048 }
00049 bool reached_node(Node *node, AttributeWrapper &state, NullLevelState &)
00050 {
00051 indent(nout, _indent_level) << "Reached " << *node << ", state is " << state << "\n";
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 return true;
00065 }
00066 bool forward_arc(NodeRelation *, TransitionWrapper &, AttributeWrapper &, AttributeWrapper &, NullLevelState &)
00067 {
00068 _indent_level += 2;
00069 return true;
00070 }
00071 void backward_arc(NodeRelation *, TransitionWrapper &, AttributeWrapper &, AttributeWrapper &, const NullLevelState &)
00072 {
00073 _indent_level -= 2;
00074 }
00075 int _indent_level;
00076 };
00077
00078
00079
00080 int main(int argc, char* argv[]) {
00081 if (argc < 2)
00082 {
00083 nout << "Need an egg file" << endl;
00084 exit(0);
00085 }
00086 Filename file(argv[1]);
00087 if (file.get_extension().compare("egg") != 0)
00088 {
00089 nout << "Need an egg file" << endl;
00090 exit(0);
00091 }
00092 datagram_file stream(file.get_basename_wo_extension()+string(".bam"));
00093 BamWriter manager(&stream);
00094
00095 PT_NamedNode smiley = loader.load_sync(file);
00096
00097 nout << "\n";
00098 PrintNodes<NodeTransitionWrapper> pn;
00099 df_traverse(smiley, pn,
00100 NodeAttributeWrapper(TransformTransition::get_class_type()),
00101 NullLevelState(),
00102 RenderRelation::get_class_type());
00103 nout << "\n";
00104
00105 stream.open(file::FILE_WRITE, _bam_header);
00106 manager.init();
00107 manager.write_object(smiley);
00108 stream.close();
00109
00110 return 0;
00111 }
00112