def export_obj_raw(obj_path, points_out="points.txt", faces_out="faces.txt"):
    vertices = []
    faces = []

    with open(obj_path, "r") as f:
        for line in f:
            # Vertex line: v x y z
            if line.startswith("v "):
                parts = line.strip().split()
                # parts = ["v", x, y, z]
                vertices.append(parts[1:4])

            # Face line: f i/j/k i/j/k ...
            elif line.startswith("f "):
                parts = line.strip().split()[1:]
                # Extract only vertex indices before any "/"
                face_indices = [p.split("/")[0] for p in parts]
                faces.append(face_indices)

    # Write vertices
    with open(points_out, "w") as f:
        for v in vertices:
            f.write(" ".join(v) + "\n")

    # Write faces
    with open(faces_out, "w") as f:
        for face in faces:
            f.write(" ".join(face) + "\n")

    print(f"Export completed:\n  {points_out}\n  {faces_out}")


# Example usage:
export_obj_raw("cube.obj")

