X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkComplexBlackBox.cxx;h=c07ba9f383b74ef805b56f208243c17ce8aadb51;hb=7a86b21a88862240b2b56d165433cbcbb50ab316;hp=840c596091e0c1e404355089e7a05c7c6088fe13;hpb=d7a6d341e2d11c175351212f0bf4812784dc57e5;p=bbtk.git diff --git a/kernel/src/bbtkComplexBlackBox.cxx b/kernel/src/bbtkComplexBlackBox.cxx index 840c596..c07ba9f 100644 --- a/kernel/src/bbtkComplexBlackBox.cxx +++ b/kernel/src/bbtkComplexBlackBox.cxx @@ -1,29 +1,48 @@ +/* + # --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la SantÈ) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + + /*========================================================================= - -Program: bbtk -Module: $RCSfile: bbtkComplexBlackBox.cxx,v $ -Language: C++ -Date: $Date: 2008/04/22 06:59:31 $ -Version: $Revision: 1.13 $ - -Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de -l'Image). All rights reserved. See Doc/License.txt or -http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. - -This software is distributed WITHOUT ANY WARRANTY; without even -the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR -PURPOSE. See the above copyright notices for more information. - + Program: bbtk + Module: $RCSfile: bbtkComplexBlackBox.cxx,v $ + Language: C++ + Date: $Date: 2012/11/16 08:49:01 $ + Version: $Revision: 1.33 $ =========================================================================*/ + /** * \file * \brief class bbtk::ComplexBlackBox : user defined complex black boxes */ #include "bbtkComplexBlackBox.h" -#include "bbtkBlackBoxDescriptor.h" -#include "bbtkFactory.h" +#include "bbtkWx.h" +//#include "bbtkBlackBoxDescriptor.h" +//#include "bbtkFactory.h" #include "bbtkConfigurationFile.h" namespace bbtk @@ -34,12 +53,9 @@ namespace bbtk ComplexBlackBox::Pointer ComplexBlackBox::New(const std::string& name, ComplexBlackBoxDescriptor::Pointer desc) { - bbtkDebugMessage("object",1,"##> ComplexBlackBox::New('"<GetTypeName()<<"')" <GetTypeName()<<"')" < ComplexBlackBox::New('"<GetTypeName()<<"')" <GetTypeName()<<"')" < ComplexBlackBox::ComplexBlackBox(\"" + bbtkBlackBoxDebugMessage("object",3, + "##> ComplexBlackBox(\"" < ComplexBlackBox::ComplexBlackBox(\"" + bbtkBlackBoxDebugMessage("object",3, + "##> ComplexBlackBox(\"" <first<<"\""<first<<"\""<second->bbClone(i->second->bbGetName()); bbUnsafeAddBlackBox(B); - } - bbtkDebugMessage("object",4," * Cloning Connections"<GetFullName()<<"\""<GetOriginalBlackBoxFrom()->bbGetName() ); @@ -110,8 +130,8 @@ namespace bbtk } bbAllocateConnectors(); - bbtkDebugMessage("object",3, - "<## ComplexBlackBox::ComplexBlackBox(\"" + bbtkBlackBoxDebugMessage("object",3, + "<## ComplexBlackBox(\"" < ComplexBlackBox::~ComplexBlackBox() [" - < ~ComplexBlackBox()" + <bbDesallocateConnectors(); + + bbtkBlackBoxDebugMessage("object",3, + "<== ~ComplexBlackBox()" + < ComplexBlackBox::Clear()" + < Releasing connections"< Releasing boxes"<bbDesallocateConnectors(); - if (mLockedDescriptor) - { - bbtkMessage("object",3," --> Releasing descriptor"< ComplexBlackBox::bbAllocateConnectors()" <GetInputDescriptorMap(); BlackBoxDescriptor::InputDescriptorMapType::const_iterator i; for ( i = imap.begin(); i != imap.end(); ++i ) { - bbtkDebugMessage("Kernel",8,"* Allocate \""<first<<"\""<first<<"\""<bbGetInputConnectorMap()[ d->GetInput() ]; bbGetInputConnectorMap()[i->second->GetName()] = c; -//new BlackBoxInputConnector(); } // Output connectors @@ -184,7 +209,7 @@ namespace bbtk BlackBoxDescriptor::OutputDescriptorMapType::const_iterator o; for ( o = omap.begin(); o != omap.end(); ++o ) { - bbtkDebugMessage("Kernel",8,"* Allocate \""<first<<"\""<first<<"\""<bbGetOutputConnectorMap()[ d->GetOutput() ]; bbGetOutputConnectorMap()[o->second->GetName()] = c; - //new BlackBoxOutputConnector(); } - -*/ - - bbtkDebugDecTab("Kernel",8); - } + bbtkBlackBoxDebugMessage("kernel",8, + "<== ComplexBlackBox::bbAllocateConnectors()" + < ComplexBlackBox::DesallocateConnectors()" < ComplexBlackBox::bbClone(\""< ComplexBlackBox::bbExecute()" + < Executing '"<<*i<<"'"< Executing '"<<*i<<"'"<bbExecute(force); } } @@ -271,110 +298,23 @@ namespace bbtk i->second->bbExecute(force); } } - - Wx::EndBusyCursor(); + bbtkBlackBoxDebugMessage("process",2, + "<** ComplexBlackBox::bbExecute()" + <GetBlackBox()->bbSetModifiedStatus(c); - - bbtkDebugMessage("Process",3, - "EO ComplexBlackBox::bbSetModifiedStatus(" - <GetFullName():"0")<<") [" - <GetBlackBoxFrom()->bbGetFullName() - <<"."<GetBlackBoxFromOutput()<<"----" - <GetOriginalBlackBoxFrom()->bbGetFullName() - <<"."<GetOriginalBlackBoxFromOutput()<GetOutputDescriptorMap(); - BlackBoxDescriptor::OutputDescriptorMapType::const_iterator i - = omap.find(caller->GetBlackBoxFromOutput()); - if (i!=omap.end()) - { - // Cast the BBOutputDescriptor into a ComplexBBOutputDescriptor - ComplexBlackBoxOutputDescriptor* d = - (ComplexBlackBoxOutputDescriptor*)i->second; - // Get the internal box - BlackBox::Pointer b = bbUnsafeGetBlackBox ( d->GetTarget() ); - // Calls BackwardUpdate on it - bbtkDebugMessageInc("Process",2,"Internal box connected to output : "<GetTarget()<GetBlackBoxFromOutput(); - // std::cout << "oldout = "<GetFullName()<<"' does not point to a valid output of the complex box !"); - } - bbtkDebugDecTab("Process",1); - - return s; } //================================================================== @@ -383,9 +323,9 @@ namespace bbtk //================================================================== Data ComplexBlackBox::bbGetOutput( const std::string &name ) { - bbtkDebugMessageInc("Data",7, - "ComplexBlackBox::bbGetOutput(\""<GetTarget())->bbGetOutput(d->GetOutput()); - - bbtkDebugDecTab("Data",7); return p; } //================================================================== @@ -403,9 +341,9 @@ namespace bbtk /// Gets the input Data of a given name Data ComplexBlackBox::bbGetInput( const std::string &name ) { - bbtkDebugMessageInc("Data",7, - "ComplexBlackBox::bbGetInput(\""<GetTarget())->bbGetInput(d->GetInput()); - bbtkDebugDecTab("Data",7); return p; } //================================================================== @@ -422,9 +359,9 @@ namespace bbtk /// Sets the data of the output called void ComplexBlackBox::bbSetOutput( const std::string &name, Data data) { - bbtkDebugMessageInc("Data",7, - "ComplexBlackBox::bbSetOutput(\""<GetTarget())->bbSetOutput(d->GetOutput(),data); - bbtkDebugDecTab("Data",7); } //================================================================== @@ -441,16 +377,15 @@ namespace bbtk void ComplexBlackBox::bbSetInput( const std::string &name, Data data, bool setModified) { - bbtkDebugMessageInc("Data",7, - "ComplexBlackBox::bbSetInput(\""<GetInputDescriptor(name); bbGetBlackBox(d->GetTarget())->bbSetInput(d->GetInput(),data,setModified); - bbtkDebugDecTab("Data",7); } //================================================================== @@ -461,10 +396,10 @@ namespace bbtk void* data, bool setModified) { - bbtkDebugMessageInc("Data",7, + bbtkBlackBoxDebugMessage("data",7, "ComplexBlackBox::bbBruteForceSetInputPointer('" - <GetInputDescriptor(name); @@ -473,18 +408,16 @@ namespace bbtk data, setModified); - bbtkDebugDecTab("Data",7); } //================================================================== //========================================================================= /// Connects the input to the connection c - void ComplexBlackBox::bbConnectInput( const std::string& name, Connection::Pointer c) + void ComplexBlackBox::bbConnectInput( const std::string& name, Connection* c) { - bbtkDebugMessage("connection",2, + bbtkBlackBoxDebugMessage("connection",2, "==> ComplexBlackBox::bbConnectInput(\"" - <GetFullName()<<") [" - <GetFullName()<<")" <GetTarget()); - bbtkDebugMessage("connection",2," - Target = "<GetTarget()<<" = "<bbGetFullName()<bbGetFullName()<SetBlackBoxTo(t); c->SetBlackBoxToInput(d->GetInput()); - bbtkDebugMessage("connection",2," - New conn = "<GetFullName()<GetFullName()<<") [" - <GetFullName()<<")" < to the connection c - void ComplexBlackBox::bbConnectOutput( const std::string& name, Connection::Pointer c) + void ComplexBlackBox::bbConnectOutput( const std::string& name, Connection* c) { - bbtkDebugMessage("connection",2, + bbtkBlackBoxDebugMessage("connection",2, "==> ComplexBlackBox::bbConnectOutput(\"" - <GetFullName()<<") [" - <GetFullName()<<")" + <GetOutputDescriptor(name); BlackBox::Pointer t = bbGetBlackBox(d->GetTarget()); - bbtkDebugMessage("connection",2," - Target = "<GetTarget()<<" = "<bbGetFullName()<bbGetFullName()<SetBlackBoxFrom(t); c->SetBlackBoxFromOutput(d->GetOutput()); - bbtkDebugMessage("connection",2," - New conn = "<GetFullName()<GetFullName()<<") [" - <GetFullName()<<")" + <bbGetName() - <<"\") [" - <bbGetName() + <<"\")" + <bbGetName()) ) { @@ -558,7 +490,6 @@ namespace bbtk b->bbSetParent(GetThisPointer()); mBlackBoxMap[b->bbGetName()] = b; - bbtkDebugDecTab("Kernel",7); } //================================================================== @@ -566,15 +497,14 @@ namespace bbtk /// Adds the black box to the complex box (unsafe) void ComplexBlackBox::bbUnsafeAddBlackBox( BlackBox::Pointer b) { - bbtkDebugMessageInc("Kernel",7, + bbtkBlackBoxDebugMessage("kernel",7, "ComplexBlackBox::UnsafeAddBlackBox(\""<bbGetName() - <<"\") [" - <bbSetParent(GetThisPointer()); mBlackBoxMap[b->bbGetName()] = b; - bbtkDebugDecTab("Kernel",7); } //================================================================== @@ -583,9 +513,9 @@ namespace bbtk void ComplexBlackBox::bbRemoveBlackBox( const std::string& name, bool remove_connections ) { - bbtkDebugMessageInc("Kernel",7, - "ComplexBlackBox::RemoveBlackBox(\""< BlackBox::Pointer ComplexBlackBox::bbGetBlackBox( const std::string& name ) { - bbtkDebugMessageInc("Kernel",9, - "ComplexBlackBox::GetBlackBox(\""<second; } //================================================================== @@ -657,19 +582,16 @@ namespace bbtk /// if it does not exist but return a null pointer BlackBox::Pointer ComplexBlackBox::bbUnsafeGetBlackBox( const std::string& name ) { - bbtkDebugMessageInc("Kernel",9, - "ComplexBlackBox::UnsafeGetBlackBox(\""<second; } @@ -678,18 +600,16 @@ namespace bbtk //================================================================== void ComplexBlackBox::bbPrintBlackBoxes() { - bbtkDebugMessageInc("Kernel",9, - "ComplexBlackBox::PrintBlackBoxes() [" - <second->bbGetFullName()<second->bbGetFullName()<\n\n"; // End @@ -1042,21 +977,21 @@ namespace bbtk { if (ii->second) { - Connection::Pointer con = ii->second->GetConnection(); + Connection* con = ii->second->GetConnection(); if (con!=NULL){ - BlackBox::Pointer a=con->GetBlackBoxFrom(); - BlackBox::Pointer b=con->GetBlackBoxTo(); + BlackBox::Pointer a=con->GetOriginalBlackBoxFrom(); + BlackBox::Pointer b=con->GetOriginalBlackBoxTo(); fprintf(ff," "); a->bbWriteDotInputOutputName(ff,false,detail,level); if (detail==1) { - fprintf(ff,":%s",con->GetBlackBoxFromOutput().c_str()); + fprintf(ff,":%s",con->GetOriginalBlackBoxFromOutput().c_str()); } fprintf(ff,"->"); b->bbWriteDotInputOutputName(ff,true,detail,level); if (detail==1) { - fprintf(ff,":%s",con->GetBlackBoxToInput().c_str()); + fprintf(ff,":%s",con->GetOriginalBlackBoxToInput().c_str()); } fprintf(ff,"%s\n",";"); } // if con @@ -1090,7 +1025,7 @@ namespace bbtk //======================================================================= void ComplexBlackBox::Check(bool recursive) { - bbtkMessage("Debug",1,"**** Checking Complex Black Box "<<(void*)this + bbtkMessage("debug",1,"**** Checking Complex Black Box "<<(void*)this <<" ["<Check(); + (*j)->Check(); } - bbtkMessage("Debug",1,"**** Checking Complex Black Box "<<(void*)this + bbtkMessage("debug",1,"**** Checking Complex Black Box "<<(void*)this <<" ["<second->GetObjectRecursiveSize(); + s += i->second->GetObjectRecursiveSize(); } ConnectionListType::const_iterator j; for ( j = mConnectionList.begin(); j != mConnectionList.end(); ++j ) { - s += (*j)->GetObjectRecursiveSize(); + s += (*j)->GetObjectRecursiveSize(); } return s; }