public static Brep MoveBrep(Brep brep, Mesh base_mesh, Point3d current_point, out List <Sphere> pin_ball_list)
        {
            Brep     new_brep           = brep.DuplicateBrep();
            Point3d  original_position  = My_object_functions.GetPosition(new_brep);
            Vector3d original_direction = My_object_functions.GetZ(new_brep);
            Vector3d normal_on_mesh     = base_mesh.NormalAt(base_mesh.ClosestMeshPoint(current_point, 0.1));

            My_object_functions.RotateVerticallyTo(new_brep, normal_on_mesh);
            My_object_functions.TranslateTo(new_brep, current_point);

            int             pin_quantity          = My_object_functions.GetPinQuantity(new_brep);
            List <double>   pin_to_mesh_distance  = new List <double>();
            List <Vector3d> pin_to_mesh_direction = new List <Vector3d>();
            List <Sphere>   pin_ball = new List <Sphere>();

            for (int i = 0; i < pin_quantity; i++)
            {
                Point3d pin_position = My_object_functions.GetPinPosition(new_brep, i);
                //Sphere pin_ball_i = new Sphere(pin_position, 2);
                //pin_ball.Add(pin_ball_i);
                Line      line1 = new Line(pin_position, -20 * normal_on_mesh);
                Line      line2 = new Line(pin_position, 10 * normal_on_mesh);
                int[]     faceids;
                Point3d[] i_p_1 = Intersection.MeshLine(base_mesh, line1, out faceids);
                Point3d[] i_p_2 = Intersection.MeshLine(base_mesh, line2, out faceids);
                foreach (Point3d p_1 in i_p_1)
                {
                    pin_to_mesh_distance.Add(pin_position.DistanceTo(p_1));
                    pin_to_mesh_direction.Add(p_1 - pin_position);
                }
                foreach (Point3d p_2 in i_p_2)
                {
                    pin_to_mesh_distance.Add(pin_position.DistanceTo(p_2));
                    pin_to_mesh_direction.Add(p_2 - pin_position);
                }
            }
            int    min   = 0;
            double min_d = double.MaxValue;

            for (int i = 0; i < pin_to_mesh_distance.Count; i++)
            {
                if (min_d > pin_to_mesh_distance[i])
                {
                    min_d = pin_to_mesh_distance[i];
                    min   = i;
                }
            }
            original_position = My_object_functions.GetPosition(new_brep);
            My_object_functions.TranslateTo(new_brep, original_position + pin_to_mesh_direction[min]);

            /*
             * for (int i = 0; i < pin_quantity; i ++)
             * {
             *  Point3d pin_position = My_object_functions.GetPinPosition(new_brep, i);
             *  Sphere pin_ball_i = new Sphere(pin_position, 2);
             *  pin_ball.Add(pin_ball_i);
             * }
             */
            pin_ball_list = pin_ball;
            return(new_brep);
        }