It is recommended practice that - instead of adding the required interpreter command in the original TclModel BuilderSectionCommand.cpp - one should write his/her own interpreter-command file (call it TclXXFiberSectionCommand.cpp) and only include a declaration for it (call it TclModelBuilder_addXXFiberSection) in the original file; along with an if-clause which calls the external command when requested. It has been a practice I kept successfully with materials, however, with the fiber section, I have run across the following problem:
The TclModelBuilder_addXXFiberSection command needs to call the addPatch() method to parse the subcommands in the {}. This method exists in the original TclModel BuilderSectionCommand.cpp file. When it is called from outside the file, it returns an error. This happens because it checks for the value of the integer variable "currentSectionTag". This variable is declared "Static int" in TclModel BuilderSectionCommand.cpp, and my limited knowledge of C++ doesn't help me to think of a way to change its value when I call the addPatch() command from my TclXXFiberSectionCommand.cpp file. I had to revert to the not-so-elegant solution of copying and pasting all my interpreter commands into the original file and discarding TclXXFiberSectionCommand.cpp during compilation, but I am sure there must be a way around it that will keep my interpreter comands "external". The only thing I can think of is to copy the addPatch() method to my external file and rename it but that would be flimsy patchwork.
Can one type something like
Code: Select all
TclModelBuilderSectionCommand::currentSectionTag = 1
I guess the question boils down to, "how to change the value of a static variable which is declared and exists in another file and does not belong to any method or class? C++ pundits, any clue?