2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 #define _CRT_SECURE_NO_DEPRECATE
38 //==========================================================================
42 bbfyException(const std::string& message) : mMessage(message) {}
46 //==========================================================================
48 const std::string itkImageToImageFilterString = "ITK_ImageToImageFilter";
49 const std::string vtkImageAlgorithmString = "VTK_ImageAlgorithm";
50 const std::string vtkPolyDataAlgorithmString = "VTK_PolyDataAlgorithm";
52 //==========================================================================
56 bbfy(const std::string& filename,
57 const std::string& package = "PACKAGE_NAME",
58 const std::string& output_path = "",
59 bool verbose = false);
61 void CreateBlackBox();
66 void WriteGenericITKFilterHeader();
68 void BeginNamespace();
73 std::string mFilename;
74 std::string mOutputPath;
82 itkImageToImageFilter,
90 std::string mParentBlackBox;
91 std::string mItkParent;
92 std::string mVtkObject;
95 std::string mDescription;
96 std::string mCategory;
98 // bool mIsInNamespace;
99 std::string mNamespace;
100 // int mNbTemplateParam;
101 std::vector<std::string> mTemplateParam;
102 std::string mTemplateDeclaration;
103 std::string mTemplateImplementation;
105 std::vector<std::string> mInclude;
106 std::string mVerbosePreprocessor;
107 std::vector<std::string> mTypedef;
109 std::string mUserSetDefaultValues;
110 std::string mUserInitializeProcessing;
111 std::string mUserFinalizeProcessing;
120 std::string generic_type;
124 std::vector<IO> mInput;
125 std::vector<IO> mOutput;
127 std::string mProcess;
128 std::string mCreateWidget;
133 std::string mCxxName;
138 //==========================================================================
142 //==========================================================================
143 bbfy::bbfy(const std::string& filename,
144 const std::string& package,
145 const std::string& output_path,
150 mFilename = filename;
152 mNamespace = "bb" + mPackage;
154 mOutputPath = output_path;
159 //==========================================================================
161 //==========================================================================
162 void bbfy::CreateBlackBox()
164 // Parse XML input file
166 // Create output files
170 //==========================================================================
172 void bbfy::AlertString()
175 mFile << "//===== \n";
176 mFile << "// Before editing this file, make sure it's a file of your own ";
177 mFile << "(i.e.: it wasn't generated from xml description; if so : your modifications will be lost)\n";
178 mFile << "//===== \n";
182 //==========================================================================
183 void bbfy::ParseXML()
188 XMLResults* res = new XMLResults;
189 XMLNode BB = XMLNode::parseFile(mFilename.c_str(),"blackbox",res);
191 if ( res->error != eXMLErrorNone )
193 std::ostringstream str;
194 str << XMLNode::getError(res->error);
195 str << " [line " << res->nLine << ", col "<<res->nColumn<<"]";
197 throw bbfyException(str.str());
202 if (!BB.isAttributeSet("name"))
204 throw bbfyException("Error : <blackbox> tag : no 'name' attribute found (mandatory)");
206 mName = BB.getAttribute("name");
208 if (mVerbose) std::cout << "* Creating BlackBox '"<<mName<<"'"<<std::endl;
215 if (BB.isAttributeSet("type"))
217 std::string bbtype = BB.getAttribute("type");
218 if (bbtype=="standard")
223 else if (bbtype==itkImageToImageFilterString)
225 mType = itkImageToImageFilter;
226 // Looks for <itkparent> tag
227 if (!BB.nChildNode("itkparent"))
229 throw bbfyException("Error : blackbox type '"+itkImageToImageFilterString+"' but no <itkparent> tag found (mandatory)");
231 bbtk::GetTextOrClear(BB.getChildNode("itkparent"),mItkParent);
234 if (BB.isAttributeSet("generic")) mGeneric=true;
236 else if (bbtype == vtkImageAlgorithmString)
238 mType = vtkImageAlgorithm;
239 // Looks for <vtkobject> tag
240 if (!BB.nChildNode("vtkobject"))
242 throw bbfyException("Error : blackbox type '"
243 +vtkImageAlgorithmString
244 +"' but no <vtkobject> tag found (mandatory)");
246 bbtk::GetTextOrClear(BB.getChildNode("vtkobject"),mVtkObject);
249 else if (bbtype == vtkPolyDataAlgorithmString )
251 mType = vtkPolyDataAlgorithm;
252 // Looks for <vtkobject> tag
253 if (!BB.nChildNode("vtkobject"))
255 throw bbfyException("Error : blackbox type '"
256 +vtkPolyDataAlgorithmString
257 +"' but no <vtkobject> tag found (mandatory)");
259 bbtk::GetTextOrClear(BB.getChildNode("vtkobject"),mVtkObject);
264 std::string mess("Error : blackbox type '");
266 mess += "' unknown. Known types :";
267 mess += "'" + itkImageToImageFilterString + "' ";
268 mess += "'" + vtkImageAlgorithmString + "' ";
269 mess += "'" + vtkPolyDataAlgorithmString + "' ";
270 throw bbfyException(mess);
275 if (BB.isAttributeSet("widget"))
278 mParentBlackBox = "bbtk::WxBlackBox";
279 mInclude.push_back("bbtkWxBlackBox.h");
284 mParentBlackBox = "bbtk::AtomicBlackBox";
285 mInclude.push_back("bbtkAtomicBlackBox.h");
290 for (i=0,j=0; i<BB.nChildNode("author"); i++)
293 bbtk::GetTextOrClear(BB.getChildNode("author",&j),val);
297 // Verbose preprocessor
298 for (i=0,j=0; i<BB.nChildNode("verbosePreprocessor"); i++)
301 bbtk::GetTextOrClear(BB.getChildNode("verbosePreprocessor",&j),val);
302 mVerbosePreprocessor += val + "\n";
306 for (i=0,j=0; i<BB.nChildNode("description"); i++)
309 bbtk::GetTextOrClear(BB.getChildNode("description",&j),val);
314 for (i=0,j=0; i<BB.nChildNode("category"); i++)
317 bbtk::GetTextOrClear(BB.getChildNode("category",&j),val);
322 if (BB.nChildNode("namespace"))
324 bbtk::GetTextOrClear(BB.getChildNode("namespace"),mNamespace);
327 // UserSetDefaultValues body
328 if (BB.nChildNode("defaultValues"))
330 bbtk::GetTextOrClear(BB.getChildNode("defaultValues"),
331 mUserSetDefaultValues);
334 // UserInitializeProcessing body
335 if (BB.nChildNode("initializeProcessing"))
337 bbtk::GetTextOrClear(BB.getChildNode("initializeProcessing"),
338 mUserInitializeProcessing);
341 // UserFinalizeProcessing body
342 if (BB.nChildNode("finalizeProcessing"))
344 bbtk::GetTextOrClear(BB.getChildNode("finalizeProcessing"),
345 mUserFinalizeProcessing);
350 // Template parameters
351 // mNbTemplateParam = BB.nChildNode("template");
353 if ( BB.nChildNode("template") > 0)
355 mTemplateDeclaration = "<";
356 mTemplateImplementation = "<";
358 for (i=0,j=0; i<BB.nChildNode("template")-1; i++)
360 mTemplateDeclaration += "class ";
362 bbtk::GetTextOrClear(BB.getChildNode("template",&j),val);
363 mTemplateDeclaration += val;
364 mTemplateDeclaration += ",";
365 mTemplateImplementation += val;
366 mTemplateImplementation += ",";
367 mTemplateParam.push_back(val);
369 mTemplateDeclaration += "class ";
371 bbtk::GetTextOrClear(BB.getChildNode("template",&j),val);
372 mTemplateDeclaration += val;
373 mTemplateDeclaration += ">";
374 mTemplateImplementation += val;
375 mTemplateImplementation += ">";
376 mTemplateParam.push_back(val);
380 for (i=0,j=0; i<BB.nChildNode("include"); i++)
383 bbtk::GetTextOrClear(BB.getChildNode("include",&j),val);
384 mInclude.push_back(val);
387 for (i=0,j=0; i<BB.nChildNode("typedef"); i++)
390 bbtk::GetTextOrClear(BB.getChildNode("typedef",&j),val);
391 mTypedef.push_back(val);
395 for (i=0,j=0; i<BB.nChildNode("input"); i++)
398 XMLNode n = BB.getChildNode("input",&j);
399 if (!n.isAttributeSet("name"))
401 throw bbfyException("Error : <input> attribute 'name' not found (mandatory)");
403 io.name = n.getAttribute("name");
404 if (!n.isAttributeSet("type"))
406 throw bbfyException("Error : <input name=\""+io.name+"\"> attribute 'type' not found (mandatory)");
408 io.type = n.getAttribute("type");
409 if (!n.isAttributeSet("description"))
411 throw bbfyException("Error : <input name=\""+io.name+"\"> attribute 'description' not found (mandatory)");
413 io.descr = n.getAttribute("description");
415 if (n.isAttributeSet("special"))
417 io.special = n.getAttribute("special");
420 if (n.isAttributeSet("nature"))
422 io.nature = n.getAttribute("nature");
425 if (n.isAttributeSet("generic_type"))
427 io.generic_type = n.getAttribute("generic_type");
430 mInput.push_back(io);
434 for (i=0,j=0; i<BB.nChildNode("output"); i++)
437 XMLNode n = BB.getChildNode("output",&j);
438 if (!n.isAttributeSet("name"))
440 throw bbfyException("Error : <output> attribute 'name' not found (mandatory)");
442 io.name = n.getAttribute("name");
443 if (!n.isAttributeSet("type"))
445 throw bbfyException("Error : <output name=\""+io.name+"\"> attribute 'type' not found (mandatory)");
447 io.type = n.getAttribute("type");
448 if (!n.isAttributeSet("description"))
450 throw bbfyException("Error : <output name=\""+io.name+"\"> attribute 'description' not found (mandatory)");
452 io.descr = n.getAttribute("description");
454 if (n.isAttributeSet("special"))
456 io.special = n.getAttribute("special");
459 if (n.isAttributeSet("nature"))
461 io.nature = n.getAttribute("nature");
464 if (n.isAttributeSet("generic_type"))
466 io.generic_type = n.getAttribute("generic_type");
469 mOutput.push_back(io);
474 // process tag given ?
475 if (BB.nChildNode("process"))
477 bbtk::GetTextOrClear(BB.getChildNode("process"),mProcess);
481 // createwidget tag given ?
482 if (BB.nChildNode("createwidget"))
484 bbtk::GetTextOrClear(BB.getChildNode("createwidget"),mCreateWidget);
493 // OBSOLETE/UNSUPPORTED TAGS
494 // WARN IF OBSOLETE TAGS PROVIDED
495 if (BB.nChildNode("constructor"))
497 std::cout << "WARNING !!! The tag <constructor> is obsolete !!"<<std::endl;
499 if (BB.nChildNode("destructor"))
501 std::cout << "WARNING !!! The tag <destructor> is obsolete !!"<<std::endl;
503 if (BB.nChildNode("copy_constructor"))
505 std::cout << "WARNING !!! The tag <copy_constructor> is obsolete !!"<<std::endl;
511 //==========================================================================
514 //==========================================================================
515 void bbfy::BeginNamespace()
517 // if (mIsInNamespace)
519 mFile << "namespace "<<mNamespace <<"\n{\n\n";
522 //==========================================================================
524 //==========================================================================
525 void bbfy::EndNamespace()
527 // if (mIsInNamespace)
529 mFile << "}\n// EO namespace "<<mNamespace<<"\n\n";
532 //==========================================================================
535 //==========================================================================
536 void bbfy::CreateHeader()
543 if (mVerbose) std::cout << " - Creating header '"<<mHName<<"'"<<std::endl;
544 std::string fullname = mOutputPath + mHName;
545 mFile.open(fullname.c_str());
548 std::string mess("Error : could not open file \"");
549 mess += fullname + "\"";
550 throw bbfyException(mess);
558 mFile << "#ifdef _USE_WXWIDGETS_\n";
561 // Prevent multiple inclusions
562 std::string included("__bb");
563 included += mPackage + mName + "_h_INCLUDED__";
564 mFile << "#ifndef " << included <<"\n";
565 mFile << "#define " << included <<"\n";
567 // Verbose preprocessor
568 mFile << mVerbosePreprocessor << "\n";
571 mFile << "#include \"bb" << mPackage << "_EXPORT.h\"\n";
572 std::vector<std::string>::iterator i;
573 for (i=mInclude.begin(); i!=mInclude.end(); ++i)
575 mFile << "#include \"" << *i <<"\"\n";
577 if (mGeneric) mFile << "#include \"bbitkImage.h\"\n";
580 if (mType == itkImageToImageFilter )
582 mFile << "#include \"bbtkItkBlackBoxMacros.h\"\n";
584 else if ( (mType == vtkImageAlgorithm) ||
585 (mType == vtkPolyDataAlgorithm) )
587 mFile << "#include \"bbtkVtkBlackBoxMacros.h\"\n";
594 // If it is a template class
595 if (mTemplateParam.size() > 0)
597 mFile << "template " << mTemplateDeclaration <<"\n";
600 // Class declaration and parents
601 mFile << "class bb"<<mPackage<<"_EXPORT "<<mName<<"\n";
605 if (mBB.nChildNode("inherits"))
608 for (i=0,j=0; i<mBB.nChildNode("inherits")-1; i++)
611 << mBB.getChildNode("inherits",&j).getText()
615 << mBB.getChildNode("Inherits",&j).getText()
620 if (mType == itkImageToImageFilter )
622 mFile << " public " << mItkParent <<",\n";
625 mFile << " public "<<mParentBlackBox << "\n";
632 if (mType == itkImageToImageFilter)
634 mFile << " BBTK_ITK_BLACK_BOX_INTERFACE("
636 << mParentBlackBox << ","
641 else if ( (mType == vtkImageAlgorithm) ||
642 (mType == vtkPolyDataAlgorithm) )
644 mFile << " BBTK_VTK_BLACK_BOX_INTERFACE("
646 << mParentBlackBox << ","
654 mFile << " BBTK_BLACK_BOX_INTERFACE("
656 << mParentBlackBox << ");\n";
659 for (i=mTypedef.begin(); i!=mTypedef.end(); ++i)
668 std::vector<IO>::iterator ioi;
669 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
671 if (ioi->special=="")
673 mFile << " BBTK_DECLARE_INPUT("
679 else if (ioi->special=="itk input")
681 mFile << " BBTK_DECLARE_ITK_INPUT("
687 else if (ioi->special=="vtk input")
689 if (mType == vtkImageAlgorithm) {
690 mFile << " BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT("
696 else if (mType == vtkPolyDataAlgorithm) {
697 mFile << " BBTK_DECLARE_POLY_DATA_ALGORITHM_INPUT("
704 else if (ioi->special=="itk parameter")
706 mFile << " BBTK_DECLARE_ITK_PARAM("
712 else if (ioi->special=="vtk parameter")
714 mFile << " BBTK_DECLARE_VTK_PARAM("
722 std::string mess("Error : input '");
724 mess += "', 'special' attribute '";
725 mess += ioi->special;
727 throw bbfyException(mess);
733 for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi)
735 if (ioi->special=="")
737 mFile << " BBTK_DECLARE_OUTPUT("
743 else if (ioi->special=="itk output")
745 mFile << " BBTK_DECLARE_ITK_OUTPUT("
751 else if (ioi->special=="vtk output")
753 mFile << " BBTK_DECLARE_VTK_OUTPUT("
761 std::string mess("Error : output '");
763 mess += "', 'special' attribute '";
764 mess += ioi->special;
766 throw bbfyException(mess);
771 if ((mType == STD)||(mProcess.size()))
773 mFile << " BBTK_PROCESS(Process);\n" ;
774 mFile << " void Process();\n";
776 else if (mType == itkImageToImageFilter)
778 mFile << " BBTK_ITK_PROCESS();\n" ;
780 else if ((mType == vtkImageAlgorithm) ||
781 (mType == vtkPolyDataAlgorithm) )
784 mFile << " BBTK_VTK_PROCESS();\n" ;
790 mFile << " BBTK_CREATE_WIDGET(CreateWidget);\n" ;
791 mFile << " void CreateWidget(wxWindow*);\n";
796 // EO black box declaration
799 // BO black box description
800 if (mTemplateParam.size()==0)
802 mFile << "BBTK_BEGIN_DESCRIBE_BLACK_BOX("
804 << mParentBlackBox << ");\n";
805 mFile << "BBTK_NAME(\"" << mName <<"\");\n";
807 else if (mTemplateParam.size()==1)
809 mFile << "BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX("
811 //<< mParentBlackBox //<< ","
812 // << mTemplateParam[0]
814 mFile << "BBTK_NAME(\"" << mName
815 << "<\"+bbtk::TypeName<" << mTemplateParam[0]
820 throw bbfyException("template bb with more than 1 templ param not impl");
825 mFile << "BBTK_AUTHOR(\""<<mAuthor<< "\");\n";
828 mFile << "BBTK_DESCRIPTION(\""<<mDescription<< "\");\n";
831 mFile << "BBTK_CATEGORY(\""<<mCategory<< "\");\n";
833 for (i=mTypedef.begin(); i!=mTypedef.end(); ++i)
839 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
841 if (mTemplateParam.size()>0)
843 mFile << "BBTK_TEMPLATE_INPUT(";
847 mFile << "BBTK_INPUT(";
849 mFile << mName << "," << ioi->name << ",\""
850 << ioi->descr << "\"," << ioi->type << ",\""
851 << ioi->nature<<"\");\n";
855 for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi)
857 if (mTemplateParam.size()>0)
859 mFile << "BBTK_TEMPLATE_OUTPUT(";
863 mFile << "BBTK_OUTPUT(";
865 mFile << mName << "," << ioi->name << ",\""
866 << ioi->descr << "\"," << ioi->type << ",\""
867 << ioi->nature<<"\");\n";
870 // EO black box description
871 if (mTemplateParam.size()==0)
873 mFile << "BBTK_END_DESCRIBE_BLACK_BOX("
876 else if (mTemplateParam.size()==1)
878 mFile << "BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX("
880 // << mTemplateParam[0]
885 throw bbfyException("template bb with more than 1 templ param not impl");
889 // Untemplatization of itk filters
892 WriteGenericITKFilterHeader();
900 // Prevent multiple inclusions
901 mFile << "#endif // " << included <<"\n";
905 mFile << "#endif // _USE_WXWIDGETS_\n";
913 //==========================================================================
917 //==========================================================================
918 void bbfy::WriteGenericITKFilterHeader()
920 mFile << "\n//===================================================\n";
921 mFile << "// Generic \"untemplatized\" filter\n";
922 mFile << "//===================================================\n";
924 // Class declaration and parents
925 mFile << "class /*BBTK_EXPORT*/ "<<mName<<"Generic\n";
927 mFile << " public bbtk::AtomicBlackBox\n";
931 mFile << " BBTK_BLACK_BOX_INTERFACE("
932 << mName << "Generic,bbtk::AtomicBlackBox);\n";
935 std::vector<IO>::iterator ioi;
936 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
938 mFile << " BBTK_DECLARE_INPUT("
946 for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi)
948 mFile << " BBTK_DECLARE_OUTPUT("
956 mFile << " BBTK_PROCESS(ProcessSwitch);\n";
957 mFile << " private :\n";
958 mFile << " inline void ProcessSwitch();\n";
959 mFile << " template <class T, unsigned int D> void Process();\n";
960 // EO black box declaration
965 // BO black box description
966 mFile << "BBTK_BEGIN_DESCRIBE_BLACK_BOX("
967 << mName << "Generic,bbtk::AtomicBlackBox);\n";
968 mFile << "BBTK_NAME(\"" << mName <<"\");\n";
971 mFile << "BBTK_AUTHOR(\""<<mAuthor<< "\");\n";
974 mFile << "BBTK_DESCRIPTION(\""<<mDescription<< "\");\n";
977 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
979 mFile << "BBTK_INPUT(";
980 mFile << mName << "Generic," << ioi->name << ",\""
981 << ioi->descr << "\"," << ioi->generic_type <<");\n";
985 for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi)
987 mFile << "BBTK_OUTPUT(";
988 mFile << mName << "Generic," << ioi->name << ",\""
989 << ioi->descr << "\"," << ioi->generic_type <<");\n";
992 // EO black box description
993 mFile << "BBTK_END_DESCRIBE_BLACK_BOX("
994 << mName << "Generic);\n";
997 //=================================================================
998 // ProcessSwitch implementation
999 mFile << "void "<< mName <<"Generic::ProcessSwitch()\n"
1001 << "CALL_FOR_ALL_TYPES_AND_DIM(bbGetInputIn()->GetType(),\n"
1002 << " bbGetInputIn()->GetDimension(),\n"
1005 //=================================================================
1008 //=================================================================
1009 // Template process implementation
1010 mFile << "template <class T, unsigned int D>\n"
1011 << "void "<<mName<<"Generic::Process()\n"
1013 << " bbtkDebugMessageInc(\"Kernel\",9,\n"
1015 << "Generic::Process<\"<<TypeName<T>()<<\",\"<<D<<\">()\"<<std::endl);\n"
1017 << " typedef itk::Image<T,D> ImageType;\n"
1018 << " typedef "<<mName<<"<ImageType> FilterType;\n"
1020 << " FilterType* f = new FilterType(\"Temp\");\n"
1022 << " f->bbSetInputIn( this->bbGetInputIn()->GetImage<T,D>() );\n";
1024 for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi)
1026 if (ioi->name == "In") continue;
1027 mFile << " f->bbSetInput"<<ioi->name<<" ( this->bbGetInput"
1028 << ioi->name << "() );\n";
1031 mFile << " f->bbUpdate();\n"
1032 << " this->bbSetOutputOut( new itkImage( f->bbGetOutputOut() ) );\n"
1033 << " f->UnRegister();\n"
1034 << " bbtkDebugDecTab(\"Kernel\",9);\n"
1036 //=================================================================
1040 //==========================================================================
1043 //==========================================================================
1044 void bbfy::CreateCode()
1047 mCxxName += mPackage;
1050 if (mVerbose) std::cout << " - Creating code '"<<mCxxName<<"'"<<std::endl;
1051 std::string fullname = mOutputPath + mCxxName;
1052 mFile.open(fullname.c_str());
1055 std::string mess("Error : could not open file \"");
1058 throw bbfyException(mess);
1065 // Header of the class
1066 mFile << "#include \"" << mHName << "\"\n";
1068 // Include Package header
1069 mFile << "#include \"bb"<<mPackage << "Package.h\"\n";
1076 if (mTemplateParam.size()>0)
1079 mFile << "BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION("
1081 << mParentBlackBox << ");\n";
1086 mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
1087 << mName << "Generic,bbtk::AtomicBlackBox);\n";
1089 mFile << "BBTK_ADD_BLACK_BOX_TO_PACKAGE("
1091 << mName << "Generic)\n";
1096 // Non template class
1098 mFile << "BBTK_ADD_BLACK_BOX_TO_PACKAGE("
1103 mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
1105 << mParentBlackBox << ");\n";
1108 if ((mType == STD)||(mProcess.size()))
1111 mFile << "void "<<mName<<"::Process()\n{\n";
1112 mFile << mProcess << "\n";
1119 mFile << "void "<<mName<<"::CreateWidget(wxWindow* parent)\n{\n";
1120 mFile << mCreateWidget << "\n";
1125 // User Set Default Values
1127 mFile <<"void "<<mName<<"::bbUserSetDefaultValues()"<<std::endl;
1128 mFile << "{"<<std::endl;
1129 if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
1131 mFile << " BBTK_VTK_SET_DEFAULT_VALUES();\n";
1133 mFile << mUserSetDefaultValues << std::endl;
1134 mFile << "}" << std::endl;
1136 // User Initialize Processing
1138 mFile <<"void "<<mName<<"::bbUserInitializeProcessing()"
1140 mFile << "{"<<std::endl;
1141 if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
1143 mFile << " BBTK_VTK_INITIALIZE_PROCESSING();\n";
1145 mFile << mUserInitializeProcessing << std::endl;
1146 mFile << "}" << std::endl;
1148 // User Finalize Processing
1150 mFile <<"void "<<mName<<"::bbUserFinalizeProcessing()"<<std::endl;
1151 mFile << "{"<<std::endl;
1152 if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
1154 mFile << " BBTK_VTK_FINALIZE_PROCESSING();\n";
1156 mFile << mUserFinalizeProcessing << std::endl;
1157 mFile << "}" << std::endl;
1169 //==========================================================================
1175 //==========================================================================
1176 int main(int argc, char **argv)
1179 if (argc<2 || argc>5)
1181 std::cerr << "usage : "<< argv[0] <<" xml_file [package_name] [output_path] [-q]" << std::endl;
1187 std::string package("PACKAGE_NAME");
1188 std::string output_path("");
1189 bool verbose = true;
1190 if (argc>2) package = argv[2];
1191 if (argc>3) output_path = argv[3];
1192 if (argc>4) verbose = false;
1194 bbfy B(argv[1],package,output_path,verbose);
1196 catch (bbfyException e)
1198 std::cerr << argv[0] << " " << argv[1] << std::endl
1199 << e.mMessage << std::endl;
1204 //==========================================================================