<commit_before>/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   p_objects.c                                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: bbeldame <<EMAIL>>          +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2017/04/15 21:47:24 by bbeldame          #+#    #+#             */
/*   Updated: 2017/04/18 17:43:15 by bbeldame         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "../../includes/rtv1.h"

void		set_sphere(t_env *e)
{
	static t_object		*sphere;
	char				*option;
	char				*option_arg;

	if (!sphere)
		sphere = (t_object *)semalloc(sizeof(t_object));
	sphere->type = SPHERE;
	e->nbline++;
	if (get_next_line(e->fd, &option) == 1 && option[0] == ' ')
	{
		option = trim_option(e, option, &option_arg);
		if (!ft_strcmp("origin", option))
			sphere->origin = set_vector(e, option_arg);
		else if (!ft_strcmp("radius", option))
			sphere->radius = ft_atoi(option_arg);
		else if (!ft_strcmp("color", option))
			sphere->color = set_color(e, option_arg);
		else
			unknown_option(option, e->nbline, "sphere");
		free(option);
		set_sphere(e);
	}
	else
	{
		set_last_obj(e, sphere);
		sphere = NULL;
		dispatch(e, option);
	}
}

void		set_plane(t_env *e)
{
	ft_putstr("Cool plane");
}

void		set_cylinder(t_env *e)
{
	ft_putstr("Cool cylinder");
}

void		set_cone(t_env *e)
{
	ft_putstr("Cool cone");
}<commit_msg>parse for cone cylinder & plane<commit_after>/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   p_objects.c                                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: tfaure <<EMAIL>>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2017/04/15 21:47:24 by bbeldame          #+#    #+#             */
/*   Updated: 2017/04/19 17:09:56 by tfaure           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "../../includes/rtv1.h"

void		set_sphere(t_env *e)
{
	static t_object		*sphere;
	char				*option;
	char				*option_arg;

	if (!sphere)
		sphere = (t_object *)semalloc(sizeof(t_object));
	sphere->type = SPHERE;
	e->nbline++;
	if (get_next_line(e->fd, &option) == 1 && option[0] == ' ')
	{
		option = trim_option(e, option, &option_arg);
		if (!ft_strcmp("origin", option))
			sphere->origin = set_vector(e, option_arg);
		else if (!ft_strcmp("radius", option))
			sphere->radius = ft_atoi(option_arg);
		else if (!ft_strcmp("color", option))
			sphere->color = set_color(e, option_arg);
		else
			unknown_option(option, e->nbline, "sphere");
		free(option);
		set_sphere(e);
	}
	else
	{
		set_last_obj(e, sphere);
		sphere = NULL;
		dispatch(e, option);
	}
}

void		set_plane(t_env *e)
{
	static t_object		*plane;
	char				*option;
	char				*option_arg;

	if (!plane)
		plane = (t_object *)semalloc(sizeof(t_object));
	plane->type = PLANE;
	e->nbline++;
	if (get_next_line(e->fd, &option) == 1 && option[0] == ' ')
	{
		option = trim_option(e, option, &option_arg);
		if (!ft_strcmp("origin", option))
			plane->origin = set_vector(e, option_arg);
		else if (!ft_strcmp("radius", option))
			plane->radius = ft_atoi(option_arg);
		else if (!ft_strcmp("color", option))
			plane->color = set_color(e, option_arg);
		else
			unknown_option(option, e->nbline, "plane");
		free(option);
		set_plane(e);
	}
	else
	{
		set_last_obj(e, plane);
		plane = NULL;
		dispatch(e, option);
	}
}

void		set_cylinder(t_env *e)
{
	static t_object		*cylinder;
	char				*option;
	char				*option_arg;

	if (!cylinder)
		cylinder = (t_object *)semalloc(sizeof(t_object));
	cylinder->type = CYLINDER;
	e->nbline++;
	if (get_next_line(e->fd, &option) == 1 && option[0] == ' ')
	{
		option = trim_option(e, option, &option_arg);
		if (!ft_strcmp("origin", option))
			cylinder->origin = set_vector(e, option_arg);
		else if (!ft_strcmp("radius", option))
			cylinder->radius = ft_atoi(option_arg);
		else if (!ft_strcmp("color", option))
			cylinder->color = set_color(e, option_arg);
		else
			unknown_option(option, e->nbline, "sphere");
		free(option);
		set_cylinder(e);
	}
	else
	{
		set_last_obj(e, cylinder);
		cylinder = NULL;
		dispatch(e, option);
	}
}

void		set_cone(t_env *e)
{
	static t_object		*cone;
	char				*option;
	char				*option_arg;

	if (!cone)
		cone = (t_object *)semalloc(sizeof(t_object));
	cone->type = CONE;
	e->nbline++;
	if (get_next_line(e->fd, &option) == 1 && option[0] == ' ')
	{
		option = trim_option(e, option, &option_arg);
		if (!ft_strcmp("origin", option))
			cone->origin = set_vector(e, option_arg);
		else if (!ft_strcmp("radius", option))
			cone->radius = ft_atoi(option_arg);
		else if (!ft_strcmp("color", option))
			cone->color = set_color(e, option_arg);
		else
			unknown_option(option, e->nbline, "cone");
		free(option);
		set_cone(e);
	}
	else
	{
		set_last_obj(e, cone);
		cone = NULL;
		dispatch(e, option);
	}
}
{'fraction_non_alphanumeric': 0.22088353413654618, 'fraction_numerical': 0.011873581281648332, 'mean_word_length': 2.1198257080610023, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6506176', 'n_tokens_mistral': 2176, 'n_tokens_neox': 1959, 'n_words': 350}