27 namespace neuroscience {
36 Base::Initialize(event);
40 if (mother->daughters_.size() != 0) {
42 "Dividing a neuron soma with attached neurites is not supported "
43 "in the default implementation! If you want to change this "
44 "behavior derive from this class and overwrite this method.");
54 auto* neurite = bdm_static_cast<NeuriteElement*>(event.
new_agents[0]);
56 real_t theta = ne_event.theta;
58 real_t x_coord = std::sin(theta) * std::cos(phi);
59 real_t y_coord = std::sin(theta) * std::sin(phi);
60 real_t z_coord = std::cos(theta);
71 aptrs->push_back(Agent::GetAgentPtr<>());
73 aptrs->push_back(daughter);
80 auto angles = Base::TransformCoordinatesGlobalToPolar(dir);
82 return ExtendNewNeurite(param->neurite_default_diameter, angles[2], angles[1],
91 prototype = &kDefaultNeurite;
95 return bdm_static_cast<NeuriteElement*>(event.
new_agents[0]);
101 "The element you wanted to remove is not part of daughters_");
115 Real3 result = {xyz * axis_0, xyz * axis_1, xyz * axis_2};
123 auto old_rel_agent_ptr = bdm_static_cast<const NeuriteElement*>(&old_rel)
125 auto new_rel_agent_ptr = bdm_static_cast<const NeuriteElement*>(&new_rel)
131 "old_element_idx could not be found in daughters_ vector");
132 *it = new_rel_agent_ptr;
144 out <<
" " << pos[0] <<
" " << pos[1] <<
" " << pos[2] <<
" ";
150 out <<
"# This SWC file was created with BioDynaMo and is (very) likely "
151 "to\n# be the result of a simulation. Be careful not to confuse it\n"
152 "# with real data. \n\n";
156 ltime = time(<ime);
157 localtime_r(<ime, &newtime);
158 char creation_time[100];
159 std::strftime(creation_time,
sizeof(creation_time),
"%A, %F, %T", &newtime);
160 out <<
"# Created at: " << creation_time <<
"\n\n";
164 int previous_element_id{-1};
167 out <<
GetDiameter() / 2 <<
" " << previous_element_id <<
"\n";
172 bool is_new_brach{
true};
177 std::vector<AgentPointer<NeuriteElement>> bifurcation_points;
180 std::vector<int> bifurcation_points_lables;
182 bool connect_to_bifurcation{
false};
195 current_element = daughter;
200 out << element_id <<
" " << current_element->GetIdentifierSWC();
202 out << current_element->GetDiameter() / 2 <<
" ";
206 previous_element_id = 1;
207 is_new_brach =
false;
209 if (!connect_to_bifurcation) {
211 previous_element_id = element_id - 1;
215 previous_element_id = bifurcation_points_lables.back();
216 bifurcation_points_lables.pop_back();
217 connect_to_bifurcation =
false;
220 out << previous_element_id <<
"\n";
224 next_element = current_element->GetDaughterLeft();
226 if (current_element->GetDaughterRight() !=
nullptr) {
227 bifurcation_points.push_back(current_element->GetDaughterRight());
228 bifurcation_points_lables.push_back(element_id);
231 if (next_element ==
nullptr && bifurcation_points.empty()) {
235 }
else if (next_element ==
nullptr) {
237 next_element = bifurcation_points.back();
238 bifurcation_points.pop_back();
239 connect_to_bifurcation =
true;
241 std::swap(current_element, next_element);