Path: blob/master/libraries/AC_Avoidance/AP_OAVisGraph.cpp
4182 views
/*1This program is free software: you can redistribute it and/or modify2it under the terms of the GNU General Public License as published by3the Free Software Foundation, either version 3 of the License, or4(at your option) any later version.56This program is distributed in the hope that it will be useful,7but WITHOUT ANY WARRANTY; without even the implied warranty of8MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9GNU General Public License for more details.1011You should have received a copy of the GNU General Public License12along with this program. If not, see <http://www.gnu.org/licenses/>.13*/1415#include "AC_Avoidance_config.h"1617#if AP_OAPATHPLANNER_ENABLED1819#include "AP_OAVisGraph.h"2021// constructor initialises expanding array to use 20 elements per chunk22AP_OAVisGraph::AP_OAVisGraph() :23_items(20)24{25}2627// add item to visiblity graph, returns true on success, false if graph is full28bool AP_OAVisGraph::add_item(const OAItemID &id1, const OAItemID &id2, float distance_cm)29{30// no more than 65k items31if (_num_items == UINT16_MAX) {32return false;33}3435// ensure there is space in the array36if (!_items.expand_to_hold(_num_items+1)) {37return false;38}3940// add item41_items[_num_items] = {id1, id2, distance_cm};42_num_items++;43return true;44}4546#endif // AP_OAPATHPLANNER_ENABLED474849