Example #1
0
/// Returns the Id of the loaded model.
Id Shell::doLoadModel( const string& fileName, const string& modelPath, const string& solverClass )
{
    ifstream fin( fileName.c_str() );
    if ( !fin )
    {
        LOG( moose::failed, "Shell::doLoadModel: could not open file " << fileName );
        return Id();
    }

    string modelName;
    Id parentId;

    if ( !( findModelParent ( cwe_, modelPath, parentId, modelName ) ) )
        return Id();

    string line;
    switch ( findModelType( fileName, fin, line ) )
    {
    case DOTP:
    {
        ReadCell rc;
        return rc.read( fileName, modelName, parentId );
        return Id();
    }
    case SWC:
    {
        LOG( moose::info, "In doLoadModel for SWC" );
        ReadSwc rs( fileName );
        Id model = parentId;
        if ( !parentId.element()->cinfo()->isA( "Neuron" ) )
        {
            model = doCreate( "Neuron", parentId, modelName, 1 );
        }
        rs.build( model, 0.5e-3, 1.0, 1.0, 0.01 );
        return model;
    }
    case KKIT:
    {
        string sc = solverClass;
        ReadKkit rk;
        Id ret = rk.read( fileName, modelName, parentId, sc);
        return ret;
    }
    break;
    case CSPACE:
    {
        string sc = solverClass;
        ReadCspace rc;
        Id ret = rc.readModelString( line, modelName, parentId, sc);
        rc.makePlots( 1.0 );
        return ret;
    }
    case UNKNOWN:
    default:
        cout << "Error: Shell::doLoadModel: File type of '" <<
             fileName << "' is unknown\n";
    }
    return Id();
}
void testReadKkit()
{
	ReadKkit rk;
	// rk.read( "test.g", "dend", 0 );
	Id base = rk.read( "foo.g", "dend", Id() );
	assert( base != Id() );
	// Id kinetics = s->doFind( "/kinetics" );

	Shell* s = reinterpret_cast< Shell* >( Id().eref().data() );
	rk.run();
	rk.dumpPlots( "dend.plot" );

	s->doDelete( base );
	cout << "." << flush;
}