Example #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;
}
Example #3
0
void Square::setCenter(double x, double y)
{
    QSizeF s=size();
    double he = halfEdge();

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

    setTopLeft(QPointF(c.x()-he, c.y()-he));
    setSize(s);
}
Example #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;
}
Example #6
0
const KHalfEdgeMesh::HalfEdge *KHalfEdgeMesh::unsafeHalfEdge(size_t idx) const
{
  return halfEdge(HalfEdgeIndex(static_cast<IndexType::index_type>(idx)));
}
Example #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;
}
Example #8
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::cwBounds(HalfEdgeIndex const &idx) const
{
  return halfEdge(cwBoundsIndex(idx));
}
Example #9
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::cwBounds(HalfEdge const *he) const
{
  return halfEdge(cwBoundsIndex(index(he)));
}
Example #10
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::cwSwivel(HalfEdgeIndex const &idx) const
{
  return halfEdge(cwSwivelIndex(idx));
}
Example #11
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::cwSwivel(HalfEdge const *he) const
{
  return halfEdge(cwSwivelIndex(index(he)));
}
Example #12
0
inline KVector3D KHalfEdgeMeshPrivate::edgeVector(HalfEdgeIndex const &idx) const
{
  return edgeVector(halfEdge(idx));
}
Example #13
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::twin(HalfEdgeIndex const &idx) const
{
  return halfEdge(twinIndex(idx));
}
Example #14
0
inline KHalfEdgeMeshPrivate::HalfEdge const *KHalfEdgeMeshPrivate::twin(HalfEdge const *edge) const
{
  return halfEdge(twinIndex(index(edge)));
}
Example #15
0
/*******************************************************************************
 * HalfEdgeMeshPrivate :: Traversal Commands
 ******************************************************************************/
inline KHalfEdgeMeshPrivate::HalfEdge *KHalfEdgeMeshPrivate::twin(HalfEdge *he)
{
  return halfEdge(twinIndex(index(he)));
}