本文整理汇总了C++中WOEdge::GetbVertex方法的典型用法代码示例。如果您正苦于以下问题:C++ WOEdge::GetbVertex方法的具体用法?C++ WOEdge::GetbVertex怎么用?C++ WOEdge::GetbVertex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WOEdge
的用法示例。
在下文中一共展示了WOEdge::GetbVertex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: gts_vertex_gaussian_curvature
/*! gts_vertex_gaussian_curvature:
* @v: a #WVertex.
* @s: a #GtsSurface.
* @Kg: the Discrete Gaussian Curvature approximation at @v.
*
* Computes the Discrete Gaussian Curvature approximation at @v.
*
* This approximation is from the paper:
* Discrete Differential-Geometry Operators for Triangulated 2-Manifolds
* Mark Meyer, Mathieu Desbrun, Peter Schroder, Alan H. Barr
* VisMath '02, Berlin (Germany)
* http://www-grail.usc.edu/pubs.html
*
* Returns: %true if the operator could be evaluated, %false if the evaluation failed for some reason (@v is
* boundary or is the endpoint of a non-manifold edge.)
*/
bool gts_vertex_gaussian_curvature(WVertex *v, real *Kg)
{
real area = 0.0;
real angle_sum = 0.0;
if (!v)
return false;
if (!Kg)
return false;
/* this operator is not defined for boundary edges */
if (v->isBoundary()) {
*Kg = 0.0;
return false;
}
WVertex::incoming_edge_iterator itE;
for (itE = v->incoming_edges_begin(); itE != v->incoming_edges_end(); itE++) {
area += (*itE)->GetaFace()->getArea();
}
for (itE = v->incoming_edges_begin(); itE != v->incoming_edges_end(); itE++) {
WOEdge *e = (*itE)->getPrevOnFace();
WVertex *v1 = e->GetaVertex();
WVertex *v2 = e->GetbVertex();
angle_sum += angle_from_cotan(v, v1, v2);
}
*Kg = (2.0 * M_PI - angle_sum) / area;
return true;
}
示例2: AdvanceToEdge
bool AdvanceToEdge(WFace * face, Vec3r currentPoint, int edgeIndex, Vec3r & nextPoint)
{
Vec3r viewpoint = SilhouetteGeomEngine::GetViewpoint();
WOEdge * edge = face->GetOEdge(edgeIndex);
Vec3r A = edge->GetaVertex()->GetVertex();
Vec3r B = edge->GetbVertex()->GetVertex();
Vec3r edgedir = B-A;
Vec3r planeNormal = (viewpoint - currentPoint) ^ face->GetNormal();
real t;
GeomUtils::intersection_test result = GeomUtils::intersectLinePlanePN(A, edgedir, planeNormal, currentPoint, t);
// printf("\te = %d, result = %d, want: %d, t = %f\n", edgeIndex, result, GeomUtils::DO_INTERSECT, t);
if (result != GeomUtils::DO_INTERSECT || t < 0 || t > 1)
return false;
nextPoint = A + t*edgedir;
return true;
/*
real dp = (nextPoint - currentPoint) * (viewpoint - currentPoint) ;
printf("\tdp = %f\n", dp);
return dp > 0;
*/
}
示例3: gts_vertex_mean_curvature_normal
/*! gts_vertex_mean_curvature_normal:
* @v: a #WVertex.
* @s: a #GtsSurface.
* @Kh: the Mean Curvature Normal at @v.
*
* Computes the Discrete Mean Curvature Normal approximation at @v.
* The mean curvature at @v is half the magnitude of the vector @Kh.
*
* Note: the normal computed is not unit length, and may point either into or out of the surface, depending on
* the curvature at @v. It is the responsibility of the caller of the function to use the mean curvature normal
* appropriately.
*
* This approximation is from the paper:
* Discrete Differential-Geometry Operators for Triangulated 2-Manifolds
* Mark Meyer, Mathieu Desbrun, Peter Schroder, Alan H. Barr
* VisMath '02, Berlin (Germany)
* http://www-grail.usc.edu/pubs.html
*
* Returns: %true if the operator could be evaluated, %false if the evaluation failed for some reason (@v is
* boundary or is the endpoint of a non-manifold edge.)
*/
bool gts_vertex_mean_curvature_normal(WVertex *v, Vec3r &Kh)
{
real area = 0.0;
if (!v)
return false;
/* this operator is not defined for boundary edges */
if (v->isBoundary())
return false;
WVertex::incoming_edge_iterator itE;
for (itE = v->incoming_edges_begin(); itE != v->incoming_edges_end(); itE++)
area += (*itE)->GetaFace()->getArea();
Kh = Vec3r(0.0, 0.0, 0.0);
for (itE = v->incoming_edges_begin(); itE != v->incoming_edges_end(); itE++) {
WOEdge *e = (*itE)->getPrevOnFace();
#if 0
if ((e->GetaVertex() == v) || (e->GetbVertex() == v))
cerr<< "BUG ";
#endif
WVertex *v1 = e->GetaVertex();
WVertex *v2 = e->GetbVertex();
real temp;
temp = cotan(v1, v, v2);
Kh = Vec3r(Kh + temp * (v2->GetVertex() - v->GetVertex()));
temp = cotan(v2, v, v1);
Kh = Vec3r(Kh + temp * (v1->GetVertex() - v->GetVertex()));
}
if (area > 0.0) {
Kh[0] /= 2 * area;
Kh[1] /= 2 * area;
Kh[2] /= 2 * area;
}
else {
return false;
}
return true;
}
示例4: angle_obtuse
static bool angle_obtuse(WVertex *v, WFace *f)
{
WOEdge *e;
f->getOppositeEdge(v, e);
Vec3r vec1(e->GetaVertex()->GetVertex() - v->GetVertex());
Vec3r vec2(e->GetbVertex()->GetVertex() - v->GetVertex());
return ((vec1 * vec2) < 0);
}
示例5: incoming_edges_end
WVertex::incoming_edge_iterator WVertex::incoming_edges_end()
{
WOEdge *begin;
WOEdge *aOEdge = _EdgeList.front()->GetaOEdge();
if (aOEdge->GetbVertex() == this)
begin = aOEdge;
else
begin = _EdgeList.front()->GetbOEdge();
return incoming_edge_iterator(this, begin, 0);
}
示例6:
WOEdge::WOEdge(WOEdge& iBrother)
{
_paVertex = iBrother.GetaVertex();
_pbVertex = iBrother.GetbVertex();
_paFace = iBrother.GetaFace();
_pbFace = iBrother.GetbFace();
_pOwner = iBrother.GetOwner();
userdata = NULL;
iBrother.userdata = new oedgedata;
((oedgedata *)(iBrother.userdata))->_copy = this;
_vec = iBrother._vec;
_angle = iBrother._angle;
}
示例7: instanciateEdge
WOEdge *WFace::MakeEdge(WVertex *v1, WVertex *v2)
{
// First check whether the same oriented edge already exists or not:
vector<WEdge *>& v1Edges = v1->GetEdges();
for (vector<WEdge*>::iterator it1 = v1Edges.begin(), end = v1Edges.end(); it1 != end; it1++) {
WEdge *we = (*it1);
WOEdge *woea = we->GetaOEdge();
//if ((*it1)->GetbVertex() == v2) {
if ((woea->GetaVertex() == v1) && (woea->GetbVertex() == v2)) {
// The oriented edge already exists
cerr << "Warning: edge " << v1->GetId() << " - " << v2->GetId() << " appears twice, correcting" << endl;
// Adds the edge to the face
//AddEdge((*it1)->GetaOEdge());
AddEdge(woea);
(*it1)->setNumberOfOEdges((*it1)->GetNumberOfOEdges() + 1);
//sets these vertices as border:
v1->setBorder(true);
v2->setBorder(true);
//return (*it1)->GetaOEdge();
return woea;
}
WOEdge *woeb = we->GetbOEdge();
//if ((*it1)->GetbVertex() == v2)
if (woeb && (woeb->GetaVertex() == v1) && (woeb->GetbVertex() == v2)) {
// The oriented edge already exists
cerr << "Warning: edge " << v1->GetId() << " - " << v2->GetId() << " appears twice, correcting" << endl;
// Adds the edge to the face
//AddEdge((*it1)->GetaOEdge());
AddEdge(woeb);
(*it1)->setNumberOfOEdges((*it1)->GetNumberOfOEdges() + 1);
//sets these vertices as border:
v1->setBorder(true);
v2->setBorder(true);
//return (*it1)->GetaOEdge();
return woeb;
}
}
// the oriented edge we're about to build
WOEdge *pOEdge = new WOEdge;
// The edge containing the oriented edge.
WEdge *edge;
// checks whether this edge already exists or not
// If it exists, it points outward v2
bool exist = false;
WOEdge *pInvertEdge = NULL; // The inverted edge if it exists
vector<WEdge *>& v2Edges = v2->GetEdges();
vector<WEdge *>::iterator it;
for (it = v2Edges.begin(); it != v2Edges.end(); it++) {
if ((*it)->GetbVertex() == v1) {
// The invert edge already exists
exist = true;
pInvertEdge = (*it)->GetaOEdge();
break;
}
}
//DEBUG:
if (true == exist) { // The invert edge already exists
// Retrieves the corresponding edge
edge = pInvertEdge->GetOwner();
// Sets the a Face (retrieved from pInvertEdge
pOEdge->setaFace(pInvertEdge->GetbFace());
// Updates the invert edge:
pInvertEdge->setaFace(this);
}
else { // The invert edge does not exist yet
// we must create a new edge
//edge = new WEdge;
edge = instanciateEdge();
// updates the a,b vertex edges list:
v1->AddEdge(edge);
v2->AddEdge(edge);
}
pOEdge->setOwner(edge);
// Add the vertices:
pOEdge->setaVertex(v1);
pOEdge->setbVertex(v2);
// Debug:
if (v1->GetId() == v2->GetId())
cerr << "Warning: edge " << this << " null with vertex " << v1->GetId() << endl;
edge->AddOEdge(pOEdge);
//edge->setNumberOfOEdges(edge->GetNumberOfOEdges() + 1);
// Add this face (the b face)
pOEdge->setbFace(this);
// Adds the edge to the face
AddEdge(pOEdge);
return pOEdge;
//.........这里部分代码省略.........
示例8: ProcessRidgeFace
void FEdgeXDetector::ProcessRidgeFace(WXFace *iFace)
{
// RIDGE LAYER
// Compute the RidgeFunction, that is the derivative of the ppal curvature along e1 at each vertex of the face
WVertex *v;
Vec3r v1v2;
real t;
vector<WXFaceLayer*> SmoothLayers;
WXFaceLayer *faceLayer;
Face_Curvature_Info *layer_info;
real K1_a(0), K1_b(0);
Vec3r Inter_a, Inter_b;
// find the ridge layer of the face
iFace->retrieveSmoothLayers(Nature::RIDGE, SmoothLayers);
if ( SmoothLayers.size()!=1 )
return;
faceLayer = SmoothLayers[0];
// retrieve the curvature info of this layer
layer_info = (Face_Curvature_Info *)faceLayer->userdata;
int numVertices = iFace->numberOfVertices();
for (int i = 0; i < numVertices; i++) {
v = iFace->GetVertex(i);
// vec_curvature_info[i] contains the curvature info of this vertex
Vec3r e2 = layer_info->vec_curvature_info[i]->K2*layer_info->vec_curvature_info[i]->e2;
Vec3r e1 = layer_info->vec_curvature_info[i]->K1*layer_info->vec_curvature_info[i]->e1;
e2.normalize();
WVertex::face_iterator fit = v->faces_begin();
WVertex::face_iterator fitend = v->faces_end();
for (; fit != fitend; ++fit) {
WXFace *wxf = dynamic_cast<WXFace*>(*fit);
WOEdge *oppositeEdge;
if (!(wxf->getOppositeEdge(v, oppositeEdge)))
continue;
v1v2 = oppositeEdge->GetbVertex()->GetVertex() - oppositeEdge->GetaVertex()->GetVertex();
GeomUtils::intersection_test res;
res = GeomUtils::intersectRayPlane(oppositeEdge->GetaVertex()->GetVertex(), v1v2, e2, -(v->GetVertex()*e2),
t, 1.0e-06);
if ((res == GeomUtils::DO_INTERSECT) && (t >= 0.0) && (t <= 1.0)) {
vector<WXFaceLayer*> second_ridge_layer;
wxf->retrieveSmoothLayers(Nature::RIDGE, second_ridge_layer);
if (second_ridge_layer.size() != 1)
continue;
Face_Curvature_Info *second_layer_info = (Face_Curvature_Info*)second_ridge_layer[0]->userdata;
unsigned index1 = wxf->GetIndex(oppositeEdge->GetaVertex());
unsigned index2 = wxf->GetIndex(oppositeEdge->GetbVertex());
real K1_1 = second_layer_info->vec_curvature_info[index1]->K1;
real K1_2 = second_layer_info->vec_curvature_info[index2]->K1;
real K1 = (1.0 - t) * K1_1 + t * K1_2;
Vec3r inter((1.0 - t) * oppositeEdge->GetaVertex()->GetVertex() +
t * oppositeEdge->GetbVertex()->GetVertex());
Vec3r vtmp(inter - v->GetVertex());
// is it K1_a or K1_b ?
if (vtmp * e1 > 0) {
K1_b = K1;
Inter_b = inter;
}
else {
K1_a = K1;
Inter_a = inter;
}
}
}
// Once we have K1 along the ppal direction compute the derivative : K1b - K1a put it in DotP
//real d = fabs(K1_b) - fabs(K1_a);
real d = 0;
real threshold = _meanK1 + (_maxK1 - _meanK1) / 7.0;
//real threshold = _meanK1;
//if ((fabs(K1_b) > threshold) || ((fabs(K1_a) > threshold)))
d = (K1_b) - (K1_a) / (Inter_b - Inter_a).norm();
faceLayer->PushDotP(d);
//faceLayer->PushDotP(layer_info->vec_curvature_info[i]->K1);
}
// Make the values relevant by checking whether all principal directions have the "same" direction:
Vec3r e0((layer_info->vec_curvature_info[0]->K1 * layer_info->vec_curvature_info[0]->e1));
e0.normalize();
Vec3r e1((layer_info->vec_curvature_info[1]->K1 * layer_info->vec_curvature_info[1]->e1));
e1.normalize();
Vec3r e2((layer_info->vec_curvature_info[2]->K1 * layer_info->vec_curvature_info[2]->e1));
e2.normalize();
if (e0 * e1 < 0)
// invert dotP[1]
faceLayer->ReplaceDotP(1, -faceLayer->dotP(1));
if (e0 * e2 < 0)
// invert dotP[2]
faceLayer->ReplaceDotP(2, -faceLayer->dotP(2));
#if 0 // remove the weakest values;
real minDiff = (_maxK1 - _minK1) / 10.0;
real minDiff = _meanK1;
if ((faceLayer->dotP(0) < minDiff) && (faceLayer->dotP(1) < minDiff) && (faceLayer->dotP(2) < minDiff)) {
faceLayer->ReplaceDotP(0, 0);
faceLayer->ReplaceDotP(1, 0);
faceLayer->ReplaceDotP(2, 0);
}
#endif
//.........这里部分代码省略.........
示例9: gts_vertex_principal_directions
//.........这里部分代码省略.........
/* We are solving for the values of the curvature tensor
* B = [ a b ; b c ].
* The computations here are from section 5 of [Meyer et al 2002].
*
* The first step is to calculate the linear equations governing the values of (a,b,c). These can be computed
* by setting the derivatives of the error E to zero (section 5.3).
*
* Since a + c = norm(Kh), we only compute the linear equations for dE/da and dE/db. (NB: [Meyer et al 2002]
* has the equation a + b = norm(Kh), but I'm almost positive this is incorrect).
*
* Note that the w_ij (defined in section 5.2) are all scaled by (1/8*A_mixed). We drop this uniform scale
* factor because the solution of the linear equations doesn't rely on it.
*
* The terms of the linear equations are xterm_dy with x in {a,b,c} and y in {a,b}. There are also const_dy
* terms that are the constant factors in the equations.
*/
/* find the vector from v along edge e */
vec_edge = Vec3r(-1 * e->GetVec());
ve2 = vec_edge.squareNorm();
vdotN = vec_edge * N;
/* section 5.2 - There is a typo in the computation of kappa. The edges should be x_j-x_i. */
kappa = 2.0 * vdotN / ve2;
/* section 5.2 */
/* I don't like performing a minimization where some of the weights can be negative (as can be the case
* if f1 or f2 are obtuse). To ensure all-positive weights, we check for obtuseness. */
weight = 0.0;
if (!triangle_obtuse(v, f1)) {
weight += ve2 * cotan(f1->GetNextOEdge(e->twin())->GetbVertex(), e->GetaVertex(), e->GetbVertex()) / 8.0;
}
else {
if (angle_obtuse(v, f1)) {
weight += ve2 * f1->getArea() / 4.0;
}
else {
weight += ve2 * f1->getArea() / 8.0;
}
}
if (!triangle_obtuse(v, f2)) {
weight += ve2 * cotan (f2->GetNextOEdge(e)->GetbVertex(), e->GetaVertex(), e->GetbVertex()) / 8.0;
}
else {
if (angle_obtuse(v, f2)) {
weight += ve2 * f1->getArea() / 4.0;
}
else {
weight += ve2 * f1->getArea() / 8.0;
}
}
/* projection of edge perpendicular to N (section 5.3) */
d[0] = vec_edge[0] - vdotN * N[0];
d[1] = vec_edge[1] - vdotN * N[1];
d[2] = vec_edge[2] - vdotN * N[2];
d.normalize();
/* not explicit in the paper, but necessary. Move d to 2D basis. */
d1 = d * basis1;
d2 = d * basis2;
示例10: FindPreviousFaceLayer
OWXFaceLayer ViewEdgeXBuilder::FindPreviousFaceLayer(const OWXFaceLayer& iFaceLayer)
{
WXFace *previousFace = NULL;
WOEdge *woebegin;
real tend;
if (iFaceLayer.order) {
woebegin = iFaceLayer.fl->getSmoothEdge()->woea();
tend = iFaceLayer.fl->getSmoothEdge()->ta();
}
else {
woebegin = iFaceLayer.fl->getSmoothEdge()->woeb();
tend = iFaceLayer.fl->getSmoothEdge()->tb();
}
// special case of EDGE_VERTEX config:
if ((tend == 0.0) || (tend == 1.0)) {
WVertex *previousVertex;
if (tend == 0.0)
previousVertex = woebegin->GetaVertex();
else
previousVertex = woebegin->GetbVertex();
if (previousVertex->isBoundary()) // if it's a non-manifold vertex -> ignore
return OWXFaceLayer(NULL, true);
bool found = false;
WVertex::face_iterator f = previousVertex->faces_begin();
WVertex::face_iterator fend = previousVertex->faces_end();
for (; (!found) && (f != fend); ++f) {
previousFace = dynamic_cast<WXFace*>(*f);
if ((0 != previousFace) && (previousFace != iFaceLayer.fl->getFace())) {
vector<WXFaceLayer*> sameNatureLayers;
previousFace->retrieveSmoothEdgesLayers(iFaceLayer.fl->nature(), sameNatureLayers);
// don't know... Maybe should test whether this face has also a vertex_edge configuration
if (sameNatureLayers.size() == 1) {
WXFaceLayer *winner = sameNatureLayers[0];
// check face mark continuity
if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark())
return OWXFaceLayer(NULL, true);
if (woebegin == winner->getSmoothEdge()->woeb()->twin())
return OWXFaceLayer(winner, true);
else
return OWXFaceLayer(winner, false);
}
}
}
}
else {
previousFace = dynamic_cast<WXFace*>(iFaceLayer.fl->getFace()->GetBordingFace(woebegin));
if (0 == previousFace)
return OWXFaceLayer(NULL, true);
// if the next face layer has either no smooth edge or no smooth edge of same nature, no next face
if (!previousFace->hasSmoothEdges())
return OWXFaceLayer(NULL, true);
vector<WXFaceLayer*> sameNatureLayers;
previousFace->retrieveSmoothEdgesLayers(iFaceLayer.fl->nature(), sameNatureLayers);
// don't know how to deal with several edges of same nature on a single face
if ((sameNatureLayers.empty()) || (sameNatureLayers.size() != 1)) {
return OWXFaceLayer(NULL, true);
}
else {
WXFaceLayer *winner = sameNatureLayers[0];
// check face mark continuity
if (winner->getFace()->GetMark() != iFaceLayer.fl->getFace()->GetMark())
return OWXFaceLayer(NULL, true);
if (woebegin == winner->getSmoothEdge()->woeb()->twin())
return OWXFaceLayer(winner, true);
else
return OWXFaceLayer(winner, false);
}
}
return OWXFaceLayer(NULL, true);
}