• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

BlueBrain / MorphIO / 11254817533

09 Oct 2024 12:20PM UTC coverage: 77.697% (+0.08%) from 77.615%
11254817533

Pull #476

github

mgeplf
Merge remote-tracking branch 'origin/master' into efficient-swc-build
Pull Request #476: Efficient swc build

286 of 321 new or added lines in 10 files covered. (89.1%)

9 existing lines in 4 files now uncovered.

2125 of 2735 relevant lines covered (77.7%)

901.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

90.91
/src/mut/writer_asc.cpp
1
/* Copyright (c) 2013-2023, EPFL/Blue Brain Project
2
 *
3
 * SPDX-License-Identifier: Apache-2.0
4
 */
5
#include <fstream>
6
#include <iomanip>  // std::fixed, std::setw, std::setprecision
7

8
#include <morphio/mut/mitochondria.h>
9
#include <morphio/mut/morphology.h>
10
#include <morphio/mut/section.h>
11
#include <morphio/mut/writers.h>
12
#include <morphio/version.h>
13
#include <morphio/warning_handling.h>
14

15
#include "../error_message_generation.h"
16
#include "../shared_utils.hpp"
17
#include "writer_utils.h"
18

19
namespace {
20
void write_asc_points(std::ofstream& myfile,
14✔
21
                      const morphio::Points& points,
22
                      const std::vector<morphio::floatType>& diameters,
23
                      size_t indentLevel) {
24
    for (unsigned int i = 0; i < points.size(); ++i) {
46✔
25
        myfile << std::fixed << std::setprecision(morphio::FLOAT_PRECISION_PRINT)
32✔
26
               << std::string(indentLevel, ' ') << '(' << points[i][0] << ' ' << points[i][1] << ' '
64✔
27
               << points[i][2] << ' ' << diameters[i] << ")\n";
32✔
28
    }
29
}
14✔
30

31
void write_asc_section(std::ofstream& myfile,
12✔
32
                       const std::shared_ptr<morphio::mut::Section>& section,
33
                       size_t indentLevel) {
34
    const std::string indent(indentLevel, ' ');
24✔
35
    write_asc_points(myfile, section->points(), section->diameters(), indentLevel);
12✔
36

37
    if (!section->children().empty()) {
12✔
38
        auto children = section->children();
8✔
39
        size_t nChildren = children.size();
4✔
40
        for (unsigned int i = 0; i < nChildren; ++i) {
12✔
41
            myfile << indent << (i == 0 ? "(\n" : "|\n");
8✔
42
            write_asc_section(myfile, children[i], indentLevel + 2);
8✔
43
        }
44
        myfile << indent << ")\n";
4✔
45
    }
46
}
12✔
47
}  // namespace
48

49
namespace morphio {
50
namespace mut {
51
namespace writer {
52

53
void asc(const Morphology& morph,
2✔
54
         const std::string& filename,
55
         std::shared_ptr<morphio::WarningHandler> handler) {
56
    if (details::emptyMorphology(morph, handler)) {
2✔
NEW
57
        throw morphio::WriterError(morphio::details::ErrorMessages().ERROR_EMPTY_MORPHOLOGY());
×
58
    }
59

60
    details::validateContourSoma(morph, handler);
2✔
61
    details::checkSomaHasSameNumberPointsDiameters(*morph.soma());
2✔
62
    details::validateHasNoMitochondria(morph, handler);
2✔
63
    details::validateHasNoPerimeterData(morph);
2✔
64
    details::validateRootPointsHaveTwoOrMorePoints(morph);
2✔
65

66
    std::ofstream myfile(filename);
2✔
67

68
    const std::shared_ptr<Soma>& soma = morph.soma();
2✔
69
    if (!soma->points().empty()) {
2✔
70
        myfile << "(\"CellBody\"\n  (Color Red)\n  (CellBody)\n";
2✔
71
        write_asc_points(myfile, soma->points(), soma->diameters(), 2);
2✔
72
        myfile << ")\n\n";
2✔
73
    }
74

75
    for (const std::shared_ptr<Section>& section : morph.rootSections()) {
6✔
76
        const auto type = section->type();
4✔
77
        if (type == SECTION_AXON) {
4✔
78
            myfile << "( (Color Cyan)\n  (Axon)\n";
2✔
79
        } else if (type == SECTION_DENDRITE) {
2✔
80
            myfile << "( (Color Red)\n  (Dendrite)\n";
2✔
81
        } else if (type == SECTION_APICAL_DENDRITE) {
×
82
            myfile << "( (Color Red)\n  (Apical)\n";
×
83
        } else {
84
            throw WriterError(
NEW
85
                morphio::details::ErrorMessages().ERROR_UNSUPPORTED_SECTION_TYPE(type));
×
86
        }
87
        write_asc_section(myfile, section, 2);
4✔
88
        myfile << ")\n\n";
4✔
89
    }
90

91
    myfile << "; " << details::version_string() << '\n';
2✔
92
}
2✔
93
}  // end namespace writer
94
}  // end namespace mut
95
}  // end namespace morphio
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc