// Track.h - the interface for tracks
//
// Copyright (C) 2003 Sam Varner
//
// This file is part of Vamos Automotive Simulator.
//
// Vamos is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vamos is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vamos. If not, see <http://www.gnu.org/licenses/>.
#ifndef _TRACK_H_
#define _TRACK_H_
#include "../geometry/Contact_Info.hpp"
#include "../geometry/Rectangle.hpp"
#include "../geometry/Three_Matrix.hpp"
#include "../geometry/Three_Vector.hpp"
#include <string>
namespace Vamos_Track
{
class Track
{
public:
virtual ~Track() = default;
/// Read the track definition file.
virtual void read(std::string data_dir = "", std::string track_file = "") = 0;
/// Make the track.
virtual void build(bool close, int adjusted_segments, double length, bool join_pit_lane,
int adjusted_pit_segments) = 0;
/// Draw the track.
virtual void draw() const = 0;
/// Draw the sky.
virtual void draw_sky(const Vamos_Geometry::Three_Vector& view) const = 0;
/// Add a sector timing line.
virtual void timing_line(double dist) = 0;
/// @return The number of timing lines.
virtual size_t timing_lines() const = 0;
/// @return A rectangle that encloses the track.
virtual const Vamos_Geometry::Rectangle& bounds() const = 0;
/// Scale the track to a particular length.
virtual void set_length(double length) = 0;
/// @return The new position for a vehicle at \p pos when a reset is performed.
virtual Vamos_Geometry::Three_Vector reset_position(
const Vamos_Geometry::Three_Vector& pos,
size_t& road_index,
size_t& segment_index) const = 0;
/// @return The new orientation for a vehicle at \p pos when a reset is performed.
virtual Vamos_Geometry::Three_Matrix reset_orientation(const Vamos_Geometry::Three_Vector& pos,
size_t& road_index,
size_t& segment_index) const = 0;
virtual Vamos_Geometry::Contact_Info test_for_contact(const Vamos_Geometry::Three_Vector& pos,
double bump_parameter, size_t& road_index,
size_t& segment_index) const = 0;
// @return The vector \p world_pos transformed to the track's coordinate system.
// @param segment_index A guess of the segment the car is on. It's modified if the
// position is found on another segment.
virtual Vamos_Geometry::Three_Vector track_coordinates(const Vamos_Geometry::Three_Vector& pos,
size_t& road_index,
size_t& segment_index) const = 0;
/// @return The timing sector at the given distance.
virtual int sector(double distance) const = 0;
};
} // namespace Vamos_Track
#endif