SimpleTorusParametrization.cpp
Go to the documentation of this file.
2 
4  const Torus& torus)
5  : m_torus(&torus)
6 {
7  m_hcs.FromNormal(m_torus->AxisDirection());
8 }
9 
11 {
12  m_torus = &torus;
13  m_hcs.FromNormal(m_torus->AxisDirection());
14 }
15 
17  float epsilon, bool* uwrap, bool* vwrap) const
18 {
19  if (bbox.Max()[0] - bbox.Min()[0] >= 2 * M_PI *
20  ((m_torus->MajorRadius() < m_torus->MinorRadius() * 2) ?
21  m_torus->MajorRadius() + m_torus->MinorRadius() : m_torus->MajorRadius()) - 2 * epsilon)
22  {
23  *uwrap = true; // wrap around major component
24  }
25  else
26  {
27  *uwrap = false;
28  }
29  if (bbox.Max()[1] - bbox.Min()[1] >= 2 * M_PI * m_torus->MinorRadius() - 2 * epsilon)
30  {
31  *vwrap = true; // wrap around minor component
32  }
33  else
34  {
35  *vwrap = false;
36  }
37 }
38 
40 {
41  return sizeof(float);
42 }
43 
44 void SimpleTorusParametrization::Serialize(std::ostream* o, bool binary) const
45 {
46  // for now only output placeholder for rotation of hcs
47  float rot = 0;
48  if (binary)
49  {
50  o->write((char*)&rot, sizeof(rot));
51  }
52  else
53  {
54  *o << rot << " ";
55  }
56 }
57 
58 void SimpleTorusParametrization::Deserialize(std::istream* i, bool binary)
59 {
60  // read the placeholder
61  float rot;
62  if (binary)
63  {
64  i->read((char*)&rot, sizeof(rot));
65  }
66  else
67  {
68  *i >> rot;
69  }
70 }
SimpleTorusParametrization::WrapBitmap
void WrapBitmap(const GfxTL::AABox< GfxTL::Vector2Df > &bbox, float epsilon, bool *uwrap, bool *vwrap) const
Definition: SimpleTorusParametrization.cpp:16
GfxTL::AABox::Max
Point & Max()
Definition: AABox.hpp:74
Torus::MinorRadius
const float MinorRadius() const
Definition: Torus.h:42
Torus
Definition: Torus.h:18
SimpleTorusParametrization::Shape
const Torus & Shape() const
Definition: SimpleTorusParametrization.h:18
Torus::AxisDirection
const Vec3f & AxisDirection() const
Definition: Torus.h:38
M_PI
#define M_PI
Definition: MathTools.h:17
SimpleTorusParametrization.h
SimpleTorusParametrization::Serialize
void Serialize(std::ostream *o, bool binary) const
Definition: SimpleTorusParametrization.cpp:44
float
#define float
Definition: 16_Level.h:22
GfxTL::AABox::Min
Point & Min()
Definition: AABox.hpp:62
Torus::MajorRadius
const float MajorRadius() const
Definition: Torus.h:46
SimpleTorusParametrization::SerializedSize
static size_t SerializedSize()
Definition: SimpleTorusParametrization.cpp:39
GfxTL::AABox
Definition: AABox.h:18
SimpleTorusParametrization::Deserialize
void Deserialize(std::istream *i, bool binary)
Definition: SimpleTorusParametrization.cpp:58
SimpleTorusParametrization::SimpleTorusParametrization
SimpleTorusParametrization(const Torus &torus)
Definition: SimpleTorusParametrization.cpp:3