LEAP 71

Automated AI Code generation conversation with ChatGPT

Current time (UTC): 2024-03-28 14:39:07 (UTC) Current local time: 2024-03-28 23:39:07 (+09:00)

Prompt 1

Please create three objects, whose center point is in a equidistant triangle 23mm from each other. A 88mm cube and two 45mm spheres. Create a boolean intersection between the three objects and show (only) the result.

Please include all the code, including the class definition and the static Task function. The function needs to be called ‘Task’, so don’t call it anything else. Please call the class ‘AIExample’.

Do not add placeholder code. It needs to be functional.

Here’s an example code to base your code on:

//
// SPDX-License-Identifier: CC0-1.0
//
// This example code file is released to the public under Creative Commons CC0.
// See https://creativecommons.org/publicdomain/zero/1.0/legalcode
//
// To the extent possible under law, LEAP 71 has waived all copyright and
// related or neighboring rights to this PicoGK example code file.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

using PicoGK;
using System.Numerics;

namespace PicoGKExamples
{
    ///////////////////////////////////////////////////////////////////////////
    // Below is a static class that implements a single static function
    // that can be called from Library::Go()

    class BooleanShowCase
    {
        public class Sphere : IImplicit
        {
            public Sphere(  float fRadius,
                            Vector3 vecCenter)
            {
                m_fRadius   = fRadius;
                m_vecC      = vecCenter;
                oBB = new BBox3(    vecCenter - new Vector3(fRadius),
                                    vecCenter + new Vector3(fRadius));
            }

            public float fSignedDistance(in Vector3 vecSample)
            {
                Vector3 vecPt = vecSample - m_vecC;
                // Move sample point to origin by subtracting center

                return float.Sqrt(  vecPt.X * vecPt.X +
                                    vecPt.Y * vecPt.Y +
                                    vecPt.Z * vecPt.Z) - m_fRadius;
            }

            public readonly BBox3   oBB;
            float   m_fRadius;
            Vector3 m_vecC;
        }

        public static void Task()
        {
            try
            {
                Library.oViewer().SetGroupMaterial(0, "EE", 0f, 1f);

                Library.oViewer().SetGroupMaterial(1, "FF000033", 0f, 1f);
                // Transparent Red

                Library.oViewer().SetGroupMaterial(2, "00FF0033", 0f, 1f);
                // Transparent Green

                Sphere oSphere1A = new Sphere(20f, new Vector3(-5f, 0, 0));
                Sphere oSphere1B = new Sphere(20f, new Vector3(5f, 0, 0));

                // Boolean Add showcase

                Voxels vox1 = new Voxels(oSphere1A, oSphere1A.oBB);
                vox1.BoolAdd(new Voxels(oSphere1B, oSphere1B.oBB));
                Library.oViewer().Add(vox1);

                Sphere oSphere2A = new Sphere(20f, new Vector3(-5f + 90, 0, 0));
                Sphere oSphere2B = new Sphere(20f, new Vector3(5f + 90, 0, 0));

                // Boolean Subtract showcase

                Voxels vox2A    = new Voxels(oSphere2A, oSphere2A.oBB);
                Voxels vox2B    = new Voxels(oSphere2B, oSphere2B.oBB);

                vox2A.BoolSubtract(vox2B);

                Library.oViewer().Add(vox2A);
                Library.oViewer().Add(vox2B, 1);

                // Boolean Intersect showcase

                Sphere oSphere3A = new Sphere(20f, new Vector3(-5f + 180, 0, 0));
                Sphere oSphere3B = new Sphere(20f, new Vector3(5f + 180, 0, 0));

                Voxels vox3A    = new Voxels(oSphere3A, oSphere3A.oBB);
                Voxels vox3B    = new Voxels(oSphere3B, oSphere3B.oBB);
                Voxels vox3     = new Voxels(vox3A);

                vox3.BoolIntersect(vox3B);

                Library.oViewer().Add(vox3);
                Library.oViewer().Add(vox3A, 2);
                Library.oViewer().Add(vox3B, 2);

                Voxels vox = new Voxels();

                vox.BoolAdd(vox3);
                vox.BoolAdd(vox2A);
                vox.BoolAdd(vox1);

                Mesh msh = new Mesh(vox);
                msh.SaveToStlFile(  Path.Combine(Library.strLogFolder,
                                    "Booleans.stl"));
            }

            catch (Exception e)
            {
                Library.Log($"Failed run example: \n{e.Message}"); ;
            }
        }
    }
}


Response 1

| Response Stats | Tokens | | — | — | | Prompt | 1212 | | Response | 716 | | Total | 1928 |

//
// SPDX-License-Identifier: CC0-1.0
//
// This example code file is released to the public under Creative Commons CC0.
// See https://creativecommons.org/publicdomain/zero/1.0/legalcode
//
// To the extent possible under law, LEAP 71 has waived all copyright and
// related or neighboring rights to this PicoGK example code file.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

using PicoGK;
using System;
using System.IO;
using System.Numerics;

namespace PicoGKExamples
{
    ///////////////////////////////////////////////////////////////////////////
    // Below is a static class that implements a single static function
    // that can be called from Library::Go()

    class AIExample
    {
        public class Cube : IImplicit
        {
            public Cube(float sideLength, Vector3 center)
            {
                SideLength = sideLength;
                Center = center;
                oBB = new BBox3(center - new Vector3(sideLength / 2f), center + new Vector3(sideLength / 2f));
            }

            public float fSignedDistance(in Vector3 samplePoint)
            {
                Vector3 d = Vector3.Abs(samplePoint - Center) - new Vector3(SideLength / 2f);
                return Vector3.Max(d, Vector3.Zero).Length();
            }

            public readonly BBox3 oBB;
            float SideLength;
            Vector3 Center;
        }

        public static void Task()
        {
            try
            {
                Library.oViewer().SetGroupMaterial(0, "EE", 0f, 1f);

                Library.oViewer().SetGroupMaterial(1, "FF000033", 0f, 1f);
                // Transparent Red

                Library.oViewer().SetGroupMaterial(2, "00FF0033", 0f, 1f);
                // Transparent Green

                Cube cube = new Cube(88f, new Vector3(0f, 0f, 0f));
                Sphere sphere1 = new Sphere(45f, new Vector3(-23f, (float)(-Math.Sqrt(3) * 23 / 3), 0f));
                Sphere sphere2 = new Sphere(45f, new Vector3(23f, (float)(-Math.Sqrt(3) * 23 / 3), 0f));

                Voxels vox1 = new Voxels(cube, cube.oBB);
                vox1.BoolIntersect(new Voxels(sphere1, sphere1.oBB));
                vox1.BoolIntersect(new Voxels(sphere2, sphere2.oBB));

                Library.oViewer().Add(vox1);

                Mesh msh = new Mesh(vox1);
                msh.SaveToStlFile(Path.Combine(Library.strLogFolder, "IntersectionResult.stl"));
            }
            catch (Exception e)
            {
                Library.Log($"Failed to run the example: \n{e.Message}");
            }
        }
    }
}

Prompt 2

The compiler reported the following errors in your code, could you rewrite? Code compilation failed with the following errors

Response 2

| Response Stats | Tokens | | — | — | | Prompt | 2091 | | Response | 716 | | Total | 2807 |

//
// SPDX-License-Identifier: CC0-1.0
//
// This example code file is released to the public under Creative Commons CC0.
// See https://creativecommons.org/publicdomain/zero/1.0/legalcode
//
// To the extent possible under law, LEAP 71 has waived all copyright and
// related or neighboring rights to this PicoGK example code file.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

using PicoGK;
using System;
using System.IO;
using System.Numerics;

namespace PicoGKExamples
{
    ///////////////////////////////////////////////////////////////////////////
    // Below is a static class that implements a single static function
    // that can be called from Library::Go()

    class AIExample
    {
        public class Cube : IImplicit
        {
            public Cube(float sideLength, Vector3 center)
            {
                SideLength = sideLength;
                Center = center;
                oBB = new BBox3(center - new Vector3(sideLength / 2f), center + new Vector3(sideLength / 2f));
            }

            public float fSignedDistance(in Vector3 samplePoint)
            {
                Vector3 d = Vector3.Abs(samplePoint - Center) - new Vector3(SideLength / 2f);
                return Vector3.Max(d, Vector3.Zero).Length();
            }

            public readonly BBox3 oBB;
            float SideLength;
            Vector3 Center;
        }

        public static void Task()
        {
            try
            {
                Library.oViewer().SetGroupMaterial(0, "EE", 0f, 1f);

                Library.oViewer().SetGroupMaterial(1, "FF000033", 0f, 1f);
                // Transparent Red

                Library.oViewer().SetGroupMaterial(2, "00FF0033", 0f, 1f);
                // Transparent Green

                Cube cube = new Cube(88f, new Vector3(0f, 0f, 0f));
                Sphere sphere1 = new Sphere(45f, new Vector3(-23f, (float)(-Math.Sqrt(3) * 23 / 3), 0f));
                Sphere sphere2 = new Sphere(45f, new Vector3(23f, (float)(-Math.Sqrt(3) * 23 / 3), 0f));

                Voxels vox1 = new Voxels(cube, cube.oBB);
                vox1.BoolIntersect(new Voxels(sphere1, sphere1.oBB));
                vox1.BoolIntersect(new Voxels(sphere2, sphere2.oBB));

                Library.oViewer().Add(vox1);

                Mesh msh = new Mesh(vox1);
                msh.SaveToStlFile(Path.Combine(Library.strLogFolder, "IntersectionResult.stl"));
            }
            catch (Exception e)
            {
                Library.Log($"Failed to run the example: \n{e.Message}");
            }
        }
    }
}

Prompt 3

The compiler reported the following errors in your code, could you rewrite? Code compilation failed with the following errors

Response 3

| Response Stats | Tokens | | — | — | | Prompt | 4855 | | Response | 872 | | Total | 5727 |

//
// SPDX-License-Identifier: CC0-1.0
//
// This example code file is released to the public under Creative Commons CC0.
// See https://creativecommons.org/publicdomain/zero/1.0/legalcode
//
// To the extent possible under law, LEAP 71 has waived all copyright and
// related or neighboring rights to this PicoGK example code file.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

using PicoGK;
using System;
using System.IO;
using System.Numerics;

namespace PicoGKExamples
{
    ///////////////////////////////////////////////////////////////////////////
    // Below is a static class that implements a single static function
    // that can be called from Library::Go()

    class AIExample
    {
        public class Cube : IImplicit
        {
            public Cube(float sideLength, Vector3 center)
            {
                SideLength = sideLength;
                Center = center;
                oBB = new BBox3(center - new Vector3(sideLength / 2f), center + new Vector3(sideLength / 2f));
            }

            public float fSignedDistance(in Vector3 samplePoint)
            {
                Vector3 d = Vector3.Abs(samplePoint - Center) - new Vector3(SideLength / 2f);
                return Vector3.Max(d, Vector3.Zero).Length();
            }

            public readonly BBox3 oBB;
            float SideLength;
            Vector3 Center;
        }

        public class Sphere : IImplicit
        {
            public Sphere(float fRadius, Vector3 vecCenter)
            {
                m_fRadius = fRadius;
                m_vecC = vecCenter;
                oBB = new BBox3(vecCenter - new Vector3(fRadius), vecCenter + new Vector3(fRadius));
            }

            public float fSignedDistance(in Vector3 vecSample)
            {
                Vector3 vecPt = vecSample - m_vecC;
                return (float)Math.Sqrt(vecPt.X * vecPt.X + vecPt.Y * vecPt.Y + vecPt.Z * vecPt.Z) - m_fRadius;
            }

            public readonly BBox3 oBB;
            float m_fRadius;
            Vector3 m_vecC;
        }

        public static void Task()
        {
            try
            {
                Library.oViewer().SetGroupMaterial(0, "EE", 0f, 1f);
                Library.oViewer().SetGroupMaterial(1, "FF000033", 0f, 1f); // Transparent Red
                Library.oViewer().SetGroupMaterial(2, "00FF0033", 0f, 1f); // Transparent Green

                Cube cube = new Cube(88f, new Vector3(0f, 0f, 0f));
                Sphere sphere1 = new Sphere(45f, new Vector3(-23f, (float)(-Math.Sqrt(3) * 23 / 3), 0f));
                Sphere sphere2 = new Sphere(45f, new Vector3(23f, (float)(-Math.Sqrt(3) * 23 / 3), 0f));

                Voxels vox1 = new Voxels(cube, cube.oBB);
                vox1.BoolIntersect(new Voxels(sphere1, sphere1.oBB));
                vox1.BoolIntersect(new Voxels(sphere2, sphere2.oBB));

                Library.oViewer().Add(vox1);

                Mesh msh = new Mesh(vox1);
                msh.SaveToStlFile(Path.Combine(Library.strLogFolder, "IntersectionResult.stl"));
            }
            catch (Exception e)
            {
                Library.Log($"Failed to run the example: \n{e.Message}");
            }
        }
    }
}

Success

Created compilable code in 3 Attempts