blob: 7e790def0246d04408d82a5f594c4755878c7b5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
// Begin License:
// Copyright (C) 2006-2014 Tobias Sargeant (tobias.sargeant@gmail.com).
// All rights reserved.
//
// This file is part of the Carve CSG Library (http://carve-csg.com/)
//
// This file may be used under the terms of either the GNU General
// Public License version 2 or 3 (at your option) as published by the
// Free Software Foundation and appearing in the files LICENSE.GPL2
// and LICENSE.GPL3 included in the packaging of this file.
//
// This file is provided "AS IS" with NO WARRANTY OF ANY KIND,
// INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE.
// End:
#if defined(HAVE_CONFIG_H)
# include <carve_config.h>
#endif
#include <carve/csg.hpp>
#include "csg_detail.hpp"
const char *carve::csg::ENUM(carve::csg::FaceClass f) {
if (f == FACE_ON_ORIENT_OUT) return "FACE_ON_ORIENT_OUT";
if (f == FACE_OUT) return "FACE_OUT";
if (f == FACE_IN) return "FACE_IN";
if (f == FACE_ON_ORIENT_IN) return "FACE_ON_ORIENT_IN";
return "???";
}
const char *carve::csg::ENUM(carve::PointClass p) {
if (p == POINT_UNK) return "POINT_UNK";
if (p == POINT_OUT) return "POINT_OUT";
if (p == POINT_ON) return "POINT_ON";
if (p == POINT_IN) return "POINT_IN";
if (p == POINT_VERTEX) return "POINT_VERTEX";
if (p == POINT_EDGE) return "POINT_EDGE";
return "???";
}
void carve::csg::detail::LoopEdges::addFaceLoop(FaceLoop *fl) {
carve::mesh::MeshSet<3>::vertex_t *v1, *v2;
v1 = fl->vertices[fl->vertices.size() - 1];
for (unsigned j = 0; j < fl->vertices.size(); ++j) {
v2 = fl->vertices[j];
(*this)[std::make_pair(v1, v2)].push_back(fl);
v1 = v2;
}
}
void carve::csg::detail::LoopEdges::sortFaceLoopLists() {
for (super::iterator i = begin(), e = end(); i != e; ++i) {
(*i).second.sort();
}
}
void carve::csg::detail::LoopEdges::removeFaceLoop(FaceLoop *fl) {
carve::mesh::MeshSet<3>::vertex_t *v1, *v2;
v1 = fl->vertices[fl->vertices.size() - 1];
for (unsigned j = 0; j < fl->vertices.size(); ++j) {
v2 = fl->vertices[j];
iterator l(find(std::make_pair(v1, v2)));
if (l != end()) {
(*l).second.remove(fl);
if (!(*l).second.size()) {
erase(l);
}
}
v1 = v2;
}
}
carve::csg::FaceClass carve::csg::FaceLoopGroup::classificationAgainst(const carve::mesh::MeshSet<3>::mesh_t *mesh) const {
for (std::list<ClassificationInfo>::const_iterator i = classification.begin(); i != classification.end(); ++i) {
if ((*i).intersected_mesh == mesh) {
return (*i).classification;
}
}
return FACE_UNCLASSIFIED;
}
|