-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdjacentOrientedFace.cpp
75 lines (64 loc) · 1.8 KB
/
AdjacentOrientedFace.cpp
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
/**
* @file Body.cpp
* @author Dan R. Lipsa
* @date 20 May 2010
*
* Implementation of the AdjacentOrientedFace class
*/
#include "Body.h"
#include "AdjacentOrientedFace.h"
#include "OrientedFace.h"
#include "OrientedEdge.h"
const AdjacentBody& AdjacentOrientedFace::GetAdjacentBody () const
{
return GetOrientedFace ()->GetAdjacentBody ();
}
bool AdjacentOrientedFace::IsOrientedEdgeReversed () const
{
return GetOrientedEdge ().IsReversed ();
}
OrientedEdge AdjacentOrientedFace::GetOrientedEdge () const
{
return GetOrientedFace ()->GetOrientedEdge (GetOrientedEdgeIndex ());
}
size_t AdjacentOrientedFace::GetBodyId () const
{
return GetAdjacentBody ().GetBodyId ();
}
boost::shared_ptr<Body> AdjacentOrientedFace::GetBody () const
{
return GetAdjacentBody ().GetBody ();
}
bool AdjacentOrientedFace::IsValidNext (const AdjacentOrientedFace& next) const
{
using G3D::Vector3;
Vector3 thisNormal = GetOrientedFace()->GetNormal ();
Vector3 nextNormal = next.GetOrientedFace()->GetNormal ();
Vector3 nextEdge = next.GetOrientedEdge ().GetEdgeVector ().unit ();
Vector3 alongEdge = nextNormal.cross (thisNormal).direction ();
return alongEdge.fuzzyEq (nextEdge);
}
boost::shared_ptr<Face> AdjacentOrientedFace::GetFace () const
{
return GetOrientedFace ()->GetFace ();
}
string AdjacentOrientedFace::ToString () const
{
boost::shared_ptr<OrientedFace> of = GetOrientedFace ();
ostringstream ostr;
if (of->IsStandalone ())
ostr << "(standalone face";
else
{
const AdjacentBody& bi = GetAdjacentBody ();
ostr << "(" << bi;
}
ostr << ", of=" << of->GetStringId () << ", "
<< "oeI=" << GetOrientedEdgeIndex ()
<< ")";
return ostr.str ();
}
bool AdjacentOrientedFace::IsStandalone () const
{
return GetOrientedFace ()->IsStandalone ();
}