5 #include "internal.hxx"
23 props.schema_location(
"http://www.neuroml.org/schema/neuroml2",
getSchemaPath());
24 std::unique_ptr<NeuroMLDocument> model(
neuroml(filePath, 0, props));
31 if (FILE* fp = fopen(SOURCE_SCHEMA_PATH,
"r"))
34 path = SOURCE_SCHEMA_PATH;
36 else if (FILE* fp = fopen(INSTALLED_SCHEMA_PATH,
"r"))
39 path = INSTALLED_SCHEMA_PATH;
42 throw std::ios_base::failure(
"Unable to find NeuroML schema at " INSTALLED_SCHEMA_PATH);
43 return "file://" + path;
51 map[
""].name =
"http://www.neuroml.org/schema/neuroml2";
53 std::ofstream f(pathToFile, mode);
150 return sqrt(x*x + y*y + z*z);
156 double prox_rad =
proximal()->diameter() / 2.0;
159 return (M_PI/3.0) *
length() * (prox_rad*prox_rad + dist_rad*dist_rad + prox_rad*dist_rad);
165 double prox_rad =
proximal()->diameter() / 2.0;
167 double rad_diff = prox_rad-dist_rad;
170 return M_PI * (prox_rad + dist_rad) * sqrt(rad_diff*rad_diff + len*len);
195 return new Segment(*
this, f, c);
213 unsigned Connection::_get_cell_id(
const std::string& id_string)
const
216 std::string::size_type pos = id_string.find(
'[');
217 if (pos != std::string::npos)
220 std::string::size_type end_pos = id_string.find(
']', pos);
221 assert(end_pos != std::string::npos);
222 id = stoi(id_string.substr(pos+1, end_pos-pos-1));
227 pos = id_string.find(
'/');
228 assert(pos != std::string::npos);
229 pos = id_string.find(
'/', pos+1);
230 assert(pos != std::string::npos);
231 std::string::size_type end_pos = id_string.find(
'/', pos+1);
232 if (end_pos == std::string::npos)
234 id = stoi(id_string.substr(pos+1));
238 id = stoi(id_string.substr(pos+1, end_pos-pos-1));
242 return static_cast<unsigned>(
id);
245 unsigned Connection::get_pre_cell_id()
const
250 unsigned Connection::get_post_cell_id()
const
283 operator<<(::std::ostream& o,
const Connection& c)
285 o << ::std::endl <<
"Connection " << c.
id() <<
": "
286 << c.get_pre_cell_id() <<
" -> " << c.get_post_cell_id();
287 o << static_cast<const ::neuroml2::Connection_base&>(c);
const id_type & id() const
Return a read-only (constant) reference to the attribute.
Class corresponding to the Connection schema type.
Class corresponding to the Connection schema type.
virtual Connection * _clone(::xml_schema::flags f=0, ::xml_schema::container *c=0) const
Copy the instance polymorphically.
virtual ~Connection()
Destructor.
Connection(const id_type &, const preCellId_type &, const postCellId_type &)
Create an instance from the ultimate base and initializers for required elements and attributes.
Class corresponding to the Morphology schema type.
const segment_sequence & segment() const
Return a read-only (constant) reference to the element sequence.
Class corresponding to the Morphology schema type.
virtual Morphology * _clone(::xml_schema::flags f=0, ::xml_schema::container *c=0) const
Copy the instance polymorphically.
unsigned num_segments() const
virtual ~Morphology()
Destructor.
Morphology(const id_type &)
Create an instance from the ultimate base and initializers for required elements and attributes.
Morphology & operator=(const Morphology &x)
Copy assignment operator.
Class corresponding to the NeuroMLDocument schema type.
Class corresponding to the NeuroMLDocument schema type.
NeuroMLDocument & operator=(const NeuroMLDocument &x)
Copy assignment operator.
NeuroMLDocument(const id_type &)
Create an instance from the ultimate base and initializers for required elements and attributes.
void writeToFile(const std::string &pathToFile, std::ios_base::openmode mode=std::ios_base::out) const
virtual NeuroMLDocument * _clone(::xml_schema::flags f=0, ::xml_schema::container *c=0) const
Copy the instance polymorphically.
virtual ~NeuroMLDocument()
Destructor.
Class corresponding to the Nml2PopulationReferencePath schema type.
Class corresponding to the NmlId schema type.
Class corresponding to the NonNegativeInteger schema type.
Class corresponding to the Point3DWithDiam schema type.
const x_type & x() const
Return a read-only (constant) reference to the attribute.
const z_type & z() const
Return a read-only (constant) reference to the attribute.
const y_type & y() const
Return a read-only (constant) reference to the attribute.
const diameter_type & diameter() const
Return a read-only (constant) reference to the attribute.
Class corresponding to the Segment schema type.
const distal_type & distal() const
Return a read-only (constant) reference to the element.
const proximal_optional & proximal() const
Return a read-only (constant) reference to the element container.
Class corresponding to the Segment schema type.
Segment & operator=(const Segment &x)
Copy assignment operator.
virtual ~Segment()
Destructor.
double surface_area() const
Segment(const id_type &, const distal_type &)
Create an instance from the ultimate base and initializers for required elements and attributes.
virtual Segment * _clone(::xml_schema::flags f=0, ::xml_schema::container *c=0) const
Copy the instance polymorphically.
C++ namespace for the http://www.neuroml.org/schema/neuroml2 schema namespace.
::std::unique_ptr< ::neuroml2::NeuroMLDocument > neuroml(const ::std::string &u, ::xml_schema::flags f, const ::xml_schema::properties &p)
Parse a URI or a local file.
std::string getSchemaPath()
std::unique_ptr< NeuroMLDocument > parseFile(const std::string &filePath)
::xsd::cxx::tree::type container
Alias for the anyType type.
::xsd::cxx::tree::id< char, ncname > id
C++ type corresponding to the ID XML Schema built-in type.
::xsd::cxx::tree::flags flags
Parsing and serialization flags.
::xsd::cxx::tree::properties< char > properties
Parsing properties.
::xsd::cxx::xml::dom::namespace_infomap< char > namespace_infomap
Namespace serialization information map.
::xsd::cxx::tree::string< char, simple_type > string
C++ type corresponding to the string XML Schema built-in type.