Exemplo n.º 1
0
        private void OutputSubDendrite()
        {
            DendriteIO io = new DendriteIO();

            string rawFilename = Path.GetFileNameWithoutExtension(param.ofname);
            string dirname     = Path.Combine(Path.GetDirectoryName(param.ofname), rawFilename + "-sub");

            if (Directory.Exists(dirname))
            {
                Directory.Delete(dirname, true);
            }

            Directory.CreateDirectory(dirname);

            // 出力するファイル名の末尾の桁数
            // ファイル名は0オリジンにするので .Count - 1 にしている
            int digit = (NotMergedSubDendritesIdx.Count - 1).ToString().Length;
            // 出力するファイル名の末尾のID
            int sub_dendrite_id = 0;

            // 独立して存在している(他のノードに併合されていない)側枝ノードを、体積降順で並べ替える
            var orderByVolume = NotMergedSubDendritesIdx.OrderByDescending(x => sub_dendrites_volume[x]);

            foreach (int sub_index in orderByVolume)
            {
                Dendrite             sdendrite = sub_dendrites[sub_index];
                IList <DendriteNode> edge      = sdendrite.GetEdgeNodes();
                sdendrite.ChangeRootNode(edge[0]);

                string filename = CreateFileNameForSubDendriteIO(dirname, digit, sub_dendrite_id);
                string path     = Path.Combine(dirname, filename);
                io.SaveToSWC(path, sdendrite);
                sub_dendrite_id++;

                if (param.outputVTK)
                {
                    string vtkFilename = Path.ChangeExtension(filename, "vtk");
                    string vtkPath     = Path.Combine(dirname, vtkFilename);
                    VtkWriter.SaveToVTKLegacy(vtkPath, sdendrite);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 樹状突起構造をswcファイルに出力
        /// </summary>
        public void OutputDendrite()
        {
            DendriteIO           io   = new DendriteIO();
            IList <DendriteNode> edge = main_dendrite.GetEdgeNodes();

            main_dendrite.ChangeRootNode(edge.First());

            SetSwcHeader(main_dendrite);

            io.SaveToSWC(param.ofname, main_dendrite);

            if (param.outputVTK)
            {
                string vtkFilename = Path.ChangeExtension(param.ofname, "vtk");
                VtkWriter.SaveToVTKLegacy(vtkFilename, main_dendrite);
            }

            // sub_dendritesについても出力する(sub_dendritesのスムージング、ひげの除去には未対応)
            if (param.outputSub)
            {
                OutputSubDendrite();
            }
        }