# gPatch.py is a Python program to create a gyroid surface point network, from a CSV file from MoI.
# Data flow:
# wDomainG.3dm surface curve network is created in MoI.
# wDomainG.3dm > gDomain.csv, (point coordinates), via MoI SavePointNetwork script.
# gDomain.csv > gDomain_df, via gPatch.py program, using Python pandas.
# gDomain_df > gPatch.csv, via gPatch.py program.
# gPatch.csv > gPatchNetwork.3dm, via MoI ImportPointNetwork script, to form a curve network.
# gPatchNetwork.3dm > gPatchSurface > gyroid, with MoI.
# Data structures:
# gDomain.csv, a TEXT file with one [x, y, z, curveIndex] row per point, with no Header row, and no rowIndex. (All elements of any csv file are text.) (The delimiter is a comma.)
# For this particular project, the z values are all zero, and are not needed, and also the x,y points represent the complex number (x + yj).
# gDomain_df, a pandas data frame. Header is (x, y, z, cIndex), rowIndex is a column of integers. x, y, and z are float64. cIndex is int64. (cIndex denotes which curve a point is on.)
# The gPatch.py program calculates the (new) X, Y, and Z, float64 coordinate values.
# gPatch.csv, a TEXT file with one [X, Y, Z, curveIndex] row per point, no Header row, no rowIndex.
# The imported text numbers become Javascript numbers, which are the same as numpy float64.
# Overview of gPatch.py program:
# Ignoring z, each x, y, z, and cIndex element in gDomain_df is processed in turn. Coordinate (x,y) is converted into a complex number "w". Certain complex number math equations are applied to "w" to yield real number values for new surface coordinates (X,Y,Z), for each cIndex. Each [X, Y, Z, cIndex] list is saved to a row of gPatch.csv.
# MoI script ImportPointNetwork.js is used to import the new surface point coordinates, and iCrv, from the gPatch.csv text file. The ImportPointNetwork option to create Interpcurves should be used. The new curves form a network of curves. MoI Network command should then be used to create the fundamental gPatchSurface. Next various MoI commands Mirror and Rotate can be used to create the GYROID UNIT, and then the cubical gyroid unit cell. Join or Boolean...
# Superb links using Iris.csv data, a 1937 flower database:
#
https://datascienceparichay.com/article/read-csv-files-using-pandas-with-examples/
#
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html
#
https://songthamtung.medium.com/pandas-csv-cheatsheet-f88abecbe289