forked from zippy84/vtkbool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvtkPolyDataContactFilter.h
More file actions
151 lines (107 loc) · 4.13 KB
/
vtkPolyDataContactFilter.h
File metadata and controls
151 lines (107 loc) · 4.13 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
Copyright 2012-2022 Ronald Römer
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef __vtkPolyDataContactFilter_h
#define __vtkPolyDataContactFilter_h
#include <map>
#include <tuple>
#include <set>
#include <vtkPolyDataAlgorithm.h>
#include <vtkIdTypeArray.h>
#include "Utilities.h"
class vtkOBBNode;
class vtkMatrix4x4;
enum class Src {
A,
B
};
enum class End {
NONE,
BEGIN,
END
};
class InterPt {
public:
InterPt () = delete;
InterPt (double x, double y, double z, double t, vtkIdType a, vtkIdType b, End end, Src src) : t(t), edge(a, b), end(end), src(src), srcA(NOTSET), srcB(NOTSET), inaccurate(false) {
pt[0] = x;
pt[1] = y;
pt[2] = z;
}
double pt[3], t;
Pair edge;
End end;
Src src;
vtkIdType srcA, srcB;
bool inaccurate;
friend std::ostream& operator<< (std::ostream &out, const InterPt &s) {
out << "pt [" << s.pt[0] << ", " << s.pt[1] << ", " << s.pt[2] << "]"
<< ", t " << s.t
<< ", edge " << s.edge
<< ", end " << s.end
<< ", src " << s.src;
return out;
}
void Merge (const InterPt &other) {
assert(src != other.src);
if (src == Src::A) {
srcA = end == End::END ? edge.g : edge.f;
} else {
srcB = end == End::END ? edge.g : edge.f;
}
if (std::abs(other.t-t) < 1e-5) {
if (other.src == Src::A) {
srcA = other.end == End::END ? other.edge.g : other.edge.f;
} else {
srcB = other.end == End::END ? other.edge.g : other.edge.f;
}
}
if (other.inaccurate) {
inaccurate = true;
}
}
};
typedef std::vector<InterPt> InterPtsType;
typedef std::vector<std::tuple<InterPt, InterPt, vtkIdType, vtkIdType>> OverlapsType;
typedef std::set<Pair> InvalidEdgesType;
class VTK_EXPORT vtkPolyDataContactFilter : public vtkPolyDataAlgorithm {
void PreparePolyData (vtkPolyData *pd);
static void InterEdgeLine (InterPtsType &interPts, vtkPolyData *pd, vtkIdType idA, vtkIdType idB, const double *r, const double *pt, Src src);
static void InterPolyLine (InterPtsType &interPts, vtkPolyData *pd, vtkIdType num, const vtkIdType *poly, const double *r, const double *pt, Src src, const double *n);
void InterPolys (vtkIdType idA, vtkIdType idB);
void OverlapLines (OverlapsType &ols, InterPtsType &intersA, InterPtsType &intersB, vtkIdType idA, vtkIdType idB);
void AddContactLines (InterPtsType &intersA, InterPtsType &intersB, vtkIdType idA, vtkIdType idB);
static void CheckInters (InterPtsType &interPts, vtkPolyData *pd, vtkIdType idA, vtkIdType idB);
vtkIdTypeArray *contA, *contB;
vtkPolyData *contLines;
vtkPoints *contPts;
vtkPolyData *pdA, *pdB;
vtkIdTypeArray *sourcesA, *sourcesB;
vtkIdTypeArray *neigsA, *neigsB;
bool invalidA, invalidB;
InvalidEdgesType edgesA, edgesB;
void GetInvalidEdges (vtkPolyData *pd, InvalidEdgesType &edges);
vtkIdTypeArray *accuracy;
public:
vtkTypeMacro(vtkPolyDataContactFilter, vtkPolyDataAlgorithm);
static vtkPolyDataContactFilter* New();
static int InterOBBNodes (vtkOBBNode *nodeA, vtkOBBNode *nodeB, vtkMatrix4x4 *mat, void *caller);
protected:
vtkPolyDataContactFilter ();
~vtkPolyDataContactFilter ();
int ProcessRequest (vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector) override;
void PrintSelf (ostream&, vtkIndent) override {};
private:
vtkPolyDataContactFilter (const vtkPolyDataContactFilter&) = delete;
void operator= (const vtkPolyDataContactFilter&) = delete;
};
#endif