where segmentation fault is at #include "Custom.h"
#include <GL/glut.h>

#ifndef PI
#define PI 3.14159265358979323846

#endif

Custom::Custom(float x, float y, float z, float scale, int colorIndex, int id)
	: Shape(x, y, z, scale, colorIndex, id) {
		
	shapeType = "Hourglass";  // Set the type as "Custom" unless changed by developer

// 2.3.5.2 - Create the model for the sphere in the constructor of the Custom class. You can create any model that you like. Remember that you will require at least 25 faces to meet this requirement. Populate the vertices and faces vectors to define the custom shape. 
    const int numSlices = 20;  // Number of slices for the hourglass
    const float radius = 0.5f; // Radius of the top and bottom cones
    const float height = 1.0f; // Height of the hourglass
    const float waistWidth = 0.2f; // Width of the waist

    // Create vertices for the top circle of the upper cone
    for (int i = 0; i < numSlices; ++i) {
        float theta = 2.0f * PI * i / numSlices;
        float xPos = radius * cos(theta);
        float zPos = radius * sin(theta);
        vertices.push_back(Vector3f(xPos, height / 2, zPos)); // Top circle vertices
    }

    // Create vertices for the bottom circle of the lower cone
    for (int i = 0; i < numSlices; ++i) {
        float theta = 2.0f * PI * i / numSlices;
        float xPos = radius * cos(theta);
        float zPos = radius * sin(theta);
        vertices.push_back(Vector3f(xPos, -height / 2, zPos)); // Bottom circle vertices
    }

    // Create vertices for the waist
    for (int i = 0; i < numSlices; ++i) {
        float theta = 2.0f * PI * i / numSlices;
        float xPos = waistWidth * cos(theta);
        float zPos = waistWidth * sin(theta);
        vertices.push_back(Vector3f(xPos, 0.0f, zPos)); // Waist vertices
    }

    // Define faces for the upper cone, connecting top circle to the waist
    int waistStartIndex = 2 * (numSlices + 1); // Starting index of the waist vertices
    for (int i = 0; i < numSlices; ++i) {
        faces.push_back({i, (i + 1) % numSlices, waistStartIndex + i});                    // Connect top circle to waist
        faces.push_back({waistStartIndex + i, (i + 1) % numSlices, waistStartIndex + i});  // Triangular face
    }

    // Define faces for the lower cone, connecting bottom circle to the waist
    int bottomStartIndex = numSlices + 1; // Starting index of the bottom circle vertices
    for (int i = 0; i < numSlices; ++i) {
        faces.push_back({bottomStartIndex + i, (bottomStartIndex + 1) % numSlices}); // Connect bottom circle to waist
        faces.push_back({waistStartIndex + i});                                   // create triangular faces
    }







// 2.3.5.3 - Find the normals for each face by calculating the cross product of the two vectors on the face, and normalizing it. You will edit the calculateNormals in the Shapes class.

	calculateNormals();

}

void Custom::draw() {
	glPushMatrix();
	transform();
	glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, (colorIndex==31)? customColor:colorPresets[colorIndex].color);

// 2.3.5.4 - Implement the Draw() function using glBegin(GL_TRIANGLES) to render the custom shape based on its faces.

	//glutSolidIcosahedron(); // Disable this line when you're creating your drawing functionality
	
  glBegin(GL_TRIANGLES);
  for (size_t i = 0; i < faces.size(); i++) {
    glNormal3fv(normals[i]);
    for (int j = 0; j < 3; j++) {
      const Vector3f& vertex = vertices[faces[i][j]];
      glVertex3f(vertex.x(), vertex.y(), vertex.z());
    }
  }
    
  glEnd();

	glPopMatrix();
}