Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

A48::Mesh Class Reference

The class Mesh defines data structures and methods that represent a 4-8 mesh. More...

#include <mesh.h>

Collaboration diagram for A48::Mesh:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Mesh (Surface *s)
 The construtor specifies a surface class.

 ~Mesh ()
 The mesh class destructor. Destroys the mesh data structures.

Surfacesurf ()
 Returns the surface pointer.

VertexIter verts_begin ()
 Returns iterator that points to the first vertex of the mesh.

VertexIter verts_end ()
 Returns iterador that points to the last vertex of the mesh.

int num_verts ()
 Returns the number of vertices.

EdgeIter edges_begin ()
 Returns iterator that points to the first edge of the mesh.

EdgeIter edges_end ()
 Returns iterador that points to the last vertex of the mesh.

int num_edges ()
 Returns the number of egdes.

FaceIter faces_begin ()
 Returns iterator that points to the first face of the mesh.

FaceIter faces_end ()
 Returns iterador that points to the last vertex of the mesh.

int num_faces ()
 Returns the number of faces.

void adapt_refine (double t)
 Refines the mesh based on threshold t.

void adapt_simplify (double t)
 Simplifies the mesh based on threshold t.

Vertexrefine (Hedge *e)
 Splits an edge.

Hedgesimplify (Vertex *w)
 Removes a vertex from mesh.

Vertexsplit (Face *f)
 Divides a face.

Vertexsplit (Hedge *e)
 Splits an edge.

Hedgeweld (Vertex *w)
 Removes a vertex.

Hedgeflip (Hedge *h)
 Flips internal edge.


Private Member Functions

Vertexadd_vertex (void)
 Adds a new vertex.

bool add_vertex (Vertex *v)
 Adds an existing vertex.

void del_vertex (Vertex *v)
 Removes a vertex from mesh.

Hedgeadd_edge (Vertex *v0, Vertex *v1)
 Adds a new edge.

bool add_edge (Edge *e)
 Add an existing edge.

void del_edge (Edge *e)
 Removes an edge from mesh.

Faceadd_face (Hedge *e0, Hedge *e1, Hedge *e2)
 Adds a new face.

bool add_face (Face *f)
 Adds an existing face.

void del_face (Face *f)
 Removes a face from mesh.

void link_mesh ()
 Creates links among faces, egdes and verticess.

Vertexbisect (Hedge *e, Hedge **el, Hedge **er)
 Splits an edge in two sub-edges.

Hedgebisect (Face *f, Hedge *e1, Hedge *e2, Hedge *el, Hedge *er)
 Splits a face in two sub-faces.

void new_front ()
 Creates the simplifying and refining queues.

void update_ref_front (Edge *e)
 Inserts an edge in the refining priority queue.

void update_ref_front (Vertex *v)
 Inserts a vertex in the refining priority queue.

void update_simpl_front (Vertex *v)
 Inserts a vertex in the simplifying priority queue.

void update_simpl_front (Edge *e)
 Inserts an edge in the simplifying priority queue.

bool is_triquad (void)
 Returns true if the mesh is a triangulated-quadrangulation, else return false.

void make_triquad (void)
 Converts the mesh to a triagulated-quadrangulation.

void set_base_mesh (int np, int *tris, int nf)
 Specifies a base mesh.

Hedgeget_hedge (int i0, int i1, Vertex *verts[], HedgeMap *edges)
 Returns half-edge pointer identified by the vertices of index i0 and i1.

void put_face (int i0, int i1, int i2, Vertex *verts[], HedgeMap *edges)
 Creates a face from half-edges. The half-edges are specified by vertices of index i0, i1 and i2.


Private Attributes

Surfacesurf_
 Surface pointer.

FaceContainer fc_
 Set of faces.

EdgeContainer ec_
 Set of edges.

VertexContainer vc_
 Set of vertices.

MxHeap sf_
 Priority queue for simplification front.

MxHeap rf_
 Priority queue for refinement front.


Detailed Description

The class Mesh defines data structures and methods that represent a 4-8 mesh.

Definition at line 74 of file mesh.h.


Constructor & Destructor Documentation

Mesh::Mesh Surface s  ) 
 

The construtor specifies a surface class.

Receives a surface object that determines the mesh.

Parameters:
s Surface pointer.

Definition at line 16 of file mesh.cpp.

References A48::Surface::base_mesh(), is_triquad(), make_triquad(), new_front(), set_base_mesh(), and surf().

00016 : surf_(s) 00017 { 00018 int np, nf, *fcs; 00019 surf()->base_mesh(&np, &fcs, &nf); 00020 set_base_mesh(np, fcs, nf); 00021 if (!is_triquad()) 00022 make_triquad(); 00023 new_front(); 00024 }

Mesh::~Mesh  ) 
 

The mesh class destructor. Destroys the mesh data structures.

Dealocates all data (vertices, faces, edges and half-edges) of the mesh.

Definition at line 29 of file mesh.cpp.

References ec_, fc_, and vc_.

00030 { 00031 for (VertexIter p = vc_.begin(); p != vc_.end(); p++) 00032 delete *p; 00033 vc_.clear(); 00034 for (EdgeIter e = ec_.begin(); e != ec_.end(); e++) 00035 delete *e; 00036 ec_.clear(); 00037 for (FaceIter f = fc_.begin(); f != fc_.end(); f++) 00038 delete *f; 00039 fc_.clear(); 00040 }


Member Function Documentation

void Mesh::adapt_refine double  t  ) 
 

Refines the mesh based on threshold t.

Updates the refinement queue and inserts a half-edge based on rank. The adge is inserted in the queue if its rank is less than a threshold.

Parameters:
t Specifies a priority threshold.

Definition at line 61 of file adapt.cpp.

References ec_, A48::Edge::hedge(), refine(), rf_, and surf().

00062 { 00063 for (EdgeIter ei = ec_.begin(); ei != ec_.end(); ei++) 00064 if ((*ei)->is_in_heap()) 00065 rf_.update((MxHeapable*)(*ei), surf()->ref_rank(*ei)); 00066 Edge *e; 00067 while ((e = (Edge*) rf_.extract()) != NULL) { 00068 if (e->heap_key() < t) { 00069 rf_.insert((MxHeapable*)e, surf()->ref_rank(e)); 00070 return; 00071 } 00072 refine(e->hedge(0)); 00073 } 00074 }

void Mesh::adapt_simplify double  t  ) 
 

Simplifies the mesh based on threshold t.

Updates the simplifying queue and inserts a vertex based on rank. The edge is inserted in the queue if its rank is less than a threshold.

Parameters:
t Specifies a priority threshold.

Definition at line 82 of file adapt.cpp.

References sf_, simplify(), surf(), and vc_.

00083 { 00084 for (VertexIter vi = vc_.begin(); vi != vc_.end(); vi++) 00085 if ((*vi)->is_in_heap()) 00086 sf_.update((MxHeapable*)(*vi), surf()->simpl_rank(*vi)); 00087 Vertex *v; 00088 while ((v = (Vertex*) sf_.extract()) != NULL) { 00089 if (v->heap_key() < t) { 00090 sf_.insert((MxHeapable*)v, surf()->simpl_rank(v)); 00091 return; 00092 } 00093 simplify(v); 00094 } 00095 }

bool A48::Mesh::add_edge Edge e  )  [inline, private]
 

Add an existing edge.

Parameters:
e Edge pointer.
Returns:
true if add operation was completed, else return false.

Definition at line 174 of file mesh.h.

References ec_.

00175 { std::pair<EdgeIter, bool> r = ec_.insert(e); return r.second;};

Hedge * Mesh::add_edge Vertex v0,
Vertex v1
[private]
 

Adds a new edge.

Adds a new edge in the mesh.

Parameters:
v0 origin vertex pointer.
v1 end vertex pointer.
Returns:
pointer to half-egde of the origin vertex.

Definition at line 62 of file mesh.cpp.

References add_edge(), and A48::Edge::hedge().

Referenced by add_edge(), bisect(), get_hedge(), and split().

00063 { 00064 Edge *e = new Edge(v0, v1); 00065 add_edge(e); 00066 return e->hedge(0); 00067 }

bool A48::Mesh::add_face Face f  )  [inline, private]
 

Adds an existing face.

Parameters:
f Face pointer.
Returns:
true if add operation was completed, else return false.

Definition at line 187 of file mesh.h.

References fc_.

00188 { std::pair<FaceIter, bool> r = fc_.insert(f); return r.second;}

Face * Mesh::add_face Hedge e0,
Hedge e1,
Hedge e2
[private]
 

Adds a new face.

Adds a new face in the mesh

Parameters:
e0 First half-edge.
e1 Second half-edge.
e2 Third half-edge.
Returns:
pointer to new face.

Definition at line 49 of file mesh.cpp.

References add_face().

Referenced by add_face(), bisect(), put_face(), and split().

00050 { 00051 Face *f = new Face(e0, e1, e2); 00052 add_face(f); 00053 return f; 00054 }

bool A48::Mesh::add_vertex Vertex v  )  [inline, private]
 

Adds an existing vertex.

Parameters:
v Vertex pointer.
Returns:
Return true if add operation was completed, else return false.

Definition at line 161 of file mesh.h.

References vc_.

00162 { std::pair<VertexIter, bool> r = vc_.insert(v); return r.second; };

Vertex * Mesh::add_vertex void   )  [private]
 

Adds a new vertex.

Adds a new vertex in the mesh.

Returns:
pointer to new vertex.

Definition at line 73 of file mesh.cpp.

References A48::Surface::new_vertex(), and surf().

Referenced by bisect(), set_base_mesh(), and split().

00074 { 00075 Vertex *v = surf()->new_vertex(); 00076 add_vertex(v); 00077 return v; 00078 }

Hedge * Mesh::bisect Face f,
Hedge e1,
Hedge e2,
Hedge el,
Hedge er
[private]
 

Splits a face in two sub-faces.

Splits a face into two new faces. The face is splitted through vertex m.

Parameters:
f face that must be splitted.
e1 next half-edge of splitted half-edge.
e2 previous half-edge of splitted half-edge.
el Half-edge from vertex v0 to vertex m.
er Half-edge from vertex m to vertex v1.
Returns:
Return a half-edge pointer that splitted the face.

Definition at line 72 of file stellar.cpp.

References add_edge(), add_face(), A48::Hedge::mate(), A48::Hedge::org(), and A48::Face::reuse().

00073 { 00074 if (f == NULL) return 0; 00075 Hedge *em = add_edge(e2->org(), er->org()); 00076 f->reuse(e1, em, er); 00077 add_face(new Face(e2, el, em->mate())); 00078 return em; 00079 }

Vertex * Mesh::bisect Hedge e,
Hedge **  el,
Hedge **  er
[private]
 

Splits an edge in two sub-edges.

Bisects a half-edge into two new sub half-edges. The old half-edge is divided by inserting a new vertex.

Parameters:
e Half-edge pointer.
el Half-edge from vertex v0 to vertex m.
er Half-edge from vertex m to vertex v1.
Returns:
Return a new vertex pointer (m).

Definition at line 48 of file stellar.cpp.

References add_edge(), add_vertex(), A48::Hedge::dst(), A48::Hedge::edge(), A48::Hedge::level(), A48::Hedge::org(), A48::Hedge::reuse(), A48::Surface::sample(), A48::Vertex::set_level(), A48::Vertex::set_star(), A48::Vertex::star_first(), and surf().

Referenced by split().

00049 { 00050 Vertex *v0 = e->org(); 00051 Vertex *v1 = e->dst(); 00052 Vertex *m = add_vertex(); 00053 m->set_level(e->level() + 1); 00054 surf()->sample(e->edge(), m); 00055 *el = e->reuse(v0, m); 00056 *er = add_edge(m, v1); 00057 if (v1->star_first() == e) 00058 v1->set_star((*er)); 00059 return m; 00060 }

void A48::Mesh::del_edge Edge e  )  [inline, private]
 

Removes an edge from mesh.

Parameters:
e Edge pointer.

Definition at line 179 of file mesh.h.

References del_edge(), and ec_.

Referenced by del_edge(), and weld().

00179 { ec_.erase(e); delete(e); }

void A48::Mesh::del_vertex Vertex v  )  [inline, private]
 

Removes a vertex from mesh.

Parameters:
v Vertex pointer.

Definition at line 166 of file mesh.h.

References A48::Surface::del_vertex(), del_vertex(), surf(), and vc_.

Referenced by del_vertex(), and weld().

00166 { vc_.erase(v); surf()->del_vertex(v); };

EdgeIter A48::Mesh::edges_begin  )  [inline]
 

Returns iterator that points to the first edge of the mesh.

Returns:
Edge iterator.

Definition at line 107 of file mesh.h.

References ec_.

Referenced by new_front().

00107 { return ec_.begin(); };

EdgeIter A48::Mesh::edges_end  )  [inline]
 

Returns iterador that points to the last vertex of the mesh.

Returns:
Edge iterator.

Definition at line 111 of file mesh.h.

References ec_.

Referenced by new_front().

00111 { return ec_.end(); };

FaceIter A48::Mesh::faces_begin  )  [inline]
 

Returns iterator that points to the first face of the mesh.

Returns:
Face iterator.

Definition at line 119 of file mesh.h.

References fc_.

00119 { return fc_.begin(); };

FaceIter A48::Mesh::faces_end  )  [inline]
 

Returns iterador that points to the last vertex of the mesh.

Returns:
Face iterator.

Definition at line 123 of file mesh.h.

References fc_.

00123 { return fc_.end(); };

Hedge * Mesh::flip Hedge h  ) 
 

Flips internal edge.

Changes the connectivity of an edge shared by two faces.

Parameters:
h Points to half-edge.
Returns:
new half-edge pointer.

Definition at line 164 of file stellar.cpp.

References A48::Hedge::dst(), A48::Hedge::face(), A48::Hedge::mate(), A48::Hedge::next(), A48::Hedge::org(), A48::Hedge::prev(), A48::Face::reuse(), A48::Hedge::reuse(), A48::Vertex::set_star(), and A48::Vertex::star_first().

00165 { 00166 Hedge *m = h->mate(); 00167 Face *fl = h->face(); 00168 Face *fr = m->face(); 00169 if (fl == NULL || fr == NULL) 00170 return h; 00171 Hedge *hp = h->prev(); 00172 Hedge *hn = h->next(); 00173 Hedge *mp = m->prev(); 00174 Hedge *mn = m->next(); 00175 Vertex *v0 = h->org(); 00176 Vertex *v1 = h->dst(); 00177 Vertex *vl = hp->org(); 00178 Vertex *vr = mp->org(); 00179 if (v0->star_first() == m) 00180 v0->set_star(hp); 00181 if (v1->star_first() == h) 00182 v1->set_star(mp); 00183 Hedge *o = h->reuse(vl, vr); 00184 fr->reuse(o, mp, hn); 00185 fl->reuse(o->mate(), hp, mn); 00186 return o; 00187 }

Hedge * Mesh::get_hedge int  i0,
int  i1,
Vertex verts[],
HedgeMap *  hedges
[private]
 

Returns half-edge pointer identified by the vertices of index i0 and i1.

Returns a half-edge specified by vertices of index i0 and i1. If the vertices don't exist, a new edge is created with two new vertices.

Parameters:
i0 First vertex index.
i1 Second vertex index.
verts Points to vertices.
hedges Belongs to std::map class. (This class provides efficient search operations.)
Returns:
half-edge pointer.

Definition at line 103 of file mesh.cpp.

References add_edge().

Referenced by put_face().

00104 { 00105 bool mate = false; 00106 if (i0 > i1) { 00107 std::swap<int>(i0, i1); 00108 mate = true; 00109 } 00110 Hedge* he; HedgeMap::iterator ei = hedges->find(Ipair(i0,i1)); 00111 if (ei == hedges->end()) 00112 (*hedges)[Ipair(i0,i1)] = he = add_edge(verts[i0], verts[i1]); 00113 else 00114 he = (*ei).second; 00115 return (mate)? he->mate() : he ; 00116 }

bool Mesh::is_triquad void   )  [private]
 

Returns true if the mesh is a triangulated-quadrangulation, else return false.

Verifies if a mesh is a triangulated-quadrangulation.

Definition at line 94 of file triquad.cpp.

References ec_, A48::Hedge::face(), A48::Edge::hedge(), A48::Edge::is_bdry(), and A48::Face::subd_edge().

Referenced by Mesh().

00095 { 00096 for (EdgeIter ei = ec_.begin(); ei != ec_.end(); ei++) { 00097 Edge *e = *ei; 00098 if (!e->is_bdry()) { 00099 bool f0s = (e->hedge(0)->face()->subd_edge() == e->hedge(0)); 00100 bool f1s = (e->hedge(1)->face()->subd_edge() == e->hedge(1)); 00101 if ((f0s && !f1s) || (!f0s && f1s)) 00102 return false; 00103 } 00104 } 00105 return true; 00106 }

void Mesh::link_mesh  )  [private]
 

Creates links among faces, egdes and verticess.

Links stars of mesh

Definition at line 83 of file mesh.cpp.

References A48::Hedge::dst(), ec_, fc_, A48::Hedge::is_bdry(), and A48::Vertex::set_star().

Referenced by set_base_mesh().

00084 { 00085 for (FaceIter f = fc_.begin(); f != fc_.end(); f++) 00086 (*f)->link_star_verts(); 00087 for (EdgeIter e = ec_.begin(); e != ec_.end(); e++) { 00088 Hedge* h = (*e)->hedge(0); 00089 if (h->is_bdry()) 00090 h->dst()->set_star(h); 00091 } 00092 }

void Mesh::make_triquad void   )  [private]
 

Converts the mesh to a triagulated-quadrangulation.

Transforms a general mesh into a triangulated-quadrangulation.

Definition at line 63 of file triquad.cpp.

References ec_, node::edge, A48::Hedge::face(), fc_, A48::Edge::hedge(), A48::Markable::is_marked(), split(), and vc_.

Referenced by Mesh().

00064 { 00065 std::priority_queue< node, std::vector< node >, std::less<node> > q; 00066 00067 for (VertexIter p = vc_.begin(); p != vc_.end(); p++) 00068 (*p)->set_level(0); 00069 for (EdgeIter e = ec_.begin(); e != ec_.end(); e++) { 00070 (*e)->set_mark(false); 00071 q.push(node(*e, this)); 00072 } 00073 while ( !q.empty() ) { 00074 node n = q.top(); q.pop(); 00075 if (!n.edge->is_marked()) { 00076 mark_link(n.edge); 00077 if (n.edge->hedge(0)->face() != NULL) 00078 split(n.edge->hedge(0)); 00079 else 00080 split(n.edge->hedge(1)); 00081 } 00082 } 00083 for (FaceIter f = fc_.begin(); f != fc_.end(); f++) 00084 if ((*f)->level() == 0) 00085 split(*f); 00086 for (VertexIter p = vc_.begin(); p != vc_.end(); p++) 00087 (*p)->set_level(0); 00088 }

void Mesh::new_front  )  [private]
 

Creates the simplifying and refining queues.

Creates simplification and refinement fronts. Insert vertices that can be removed from mesh and edges that can be splitted.

Definition at line 16 of file front.cpp.

References edges_begin(), edges_end(), rf_, sf_, surf(), verts_begin(), and verts_end().

Referenced by Mesh().

00017 { 00018 while (rf_.extract() != NULL) 00019 ; 00020 for (EdgeIter ei = edges_begin(); ei != edges_end(); ei++) { 00021 if ((*ei)->is_subdiv()) 00022 rf_.insert((MxHeapable *) *ei, surf()->ref_rank(*ei)); 00023 } 00024 while (sf_.extract() != NULL) 00025 ; 00026 for (VertexIter w = verts_begin(); w != verts_end(); w++) 00027 if ((*w)->is_weld()) 00028 sf_.insert((MxHeapable *) *w, surf()->simpl_rank(*w)); 00029 }

int A48::Mesh::num_edges  )  [inline]
 

Returns the number of egdes.

Returns:
Number of edges.

Definition at line 115 of file mesh.h.

References ec_.

00115 { return ec_.size(); };

int A48::Mesh::num_faces  )  [inline]
 

Returns the number of faces.

Returns:
Number of faces.

Definition at line 127 of file mesh.h.

References fc_.

00127 { return fc_.size(); };

int A48::Mesh::num_verts  )  [inline]
 

Returns the number of vertices.

Returns:
Number of faces.

Definition at line 103 of file mesh.h.

References vc_.

00103 { return vc_.size(); };

void Mesh::put_face int  i0,
int  i1,
int  i2,
Vertex verts[],
HedgeMap *  hedges
[private]
 

Creates a face from half-edges. The half-edges are specified by vertices of index i0, i1 and i2.

Adds a new face specified by the vertices of index i1, i2, i3. If any vertex doesn't exist, than it is created.

Parameters:
i0 First vertex index.
i1 Second vertex index.
i2 Third vertex index.
verts Points to new vertexes.
hedges Points to std::map class. (This class provide efficient search operations.)

Definition at line 127 of file mesh.cpp.

References add_face(), and get_hedge().

Referenced by set_base_mesh().

00128 { 00129 Hedge* e0 = get_hedge(i1, i2, verts, hedges); 00130 Hedge* e1 = get_hedge(i2, i0, verts, hedges); 00131 Hedge* e2 = get_hedge(i0, i1, verts, hedges); 00132 add_face(e0, e1, e2); 00133 }

Vertex * Mesh::refine Hedge e  ) 
 

Splits an edge.

Refines a region specified by a half-edge, recursively.

Parameters:
e Specifies half-edge that must be splitted.
Returns:
vertex of the half-edge splitted.

Definition at line 16 of file adapt.cpp.

References A48::Hedge::edge(), A48::Hedge::face(), A48::Hedge::mate(), refine(), split(), A48::Face::subd_edge(), and update_ref_front().

Referenced by adapt_refine(), and refine().

00017 { 00018 Face *f; Hedge *r[2]; int n = 0; 00019 if ((f = e->face()) != NULL && f->subd_edge() != e) 00020 r[n++] = f->subd_edge(); 00021 if ((f = e->mate()->face()) != NULL && f->subd_edge() != e->mate()) 00022 r[n++] = f->subd_edge(); 00023 for (int k=0; k < n; k++) 00024 refine(r[k]); 00025 update_ref_front(e->edge()); 00026 Vertex* w = split(e); 00027 update_ref_front(w); 00028 return w; 00029 }

void Mesh::set_base_mesh int  np,
int *  tris,
int  nf
[private]
 

Specifies a base mesh.

Receives all data information to build the base mesh.

Parameters:
np Number of vertices.
tris Array of indices with mesh topology.
nf Number of faces.

Definition at line 141 of file mesh.cpp.

References add_vertex(), link_mesh(), A48::Surface::new_vertex(), put_face(), A48::Surface::sample(), and surf().

Referenced by Mesh().

00142 { 00143 Vertex** verts = new Vertex*[np]; 00144 for (int i=0; i < np; i++) { 00145 verts[i] = surf()->new_vertex(); 00146 surf()->sample(i, verts[i]); 00147 add_vertex(verts[i]); 00148 } 00149 HedgeMap hedges; 00150 for (int i=0; i < nf; i++, tris += 3) 00151 put_face(tris[2], tris[0],tris[1], verts, &hedges); 00152 link_mesh(); 00153 delete(verts); 00154 }

Hedge * Mesh::simplify Vertex w  ) 
 

Removes a vertex from mesh.

Simplifies a region specified by a vertex.

Parameters:
w Specifies a vertex that must be removed from the mesh.
Returns:
half-edge created by welding two half-edges.

Definition at line 36 of file adapt.cpp.

References A48::Hedge::edge(), A48::Vertex::is_bdry(), A48::Vertex::level(), A48::Hedge::org(), simplify(), A48::Vertex::star_first(), A48::Vertex::star_next(), update_simpl_front(), and weld().

Referenced by adapt_simplify(), and simplify().

00037 { 00038 int n = 0, weld_deg = (w->is_bdry()) ? 3 : 4; 00039 do { 00040 int lmax = w->level(); Hedge *e; Vertex *u, *v; 00041 for (e = w->star_first(), n = 0; e != NULL; e = w->star_next(e), n++) { 00042 u = e->org(); 00043 if (u->level() > lmax) { 00044 lmax = u->level(); v = u; 00045 } 00046 } 00047 if (lmax > w->level()) 00048 simplify(v); 00049 } while (n > weld_deg); 00050 update_simpl_front(w); 00051 Hedge* e = weld(w); 00052 update_simpl_front(e->edge()); 00053 return e; 00054 }

Vertex * Mesh::split Hedge e  ) 
 

Splits an edge.

Splits a half-edge into two sub-half-edges.

Parameters:
e Half-edge that must be splitted.
Returns:
new vertex pointer.

Definition at line 19 of file stellar.cpp.

References bisect(), A48::Hedge::face(), A48::Face::level(), A48::Hedge::mate(), A48::Hedge::next(), A48::Hedge::prev(), A48::Vertex::set_level(), and A48::Vertex::set_star().

00020 { 00021 Hedge *el, *er; 00022 if (e->face() == NULL) e = e->mate(); 00023 Face *f = e->face(); 00024 if (f == NULL) throw Error("subdiv edge"); 00025 int lf0 = f->level(); 00026 Face *fm = e->mate()->face(); 00027 int lf1 = (fm)? fm->level() : 0; 00028 Hedge *ef1 = e->next(); 00029 Hedge *ef2 = e->prev(); 00030 Hedge *efm1 = (fm)? e->mate()->next() : NULL; 00031 Hedge *efm2 = (fm)? e->mate()->prev() : NULL; 00032 Vertex *v = bisect(e, &el, &er); 00033 bisect(f, ef1, ef2, e, er); 00034 bisect(fm, efm1, efm2, er->mate(), e->mate()); 00035 v->set_star(e); 00036 v->set_level(max(lf0, lf1) + 1); 00037 return v; 00038 }

Vertex * Mesh::split Face f  ) 
 

Divides a face.

Divides a face into three new faces. The new vertex is inserted inside the face and new faces are built.

Parameters:
f Points to face that must be subdivided.
Returns:
new vertex pointer (inside vertex).

Definition at line 138 of file stellar.cpp.

References add_edge(), add_face(), add_vertex(), A48::Face::hedge(), A48::Face::level(), A48::Hedge::mate(), A48::Face::reuse(), A48::Surface::sample(), A48::Vertex::set_level(), A48::Vertex::set_star(), surf(), and A48::Face::vertex().

Referenced by make_triquad(), and refine().

00139 { 00140 Hedge *e0 = f->hedge(0); 00141 Hedge *e1 = f->hedge(1); 00142 Hedge *e2 = f->hedge(2); 00143 Vertex *v0 = f->vertex(0); 00144 Vertex *v1 = f->vertex(1); 00145 Vertex *v2 = f->vertex(2); 00146 Vertex *vc = add_vertex(); 00147 vc->set_level(f->level() + 1); 00148 surf()->sample(f, vc); 00149 Hedge *e0c = add_edge(v0, vc); 00150 Hedge *e1c = add_edge(v1, vc); 00151 Hedge *e2c = add_edge(v2, vc); 00152 f->reuse(e0, e2c, e1c->mate()); 00153 add_face(new Face(e1, e0c, e2c->mate())); 00154 add_face(new Face(e2, e1c, e0c->mate())); 00155 vc->set_star(e0c); 00156 return vc; 00157 }

Surface* A48::Mesh::surf  )  [inline]
 

Returns the surface pointer.

Returns:
Surface pointer.

Definition at line 91 of file mesh.h.

References surf_.

Referenced by adapt_refine(), adapt_simplify(), add_vertex(), bisect(), del_vertex(), Mesh(), new_front(), node::node(), set_base_mesh(), split(), update_ref_front(), and update_simpl_front().

00091 { return surf_; };

void Mesh::update_ref_front Vertex v  )  [private]
 

Inserts a vertex in the refining priority queue.

Updates the refinement front (insertion phase)

Parameters:
v Pointer to a vertex added.

Definition at line 56 of file front.cpp.

References A48::Hedge::edge(), A48::Edge::is_subdiv(), A48::Hedge::prev(), rf_, sf_, A48::Vertex::star_first(), A48::Vertex::star_next(), and surf().

00057 { 00058 sf_.insert(v, surf()->simpl_rank(v)); 00059 for (Hedge* s = v->star_first(); s != NULL; s = v->star_next(s)) 00060 if (s->prev() != NULL) { 00061 Edge *e = s->prev()->edge(); 00062 if (e->is_subdiv()) 00063 rf_.insert(e, surf()->ref_rank(e)); 00064 } 00065 }

void Mesh::update_ref_front Edge e  )  [private]
 

Inserts an edge in the refining priority queue.

Updates the refinement front (deletion phase)

Parameters:
e Pointer to splitted edge.

Definition at line 35 of file front.cpp.

References A48::Hedge::dst(), A48::Hedge::face(), A48::Edge::hedge(), A48::Vertex::is_weld(), A48::Hedge::next(), rf_, and sf_.

Referenced by refine().

00036 { 00037 rf_.remove(e); 00038 if (e->hedge(0)->next() != NULL) { 00039 Face *f = e->hedge(0)->face(); 00040 Vertex *v = e->hedge(0)->next()->dst(); 00041 if (!v->is_weld(f)) 00042 sf_.remove(v); 00043 } 00044 if (e->hedge(1)->next() != NULL) { 00045 Face *f = e->hedge(1)->face(); 00046 Vertex *v = e->hedge(1)->next()->dst(); 00047 if (!v->is_weld(f)) 00048 sf_.remove(v); 00049 } 00050 }

void Mesh::update_simpl_front Edge e  )  [private]
 

Inserts an edge in the simplifying priority queue.

Updates the siplification front (insertion phase)

Parameters:
e Weld edge pointer.

Definition at line 88 of file front.cpp.

References A48::Hedge::dst(), A48::Edge::hedge(), A48::Vertex::is_weld(), A48::Hedge::next(), rf_, sf_, and surf().

00089 { 00090 rf_.insert(e, surf()->ref_rank(e)); 00091 if (e->hedge(0)->next() != NULL) { 00092 Vertex* w = e->hedge(0)->next()->dst(); 00093 if (w->is_weld()) 00094 sf_.insert(w, surf()->simpl_rank(w)); 00095 } 00096 if (e->hedge(1)->next() != NULL) { 00097 Vertex* w = e->hedge(1)->next()->dst(); 00098 if (w->is_weld()) 00099 sf_.insert(w, surf()->simpl_rank(w)); 00100 } 00101 }

void Mesh::update_simpl_front Vertex v  )  [private]
 

Inserts a vertex in the simplifying priority queue.

Updates the siplification front (deletion phase)

Parameters:
v Pointer to vertex that must be removed from mesh.

Definition at line 71 of file front.cpp.

References A48::Hedge::edge(), A48::Hedge::is_subdiv_itself(), A48::Hedge::mate(), A48::Hedge::prev(), rf_, sf_, A48::Vertex::star_first(), and A48::Vertex::star_next().

Referenced by simplify().

00072 { 00073 sf_.remove(v); 00074 for (Hedge* s = v->star_first(); s != NULL; s = v->star_next(s)) 00075 if (s->prev() != NULL) { 00076 Hedge *m = s->prev()->mate(); 00077 if (!m->is_subdiv_itself()) { 00078 Edge *e = s->prev()->edge(); 00079 rf_.remove(e); 00080 } 00081 } 00082 }

VertexIter A48::Mesh::verts_begin  )  [inline]
 

Returns iterator that points to the first vertex of the mesh.

Returns:
Vertex iterator.

Definition at line 95 of file mesh.h.

References vc_.

Referenced by new_front().

00095 { return vc_.begin(); };

VertexIter A48::Mesh::verts_end  )  [inline]
 

Returns iterador that points to the last vertex of the mesh.

Returns:
Vertex iterator.

Definition at line 99 of file mesh.h.

References vc_.

Referenced by new_front().

00099 { return vc_.end(); };

Hedge * Mesh::weld Vertex w  ) 
 

Removes a vertex.

Removes a vertex from mesh. This operation welds two half-edges into one half-edge.

Parameters:
w Points to a vertex that must be removed from mesh.
Returns:
new half-edge pointer.

Definition at line 87 of file stellar.cpp.

References del_edge(), del_face(), del_vertex(), A48::Vertex::level(), A48::Hedge::mate(), A48::Hedge::next(), A48::Hedge::prev(), A48::Face::reuse(), A48::Hedge::reuse(), A48::Vertex::set_star(), A48::Vertex::star_first(), and A48::Vertex::star_next().

Referenced by simplify().

00088 { 00089 int k, n; 00090 Hedge *ee, *e[6]; Face *f[6]; Vertex *v[6]; 00091 if (w->level() == 0) 00092 return NULL; 00093 for (n=0, ee=w->star_first(); ee != NULL; n++, ee=w->star_next(ee)) { 00094 if (n > 4) throw Error("weld"); 00095 e[n] = ee; 00096 v[n] = ee->org(); 00097 f[n] = ee->face(); 00098 } 00099 if (n != 4 && n != 3) 00100 { std::cerr << "can't weld " << n << "\n"; return NULL; } 00101 Hedge *p0 = e[0]->prev(); 00102 Hedge *n2 = e[2]->mate()->next(); 00103 Hedge *n0, *p2; 00104 if (f[2] != NULL) { 00105 n0 = e[0]->mate()->next(); 00106 p2 = e[2]->prev(); 00107 } 00108 Hedge *en = e[0]; e[0]->reuse(v[0], v[2]); 00109 00110 if (v[2]->star_first() == e[2]->mate()) 00111 v[2]->set_star(en); 00112 if (v[1]->star_first() == e[1]->mate()) 00113 v[1]->set_star(n2); 00114 if (n == 4 && (v[3]->star_first() == e[3]->mate())) 00115 v[3]->set_star(n0); 00116 00117 f[0]->reuse(en, n2, p0); 00118 if (f[2] != NULL) 00119 f[1]->reuse(en->mate(), n0, p2); 00120 else 00121 del_face(f[1]); 00122 00123 for (k = 2; k < n; k++) 00124 if (f[k] != NULL) 00125 del_face(f[k]); 00126 for (k = 1; k < n; k++) 00127 del_edge(e[k]->edge()); 00128 del_vertex(w); 00129 return en; 00130 }


The documentation for this class was generated from the following files:
Generated on Mon Oct 11 19:32:40 2004 for A48 by doxygen 1.3.7