2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19
* All rights reserved.
21
* The Original Code is: all of this file.
23
* Contributor(s): none yet.
25
* ***** END GPL LICENSE BLOCK *****
28
/** \file boolop/intern/BOP_BSPTree.cpp
29
* \ingroup boolopintern
33
#include "BOP_BSPTree.h"
38
* Constructs a new BSP tree.
40
BOP_BSPTree::BOP_BSPTree()
47
* Destroys a BSP tree.
49
BOP_BSPTree::~BOP_BSPTree()
51
if (m_root!=NULL) delete m_root;
52
if (m_bspBB!=NULL) delete m_bspBB;
56
* Adds all mesh faces to BSP tree.
57
* @param mesh mesh to add.
58
* @param facesList face list to add.
60
void BOP_BSPTree::addMesh(BOP_Mesh* mesh, BOP_Faces& facesList)
62
for (BOP_IT_Faces it = facesList.begin(); it != facesList.end(); ++it) {
69
* Adds a new face into bsp tree.
70
* @param mesh Input data for BSP tree.
71
* @param face index to mesh face.
74
void BOP_BSPTree::addFace(BOP_Mesh* mesh, BOP_Face* face)
76
addFace(mesh->getVertex(face->getVertex(0))->getPoint(),
77
mesh->getVertex(face->getVertex(1))->getPoint(),
78
mesh->getVertex(face->getVertex(2))->getPoint(),
83
* Adds new facee to the bsp-tree.
84
* @param p1 first face point.
85
* @param p2 second face point.
86
* @param p3 third face point.
87
* @param plane face plane.
89
void BOP_BSPTree::addFace(const MT_Point3& p1,
92
const MT_Plane3& plane)
95
m_root = new BOP_BSPNode(plane);
103
m_root->addFace(pts,plane);
106
// update bounding box
113
* Tests face vs bsp-tree (returns where is the face respect bsp planes).
114
* @param p1 first face triangle point.
115
* @param p2 secons face triangle point.
116
* @param p3 third face triangle point.
117
* @param plane face plane.
118
* @return BSP_IN, BSP_OUT or BSP_IN_OUT
120
BOP_TAG BOP_BSPTree::classifyFace(const MT_Point3& p1,
123
const MT_Plane3& plane) const
125
if ( m_root != NULL )
126
return m_root->classifyFace(p1, p2, p3, plane);
132
* Filters a face using the BSP bounding infomation.
133
* @param p1 first face triangle point.
134
* @param p2 secons face triangle point.
135
* @param p3 third face triangle point.
136
* @param face face to test.
137
* @return UNCLASSIFIED, BSP_IN, BSP_OUT or BSP_IN_OUT
139
BOP_TAG BOP_BSPTree::filterFace(const MT_Point3& p1,
144
if ( m_bspBB != NULL ) {
145
return m_bspBB->classifyFace(p1,p2,p3,face->getPlane());
152
* Tests face vs bsp-tree (returns where is the face respect bsp planes).
153
* @param p1 first face triangle point.
154
* @param p2 secons face triangle point.
155
* @param p3 third face triangle point.
156
* @param plane face plane.
157
* @return BSP_IN, BSP_OUT or BSP_IN_OUT
159
BOP_TAG BOP_BSPTree::simplifiedClassifyFace(const MT_Point3& p1,
162
const MT_Plane3& plane) const
164
if ( m_root != NULL )
165
return m_root->simplifiedClassifyFace(p1, p2, p3, plane);
171
* Returns the deep of this BSP tree.
174
unsigned int BOP_BSPTree::getDeep() const
176
if ( m_root != NULL )
177
return m_root->getDeep();
183
* Prints debug information.
185
void BOP_BSPTree::print()
187
if ( m_root != NULL )