22 template <
typename Real>
36 int& positiveDirection,
int& negativeDirection)
override;
80 std::set<std::shared_ptr<Triangle>>
const& tAdj,
81 std::vector<std::shared_ptr<Triangle>>& tAdjSorted);
96 template <
typename Real>
104 int const numTriangles =
static_cast<int>(
indices.size() / 3);
105 for (
int t = 0;
t < numTriangles; ++
t)
108 for (
int j = 0; j < 3; ++j)
112 auto triangle = mesh.
Insert(V[0], V[1], V[2]);
117 std::multiset<SphericalArc> arcs;
124 template <
typename Real>
126 int& positiveDirection,
int& negativeDirection)
184 template <
typename Real>
inline 187 return static_cast<int>(
mNodes.size());
190 template <
typename Real>
inline 196 template <
typename Real>
198 std::set<std::shared_ptr<Triangle>>
const& tAdj,
199 std::vector<std::shared_ptr<Triangle>>& tAdjSorted)
202 int const numTriangles =
static_cast<int>(tAdj.size());
203 tAdjSorted.resize(tAdj.size());
207 auto tri = *tAdj.begin();
208 for (
int i = 0; i < numTriangles; ++i)
210 for (
int prev = 2, curr = 0; curr < 3; prev = curr++)
212 if (tri->V[curr] == vIndex)
215 tri = tri->T[prev].lock();
222 template <
typename Real>
224 std::multiset<SphericalArc>& arcs)
226 int const prev[3] = { 2, 0, 1 };
227 int const next[3] = { 1, 2, 0 };
229 for (
auto const& element : mesh.
GetEdges())
231 auto edge = element.second;
239 auto adj = edge->T[0].lock();
241 for (j = 0; j < 3; ++j)
243 if (adj->V[j] != edge->V[0] && adj->V[j] != edge->V[1])
250 LogAssert(j < 3,
"Unexpected condition.");
258 template <
typename Real>
260 std::multiset<SphericalArc>& arcs)
262 std::queue<std::pair<int,int>> queue;
267 auto vertex = element.second;
268 int const vIndex = vertex->V;
269 std::vector<std::shared_ptr<Triangle>> tAdjSorted;
271 int const numTriangles =
static_cast<int>(vertex->TAdjacent.size());
272 queue.push(std::make_pair(0, numTriangles));
273 while (!queue.empty())
275 std::pair<int, int> item = queue.front();
277 int i0 = item.first, i1 = item.second;
278 int separation = i1 - i0;
279 if (separation > 1 && separation != numTriangles - 1)
281 if (i1 < numTriangles)
289 this->mFaceNormals[arc.
nIndex[1]]);
295 int imid = (i0 + i1 + 1) / 2;
298 queue.push(std::make_pair(i0, imid));
299 queue.push(std::make_pair(imid, i1));
306 template <
typename Real>
322 template <
typename Real>
330 std::stack<int> candidates;
332 while (!candidates.empty())
334 int current = candidates.top();
361 if (sign0 * sign1 < 0)
367 else if (sign0 > 0 || sign1 > 0)
372 else if (sign0 < 0 || sign1 < 0)
388 depth =
static_cast<int>(candidates.size());
410 depth =
static_cast<int>(candidates.size());
431 template <
typename Real>
439 template <
typename Real>
virtual void GetExtremeVertices(Vector3< Real > const &direction, int &positiveDirection, int &negativeDirection) override
ExtremalQuery3BSP(Polyhedron3< Real > const &polytope)
EMap const & GetEdges() const
ReversalObject< ReverseIterator > reverse(Iterable &&range)
void CreateBSPTree(std::multiset< SphericalArc > &arcs)
void SortAdjacentTriangles(int vIndex, std::set< std::shared_ptr< Triangle >> const &tAdj, std::vector< std::shared_ptr< Triangle >> &tAdjSorted)
std::map< std::shared_ptr< Triangle >, int > mTriToNormal
#define LogAssert(condition, message)
void CreateSphericalBisectors(VETManifoldMesh &mesh, std::multiset< SphericalArc > &arcs)
bool operator<(SphericalArc const &arc) const
VETManifoldMesh::Triangle Triangle
void CreateSphericalArcs(VETManifoldMesh &mesh, std::multiset< SphericalArc > &arcs)
GLint GLint GLsizei GLsizei GLsizei depth
GLsizei GLenum const void * indices
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
std::vector< Vector3< Real > > mFaceNormals
DualQuaternion< Real > Cross(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
void InsertArc(SphericalArc const &arcs)
static int ISign(Real const &x)
Polyhedron3< Real > const & mPolytope
std::vector< SphericalArc > mNodes
ExtremalQuery3BSP & operator=(ExtremalQuery3BSP const &)=delete
virtual std::shared_ptr< Triangle > Insert(int v0, int v1, int v2) override
VMap const & GetVertices() const