#include <set>
// Signal/slot mechanism for output change events
-#include <boost/signal.hpp>
+#include <boost/signals2/signal.hpp>
#include <boost/bind.hpp>
//==================================================================
// Types
//==================================================================
- typedef boost::signals::trackable OutputChangeObserverType;
- typedef boost::signal<void (bbtk::BlackBox::Pointer,
+ typedef boost::signals2::trackable OutputChangeObserverType;
+ typedef boost::signals2::signal<void (bbtk::BlackBox::Pointer,
const std::string&,
IOStatus)> OutputChangeSignalType;
typedef OutputChangeSignalType::slot_function_type
#include <fstream>
#include <deque>
-// Signal/slot mechanism for 'break' commands
-//#include <boost/signal.hpp>
-//#include <boost/bind.hpp>
namespace bbtk
{
class WxConsole;
#endif
-/* EED Borrame
- //=======================================================================
- class BBTK_EXPORT InterpreterUser
- {
- public:
- InterpreterUser() {}
- virtual ~InterpreterUser() {}
-
- virtual bool InterpreterUserHasOwnHtmlPageViewer() { return false; }
- virtual void InterpreterUserViewHtmlPage(const std::string&) {}
- };
- //=======================================================================
-*/
-/* EED Borrame
- //=======================================================================
- class BBTK_EXPORT InterpreterException : public Exception
- {
- public:
- InterpreterException( const std::string& message,
- bool in_script_file,
- const std::string& script_file,
- int script_line
- );
- InterpreterException( const Exception& excep,
- bool in_script_file,
- const std::string& script_file,
- int script_line
- );
- ~InterpreterException() throw() {}
-
- bool IsInScriptFile() const { return mInScriptFile; }
- const std::string& GetScriptFile() const { return mScriptFile; }
- int GetScriptLine() const { return mScriptLine; }
- private:
- bool mInScriptFile;
- std::string mScriptFile;
- int mScriptLine;
- };
- //=======================================================================
-*/
-
- /*
- //=======================================================================
- // The "Quit" exception
- class BBTK_EXPORT QuitException : public InterpreterError
- {
- public:
- QuitException( bool in_script_file,
- const std::string& script_file,
- int script_line
- )
- : InterpreterError("QUIT",in_script_file,script_file,script_line)
- {}
- ~QuitException() throw() {}
- };
- //=======================================================================
- const std::string BREAK("BREAK");
- //=======================================================================
- // The "Break" exception
- class BBTK_EXPORT BreakException : public InterpreterError
- {
- public:
- BreakException( bool in_script_file,
- std::string script_file,
- int script_line
- )
- : InterpreterError(BREAK,in_script_file,script_file,script_line)
- { std::cout << "BUILDING BREAK"<<std::endl; }
- ~BreakException() throw() {}
- };
- //=======================================================================
- */
//=======================================================================
class BBTK_EXPORT Interpreter : public InterpreterVirtual
static Pointer New(const std::string& cpp_file = "");
static Pointer New(VirtualExec::Pointer);
-/* EED Borrame
- typedef enum
- {
- Interpreter_OK,
- Interpreter_ERROR,
- Interpreter_QUIT,
- Interpreter_BREAK,
- }
- ExitStatus;
-
- /// Runs the interpretation of a file
- ExitStatus InterpretFile( const std::string& filename, bool source = false);
-
- /// Runs the interpretation of a buffer and deletes it !
- ExitStatus InterpretBuffer( std::stringstream* buffer );
-
- /// Runs the interpretation of a command
- ExitStatus InterpretLine( const std::string& line );
-
- /// Runs the interpretation of the currently open streams
- ExitStatus InterpretCurrentStreams();
-
- /// Launches a command line interpreter (with a prompt)
- void CommandLineInterpreter();
-*/
-
/// Sets the inputs of the workspace :
/// the map is passed as is to the Executer
void SetDialogMode(DialogModeType t) { mVirtualExecuter->SetDialogMode(t);}
-/*EED Borrame
- /// Sets the bool that indicates wether we are in command line context
- void SetCommandLine(bool v = true) { mCommandLine = v; }
-
- void SetThrow(bool b) { mThrow = b; }
-
-#ifdef USE_WXWIDGETS
- /// Sets the user of the interpreter (if any)
- void SetUser(InterpreterUser* c) { mUser = c; }
- /// Gets the InterpreterUser of this
- InterpreterUser* GetUser() { return mUser; }
- /// Gets the InterpreterUser of this (const)
- const InterpreterUser* GetUser() const { return mUser; }
-
-#endif
- */
/// Gets the Executer
VirtualExec::Pointer GetExecuter() const { return mVirtualExecuter; }
protected:
-/* EED Borrame
- /// The enumeration of command codes == Command name
- typedef enum
- {
- cBreak, // LG 12/12/08 : Stops the current script execution (if not exec frozen) - used in tutorial + debugging
- cClear, // LG 12/12/08 : Clears the current complex black box (e.g. workspace) - used in tours
- cNew,
- cDelete,
- cConnect,
- cExec,
- cPackage,
- cEndPackage,
- cDefine,
- cEndDefine,
- cInput,
- cOutput,
- cSet,
- cConfig, // JPR
- cReset, // EED
- cAuthor,
- cCategory, // JPR
- cDescription,
- cHelp,
- cMessage,
- cInclude,
- cQuit,
- cLoad,
- cUnload,
- cGraph,
- cPrint,
- cIndex,
- cKind, // LG
- cNewGUI, // LG
- cWorkspace, // LG
- cDebug // LG
- } CommandCodeType;
-
- /// The structure storing the informations on a command
- typedef struct
- {
- std::string keyword;
- int argmin, argmax;
- CommandCodeType code;
- std::string syntax;
- std::string help;
- } CommandInfoType;
-
- /// The type of dictionnary of commands
- typedef std::map<std::string,CommandInfoType> CommandDictType;
-
-
- /// Interprets a line
- void DoInterpretLine( const std::string& line ); //, bool &insideComment );
-
- /// Reads a line from prompt
- void GetLineFromPrompt( std::string& line );
-
- /// Splits a line into words
- void SplitLine ( const std::string& line,
- std::vector<std::string>& words );
-
- /// Executes the right action depending on the command name
- void InterpretCommand( const std::vector<std::string>& words,
- CommandInfoType& info );
-
- /// Switch to the interpretation of a file
- void SwitchToFile( const std::string& filename, bool source = false );
-
- /// Switch to the interpretation of a stringstream
- void SwitchToStream( std::stringstream* stream );
-
- /// Closes the currently open file
- void CloseCurrentFile();
-
- /// Closes all open files
- void CloseAllFiles();
-*/
/// Resets all
virtual void commandReset();
virtual void commandIndex(const std::string& filename,
const std::string& type = "Initials");
-/*EED Borrame
- ///
- void FindCommandsWithPrefix( char* buf,
- int n,
- std::vector<std::string>& commands );
-*/
/// Creates and connects the piece of pipeline which defines a GUI
/// for the box box.
/// Define it as a complex box type with name instanceName+"Type"
/// The instance is called instanceName
/// and connected to the existing pipeline
- virtual void commandNewGUI(const std::string& box,const std::string& instanceName);
- virtual void commandDebug(const std::string& arg);
+ virtual void commandNewGUI(const std::string& box,const std::string& instanceName);
+ virtual void commandDebug(const std::string& arg);
virtual void commandNew(const std::string &boxType,const std::string &boxName);
virtual void commandDelete(const std::string &boxName);
virtual void commandConnection(const std::string &nodeFrom,const std::string &outputLabel,const std::string &nodeTo,const std::string &inputLabel);
void Init(VirtualExec::Pointer, const std::string& cpp_file);
-/*EED Borrame
- /// Opens the file fullPathScriptName
- /// includeScriptName is the name as given to the include command
- void LoadScript( std::string fullPathScriptName,
- std::string includeScriptName);
-*/
+
//==================================================================
// ATTRIBUTES
bbtk::VirtualExec::Pointer mVirtualExecuter;
bbtk::Executer::WeakPointer mRealExecuter;
-/*EED Borrame
- /// The user of the interpreter (0 if none)
- bbtk::InterpreterUser* mUser;
- /// Vector of open files / buffers (can be stringstream)
- std::vector<std::istream*> mFile;
-
- /// Vector of names of open files with full path (as open)
- std::vector<std::string> mFileName;
-
- /// Vector of names of files which have been open
- /// before (and may closed then which are no more in mFileName)
- /// with full path (as open)
- std::vector<std::string> mFileNameHistory;
-
- /// Vector of names of open files as given to the include command
- std::vector<std::string> mIncludeFileName;
-
- /// Stores the current line number in each open file
- std::vector<int> mLine;
-
- /// The dictionnary of commands
- CommandDictType mCommandDict;
-
- /// Are we in a command line context ?
- bool mCommandLine;
-
- /// Are we inside a commented-out zone ?
- bool mInsideComment;
-
- /// The current interpreter status
- ExitStatus mStatus;
-
- /// The history of commands
- std::deque< char* > mHistory;
-
- int bufferNb;
-
- bool mThrow;
-
- /// The break signal
- // BreakSignalType mBreakSignal;
-
- */
protected:
~Interpreter();
// break and quit commands
if ((command.code==cBreak) || (command.code==cQuit))
- {
- bool in_script = false;
- std::string file("");
- int line = 0;
-
- if (mFileName.size())
- {
- std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
- if (fs!=0) in_script = true;
- file = mFileName.back();
- line = mLine.back();
- }
- if (command.code==cBreak)
+ {
+//EED-Borrame bool in_script = false;
+//EED-Borrame std::string file("");
+//EED-Borrame int line = 0;
+
+//EED-Borrame if (mFileName.size())
+//EED-Borrame {
+//EED-Borrame std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back());
+//EED-Borrame if (fs!=0) in_script = true;
+//EED-Borrame file = mFileName.back();
+//EED-Borrame line = mLine.back();
+//EED-Borrame }
+ if (command.code==cBreak)
{
/*
std::cout << "BreakException("
commandBreak();
//EED Borrame bbtkError("break");//,in_script,file,line);
// throw BreakException(in_script,file,line);
- }
- else
- {
+ } else {
commandQuit();
//EED Borrame bbtkError("quit");//,in_script,file,line);
//throw QuitException(in_script,file,line);
- }
- return;
- }
+ } // cBreak
+ return;
+ } // cBreak cQuit
//std::cout<<" mVirtualExecuter->Create(words[1],words[2]); "<<line<<std::endl;
// other cammands
#include <deque>
// Signal/slot mechanism for 'break' commands
-#include <boost/signal.hpp>
+//#include <boost/signals2/signal.hpp>
#include <boost/bind.hpp>
namespace bbtk
// SIGNAL/SLOT MECHANISM
// FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION
// BBTKKWSIG
-#include <boost/signal.hpp>
+#include <boost/signals2/signal.hpp>
#include <boost/bind.hpp>
// \BBTKKWSIG
//===========================================================================
{
public:
// BBTKKWSIG
- typedef boost::signals::trackable SignalObserver;
- typedef boost::signal<void ()> Signal_type;
+ typedef boost::signals2::signals::trackable SignalObserver;
+ typedef boost::signals2::signal<void ()> Signal_type;
typedef Signal_type::slot_function_type Slot_function_type;
// \BBTKKWSIG
bbtkDebugMessage("package",3,"* Symbol ["<<getvername
<<"] found"<<std::endl);
// version matches ?
+
if (getbbtkversion() != bbtk::GetVersion())
{
bbtkMessage("package",0,
// SIGNAL/SLOT MECHANISM
// FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION
// BBTKWXSIG
-#include <boost/signal.hpp>
+#include <boost/signals2/signal.hpp>
#include <boost/bind.hpp>
-typedef boost::signals::trackable SignalObserver;
+//typedef boost::signals2::signal::trackable SignalObserver;
// \BBTKWXSIG
//===========================================================================
// BBTKWXSIG
// The keyword 'signals' is also a macro in qt
// typedef boost::signals::trackable SignalObserver;
- typedef boost::signal<void ()> Signal_type;
+ typedef boost::signals2::signal<void ()> Signal_type;
typedef Signal_type::slot_function_type Slot_function_type;
// \BBTKWXSIG
// SIGNAL/SLOT MECHANISM
// FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION
// BBTKWXSIG
-#include <boost/signal.hpp>
+#include <boost/signals2/signal.hpp>
#include <boost/bind.hpp>
// \BBTKWXSIG
//===========================================================================
{
public:
// BBTKWXSIG
- typedef boost::signals::trackable SignalObserver;
- typedef boost::signal<void ()> Signal_type;
+ typedef boost::signals2::trackable SignalObserver;
+ typedef boost::signals2::signal<void ()> Signal_type;
typedef Signal_type::slot_function_type Slot_function_type;
// \BBTKWXSIG
printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked cc %s \n",commandPath.c_str() );
// cleanning path
- while (commandPath.rfind("\\\\")!=-1 )
+ while ((int)commandPath.rfind("\\\\")!=-1 )
{
commandPath.erase( commandPath.rfind("\\\\") , 1 );
printf("EED WxGUIScriptingInterface::WxGUIHtmlBrowserUserOnLinkClicked cc %s \n",commandPath.c_str() );
--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#include "bbstdMathOperation.h"
+#include "bbstdPackage.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <time.h>
+
+namespace bbstd
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MathOperation)
+BBTK_BLACK_BOX_IMPLEMENTATION(MathOperation,bbtk::AtomicBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void MathOperation::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+// Here we simply set the input 'In' value to the output 'Out'
+// And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+// void bbSet{Input|Output}NAME(const TYPE&)
+// const TYPE& bbGet{Input|Output}NAME() const
+// Where :
+// * NAME is the name of the input/output
+// (the one provided in the attribute 'name' of the tag 'input')
+// * TYPE is the C++ type of the input/output
+// (the one provided in the attribute 'type' of the tag 'input')
+
+
+ if (firsttime==true)
+ {
+ firsttime=false;
+ /* initialize random seed: */
+ srand (time(NULL));
+ if (bbGetInputType()==7) acum=bbGetInputIn1();
+ }
+
+ if (bbGetInputType()==0) bbSetOutputOut( bbGetInputIn1() + bbGetInputIn2() );
+ if (bbGetInputType()==1) bbSetOutputOut( bbGetInputIn1() - bbGetInputIn2() );
+ if (bbGetInputType()==2) bbSetOutputOut( bbGetInputIn1() * bbGetInputIn2() );
+
+ if (bbGetInputType()==3)
+ {
+ if (bbGetInputIn2()!=0) bbSetOutputOut( bbGetInputIn1() / bbGetInputIn2() );
+ else bbSetOutputOut( 99999999 );
+ }
+
+ if (bbGetInputType()==4) bbSetOutputOut( sqrt( bbGetInputIn1() ) );
+
+ if (bbGetInputType()==5)
+ {
+ if (bbGetInputIn2()>0) bbSetOutputOut( log( bbGetInputIn1() ) );
+ else bbSetOutputOut( -99999999 );
+ }
+
+ if (bbGetInputType()==6) bbSetOutputOut( exp( bbGetInputIn1() ) );
+
+ if (bbGetInputType()==7)
+ {
+ bbSetOutputOut( acum );
+ acum++;
+ if (acum>bbGetInputIn2()) acum=bbGetInputIn1();
+ }
+ if (bbGetInputType()==8) bbSetOutputOut( rand() % (int) (bbGetInputIn2()-bbGetInputIn1()) + bbGetInputIn1() );
+ if (bbGetInputType()==9) bbSetOutputOut( sin( bbGetInputIn1() ) );
+ if (bbGetInputType()==10) bbSetOutputOut( cos( bbGetInputIn1() ) );
+ if (bbGetInputType()==11) bbSetOutputOut( tan( bbGetInputIn1() ) );
+ if (bbGetInputType()==12) bbSetOutputOut( asin( bbGetInputIn1() ) );
+ if (bbGetInputType()==13) bbSetOutputOut( acos( bbGetInputIn1() ) );
+ if (bbGetInputType()==14) bbSetOutputOut( atan( bbGetInputIn1() ) );
+ if (bbGetInputType()==15) bbSetOutputOut( atan2( bbGetInputIn1(),bbGetInputIn2() ) );
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void MathOperation::bbUserSetDefaultValues()
+{
+
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+ bbSetInputIn1(0);
+ bbSetInputIn2(0);
+ bbSetInputType(0);
+
+ firsttime=true;
+ acum=0;
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void MathOperation::bbUserInitializeProcessing()
+{
+
+// THE INITIALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should allocate the internal/output pointers
+// if any
+
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void MathOperation::bbUserFinalizeProcessing()
+{
+
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+
+}
+}
+// EO namespace bbstd
+
+
--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#ifndef __bbstdMathOperation_h_INCLUDED__
+#define __bbstdMathOperation_h_INCLUDED__
+#include "bbstd_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+namespace bbstd
+{
+
+class bbstd_EXPORT MathOperation
+ :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(MathOperation,bbtk::AtomicBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+ BBTK_DECLARE_INPUT(In1,double);
+ BBTK_DECLARE_INPUT(In2,double);
+ BBTK_DECLARE_INPUT(Type,int);
+ BBTK_DECLARE_OUTPUT(Out,double);
+ BBTK_PROCESS(Process);
+ void Process();
+
+ bool firsttime;
+ double acum;
+
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(MathOperation,bbtk::AtomicBlackBox);
+ BBTK_NAME("MathOperation");
+ BBTK_AUTHOR("InfoDev");
+ BBTK_DESCRIPTION("No Description.");
+ BBTK_CATEGORY("empty");
+ BBTK_INPUT(MathOperation,In1,"First input",double,"");
+ BBTK_INPUT(MathOperation,In2,"Second input",double,"");
+ BBTK_INPUT(MathOperation,Type,"Type (defalult 0): 0 adition (default), 1 sustraction In1+In2, 2 multiplication In1*In2, 3 divisiuon In1/In2, 4 sqrt In1, 5 log In1, 6 exp In1, 7 incremental int [In1..In2], 8 random int [In1..In2], 9 sin In1, 10 cos In1, 11 tan In1, 12 asin In 1, 13 acos In1, 14 atan In1, 15 atan2 In1,In2 ",int,"");
+
+ BBTK_OUTPUT(MathOperation,Out,"Output",double,"");
+BBTK_END_DESCRIBE_BLACK_BOX(MathOperation);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+}
+// EO namespace bbstd
+
+#endif // __bbstdMathOperation_h_INCLUDED__
+
tlst.push_back( new std::vector<std::string> );
}
+ int iSkipLines;
int numberOfLines = 0;
- char tmpValue[50];
+ char tmpValue[500];
std::vector<std::string> *vecData;
FILE *ff1 = fopen( bbGetInputFileName().c_str() , "r+" );
if (ff1!=NULL)
{
+ for (iSkipLines=0;iSkipLines<bbGetInputSkipLines(); iSkipLines++ )
+ {
+ fgets( tmpValue , 500, ff1 );
+ }
+
while (!feof(ff1))
{
for( i=0 ; i<bbGetInputDimension() ; i++)
// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
// Here we initialize the input 'In' to 0
+ bbSetInputSkipLines(0);
bbSetInputDimension(1);
bbSetInputFileName("");
// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
//=====
BBTK_DECLARE_INPUT(FileName,std::string);
+ BBTK_DECLARE_INPUT(SkipLines,int);
BBTK_DECLARE_INPUT(Dimension,int);
BBTK_DECLARE_OUTPUT(lstData1,std::vector<std::string> );
BBTK_DESCRIPTION("Read Columns from a text file");
BBTK_CATEGORY("read/write");
BBTK_INPUT(ReadColumnsString,FileName,"File name of Points",std::string,"");
+ BBTK_INPUT(ReadColumnsString,SkipLines,"(default 0) - Number of lines to be skipe before read data",int,"");
BBTK_INPUT(ReadColumnsString,Dimension,"(default 1) - The number of columns of the file",int,"");
BBTK_OUTPUT(ReadColumnsString,lstData1,"vector of data",std::vector<std::string>,"");
--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#include "bbstdWriteColumnsString.h"
+#include "bbstdPackage.h"
+namespace bbstd
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,WriteColumnsString)
+BBTK_BLACK_BOX_IMPLEMENTATION(WriteColumnsString,bbtk::AtomicBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void WriteColumnsString::Process()
+{
+
+ std::cout << "MLER WriteColumnsString::Process Start " << std::endl;
+
+
+ std::ofstream write_fi;
+ write_fi.open(bbGetInputFileName().c_str());
+
+ std::vector<std::string> headers = bbGetInputHeaders(); //Headers Input
+ bool onHeaders = bbGetInputOnHeaders();
+
+
+ std::vector<std::vector<std::string> > values;
+
+ values.push_back(bbGetInputlstData1());
+ values.push_back(bbGetInputlstData2());
+ values.push_back(bbGetInputlstData3());
+ values.push_back(bbGetInputlstData4());
+ values.push_back(bbGetInputlstData5());
+ values.push_back(bbGetInputlstData6());
+ values.push_back(bbGetInputlstData7());
+ values.push_back(bbGetInputlstData8());
+ values.push_back(bbGetInputlstData9());
+
+ std::vector<std::vector<std::string> >::iterator it;
+
+ std::cout << "values size"<<values.size()<< std::endl;
+ for(it = values.begin() ; it != values.end() ; )
+ {
+ if((*it).empty())
+ {
+ it = values.erase(it);
+ }else
+ {
+ it++;
+ }
+ }
+ std::cout << "values size"<<values.size()<< std::endl;
+
+ if(write_fi.is_open())
+ {
+ if(onHeaders == true) // If onHeaders is true, the file is write with Headers.
+ {
+ //Add each header input write to file
+ for(unsigned int i=0 ;i< headers.size(); i++ )
+ {
+ if(i==(headers.size()-1))
+ {
+ write_fi << headers[i] << "\n";
+ }else{
+ write_fi << headers[i] << "\t";
+ }
+
+ }//for headersSize
+ }
+
+ unsigned int colSize = values[0].size();
+
+ for(unsigned int j=0;j<colSize;j++)
+ {
+ for(unsigned int i=0;i<values.size();i++)
+ {
+ if(i==(values.size()-1))
+ {
+ write_fi << values[i][j] << "\n";
+ }else{
+ write_fi << values[i][j] << "\t";
+ }
+
+ }
+
+ }
+
+
+ }// if write_fi.is_open()
+ else
+ {
+ std::cout<<"No es posible abrir"<<std::endl;
+ }//else
+
+ write_fi.close();
+
+ bbSetOutputOutFileName(bbGetInputFileName().c_str());
+
+ std::cout << "MLER WriteColumnsString::End Process " << std::endl;
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void WriteColumnsString::bbUserSetDefaultValues()
+{
+
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+ bbSetInputFileName("");
+ bbSetInputFileName("true");
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void WriteColumnsString::bbUserInitializeProcessing()
+{
+
+// THE INITIALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should allocate the internal/output pointers
+// if any
+
+
+}
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+void WriteColumnsString::bbUserFinalizeProcessing()
+{
+
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+
+}
+}
+// EO namespace bbstd
+
+
--- /dev/null
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+#ifndef __bbstdWriteColumnsString_h_INCLUDED__
+#define __bbstdWriteColumnsString_h_INCLUDED__
+#include "bbstd_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+namespace bbstd
+{
+
+class bbstd_EXPORT WriteColumnsString :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(WriteColumnsString,bbtk::AtomicBlackBox);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+ BBTK_DECLARE_INPUT(FileName,std::string);
+ BBTK_DECLARE_INPUT(Headers,std::vector<std::string>);
+ BBTK_DECLARE_INPUT(OnHeaders,bool);
+
+
+ BBTK_DECLARE_INPUT(lstData1,std::vector<std::string> );
+ BBTK_DECLARE_INPUT(lstData2,std::vector<std::string> );
+ BBTK_DECLARE_INPUT(lstData3,std::vector<std::string> );
+ BBTK_DECLARE_INPUT(lstData4,std::vector<std::string> );
+ BBTK_DECLARE_INPUT(lstData5,std::vector<std::string> );
+ BBTK_DECLARE_INPUT(lstData6,std::vector<std::string> );
+ BBTK_DECLARE_INPUT(lstData7,std::vector<std::string> );
+ BBTK_DECLARE_INPUT(lstData8,std::vector<std::string> );
+ BBTK_DECLARE_INPUT(lstData9,std::vector<std::string> );
+
+ BBTK_DECLARE_OUTPUT(OutFileName,std::string);
+ BBTK_PROCESS(Process);
+ void Process();
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(WriteColumnsString,bbtk::AtomicBlackBox);
+BBTK_NAME("WriteColumnsString");
+BBTK_AUTHOR("Monica ESPINOSA");
+BBTK_DESCRIPTION("Write Columns to file");
+BBTK_CATEGORY("read/write");
+
+BBTK_INPUT(WriteColumnsString,FileName,"File name",std::string,"");
+BBTK_INPUT(WriteColumnsString,Headers,"Headers of Columns",std::vector<std::string>,"");
+BBTK_INPUT(WriteColumnsString,OnHeaders,"On Headers / Off Headers",bool,"");
+
+BBTK_INPUT(WriteColumnsString,lstData1,"vector of data",std::vector<std::string>,"");
+BBTK_INPUT(WriteColumnsString,lstData2,"vector of data",std::vector<std::string>,"");
+BBTK_INPUT(WriteColumnsString,lstData3,"vector of data",std::vector<std::string>,"");
+BBTK_INPUT(WriteColumnsString,lstData4,"vector of data",std::vector<std::string>,"");
+BBTK_INPUT(WriteColumnsString,lstData5,"vector of data",std::vector<std::string>,"");
+BBTK_INPUT(WriteColumnsString,lstData6,"vector of data",std::vector<std::string>,"");
+BBTK_INPUT(WriteColumnsString,lstData7,"vector of data",std::vector<std::string>,"");
+BBTK_INPUT(WriteColumnsString,lstData8,"vector of data",std::vector<std::string>,"");
+BBTK_INPUT(WriteColumnsString,lstData9,"vector of data",std::vector<std::string>,"");
+
+BBTK_OUTPUT(WriteColumnsString,OutFileName,"File Name",std::string,"");
+BBTK_END_DESCRIBE_BLACK_BOX(WriteColumnsString);
+//=====
+// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
+//=====
+}
+// EO namespace bbstd
+
+#endif // __bbstdWriteColumnsString_h_INCLUDED__
+
--- /dev/null
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBG BlackBox Diagram file
+# - /home/davila/Creatis/creaTools/creatools_source/bbtk/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbg
+# ----------------------------------
+
+APP_START
+CATEGORY:<VOID>
+DESCRIPTION:Description ??
+AUTHOR:Author ??
+COMPLEXBOX:TRUE
+COMPLEXBOXNAME:ApplyMaskWithTransparence
+PACKAGENAME:toolsbbtk
+COMPLEXOUTPUTS:1
+COMPLEX_PORT
+OutImage
+-71.833968:-77.907690:-900.000000
+FIN_COMPLEX_PORT
+COMPLEXINPUTS:2
+COMPLEX_PORT
+maskImage
+-155.945750:140.976519:-900.000000
+FIN_COMPLEX_PORT
+COMPLEX_PORT
+Image
+-52.261663:144.599262:-900.000000
+FIN_COMPLEX_PORT
+BOXES:12
+BOX
+vtk:BinaryOperations:Box06
+ISEXEC:FALSE
+-21.965422:21.398218:-900.000000
+23.609578:11.398218:-900.000000
+PORT
+Operation:"2"
+FIN_BOX
+BOX
+vtk:ImageVtkProperties:Box16
+ISEXEC:FALSE
+-89.759228:16.979477:-900.000000
+-44.184228:6.979477:-900.000000
+FIN_BOX
+BOX
+vtk:BinaryOperations:Box20
+ISEXEC:FALSE
+-74.625874:-54.714389:-900.000000
+-29.050874:-64.714389:-900.000000
+FIN_BOX
+BOX
+std:GetVectorFloatElement:Box22
+ISEXEC:FALSE
+-112.217901:-2.482812:-900.000000
+-41.042901:-12.482812:-900.000000
+PORT
+I:"0"
+FIN_BOX
+BOX
+vtk:RescaleSlopeIntercept:Box23
+ISEXEC:FALSE
+-177.610123:18.460663:-900.000000
+-106.435123:8.460663:-900.000000
+PORT
+OutputFormat:"VTK_DOUBLE"
+PORT
+Type:"1"
+FIN_BOX
+BOX
+vtk:UnaryOperations:Box24
+ISEXEC:FALSE
+-142.749404:-25.417995:-900.000000
+-97.174404:-35.417995:-900.000000
+PORT
+InConstant:"1"
+PORT
+Operation:"11"
+FIN_BOX
+BOX
+vtk:vtkImageDataPointerRelay:Box18
+ISEXEC:FALSE
+-171.782936:117.774432:-900.000000
+-100.607936:107.774432:-900.000000
+FIN_BOX
+BOX
+vtk:vtkImageDataPointerRelay:Box19
+ISEXEC:FALSE
+-53.355388:100.244903:-900.000000
+17.819612:90.244903:-900.000000
+FIN_BOX
+BOX
+vtk:UnaryOperations:Box09
+ISEXEC:FALSE
+-157.853849:61.413786:-900.000000
+-112.278849:51.413786:-900.000000
+PORT
+Operation:"3"
+FIN_BOX
+BOX
+vtk:ImageVtkProperties:Box10
+ISEXEC:FALSE
+-152.556320:102.747202:-900.000000
+-106.981320:92.747202:-900.000000
+FIN_BOX
+BOX
+std:GetVectorFloatElement:Box11
+ISEXEC:FALSE
+-149.145811:85.700627:-900.000000
+-77.970811:75.700627:-900.000000
+PORT
+I:"1"
+FIN_BOX
+BOX
+vtk:RescaleSlopeIntercept:Box12
+ISEXEC:FALSE
+-160.936834:45.783197:-900.000000
+-89.761834:35.783197:-900.000000
+PORT
+OutputFormat:"VTK_DOUBLE"
+FIN_BOX
+CONNECTIONS:17
+CONNECTION
+Box16:MinMax:Box22:In
+NumberOfControlPoints:0
+CONNECTION
+Box23:Out:Box24:In1
+NumberOfControlPoints:0
+CONNECTION
+Box22:Out:Box24:NewValue
+NumberOfControlPoints:0
+CONNECTION
+Box06:Out:Box20:In2
+NumberOfControlPoints:0
+CONNECTION
+Box24:Out:Box20:In1
+NumberOfControlPoints:0
+CONNECTION
+maskImage:maskImage:Box18:In
+NumberOfControlPoints:0
+CONNECTION
+Image:Image:Box19:In
+NumberOfControlPoints:0
+CONNECTION
+Box19:Out:Box16:In
+NumberOfControlPoints:0
+CONNECTION
+Box19:Out:Box06:In2
+NumberOfControlPoints:0
+CONNECTION
+Box20:Out:OutImage:OutImage
+NumberOfControlPoints:0
+CONNECTION
+Box18:Out:Box10:In
+NumberOfControlPoints:0
+CONNECTION
+Box18:Out:Box09:In1
+NumberOfControlPoints:0
+CONNECTION
+Box10:MinMax:Box11:In
+NumberOfControlPoints:0
+CONNECTION
+Box11:Out:Box09:InConstant
+NumberOfControlPoints:0
+CONNECTION
+Box09:Out:Box12:In
+NumberOfControlPoints:0
+CONNECTION
+Box12:Out:Box23:In
+NumberOfControlPoints:0
+CONNECTION
+Box12:Out:Box06:In1
+NumberOfControlPoints:0
+APP_END
--- /dev/null
+# ----------------------------------
+# - BBTKGEditor v 1.4 BBS BlackBox Script (Complex Box)
+# - /home/davila/Creatis/creaTools/creatools_source/bbtk/packages/toolsbbtk/bbs/boxes/ApplyMaskWithTransparence.bbs
+# ----------------------------------
+
+include std
+include itkvtk
+include vtk
+include std
+
+define ApplyMaskWithTransparence toolsbbtk
+
+author "Author ??"
+description "Description ??"
+
+category "<VOID>"
+
+new BinaryOperations Box06
+ set Box06.Operation "2"
+
+new ImageVtkProperties Box16
+
+new BinaryOperations Box20
+
+new GetVectorFloatElement Box22
+ set Box22.I "0"
+
+new RescaleSlopeIntercept Box23
+ set Box23.OutputFormat "VTK_DOUBLE"
+ set Box23.Type "1"
+
+new UnaryOperations Box24
+ set Box24.InConstant "1"
+ set Box24.Operation "11"
+
+new vtkImageDataPointerRelay Box18
+
+new vtkImageDataPointerRelay Box19
+
+new UnaryOperations Box09
+ set Box09.Operation "3"
+
+new ImageVtkProperties Box10
+
+new GetVectorFloatElement Box11
+ set Box11.I "1"
+
+new RescaleSlopeIntercept Box12
+ set Box12.OutputFormat "VTK_DOUBLE"
+
+
+connect Box16.MinMax Box22.In
+connect Box23.Out Box24.In1
+connect Box22.Out Box24.NewValue
+connect Box06.Out Box20.In2
+connect Box24.Out Box20.In1
+connect Box19.Out Box16.In
+connect Box19.Out Box06.In2
+connect Box18.Out Box10.In
+connect Box18.Out Box09.In1
+connect Box10.MinMax Box11.In
+connect Box11.Out Box09.InConstant
+connect Box09.Out Box12.In
+connect Box12.Out Box23.In
+connect Box12.Out Box06.In1
+
+# Complex input ports
+input maskImage Box18.In " "
+input Image Box19.In " "
+
+# Complex output ports
+output OutImage Box20.Out " "
+
+message
+
+endefine
}
-
-
-
-
-
bbGetInputMesh()->GetPointData()->SetScalars(colors);
if (bbGetInputColorType()==1)
bbGetInputTransform()->Update();
}
- unsigned short gl;
+ double gl;
double p1[3];
double p2[3];
double dcolor[3];
bbSetInputColorWindow(500);
bbSetInputTransform(NULL);
- firsttime = true;
- colors = NULL;
- colorLookupTable = NULL;
+ firsttime = true;
+ colors = NULL;
+ colorLookupTable = NULL;
colorLookupTableWL = NULL;
}
//=====
ope->SetInput1((vtkDataObject*)bbGetInputIn1());
- ope->SetConstantK( bbGetInputInConstant() );
-// ope->SetConstantC(bbGetInputInConstant());
-
switch (bbGetInputOperation())
{
case 0:
+ ope->SetConstantC( bbGetInputInConstant() );
ope->SetOperationToAddConstant();
break;
case 1:
- ope->SetConstantK( -1.0 * bbGetInputInConstant() );
+ ope->SetConstantC( -1.0 * bbGetInputInConstant() );
ope->SetOperationToAddConstant();
break;
case 2:
+ ope->SetConstantK( bbGetInputInConstant() );
ope->SetOperationToMultiplyByK();
printf("EED UnaryOperations::Process() 2 \n");
ope->SetOperationToInvert();
break;
case 5:
-
ope->SetOperationToSin();
break;
case 6:
-
ope->SetOperationToCos();
break;
case 7:
-
ope->SetOperationToExp();
break;
case 8:
-
ope->SetOperationToLog();
break;
case 9:
case 10:
ope->SetOperationToSquareRoot();
break;
+ case 11:
+ ope->SetConstantC( bbGetInputInConstant() );
+ ope->SetConstantK( bbGetInputNewValue() );
+ ope->SetOperationToReplaceCByK();
+ break;
-/* EED 21Juin 2011 Borrame
- case 10:
- substractWithMinimum();
- bbSetOutputOut(constante);
- return;
- break;
- case 11:
- MultiplyBy();
- bbSetOutputOut(constante);
- return;
- break;
-*/
default:
std::cout << "Invalid Operation" << std::endl;
}
-/* Borrame Eduardo - Juan Pablo
-void UnaryOperations::crearPredeterminado()
-{
- int ext[6];
- vtkImageData* inicial = bbGetInputIn1();
-
-
- if (constante == NULL)
- {
- inicial->GetExtent(ext);
- constante = vtkImageData::New();
- constante->SetExtent(ext);
- constante->SetScalarType(inicial->GetScalarType());
- constante->AllocateScalars();
- constante->Update();
- }
-
- for (int i=ext[0]; i<=ext[1]; i++)
- {
- for (int j=ext[2]; j<=ext[3]; j++)
- {
- for (int k=ext[4]; k<=ext[5]; k++)
- {
- unsigned short* value = (unsigned short*)constante->GetScalarPointer(i,j,k);
- *value = bbGetInputInConstant();
- }
- }
- }
-}
-*/
-
-
-void UnaryOperations::substractWithMinimum()
-{
- int ext[6];
- double spc[3];
- vtkImageData* inicial = bbGetInputIn1();
-
-
- if (constante == NULL)
- {
- inicial->GetExtent(ext);
- inicial->GetSpacing(spc);
- constante = vtkImageData::New();
- constante->SetExtent(ext);
- constante->SetSpacing(spc);
- constante->SetOrigin(inicial->GetOrigin());
- constante->SetScalarType(inicial->GetScalarType());
- constante->AllocateScalars();
- constante->Update();
- }
-
- for (int i=ext[0]; i<=ext[1]; i++)
- {
- for (int j=ext[2]; j<=ext[3]; j++)
- {
- for (int k=ext[4]; k<=ext[5]; k++)
- {
- double temp1 = lector.getPixelValue(i,j,k,inicial);
- double temp = temp1 - bbGetInputInConstant();
- if (temp < 0)
- temp = 0;
- lector.setPixelValue(i,j,k,constante,temp);
- }
- }
- }
-}
void UnaryOperations::bbUserSetDefaultValues()
bbSetInputIn1(NULL);
bbSetOutputOut(NULL);
bbSetInputInConstant(0);
+ bbSetInputNewValue(0);
bbSetInputOperation(0);
ope = vtkImageMathematics::New();
constante = NULL;
BBTK_DECLARE_INPUT(In1,vtkImageData*);
BBTK_DECLARE_INPUT(Operation,int);
BBTK_DECLARE_INPUT(InConstant,double);
+ BBTK_DECLARE_INPUT(NewValue,double);
BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
BBTK_PROCESS(Process);
void Process();
BBTK_CATEGORY("filtre");
BBTK_INPUT(UnaryOperations,In1,"Image to be operated",vtkImageData*,"");
BBTK_INPUT(UnaryOperations,InConstant,"Constant that will be used in the operations.",double,"0 default");
- BBTK_INPUT(UnaryOperations,Operation,"0:Add (Default), 1:subtract, 2:multiply, 3:divide, 4:invert, 5:sin, 6:cos, 7:exp, 8:log, 9:abs????, 10:SquareRoot",int,"Addition default");
+ BBTK_INPUT(UnaryOperations,NewValue,"InConstant replace by NewValue",double,"0 default");
+ BBTK_INPUT(UnaryOperations,Operation,"0:Add (Default), 1:subtract, 2:multiply, 3:divide, 4:invert, 5:sin, 6:cos, 7:exp, 8:log, 9:abs????, 10:SquareRoot, 11:ReplaceByContant",int,"Addition default");
BBTK_OUTPUT(UnaryOperations,Out,"",vtkImageData*,"");
BBTK_END_DESCRIBE_BLACK_BOX(UnaryOperations);
}