2 #define _CRT_SECURE_NO_DEPRECATE
12 //==========================================================================
16 bbfyException(const std::string& message) : mMessage(message) {}
20 //==========================================================================
22 const std::string itkImageToImageFilterString = "ITK_ImageToImageFilter";
23 const std::string vtkImageAlgorithmString = "VTK_ImageAlgorithm";
24 const std::string vtkPolyDataAlgorithmString = "VTK_PolyDataAlgorithm";
26 //==========================================================================
30 bbfy(const std::string& filename,
31 const std::string& package = "PACKAGE_NAME",
32 const std::string& output_path = "",
33 bool verbose = false);
35 void CreateBlackBox();
40 void WriteGenericITKFilterHeader();
42 void BeginNamespace();
47 std::string mFilename;
48 std::string mOutputPath;
56 itkImageToImageFilter,
64 std::string mParentBlackBox;
65 std::string mItkParent;
66 std::string mVtkParent;
69 std::string mDescription;
70 std::string mCategory;
72 // bool mIsInNamespace;
73 std::string mNamespace;
74 // int mNbTemplateParam;
75 std::vector<std::string> mTemplateParam;
76 std::string mTemplateDeclaration;
77 std::string mTemplateImplementation;
79 std::vector<std::string> mInclude;
80 std::vector<std::string> mTypedef;
82 std::string mUserSetDefaultValues;
83 std::string mUserInitializeProcessing;
84 std::string mUserFinalizeProcessing;
93 std::string generic_type;
97 std::vector<IO> mInput;
98 std::vector<IO> mOutput;
100 std::string mProcess;
101 std::string mCreateWidget;
106 std::string mCxxName;
109 //==========================================================================
113 //==========================================================================
114 bbfy::bbfy(const std::string& filename,
115 const std::string& package,
116 const std::string& output_path,
121 mFilename = filename;
123 mNamespace = "bb" + mPackage;
125 mOutputPath = output_path;
130 //==========================================================================
132 //==========================================================================
133 void bbfy::CreateBlackBox()
135 // Parse XML input file
137 // Create output files
141 //==========================================================================
145 //==========================================================================
146 void bbfy::ParseXML()
148 XMLResults* res = new XMLResults;
149 XMLNode BB = XMLNode::parseFile(mFilename.c_str(),"blackbox",res);
151 if ( res->error != eXMLErrorNone )
153 std::ostringstream str;
154 str << XMLNode::getError(res->error);
155 str << " [line " << res->nLine << ", col "<<res->nColumn<<"]";
157 throw bbfyException(str.str());
162 if (!BB.isAttributeSet("name"))
164 throw bbfyException("Error : <blackbox> tag : no 'name' attribute found (mandatory)");
166 mName = BB.getAttribute("name");
168 if (mVerbose) std::cout << "* Creating BlackBox '"<<mName<<"'"<<std::endl;
175 if (BB.isAttributeSet("type"))
177 std::string bbtype = BB.getAttribute("type");
178 if (bbtype=="standard")
183 else if (bbtype==itkImageToImageFilterString)
185 mType = itkImageToImageFilter;
186 // Looks for <itkparent> tag
187 if (!BB.nChildNode("itkparent"))
189 throw bbfyException("Error : blackbox type '"+itkImageToImageFilterString+"' but no <itkparent> tag found (mandatory)");
191 bbtk::GetTextOrClear(BB.getChildNode("itkparent"),mItkParent);
194 if (BB.isAttributeSet("generic")) mGeneric=true;
196 else if (bbtype == vtkImageAlgorithmString)
198 mType = vtkImageAlgorithm;
199 // Looks for <vtkparent> tag
200 if (!BB.nChildNode("vtkparent"))
202 throw bbfyException("Error : blackbox type '"
203 +vtkImageAlgorithmString
204 +"' but no <vtkparent> tag found (mandatory)");
206 bbtk::GetTextOrClear(BB.getChildNode("vtkparent"),mVtkParent);
209 else if (bbtype == vtkPolyDataAlgorithmString )
211 mType = vtkPolyDataAlgorithm;
212 // Looks for <vtkparent> tag
213 if (!BB.nChildNode("vtkparent"))
215 throw bbfyException("Error : blackbox type '"
216 +vtkPolyDataAlgorithmString
217 +"' but no <vtkparent> tag found (mandatory)");
219 bbtk::GetTextOrClear(BB.getChildNode("vtkparent"),mVtkParent);
224 std::string mess("Error : blackbox type '");
226 mess += "' unknown. Known types :";
227 mess += "'" + itkImageToImageFilterString + "' ";
228 mess += "'" + vtkImageAlgorithmString + "' ";
229 mess += "'" + vtkPolyDataAlgorithmString + "' ";
230 throw bbfyException(mess);
235 if (BB.isAttributeSet("widget"))
238 mParentBlackBox = "bbtk::WxBlackBox";
239 mInclude.push_back("bbtkWxBlackBox.h");
244 mParentBlackBox = "bbtk::AtomicBlackBox";
245 mInclude.push_back("bbtkAtomicBlackBox.h");
250 for (i=0,j=0; i<BB.nChildNode("author"); i++)
253 bbtk::GetTextOrClear(BB.getChildNode("author",&j),val);
258 for (i=0,j=0; i<BB.nChildNode("description"); i++)
261 bbtk::GetTextOrClear(BB.getChildNode("description",&j),val);
266 for (i=0,j=0; i<BB.nChildNode("category"); i++)
269 bbtk::GetTextOrClear(BB.getChildNode("category",&j),val);
274 if (BB.nChildNode("namespace"))
276 bbtk::GetTextOrClear(BB.getChildNode("namespace"),mNamespace);
279 // UserSetDefaultValues body
280 if (BB.nChildNode("defaultValues"))
282 bbtk::GetTextOrClear(BB.getChildNode("defaultValues"),
283 mUserSetDefaultValues);
286 // UserInitializeProcessing body
287 if (BB.nChildNode("initializeProcessing"))
289 bbtk::GetTextOrClear(BB.getChildNode("initializeProcessing"),
290 mUserInitializeProcessing);
293 // UserFinalizeProcessing body
294 if (BB.nChildNode("finalizeProcessing"))
296 bbtk::GetTextOrClear(BB.getChildNode("finalizeProcessing"),
297 mUserFinalizeProcessing);
302 // Template parameters
303 // mNbTemplateParam = BB.nChildNode("template");
305 if ( BB.nChildNode("template") > 0)
307 mTemplateDeclaration = "<";
308 mTemplateImplementation = "<";
310 for (i=0,j=0; i<BB.nChildNode("template")-1; i++)
312 mTemplateDeclaration += "class ";
314 bbtk::GetTextOrClear(BB.getChildNode("template",&j),val);
315 mTemplateDeclaration += val;
316 mTemplateDeclaration += ",";
317 mTemplateImplementation += val;
318 mTemplateImplementation += ",";
319 mTemplateParam.push_back(val);
321 mTemplateDeclaration += "class ";
323 bbtk::GetTextOrClear(BB.getChildNode("template",&j),val);
324 mTemplateDeclaration += val;
325 mTemplateDeclaration += ">";
326 mTemplateImplementation += val;
327 mTemplateImplementation += ">";
328 mTemplateParam.push_back(val);
332 for (i=0,j=0; i<BB.nChildNode("include"); i++)
335 bbtk::GetTextOrClear(BB.getChildNode("include",&j),val);
336 mInclude.push_back(val);
339 for (i=0,j=0; i<BB.nChildNode("typedef"); i++)
342 bbtk::GetTextOrClear(BB.getChildNode("typedef",&j),val);
343 mTypedef.push_back(val);
347 for (i=0,j=0; i<BB.nChildNode("input"); i++)
350 XMLNode n = BB.getChildNode("input",&j);
351 if (!n.isAttributeSet("name"))
353 throw bbfyException("Error : <input> attribute 'name' not found (mandatory)");
355 io.name = n.getAttribute("name");
356 if (!n.isAttributeSet("type"))
358 throw bbfyException("Error : <input name=\""+io.name+"\"> attribute 'type' not found (mandatory)");
360 io.type = n.getAttribute("type");
361 if (!n.isAttributeSet("description"))
363 throw bbfyException("Error : <input name=\""+io.name+"\"> attribute 'description' not found (mandatory)");
365 io.descr = n.getAttribute("description");
367 if (n.isAttributeSet("special"))
369 io.special = n.getAttribute("special");
372 if (n.isAttributeSet("nature"))
374 io.nature = n.getAttribute("nature");
377 if (n.isAttributeSet("generic_type"))
379 io.generic_type = n.getAttribute("generic_type");
382 mInput.push_back(io);
386 for (i=0,j=0; i<BB.nChildNode("output"); i++)
389 XMLNode n = BB.getChildNode("output",&j);
390 if (!n.isAttributeSet("name"))
392 throw bbfyException("Error : <output> attribute 'name' not found (mandatory)");
394 io.name = n.getAttribute("name");
395 if (!n.isAttributeSet("type"))
397 throw bbfyException("Error : <output name=\""+io.name+"\"> attribute 'type' not found (mandatory)");
399 io.type = n.getAttribute("type");
400 if (!n.isAttributeSet("description"))
402 throw bbfyException("Error : <output name=\""+io.name+"\"> attribute 'description' not found (mandatory)");
404 io.descr = n.getAttribute("description");
406 if (n.isAttributeSet("special"))
408 io.special = n.getAttribute("special");
411 if (n.isAttributeSet("nature"))
413 io.nature = n.getAttribute("nature");
416 if (n.isAttributeSet("generic_type"))
418 io.generic_type = n.getAttribute("generic_type");
421 mOutput.push_back(io);
426 // process tag given ?
427 if (BB.nChildNode("process"))
429 bbtk::GetTextOrClear(BB.getChildNode("process"),mProcess);
433 // createwidget tag given ?
434 if (BB.nChildNode("createwidget"))
436 bbtk::GetTextOrClear(BB.getChildNode("createwidget"),mCreateWidget);
445 // OBSOLETE/UNSUPPORTED TAGS
446 // WARN IF OBSOLETE TAGS PROVIDED
447 if (BB.nChildNode("constructor"))
449 std::cout << "WARNING !!! The tag <constructor> is obsolete !!"<<std::endl;
451 if (BB.nChildNode("destructor"))
453 std::cout << "WARNING !!! The tag <destructor> is obsolete !!"<<std::endl;
455 if (BB.nChildNode("copy_constructor"))
457 std::cout << "WARNING !!! The tag <copy_constructor> is obsolete !!"<<std::endl;
463 //==========================================================================
466 //==========================================================================
467 void bbfy::BeginNamespace()
469 // if (mIsInNamespace)
471 mFile << "namespace "<<mNamespace <<"\n{\n\n";
474 //==========================================================================
476 //==========================================================================
477 void bbfy::EndNamespace()
479 // if (mIsInNamespace)
481 mFile << "}\n// EO namespace "<<mNamespace<<"\n\n";
484 //==========================================================================
487 //==========================================================================
488 void bbfy::CreateHeader()
495 if (mVerbose) std::cout << " - Creating header '"<<mHName<<"'"<<std::endl;
496 std::string fullname = mOutputPath + mHName;
497 mFile.open(fullname.c_str());
500 std::string mess("Error : could not open file \"");
501 mess += fullname + "\"";
502 throw bbfyException(mess);
508 mFile << "#ifdef _USE_WXWIDGETS_\n";
511 // Prevent multiple inclusions
512 std::string included("__bb");
513 included += mPackage + mName + "_h_INCLUDED__";
514 mFile << "#ifndef " << included <<"\n";
515 mFile << "#define " << included <<"\n";
518 mFile << "#include \"bb" << mPackage << "_EXPORT.h\"\n";
519 std::vector<std::string>::iterator i;
520 for (i=mInclude.begin(); i!=mInclude.end(); ++i)
522 mFile << "#include \"" << *i <<"\"\n";
524 if (mGeneric) mFile << "#include \"bbitkImage.h\"\n";
527 if (mType == itkImageToImageFilter )
529 mFile << "#include \"bbtkItkBlackBoxMacros.h\"\n";
531 else if ( (mType == vtkImageAlgorithm) ||
532 (mType == vtkPolyDataAlgorithm) )
534 mFile << "#include \"bbtkVtkBlackBoxMacros.h\"\n";
541 // If it is a template class
542 if (mTemplateParam.size() > 0)
544 mFile << "template " << mTemplateDeclaration <<"\n";
547 // Class declaration and parents
548 mFile << "class bb"<<mPackage<<"_EXPORT "<<mName<<"\n";
552 if (mBB.nChildNode("inherits"))
555 for (i=0,j=0; i<mBB.nChildNode("inherits")-1; i++)
558 << mBB.getChildNode("inherits",&j).getText()
562 << mBB.getChildNode("Inherits",&j).getText()
567 if (mType == itkImageToImageFilter )
569 mFile << " public " << mItkParent <<",\n";
572 // else if ( (mType == vtkImageAlgorithm) ||
573 // (mType == vtkPolyDataAlgorithm) )
575 // mFile << " public " << mVtkParent <<",\n";
578 mFile << " public "<<mParentBlackBox << "\n";
585 if (mType == itkImageToImageFilter)
587 mFile << " BBTK_ITK_BLACK_BOX_INTERFACE("
589 << mParentBlackBox << ","
594 else if ( (mType == vtkImageAlgorithm) ||
595 (mType == vtkPolyDataAlgorithm) )
597 mFile << " BBTK_VTK_BLACK_BOX_INTERFACE("
599 << mParentBlackBox << ","
607 mFile << " BBTK_BLACK_BOX_INTERFACE("
609 << mParentBlackBox << ");\n";
612 for (i=mTypedef.begin(); i!=mTypedef.end(); ++i)
617 // Declare user constructor / copy cons /destr
619 mFile << "//=================================================================="<<std::endl;
620 mFile << "/// User callback called in the box contructor"<<std::endl;
622 mFile << "virtual void bbUserConstructor();"<<std::endl;
623 mFile << "/// User callback called in the box copy constructor"<<std::endl;
624 mFile << "virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer);"<<std::endl;
625 mFile << "/// User callback called in the box destructor"<<std::endl;
626 mFile << "virtual void bbUserDestructor();"<<std::endl;
627 mFile << "//=================================================================="<<std::endl;
632 std::vector<IO>::iterator ioi;
633 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
635 if (ioi->special=="")
637 mFile << " BBTK_DECLARE_INPUT("
643 else if (ioi->special=="itk input")
645 mFile << " BBTK_DECLARE_ITK_INPUT("
651 else if (ioi->special=="vtk input")
653 if (mType == vtkImageAlgorithm) {
654 mFile << " BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT("
660 else if (mType == vtkPolyDataAlgorithm) {
661 mFile << " BBTK_DECLARE_POLY_DATA_ALGORITHM_INPUT("
668 else if (ioi->special=="itk parameter")
670 mFile << " BBTK_DECLARE_ITK_PARAM("
676 else if (ioi->special=="vtk parameter")
678 mFile << " BBTK_DECLARE_VTK_PARAM("
686 std::string mess("Error : input '");
688 mess += "', 'special' attribute '";
689 mess += ioi->special;
691 throw bbfyException(mess);
696 for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi)
698 if (ioi->special=="")
700 mFile << " BBTK_DECLARE_OUTPUT("
706 else if (ioi->special=="itk output")
708 mFile << " BBTK_DECLARE_ITK_OUTPUT("
714 else if (ioi->special=="vtk output")
716 mFile << " BBTK_DECLARE_VTK_OUTPUT("
724 std::string mess("Error : output '");
726 mess += "', 'special' attribute '";
727 mess += ioi->special;
729 throw bbfyException(mess);
734 if ((mType == STD)||(mProcess.size()))
736 mFile << " BBTK_PROCESS(Process);\n" ;
737 mFile << " void Process();\n";
739 else if (mType == itkImageToImageFilter)
741 mFile << " BBTK_ITK_PROCESS();\n" ;
743 else if ((mType == vtkImageAlgorithm) ||
744 (mType == vtkPolyDataAlgorithm) )
747 mFile << " BBTK_VTK_PROCESS();\n" ;
753 mFile << " BBTK_CREATE_WIDGET(CreateWidget);\n" ;
754 mFile << " void CreateWidget(wxWindow*);\n";
758 // EO black box declaration
761 // BO black box description
762 if (mTemplateParam.size()==0)
764 mFile << "BBTK_BEGIN_DESCRIBE_BLACK_BOX("
766 << mParentBlackBox << ");\n";
767 mFile << "BBTK_NAME(\"" << mName <<"\");\n";
769 else if (mTemplateParam.size()==1)
771 mFile << "BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX("
773 //<< mParentBlackBox //<< ","
774 // << mTemplateParam[0]
776 mFile << "BBTK_NAME(\"" << mName
777 << "<\"+bbtk::TypeName<" << mTemplateParam[0]
782 throw bbfyException("template bb with more than 1 templ param not impl");
786 mFile << "BBTK_AUTHOR(\""<<mAuthor<< "\");\n";
789 mFile << "BBTK_DESCRIPTION(\""<<mDescription<< "\");\n";
792 mFile << "BBTK_CATEGORY(\""<<mCategory<< "\");\n";
794 for (i=mTypedef.begin(); i!=mTypedef.end(); ++i)
800 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
802 if (mTemplateParam.size()>0)
804 mFile << "BBTK_TEMPLATE_INPUT(";
808 mFile << "BBTK_INPUT(";
810 mFile << mName << "," << ioi->name << ",\""
811 << ioi->descr << "\"," << ioi->type << ",\""
812 << ioi->nature<<"\");\n";
816 for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi)
818 if (mTemplateParam.size()>0)
820 mFile << "BBTK_TEMPLATE_OUTPUT(";
824 mFile << "BBTK_OUTPUT(";
826 mFile << mName << "," << ioi->name << ",\""
827 << ioi->descr << "\"," << ioi->type << ",\""
828 << ioi->nature<<"\");\n";
831 // EO black box description
832 if (mTemplateParam.size()==0)
834 mFile << "BBTK_END_DESCRIBE_BLACK_BOX("
837 else if (mTemplateParam.size()==1)
839 mFile << "BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX("
841 // << mTemplateParam[0]
846 throw bbfyException("template bb with more than 1 templ param not impl");
850 // Untemplatization of itk filters
853 WriteGenericITKFilterHeader();
860 // Prevent multiple inclusions
861 mFile << "#endif // " << included <<"\n";
865 mFile << "#endif // _USE_WXWIDGETS_\n";
873 //==========================================================================
877 //==========================================================================
878 void bbfy::WriteGenericITKFilterHeader()
880 mFile << "\n//===================================================\n";
881 mFile << "// Generic \"untemplatized\" filter\n";
882 mFile << "//===================================================\n";
884 // Class declaration and parents
885 mFile << "class /*BBTK_EXPORT*/ "<<mName<<"Generic\n";
887 mFile << " public bbtk::AtomicBlackBox\n";
891 mFile << " BBTK_BLACK_BOX_INTERFACE("
892 << mName << "Generic,bbtk::AtomicBlackBox);\n";
895 std::vector<IO>::iterator ioi;
896 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
898 mFile << " BBTK_DECLARE_INPUT("
906 for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi)
908 mFile << " BBTK_DECLARE_OUTPUT("
916 mFile << " BBTK_PROCESS(ProcessSwitch);\n";
917 mFile << " private :\n";
918 mFile << " inline void ProcessSwitch();\n";
919 mFile << " template <class T, unsigned int D> void Process();\n";
920 // EO black box declaration
925 // BO black box description
926 mFile << "BBTK_BEGIN_DESCRIBE_BLACK_BOX("
927 << mName << "Generic,bbtk::AtomicBlackBox);\n";
928 mFile << "BBTK_NAME(\"" << mName <<"\");\n";
931 mFile << "BBTK_AUTHOR(\""<<mAuthor<< "\");\n";
934 mFile << "BBTK_DESCRIPTION(\""<<mDescription<< "\");\n";
937 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
939 mFile << "BBTK_INPUT(";
940 mFile << mName << "Generic," << ioi->name << ",\""
941 << ioi->descr << "\"," << ioi->generic_type <<");\n";
945 for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi)
947 mFile << "BBTK_OUTPUT(";
948 mFile << mName << "Generic," << ioi->name << ",\""
949 << ioi->descr << "\"," << ioi->generic_type <<");\n";
952 // EO black box description
953 mFile << "BBTK_END_DESCRIBE_BLACK_BOX("
954 << mName << "Generic);\n";
957 //=================================================================
958 // ProcessSwitch implementation
959 mFile << "void "<< mName <<"Generic::ProcessSwitch()\n"
961 << "CALL_FOR_ALL_TYPES_AND_DIM(bbGetInputIn()->GetType(),\n"
962 << " bbGetInputIn()->GetDimension(),\n"
965 //=================================================================
968 //=================================================================
969 // Template process implementation
970 mFile << "template <class T, unsigned int D>\n"
971 << "void "<<mName<<"Generic::Process()\n"
973 << " bbtkDebugMessageInc(\"Kernel\",9,\n"
975 << "Generic::Process<\"<<TypeName<T>()<<\",\"<<D<<\">()\"<<std::endl);\n"
977 << " typedef itk::Image<T,D> ImageType;\n"
978 << " typedef "<<mName<<"<ImageType> FilterType;\n"
980 << " FilterType* f = new FilterType(\"Temp\");\n"
982 << " f->bbSetInputIn( this->bbGetInputIn()->GetImage<T,D>() );\n";
984 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
986 if (ioi->name == "In") continue;
987 mFile << " f->bbSetInput"<<ioi->name<<" ( this->bbGetInput"
988 << ioi->name << "() );\n";
991 mFile << " f->bbUpdate();\n"
992 << " this->bbSetOutputOut( new itkImage( f->bbGetOutputOut() ) );\n"
993 << " f->UnRegister();\n"
994 << " bbtkDebugDecTab(\"Kernel\",9);\n"
996 //=================================================================
1000 //==========================================================================
1003 //==========================================================================
1004 void bbfy::CreateCode()
1007 mCxxName += mPackage;
1010 if (mVerbose) std::cout << " - Creating code '"<<mCxxName<<"'"<<std::endl;
1011 std::string fullname = mOutputPath + mCxxName;
1012 mFile.open(fullname.c_str());
1015 std::string mess("Error : could not open file \"");
1018 throw bbfyException(mess);
1022 // Header of the class
1023 mFile << "#include \"" << mHName << "\"\n";
1025 // Include Package header
1026 mFile << "#include \"bb"<<mPackage << "Package.h\"\n";
1033 if (mTemplateParam.size()>0)
1036 mFile << "BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION("
1038 << mParentBlackBox << ");\n";
1043 mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
1044 << mName << "Generic,bbtk::AtomicBlackBox);\n";
1046 mFile << "BBTK_ADD_BLACK_BOX_TO_PACKAGE("
1048 << mName << "Generic)\n";
1053 // Non template class
1055 mFile << "BBTK_ADD_BLACK_BOX_TO_PACKAGE("
1060 mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
1062 << mParentBlackBox << ");\n";
1065 if ((mType == STD)||(mProcess.size()))
1067 mFile << "void "<<mName<<"::Process()\n{\n";
1068 mFile << mProcess << "\n";
1074 mFile << "void "<<mName<<"::CreateWidget(wxWindow* parent)\n{\n";
1075 mFile << mCreateWidget << "\n";
1080 // User Set Default Values
1081 mFile <<"void "<<mName<<"::bbUserSetDefaultValues()"<<std::endl;
1082 mFile << "{"<<std::endl;
1083 if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
1085 mFile << " mVtkObject = NULL;\n";
1087 mFile << mUserSetDefaultValues << std::endl;
1088 mFile << "}" << std::endl;
1090 // User Initialize Processing
1091 mFile <<"void "<<mName<<"::bbUserInitializeProcessing()"
1093 mFile << "{"<<std::endl;
1094 if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
1096 mFile << " mVtkObject = "<< mVtkParent <<"::New();\n";
1098 mFile << mUserInitializeProcessing << std::endl;
1099 mFile << "}" << std::endl;
1101 // User Finalize Processing
1102 mFile <<"void "<<mName<<"::bbUserFinalizeProcessing()"<<std::endl;
1103 mFile << "{"<<std::endl;
1104 if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
1106 mFile << " mVtkObject->Delete();\n";
1108 mFile << mUserFinalizeProcessing << std::endl;
1109 mFile << "}" << std::endl;
1121 //==========================================================================
1127 //==========================================================================
1128 int main(int argc, char **argv)
1131 if (argc<2 || argc>5)
1133 std::cerr << "usage : "<< argv[0] <<" xml_file [package_name] [output_path] [-q]" << std::endl;
1139 std::string package("PACKAGE_NAME");
1140 std::string output_path("");
1141 bool verbose = true;
1142 if (argc>2) package = argv[2];
1143 if (argc>3) output_path = argv[3];
1144 if (argc>4) verbose = false;
1146 bbfy B(argv[1],package,output_path,verbose);
1148 catch (bbfyException e)
1150 std::cerr << argv[0] << " " << argv[1] << std::endl
1151 << e.mMessage << std::endl;
1156 //==========================================================================