Esempio n. 1
0
KVector3D KHalfEdgeMeshPrivate::calculateVertexNormal(const Vertex *vertex, std::vector<KVector3D> &accumulator)
{
  // If the vertex isn't a part of any face, abandon it.
  if (!vertex->to) return KVector3D();

  KVector3D cumulative, normal;
  const HalfEdge *startEdge = halfEdge(vertex->to);
  const HalfEdge *edge = startEdge;
  do
  {
    if (edge->face != 0)
    {
      normal = face(edge->face)->normal;
      if (std::none_of(accumulator.begin(), accumulator.end(), DotTest(normal)))
      {
        accumulator.push_back(normal);
        cumulative += normal;
      }
    }
    edge = cwSwivel(edge);
  }
  while (edge != startEdge);
  accumulator.clear();

  // Note: QVector3D cannot handle small values.
  float length = cumulative.length();
  if (length != 0.0f) cumulative /= length;

  return cumulative;
}
int TriangleAdjacencyGraph::fillIndexFromFan( std::vector<Index> &indexVec,
    HalfEdge &firstEdge )
{
  int count = 0;
  HalfEdge *halfEdge(&firstEdge);
  HalfEdge *gateEdge = 0;

  if (halfEdge) {
    count = 3;
    indexVec.resize(2);
    indexVec[0] = halfEdge->vertexStart();
    indexVec[1] = halfEdge->vertexEnd();
    for ( gateEdge = halfEdge->next->next->twin;
	gateEdge != halfEdge;
	gateEdge = gateEdge->next->next->twin ) {
      indexVec.push_back(gateEdge->vertexEnd());
      count++;
    }
    indexVec.push_back(halfEdge->vertexEnd());
  }
  else {
    cerr << "Invalid fac in fillIndexFromFan()" << endl;
  }

  return count;
}
Esempio n. 3
0
void Square::setCenter(double x, double y)
{
    QSizeF s=size();
    double he = halfEdge();

    setTopLeft(QPointF(x-he, y-he));
    setSize(s);
}
Esempio n. 4
0
void Square::setCeter(const QPointF& c)
{
    QSizeF s=size();
    double he = halfEdge();

    setTopLeft(QPointF(c.x()-he, c.y()-he));
    setSize(s);
}
Esempio n. 5
0
KVector3D KHalfEdgeMeshPrivate::calculateFaceNormal(const Face *face)
{
  const HalfEdge *edge = halfEdge(face->first);

  KVector3D pos1 = vertex(edge->to)->position;
  edge = halfEdge(edge->next);
  KVector3D pos2 = vertex(edge->to)->position;
  edge = halfEdge(edge->next);
  KVector3D pos3 = vertex(edge->to)->position;

  KVector3D a = pos2 - pos1;
  KVector3D b = pos3 - pos1;
  KVector3D c = KVector3D::crossProduct(a,b);

  // Note: QVector3D cannot handle small values.
  float length = c.length();
  if (length != 0.0f) c /= length;

  return c;
}
Esempio n. 6
0
const KHalfEdgeMesh::HalfEdge *KHalfEdgeMesh::unsafeHalfEdge(size_t idx) const
{
  return halfEdge(HalfEdgeIndex(static_cast<IndexType::index_type>(idx)));
}
Esempio n. 7
0
inline void KHalfEdgeMeshPrivate::initializeInnerHalfEdge(const KHalfEdgeMeshPrivate::HalfEdgeIndex &he, const KHalfEdgeMeshPrivate::FaceIndex &f, const KHalfEdgeMeshPrivate::HalfEdgeIndex &next)
{
  HalfEdge *edge = halfEdge(he);
  edge->face = f;
  edge->next = next;
}
Esempio n. 8
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::cwBounds(HalfEdgeIndex const &idx) const
{
  return halfEdge(cwBoundsIndex(idx));
}
Esempio n. 9
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::cwBounds(HalfEdge const *he) const
{
  return halfEdge(cwBoundsIndex(index(he)));
}
Esempio n. 10
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::cwSwivel(HalfEdgeIndex const &idx) const
{
  return halfEdge(cwSwivelIndex(idx));
}
Esempio n. 11
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::cwSwivel(HalfEdge const *he) const
{
  return halfEdge(cwSwivelIndex(index(he)));
}
Esempio n. 12
0
inline KVector3D KHalfEdgeMeshPrivate::edgeVector(HalfEdgeIndex const &idx) const
{
  return edgeVector(halfEdge(idx));
}
Esempio n. 13
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::twin(HalfEdgeIndex const &idx) const
{
  return halfEdge(twinIndex(idx));
}
Esempio n. 14
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::twin(HalfEdge const *edge) const
{
  return halfEdge(twinIndex(index(edge)));
}
Esempio n. 15
0
/*******************************************************************************
 * HalfEdgeMeshPrivate :: Traversal Commands
 ******************************************************************************/
inline KHalfEdgeMeshPrivate::HalfEdge *KHalfEdgeMeshPrivate::twin(HalfEdge *he)
{
  return halfEdge(twinIndex(index(he)));
}