Don't import ogdf namespace
[TortoiseGit.git] / ext / OGDF / src / energybased / WSPD.cpp
blob2b0fbc743d21a6b4a5b986d2198690bda37c987e
1 /*
2 * $Revision: 2565 $
4 * last checkin:
5 * $Author: gutwenger $
6 * $Date: 2012-07-07 17:14:54 +0200 (Sa, 07. Jul 2012) $
7 ***************************************************************/
9 /** \file
10 * \brief Implementation of class WSPD (well-separated pair decomposition).
12 * \author Martin Gronemann
14 * \par License:
15 * This file is part of the Open Graph Drawing Framework (OGDF).
17 * \par
18 * Copyright (C)<br>
19 * See README.txt in the root directory of the OGDF installation for details.
21 * \par
22 * This program is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU General Public License
24 * Version 2 or 3 as published by the Free Software Foundation;
25 * see the file LICENSE.txt included in the packaging of this file
26 * for details.
28 * \par
29 * This program is distributed in the hope that it will be useful,
30 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32 * GNU General Public License for more details.
34 * \par
35 * You should have received a copy of the GNU General Public
36 * License along with this program; if not, write to the Free
37 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
38 * Boston, MA 02110-1301, USA.
40 * \see http://www.gnu.org/copyleft/gpl.html
41 ***************************************************************/
43 #include "WSPD.h"
44 #include "FastUtils.h"
46 namespace ogdf {
48 WSPD::WSPD(__uint32 maxNumNodes) : m_maxNumNodes(maxNumNodes)
50 m_maxNumPairs = maxNumNodes*2;
51 m_numPairs = 0;
52 allocate();
53 clear();
57 WSPD::~WSPD(void)
59 deallocate();
63 unsigned long WSPD::sizeInBytes() const
65 return m_maxNumNodes*sizeof(WSPDNodeInfo) +
66 m_maxNumPairs*sizeof(WSPDPairInfo);
70 void WSPD::allocate()
72 m_nodeInfo = (WSPDNodeInfo*)MALLOC_16(m_maxNumNodes*sizeof(WSPDNodeInfo));
73 m_pairs = (WSPDPairInfo*)MALLOC_16(m_maxNumPairs*sizeof(WSPDPairInfo));
77 void WSPD::deallocate()
79 FREE_16(m_nodeInfo);
80 FREE_16(m_pairs);
84 void WSPD::clear()
86 for (__uint32 i = 0; i < m_maxNumNodes; i++)
88 m_nodeInfo[i].numWSNodes = 0;
90 m_numPairs = 0;
93 } // end of namespace ogdf