]> Creatis software - bbtk.git/blob - doc/bouml/bbtkk/152962.bodies
.
[bbtk.git] / doc / bouml / bbtkk / 152962.bodies
1 class bbfy
2 !!!202626.cpp!!!        bbfy(in filename : std::string, in package : std::string = "PACKAGE_NAME", in output_path : std::string = "", in verbose : bool = false)
3   mIsWidget = false;
4   
5   mFilename = filename;
6   mPackage = package;
7   mNamespace = "bb" + mPackage;
8
9   mOutputPath = output_path;
10   mVerbose = verbose;
11
12   CreateBlackBox();
13 !!!202754.cpp!!!        CreateBlackBox() : void
14   // Parse XML input file
15   ParseXML();
16   // Create output files
17   CreateHeader();
18   CreateCode();
19 !!!202882.cpp!!!        ParseXML() : void
20   XMLResults* res = new XMLResults;
21   XMLNode BB = XMLNode::parseFile(mFilename.c_str(),"blackbox",res);
22
23   if ( res->error != eXMLErrorNone ) 
24     {
25       std::ostringstream str;
26       str << XMLNode::getError(res->error);
27       str << " [line " << res->nLine << ", col "<<res->nColumn<<"]"; 
28       delete res;
29       throw bbfyException(str.str());
30     }
31   delete res;
32
33   // Name
34   if (!BB.isAttributeSet("name")) 
35     {
36       throw bbfyException("Error : <blackbox> tag : no 'name' attribute found (mandatory)");
37     }
38   mName = BB.getAttribute("name");
39
40   if (mVerbose) std::cout << "* Creating BlackBox '"<<mName<<"'"<<std::endl;
41
42   // Type 
43   mGeneric = false;
44   mType = STD;
45
46
47   if (BB.isAttributeSet("type")) 
48     {
49       std::string bbtype = BB.getAttribute("type");
50       if (bbtype=="standard")
51         {
52           mGeneric = false;
53           mType = STD;
54         }
55       else if (bbtype==itkImageToImageFilterString)
56         {
57           mType = itkImageToImageFilter;
58           // Looks for <itkparent> tag
59           if (!BB.nChildNode("itkparent")) 
60             {
61               throw bbfyException("Error : blackbox type '"+itkImageToImageFilterString+"' but no <itkparent> tag found (mandatory)");
62             }
63           bbtk::GetTextOrClear(BB.getChildNode("itkparent"),mItkParent);
64           // 
65           mGeneric = false;
66           if (BB.isAttributeSet("generic")) mGeneric=true;
67         }
68       else if (bbtype == vtkImageAlgorithmString)
69         {
70           mType = vtkImageAlgorithm;
71           // Looks for <vtkobject> tag
72           if (!BB.nChildNode("vtkobject")) 
73             {
74               throw bbfyException("Error : blackbox type '"
75                                   +vtkImageAlgorithmString
76                                   +"' but no <vtkobject> tag found (mandatory)");
77             }
78           bbtk::GetTextOrClear(BB.getChildNode("vtkobject"),mVtkObject);
79           // 
80         }
81     else if (bbtype == vtkPolyDataAlgorithmString )
82         {
83           mType = vtkPolyDataAlgorithm;
84           // Looks for <vtkobject> tag
85           if (!BB.nChildNode("vtkobject")) 
86             {
87               throw bbfyException("Error : blackbox type '"
88                                   +vtkPolyDataAlgorithmString
89                                   +"' but no <vtkobject> tag found (mandatory)");
90             }
91           bbtk::GetTextOrClear(BB.getChildNode("vtkobject"),mVtkObject);
92           // 
93         }
94      else 
95         {
96           std::string mess("Error : blackbox type '");
97           mess += bbtype;
98           mess += "' unknown. Known types :";
99           mess += "'" + itkImageToImageFilterString + "' ";
100           mess += "'" + vtkImageAlgorithmString + "' ";
101           mess += "'" + vtkPolyDataAlgorithmString + "' ";
102           throw bbfyException(mess);
103         }
104     }
105
106   // Is a widget box ?
107   if (BB.isAttributeSet("widget")) 
108     {
109       mIsWidget = true;
110       mParentBlackBox = "bbtk::WxBlackBox";
111       mInclude.push_back("bbtkWxBlackBox.h");
112     }
113   else 
114     {
115       mIsWidget = false;
116       mParentBlackBox = "bbtk::AtomicBlackBox";
117       mInclude.push_back("bbtkAtomicBlackBox.h");
118     }
119
120   // Author
121   int i,j;
122   for (i=0,j=0; i<BB.nChildNode("author"); i++) 
123     {
124       std::string val;
125       bbtk::GetTextOrClear(BB.getChildNode("author",&j),val);
126       mAuthor += val;
127     }
128
129   // Description
130   for (i=0,j=0; i<BB.nChildNode("description"); i++) 
131     {
132       std::string val;
133       bbtk::GetTextOrClear(BB.getChildNode("description",&j),val);
134       mDescription += val;
135     }
136   
137   // Category
138   for (i=0,j=0; i<BB.nChildNode("category"); i++) 
139     {
140       std::string val;
141       bbtk::GetTextOrClear(BB.getChildNode("category",&j),val);
142       mCategory += val;
143     }
144
145   // Namespace
146   if (BB.nChildNode("namespace"))
147     {
148       bbtk::GetTextOrClear(BB.getChildNode("namespace"),mNamespace);
149     }
150
151   // UserSetDefaultValues body
152   if (BB.nChildNode("defaultValues"))
153     {
154       bbtk::GetTextOrClear(BB.getChildNode("defaultValues"),
155                            mUserSetDefaultValues);
156     }
157     
158   // UserInitializeProcessing body
159   if (BB.nChildNode("initializeProcessing"))
160     {
161       bbtk::GetTextOrClear(BB.getChildNode("initializeProcessing"),
162                            mUserInitializeProcessing);
163     }
164     
165  // UserFinalizeProcessing body
166   if (BB.nChildNode("finalizeProcessing"))
167     {
168       bbtk::GetTextOrClear(BB.getChildNode("finalizeProcessing"),
169                            mUserFinalizeProcessing);
170     }
171
172
173
174      // Template parameters
175   //  mNbTemplateParam = BB.nChildNode("template");
176
177   if ( BB.nChildNode("template") > 0)
178     {
179       mTemplateDeclaration = "<";
180       mTemplateImplementation = "<";
181       
182       for (i=0,j=0; i<BB.nChildNode("template")-1; i++) 
183         {
184           mTemplateDeclaration += "class ";
185           std::string val;
186           bbtk::GetTextOrClear(BB.getChildNode("template",&j),val);
187           mTemplateDeclaration += val;
188           mTemplateDeclaration +=  ",";
189           mTemplateImplementation += val;
190           mTemplateImplementation +=  ",";
191           mTemplateParam.push_back(val);
192         }
193       mTemplateDeclaration += "class ";
194       std::string val;
195       bbtk::GetTextOrClear(BB.getChildNode("template",&j),val);
196       mTemplateDeclaration += val;
197       mTemplateDeclaration +=  ">";
198       mTemplateImplementation += val;
199       mTemplateImplementation +=  ">";
200       mTemplateParam.push_back(val);
201     }
202
203   // Includes 
204   for (i=0,j=0; i<BB.nChildNode("include"); i++) 
205     {
206       std::string val;
207       bbtk::GetTextOrClear(BB.getChildNode("include",&j),val);
208       mInclude.push_back(val);
209     }
210   // Typedef
211   for (i=0,j=0; i<BB.nChildNode("typedef"); i++) 
212     {
213       std::string val;
214       bbtk::GetTextOrClear(BB.getChildNode("typedef",&j),val);
215       mTypedef.push_back(val);
216     }
217   
218   // Inputs
219   for (i=0,j=0; i<BB.nChildNode("input"); i++) 
220     {
221       IO io;
222       XMLNode n = BB.getChildNode("input",&j); 
223       if (!n.isAttributeSet("name"))
224         {
225           throw bbfyException("Error : <input> attribute 'name' not found (mandatory)");
226         }
227       io.name = n.getAttribute("name");
228       if (!n.isAttributeSet("type"))
229         {
230           throw bbfyException("Error : <input name=\""+io.name+"\"> attribute 'type' not found (mandatory)");
231         }
232       io.type = n.getAttribute("type"); 
233       if (!n.isAttributeSet("description"))
234         {
235           throw bbfyException("Error : <input name=\""+io.name+"\"> attribute 'description' not found (mandatory)");
236         }
237       io.descr = n.getAttribute("description"); 
238
239       if (n.isAttributeSet("special")) 
240         {
241           io.special =  n.getAttribute("special");  
242         }
243
244       if (n.isAttributeSet("nature")) 
245         {
246           io.nature =  n.getAttribute("nature");  
247         }
248
249       if (n.isAttributeSet("generic_type")) 
250         {
251           io.generic_type =  n.getAttribute("generic_type");  
252         }
253
254       mInput.push_back(io);
255     }
256   
257   // Outputs
258   for (i=0,j=0; i<BB.nChildNode("output"); i++) 
259     {
260       IO io;
261       XMLNode n = BB.getChildNode("output",&j); 
262       if (!n.isAttributeSet("name"))
263         {
264           throw bbfyException("Error : <output> attribute 'name' not found (mandatory)");
265         }
266       io.name = n.getAttribute("name"); 
267       if (!n.isAttributeSet("type"))
268         {
269           throw bbfyException("Error : <output name=\""+io.name+"\"> attribute 'type' not found (mandatory)");
270         }
271       io.type = n.getAttribute("type"); 
272       if (!n.isAttributeSet("description"))
273         {
274           throw bbfyException("Error : <output name=\""+io.name+"\"> attribute 'description' not found (mandatory)");
275         }
276       io.descr = n.getAttribute("description"); 
277
278       if (n.isAttributeSet("special")) 
279         {
280           io.special =  n.getAttribute("special");  
281         }
282
283       if (n.isAttributeSet("nature")) 
284         {
285           io.nature =  n.getAttribute("nature");  
286         }
287
288       if (n.isAttributeSet("generic_type")) 
289         {
290           io.generic_type =  n.getAttribute("generic_type");  
291         }
292
293       mOutput.push_back(io);
294     }
295
296
297   // Process
298   // process tag given ?
299    if (BB.nChildNode("process"))
300      {
301        bbtk::GetTextOrClear(BB.getChildNode("process"),mProcess);
302      }
303      
304   // CreateWidget
305   // createwidget tag given ?
306    if (BB.nChildNode("createwidget"))
307      {
308        bbtk::GetTextOrClear(BB.getChildNode("createwidget"),mCreateWidget);
309      }
310
311
312
313
314
315
316
317    // OBSOLETE/UNSUPPORTED TAGS
318   // WARN IF OBSOLETE TAGS PROVIDED
319   if (BB.nChildNode("constructor"))
320     {
321       std::cout << "WARNING !!! The tag <constructor> is obsolete !!"<<std::endl;
322     }
323   if (BB.nChildNode("destructor"))
324     {
325       std::cout << "WARNING !!! The tag <destructor> is obsolete !!"<<std::endl;
326     }
327   if (BB.nChildNode("copy_constructor"))
328     {
329       std::cout << "WARNING !!! The tag <copy_constructor> is obsolete !!"<<std::endl;
330     }
331
332
333
334 !!!203010.cpp!!!        CreateHeader() : void
335
336   mHName = "bb";
337   mHName += mPackage;
338   mHName += mName;
339   mHName += ".h";
340   if (mVerbose) std::cout << " - Creating header '"<<mHName<<"'"<<std::endl;
341   std::string fullname = mOutputPath + mHName;
342   mFile.open(fullname.c_str());
343   if (!mFile.good())
344     {
345       std::string mess("Error : could not open file \"");
346       mess += fullname + "\"";
347       throw bbfyException(mess);
348     }
349   
350   // If is widget 
351   if (mIsWidget)
352     {
353       mFile << "#ifdef _USE_WXWIDGETS_\n";
354     }
355
356   // Prevent multiple inclusions
357   std::string included("__bb");
358   included += mPackage + mName + "_h_INCLUDED__";
359   mFile << "#ifndef " << included <<"\n";
360   mFile << "#define " << included <<"\n";
361
362   // Includes 
363   mFile << "#include \"bb" << mPackage << "_EXPORT.h\"\n";
364   std::vector<std::string>::iterator i;
365   for (i=mInclude.begin(); i!=mInclude.end(); ++i) 
366     {
367       mFile << "#include \"" << *i <<"\"\n";
368     }
369   if (mGeneric) mFile << "#include \"bbitkImage.h\"\n";
370   mFile << "\n";
371
372   if (mType == itkImageToImageFilter )
373     {
374       mFile << "#include \"bbtkItkBlackBoxMacros.h\"\n";
375     }
376   else if ( (mType == vtkImageAlgorithm) ||
377             (mType == vtkPolyDataAlgorithm) )
378     {
379       mFile << "#include \"bbtkVtkBlackBoxMacros.h\"\n";
380     }
381   // Namespace
382   BeginNamespace();
383
384   // Interface
385
386   // If it is a template class
387   if (mTemplateParam.size() > 0)
388     {
389       mFile << "template " << mTemplateDeclaration <<"\n";
390     }
391   
392   // Class declaration and parents
393   mFile << "class bb"<<mPackage<<"_EXPORT "<<mName<<"\n";
394   mFile << " : \n";
395
396   /*
397   if (mBB.nChildNode("inherits"))
398     {
399       mFile << ",\n";
400       for (i=0,j=0; i<mBB.nChildNode("inherits")-1; i++) 
401         {
402           mFile << "   public " 
403                 << mBB.getChildNode("inherits",&j).getText()
404                 << ",\n";
405         }
406       mFile << "   public " 
407             << mBB.getChildNode("Inherits",&j).getText()
408             <<"\n";
409     }
410   */
411
412   if (mType == itkImageToImageFilter )
413     {
414       mFile << "   public " << mItkParent <<",\n";
415     }
416
417   mFile << "   public "<<mParentBlackBox << "\n";
418
419   mFile << "{\n";
420
421   // Interface
422
423   // ITK 
424   if (mType == itkImageToImageFilter)
425     {
426       mFile << "  BBTK_ITK_BLACK_BOX_INTERFACE("
427             << mName << ","
428             << mParentBlackBox << ","
429             << mItkParent 
430             << ");\n";
431     }
432   // VTK
433   else if ( (mType == vtkImageAlgorithm) ||
434        (mType == vtkPolyDataAlgorithm) )
435     {
436       mFile << "  BBTK_VTK_BLACK_BOX_INTERFACE("
437             << mName << ","
438             << mParentBlackBox << ","
439             << mVtkObject
440             << ");\n";
441     }
442         
443   // Default
444   else 
445     {
446       mFile << "  BBTK_BLACK_BOX_INTERFACE("
447             << mName << ","
448             << mParentBlackBox << ");\n";
449     }
450
451   for (i=mTypedef.begin(); i!=mTypedef.end(); ++i) 
452     {
453       mFile << *i <<"\n";
454     }
455
456
457
458   // Inputs
459   std::vector<IO>::iterator ioi;
460   for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi) 
461     {
462       if (ioi->special=="") 
463         {
464           mFile << "  BBTK_DECLARE_INPUT(" 
465                 << ioi->name
466                 << ","
467                 << ioi->type
468                 << ");\n";
469         }
470       else if (ioi->special=="itk input")
471         {
472           mFile << "  BBTK_DECLARE_ITK_INPUT(" 
473                 << ioi->name
474                 << ","
475                 << ioi->type
476                 << ");\n";
477         }
478       else if (ioi->special=="vtk input")
479         {
480           if (mType == vtkImageAlgorithm) {
481           mFile << "  BBTK_DECLARE_VTK_IMAGE_ALGORITHM_INPUT(" 
482                 << ioi->name
483                 << ","
484                 << ioi->type
485                 << ");\n";
486           } 
487           else if (mType == vtkPolyDataAlgorithm) {
488           mFile << "  BBTK_DECLARE_POLY_DATA_ALGORITHM_INPUT(" 
489                 << ioi->name
490                 << ","
491                 << ioi->type
492                 << ");\n";
493           }
494         }
495       else if (ioi->special=="itk parameter")
496         {
497           mFile << "  BBTK_DECLARE_ITK_PARAM(" 
498                 << ioi->name
499                 << ","
500                 << ioi->type
501                 << ");\n";
502         }
503       else if (ioi->special=="vtk parameter")
504         {
505           mFile << "  BBTK_DECLARE_VTK_PARAM(" 
506                 << ioi->name
507                 << ","
508                 << ioi->type
509                 << ");\n";
510         }
511       else 
512         {
513           std::string mess("Error : input '");
514           mess += ioi->name;
515           mess += "', 'special' attribute '";
516           mess += ioi->special;
517           mess += "' unknown";
518           throw bbfyException(mess);
519         }
520     }
521   
522   // Outputs
523   for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi) 
524     {
525       if (ioi->special=="") 
526         {
527           mFile << "  BBTK_DECLARE_OUTPUT(" 
528                 << ioi->name
529                 << ","
530                 << ioi->type
531                 << ");\n";
532         }
533       else if (ioi->special=="itk output")
534         {
535           mFile << "  BBTK_DECLARE_ITK_OUTPUT(" 
536                 << ioi->name
537                 << ","
538                 << ioi->type
539                 << ");\n";
540         }  
541       else if (ioi->special=="vtk output")
542         {
543           mFile << "  BBTK_DECLARE_VTK_OUTPUT(" 
544                 << ioi->name
545                 << ","
546                 << ioi->type
547                 << ");\n";
548         }  
549       else 
550         {
551           std::string mess("Error : output '");
552           mess += ioi->name;
553           mess += "', 'special' attribute '";
554           mess += ioi->special;
555           mess += "' unknown";
556           throw bbfyException(mess);
557         }
558     }
559   
560   // Process
561   if ((mType == STD)||(mProcess.size()))
562     {
563       mFile << "  BBTK_PROCESS(Process);\n" ;
564       mFile << "  void Process();\n";
565     }
566   else if (mType == itkImageToImageFilter)
567     {   
568       mFile << "  BBTK_ITK_PROCESS();\n" ;
569     }
570   else if ((mType == vtkImageAlgorithm) ||
571            (mType == vtkPolyDataAlgorithm) )
572
573     {   
574       mFile << "  BBTK_VTK_PROCESS();\n" ;
575     }
576
577   // CreateWidget
578   if (mIsWidget) 
579     {
580        mFile << "  BBTK_CREATE_WIDGET(CreateWidget);\n" ;
581        mFile << "  void CreateWidget(wxWindow*);\n";
582     }
583
584
585   // EO black box declaration
586   mFile << "};\n\n";
587
588   // BO black box description
589   if (mTemplateParam.size()==0)
590     {
591       mFile << "BBTK_BEGIN_DESCRIBE_BLACK_BOX("
592             << mName << ","
593             << mParentBlackBox << ");\n";
594       mFile << "BBTK_NAME(\"" << mName <<"\");\n";
595     }
596   else if (mTemplateParam.size()==1)
597     {
598       mFile << "BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX("
599             << mName //<< ","
600         //<< mParentBlackBox //<< ","
601         //   << mTemplateParam[0] 
602             << ");\n";
603       mFile << "BBTK_NAME(\"" << mName 
604             << "<\"+bbtk::TypeName<" << mTemplateParam[0]
605             <<">()+\">\");\n";
606     }
607  else 
608     {
609       throw bbfyException("template bb with more than 1 templ param not impl");
610     } 
611   
612   // Author
613   mFile << "BBTK_AUTHOR(\""<<mAuthor<< "\");\n";
614
615   // Description
616   mFile << "BBTK_DESCRIPTION(\""<<mDescription<< "\");\n"; 
617   
618   // Category
619   mFile << "BBTK_CATEGORY(\""<<mCategory<< "\");\n"; 
620
621   for (i=mTypedef.begin(); i!=mTypedef.end(); ++i) 
622     {
623       mFile << *i <<"\n";
624     }
625   
626   // Inputs
627   for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi) 
628     {
629       if (mTemplateParam.size()>0)
630         {
631           mFile << "BBTK_TEMPLATE_INPUT(";
632         } 
633       else 
634         {
635           mFile << "BBTK_INPUT(";
636         } 
637       mFile << mName << "," << ioi->name << ",\""
638             << ioi->descr << "\"," <<  ioi->type << ",\"" 
639             << ioi->nature<<"\");\n";
640     }
641   
642   // Outputs
643   for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi) 
644     {
645       if (mTemplateParam.size()>0)
646         {
647           mFile << "BBTK_TEMPLATE_OUTPUT(";
648         } 
649       else 
650         {
651           mFile << "BBTK_OUTPUT(";
652         } 
653       mFile << mName << "," << ioi->name << ",\""
654             << ioi->descr << "\"," <<  ioi->type << ",\"" 
655             << ioi->nature<<"\");\n";
656     }
657   
658   // EO black box description
659   if (mTemplateParam.size()==0)
660     {
661       mFile << "BBTK_END_DESCRIBE_BLACK_BOX("
662             << mName << ");\n";
663     }
664   else if (mTemplateParam.size()==1)
665     {
666       mFile << "BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX("
667             << mName //<< ","
668         // << mTemplateParam[0] 
669             << ");\n";
670     }
671   else 
672     {
673       throw bbfyException("template bb with more than 1 templ param not impl");
674      
675     } 
676   
677   // Untemplatization of itk filters
678   if ( mGeneric )
679     {
680       WriteGenericITKFilterHeader();
681     }
682
683
684   // EO namespace
685   EndNamespace();
686   
687   // Prevent multiple inclusions
688   mFile << "#endif // " << included <<"\n";
689   // If is widget 
690   if (mIsWidget)
691     {
692       mFile << "#endif // _USE_WXWIDGETS_\n";
693     }
694
695   // EOF
696   mFile << "\n";
697
698   mFile.close();
699 !!!203138.cpp!!!        CreateCode() : void
700   mCxxName = "bb";
701   mCxxName += mPackage;
702   mCxxName += mName;
703   mCxxName += ".cxx";
704   if (mVerbose) std::cout << " - Creating code   '"<<mCxxName<<"'"<<std::endl;
705   std::string fullname = mOutputPath + mCxxName;
706   mFile.open(fullname.c_str());
707   if (!mFile.good()) 
708     {
709       std::string mess("Error : could not open file \"");
710       mess += fullname;
711       mess += "\"";
712       throw bbfyException(mess);
713     }
714   
715   // Includes
716   // Header of the class
717   mFile << "#include \"" << mHName << "\"\n";
718
719   // Include Package header
720   mFile << "#include \"bb"<<mPackage << "Package.h\"\n";
721
722   // BO namespace
723   BeginNamespace();
724  
725   
726   // Template class ?
727   if (mTemplateParam.size()>0) 
728     {
729       // Implementation
730       mFile << "BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION("
731             << mName << ","  
732             << mParentBlackBox << ");\n";
733      
734       if (mGeneric) 
735         {       
736           // Implementation
737           mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
738                 << mName << "Generic,bbtk::AtomicBlackBox);\n";
739           // Package
740           mFile << "BBTK_ADD_BLACK_BOX_TO_PACKAGE("
741                 << mPackage << ","
742                 << mName << "Generic)\n";
743         }
744     }
745   else 
746     {
747       // Non template class
748       // Package
749       mFile << "BBTK_ADD_BLACK_BOX_TO_PACKAGE("
750             << mPackage << ","
751             << mName << ")\n";
752
753       // Implementation
754       mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
755             << mName << ","  
756             << mParentBlackBox << ");\n"; 
757     }
758   // Process
759   if ((mType == STD)||(mProcess.size()))
760     {
761       mFile << "void "<<mName<<"::Process()\n{\n";
762       mFile << mProcess << "\n";
763       mFile << "}\n";
764     }
765   // CreateWidget
766   if (mIsWidget)
767     {
768       mFile << "void "<<mName<<"::CreateWidget(wxWindow* parent)\n{\n";
769       mFile << mCreateWidget << "\n";
770       mFile << "}\n";
771     }
772
773                 
774   // User Set Default Values  
775   mFile <<"void "<<mName<<"::bbUserSetDefaultValues()"<<std::endl;
776   mFile << "{"<<std::endl;  
777         if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
778         {
779                 mFile << "   BBTK_VTK_SET_DEFAULT_VALUES();\n";
780         }
781         mFile << mUserSetDefaultValues << std::endl;
782   mFile << "}" << std::endl;
783
784   // User Initialize Processing
785   mFile <<"void "<<mName<<"::bbUserInitializeProcessing()"
786         <<std::endl;
787   mFile << "{"<<std::endl;
788         if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
789         {
790                 mFile <<  "  BBTK_VTK_INITIALIZE_PROCESSING();\n";
791         }
792         mFile << mUserInitializeProcessing << std::endl;
793   mFile << "}" << std::endl;
794
795         // User Finalize Processing
796   mFile <<"void "<<mName<<"::bbUserFinalizeProcessing()"<<std::endl;
797   mFile << "{"<<std::endl;
798         if ( (mType == vtkImageAlgorithm) || (mType == vtkPolyDataAlgorithm) )
799         {
800                 mFile << "   BBTK_VTK_FINALIZE_PROCESSING();\n";
801         }
802         mFile << mUserFinalizeProcessing << std::endl;
803   mFile << "}" << std::endl;
804
805
806   // EO namespace
807   EndNamespace();
808
809   mFile << "\n";
810   
811   // EOF
812   mFile.close();
813   
814 !!!203266.cpp!!!        WriteGenericITKFilterHeader() : void
815   mFile << "\n//===================================================\n";
816   mFile << "// Generic \"untemplatized\" filter\n";
817   mFile << "//===================================================\n";
818
819   // Class declaration and parents
820   mFile << "class /*BBTK_EXPORT*/ "<<mName<<"Generic\n";
821   mFile << " : \n";
822   mFile << "   public bbtk::AtomicBlackBox\n";
823   mFile << "{\n";
824
825   // Interface
826   mFile << "  BBTK_BLACK_BOX_INTERFACE("
827         << mName << "Generic,bbtk::AtomicBlackBox);\n";
828
829   // Inputs
830   std::vector<IO>::iterator ioi;
831   for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi) 
832     {
833       mFile << "  BBTK_DECLARE_INPUT(" 
834             << ioi->name
835             << ","
836             << ioi->generic_type
837             << ");\n";
838     }
839   
840   // Outputs
841   for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi) 
842     {
843       mFile << "  BBTK_DECLARE_OUTPUT(" 
844             << ioi->name
845             << ","
846             << ioi->generic_type
847             << ");\n";
848     }
849     
850   // Process
851   mFile << "  BBTK_PROCESS(ProcessSwitch);\n";
852   mFile << "  private :\n";
853   mFile << "    inline void ProcessSwitch();\n";
854   mFile << "    template <class T, unsigned int D> void Process();\n";
855   // EO black box declaration
856   mFile << "};\n\n";
857
858
859
860   // BO black box description
861   mFile << "BBTK_BEGIN_DESCRIBE_BLACK_BOX("
862         << mName << "Generic,bbtk::AtomicBlackBox);\n";
863   mFile << "BBTK_NAME(\"" << mName <<"\");\n";
864
865   // Author
866   mFile << "BBTK_AUTHOR(\""<<mAuthor<< "\");\n";
867
868   // Description
869   mFile << "BBTK_DESCRIPTION(\""<<mDescription<< "\");\n"; 
870   
871   // Inputs
872   for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi) 
873     {
874       mFile << "BBTK_INPUT(";
875       mFile << mName << "Generic," << ioi->name << ",\""
876             << ioi->descr << "\"," <<  ioi->generic_type <<");\n";
877     }
878   
879   // Outputs
880   for (ioi=mOutput.begin(); ioi!=mOutput.end(); ++ioi) 
881     {
882       mFile << "BBTK_OUTPUT(";
883       mFile << mName << "Generic," << ioi->name << ",\""
884             << ioi->descr << "\"," <<  ioi->generic_type <<");\n";
885     }
886   
887   // EO black box description
888   mFile << "BBTK_END_DESCRIBE_BLACK_BOX("
889         << mName << "Generic);\n";
890
891
892   //=================================================================
893   // ProcessSwitch implementation
894   mFile << "void "<< mName <<"Generic::ProcessSwitch()\n"
895         << "{\n"
896         << "CALL_FOR_ALL_TYPES_AND_DIM(bbGetInputIn()->GetType(),\n"
897         << "                           bbGetInputIn()->GetDimension(),\n"
898         << "                           Process);\n"
899         << "}\n";
900   //=================================================================
901
902
903   //=================================================================
904   // Template process implementation
905   mFile << "template <class T, unsigned int D>\n"
906         << "void "<<mName<<"Generic::Process()\n"
907         << "{\n"
908         << "  bbtkDebugMessageInc(\"Kernel\",9,\n"
909         << "      \""<<mName 
910         << "Generic::Process<\"<<TypeName<T>()<<\",\"<<D<<\">()\"<<std::endl);\n"
911     
912         << "  typedef itk::Image<T,D> ImageType;\n"
913         << "  typedef "<<mName<<"<ImageType> FilterType;\n"
914     
915         << "  FilterType* f = new FilterType(\"Temp\");\n"
916     
917         << "  f->bbSetInputIn( this->bbGetInputIn()->GetImage<T,D>() );\n";
918   
919   for (ioi=mInput.begin(); ioi!=mInput.end(); ++ioi) 
920     {
921       if (ioi->name == "In") continue;
922       mFile << "  f->bbSetInput"<<ioi->name<<" ( this->bbGetInput" 
923             << ioi->name << "() );\n";
924     }
925   
926   mFile << "  f->bbUpdate();\n"
927         << "  this->bbSetOutputOut( new itkImage( f->bbGetOutputOut() ) );\n"
928         << "  f->UnRegister();\n"
929         << "  bbtkDebugDecTab(\"Kernel\",9);\n"
930         << "}\n\n";
931   //=================================================================
932
933
934 !!!203394.cpp!!!        BeginNamespace() : void
935   //  if (mIsInNamespace)
936   // {
937   mFile << "namespace "<<mNamespace <<"\n{\n\n";
938   //  }
939 !!!203522.cpp!!!        EndNamespace() : void
940   // if (mIsInNamespace)
941   //  {
942   mFile << "}\n// EO namespace "<<mNamespace<<"\n\n";
943   //  }