[仮想の館・3次元表示 のための、断面画像を生成する], Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

Python(パイソン) プログラム作ってみた インデックス へ

-----

2024.10.1 presented in [note] ( //note.com/runningWater/ )

----------
1 はじめに

これ以降に記述されている内容は、このようなコンピューター・プログラムを制作した、というような事を、ただ、述べているに過ぎない。

以下の記述を読んだ人が、それを単に参考にする、というのであれば、問題は無いと、思われる。

しかし、記述されている内容に沿って、その人が、そこに記されているのと同様の制作や作業を行った際に、その制作、作業、コンピューターの作動の結果、使用されたコンピューター等、様々な方面において、何らかの問題が発生しない、という保証は、全くない。

その制作、作業、コンピューターの作動の結果、その人や、その人が所属している組織、その人が使用した様々な機器、インフラストラクチャー等の、身の上にどのような事が起ころうとも、私は一切、責任を負わない。

このプログラムは、Python(パイソン) 言語を使って、記述されている。

----------
2 どのようなものを作ったのか

[断面画像を重ね合わせて、物体を3次元表示], Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

のモジュール群に対して、与える、断面画像を生成する、というようなものを、作ってみた。

このモジュール群により、生成された断面画像のデータを、

[断面画像を重ね合わせて、物体を3次元表示], Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり] モジュール群

に対して、与え、そのモジュールを動かすと、下図のように、表示された。


----------
3 館は、部分オブジェクトにより、構成

前記の図は、館のさまざまな部分を構成する、[部分オブジェクト]によって、描画されている。

[部分オブジェクト] は、[垣根]、[支柱]、[壁]、[屋根]等の各部分を表現するためのものであり、下記3種類の画像から、構成されている。

(1)部分の断面の画像
(2)部分の径の推移(上下方向での)を示す曲線(を格納する画像)
(3)部分の表面の絵柄を表す画像

下記に、その一部を、記す。左から順に、上記(1)、(2)、(3)の順になっている。

支柱

屋根

----------
3 このモジュール群の構成

以下のような、モジュールから、構成されている。

[ StartProcess ]
[ MakeImageDatas ]
[ Prepare ]
[ DetectCurveInImageData ]
[ OneObject ]
[ OneObjectTypeDrawingH ] ( [ OneObject ] を継承 )
[ OneObjectTypeDrawingV ] ( [ OneObject ] を継承 )

これらのモジュールは、必要に応じて、下記に解説されているモジュールを、使用している。

[画像中の、特定の色で塗りつぶされている部分の、境界部分の位置座標を、検出し、それを、テキストファイルに出力する] , Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

[[画像処理, OpenCV2 使用] を 行う, 機能追加版, 多角形(内部ぬりつぶし)描画機能を追加] , Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

[テキストデータ を処理する] ためのクラス, Python(パイソン) 使って作ってみた ,ソースプログラムリスト あり

Python(パイソン) ,ソースプログラムリスト あり ,プログラム作ってみた ,[エラー処理] を 行う

----------

以降に、各モジュールの内容を、記す。

----------
4 [ StartProcess モジュール]

ファイル名 [ StartProcess.py ]

----------


import  MakeImageDatas

MODULE_NAME = "MakeSectionImageData"
FUNCTION_NAME = "start_process"

print ( "==================================" )
print ( "Module = " + MODULE_NAME
                   + " ,  function = " + FUNCTION_NAME )
print ( "process started"  )
print ( "==================================" )

MakeImageDatas.make_ImageDatas ( )

print ( "==================================" )
print ( "Module = " + MODULE_NAME
                   + " ,  function = " + FUNCTION_NAME )
print ( "process terminated"  )
print ( "==================================" )

----------

----------
5 [ MakeImageDatas モジュール]

ファイル名 [ MakeImageDatas.py ]

----------


import  sys
import  time

import  Prepare
import  OneObjectTypeDrawingV
import  OneObjectTypeDrawingH

import  ImageDataTwoDimensionHandlingV3

MODULE_NAME = "MakeImageDatas"

global_number_of_Object = 0

global_from_Z = 1
global_to_Z     = 90

#global_ins_ImageDataTwoDimensionHandling_BasicImage = ""
#global_abs_path_of_ImageData_Basic = " "
#global_Part_2_of_abs_path_of_ImageData_output = " "
#global_abs_path_of_ImageData_output_part_1 = " "

#=================================
def  make_ImageDatas (  ) :

    function_name = "make_ImageDatas"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "==================================" )

    name_of_Object  = "Roof1"
    list_of_path = Prepare   \
                            .make_path_list ( name_of_Object )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "passed : phase 1"  )
    print ( "==================================" )

    global  global_from_Z
    global  global_to_Z

    Prepare  \
            .make_SectionImageData_of_initial_status ( \
                        list_of_path [ 0 ]   # arg_abs_path_of_ImageData_Basic
                      , list_of_path [ 3 ]   # arg_Part_1_of_abs_path_of_ImageData_output
                     , list_of_path [ 4 ]   #arg_Part_2_of_abs_path_of_ImageData_outpu

                     , global_from_Z
                     , global_to_Z
                                                      )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "passed : phase 2"  )
    print ( "==================================" )
             #------------------------------------------
    list_Objects = make_all_Objects ( )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "start : phase 3"  )
    print ( "==================================" )

    global  global_number_of_Object

    for  order_number_of_Object   \
                       in range ( 1 , ( global_number_of_Object + 1 ) ) :

        print ( "**********************************************" )
        print ( "**********************************************" )
        print ( "**********************************************" )
        print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
        print ( "phase 3 ,order_number_of_Object = " ,  order_number_of_Object )
        print ( "**********************************************" )
        print ( "**********************************************" )
        print ( "**********************************************" )

        time.sleep ( 3 )

        ins_object = list_Objects [  order_number_of_Object - 1 ]
        ins_object  \
               .vary_ImageData_for_all_z (
                     MODULE_NAME    # arg_requester_module
                  ,  function_name    # arg_requester_function
                                                       )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "==================================" )

#=================================
def  make_all_Objects (  ) :

    function_name = "make_all_Object"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "==================================" )

    global global_from_Z
    global global_to_Z
    global global_number_of_Object

#******************************************
    list_of_Objects = [ ]
    list_Object_information = [ ]

    #******************************************
              # [ id , name , type , Center_of_Object_location_x , y , mode of radiation V ]
                  #======== Ground ========
    list_Object_information   \
        .append ( [ "1"  ,  "Ground" , "H" , 350 , 350 , "B" ] )
                  #======== Fence========
    list_Object_information   \
        .append ( [ "2"  ,  "Fence" , "V" , 350 , 350 , "B" ] )
                   #======== House ========
                        # --- 4 pillar s --------
    list_Object_information   \
        .append ( [ "3"  ,  "Pillar" , "V" , 430 , 300 , "B"] )
    list_Object_information   \
        .append ( [ "4"  ,  "Pillar" , "V" , 430 , 400 , "B"] )
    list_Object_information   \
        .append ( [ "5"  ,  "Pillar" , "V" , 470 , 300 , "B"] )
    list_Object_information   \
        .append ( [ "6"  ,  "Pillar" , "V" , 470 , 400 , "B"] )
                        # --- wall --------
    list_Object_information   \
        .append ( [ "7"  ,  "Wall1" , "V" , 450 , 350 , "B" ] )
                         # ---roof --------
    list_Object_information   \
        .append ( [ "8"  ,  "Roof1" , "H" , 450 , 350 , "X" ] )
                    #======== Tower ========
                        # --- 4 pillar s --------
    list_Object_information   \
        .append ( [ "9"  ,  "Pillar" , "V" , 150 , 300 , "B"] )
    list_Object_information   \
        .append ( [ "10"  ,  "Pillar" , "V" , 250 , 300 , "B"] )
    list_Object_information   \
        .append ( [ "11"  ,  "Pillar" , "V" , 150 , 400 , "B"] )
    list_Object_information   \
        .append ( [ "12"  ,  "Pillar" , "V" , 250 , 400 , "B"] )
                                # --- corridor --------
    list_Object_information   \
        .append ( [ "13"  ,  "Corridor2" , "H" , 200 , 350 , "B" ] )
                        # --- wall --------
    list_Object_information   \
        .append ( [ "14"  ,  "Wall2" , "V" , 200 , 350 , "B" ] )
                         # ---roof --------
    list_Object_information   \
        .append ( [ "15"  ,  "Roof2" , "H" , 200 , 350 , "B" ] )

#******************************************
    global_number_of_Object = 15
#******************************************

    for i in range ( 0 , global_number_of_Object ) :

        information_list_of_Object = \
                list_Object_information [ i ]

        list_of_path = Prepare   \
                                  .make_path_list ( information_list_of_Object [ 1 ] )
             #-------------------------------------------
        Prepare   \
            .make_TextData_contain_VariationOfRadius ( \
                                       # abs_path_of_VariationOfRadius
                                list_of_path [ 2 ]
                           ,           # abs_path_of_TextData_contain_VariationOfRadius
                                list_of_path [ 5 ]
                                                                            )
             #----------------------------------------------
        if ( information_list_of_Object [ 2 ] == "H" ) :
                      # [ type of Object] is [drawing Horizantal direction]
            ins_OneObject \
                  = OneObjectTypeDrawingH   \
                        .OneObjectTypeDrawingH (  \
                              MODULE_NAME   # arg_requester_module
                            , function_name     # arg_requester_function

                            , information_list_of_Object [ 0 ]
                            , information_list_of_Object [ 1 ]  #name of Object

                            , information_list_of_Object [ 3 ]
                            , information_list_of_Object [ 4 ]

                            ,  global_from_Z
                            ,  global_to_Z

                            , list_of_path [ 0 ]   # arg_abs_path_of_ImageData_Basic
                            , list_of_path [ 1 ]   # arg_abs_path_of_ImageData_for_drawing_CrossSectionalView
                            , list_of_path [ 6 ]   # arg_abs_path_ForDrawingSurfaceImage

                            , list_of_path [ 3 ]   # arg_Part_1_of_abs_path_of_ImageData_output
                            , list_of_path [ 4 ]   #arg_Part_2_of_abs_path_of_ImageData_output

                            , list_of_path [ 5 ]   # arg_abs_path_of_TextData_contain_VariationOfRadius

                            , information_list_of_Object [ 5 ]  # mode_of_VariationOfRadius
                                                                )
                        #--------------------------------------
        else :
                        # [ type of Object] is [drawing Vertical direction]
            ins_OneObject \
                  = OneObjectTypeDrawingV   \
                         .OneObjectTypeDrawingV (  \
                                MODULE_NAME   # arg_requester_module
                              , function_name     # arg_requester_function

                              , information_list_of_Object [ 0 ]
                              , information_list_of_Object [ 1 ]  #name of Object

                              , information_list_of_Object [ 3 ]
                              , information_list_of_Object [ 4 ]

                              ,  global_from_Z
                              ,  global_to_Z

                              , list_of_path [ 0 ]   # arg_abs_path_of_ImageData_Basic
                              , list_of_path [ 1 ]   # arg_abs_path_of_ImageData_for_drawing_CrossSectionalView
                              , list_of_path [ 6 ]   # arg_abs_path_ForDrawingSurfaceImage

                              , list_of_path [ 3 ]   # arg_Part_1_of_abs_path_of_ImageData_output
                              , list_of_path [ 4 ]   #arg_Part_2_of_abs_path_of_ImageData_output

                              , list_of_path [ 7 ]   # arg_abs_path_of_TextData_contain_CrossSectionalView
                              , list_of_path [ 5 ]   # arg_abs_path_of_TextData_contain_VariationOfRadius

                              , information_list_of_Object [ 5 ]  # mode_of_VariationOfRadius
                                                                )
                     #-------------------------------------------
        list_of_Objects  \
                .append ( ins_OneObject )

        print ( "==================================" )
        print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
        print ( "one Object has been constructed" )
        print (  "i = " , i )
        print ( "==================================" )

    #-------------------------------------------
    return   list_of_Objects


----------

----------
6 [ Prepare モジュール]

ファイル名 [ Prepare.py ]

----------


import  ImageDataTwoDimensionHandlingV3
import  OneObject
import  DetectCurveInImageData

MODULE_NAME = "Prepare"

#=================================
def  make_path_list ( arg_name_of_Object ) :

    function_name = "make_path_list"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_name_of_Object = " , arg_name_of_Object )
    print ( "==================================" )

    return_list = [ " " , " " , " " , " " , " " , " "  , " " , " " ]

    path_of_Top   \
                  =   "E:ForPython/ForTest/Test_9V2/"
    path_of_directory_InputImageData = "InputImageData/"

    path_of_directory_OutputImageData = "OutputImageData/"

    path_of_directory_ForEachObject = "ForEachObject/"

    path_of_directory_BasicImageData = "BasicImageData/"
    path_of_file_part_1_BasicImageData = "BasicImageData"

    path_of_directory_CrossSectionalView = "CrossSectionalView/"
    path_of_file_part_1_CrossSectionalView = "CrossSectionalView"

    path_of_directory_VariationOfRadius = "VariationOfRadius/"
    path_of_file_part_1_VariationOfRadius = "VariationOfRadius"

    path_of_directory_ForDrawingSurfaceImage = "ForDrawingSurfaceImage/"
    path_of_file_ForDrawingSurfaceImage = "ForDrawingSurfaceImage.png"

    path_of_directory_DrawingImageData = "DrawingImageData/"
    path_of_file_part_1_DrawingImageData = "DrawingImageData"

    path_of_directory_TextData = "TextData/"

    path_of_file_part_2_for_ImageData = ".png"
    path_of_file_part_2_for_TextData = ".txt"

        #------ abs_path_of_ImageData_Basic ----------------
    return_list [ 0 ] = \
               path_of_Top  \
            + path_of_directory_InputImageData \
            + path_of_directory_BasicImageData  \
            + path_of_file_part_1_BasicImageData  \
            + path_of_file_part_2_for_ImageData

    print ( "return_list [ 0 ] = " + return_list [ 0 ] )

        #------ abs_path_of_CrossSectionalView ----------------
    return_list [ 1 ] = \
               path_of_Top  \
            + path_of_directory_InputImageData \
                   + path_of_directory_ForEachObject  \
                   + arg_name_of_Object + "/"      \
            + path_of_directory_CrossSectionalView  \
            + path_of_file_part_1_CrossSectionalView  \
            + path_of_file_part_2_for_ImageData

    print ( "return_list [ 1 ] = " + return_list [ 1 ] )

        #------ abs_path_of_VariationOfRadius ----------------
    return_list [ 2 ] = \
                path_of_Top  \
             + path_of_directory_InputImageData \
                         + path_of_directory_ForEachObject   \
                         + arg_name_of_Object + "/"     \
             + path_of_directory_VariationOfRadius \
             + path_of_file_part_1_VariationOfRadius  \
             + path_of_file_part_2_for_ImageData

    print ( "return_list [ 2 ] = " + return_list [ 2 ] )

            #---- abs_path_of_ImageData_output_part_1 --------------
    return_list [ 3 ] =  \
                path_of_Top  \
             + path_of_directory_OutputImageData \
             + path_of_directory_DrawingImageData \
             + path_of_file_part_1_DrawingImageData  \
             + "_"

    print ( "return_list [ 3 ] = " + return_list [ 3 ] )

            #---- abs_path_of_ImageData_output_part_2 --------------
    return_list [ 4 ] =  \
                 path_of_file_part_2_for_ImageData

    print ( "return_list [ 4 ] = " + return_list [ 4 ] )

      # ----- abs_path_of_TextData_contain_VariationOfRadius ---------------
    return_list [ 5 ] =  \
             path_of_Top  \
          + path_of_directory_TextData \
                   + path_of_directory_ForEachObject    \
                   + arg_name_of_Object + "/"      \
          + path_of_directory_VariationOfRadius \
          + path_of_file_part_1_VariationOfRadius  \
          + path_of_file_part_2_for_TextData

    print ( "return_list [ 5 ] = " + return_list [ 5 ] )

       # ----- abs_path_of_ForDrawingSurfaceImage ---------------
    return_list [ 6 ] = \
               path_of_Top  \
            + path_of_directory_InputImageData \
                        + path_of_directory_ForEachObject   \
                        + arg_name_of_Object + "/"      \
            + path_of_directory_ForDrawingSurfaceImage  \
            + path_of_file_ForDrawingSurfaceImage

    print ( "return_list [ 6 ] = " + return_list [ 6 ] )
    
          # ----- abs_path_of_TextData_contain_CrossSectionalView ---------------
    return_list [ 7 ] =  \
              path_of_Top  \
           + path_of_directory_TextData \
                   + path_of_directory_ForEachObject    \
                   + arg_name_of_Object + "/"      \
           + path_of_directory_CrossSectionalView \
           + path_of_file_part_1_CrossSectionalView  \
           + path_of_file_part_2_for_TextData

    print ( "return_list [ 7 ] = " , return_list [ 7 ] )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "==================================" )

    return return_list

#=================================
def  make_TextData_contain_VariationOfRadius ( \
                arg_abs_path_of_ImageData
              , arg_abs_path_of_TextData
                               ) :

    function_name = "make_TextData_contain_VariationOfRadius"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData = " , arg_abs_path_of_ImageData )
    print ( "arg_abs_path_of_TextData = " , arg_abs_path_of_TextData )
    print ( "==================================" )

    DetectCurveInImageData  \
        .detect_Curve_in_ImageData ( \
                arg_abs_path_of_ImageData
              , arg_abs_path_of_TextData
               )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData = " , arg_abs_path_of_ImageData )
    print ( "arg_abs_path_of_TextData = " , arg_abs_path_of_TextData )
    print ( "==================================" )

#=================================
def  make_SectionImageData_of_initial_status ( \
           arg_abs_path_of_ImageData_Basic
         , arg_abs_path_of_ImageData_output_part_1
         , arg_abs_path_of_ImageData_output_part_2

         ,  arg_from_Z
         ,  arg_to_Z
                                                            ) :

    function_name = "make_SectionImageData_of_initial_status"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData_Basic = " \
              + arg_abs_path_of_ImageData_Basic )
    print ( "arg_abs_path_of_ImageData_output_part_1 = " \
              + arg_abs_path_of_ImageData_output_part_1 )
    print ( "arg_abs_path_of_ImageData_output_part_2 = " \
              + arg_abs_path_of_ImageData_output_part_2 )
    print ( "==================================" )

    ins_ImageDataTwoDimensionHandling_BasicImage = \
        ImageDataTwoDimensionHandlingV3   \
          .ImageDataTwoDimensionHandlingV3 ( MODULE_NAME , function_name )
    ins_ImageDataTwoDimensionHandling_BasicImage  \
         .load_image_data ( \
                     MODULE_NAME \
                   , function_name
                   , arg_abs_path_of_ImageData_Basic
                     )

    from_Z = arg_from_Z
    to_Z = arg_to_Z

    current_Z = from_Z
    while ( current_Z <= to_Z ) :

        make_and_write_ImageData_for_directed_Z ( \
                current_Z
              , ins_ImageDataTwoDimensionHandling_BasicImage
              , arg_abs_path_of_ImageData_output_part_1
              , arg_abs_path_of_ImageData_output_part_2
                                     )
        print ( "==================================" )
        print ( "Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
        print ( "current_Z = " , current_Z )
        print ( "to_Z = " , to_Z )
        print ( "==================================" )

        current_Z += 1

      #---------------------------------------------------
def  make_and_write_ImageData_for_directed_Z ( \
                arg_z
              , arg_ins_ImageDataTwoDimensionHandling_BasicImage
              , arg_abs_path_of_ImageData_output_part_1
              , arg_abs_path_of_ImageData_output_part_2
                ) :

    function_name = "make_and_write_ImageData_for_directed_Z"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_z = " , arg_z )
    print ( "==================================" )

    abs_path_of_write = \
            make_abs_path ( \
                arg_z
              , arg_abs_path_of_ImageData_output_part_1
              , arg_abs_path_of_ImageData_output_part_2
                           )
    arg_ins_ImageDataTwoDimensionHandling_BasicImage \
              .write_loaded_image_data_to_directed_path (
                          MODULE_NAME
                        , function_name
                        , abs_path_of_write )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "Has been written , " + abs_path_of_write )
    print ( "==================================" )

          #------------------------------------------------------------
def  make_abs_path (  \
                     arg_z
                   , arg_abs_path_of_ImageData_output_part_1
                   , arg_abs_path_of_ImageData_output_part_2
                    ) :

    function_name = "make_abs_path"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_z = " , arg_z  )
    print ( "arg_abs_path_of_ImageData_output_part_1 = " \
              , arg_abs_path_of_ImageData_output_part_1  )
    print ( "arg_abs_path_of_ImageData_output_part_2 = " \
              , arg_abs_path_of_ImageData_output_part_2  )
    print ( "==================================" )

    if ( arg_z < 10 ) :
        string_of_file_order_number = "0" + str ( arg_z )
    else :
        string_of_file_order_number = str ( arg_z )

    return_abs_path_of_ImageDataFile =    \
             arg_abs_path_of_ImageData_output_part_1  \
           + string_of_file_order_number   \
           + arg_abs_path_of_ImageData_output_part_2

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "return_abs_path_of_ImageDataFile = " \
              + return_abs_path_of_ImageDataFile )
    print ( "==================================" )

    return  return_abs_path_of_ImageDataFile

    #------------------------------------------------------------
def  prepare_ImageData_BasicImage ( \
                 arg_abs_path_of_ImageData_Basic ) :

    function_name = "prepare_ImageData_BasicImage"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "arg_abs_path_of_ImageData_Basic = " \
                + arg_abs_path_of_ImageData_Basic )
    print ( "==================================" )

    return_ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandling  \
                 .ImageDataTwoDimensionHandling ( \
                          MODULE_NAME
                        , function_name
                                           )
    return_ins_ImageDataTwoDimensionHandling  \
           .load_image_data ( \
                          MODULE_NAME
                        , function_name
                        , arg_abs_path_of_ImageData_Basic
                         )

    width_of_BasicImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
    height_of_BasicImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )

    print ( "==================================" )
    print ( "Exit from , Module = " + MODULE_NAME
                      + " ,  function = " + function_name )
    print ( "width_of_BasicImage = " , width_of_BasicImage )
    print ( "height_of_BasicImage = " , height_of_BasicImage )
    print ( "==================================" )

    return  return_ins_ImageDataTwoDimensionHandling

----------

----------
7 [ DetectCurveInImageData モジュール]

ファイル名 [ DetectCurveInImageData.py ]

----------


#=============================
# DetectCurveInImageData
#     detect Curve in ImageData
#       , and make text file of cordinates of the Curve
#=============================

import  ImageDataTwoDimensionHandlingV3
import  TextFileHandling

MODULE_NAME = "DetectCurveInImageData"

    #------------------------------------------------------------
def detect_Curve_in_ImageData ( \
                arg_abs_path_of_ImageData
              , arg_abs_path_of_TextData
                            ) :

    function_name = "detect_Curve_in_ImageData"

    print ( "==================================" )
    print ( "Enter into , Module = " + MODULE_NAME
                      + " , function = " + function_name )

    print ( "arg_abs_path_of_ImageData = " \
         + arg_abs_path_of_ImageData )
    print ( "arg_abs_path_of_TextData_ = " \
         + arg_abs_path_of_TextData )
    print ( "==================================" )

    ins_ImageDataTwoDimensionHandling = \
         ImageDataTwoDimensionHandlingV3   \
            .ImageDataTwoDimensionHandlingV3 ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
                                        )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " , function = " + function_name )

    print ( "arg_abs_path_of_ImageData = " \
         + arg_abs_path_of_ImageData )
    print ( "==================================" )

    ins_ImageDataTwoDimensionHandling  \
         .load_image_data ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
               , arg_abs_path_of_ImageData
                      )
    width_of_ImageData = \
         ins_ImageDataTwoDimensionHandling \
             .get_width_of_ImageData ( )
    height_of_ImageData = \
         ins_ImageDataTwoDimensionHandling \
             .get_height_of_ImageData ( )

    print ( "==================================" )
    print ( "Module = " + MODULE_NAME
                      + " , function = " + function_name )
    print ( "arg_abs_path_of_ImageData = " \
             + arg_abs_path_of_ImageData )
    print ( "width_of_ImageData = " , width_of_ImageData )
    print ( "height_of_ImageData = " , height_of_ImageData )
    print ( "==================================" )

      # --------------------------------
    ins_TextFileHandling_1 = \
         TextFileHandling   \
            .TextFileHandling ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
               , arg_abs_path_of_TextData
                         # arg_character_used_for_delimiter
               , ","
                              )
    ins_TextFileHandling_1   \
        .do_open_process_output_mode ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
                                      )
       # ---------------------------------

    result_of_detect = [ " " , 0 , 0 , 0.0 , 0.0 ]
    for get_location_y  \
              in range ( height_of_ImageData ) :

        result_of_detect = detect_for_one_y ( \
                                   get_location_y
                                ,  ins_ImageDataTwoDimensionHandling
                                ,  width_of_ImageData
                                ,  height_of_ImageData
                                    )

        ins_TextFileHandling_1   \
            .do_write_one_line_process (    \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
               , result_of_detect  # arg_list_values_for_output_one_line
                                     )

         # -------------------------------------
    ins_TextFileHandling_1   \
        .do_close_process ( \
                 MODULE_NAME #  arg_requester_module
               , function_name   # arg_requester_function
                      )

    print ( "==================================" )
    print ( "Exit from into , Module = " + MODULE_NAME
                      + " , function = " + function_name )
    print ( "==================================" )

        #------------------------------------------------
def detect_for_one_y ( arg_get_location_y  \
                     , arg_ins_ImageDataTwoDimensionHandling
                     , arg_width_of_ImageData
                     , arg_height_of_ImageData
                      ) :

    function_name = "detect_for_one_y"

      #--------------------
    return_list = [ "N" , -999 , arg_get_location_y , 0.0 , 0.0 ]

    get_location_x = 0

    process_continue = "Y"
    while ( process_continue == "Y" ) :

        if ( get_location_x >= arg_width_of_ImageData ) :
              # pixel of Curve was not found
            process_continue = "N"
            return  return_list

            #-----------------------
        color_value = \
           arg_ins_ImageDataTwoDimensionHandling \
              .get_data_of_one_pixel ( \
                    MODULE_NAME #  arg_requester_module
                  , function_name   # arg_requester_function
                              # in the commonly used mathematical XY cordinates
                  , get_location_x  # arg_x_on_ImageData_space
                  , arg_get_location_y
                                  )

        if ( ( color_value [ 2 ] > 200 )   \
             and                          \
             ( color_value [ 0 ] < 200 )   \
             and                          \
             ( color_value [ 1 ] < 200 )   \
           ) :
           # color Red , found pixel of Curve
            return_list [ 0 ] = "Y"
            return_list [ 1 ] =  get_location_x

            return_list [ 3 ] =  \
                float ( return_list [ 1 ] ) /    \
                   float ( arg_width_of_ImageData)
            return_list [ 4 ] =  \
                float ( return_list [ 2 ] ) /    \
                   float ( arg_height_of_ImageData)

            return  return_list

        get_location_x += 1

#-----------------------------

----------

----------
8 [ OneObject モジュール]

ファイル名 [ OneObject.py ]

----------


import  sys

import  Prepare
import  TextFileHandling
import  ImageDataTwoDimensionHandlingV3
import  ErrorProcess

#===========================================
class OneObject :

    CV_CLASS_NAME = "OneObject"

    #------------------------------------------------------------
            # definition of constructer ( set encording to UTF-8 )

    def __init__( self
                      , arg_requester_module
                      , arg_requester_function

                      , arg_id_of_Object
                      , arg_name_of_Object

                      , arg_type_of_Object

                      , arg_Center_of_Object_location_x
                      , arg_Center_of_Object_location_y

                      ,  arg_from_z
                      ,  arg_to_z

                      , arg_abs_path_of_ImageData_Basic
                      , arg_abs_path_of_ImageData_CrossSectionalImage
                      , arg_abs_path_of_ImageData_ForDrawingSurfaceImage

                      , arg_Part_1_of_abs_path_of_ImageData_output
                      , arg_Part_2_of_abs_path_of_ImageData_output

                      , arg_abs_path_of_TextData_contain_CrossSectionalImage
                      , arg_abs_path_of_TextData_contain_VariationOfRadius

                      , arg_mode_of_VariationOfRadius
                     ):

        methode_name = "constructer"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "    arg_id_of_Object = " , arg_id_of_Object )
        print ( "    arg_name_of_Object = " , arg_name_of_Object )
        print ( "==================================" )

        self.iv_id_of_Object = arg_id_of_Object
        self.iv_name_of_Object  = arg_name_of_Object
        self.iv_type_of_Object = arg_type_of_Object
            #-----------------------------------
        self.iv_Center_of_Object_location_x = arg_Center_of_Object_location_x
        self.iv_Center_of_Object_location_y = arg_Center_of_Object_location_y
             #----------------------------------
        self.iv_from_z = arg_from_z
        self.iv_to_z = arg_to_z
        self.iv_length_z = self.iv_to_z - self.iv_from_z

        print ( "==================================" )
        print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "self.iv_from_z = " , self.iv_from_z )
        print ( "self.iv_to_z = " , self.iv_to_z )
        print ( "self.iv_length_z = " , self.iv_length_z )
        print ( "==================================" )

             #------------------------------
        self.iv_abs_path_of_TextData_contain_VariationOfRadius = \
              arg_abs_path_of_TextData_contain_VariationOfRadius
        print ( "self.iv_abs_path_of_TextData_contain_VariationOfRadius = "
              , self.iv_abs_path_of_TextData_contain_VariationOfRadius )
        self.iv_ins_TextFileHandling_VariationOfRadius  \
               = self.prepare_TextFileHandling_VariationOfRadius ( )

        self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = 0
        self.iv_total_number_of_information_VariationOfRadius = 0
        self.iv_readed_data_in_TextFileHandling_VariationOfRadius = ""

        self.iv_mode_of_VariationOfRadius = arg_mode_of_VariationOfRadius

             # ----------------------------------
        self.iv_abs_path_of_ImageData_Basic = \
              arg_abs_path_of_ImageData_Basic
        print ( "self.iv_abs_path_of_ImageData_Basic = " \
                      + self.iv_abs_path_of_ImageData_Basic )
        self.iv_ins_ImageDataTwoDimensionHandling_BasicImage  \
               = self.prepare_ImageData_BasicImage (  )
             # ----------------------------------
        self.iv_abs_path_of_ImageData_CrossSectionalImage = \
              arg_abs_path_of_ImageData_CrossSectionalImage
        print ( "self.iv_abs_path_of_ImageData_CrossSectionalImage = " \
                      + self.iv_abs_path_of_ImageData_CrossSectionalImage )
        self.iv_ins_ImageDataTwoDimensionHandling_CrossSectionalImage  \
               = self.prepare_ImageData_of_CrossSectionalImage (   )
               #-----------------------------------------
        self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage = \
               arg_abs_path_of_ImageData_ForDrawingSurfaceImage
        print ( "self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage = "
              , self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage )
        self.iv_ins_ImageData_ForDrawingSurfaceImage  \
               = self.prepare_ImageData_ForDrawingSurfaceImage (  )
              #-----------------------------------------
        self.iv_abs_path_of_ImageData_output_part_1 = \
               arg_Part_1_of_abs_path_of_ImageData_output
        print ( "self.iv_abs_path_of_ImageData_output_part_1 = "
              , self.iv_abs_path_of_ImageData_output_part_1 )
        self.iv_Part_2_of_abs_path_of_ImageData_output = \
                 arg_Part_2_of_abs_path_of_ImageData_output
        print ( "self.iv_Part_2_of_abs_path_of_ImageData_output = "
              , self.iv_Part_2_of_abs_path_of_ImageData_output )
           #=================================
        self.iv_rate_on_XYPlane = 0.0
           #=================================

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "==================================" )

            #------------------------------------------------------------
    def vary_ImageData_for_all_z ( self
                               ,  arg_requester_module
                               ,  arg_requester_function ) :

        methode_name = "make_ImageData_for_all_z"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "==================================" )

        self.prepare_TextFileHandling_VariationOfRadius ( )

        current_z = self.iv_from_z
        while ( current_z <= self.iv_to_z ) :

            z_rate = float ( current_z ) / float ( self.iv_length_z )
            self.prepare_for_directed_z ( current_z ,  z_rate )

            if ( self.iv_exist_information_of_VariationOfRadius == "Y" ) :
                self.over_draw_on_loaded_image_data ( \
                                       current_z
                                     , z_rate
                                     , self.iv_ins_ImageDataTwoDimensionHandling_for_redrawing
                                     , self.iv_abs_path_of_ImageDataFile_for_redrawing
                                                                       )

            print ( "==================================" )
            print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
            print ( "current_z = " , current_z )
            print ( "self.iv_to_z = " , self.iv_to_z )
            print ( "z_rate = " , z_rate )
            print ( "==================================" )

            current_z += 1

       #---------------------------------------------------
       # This methode must be over written by [Inheriting Class]
    def   over_draw_on_loaded_image_data ( \
                                       arg_current_z
                                     , arg_z_rate
                                     , arg_ins_ImageDataTwoDimensionHandling_for_redrawing
                                     , arg_abs_path_of_ImageDataFile_for_redrawing
                                          ) :

            methode_name = "___must be over written___"

            print ( "==================================" )
            print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
            print ( "==================================" )

       #---------------------------------------------------
    def  prepare_for_directed_z ( self , arg_z , arg_z_rate ) :

        methode_name = "prepare_for_directed_z"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "arg_z_rate = " ,  arg_z_rate )
        print ( "==================================" )

        self.iv_ins_ImageDataTwoDimensionHandling_for_redrawing = \
                self.get_Drawing_ImageData ( arg_z )
              #-------------------------------------------------
        result_list = \
                self.get_information_of_VariationOfRadius (  arg_z_rate , arg_z_rate )
        self.iv_exist_information_of_VariationOfRadius = result_list [ 1 ]
        self.iv_rate_on_XYPlane = float ( result_list [ 2 ] )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "result_list = " , result_list )
        print ( "self.iv_exist_information_of_VariationOfRadius = " \
                , self.iv_exist_information_of_VariationOfRadius )
        print ( "self.iv_rate_on_XYPlane = " \
                , self.iv_rate_on_XYPlane )
        print ( "==================================" )

    #------------------------------------------------------------
    def  prepare_TextFileHandling_VariationOfRadius ( self ) :

        methode_name = "prepare_TextFileHandling_VariationOfRadius"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

          #----------------------------------------
        self.iv_ins_TextFileHandling_VariationOfRadius = \
             TextFileHandling   \
                   .TextFileHandling (  \
                          OneObject.CV_CLASS_NAME     # arg_requester_module
                        , methode_name  #arg_requester_function
                        , self.iv_abs_path_of_TextData_contain_VariationOfRadius
                        , ","     # arg_character_used_for_delimiter
                                        )
                # ---- get total number of information in TextFile -----
                    # ---- open Text File -------
        self.iv_ins_TextFileHandling_VariationOfRadius   \
                .do_open_process_input_mode (
                       OneObject.CV_CLASS_NAME     # arg_requester_module
                     , methode_name                      #arg_requester_function
                      )
                    # ---- read all datas in Text File -------
        self.iv_total_number_of_information_VariationOfRadius = 0

        process_continue = "Y"
        while ( process_continue == "Y" ) :
            result_of_reading = \
                 self.iv_ins_TextFileHandling_VariationOfRadius   \
                        .do_read_one_line_process (
                                 OneObject.CV_CLASS_NAME     # arg_requester_module
                                , methode_name                      #arg_requester_function
                                                               )
            if ( result_of_reading [ 0 ] == "E" ) :
                           #reached to file end
                process_continue = "N"
                break

            self.iv_total_number_of_information_VariationOfRadius += 1

        print ( "-----------------------------------------" )
        print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "self.iv_total_number_of_information_VariationOfRadius = " \
                  , self.iv_total_number_of_information_VariationOfRadius )
        print ( "-----------------------------------------" )

                    # ---- close Text File -------
        self.iv_ins_TextFileHandling_VariationOfRadius   \
                       .do_close_process ( \
                             OneObject.CV_CLASS_NAME     # arg_requester_module
                           , methode_name                      #arg_requester_function
                                                             )
                      # ---- re open Text File -------
        self.iv_ins_TextFileHandling_VariationOfRadius  \
                .do_open_process_input_mode ( \
                       OneObject.CV_CLASS_NAME     # arg_requester_module
                     , methode_name       #arg_requester_function
                                       )

        self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = 0

                    # --- read first data
        self.iv_readed_data_in_TextFileHandling_VariationOfRadius \
           = self.iv_ins_TextFileHandling_VariationOfRadius   \
                     .do_read_one_line_process (\
                         OneObject.CV_CLASS_NAME     # arg_requester_module
                       , methode_name                      #arg_requester_function
                       )
        self.iv_readed_counter_for_TextFileHandling_VariationOfRadius += 1

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "self.iv_total_number_of_information_VariationOfRadius = " \
                   , self.iv_total_number_of_information_VariationOfRadius )
        print ( "self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = " \
                   , self.iv_readed_counter_for_TextFileHandling_VariationOfRadius )
        print ( "==================================" )

    #------------------------------------------------------------
    def  get_Drawing_ImageData ( self , arg_z ) :

        methode_name = "get_Drawing_ImageData"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "arg_z = " , arg_z )
        print ( "==================================" )

        self.iv_abs_path_of_ImageDataFile_for_redrawing \
              = self.make_abs_path ( arg_z )

        return_ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandlingV3  \
                 .ImageDataTwoDimensionHandlingV3 ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                                           )
        return_ins_ImageDataTwoDimensionHandling  \
               .load_image_data ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                        , self.iv_abs_path_of_ImageDataFile_for_redrawing
                                          )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        return  return_ins_ImageDataTwoDimensionHandling

    #------------------------------------------------------------
    def  prepare_ImageData_BasicImage ( self ) :

        methode_name = "prepare_ImageData_BasicImage"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        return_ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandlingV3  \
                 .ImageDataTwoDimensionHandlingV3 ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                                           )
        return_ins_ImageDataTwoDimensionHandling  \
           .load_image_data ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                        , self.iv_abs_path_of_ImageData_Basic
                         )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        return  return_ins_ImageDataTwoDimensionHandling

    #------------------------------------------------------------
    def  prepare_ImageData_of_CrossSectionalImage ( self ) :

        methode_name = "prepare_ImageData_of_CrossSectionalImage"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        return_ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandlingV3  \
                  .ImageDataTwoDimensionHandlingV3 ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                                           )
        print ( "==================================" )
        print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        print ( "self.iv_abs_path_of_ImageData_CrossSectionalImage = " \
          + self.iv_abs_path_of_ImageData_CrossSectionalImage )

        return_ins_ImageDataTwoDimensionHandling  \
              .load_image_data ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                        , self.iv_abs_path_of_ImageData_CrossSectionalImage
                         )

        self.iv_width_of_CrossSectionalView = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
        self.iv_height_of_CrossSectionalView = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "width = " \
            , return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
             )
        print ( "height = " \
            , return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )
             )
        print ( "==================================" )

        return  return_ins_ImageDataTwoDimensionHandling

    #------------------------------------------------------------
    def  prepare_ImageData_ForDrawingSurfaceImage ( self ) :

        methode_name = "prepare_ImageData_ForDrawingSurfaceImage"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        return_ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandlingV3  \
                 .ImageDataTwoDimensionHandlingV3 ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                                           )
        print ( "==================================" )
        print ( "Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        print ( "self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage = " \
          + self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage )

        return_ins_ImageDataTwoDimensionHandling  \
               .load_image_data ( \
                          OneObject.CV_CLASS_NAME
                        , methode_name
                        , self.iv_abs_path_of_ImageData_ForDrawingSurfaceImage
                         )

        self.iv_width_of_ImageData_ForDrawingSurfaceImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
        self.iv_height_of_ImageData_ForDrawingSurfaceImage = \
            return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "width = " \
            , return_ins_ImageDataTwoDimensionHandling  \
                        .get_width_of_ImageData (  )
             )
        print ( "height = " \
            , return_ins_ImageDataTwoDimensionHandling  \
                        .get_height_of_ImageData (  )
             )
        print ( "==================================" )

        return  return_ins_ImageDataTwoDimensionHandling

        #---------------------------------------------------
    def  get_information_of_VariationOfRadius ( self  \
                                          ,  arg_z , arg_z_rate ) :

        methode_name = "get_information_of_VariationOfRadius"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

        return_list = [ "N" , "N" , 0.0 ]

        current_rate_for_z = \
            float ( self.iv_readed_counter_for_TextFileHandling_VariationOfRadius ) \
              / float ( self.iv_total_number_of_information_VariationOfRadius )

        if ( current_rate_for_z > arg_z_rate ) : \
                      #process error
            print ( "==================================" )
            print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
            print ( "!!!!! process error , [ current_rate_for_z > arg_z_rate ]" )
            print ( "current_rate_for_z = " , current_rate_for_z )
            print ( "arg_z_rate = " ,  arg_z_rate )
            print ( "self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = " \
                  ,  self.iv_readed_counter_for_TextFileHandling_VariationOfRadius )
            print ( "self.iv_total_number_of_information_VariationOfRadius = " \
                   ,  self.iv_total_number_of_information_VariationOfRadius )
            print ( "==================================" )

            return return_list
              #--------------------------------
        process_continue = "Y"
        while ( process_continue == "Y" ) :

            current_rate_for_z = \
                  float ( self.iv_readed_counter_for_TextFileHandling_VariationOfRadius ) \
                    / float ( self.iv_total_number_of_information_VariationOfRadius )

            #print ( "==================================" )
            #print ( "Class = " + OneObject.CV_CLASS_NAME
            #                  + " , methode = " + methode_name )

            #print ( "self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = " \
            #          ,  self.iv_readed_counter_for_TextFileHandling_VariationOfRadius )
            #print ( "self.iv_total_number_of_information_VariationOfRadius = " \
            #          ,  self.iv_total_number_of_information_VariationOfRadius )
            #print ( "current_rate_for_z = " \
            #          ,  current_rate_for_z )
            #print ( "arg_z_rate = " \
            #          ,  arg_z_rate )
            #print ( "==================================" )

                  #--------------------------------
            if ( current_rate_for_z >= arg_z_rate ) :
                if ( self.iv_readed_data_in_TextFileHandling_VariationOfRadius [ 0 ] \
                         == "E" ) :
                                             #process error
                    print ( "==================================" )
                    print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
                    print ( "!!!!! process error , reached end" )
                    print ( "current_rate_for_z = " , current_rate_for_z )
                    print ( "arg_z_rate = " ,  arg_z_rate )
                    print ( "self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = " \
                      ,  self.iv_readed_counter_for_TextFileHandling_VariationOfRadius )
                    print ( "self.iv_total_number_of_information_VariationOfRadius = " \
                      ,  self.iv_total_number_of_information_VariationOfRadius )
                    print ( "==================================" )

                    return return_list

                process_continue = "Y"

                return_list [ 0 ] = "Y"
                return_list [ 1 ] =  \
                   self.iv_readed_data_in_TextFileHandling_VariationOfRadius [ 1 ]
                return_list [ 2 ] = \
                   self.iv_readed_data_in_TextFileHandling_VariationOfRadius [ 4 ]

                   #*****************************
                   # OK return
                   #*****************************

                print ( "==================================" )
                print ( "Exit from , Class = " + OneObject.CV_CLASS_NAME
                      + " , methode = " + methode_name )
                print ( "OK return" )
                print ( "return_list = " , return_list )
                print ( "self.iv_readed_data_in_TextFileHandling_VariationOfRadius = " \
                      , self.iv_readed_data_in_TextFileHandling_VariationOfRadius )
                print ( "==================================" )

                return return_list

                                      # --- read next data
            self.iv_readed_data_in_TextFileHandling_VariationOfRadius \
               = self.iv_ins_TextFileHandling_VariationOfRadius   \
                     .do_read_one_line_process ( \
                         OneObject.CV_CLASS_NAME     # arg_requester_module
                       , methode_name                      #arg_requester_function
                                                 )
            self.iv_readed_counter_for_TextFileHandling_VariationOfRadius += 1

          #------------------------------------------------------------
    def  make_abs_path ( self \
                             , arg_z ) :

        if ( arg_z < 10 ) :
            string_of_file_order_number = "0" + str ( arg_z )
        else :
            string_of_file_order_number = str ( arg_z )

        abs_path_of_ImageDataFile =    \
             self.iv_abs_path_of_ImageData_output_part_1  \
           + string_of_file_order_number   \
           + self.iv_Part_2_of_abs_path_of_ImageData_output  \

        return  abs_path_of_ImageDataFile

#=============================================

----------

----------
9 [ OneObjectTypeDrawingH モジュール ]

ファイル名 [ OneObjectTypeDrawingH.py ]

----------


# import  ImageDataTwoDimensionHandlingV3

import  OneObject

#===========================================
class OneObjectTypeDrawingH ( OneObject.OneObject )  :

    CV_CLASS_NAME = "OneObjectTypeDrawingH"

    #------------------------------------------------------------
            # definition of constructer ( set encording to UTF-8 )

    def __init__( self
                      , arg_requester_module
                      , arg_requester_function

                      , arg_id_of_Object
                      , arg_name_of_Object

                      , arg_Center_of_Object_location_x
                      , arg_Center_of_Object_location_y

                      ,  arg_from_z
                      ,  arg_to_z

                      , arg_abs_path_of_ImageData_Basic
                      , arg_abs_path_of_ImageData_CrossSectionalImage
                      , arg_abs_path_of_ImageData_ForDrawingSurfaceImage

                      , arg_Part_1_of_abs_path_of_ImageData_output
                      , arg_Part_2_of_abs_path_of_ImageData_output

                      , arg_abs_path_of_TextData_contain_VariationOfRadius
                      , arg_mode_of_VariationOfRadius
                       ):

        methode_name = "constructer"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "    arg_id_of_Object = " , arg_id_of_Object )
        print ( "    arg_name_of_Object = " , arg_name_of_Object )
        print ( "==================================" )

                    # drawing mode = Horizontal
        type_of_Object = "H"

        super().__init__( \
                       arg_requester_module
                      , arg_requester_function

                      , arg_id_of_Object
                      , arg_name_of_Object

                      , type_of_Object

                      , arg_Center_of_Object_location_x
                      , arg_Center_of_Object_location_y

                      ,  arg_from_z
                      ,  arg_to_z

                      , arg_abs_path_of_ImageData_Basic
                      , arg_abs_path_of_ImageData_CrossSectionalImage
                      , arg_abs_path_of_ImageData_ForDrawingSurfaceImage

                      , arg_Part_1_of_abs_path_of_ImageData_output
                      , arg_Part_2_of_abs_path_of_ImageData_output

                      , "___ Not Use ___"   # arg_abs_path_of_TextData_contain_CrossSectionalImage
                      , arg_abs_path_of_TextData_contain_VariationOfRadius

                      , arg_mode_of_VariationOfRadius
                 )

            #-----------------------------------
        self.iv_from_x = 0
        self.iv_to_x = ( self.iv_ins_ImageDataTwoDimensionHandling_CrossSectionalImage    \
                                     .get_width_of_ImageData (  )     \
                             ) - 1
        self.iv_inliment_x = 1
        self.iv_median_x = int ( ( self.iv_from_x + self.iv_to_x ) / 2.0 )

        self.iv_Center_of_Object_location_x = \
                  arg_Center_of_Object_location_x
             #----------------------------------
        self.iv_from_y  = 0
        self.iv_to_y = ( self.iv_ins_ImageDataTwoDimensionHandling_CrossSectionalImage    \
                                 .get_height_of_ImageData (  )    \
                              ) - 1
        self.iv_inliment_y = 1
        self.iv_median_y = int ( ( self.iv_from_y + self.iv_to_y ) / 2.0 )

        self.iv_Center_of_Object_location_y = \
                  arg_Center_of_Object_location_y
             #----------------------------------
        self.iv_half_width_of_ImageData_ForDrawingSurfaceImage \
             =  int (                                                                              \
                         ( self.iv_ins_ImageData_ForDrawingSurfaceImage   \
                                   .get_width_of_ImageData (  )                       \
                          )                                                                         \
                             / 2.0                                                                \
                       )
        self.iv_half_height_of_ImageData_ForDrawingSurfaceImage \
             =  int (                                                                              \
                         ( self.iv_ins_ImageData_ForDrawingSurfaceImage   \
                                   .get_height_of_ImageData (  )                       \
                          )                                                                         \
                             / 2.0                                                                \
                       )
              #-----------------------------------------

        print ( "==================================" )
        print ( "Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
                      + " , methode = " + methode_name )

        print ( "self.iv_from_x = " , self.iv_from_x )
        print ( "self.iv_to_x = " , self.iv_to_x )
        print ( "self.iv_inliment_x = " , self.iv_inliment_x )
        print ( "self.iv_Center_of_Object_location_x = "  \
                     , self.iv_Center_of_Object_location_x )

        print ( "self.iv_from_y = " , self.iv_from_y )
        print ( "self.iv_to_y = " , self.iv_to_y )
        print ( "self.iv_inliment_y = " , self.iv_inliment_y )
        print ( "self.iv_Center_of_Object_location_y = "  \
                     , self.iv_Center_of_Object_location_y )

        print ( "self.iv_from_z = " , self.iv_from_z )
        print ( "self.iv_to_z = " , self.iv_to_z )
        print ( "self.iv_length_z = " , self.iv_length_z )

        print ( "==================================" )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "==================================" )

        # ********************************************************
        # -------- over draw on above loaded image data -------
        # ********************************************************
    def   over_draw_on_loaded_image_data ( self  \
                                     ,  arg_z
                                     ,  arg_z_rate
                                     ,  arg_ins_ImageDataTwoDimensionHandling_for_redrawing
                                     ,  arg_abs_path_of_ImageDataFile_for_redrawing
                                                                ) :

        methode_name = "over_draw_on_loaded_image_data"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "arg_z = " , arg_z )
        print ( "arg_z_rate  = " , arg_z_rate  )
        print ( "==================================" )

            # ------------ draw each locations ------------
        value_x = self.iv_from_x
        while ( value_x <= self.iv_to_x ) :
            value_y = self.iv_from_y
            while ( value_y <= self.iv_to_y ) :

                self.draw_one_point_on_ImageData ( \
                          value_x
                        , value_y
                        , arg_ins_ImageDataTwoDimensionHandling_for_redrawing
                        , self.iv_rate_on_XYPlane
                                                                          )

                value_y += self.iv_inliment_y

            value_x += self.iv_inliment_x

           #-------------------------------------
        arg_ins_ImageDataTwoDimensionHandling_for_redrawing   \
                .write_loaded_image_data_to_directed_path (    \
                          OneObjectTypeDrawingH.CV_CLASS_NAME
                        , methode_name
                        , arg_abs_path_of_ImageDataFile_for_redrawing )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

          #---------------------------------------------------
    def  draw_one_point_on_ImageData ( self \
                       , arg_value_x , arg_value_y
                       , arg_ins_ImageDataTwoDimensionHandling_Target
                       , arg_rate_on_XYPlane
                                     ) :

        methode_name = "draw_one_point_on_ImageData"

        if ( self.iv_exist_information_of_VariationOfRadius [ 0 ] == "N" ) :
               # there is no rate value for this z
               # , so not draw
            return "N"

        #print ( "==================================" )
        #print ( "Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
        #              + " , methode = " + methode_name )
        #print ( "arg_value_x  = " , arg_value_x )
        #print ( "arg_value_y  = " , arg_value_y )
        #print ( "==================================" )

        list_drawing_location = \
              self.decide_location_of_drawing (   \
                                arg_value_x , arg_value_y   \
                             ,  arg_rate_on_XYPlane  )
        list_vector_from_Center_of_object_to_drawing_location =  [ \
                             list_drawing_location [ 2 ]     \
                          ,  list_drawing_location [ 3 ]     \
                                                                                               ]
              #------------------------------------------------------------
        color_list = \
            self.decide_drawing_color (   \
                        list_vector_from_Center_of_object_to_drawing_location
                                                   )
            #------------------------------------------
        if ( ( color_list [ 0 ] == "O" )  #Over Area
              or
             ( color_list [ 0 ] == "W" )  #Color = White ( not draw )
          ) :
               # do not draw at this point
            return "N"
                #------------------------------------------
        if ( color_list [ 0 ] == "B" ) :
                               #draw Black
                self.draw_this_point ( \
                      list_drawing_location [ 0 ]
                    , list_drawing_location [ 1 ]
                    , 0 #Blue
                    , 0 #Green
                    , 0 #Red
                    , arg_ins_ImageDataTwoDimensionHandling_Target
                                 )
        else :
               # draw at this point
              self.draw_this_point ( \
                    list_drawing_location [ 0 ]
                  , list_drawing_location [ 1 ]
                  , color_list [ 1 ] #Blue
                  , color_list [ 2 ] #Green
                  , color_list [ 3 ] #Red
                  , arg_ins_ImageDataTwoDimensionHandling_Target
                                 )

          #---------------------------------------------------
    def  decide_drawing_color ( self \
                    ,  arg_list_vector_from_Center_of_object_to_drawing_location
                                              ) :

        methode_name = "decide_drawing_color"

        #print ( "==================================" )
        #print ( "Enter into , Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
        #              + " , methode = " + methode_name )
        #print ( "arg_value_x = " , arg_value_x )
        #print ( "arg_value_y = " , arg_value_y )
        #print ( "==================================" )

        return_list  = [ "Y" , 0 , 0 , 0 ]
              # ------------------------------
        w_x = \
              self.iv_half_width_of_ImageData_ForDrawingSurfaceImage + \
                arg_list_vector_from_Center_of_object_to_drawing_location [ 0 ]
        w_y = \
              self.iv_half_height_of_ImageData_ForDrawingSurfaceImage + \
                arg_list_vector_from_Center_of_object_to_drawing_location [ 1 ]
              #------------------------
        get_color_x = w_x
        if ( w_x < 0 ) :
           get_color_x = 0
        if ( w_x >= self.iv_width_of_ImageData_ForDrawingSurfaceImage ) :
            get_color_x = self.iv_width_of_ImageData_ForDrawingSurfaceImage - 1

        get_color_y = w_y
        if ( w_y < 0 ) :
           get_color_y = 0
        if ( w_y >= self.iv_height_of_ImageData_ForDrawingSurfaceImage ) :
            get_color_y = self.iv_height_of_ImageData_ForDrawingSurfaceImage - 1
             # ------------------------------
        color_data = \
              self.iv_ins_ImageData_ForDrawingSurfaceImage  \
                    .get_data_of_one_pixel ( \
                           OneObjectTypeDrawingH.CV_CLASS_NAME
                         , methode_name
                         , get_color_x
                         , get_color_y
                                                          )
              #-----------------------------------
        if ( ( color_data [ 0 ] > 250 )  \
              and \
             ( color_data [ 1 ] > 250 )  \
              and \
             ( color_data [ 2 ] > 250 )  \
            ) :
                 # White color is set , at this location
                 #   not draw this location
            return_list [ 0 ] = "W"
            return return_list
              #-----------------------------------
        if ( ( color_data [ 0 ] <= 5 )  \
              and \
             ( color_data [ 1 ] <= 5  )  \
              and \
             ( color_data [ 2 ] <= 5  )  \
            ) :
                 # Black color is set , at this location
                 #   draw BlackColor this location
            return_list [ 0 ] = "B"
            return return_list
            #-----------------------------------
        return_list [ 1 ] = color_data [ 0 ]
        return_list [ 2 ] = color_data [ 1 ]
        return_list [ 3 ] = color_data [ 2 ]

                 # normaly color was gotten
        return_list [ 0 ] = "Y"
        return return_list

           #---------------------------------------------------
    def  decide_location_of_drawing ( self \
                          ,  arg_value_x
                          ,  arg_value_y \
                          ,  arg_rate_on_XYPlane
                                                    ) :

        methode_name = "decide_location_of_drawing"

        # print ( "==================================" )
        # print ( "Enter into , Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
         #              + " , methode = " + methode_name )
        # print ( "arg_value_x = " , arg_value_x )
        # print ( "arg_value_y = " , arg_value_y )
        # print  ( "arg_rate_on_XYPlane = " , arg_rate_on_XYPlane )
        # print ( "==================================" )

        median_to_directed_x = arg_value_x - self.iv_median_x
        median_to_directed_y = arg_value_y - self.iv_median_y

        # print ( "==================================" )
        # print ( "Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
        #               + " , methode = " + methode_name )
        # print ( "self.iv_Center_of_Object_location_x = " , self.iv_Center_of_Object_location_x)
        # print ( "self.iv_Center_of_Object_location_y = " , self.iv_Center_of_Object_location_y )
        # print  ( "median_to_directed_x = " , median_to_directed_x )
        # print  ( "median_to_directed_y = " , median_to_directed_y )
        # print  ( "arg_rate_on_XYPlane = " , arg_rate_on_XYPlane )
        # print ( "==================================" )

        arg_rate_on_XYPlane_x_direction = 1.0
        arg_rate_on_XYPlane_y_direction = 1.0

        if ( self.iv_mode_of_VariationOfRadius == "B" ) :
                             # apply reducing-size, to, both x-direction and y-direction
            arg_rate_on_XYPlane_x_direction = arg_rate_on_XYPlane
            arg_rate_on_XYPlane_y_direction = arg_rate_on_XYPlane
        if ( self.iv_mode_of_VariationOfRadius == "X" ) :
                             # apply reducing-size, to, only x-direction
            arg_rate_on_XYPlane_x_direction = arg_rate_on_XYPlane
        if ( self.iv_mode_of_VariationOfRadius == "Y" ) :
                             # apply reducing-size, to, only y-direction
            arg_rate_on_XYPlane_y_direction = arg_rate_on_XYPlane
            #--------------------------------
        vector_from_Center_of_object_to_drawing_location = [  \
             ( median_to_directed_x *  arg_rate_on_XYPlane_x_direction )  \
             ,  \
             ( median_to_directed_y *  arg_rate_on_XYPlane_y_direction ) \
                                                                                         ]
            #--------------------------------
        w_x =  self.iv_Center_of_Object_location_x   \
                        + vector_from_Center_of_object_to_drawing_location [ 0 ]
        w_y =  self.iv_Center_of_Object_location_y  \
                        + vector_from_Center_of_object_to_drawing_location [ 1 ]

        return_list = [ int ( w_x ) , int ( w_y )   \
                             , int ( vector_from_Center_of_object_to_drawing_location [ 0 ] ) \
                             , int ( vector_from_Center_of_object_to_drawing_location [ 1 ] ) \
                           ]

        #print ( "==================================" )
        #print ( "Exit from , Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
        #              + " , methode = " + methode_name )
        #print ( "return_list = " , return_list )
        #print ( "==================================" )

        return return_list

    #------------------------------------------------------------
    def   draw_this_point ( self \
                   , arg_location_on_ImageData_x
                  , arg_location_on_ImageData_y
                  , arg_color_Blue
                  , arg_color_Green
                  , arg_color_Red
                  , arg_ins_ImageDataTwoDimensionHandling_Target
                                          )  :

        methode_name = "draw_this_point"

        arg_ins_ImageDataTwoDimensionHandling_Target  \
              .put_data_of_one_pixel ( \
                         OneObjectTypeDrawingH.CV_CLASS_NAME
                       , methode_name  # arg_requester_function
                              # in the commonly used mathematical XY cordinates
                       , arg_location_on_ImageData_x
                       , arg_location_on_ImageData_y
                       , arg_color_Blue
                       , arg_color_Green
                       , arg_color_Red
                               )

        #print ( "==================================" )
        #print ( "Exit from , Class = " + OneObjectTypeDrawingH.CV_CLASS_NAME
        #              + " , methode = " + methode_name )
        #print ( "arg_location_on_ImageData_x = " , arg_location_on_ImageData_x )
        # ( "arg_location_on_ImageData_y = " , arg_location_on_ImageData_y )
        #print ( "arg_color_Blue = " , arg_color_Blue )
        #print ( "arg_color_Green = " , arg_color_Green )
        #print ( "arg_color_Red = " , arg_color_Red )
        #print ( "==================================" )



----------

----------
10 [ OneObjectTypeDrawingV モジュール ]

ファイル名 [ OneObjectTypeDrawingV.py ]

----------


import  ImageDataTwoDimensionHandlingV3
import  TextFileHandling
import  MakeLocationDataFileOfCurve

import  OneObject

#===========================================
class OneObjectTypeDrawingV  ( OneObject.OneObject )  :

    CV_CLASS_NAME = "OneObjectTypeDrawingV"

    #------------------------------------------------------------
            # definition of constructer ( set encording to UTF-8 )

    def __init__( self
                      , arg_requester_module
                      , arg_requester_function

                      , arg_id_of_Object
                      , arg_name_of_Object

                      , arg_Center_of_Object_location_x
                      , arg_Center_of_Object_location_y

                      ,  arg_from_z
                      ,  arg_to_z

                      , arg_abs_path_of_ImageData_Basic
                      , arg_abs_path_of_ImageData_CrossSectionalImage
                      , arg_abs_path_of_ImageData_ForDrawingSurfaceImage

                      , arg_Part_1_of_abs_path_of_ImageData_output
                      , arg_Part_2_of_abs_path_of_ImageData_output

                      , arg_abs_path_of_TextData_contain_CrossSectionalImage
                      , arg_abs_path_of_TextData_contain_VariationOfRadius

                      , arg_mode_of_VariationOfRadius
                ):

        methode_name = "constructer"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObjectTypeDrawingV.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "    arg_id_of_Object = " , arg_id_of_Object )
        print ( "    arg_name_of_Object = " , arg_name_of_Object )
        print ( "==================================" )

               # drawing mode = Vertical
        type_of_Object = "V"

        super().__init__( \
                       arg_requester_module
                      , arg_requester_function

                      , arg_id_of_Object
                      , arg_name_of_Object

                      , type_of_Object

                      , arg_Center_of_Object_location_x
                      , arg_Center_of_Object_location_y

                      ,  arg_from_z
                      ,  arg_to_z

                      , arg_abs_path_of_ImageData_Basic
                      , arg_abs_path_of_ImageData_CrossSectionalImage
                      , arg_abs_path_of_ImageData_ForDrawingSurfaceImage

                      , arg_Part_1_of_abs_path_of_ImageData_output
                      , arg_Part_2_of_abs_path_of_ImageData_output

                      , arg_abs_path_of_TextData_contain_CrossSectionalImage
                      , arg_abs_path_of_TextData_contain_VariationOfRadius

                      , arg_mode_of_VariationOfRadius
                 )
             #------------------------------
        self.iv_abs_path_of_TextData_contain_VariationOfRadius = \
              arg_abs_path_of_TextData_contain_VariationOfRadius

        print ( "self.iv_abs_path_of_TextData_contain_VariationOfRadius = "
              , self.iv_abs_path_of_TextData_contain_VariationOfRadius )

        self.iv_ins_TextFileHandling_VariationOfRadius  \
               = self.prepare_TextFileHandling_VariationOfRadius ( )

        self.iv_readed_counter_for_TextFileHandling_VariationOfRadius = 0
        self.iv_total_number_of_information_VariationOfRadius = 0
        self.iv_readed_data_in_TextFileHandling_VariationOfRadius = ""

             # --------------------------
        self.iv_abs_path_of_TextData_contain_CrossSectionalImage = \
              arg_abs_path_of_TextData_contain_CrossSectionalImage
        print ( "self.iv_abs_path_of_TextData_contain_CrossSectionalImage = "
              , self.iv_abs_path_of_TextData_contain_CrossSectionalImage )
        self.iv_ins_TextFileHandling_CrossSectionalImage  \
               = self.prepare_TextFileHandling_CrossSectionalImage (
                            self.iv_abs_path_of_ImageData_CrossSectionalImage
                         ,  self.iv_abs_path_of_TextData_contain_CrossSectionalImage
                         ,  0.25   # arg_detecting_angle_degree_incliment
                         ,  1.0     # arg_detecting_line_length_incliment
                                                                                      )

           #=================================
        self.iv_rate_on_XYPlane = 0.0
           #=================================

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObjectTypeDrawingV.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "    arg_requester_module = " + arg_requester_module
                   + " , arg_requester_function = " + arg_requester_function )
        print ( "==================================" )

        # ********************************************************
        # -------- over draw on above loaded image data -------
        # ********************************************************
    def   over_draw_on_loaded_image_data ( self  \
                                     ,  arg_z
                                     ,  arg_z_rate
                                     ,  arg_ins_ImageDataTwoDimensionHandling_for_redrawing
                                     ,  arg_abs_path_of_ImageDataFile_for_redrawing
                                                                   ) :

        methode_name = "over_draw_on_loaded_image_data"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObjectTypeDrawingV.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "arg_z = " , arg_z )
        print ( "arg_z_rate  = " , arg_z_rate  )
        print ( "==================================" )

        abs_path_of_write = \
              self.make_abs_path ( arg_z )

        ins_ImageDataTwoDimensionHandling_Target = \
              ImageDataTwoDimensionHandlingV3        \
                  .ImageDataTwoDimensionHandlingV3 ( \
                       OneObjectTypeDrawingV.CV_CLASS_NAME
                     , methode_name
                      )
        ins_ImageDataTwoDimensionHandling_Target \
              .load_image_data ( \
                       OneObjectTypeDrawingV.CV_CLASS_NAME
                     , methode_name
                     , abs_path_of_write
                                 )

            # ------------ draw each locations ------------

                #------ read 9 datas ( To put it in position, containing data for culculate )
        self.iv_ins_TextFileHandling_CrossSectionalImage   \
                     .do_open_process_input_mode (\
                                 OneObjectTypeDrawingV.CV_CLASS_NAME
                                , methode_name )
        read_counter = 1
        while ( read_counter <= 9 ) :
            result_of_reading_current = \
                 self.iv_ins_TextFileHandling_CrossSectionalImage   \
                        .do_read_one_line_process (
                                 OneObjectTypeDrawingV.CV_CLASS_NAME
                                , methode_name
                                                               )
            read_counter += 1

                # -----------------------------------------
        process_continue = "Y"
        while ( process_continue == "Y" ) :
            result_of_reading_next = \
                 self.iv_ins_TextFileHandling_CrossSectionalImage   \
                        .do_read_one_line_process (
                                 OneObjectTypeDrawingV.CV_CLASS_NAME
                                , methode_name
                                                               )

            # print ( "==================================" )
            # print ( "Class = " + OneObjectTypeDrawingV.CV_CLASS_NAME    \
            #           + " , methode = " + methode_name )
            # print ( "result_of_reading = " )
            # print ( result_of_reading )
            # print ( "==================================" )

            if ( result_of_reading_next [ 0 ] == "E" ) :
                           #reached to file end
                process_continue = "N"
                break

            self.draw_one_line_on_ImageData ( \
                           arg_z
                        ,  result_of_reading_current
                        ,  result_of_reading_next
                        ,  ins_ImageDataTwoDimensionHandling_Target
                        ,  self.iv_rate_on_XYPlane
                                          )

            result_of_reading_current = result_of_reading_next

             # ------------ write data ------------
        ins_ImageDataTwoDimensionHandling_Target \
              .write_loaded_image_data_to_directed_path (
                          OneObjectTypeDrawingV.CV_CLASS_NAME
                        , methode_name
                        , abs_path_of_write )
              # -----------------------------------------
        self.iv_ins_TextFileHandling_CrossSectionalImage   \
                .do_close_process (
                       OneObjectTypeDrawingV.CV_CLASS_NAME
                     , methode_name
                                           )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObjectTypeDrawingV.CV_CLASS_NAME
                      + " , methode = " + methode_name )
        print ( "==================================" )

#---------------------------------------------------------
    def   draw_one_line_on_ImageData ( self \
                                 ,  arg_value_z
                                 ,  arg_result_of_reading_current
                                 ,  arg_result_of_reading_next
                                 ,  arg_ins_ImageDataTwoDimensionHandling_Target
                                 ,  arg_rate_on_XYPlane
                                                          ) :

        methode_name = "draw_one_line_on_ImageData"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObjectTypeDrawingV.CV_CLASS_NAME
                     + " , methode = " + methode_name )
        print ( "arg_value_z = " , arg_value_z )
        print ( "arg_rate_on_XYPlane = " , arg_rate_on_XYPlane )
        print ( "==================================" )

                      #--------------------------------------
        angle_degree =  float ( arg_result_of_reading_current [ 2 ] )

        color_list = \
                self.decide_drawing_color ( \
                            angle_degree
                          , arg_value_z
                                                      )
            #------------------------------------------
        if ( ( color_list [ 0 ] == "O" )  #Over Area
              or
             ( color_list [ 0 ] == "W" )  #Color = White ( not draw )
          ) :
               # do not draw at this point
            return "N"
                #------------------------------------------
        list_cordinates_of_vertex \
              = self.decide_cordinates_of_vertex (   \
                             arg_result_of_reading_current
                           , arg_result_of_reading_next
                           , arg_rate_on_XYPlane
                                                                  )
        arg_ins_ImageDataTwoDimensionHandling_Target   \
               .insert_polygon_filled_into_ImageData (    \
                        OneObjectTypeDrawingV.CV_CLASS_NAME
                       , methode_name
                              # in the commonly used mathematical XY cordinates
                       , list_cordinates_of_vertex

                       , color_list [ 1 ]     # arg_font_color_Blue
                       , color_list [ 2 ]     # arg_font_color_Green
                       , color_list [ 3 ]     # arg_font_color_Red
                                                                       )
#----------------------------------------------------------------
    def  decide_cordinates_of_vertex (   self  \
                            ,  arg_result_of_reading_current
                            ,  arg_result_of_reading_next
                            ,  arg_rate_on_XYPlane
                                                     ) :

        methode_name = "decide_cordinates_of_vertex"

        arg_rate_on_XYPlane_x_direction = 1.0
        arg_rate_on_XYPlane_y_direction = 1.0

        if ( self.iv_mode_of_VariationOfRadius == "B" ) :
                             # apply reducing-size, to, both x-direction and y-direction
            arg_rate_on_XYPlane_x_direction = arg_rate_on_XYPlane
            arg_rate_on_XYPlane_y_direction = arg_rate_on_XYPlane
        if ( self.iv_mode_of_VariationOfRadius == "X" ) :
                             # apply reducing-size, to, only x-direction
            arg_rate_on_XYPlane_x_direction = arg_rate_on_XYPlane
        if ( self.iv_mode_of_VariationOfRadius == "Y" ) :
                             # apply reducing-size, to, only y-direction
            arg_rate_on_XYPlane_y_direction = arg_rate_on_XYPlane
            #--------------------------------
        current_from_x = float ( arg_result_of_reading_current   [ 8 ] ) \
                                           *  arg_rate_on_XYPlane_x_direction
        current_from_y = float ( arg_result_of_reading_current  [ 9 ] ) \
                                           *   arg_rate_on_XYPlane_y_direction
        current_to_x = float ( arg_result_of_reading_current   [ 12 ] ) \
                                           *  arg_rate_on_XYPlane_x_direction
        current_to_y = float ( arg_result_of_reading_current  [ 13 ] ) \
                                           *   arg_rate_on_XYPlane_y_direction
                   #------------------
        current_from_value_x = int ( self.iv_Center_of_Object_location_x  \
                                                               + current_from_x )
        current_from_value_y = int ( self.iv_Center_of_Object_location_y \
                                                              + current_from_y )
        current_to_value_x = int ( self.iv_Center_of_Object_location_x  \
                                                              + current_to_x )
        current_to_value_y = int ( self.iv_Center_of_Object_location_y \
                                                              + current_to_y )
              #----------------------------
        next_from_x = float ( arg_result_of_reading_next   [ 8 ] ) \
                                         *  arg_rate_on_XYPlane_x_direction
        next_from_y = float ( arg_result_of_reading_next  [ 9 ] )  \
                                         *   arg_rate_on_XYPlane_y_direction
        next_to_x = float ( arg_result_of_reading_next   [ 12 ] )  \
                                         *  arg_rate_on_XYPlane_x_direction
        next_to_y = float ( arg_result_of_reading_next  [ 13 ] )  \
                                         *   arg_rate_on_XYPlane_y_direction
                          #-----------------
        next_from_value_x = int ( self.iv_Center_of_Object_location_x  \
                                                      + next_from_x )
        next_from_value_y = int ( self.iv_Center_of_Object_location_y \
                                                      + next_from_y )
        next_to_value_x = int ( self.iv_Center_of_Object_location_x  \
                                                      + next_to_x )
        next_to_value_y = int ( self.iv_Center_of_Object_location_y \
                                                      + next_to_y )
               #--------------------------------------------
        list_return = [ ]
        list_return.append (  [ current_from_value_x , current_from_value_y ] )
        list_return.append (  [ current_to_value_x , current_to_value_y ] )
        list_return.append (  [ next_to_value_x , next_to_value_y ] )
        list_return.append (  [ next_from_value_x , next_from_value_y ] )

        return list_return

          #---------------------------------------------------
    def  decide_drawing_color ( self \
                              ,  arg_angle_degree
                              ,  arg_value_z
                                            ) :

        methode_name = "decide_drawing_color"

        #print ( "==================================" )
        #print ( "Enter into , Class = " + OneObjectTypeDrawingV.CV_CLASS_NAME
        #              + " , methode = " + methode_name )
        #print ( "==================================" )

        return_list  = [ "Y" , 0 , 0 , 0 ]

        if ( arg_angle_degree < 180 ) :
            w_angle_location_rate_in_0_180 = float ( arg_angle_degree ) / 180.0
        else :
            w_1 = arg_angle_degree - 180.0
            w_2 = float ( w_1 ) / 180.0
            w_angle_location_rate_in_0_180 = 1.0 - w_2

        w_x = self.iv_width_of_ImageData_ForDrawingSurfaceImage \
                                *  ( w_angle_location_rate_in_0_180 )
        w_x_int = int ( w_x )
        get_x = w_x_int
        if ( w_x_int < 0 ) :
            get_x = 0
        if ( w_x_int >= self.iv_width_of_ImageData_ForDrawingSurfaceImage ) :
            get_x = self.iv_width_of_ImageData_ForDrawingSurfaceImage - 1
                  #-------------------------------------
        z_rate =  float ( arg_value_z ) / float ( self.iv_length_z )
        w_y = self.iv_height_of_ImageData_ForDrawingSurfaceImage  \
                              * z_rate
        w_y_int = int ( w_y )
        get_y = w_y_int
        if ( w_y_int < 0 ) :
            get_y = 0
        if ( w_y_int >= self.iv_height_of_ImageData_ForDrawingSurfaceImage ) :
            get_y = self.iv_height_of_ImageData_ForDrawingSurfaceImage - 1
                                          #-------------------------------------
        color_data_1 = \
              self.iv_ins_ImageData_ForDrawingSurfaceImage  \
                    .get_data_of_one_pixel ( \
                           OneObjectTypeDrawingV.CV_CLASS_NAME
                         , methode_name
                         , get_x
                         , get_y
                               )
              #-----------------------------------
        if ( ( color_data_1 [ 0 ] > 250 )  \
              and \
             ( color_data_1 [ 1 ] > 250 )  \
              and \
             ( color_data_1 [ 2 ] > 250 )  \
            ) :
                 # White color is set , at this location
                 #   not draw this location
            return_list [ 0 ] = "W"
            return return_list
              #-----------------------------------
        return_list [ 1 ] = int ( color_data_1 [ 0 ] )
        return_list [ 2 ] = int ( color_data_1 [ 1 ] )
        return_list [ 3 ] = int ( color_data_1 [ 2 ] )

                 # normaly color was gotten
        return_list [ 0 ] = "Y"
        return return_list

#=================================
    def  prepare_TextFileHandling_CrossSectionalImage ( self   \
                  ,  arg_abs_path_of_ImageData
                  ,  arg_abs_path_of_TextData

                  ,  arg_detecting_angle_degree_incliment
                  ,  arg_detecting_line_length_incliment
                                                               ) :

        methode_name = "prepare_TextFileHandling_CrossSectionalImage"

        print ( "==================================" )
        print ( "Enter into , Class = " + OneObjectTypeDrawingV.CV_CLASS_NAME
                       + " , methode = " + methode_name )
        print ( "arg_abs_path_of_ImageData = " , arg_abs_path_of_ImageData )
        print ( "arg_abs_path_of_TextData = " , arg_abs_path_of_TextData )
        print ( "==================================" )

        ins_ImageDataTwoDimensionHandling = \
             ImageDataTwoDimensionHandlingV3   \
                .ImageDataTwoDimensionHandlingV3 ( \
                     OneObjectTypeDrawingV.CV_CLASS_NAME #  arg_requester_module
                   , methode_name   # arg_requester_function
                                        )
        ins_ImageDataTwoDimensionHandling  \
             .load_image_data ( \
                     OneObjectTypeDrawingV.CV_CLASS_NAME #  arg_requester_module
                   , methode_name   # arg_requester_function
                   , arg_abs_path_of_ImageData
                                        )
        width_of_ImageData = \
             ins_ImageDataTwoDimensionHandling \
                     .get_width_of_ImageData ( )
        height_of_ImageData = \
             ins_ImageDataTwoDimensionHandling \
                     .get_height_of_ImageData ( )
               #-------------------------------------
        ins_TextFileHandling   \
               = TextFileHandling   \
                      .TextFileHandling ( \
                             OneObjectTypeDrawingV.CV_CLASS_NAME #  arg_requester_module
                           , methode_name   # arg_requester_function
                           , arg_abs_path_of_TextData
                           , "|"     # arg_character_used_for_delimiter
                                          )
               #-------------------------------------
        list_color_value_from = [ 0 ,       0 ,    200 ]
        list_color_value_to  =  [ 50 ,     50 ,    255 ]

        MakeLocationDataFileOfCurve   \
              .detect_Curve (   \
                          ins_ImageDataTwoDimensionHandling
                       ,  arg_abs_path_of_ImageData

                       ,  ins_TextFileHandling

                                    #  arg_list_location_of_detecting_Center
                       ,  [   \
                               int ( width_of_ImageData / 2.0 )  \
                            ,  int ( height_of_ImageData / 2.0 )  \
                          ]

                       ,  arg_detecting_angle_degree_incliment
                       ,  arg_detecting_line_length_incliment
                       ,  list_color_value_from
                       ,  list_color_value_to
                           )

        print ( "==================================" )
        print ( "Exit from , Class = " + OneObjectTypeDrawingV.CV_CLASS_NAME
                       + " , methode = " + methode_name )
        print ( "==================================" )

        return  ins_TextFileHandling


----------

Python(パイソン) プログラム作ってみた インデックス へ


いいなと思ったら応援しよう!