本文整理汇总了C++中HalfEdge类的典型用法代码示例。如果您正苦于以下问题:C++ HalfEdge类的具体用法?C++ HalfEdge怎么用?C++ HalfEdge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HalfEdge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void Face <T> ::print ( std::ostream * output ) const
{
//Print Face
if ( edge != NULL )
{
//Get next edge in cell
HalfEdge <T> *e = edge;
//Proces all edges of the Face
do
{
//Print edge
e->print ( output );
//Add new line
*output << '\n';
//Increment edge
e = e->getNextEdge();
}
while ( e != edge );
}
std::cout << std::endl;
}
示例2: include_edge
bool Face::include_edge(Edge *e)
{
HalfEdge * he = m_halfedge;
if(he->edge () == e || he->he_next ()->edge () == e || he->he_prev ()->edge () == e)
return true;
return false;
}
示例3: pointIntersection
// Return whether a point is inside, on, or outside the cell:
// -1: point is outside the perimeter of the cell
// 0: point is on the perimeter of the cell
// 1: point is inside the perimeter of the cell
//
int Cell::pointIntersection(double x, double y) {
// Check if point in polygon. Since all polygons of a Voronoi
// diagram are convex, then:
// http://paulbourke.net/geometry/polygonmesh/
// Solution 3 (2D):
// "If the polygon is convex then one can consider the polygon
// "as a 'path' from the first vertex. A point is on the interior
// "of this polygons if it is always on the same side of all the
// "line segments making up the path. ...
// "(y - y0) (x1 - x0) - (x - x0) (y1 - y0)
// "if it is less than 0 then P is to the right of the line segment,
// "if greater than 0 it is to the left, if equal to 0 then it lies
// "on the line segment"
HalfEdge* he;
size_t edgeCount = halfEdges.size();
Point2 p0;
Point2 p1;
double r;
while (edgeCount--) {
he = halfEdges[edgeCount];
p0 = *he->startPoint();
p1 = *he->endPoint();
r = (y - p0.y)*(p1.x - p0.x) - (x - p0.x)*(p1.y - p0.y);
if (r == 0) {
return 0;
}
if (r > 0) {
return -1;
}
}
return 1;
}
示例4: setTwinEdge
void Face <T>::removeAdjacency()
{
//Set twin edges of Faces adjacent to actual Face to NULL
if ( edge != NULL )
{
//Get actual edge in cell
HalfEdge <T> *e = edge;
//Proces all edges of the Face
do
{
//Get twin edge
HalfEdge <T> *e_twin = e->getTwinEdge();
//Adjacent cell exists
if ( e_twin != NULL )
{
//Set pointer to NULL
e_twin -> setTwinEdge ( NULL );
}
//Increment edge
e = e->getNextEdge();
}
while ( e != edge );
}
}
示例5: fillIndexFromFan
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;
}
示例6: calcEgdeLines
int TriangleAdjacencyGraph::calcEgdeLines ( vector<Index> & indexVec, bool codeBorder )
{
unsigned int i, nN, j, nE, halfEdgeCount = 0;
Index startVertexIndex, endVertexIndex;
HalfEdge *halfEdge;
bool isBorder;
indexVec.clear();
nN = _temporaryVector.size();
for (i = 0; i < nN; i++) {
nE = _temporaryVector[i].size();
for ( j = 0; j < nE; j++) {
halfEdge = _temporaryVector[i][j].second;
startVertexIndex = halfEdge->vertexStart();
endVertexIndex = halfEdge->vertexEnd();
if ((isBorder = (halfEdge->twin == 0)) || (startVertexIndex <
endVertexIndex)) {
indexVec.push_back(startVertexIndex);
indexVec.push_back(endVertexIndex);
if (codeBorder)
indexVec.push_back(isBorder ? 0 : 1);
halfEdgeCount++;
}
}
}
return halfEdgeCount;
}
示例7: print
void DigraphL::print(void) {
// Wagi krawedzi od 'v' do kazdego z V wierzcholkow (moga byc nieskonczone)
int matrix[V];
HalfEdge* edge;
for (int v = 0; v < V; v++) {
edges[v]->rewind();
// Inicjujemy tablice nieskonczonymi wagami
for (int w = 0; w < V; w++)
matrix[w] = INF;
// Uaktualniamy wagi odpowadajace istniejacym krawedziom
while (edges[v]->hasMoreElements()) {
edge = edges[v]->getNext();
matrix[edge->getEndingVertexIndex()] = edge->getWeight();
}
// Wypisujemy wagi na ekran
for (int w = 0; w < V; w++) {
cout << "\t";
if (matrix[w] != INF)
cout << matrix[w];
else
cout << "-";
}
cout << endl;
}
cout << endl;
}
示例8: getFacePerimeter
T FacePerimeter:: getFacePerimeter ( const HalfEdge <T> *e_start )
{
//Get perimeter of the Face given by start half edge
T perimeter = 0;
HalfEdge <T> *e = const_cast <HalfEdge <T> *> ( e_start );
//There is a valid edge
if ( e_start != NULL )
{
//Get point
Node3DCartesian <T> *pi = e->getPoint();
//Proces all edges of the Face
do
{
//Get point
Node3DCartesian <T> *pii = e->getNextEdge()->getPoint();
//Compute area
perimeter += EuclDistance::getEuclDistance2D ( pi->getX(), pi->getY(), pii->getX(), pii->getY() );
//Assign point
pi = pii;
//Assign edge
e = e->getNextEdge();
}
while ( e != e_start );
}
//Get area
return perimeter;
}
示例9: linePLaneIntersection
QVector3D Slice::linePLaneIntersection(HalfEdge edge, QVector3D planeOrigin, QVector3D planeNormal){
QVector3D u=edge.getStart()->toVector3D()-edge.getStop()->toVector3D();
QVector3D w=edge.getStop()->toVector3D()-planeOrigin;
QVector3D normal=planeNormal;
float d=QVector3D::dotProduct(normal,u);
float n=-QVector3D::dotProduct(normal,w);
//line is parallel to plane
if(fabs(d)<0.00000001){
if(n==0){
qDebug() << "line is on plane";
return QVector3D(edge.getStart()->toVector3D());
}
else{
qDebug() << "no intersection";
return QVector3D();
}
}
//line croses plane
float sI = n/d;
if(sI<0 || sI>1){
qDebug() << "no intersection";
return QVector3D();
}
return edge.getStop()->toVector3D() + u*sI;
}
示例10: while
//fill list of edges crossing plane on some z height
void Slice::fillEdgeLayer(){
QList<Face*> currentLayer;
Face* currentFace;
HalfEdge* currentEdge;
for(int i=0; i<this->triLayer.size(); i++){
currentLayer=*this->triLayer.at(i);
//take first face from list
if(currentLayer.size()>0){
while(currentLayer.size()>0){
currentFace=currentLayer.takeFirst();
currentEdge=currentFace->getEdgesCrossingPlane(this->layerHeight*i).at(0);
//create list for firts edge loop
this->edgeLayer.at(i)->append(new QList<HalfEdge*>);
this->pointLayer.at(i)->append(new QList<QVector3D>);
this->edgeLayer.at(i)->last()->append(currentEdge);
//while all faces are processed
do{
currentLayer.removeAt(currentLayer.indexOf(currentFace));
//take his twin
currentEdge=currentEdge->getTwin();
currentFace=currentEdge->getFaces().at(0);
//qDebug() << currentFace->getNeighbors().size();
if(currentFace->getEdgesCrossingPlane(this->layerHeight*i,currentEdge).size()!=1){
//qDebug() << "dupa" <<currentFace->getEdgesCrossingPlane(this->layerHeight*i,currentEdge).size();
}
currentEdge=currentFace->getEdgesCrossingPlane(this->layerHeight*i,currentEdge).first();
this->edgeLayer.at(i)->last()->append(currentEdge);
}while(currentLayer.contains(currentFace));
}
}
}
}
示例11: assert
void Curve::ReplaceSections(Vertex * startV, Vertex * endV, std::vector<HalfEdge *> & replaceList)
{
int i,j;
int startInd, endInd;
startInd = endInd = -1;
for (i=0;i<helist.size(); ++i)
{
HalfEdge * he = helist[i];
if (he->source() == startV)
{
startInd = i;
break;
}
}
assert(startInd != -1);
for (j=i; j<helist.size();++j)
{
HalfEdge * he = helist[j];
if (he->target() == endV)
{
endInd = j;
break;
}
}
assert(endInd != -1);
ReplaceSections(startInd, endInd, replaceList);
}
示例12: getNode
/** Return node no ix from triangle.
* \param ix is either 0, 1 or 2.
*/
Node* getNode(size_t ix) {
HalfEdge *he = m_he_;
for(size_t i=0; i<ix; i++) {
he = he->getNext();
}
return he->getSourceNode();
}
示例13:
Curve::Curve(std::list<Edge *> edges)
{
std::list<Edge *>::iterator eiter = edges.begin();
Edge * e = *eiter;
HalfEdge * he = e->halfedge(0);
Vertex * v = he->source();
BuildList(edges, v);
}
示例14: include_vertex
bool Face::include_vertex(Vertex *v)
{
HalfEdge * he = m_halfedge;
if(he->target () == v || he->source () == v || he->he_next ()->target () == v)
return true;
return false;
}
示例15: if
void TriMesh::buildConnectivity() {
// skip
// Use the algorithm from the lecture to categorize the edges into inner, boundary or non-manifold
// Set the twin edge appropriately to the category of the current edge
// For each node take its leading halfedge and rewind (using getVtxRingPrev) until:
// - We get the one that we started with (no need to do anything)
// - We get NULL - then the previous choice should be used as the nodes leading halfedge
// unskip
std::vector<SortElement> helper = std::vector<SortElement>();
for(int i = 0; i < m_halfedges.size(); i++){
helper.push_back(m_halfedges[i]);
}
std::sort(helper.begin(), helper.end());
int i,j;
//Loop through all edges
for(j=0; j<helper.size(); j++){
//Find i so that i and i+1 are different edges
for(i=j; i<helper.size()-1; i++){
if(helper[i].m_a != helper[i+1].m_a || helper[i].m_b != helper[i+1].m_b){
break;
}
}
if(i==j){
helper[j].m_he->m_twin_ = NULL;
// helper[j] points to a boundary edge
}
else if (i==j+1){
helper[i].m_he->m_twin_ = helper[j].m_he;
helper[j].m_he->m_twin_ = helper[i].m_he;
// connect the triangles of helper[i] and helper[j]
}
else{
std::cout << "Non-manifold mesh!" << std::endl;
}
j = i;
}
for (int i = 0; i < m_nodes.size(); i++){
HalfEdge* beginLead = m_nodes[i].getLeadingHalfEdge();
HalfEdge* tempLead = m_nodes[i].getLeadingHalfEdge();
while(true){
HalfEdge* rewindHe = tempLead->getVtxRingPrev();
if (rewindHe == NULL){
m_nodes[i].m_he_ = tempLead;
break;
}
else if (rewindHe == beginLead)
break;
tempLead = rewindHe;
}
}
}