本文整理汇总了C++中Bface类的典型用法代码示例。如果您正苦于以下问题:C++ Bface类的具体用法?C++ Bface怎么用?C++ Bface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Bface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: promote
void
Bedge::fix_multi()
{
// If any faces in the _adj listed are labelled "primary",
// then move them to a primary slot (_f1 or _f2). Used when
// reading a mesh from file, when primary/secondary face
// labels are specified only after all faces are created.
if (!_adj) // no _adj, so no fixing required
return;
// It's not possible if the total number of "primary" faces
// exceeds 2.
if (nfaces_satisfy(PrimaryFaceFilter()) > 2) {
cerr << "Bedge::fix_multi: error: more than 2 primary faces" << endl;
return;
}
// Work backwards to remove items from the list:
for (int i=_adj->num()-1; i>=0; i--) {
Bface *face = (*_adj)[i];
if (face->is_primary()) {
promote(face);
}
}
}
示例2:
/////////////////////////////////////
// clip_to_patch()
/////////////////////////////////////
void
HatchingGroupFixed::clip_to_patch(
CNDCpt_list &pts, NDCpt_list &cpts,
const ARRAY<double>&prl, ARRAY<double>&cprl )
{
int k, started = 0;
Bface *f;
Wpt foo;
for (k=0; k<pts.num(); k++)
{
f = find_face_vis(pts[k], foo);
if ((f) && (f->patch() == _patch))
{
started = 1;
cpts += pts[k];
cprl += prl[k];
}
else
{
if (started)
{
k=pts.num();
}
}
}
}
示例3: weak_edge
bool
Bface::get_quad_verts(Bvert*& a, Bvert*& b, Bvert*& c, Bvert*& d) const
{
// Return CCW verts a, b, c, d as in the picture, orienting
// things so that the weak edge runs NE as shown:
//
// d ---------- c = w->v2() ^
// | / | |
// | / | |
// | w / | tan1 tan2 |
// | / | --------> |
// | / f | |
// |/ |
// a ---------- b
// = w->v1()
//
if (!is_quad())
return 0;
Bedge* w = weak_edge();
Bface* f = w->ccw_face(w->v2());
a = w->v1();
b = f->next_vert_ccw(a);
c = w->v2();
d = f->quad_vert();
return true;
}
示例4: frontfacing_face
Patch*
Bedge::patch() const
{
Bface* f = frontfacing_face();
f = f ? f : _f1 ? _f1 : _f2;
return f ? f->patch() : 0;
}
示例5: assert
/////////////////////////////////////
// notify_change()
/////////////////////////////////////
void
HatchingHatchFixed::notify_change(BMESHptr m, BMESH::change_t chg)
{
assert(chg == BMESH::VERT_POSITIONS_CHANGED);
vector<HatchingFixedVertex>::size_type k;
if (_verts.size() > 0) {
//Sanity check
assert(_verts.size() == _pts.size());
assert(_verts.size() == _norms.size());
for (k=0; k < _verts.size(); k++) {
Bface *f = m->bf(_verts[k].ind);
assert(f);
f->bc2pos(_verts[k].bar,_pts[k]);
f->bc2norm_blend(_verts[k].bar,_norms[k]);
}
//Clear these cached values so they regenerate
_real_pts.clear();
_real_norms.clear();
_real_good.clear();
}
else
{
err_mesg(ERR_LEV_WARN, "HatchingHatchFixed::notify_change() - Verts changed, but we can't update fixed hatches!!!");
}
}
示例6: err_adv
int
SELECT_WIDGET::tap_cb(CGESTUREptr& g, DrawState*& s)
{
err_adv(debug, "SELECT_WIDGET::tap_cb()");
assert(g && g->is_tap());
if (_mode==SLASH_SEL)
{
//pattern editing
Bface* f = find_face(g->start(),0.25,MIN_PIX_AREA);
if (f) {
if (select_list.contains(f)||select_list.contains(f->quad_partner()))
{
//get whichever part of the quad is in the selection list
int temp = select_list.contains(f) ? select_list.get_index(f)+1 : select_list.get_index(f->quad_partner())+1 ;
if (temp>end_face) //user selected the end face
{
end_face=temp;
}
else //user is selecting a pattern
{
if (pattern<temp)
pattern=temp;
//select/deselect face
if (temp < MAX_PATTERN_SIZE)
pattern_array[temp]=!pattern_array[temp];
}
return 1;
}
else
cerr << "tap found a NULL face !" << endl;
}
return cancel_cb(g,s);
}
else
{
// Tap a selected face near the middle to deselect it:
if (try_deselect_face(g->center(), 0.25))
return 1;
// Tap edge to deselect
if (try_deselect_edge(g->center()))
return 1;
}
// Otherwise, turn off SELECT_WIDGET
return cancel_cb(g,s);
}
示例7: find_face
//! Same as try_select_face(), but deselects.
//! Also requires the found face is currently selected.
bool
SELECT_WIDGET::try_deselect_face(CPIXEL &pix, double margin)
{
Bface* f = find_face(pix, margin, MIN_PIX_AREA);
if (!(f && f->is_selected()))
return false;
WORLD::add_command(new MESH_DESELECT_CMD(f));
return true;
}
示例8: check_partner
inline Bface*
check_partner(Bface* f)
{
// helper function used in quad_complete_faces() below
if (!(f && f->is_quad()))
return nullptr;
Bface* p = f->quad_partner();
return p->flag() ? nullptr : p;
}
示例9: err_adv
int
INFLATE::stroke_cb(CGESTUREptr& gest, DrawState*& s)
{
err_adv(debug, "INFLATE::stroke_cb");
reset_timeout();
// Verify that we have a starting face
if ( _orig_face ) {
Bface* face = 0;
// Check that the stroke is straight enough to represent a line
if (!(gest->straightness() > 0.8)) {
err_adv(debug, "INFLATE::stroke_cb: gesture not straight");
return false;
}
// Check that the gesture starts on the mesh
Bsurface::hit_ctrl_surface(gest->start(), 1, &face);
if (!(face)) {
err_adv(debug, "INFLATE::stroke_cb: can't get hit face");
return false;
}
// create VEXELs for the gesture and the face normal
VEXEL fvec = VEXEL(face->v1()->loc(), face->norm());
VEXEL fgest = gest->endpt_vec();
// If gesture nearly parallel to normal:
double a = rad2deg(line_angle(fvec,fgest));
err_adv(debug, "INFLATE::stroke_cb: angle: %f %s",
a, (a > 15) ? "(bad)" : "(good)");
if (a > 15) {
// Fail if angle is too extreme
WORLD::message("Bad angle");
return 0;
}
// calculate extrude width
double dist = fgest.length()/fvec.length();
err_adv(debug, "INFLATE::stroke_cb: strong_edge_len: %f, gest_len: %f, \
fvect_len: %f", avg_strong_edge_len(face), fgest.length(), fvec.length() );
// Convert to relative to local edge length
dist /= avg_strong_edge_len(face);
if (fvec*fgest<0)
dist=-dist; // Get the sign right
// Store the new inflate distance
_preview_dist = dist;
}
return 1; // we used up the gesture...
}
示例10: assert
int
XformPen::tap_cb(CGESTUREptr& tap, DrawState*& s)
{
assert(tap);
if (tap->is_double_tap()) {
// should never happen given order of arcs in XformPen constructor
cerr << "XformPen::tap_cb: error: gesture is double tap"
<< endl;
return 0;
}
// tap on cursor?
BMESHray ray(tap->center());
_view->intersect(ray);
Cursor3D* c = Cursor3D::upcast(ray.geom());
if (c) {
err_adv(debug, "XformPen::tap_cb: hit axis");
c->handle_gesture(tap);
return 0;
}
// tap on mesh?
_mesh = 0;
Bface* f = cur_face();
if (!f) {
err_adv(debug, "XformPen::tap_cb: missed face");
return cancel_cb(tap, s);
}
BMESH* m = f->mesh();
if (!m) {
err_adv(debug, "XformPen::tap_cb: hit face, no mesh");
return cancel_cb(tap, s);
}
GEOMptr g = bmesh_to_geom(m);
if (!g) {
err_adv(debug, "XformPen::tap_cb: hit mesh, no geom");
return cancel_cb(tap, s);
}
// skip floor:
if (FLOOR::isa(g)) {
err_adv(debug, "XformPen::tap_cb: hit floor, skipping...");
return cancel_cb(tap, s);
}
// tap on ordinary mesh (not floor):
_mesh = m;
assert(_mesh);
BMESH::set_focus(_mesh, f->patch());
FLOOR::show();
FLOOR::realign(_mesh,0); // 0 = no undo command
Cursor3D::attach(g);
return 0;
}
示例11: set_adjacent_edges
void
EdgeStrip::build_ccw_boundaries(
CBedge_list& edges,
CSimplexFilter& face_filter
)
{
// Similar to previous...
//
// XXX - needs comments
// Clear edge flags to screen for unreached edges:
// set edge flags to 1 in 1-ring of verts,
// then clear edge flags of internal edges
set_adjacent_edges(edges.get_verts(), 1);
edges.clear_flags();
// get an edge filter that accepts "boundary" edges WRT the
// given face filter
BoundaryEdgeFilter boundary(face_filter);
// Pull out the edge tips:
Bedge_list tips = edges.filter(ChainTipEdgeFilter(boundary));
// Construct the filter that screens out previously reached
// edges:
UnreachedSimplexFilter unreached;
AndFilter wanted = unreached + boundary;
int k;
// Start from all the tips first:
for (k=0; k<tips.num(); k++) {
Bedge* e = tips[k];
Bvert* v = (e->v2()->degree(boundary) != 2) ? e->v2() : e->v1();
Bface* f = e->screen_face(face_filter);
assert(f); // e must have 1 face satisfying the filter
// If this will start out running ccw, take it.
// otherwise skip:
if (f->next_vert_ccw(v) == e->other_vertex(v))
build(v, e, wanted);
}
// Now check the rest:
for (k=0; k<edges.num(); k++) {
Bedge* e = edges[k];
Bface* f = e->screen_face(face_filter);
assert(f); // e must have 1 face satisfying the filter
// Go CCW around faces
build(f->leading_vert_ccw(e), e, wanted);
}
}
示例12: baseUVpt
// 2
// 3|_|1
// 0
Bface*
ProxySurface::neighbor_face(int dir, Bface* face)
{
UVpt base_uv = baseUVpt(face);
UVpt uv1, uv2, uv3, uv4;
switch (dir)
{
case 0:
uv1 = UVpt(base_uv[0], base_uv[1]);
uv2 = UVpt(base_uv[0]+1, base_uv[1]);
uv3 = UVpt(base_uv[0], base_uv[1]-1);
uv4 = UVpt(base_uv[0]+1, base_uv[1]-1);
break;
case 1:
uv1 = UVpt(base_uv[0]+1, base_uv[1]);
uv2 = UVpt(base_uv[0]+2, base_uv[1]);
uv3 = UVpt(base_uv[0]+1, base_uv[1]+1);
uv4 = UVpt(base_uv[0]+2, base_uv[1]+1);
break;
case 2:
uv1 = UVpt(base_uv[0], base_uv[1]+1);
uv2 = UVpt(base_uv[0]+1, base_uv[1]+1);
uv3 = UVpt(base_uv[0], base_uv[1]+2);
uv4 = UVpt(base_uv[0]+1, base_uv[1]+2);
break;
case 3:
uv1 = UVpt(base_uv[0]-1, base_uv[1]);
uv2 = UVpt(base_uv[0], base_uv[1]);
uv3 = UVpt(base_uv[0], base_uv[1]+1);
uv4 = UVpt(base_uv[0]-1, base_uv[1]+1);
break;
default:
cerr << "ProxySurface::neighbor_face: invalid diraction" << endl;
assert(0);
}
Bvert* v1 = get_vert_grid(uv1);
Bvert* v2 = get_vert_grid(uv2);
Bvert* v3 = get_vert_grid(uv3);
Bvert* v4 = get_vert_grid(uv4);
if(!v1 || !v2 || !v3 || !v4)
return 0;
Bface* n = lookup_quad(v1, v2, v3, v4);
assert(n);
assert(n->is_quad());
n = (n->is_quad_rep()) ? n : n->quad_partner();
return n;
}
示例13: get_other_face
inline void
get_other_face(CBedge* e, CBface* f, Bsimplex_list& ret)
{
assert(e && f && f->contains(e));
if (e->is_weak())
return;
Bface* g = e->other_face(f);
if (!g)
return;
ret.push_back(g);
g = g->quad_partner();
if (g)
ret.push_back(g);
}
示例14: visit
void
visit(OctreeNode* node,
double regularity, Bface_list& flist, ARRAY<Wvec>& blist)
{
if (node->get_leaf()) {
if (node->get_disp()) {
// subdivision
ARRAY<QuadtreeNode*> fs;
Bface_list temp;
for (int i = 0; i < node->intersects().num(); i++) {
Bface* f = node->intersects()[i];
temp += f;
fs += new QuadtreeNode(f->v1()->loc(), f->v2()->loc(), f->v3()->loc());
fs.last()->build_quadtree(node, regularity);
fs.last()->set_terms();
}
// assign weights
assign_weights(fs, regularity, node->center());
// pick a triangle
int t = pick(fs);
// moved below; want to ensure flist and blist stay in sync:
// flist += temp[t];
//set node face
Bface_list ftemp;
ftemp += temp[t];
node->set_face(ftemp);
// pick a point
int p = pick(fs[t]->terms());
if (p != -1) {
Wvec bc;
temp[t]->project_barycentric(fs[t]->terms()[p]->urand_pick(), bc);
blist += bc;
flist += temp[t]; // moved from above
node->set_point(bc);
}
for (int i = 0; i < fs.num(); i++)
delete fs[i];
fs.clear();
}
} else {
for (int i = 0; i < 8; i++)
visit(node->get_children()[i], regularity, flist, blist);
}
}
示例15: reset_timeout
int
INFLATE::line_cb(CGESTUREptr& gest, DrawState*& s)
{
// Activity occurred to extend the deadline for fading away:
reset_timeout();
err_adv(debug, "INFLATE::line_cb");
// Verify that we have a starting face
if ( _orig_face ) {
// Check that the stroke is straight enough to represent a line
Bface* face = 0;
if (!(gest->straightness() > 0.8)) {
err_adv(debug, "INFLATE::line_cb: gesture not straight");
return false;
}
// Check that the gesture starts on the mesh
Bsurface::hit_ctrl_surface(gest->start(), 1, &face);
if (!(face)) {
err_adv(debug, "INFLATE::line_cb: can't get hit face");
return false;
}
// create VEXELs for the gesture and the face normal
VEXEL fvec = VEXEL(face->v1()->loc(), face->norm());
VEXEL fgest = gest->endpt_vec();
// If gesture nearly parallel to normal:
double a = rad2deg(line_angle(fvec,fgest));
err_adv(debug, "INFLATE::line_cb: angle: %f %s",
a, (a > 15) ? "(bad)" : "(good)");
if (a > 15) {
return false;
}
// calculate extrude width
double dist = fgest.length()/fvec.length();
if (fvec*fgest<0)
dist=-dist; // Get the sign right
_preview_dist = dist;
}
// get here if nothing happened...
// don't cancel (which would deactivate the widget),
// just return 1 to indicate that we used up the gesture:
return 1;
}