13 #include "../utility/strutil.h"
14 #include "../utility/Vec.h"
17 #include "../biophysics/ReadCell.h"
18 #include "../biophysics/SwcSegment.h"
19 #include "../biophysics/ReadSwc.h"
20 #include "../kinetics/ReadKkit.h"
21 #include "../kinetics/ReadCspace.h"
22 #include "../utility/print_function.hpp"
26 if ( filename.substr( filename.length() - 2 ) ==
".p" )
29 if ( filename.substr( filename.length() - 4 ) ==
".swc" )
34 if ( line ==
"//genesis" )
38 if ( line.substr( 0, 7 ) ==
"// kkit" )
41 if ( line.substr( 0, 9 ) ==
"// DOQCS" )
43 while ( getline( fin, line ) )
46 if ( line.substr( 0, 7 ) ==
"// kkit" )
51 unsigned long pos = line.find_first_of(
":" );
52 string copyLine= line;
53 if (pos != string::npos )
55 copyLine = line.substr(pos+2);
58 if ( copyLine.length() >= 6 && copyLine[0] ==
'|' && copyLine[5] ==
'|' )
82 Id& parentId,
string& modelName )
85 string fullPath =
path;
87 if ( path.length() == 0 )
101 string temp = cwe.
path();
102 if ( temp[temp.length() - 1] ==
'/' )
103 fullPath = temp + path;
105 fullPath = temp +
"/" +
path;
111 string::size_type pos = fullPath.find_last_of(
"/" );
112 assert( pos != string::npos );
113 string head = fullPath.substr( 0, pos );
116 if ( ret ==
Id() && head !=
"" && head !=
"/root" )
119 modelName = fullPath.substr( pos + 1 );
134 ifstream fin( fileName.c_str() );
137 LOG(
moose::failed,
"Shell::doLoadModel: could not open file " << fileName );
153 return rc.
read( fileName, modelName, parentId );
163 model =
doCreate(
"Neuron", parentId, modelName, 1 );
165 rs.
build( model, 0.5e-3, 1.0, 1.0, 0.01 );
170 string sc = solverClass;
172 Id ret = rk.
read( fileName, modelName, parentId, sc);
178 string sc = solverClass;
186 cout <<
"Error: Shell::doLoadModel: File type of '" <<
187 fileName <<
"' is unknown\n";
bool findModelParent(Id cwe, const string &path, Id &parentId, string &modelName)
static ObjId parent(const Eref &e)
ModelType findModelType(string filename, ifstream &fin, string &line)
Element * element() const
Synonym for Id::operator()()
std::string path(const std::string &separator="/") const
ObjId cwe_
Current working Element.
Id doCreate(string type, ObjId parent, string name, unsigned int numData, NodePolicy nodePolicy=MooseBlockBalance, unsigned int preferredNode=1)
Id readModelString(const string &model, const string &modelname, Id pa, const string &solverClass)
Id read(const string &filename, const string &cellname, Id parent)
bool isA(const string &ancestor) const
void makePlots(double plotdt)
const Cinfo * cinfo() const
Id read(const string &filename, const string &cellname, Id parent, const string &solverClass="Stoich")
#define LOG(t, a)
This macro only expands when not compiling for release.
std::string trim(const std::string myString, const string &delimiters)
const string & getName() const
Id doLoadModel(const string &fname, const string &modelpath, const string &solverClass="")
Returns the Id of the loaded model.
bool build(Id parent, double lambda, double RM, double RA, double CM)