From ab5f8ff5869021958f4ae8b838c3d707a2e85eaa Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sun, 29 Apr 2018 16:25:32 +0200 Subject: Put adaptagrams into its own folder --- src/libcola/box.cpp | 111 ---------------------------------------------------- 1 file changed, 111 deletions(-) delete mode 100644 src/libcola/box.cpp (limited to 'src/libcola/box.cpp') diff --git a/src/libcola/box.cpp b/src/libcola/box.cpp deleted file mode 100644 index 8ad3cbaf6..000000000 --- a/src/libcola/box.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* - * vim: ts=4 sw=4 et tw=0 wm=0 - * - * libcola - A library providing force-directed network layout using the - * stress-majorization method subject to separation constraints. - * - * Copyright (C) 2014 Monash University - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * See the file LICENSE.LGPL distributed with the library. - * - * This library 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. - * - * Author(s): Michael Wybrow - * -*/ - -#include "libcola/box.h" - -namespace cola { - -Box::Box(double xMin, double xMax, double yMin, double yMax) -{ - m_min[vpsc::XDIM] = nonNegative(xMin); - m_max[vpsc::XDIM] = nonNegative(xMax); - m_min[vpsc::YDIM] = nonNegative(yMin); - m_max[vpsc::YDIM] = nonNegative(yMax); -} - -Box::Box(double all) -{ - double value = nonNegative(all); - m_min[vpsc::XDIM] = value; - m_max[vpsc::XDIM] = value; - m_min[vpsc::YDIM] = value; - m_max[vpsc::YDIM] = value; -} - -Box::Box() -{ - m_min[vpsc::XDIM] = 0; - m_max[vpsc::XDIM] = 0; - m_min[vpsc::YDIM] = 0; - m_max[vpsc::YDIM] = 0; -} - -Box::~Box() -{ -} - -bool Box::empty(void) const -{ - // values will be nonnegative so can sum to check if empty. - int total = m_min[vpsc::XDIM] + m_max[vpsc::XDIM] + - m_min[vpsc::YDIM] + m_max[vpsc::YDIM]; - return (total == 0); -} - -void Box::outputCode(FILE *fp) const -{ - if ((m_min[vpsc::XDIM] == m_max[vpsc::XDIM]) && - (m_min[vpsc::XDIM] == m_min[vpsc::YDIM]) && - (m_min[vpsc::XDIM] == m_max[vpsc::YDIM])) - { - fprintf(fp, "Box(%g)", m_min[vpsc::XDIM]); - } - else - { - fprintf(fp, "Box(%g, %g, %g, %g)", m_min[vpsc::XDIM], - m_max[vpsc::XDIM], m_min[vpsc::YDIM], m_max[vpsc::YDIM]); - } -} - -vpsc::Rectangle Box::rectangleByApplyingBox( - const vpsc::Rectangle rectangle) const -{ - if (!rectangle.isValid()) - { - return rectangle; - } - - return vpsc::Rectangle( - rectangle.getMinX() - m_min[vpsc::XDIM], - rectangle.getMaxX() + m_max[vpsc::XDIM], - rectangle.getMinY() - m_min[vpsc::YDIM], - rectangle.getMaxY() + m_max[vpsc::YDIM]); -} - -double Box::nonNegative(double value) -{ - return (value >= 0) ? value: 0; -} - -double Box::min(size_t dim) const -{ - return (dim < 2) ? m_min[dim] : 0; -} - -double Box::max(size_t dim) const -{ - return (dim < 2) ? m_max[dim] : 0; -} - - -} - -- cgit v1.2.3