The Parametric Pseudo-Manifold (PPS) Library 1.0
ppsfrompnt::PPSfromPNT Class Reference

This class represents a Parametric Pseudo-Surface that approximates a PN triangle surface. More...

#include <ppsfrompnt.h>

Inheritance diagram for ppsfrompnt::PPSfromPNT:
Collaboration diagram for ppsfrompnt::PPSfromPNT:

List of all members.

Public Types

typedef dcel::Surface
< VertexAttribute,
FaceAttribute, int,
HalfedgeAttribute
Surface
 Defines Surface as an alias for dcel::Surface< VertexAttribute , FaceAttribute , int , HalfedgeAttribute >

Public Member Functions

 PPSfromPNT (Surface *mesh)
 Creates an instance of this PPSfromPNT class.
 ~PPSfromPNT ()
 Destroys an instance of this class.
void eval_surface (Face *face, double u, double v, double w, double &x, double &y, double &z) const
 Computes a point on the PN triangle patch associated with a given face of the PPS underlying triangle mesh.
bool mesh_has_boundary () const
 Determines if the underlying mesh of this PPS has a non-empty boundary.
bool mesh_is_simplicial () const
 Determines if the underlying mesh of this PPS is a simplicial complex.
unsigned int get_id (Halfedge *h) const
 Returns the identifier of a given half-edge.
Vertexget_org (Halfedge *h) const
 Returns the origin vertex of a given half-edge of this PPS underlying mesh.
Vertexget_dst (Halfedge *h) const
 Returns the destination vertex of a given half-edge of this PPS underlying mesh.
Edgeget_edge (Halfedge *h) const
 Returns the edge a given half-edge of this PPS underlying mesh belongs to.
Faceget_face (Halfedge *h) const
 Returns the face a given half-edge of this PPS underlying mesh belongs to.
Halfedgeget_prev (Halfedge *h) const
 Returns the half-edge that precedes a given half-edge of this PPS underlying mesh in the face cycle of half-edges that contains both half-edges.
Halfedgeget_next (Halfedge *h) const
 Returns the half-edge that succeeds a given half-edge of this PPS underlying mesh in the face cycle of half-edges that contains both half-edges.
Halfedgeget_mate (Halfedge *h) const
 Returns the mate of a given half-edge of this PPS underlying mesh.
Halfedgeget_halfedge (Face *face) const
 Returns the first half-edge of the cycle of half-edges of a given face of this PPS underlying mesh.
Halfedgeget_halfedge (Vertex *vertex) const
 Returns one half-edge with origin at a given vertex of this PPS underlying mesh. It is assumed that this method will always return the same half-edge (as many half-edges may share the same origin vertex).
unsigned get_degree (Vertex *vertex) const
 Returns the degree of a given vertex of this PPS underlying mesh. The degree of a vertex is the number of edges incident to the vertex.
Bezierget_shape_function (Vertex *vertex) const
 Returns the shape function associated with a given vertex of this PPS underlying mesh. The shape function is a rectangular Bézier patch.
void set_shape_function (Vertex *vertex, Bezier *patch)
 Assigns a shape function to a given vertex of this PPS underlying mesh.
VertexIterator vertices_begin () const
 Returns a vertex iterator set to the initial vertex of a vertex sequence of this PPS underlying mesh.
bool is_done (const VertexIterator &iterator) const
 Returns a logic value true if a given vertex iterator has reached the end of a vertex sequence of this PPS underlying mesh; otherwise, it returns the logic value false.
void move_forward (VertexIterator &iterator) const
 Makes the iterator point to the vertex succeeding its current vertex in a vertex sequence of this PPS underlying mesh.
Vertexget_vertex (const VertexIterator &iterator) const
 Returns the current vertex of a given vertex iterator for a vertex sequence of this PPS underlying mesh.
EdgeIterator edges_begin () const
 Returns an edge iterator set to the initial edge of an edge sequence of this PPS underlying mesh.
bool is_done (const EdgeIterator &iterator) const
 Returns A logic value true if a given edge iterator has reached the end of an edge sequence of this PPS underlying mesh; otherwise, it returns the logic value false.
void move_forward (EdgeIterator &iterator) const
 Makes the iterator point to the edge succeeding its current edge in an edge sequence of this PPS underlying mesh.
Edgeget_edge (const EdgeIterator &iterator) const
 Returns the current edge of a given edge iterator for an edge sequence of this PPS underlying mesh.
FaceIterator faces_begin () const
 Returns a face iterator set to the initial face of a face sequence of this PPS underlying mesh.
bool is_done (const FaceIterator &iterator) const
 Returns A logic value true if a given face iterator has reached the end of a face sequence of this PPS underlying mesh; otherwise, it returns the logic value false.
void move_forward (FaceIterator &iterator) const
 Makes the iterator point to the face succeeding its current face in a face sequence of this PPS underlying mesh.
Faceget_face (const FaceIterator &iterator) const
 Returns the current face of a given face iterator for a face sequence of this PPS underlying mesh.

Private Member Functions

void build_pnt_surface ()
 Computes a PN triangle surface patch for each face of a given triangle mesh, and then assigns the patch to the face.
void compute_vertex_normal_vector (Vertex *vertex, double &x, double &y, double &z)
 Computes a unit vector at a given surface mesh vertex.
void compute_face_normal_vector (Face *face, double &x, double &y, double &z)
 Computes the unit vector of a given surface mesh face.

Detailed Description

This class represents a Parametric Pseudo-Surface that approximates a PN triangle surface.

Definition at line 67 of file ppsfrompnt.h.


Constructor & Destructor Documentation

ppsfrompnt::PPSfromPNT::PPSfromPNT ( Surface mesh)

Creates an instance of this PPSfromPNT class.

Parameters:
meshA Pointer to a surface mesh represented by a DCEL.
meshA Pointer to a surface mesh represented by an DCEL.

Definition at line 58 of file ppsfrompnt.cpp.

References build_pnt_surface(), edges_begin(), get_edge(), is_done(), and move_forward().

                                        : PPS< Surface >( mesh )
  {
    //
    // Sets the owner of each half-edge attribute set.
    //
    for ( EdgeIterator eit = edges_begin() ; !is_done( eit ) ; 
          move_forward( eit ) ) {
      Edge* edge = get_edge( eit ) ;

      Halfedge* h1 = edge->get_first_halfedge() ;
      Halfedge* h2 = edge->get_second_halfedge() ;

      h1->get_attributes().set_owner( h1 ) ;
      h2->get_attributes().set_owner( h2 ) ; 
    }

    //
    // Create the PN triangle surface.
    //
    build_pnt_surface() ;
  }

Member Function Documentation

void ppsfrompnt::PPSfromPNT::compute_face_normal_vector ( Face face,
double &  x,
double &  y,
double &  z 
) [private]

Computes the unit vector of a given surface mesh face.

Parameters:
faceA pointer to a surface mesh face.
xA reference to the first component of the normal vector.
yA reference to the second component of the normal vector.
zA reference to the third component of the normal vector.

Definition at line 266 of file ppsfrompnt.cpp.

Referenced by compute_vertex_normal_vector().

  {
    Halfedge* h1 = face->get_halfedge() ;
    Halfedge* h2 = h1->get_next() ;
    Halfedge* h3 = h1->get_prev() ;
    
    double x1 = h1->get_origin()->x() ;
    double y1 = h1->get_origin()->y() ;
    double z1 = h1->get_origin()->z() ;

    double x2 = h2->get_origin()->x() ;
    double y2 = h2->get_origin()->y() ;
    double z2 = h2->get_origin()->z() ;
    
    double x3 = h3->get_origin()->x() ;
    double y3 = h3->get_origin()->y() ;
    double z3 = h3->get_origin()->z() ;
    
    x2 -= x1 ;
    y2 -= y1 ;
    z2 -= z1 ;
    
    x3 -= x1 ;
    y3 -= y1 ;
    z3 -= z1 ;
    
    x = y2 * z3 - z2 * y3 ;
    y = z2 * x3 - x2 * z3 ;
    z = x2 * y3 - y2 * x3 ;
    
    double length = sqrt( ( x * x ) + ( y * y ) + ( z * z ) ) ;
    
    x /= length ;
    y /= length ;
    z /= length ;  
    
    return ;
  }
void ppsfrompnt::PPSfromPNT::compute_vertex_normal_vector ( Vertex vertex,
double &  x,
double &  y,
double &  z 
) [private]

Computes a unit vector at a given surface mesh vertex.

Parameters:
vertexA pointer to a surface mesh vertex.
xA reference to the first component of the normal vector.
yA reference to the second component of the normal vector.
zA reference to the third component of the normal vector.

Definition at line 208 of file ppsfrompnt.cpp.

References compute_face_normal_vector().

Referenced by build_pnt_surface().

  {
    unsigned i = 0 ;
    
    x = 0 ;
    y = 0 ;
    z = 0 ;
    
    Halfedge* h1 = vertex->get_halfedge() ;
    Halfedge* h2 = h1 ;
    
    do {
      double xaux ;
      double yaux ;
      double zaux ;
      
      compute_face_normal_vector( h2->get_face() , xaux , yaux , zaux ) ;
      
      x += xaux ;
      y += yaux ;
      z += zaux ;
      
      ++i ;
      
      h2 = h2->get_prev()->get_mate() ;
    }
    while ( h2 != h1 ) ;
    
    x /= double( i ) ;
    y /= double( i ) ;
    z /= double( i ) ;
    
    double length = sqrt( ( x * x ) + ( y * y ) + ( z * z ) ) ;
    
    x /= length ;
    y /= length ;
    z /= length ;  
    
    return ;
  }
EdgeIterator ppsfrompnt::PPSfromPNT::edges_begin ( ) const [inline, virtual]

Returns an edge iterator set to the initial edge of an edge sequence of this PPS underlying mesh.

Returns:
An edge iterator set to the initial edge of an edge sequence of this PPS underlying mesh.

Implements pps::PPS< Mesh >.

Definition at line 521 of file ppsfrompnt.h.

References pps::PPS< Mesh >::get_mesh().

Referenced by PPSfromPNT().

    {
      return get_mesh()->edges_begin() ;
    }
void ppsfrompnt::PPSfromPNT::eval_surface ( Face face,
double  u,
double  v,
double  w,
double &  x,
double &  y,
double &  z 
) const [virtual]

Computes a point on the PN triangle patch associated with a given face of the PPS underlying triangle mesh.

Parameters:
facePointer to one face of the underlying mesh.
uFirst barycentric coordinate of a point on the face.
vSecond barycentric coordinate of a point on the face.
wThird barycentric coordinate of a point on the face.
xFirst Cartesian coordinate of a point on the PPS image.
ySecond Cartesian coordinate of a point on the PPS image.
zThird Cartesian coordinate of a point on the PPS image.

Implements pps::PPS< Mesh >.

Definition at line 96 of file ppsfrompnt.cpp.

References ppsfrompnt::PNTriangle::point().

  {
    //
    // Make sure the face has a PN triangle associated with it.
    //
    PNTriangle* patch = face->get_attributes().get_patch() ; 

    assert( patch != 0 ) ;

    //
    // Make sure the coordinates are non-negative and add up to 1.
    //
    assert( 
           ( u >= 0 ) && ( u <= 1 ) && ( v >= 0 ) && 
           ( v <= 1 ) && ( w >= 0 ) && ( w <= 1 ) &&
           ( fabs( 1 - ( u + v + w ) ) <= 1e-15 )
          ) ;
    //
    // Evaluate the patch.
    //
    patch->point( u , v , x , y , z ) ;
  }
FaceIterator ppsfrompnt::PPSfromPNT::faces_begin ( ) const [inline, virtual]

Returns a face iterator set to the initial face of a face sequence of this PPS underlying mesh.

Returns:
A face iterator set to the initial face of a face sequence of this PPS underlying mesh.

Implements pps::PPS< Mesh >.

Definition at line 586 of file ppsfrompnt.h.

References pps::PPS< Mesh >::get_mesh().

Referenced by build_pnt_surface().

    {
      return get_mesh()->faces_begin() ;
    }
unsigned ppsfrompnt::PPSfromPNT::get_degree ( Vertex vertex) const [inline, virtual]

Returns the degree of a given vertex of this PPS underlying mesh. The degree of a vertex is the number of edges incident to the vertex.

Parameters:
vertexPointer to a vertex of this PPS underlying mesh.
Returns:
The degree of the given vertex.

Implements pps::PPS< Mesh >.

Definition at line 408 of file ppsfrompnt.h.

    {
      return vertex->get_halfedge()->get_attributes().get_origin_vertex_degree() ;
    }
Vertex * ppsfrompnt::PPSfromPNT::get_dst ( Halfedge h) const [inline, virtual]

Returns the destination vertex of a given half-edge of this PPS underlying mesh.

Parameters:
hPointer to a half-edge of this PPS underlying mesh.
Returns:
A pointer to the destination vertex of a given half-edge.

Implements pps::PPS< Mesh >.

Definition at line 272 of file ppsfrompnt.h.

    {
      return h->get_next()->get_origin() ;
    }
Edge * ppsfrompnt::PPSfromPNT::get_edge ( Halfedge h) const [inline, virtual]

Returns the edge a given half-edge of this PPS underlying mesh belongs to.

Parameters:
hPointer to a half-edge of this PPS underlying mesh.
Returns:
A pointer to the edge a given half-edge belongs to.

Implements pps::PPS< Mesh >.

Definition at line 288 of file ppsfrompnt.h.

Referenced by PPSfromPNT().

    {
      return h->get_edge() ;
    }
Edge * ppsfrompnt::PPSfromPNT::get_edge ( const EdgeIterator iterator) const [inline, virtual]

Returns the current edge of a given edge iterator for an edge sequence of this PPS underlying mesh.

Parameters:
iteratorA reference to an edge iterator.
Returns:
A pointer to the current edge of a given edge iterator for an edge sequence of this PPS underlying mesh.

Implements pps::PPS< Mesh >.

Definition at line 571 of file ppsfrompnt.h.

    {
      return *iterator ;
    }
Face * ppsfrompnt::PPSfromPNT::get_face ( Halfedge h) const [inline, virtual]

Returns the face a given half-edge of this PPS underlying mesh belongs to.

Parameters:
hPointer to a half-edge of this PPS underlying mesh.
Returns:
A pointer to the face a given half-edge belongs to.

Implements pps::PPS< Mesh >.

Definition at line 304 of file ppsfrompnt.h.

Referenced by build_pnt_surface().

    {
      return h->get_face() ;
    }
Face * ppsfrompnt::PPSfromPNT::get_face ( const FaceIterator iterator) const [inline, virtual]

Returns the current face of a given face iterator for a face sequence of this PPS underlying mesh.

Parameters:
iteratorA reference to a face iterator.
Returns:
A pointer to the current face of a given face iterator for a face sequence of this PPS underlying mesh.

Implements pps::PPS< Mesh >.

Definition at line 636 of file ppsfrompnt.h.

    {
      return *iterator ;
    }
Halfedge * ppsfrompnt::PPSfromPNT::get_halfedge ( Vertex vertex) const [inline, virtual]

Returns one half-edge with origin at a given vertex of this PPS underlying mesh. It is assumed that this method will always return the same half-edge (as many half-edges may share the same origin vertex).

Parameters:
vertexPointer to a vertex of this PPS underlying mesh.
Returns:
A pointer to one half-edge with origin at a given vertex.

Implements pps::PPS< Mesh >.

Definition at line 391 of file ppsfrompnt.h.

    {
      return vertex->get_halfedge() ;
    }
Halfedge * ppsfrompnt::PPSfromPNT::get_halfedge ( Face face) const [inline, virtual]

Returns the first half-edge of the cycle of half-edges of a given face of this PPS underlying mesh.

Parameters:
facePointer to a face of this PPS underlying mesh.
Returns:
A pointer to the first half-edge of a given face.

Implements pps::PPS< Mesh >.

Definition at line 372 of file ppsfrompnt.h.

    {
      return face->get_halfedge() ;
    }
unsigned int ppsfrompnt::PPSfromPNT::get_id ( Halfedge h) const [inline, virtual]

Returns the identifier of a given half-edge.

Parameters:
hPointer to a half-edge.
Returns:
The identifier of the given half-edge.

Reimplemented from pps::PPS< Mesh >.

Definition at line 239 of file ppsfrompnt.h.

    {
      return h->get_attributes().get_pps_id() ;
    }
Halfedge * ppsfrompnt::PPSfromPNT::get_mate ( Halfedge h) const [inline, virtual]

Returns the mate of a given half-edge of this PPS underlying mesh.

Parameters:
hPointer to a half-edge of this PPS underlying mesh.
Returns:
A pointer to the mate half-edge of a given half-edge.

Implements pps::PPS< Mesh >.

Definition at line 356 of file ppsfrompnt.h.

    {
      return h->get_mate() ;
    }
Halfedge * ppsfrompnt::PPSfromPNT::get_next ( Halfedge h) const [inline, virtual]

Returns the half-edge that succeeds a given half-edge of this PPS underlying mesh in the face cycle of half-edges that contains both half-edges.

Parameters:
hPointer to a half-edge of this PPS underlying mesh.
Returns:
A pointer to the half-edge that succeeds a given half-edge in their common face half-edge cycle.

Implements pps::PPS< Mesh >.

Definition at line 340 of file ppsfrompnt.h.

    {
      return h->get_next() ;
    }
Vertex * ppsfrompnt::PPSfromPNT::get_org ( Halfedge h) const [inline, virtual]

Returns the origin vertex of a given half-edge of this PPS underlying mesh.

Parameters:
hPointer to a half-edge of this PPS underlying mesh.
Returns:
A pointer to the origin vertex of a given half-edge.

Implements pps::PPS< Mesh >.

Definition at line 255 of file ppsfrompnt.h.

    {
      return h->get_origin() ;
    }
Halfedge * ppsfrompnt::PPSfromPNT::get_prev ( Halfedge h) const [inline, virtual]

Returns the half-edge that precedes a given half-edge of this PPS underlying mesh in the face cycle of half-edges that contains both half-edges.

Parameters:
hPointer to a half-edge of this PPS underlying mesh.
Returns:
A pointer to the half-edge that precedes a given half-edge in their common face half-edge cycle.

Implements pps::PPS< Mesh >.

Definition at line 322 of file ppsfrompnt.h.

    {
      return h->get_prev() ;
    }
Bezier * ppsfrompnt::PPSfromPNT::get_shape_function ( Vertex vertex) const [inline, virtual]

Returns the shape function associated with a given vertex of this PPS underlying mesh. The shape function is a rectangular Bézier patch.

Parameters:
vertexPointer to a vertex of this PPS underlying mesh.
Returns:
The shape function associated with the given vertex.

Implements pps::PPS< Mesh >.

Definition at line 425 of file ppsfrompnt.h.

    {
      return vertex->get_attributes().get_patch() ;
    }
Vertex * ppsfrompnt::PPSfromPNT::get_vertex ( const VertexIterator iterator) const [inline, virtual]

Returns the current vertex of a given vertex iterator for a vertex sequence of this PPS underlying mesh.

Parameters:
iteratorA reference to a vertex iterator.
Returns:
A pointer to the current vertex of a given vertex iterator for a vertex sequence of this PPS underlying mesh.

Implements pps::PPS< Mesh >.

Definition at line 506 of file ppsfrompnt.h.

    {
      return *iterator ;
    }
bool ppsfrompnt::PPSfromPNT::is_done ( const VertexIterator iterator) const [inline, virtual]

Returns a logic value true if a given vertex iterator has reached the end of a vertex sequence of this PPS underlying mesh; otherwise, it returns the logic value false.

Parameters:
iteratorA vertex iterator.
Returns:
A logic value true if a given vertex iterator has reached the end of a vertex sequence of this PPS underlying mesh; otherwise, it returns the logic value false.

Implements pps::PPS< Mesh >.

Definition at line 474 of file ppsfrompnt.h.

References pps::PPS< Mesh >::get_mesh().

Referenced by build_pnt_surface(), and PPSfromPNT().

    {
      return iterator == get_mesh()->vertices_end() ;
    }
bool ppsfrompnt::PPSfromPNT::is_done ( const EdgeIterator iterator) const [inline, virtual]

Returns A logic value true if a given edge iterator has reached the end of an edge sequence of this PPS underlying mesh; otherwise, it returns the logic value false.

Parameters:
iteratorAn edge iterator.
Returns:
A logic value true if a given edge iterator has reached the end of an edge sequence of this PPS underlying mesh; otherwise, it returns the logic value false.

Implements pps::PPS< Mesh >.

Definition at line 540 of file ppsfrompnt.h.

References pps::PPS< Mesh >::get_mesh().

    {
      return iterator == get_mesh()->edges_end() ;
    }
bool ppsfrompnt::PPSfromPNT::is_done ( const FaceIterator iterator) const [inline, virtual]

Returns A logic value true if a given face iterator has reached the end of a face sequence of this PPS underlying mesh; otherwise, it returns the logic value false.

Parameters:
iteratorA face iterator.
Returns:
A logic value true if a given face iterator has reached the end of a face sequence of this PPS underlying mesh; otherwise, it returns the logic value false.

Implements pps::PPS< Mesh >.

Definition at line 605 of file ppsfrompnt.h.

References pps::PPS< Mesh >::get_mesh().

    {
      return iterator == get_mesh()->faces_end() ;
    }
bool ppsfrompnt::PPSfromPNT::mesh_has_boundary ( ) const [inline, virtual]

Determines if the underlying mesh of this PPS has a non-empty boundary.

Returns:
The logic value true if the mesh had a non-empty boundary and the logic value false otherwise.

Implements pps::PPS< Mesh >.

Definition at line 209 of file ppsfrompnt.h.

    {
      return false ;
    }
bool ppsfrompnt::PPSfromPNT::mesh_is_simplicial ( ) const [inline, virtual]

Determines if the underlying mesh of this PPS is a simplicial complex.

Returns:
The logic value true if the mesh is a simplicial complex and the logic value false otherwise.

Implements pps::PPS< Mesh >.

Definition at line 224 of file ppsfrompnt.h.

    {
      return true ;
    }
void ppsfrompnt::PPSfromPNT::move_forward ( FaceIterator iterator) const [inline, virtual]

Makes the iterator point to the face succeeding its current face in a face sequence of this PPS underlying mesh.

Parameters:
iteratorA reference to a face iterator.

Implements pps::PPS< Mesh >.

Definition at line 619 of file ppsfrompnt.h.

    {
      ++iterator ;
    }
void ppsfrompnt::PPSfromPNT::move_forward ( VertexIterator iterator) const [inline, virtual]

Makes the iterator point to the vertex succeeding its current vertex in a vertex sequence of this PPS underlying mesh.

Parameters:
iteratorA reference to a vertex iterator.

Implements pps::PPS< Mesh >.

Definition at line 489 of file ppsfrompnt.h.

Referenced by build_pnt_surface(), and PPSfromPNT().

    {
      ++iterator ;
    }
void ppsfrompnt::PPSfromPNT::move_forward ( EdgeIterator iterator) const [inline, virtual]

Makes the iterator point to the edge succeeding its current edge in an edge sequence of this PPS underlying mesh.

Parameters:
iteratorA reference to an edge iterator.

Implements pps::PPS< Mesh >.

Definition at line 554 of file ppsfrompnt.h.

    {
      ++iterator ;
    }
void ppsfrompnt::PPSfromPNT::set_shape_function ( Vertex vertex,
Bezier patch 
) [inline, virtual]

Assigns a shape function to a given vertex of this PPS underlying mesh.

Parameters:
vertexPointer to a vertex of this PPS underlying mesh.
patchPointer to a shape function.

Implements pps::PPS< Mesh >.

Definition at line 440 of file ppsfrompnt.h.

    {
      vertex->get_attributes().set_patch( patch ) ;
    }
VertexIterator ppsfrompnt::PPSfromPNT::vertices_begin ( ) const [inline, virtual]

Returns a vertex iterator set to the initial vertex of a vertex sequence of this PPS underlying mesh.

Returns:
A vertex iterator set to the initial vertex of a vertex sequence of this PPS underlying mesh.

Implements pps::PPS< Mesh >.

Definition at line 455 of file ppsfrompnt.h.

References pps::PPS< Mesh >::get_mesh().

    {
      return get_mesh()->vertices_begin() ;
    }

The documentation for this class was generated from the following files: