PLearn 0.1
|
#include <SurfaceMesh.h>
Public Member Functions | |
SurfaceMesh () | |
Default constructor. | |
SurfaceMesh (Graph g) | |
Constructor from a graph. | |
SurfaceMesh (const SurfaceMesh &m) | |
Copy constructor. | |
virtual | ~SurfaceMesh () |
Virtual destructor. | |
virtual string | classname () const |
virtual OptionList & | getOptionList () const |
virtual OptionMap & | getOptionMap () const |
virtual RemoteMethodMap & | getRemoteMethodMap () const |
virtual SurfaceMesh * | deepCopy (CopiesMap &copies) const |
virtual void | build () |
Post-constructor. | |
virtual void | makeDeepCopyFromShallowCopy (CopiesMap &copies) |
Transforms a shallow copy into a deep copy. | |
virtual bool | readVRMLFile (string filename, Mat vtx_features=Mat()) |
virtual bool | readVRMLIndexedFaceSet (string filename, Mat vtx_features=Mat()) |
virtual bool | readVRMLIndexedLineSet (string filename, Mat vtx_features=Mat()) |
virtual void | writeVRMLFile (string filename) |
virtual void | writeVRMLIndexedFaceSet (string filename) |
virtual void | writeVRMLIndexedLineSet (string filename) |
virtual void | writeVRMLBoundaries (string filename) |
virtual int | createSurfaceMesh () |
virtual vertex_descriptor | addVertex (MVertex mv) |
virtual vertex_descriptor | addVertex (Vec coord, Vec features=Vec()) |
virtual vertex_descriptor | addVertex (real x, real y, real z) |
virtual void | delVertex (vertex_descriptor vtx) |
virtual MVertex | getVertex (vertex_descriptor vtx) |
virtual void | setVertex (vertex_descriptor vtx, const MVertex &mv) |
virtual Mat | getVertexCoords () |
virtual Mat | getVertexCoordsAndFeatures () |
virtual void | setVertexCoords (const Mat &coords) |
virtual void | setVertexFeatures (const Mat &features) |
virtual void | setVertexCoordsAndFeatures (const Mat &coords, const Mat &features) |
virtual int | numVertices () |
virtual TVec< vertex_descriptor > | getVertexDescriptors () |
virtual Mat | getVertexNorms () |
virtual void | setVertexNorms (const Mat &coords) |
virtual edge_descriptor | addEdge (vertex_descriptor first, vertex_descriptor second, MEdge me=new MeshEdge()) |
virtual void | delEdge (edge_descriptor ed) |
virtual MEdge | getEdge (edge_descriptor ed) |
virtual void | setEdge (edge_descriptor ed, const MEdge &me) |
virtual int | numEdges () |
virtual int | addFace (MFace mf) |
virtual int | addFace (TVec< vertex_descriptor > pts) |
virtual int | addFace (vertex_descriptor first, vertex_descriptor second, vertex_descriptor third) |
virtual void | delFace (int face_index) |
virtual MFace | getFace (int face_index) |
virtual void | setFace (int face_index, const MFace &mf) |
virtual int | numFaces () |
virtual TVec< set< int > > | cacheNeighborFaces () |
virtual int | buildEdges () |
virtual int | buildBoundaries () |
virtual real | getResolution () |
virtual void | setResolution (real resolution) |
virtual real | computeResolution () |
virtual void | findNormals () |
virtual real | averageSphereRadius () |
virtual int | delOrphanVertices () |
virtual Mat | boundingBox () |
Static Public Member Functions | |
static string | _classname_ () |
static OptionList & | _getOptionList_ () |
static RemoteMethodMap & | _getRemoteMethodMap_ () |
static Object * | _new_instance_for_typemap_ () |
static bool | _isa_ (const Object *o) |
static void | _static_initialize_ () |
static const PPath & | declaringFile () |
Public Attributes | |
Graph | p_mesh |
string | mesh_type |
int | verbosity |
Level of verbosity. | |
Static Public Attributes | |
static StaticInitializer | _static_initializer_ |
Protected Member Functions | |
virtual bool | readVRMLCoordinate3_ (ifstream &in, TVec< vertex_descriptor > &vertices, Mat vtx_features=Mat()) |
virtual bool | readVRMLIndexedFaceSet_ (ifstream &in, TVec< vertex_descriptor > &vertices) |
virtual bool | readVRMLIndexedLineSet_ (ifstream &in, TVec< vertex_descriptor > &vertices) |
virtual void | writeVRMLCoordinate3_ (ofstream &out, map< vertex_descriptor, int > &pts_indices) |
virtual void | writeVRMLIndexedFaceSet_ (ofstream &out, map< vertex_descriptor, int > &pts_indices) |
virtual void | writeVRMLIndexedLineSet_ (ofstream &out, map< vertex_descriptor, int > &pts_indices) |
Static Protected Member Functions | |
static void | declareOptions (OptionList &ol) |
Declares this class' options. | |
Protected Attributes | |
MGraph | mg |
bool | computed_vtx_norm |
Private Types | |
typedef Object | inherited |
Private Member Functions | |
void | build_ () |
This does the actual building. |
Definition at line 60 of file SurfaceMesh.h.
typedef Object PLearn::SurfaceMesh::inherited [private] |
Reimplemented from PLearn::Object.
Definition at line 65 of file SurfaceMesh.h.
PLearn::SurfaceMesh::SurfaceMesh | ( | ) |
Default constructor.
Definition at line 50 of file SurfaceMesh.cc.
PLearn::SurfaceMesh::SurfaceMesh | ( | Graph | g | ) |
PLearn::SurfaceMesh::SurfaceMesh | ( | const SurfaceMesh & | m | ) |
PLearn::SurfaceMesh::~SurfaceMesh | ( | ) | [virtual] |
string PLearn::SurfaceMesh::_classname_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
OptionList & PLearn::SurfaceMesh::_getOptionList_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
RemoteMethodMap & PLearn::SurfaceMesh::_getRemoteMethodMap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
Object * PLearn::SurfaceMesh::_new_instance_for_typemap_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
StaticInitializer SurfaceMesh::_static_initializer_ & PLearn::SurfaceMesh::_static_initialize_ | ( | ) | [static] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
edge_descriptor PLearn::SurfaceMesh::addEdge | ( | vertex_descriptor | first, |
vertex_descriptor | second, | ||
MEdge | me = new MeshEdge() |
||
) | [virtual] |
Definition at line 423 of file SurfaceMesh.cc.
References p_mesh.
Referenced by readVRMLIndexedLineSet_().
{ edge_descriptor ed = add_edge( first, second, me, *p_mesh ).first; return ed; }
Definition at line 453 of file SurfaceMesh.cc.
References mg.
Referenced by addFace(), and readVRMLIndexedFaceSet_().
int PLearn::SurfaceMesh::addFace | ( | TVec< vertex_descriptor > | pts | ) | [virtual] |
Definition at line 459 of file SurfaceMesh.cc.
References addFace(), PLearn::TVec< T >::length(), and PLERROR.
{ if( pts.length() != 3 ) PLERROR("Error in addFace(TVec<...> pts): you can only create a triangle face."); MFace mf = new MeshFace(); mf->pts << pts; int face_index = addFace( mf ); return face_index; }
int PLearn::SurfaceMesh::addFace | ( | vertex_descriptor | first, |
vertex_descriptor | second, | ||
vertex_descriptor | third | ||
) | [virtual] |
Definition at line 470 of file SurfaceMesh.cc.
References addFace().
{ TVec<vertex_descriptor> pts( 3 ); pts[0] = first; pts[1] = second; pts[2] = third; int face_index = addFace( pts ); return face_index; }
vertex_descriptor PLearn::SurfaceMesh::addVertex | ( | Vec | coord, |
Vec | features = Vec() |
||
) | [virtual] |
Definition at line 199 of file SurfaceMesh.cc.
References addVertex(), PLearn::TVec< T >::length(), PLearn::mv(), PLERROR, and PLearn::TVec< T >::size().
{ MVertex mv = new MeshVertex(); if( coord.length() != 3 ) PLERROR("Error in addVertex(Vec coord): coord size is supposed to be 3 (or not to be!)"); mv->coord << coord; mv->features.resize( features.size() ); mv->features << features; vertex_descriptor vtx = addVertex( mv ); return vtx; }
vertex_descriptor PLearn::SurfaceMesh::addVertex | ( | real | x, |
real | y, | ||
real | z | ||
) | [virtual] |
Definition at line 215 of file SurfaceMesh.cc.
References addVertex(), and x.
{ Vec coord( 3 ); coord[0] = x; coord[1] = y; coord[2] = z; vertex_descriptor vtx = addVertex( coord ); return vtx; }
vertex_descriptor PLearn::SurfaceMesh::addVertex | ( | MVertex | mv | ) | [virtual] |
Definition at line 193 of file SurfaceMesh.cc.
References p_mesh.
Referenced by addVertex(), and readVRMLCoordinate3_().
{ vertex_descriptor vtx = add_vertex( mv, *p_mesh ); return vtx; }
real PLearn::SurfaceMesh::averageSphereRadius | ( | ) | [virtual] |
Definition at line 1398 of file SurfaceMesh.cc.
References c, PLearn::norm(), p_mesh, and vertex_ppt.
Referenced by createSurfaceMesh().
{ Vec c( 3 ); vertex_iterator vi, vi_end; for( tie(vi,vi_end)=vertices(*p_mesh) ; vi!=vi_end ; vi++ ) { c += get( vertex_ppt, *p_mesh, *vi )->coord; } c *= real(1.0)/num_vertices( *p_mesh ); real r = 0; for( tie(vi,vi_end)=vertices(*p_mesh) ; vi!=vi_end ; vi++ ) { r += norm( c - get( vertex_ppt, *p_mesh, *vi )->coord, 2 ); } r *= real(1.0)/num_vertices( *p_mesh ); return r; }
Mat PLearn::SurfaceMesh::boundingBox | ( | ) | [virtual] |
Definition at line 1420 of file SurfaceMesh.cc.
References PLearn::columnMax(), PLearn::columnMin(), getVertexCoords(), and PLearn::max().
{ Mat box( 2, 3 ); Vec mins(3); Vec max(3); Mat coords = getVertexCoords(); columnMin( coords, mins ); columnMax( coords, max ); box(0) << mins; box(1) << max; return( box ); }
void PLearn::SurfaceMesh::build | ( | ) | [virtual] |
Post-constructor.
The normal implementation should call simply inherited::build(), then this class's build_(). This method should be callable again at later times, after modifying some option fields to change the "architecture" of the object.
Reimplemented from PLearn::Object.
Definition at line 126 of file SurfaceMesh.cc.
References PLearn::Object::build(), and build_().
{ inherited::build(); build_(); }
void PLearn::SurfaceMesh::build_ | ( | ) | [private] |
This does the actual building.
Reimplemented from PLearn::Object.
Definition at line 110 of file SurfaceMesh.cc.
References PLearn::lowerstring(), mesh_type, PLERROR, PLearn::search_replace(), and PLearn::space_to_underscore().
Referenced by build().
{ // build_vertex_normals(); string mt = lowerstring( mesh_type ); mt = space_to_underscore( mt ); search_replace( mt, "_", "" ); if( mt == "faceset" ) mesh_type = "FaceSet"; else if( mt == "lineset" ) mesh_type = "LineSet"; else if( mt == "pointset" ) mesh_type = "PointSet"; else PLERROR( "mesh_type '%s' not supported", mesh_type.c_str() ); }
int PLearn::SurfaceMesh::buildBoundaries | ( | ) | [virtual] |
Definition at line 608 of file SurfaceMesh.cc.
References edge_ppt, PLearn::endl(), p_mesh, and vertex_ppt.
Referenced by createSurfaceMesh().
{ int nerrors = 0; property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh ); property_map< graph, edge_ppt_t >::type edge_ppt_map = get( edge_ppt, *p_mesh ); /* we mark as "boundary" vertices all vertices belonging to at least a "boundary" edge */ edge_iterator ei, ei_end; for( tie(ei,ei_end)=edges( *p_mesh ) ; ei != ei_end ; ei++ ) { if( edge_ppt_map[ *ei ]->bf == 1 ) { vertex_ppt_map[ source( *ei, *p_mesh ) ]->bf = 1; } } /* we check that a "boundary" vertex belongs to, at least, two boundary edges (otherwise, it wouldn't make any sense) */ vertex_iterator vi, vi_end; for( tie(vi,vi_end)=vertices( *p_mesh ) ; vi != vi_end ; vi++ ) { if( vertex_ppt_map[ *vi ]->bf ) { int bound_count = 0; adjacency_iterator ai, ai_end; for( tie(ai,ai_end)=adjacent_vertices( *vi, *p_mesh ) ; ai!=ai_end ; ai++ ) { if( vertex_ppt_map[ *ai ]->bf ) { bound_count++; } } if( bound_count < 2 ) { cerr << "Wrong number of points on adjacent boundary to point " << *vi << endl; nerrors++; } } } return nerrors; }
int PLearn::SurfaceMesh::buildEdges | ( | ) | [virtual] |
Definition at line 528 of file SurfaceMesh.cc.
References PLearn::add_edge_ifnew(), PLearn::dist(), edge_ppt, PLearn::endl(), i, j, me, mg, p_mesh, PLearn::TVec< T >::size(), and vertex_ppt.
Referenced by createSurfaceMesh().
{ TVec<MFace> faces = mg->faces; property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh ); property_map< graph, edge_ppt_t >::type edge_ppt_map = get( edge_ppt, *p_mesh ); int n_faces = faces.size(); int nerrors = 0; for( int i=0 ; i<n_faces ; i++ ) { MFace mf = faces[i]; TVec< vertex_descriptor > pts = mf->pts; /* we build 3 edges from each face */ for( int j=0 ; j<3 ; j++ ) { MEdge me = new MeshEdge(); me->face1 = i; me->bf = 1; int jj = (j+1)%3; // jj == j+1 if j==0 or 1, jj==0 if j=3 me->length = dist( vertex_ppt_map[ pts[j] ]->coord, vertex_ppt_map[ pts[jj] ]->coord, 2 ); edge_descriptor ed; bool added; /* ed is the descriptor of the edge linking pts[j] and pts[jj], added is "true" if it didn't exist and was just created. In this last case, the "MeshEdge" property was added too, i.e. face1 is set to current face, and the edge is considered as a "boundary" (bf=1) */ tie( ed, added ) = add_edge_ifnew( pts[j], pts[jj], me, *p_mesh ); mf->edges[j] = ed; /* if the edge was not added (it already existed)... */ if( !added ) { /* either there is no "face2" yet : mf is the other face, which is adjacent to "face1", and current edge isn't a border any more */ if( edge_ppt_map[ed]->face2<0 ) { edge_ppt_map[ed]->face2 = i; int k = edge_ppt_map[ed]->face1; mf->adj_faces[j] = k; MFace neighbor_f = faces[k]; for( int l=0 ; l<3 ; l++ ) { if( neighbor_f->edges[l] == ed ) { neighbor_f->adj_faces[l] = i; } } edge_ppt_map[ed]->bf = 0; } else { vertex_descriptor src = source( ed, *p_mesh ); vertex_descriptor tgt = target( ed, *p_mesh ); cerr << "Edge between " << src << " and " << tgt << " has more than 2 faces." << endl; nerrors++; } } } } return( nerrors ); }
Definition at line 505 of file SurfaceMesh.cc.
References getEdge(), i, PLearn::TVec< T >::insert(), me, numVertices(), and p_mesh.
{ int n_pts = numVertices(); TVec< set<int> > face_cache( n_pts ); vertex_iterator vi, vi_end; tie(vi, vi_end) = vertices( *p_mesh ); for( int i=0 ; vi != vi_end ; i++, vi++ ) { out_edge_iterator oei, oei_end; tie( oei, oei_end ) = out_edges( *vi, *p_mesh ); for( ; oei != oei_end ; oei++ ) { MEdge me = getEdge( *oei ); face_cache[i].insert( me->face1 ); face_cache[i].insert( me->face2 ); } face_cache[i].erase( -1 ); } return( face_cache ); }
string PLearn::SurfaceMesh::classname | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
real PLearn::SurfaceMesh::computeResolution | ( | ) | [virtual] |
Definition at line 666 of file SurfaceMesh.cc.
References edge_ppt, i, PLearn::TVec< T >::length(), PLearn::median(), and p_mesh.
Referenced by createSurfaceMesh().
{ /* we compute the mesh resolution : it is the median of the vertices' length */ int n_edges = num_edges( *p_mesh ); property_map< graph, edge_ppt_t >::type edge_ppt_map = get( edge_ppt, *p_mesh ); Vec lengths( n_edges ); edge_iterator ei, ei_end; tie(ei,ei_end)=edges( *p_mesh ); for( int i=0 ; i<n_edges ; i++ ) { lengths[i] = edge_ppt_map[*ei]->length; ei++; } real resolution = median( lengths ); return( resolution ); }
int PLearn::SurfaceMesh::createSurfaceMesh | ( | ) | [virtual] |
Definition at line 1278 of file SurfaceMesh.cc.
References averageSphereRadius(), buildBoundaries(), buildEdges(), computeResolution(), findNormals(), and mg.
Referenced by readVRMLIndexedFaceSet_().
{ int nerrors = 0; /* initialisation from the faces */ /* create edges and setting their length and boundary flag */ nerrors += buildEdges(); /* set boundary flags to appropriate vertices */ nerrors += buildBoundaries(); /* compute and set mesh resolution */ mg->resolution = computeResolution(); findNormals(); mg->size = averageSphereRadius(); return nerrors; }
void PLearn::SurfaceMesh::declareOptions | ( | OptionList & | ol | ) | [static, protected] |
Declares this class' options.
Reimplemented from PLearn::Object.
Definition at line 89 of file SurfaceMesh.cc.
References PLearn::OptionBase::buildoption, PLearn::declareOption(), PLearn::Object::declareOptions(), PLearn::OptionBase::learntoption, mesh_type, and verbosity.
{ declareOption(ol, "mesh_type", &SurfaceMesh::mesh_type, OptionBase::learntoption, "Type of mesh, describing the kind of information that is available.\n" "Supported options are:\n" " - 'FaceSet': Vertices, Faces, and Edges;\n" " - 'LineSet': Vertices and Edges;\n" " - 'PointSet' (default): Vertices.\n" ); declareOption(ol, "verbosity", &SurfaceMesh::verbosity, OptionBase::buildoption, "Level of verbosity. If 0 should not write anything on perr.\n" "If >0 may write some info on the steps performed" " along the way.\n" "The level of details written should depend on this value.\n" ); inherited::declareOptions(ol); }
static const PPath& PLearn::SurfaceMesh::declaringFile | ( | ) | [inline, static] |
Reimplemented from PLearn::Object.
Definition at line 121 of file SurfaceMesh.h.
: virtual bool readVRMLCoordinate3_( ifstream& in,
SurfaceMesh * PLearn::SurfaceMesh::deepCopy | ( | CopiesMap & | copies | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
void PLearn::SurfaceMesh::delEdge | ( | edge_descriptor | ed | ) | [virtual] |
Definition at line 431 of file SurfaceMesh.cc.
References PLERROR.
{ PLERROR( "SurfaceMesh::delEdge() not implemented yet." ); }
void PLearn::SurfaceMesh::delFace | ( | int | face_index | ) | [virtual] |
Definition at line 483 of file SurfaceMesh.cc.
References PLERROR.
{ PLERROR( "SurfaceMesh::delFace() not implemented yet." ); }
int PLearn::SurfaceMesh::delOrphanVertices | ( | ) | [virtual] |
Definition at line 1301 of file SurfaceMesh.cc.
References delVertex(), and p_mesh.
{ int number_deleted = 0; vertex_iterator vi, vi_end, next; tie( vi, vi_end ) = vertices( *p_mesh ); for (next = vi; vi != vi_end; vi = next) { ++next; if( out_degree( *vi, *p_mesh ) == 0 ) { number_deleted++; delVertex( *vi ); } } return number_deleted; }
void PLearn::SurfaceMesh::delVertex | ( | vertex_descriptor | vtx | ) | [virtual] |
Definition at line 225 of file SurfaceMesh.cc.
References p_mesh.
Referenced by delOrphanVertices().
{ remove_vertex( vtx, *p_mesh ); }
void PLearn::SurfaceMesh::findNormals | ( | ) | [virtual] |
Definition at line 1332 of file SurfaceMesh.cc.
References PLearn::calcNormal(), computed_vtx_norm, PLearn::cross(), PLearn::dot(), edge_ppt, graph_ppt, PLearn::mv(), n, p_mesh, and vertex_ppt.
Referenced by createSurfaceMesh().
{ // calculate initial normals vertex_iterator vi, vi_end; for( tie( vi, vi_end )=vertices( *p_mesh ) ; vi != vi_end ; vi++ ) { Vec v(3); real fit_error = calcNormal( *p_mesh, *vi, v ); MVertex mv = get( vertex_ppt, *p_mesh, *vi ); mv->error = fit_error; /* orient the normal based on the orientation of the faces adjacent to the point */ /* find adjacent faces */ set<int> adj_faces; out_edge_iterator ei, ei_end; for( tie(ei,ei_end)=out_edges(*vi, *p_mesh) ; ei!=ei_end ; ei++ ) { adj_faces.insert( get(edge_ppt,*p_mesh,*ei)->face1 ); adj_faces.insert( get(edge_ppt,*p_mesh,*ei)->face2 ); } adj_faces.erase( -1 ); // we don't want to keep "dummy" faces int n_opposite = 0; int n_same = 0; /* determine number of faces with similar normal and number of faces with opposite pointing normal */ for( set<int>::iterator it=adj_faces.begin() ; it!=adj_faces.end() ; it++ ) { MFace mf = get_property( *p_mesh, graph_ppt )->faces[ *it ]; Vec p0 = get( vertex_ppt, *p_mesh, mf->pts[0] )->coord; Vec p1 = get( vertex_ppt, *p_mesh, mf->pts[1] )->coord; Vec p2 = get( vertex_ppt, *p_mesh, mf->pts[2] )->coord; Vec n( 3 ); n = cross( p2-p1, p0-p1 ); if( dot(n,v) > 0 ) { n_same++ ;} else { n_opposite++ ;} } /* if the number opposite is greater than the number the same, then flip the normal */ mv->norm.resize(3); if( n_same >= n_opposite ) { mv->norm << v ; } else { mv->norm << -v ; } /* write vertex property value in the mesh */ put( vertex_ppt, *p_mesh, *vi, mv ); } computed_vtx_norm = true; }
MEdge PLearn::SurfaceMesh::getEdge | ( | edge_descriptor | ed | ) | [virtual] |
Definition at line 436 of file SurfaceMesh.cc.
References edge_ppt, me, and p_mesh.
Referenced by cacheNeighborFaces(), writeVRMLBoundaries(), and writeVRMLIndexedFaceSet_().
Definition at line 488 of file SurfaceMesh.cc.
References mg.
Referenced by makeDeepCopyFromShallowCopy().
OptionList & PLearn::SurfaceMesh::getOptionList | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
OptionMap & PLearn::SurfaceMesh::getOptionMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
RemoteMethodMap & PLearn::SurfaceMesh::getRemoteMethodMap | ( | ) | const [virtual] |
Reimplemented from PLearn::Object.
Definition at line 64 of file SurfaceMesh.cc.
real PLearn::SurfaceMesh::getResolution | ( | ) | [virtual] |
MVertex PLearn::SurfaceMesh::getVertex | ( | vertex_descriptor | vtx | ) | [virtual] |
Definition at line 230 of file SurfaceMesh.cc.
References PLearn::mv(), p_mesh, and vertex_ppt.
{ MVertex mv = get( vertex_ppt, *p_mesh, vtx ); return mv; }
Mat PLearn::SurfaceMesh::getVertexCoords | ( | ) | [virtual] |
Definition at line 242 of file SurfaceMesh.cc.
References i, p_mesh, and vertex_ppt.
Referenced by boundingBox().
{ int n_pts = num_vertices( *p_mesh ); Mat coords( n_pts, 3 ); property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh ); vertex_iterator vi, vi_end; tie( vi, vi_end ) = vertices( *p_mesh ); for( int i=0 ; i<n_pts ; i++, vi++ ) { coords(i) << vertex_ppt_map[ *vi ]->coord; } return coords; }
Mat PLearn::SurfaceMesh::getVertexCoordsAndFeatures | ( | ) | [virtual] |
Definition at line 259 of file SurfaceMesh.cc.
References i, PLearn::mv(), p_mesh, PLearn::TMat< T >::resize(), and vertex_ppt.
{ int n_pts = num_vertices( *p_mesh ); Mat coords_and_features; property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh ); vertex_iterator vi, vi_end; tie( vi, vi_end ) = vertices( *p_mesh ); int feat_size = vertex_ppt_map[ *vi ]->features.size(); coords_and_features.resize( n_pts, 3+feat_size ); for( int i=0 ; i<n_pts ; i++, vi++ ) { MVertex mv = vertex_ppt_map[ *vi ]; coords_and_features(i).subVec(0,3) << mv->coord; coords_and_features(i).subVec(3,feat_size) << mv->features; } return coords_and_features; }
TVec< vertex_descriptor > PLearn::SurfaceMesh::getVertexDescriptors | ( | ) | [virtual] |
Definition at line 362 of file SurfaceMesh.cc.
References i, numVertices(), and p_mesh.
{ int n_pts = numVertices(); TVec<vertex_descriptor> result( n_pts ); vertex_iterator vi, vi_end; tie( vi, vi_end ) = vertices( *p_mesh ); for( int i=0 ; i<n_pts ; i++, vi++ ) { result[i] = *vi; } return( result ); }
Mat PLearn::SurfaceMesh::getVertexNorms | ( | ) | [virtual] |
Definition at line 377 of file SurfaceMesh.cc.
References computed_vtx_norm, i, p_mesh, PLWARNING, and vertex_ppt.
{ if( !computed_vtx_norm ) { PLWARNING( "Trying to get vertex normals, but they\'re not initialized" ); } int n_pts = num_vertices( *p_mesh ); Mat norms( n_pts, 3 ); property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh ); vertex_iterator vi, vi_end; tie( vi, vi_end ) = vertices( *p_mesh ); for( int i=0 ; i<n_pts ; i++, vi++ ) { norms(i) << vertex_ppt_map[ *vi ]->norm; } return norms; }
void PLearn::SurfaceMesh::makeDeepCopyFromShallowCopy | ( | CopiesMap & | copies | ) | [virtual] |
Transforms a shallow copy into a deep copy.
Reimplemented from PLearn::Object.
Definition at line 132 of file SurfaceMesh.cc.
References edge_ppt, getFace(), i, j, PLearn::Object::makeDeepCopyFromShallowCopy(), mg, numFaces(), p_mesh, and vertex_ppt.
{ inherited::makeDeepCopyFromShallowCopy(copies); Graph p_mesh2 = new Graph_( *p_mesh ); property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh2 ); map< vertex_descriptor, vertex_descriptor > vertex_corresp; vertex_iterator vi, vi_end; vertex_iterator vi2, vi2_end; tie( vi, vi_end ) = vertices( *p_mesh ); tie( vi2, vi2_end ) = vertices( *p_mesh2 ); for( ; vi != vi_end ; vi++, vi2++ ) { vertex_ppt_map[ *vi2 ] = vertex_ppt_map[*vi2]->deepCopy(copies); vertex_corresp[ *vi ] = *vi2; } property_map< graph, edge_ppt_t >::type edge_ppt_map = get( edge_ppt, *p_mesh2 ); edge_iterator ei2, ei2_end; for( tie(ei2,ei2_end) = edges( *p_mesh2 ) ; ei2 != ei2_end ; ei2++ ) { edge_ppt_map[ *ei2 ] = edge_ppt_map[*ei2]->deepCopy(copies); } mg->makeDeepCopyFromShallowCopy( copies ); int n_faces = numFaces(); for( int i=0 ; i<n_faces ; i++ ) { MFace face = getFace(i); for( int j=0 ; j<3 ; j++ ) { face->pts[j] = vertex_corresp[ face->pts[j] ]; } for( int j=0 ; j<3 ; j++ ) { int jj = (j+1)%3; // jj == j+1 if j==0 or 1, jj==0 if j=3 out_edge_iterator oei, oei_end; vertex_descriptor src = face->pts[j]; vertex_descriptor tgt = face->pts[jj]; for( tie(oei, oei_end)=out_edges(src, *p_mesh2) ; oei != oei_end ; oei++ ) { if( target( *oei, *p_mesh2 ) == tgt ) { face->edges[j] = *oei; } } } } p_mesh = p_mesh2; }
int PLearn::SurfaceMesh::numEdges | ( | ) | [virtual] |
int PLearn::SurfaceMesh::numFaces | ( | ) | [virtual] |
Definition at line 499 of file SurfaceMesh.cc.
References mg.
Referenced by makeDeepCopyFromShallowCopy().
{ return mg->faces.length(); }
int PLearn::SurfaceMesh::numVertices | ( | ) | [virtual] |
Definition at line 357 of file SurfaceMesh.cc.
References p_mesh.
Referenced by cacheNeighborFaces(), and getVertexDescriptors().
{ return( num_vertices(*p_mesh) ); }
bool PLearn::SurfaceMesh::readVRMLCoordinate3_ | ( | ifstream & | in, |
TVec< vertex_descriptor > & | vertices, | ||
Mat | vtx_features = Mat() |
||
) | [protected, virtual] |
Definition at line 700 of file SurfaceMesh.cc.
References addVertex(), PLearn::TVec< T >::append(), in, PLearn::remove_comments(), PLearn::removeblanks(), and PLearn::TMat< T >::size().
Referenced by readVRMLFile(), readVRMLIndexedFaceSet(), and readVRMLIndexedLineSet().
{ string buf; /* read from the file until "Coordinate3" is reached */ while( buf.compare( 0, 11, "Coordinate3" ) && in ) { in >> buf; } /* read characters until the open bracket */ getline( in, buf, '[' ); /* reading coordinates until close bracket */ getline( in, buf, ']' ); istringstream all_coords( buf ); /* read coordinates by comma-separated triplets */ while( all_coords ) { Vec coord( 3 ); string coords; getline( all_coords, coords ); coords = removeblanks( coords ); remove_comments( coords ); int vertex_index = 0; if( coords != "" ) { istringstream point_coords( coords ); if ( point_coords >> coord[0] >> coord[1] >> coord[2] ) { vertex_descriptor vtx; if( vtx_features.size() == 0 ) vtx = addVertex( coord ); else vtx = addVertex( coord, vtx_features(vertex_index) ); /* store the correspondence between order in VRML file and vertex descriptor */ vertices.append( vtx ); vertex_index++; } else { return false; } } } return true; }
Definition at line 1012 of file SurfaceMesh.cc.
References in, mesh_type, PLERROR, readVRMLCoordinate3_(), readVRMLIndexedFaceSet_(), and readVRMLIndexedLineSet_().
{ ifstream in( filename.c_str() ); if( !in ) PLERROR( "Cannot open file: %s.\n", filename.c_str() ); TVec<vertex_descriptor> vertices; if( !readVRMLCoordinate3_( in, vertices, vtx_features ) ) { PLERROR( "Parse error in %s: expecting a floating-point number.\n", filename.c_str() ); } ifstream in_( filename.c_str() ); if( !in_ ) PLERROR( "Cannot open file: %s.\n", filename.c_str() ); string buf; // check if a "IndexedFaceSet" node is present bool face_set = false; bool line_set = false; while( in_ >> buf ) { if( !buf.compare( 0, 14, "IndexedFaceSet" ) ) face_set = true; if( !buf.compare( 0, 14, "IndexedLineSet" ) ) line_set = true; } if( face_set && readVRMLIndexedFaceSet_( in, vertices ) ) mesh_type = "FaceSet"; else if( line_set && readVRMLIndexedLineSet_( in, vertices ) ) mesh_type = "LineSet"; else mesh_type = "PointSet"; return true; }
bool PLearn::SurfaceMesh::readVRMLIndexedFaceSet | ( | string | filename, |
Mat | vtx_features = Mat() |
||
) | [virtual] |
Definition at line 1056 of file SurfaceMesh.cc.
References PLearn::endl(), in, mesh_type, PLERROR, PLearn::pout, readVRMLCoordinate3_(), readVRMLIndexedFaceSet_(), and verbosity.
{ if( verbosity >= 1 ) pout << "\nreadVRMLIndexedFaceSet " << filename << endl; ifstream in( filename.c_str() ); if( !in ) { PLERROR( "Cannot open file: %s.\n", filename.c_str() ); } TVec<vertex_descriptor> vertices; if( !readVRMLCoordinate3_( in, vertices, vtx_features ) ) { PLERROR( "Parse error in %s: expecting a floating-point number.\n", filename.c_str() ); } if( !readVRMLIndexedFaceSet_( in, vertices ) ) { PLERROR( "Error while parsing 'IndexedFaceSet' in file '%s'.\n", filename.c_str() ); } mesh_type = "FaceSet"; return true; }
bool PLearn::SurfaceMesh::readVRMLIndexedFaceSet_ | ( | ifstream & | in, |
TVec< vertex_descriptor > & | vertices | ||
) | [protected, virtual] |
Definition at line 756 of file SurfaceMesh.cc.
References addFace(), createSurfaceMesh(), i, PLERROR, PLearn::remove_comments(), and PLearn::removeblanks().
Referenced by readVRMLFile(), and readVRMLIndexedFaceSet().
{ string buf; /* read from file until "IndexedFaceSet" is reached */ while( buf.compare( 0, 14, "IndexedFaceSet" ) ) { if( !in ) return false; in >> buf; } /* read characters until the open bracket */ getline( in, buf, '[' ); /* reading coordinates until close bracket */ getline( in, buf, ']' ); istringstream all_faces( buf ); // bool end_list = false; while( all_faces ) { TVec<int> pts(3); int delim; string face; getline( all_faces, face ); face = removeblanks( face ); remove_comments( face ); if( face != "" ) { istringstream point_indices( face ); // if( point_indices >> pts[0] >> pts[1] >> pts[2] ) bool ok = true; for( int i=0 ; i<3 ; i++ ) { string pt; getline( point_indices, pt, ',' ); istringstream point( pt ); ok = (point >> pts[i]) && ok; } if( ok ) { if( (point_indices >> delim) && (delim != -1) ) PLERROR( "Non-triangular face found in 'IndexedFaceSet'.\n" ); addFace( vertices[ pts[0] ], vertices[ pts[1] ], vertices[ pts[2] ] ); } else { PLERROR( "Parse error in 'IndexedFaceSet': expecting an integer.\n" ); } } } int nerrors = createSurfaceMesh(); // delOrphanVertices(); if( nerrors ) { return 0; } else { return 1; } }
bool PLearn::SurfaceMesh::readVRMLIndexedLineSet | ( | string | filename, |
Mat | vtx_features = Mat() |
||
) | [virtual] |
Definition at line 1086 of file SurfaceMesh.cc.
References PLearn::endl(), in, mesh_type, PLERROR, PLearn::pout, readVRMLCoordinate3_(), readVRMLIndexedLineSet_(), and verbosity.
{ // probably to be rewritten using PPath if( verbosity >= 1 ) pout << "\nreadVRMLIndexedLineSet " << filename << endl; ifstream in( filename.c_str() ); if( !in ) { PLERROR( "Cannot open file: %s.\n", filename.c_str() ); } TVec<vertex_descriptor> vertices; if( !readVRMLCoordinate3_( in, vertices, vtx_features ) ) { PLERROR( "Parse error in %s: expecting a floating-point number.\n", filename.c_str() ); } if( !readVRMLIndexedLineSet_( in, vertices ) ) { PLERROR( "Error while parsing 'IndexedLineSet' in file '%s'.\n", filename.c_str() ); } mesh_type = "LineSet"; return true; }
bool PLearn::SurfaceMesh::readVRMLIndexedLineSet_ | ( | ifstream & | in, |
TVec< vertex_descriptor > & | vertices | ||
) | [protected, virtual] |
Definition at line 825 of file SurfaceMesh.cc.
References addEdge(), i, me, PLERROR, PLearn::remove_comments(), and PLearn::removeblanks().
Referenced by readVRMLFile(), and readVRMLIndexedLineSet().
{ string buf; /* read from file until "IndexedLineSet" is reached */ while( buf.compare( 0, 14, "IndexedLineSet" ) ) { if( !in ) return false; in >> buf; } /* read characters until the open bracket */ getline( in, buf, '[' ); /* reading coordinates until close bracket */ getline( in, buf, ']' ); istringstream all_edges( buf ); while( all_edges ) { TVec<int> pts(2); int delim; string edge; getline( all_edges, edge ); edge = removeblanks( edge ); remove_comments( edge ); if( edge != "" ) { istringstream point_indices( edge ); bool ok = true; for( int i=0 ; i<2 ; i++ ) { string pt; getline( point_indices, pt, ',' ); istringstream point( pt ); ok = (point >> pts[i]) && ok; } if( ok ) { if( (point_indices >> delim) && (delim != -1) ) PLERROR( "Edge of more than 2 points found in 'IndexedLineSet'.\n" ); MEdge me = new MeshEdge(); addEdge( vertices[ pts[0] ], vertices[ pts [1] ], me ); } else { PLERROR( "Parse error in 'IndexedLineSet': expecting an integer.\n" ); } } } return true; }
void PLearn::SurfaceMesh::setEdge | ( | edge_descriptor | ed, |
const MEdge & | me | ||
) | [virtual] |
void PLearn::SurfaceMesh::setResolution | ( | real | resolution | ) | [virtual] |
void PLearn::SurfaceMesh::setVertex | ( | vertex_descriptor | vtx, |
const MVertex & | mv | ||
) | [virtual] |
Definition at line 236 of file SurfaceMesh.cc.
References p_mesh, and vertex_ppt.
{ put( vertex_ppt, *p_mesh, vtx, mv ); }
void PLearn::SurfaceMesh::setVertexCoords | ( | const Mat & | coords | ) | [virtual] |
Definition at line 282 of file SurfaceMesh.cc.
References i, PLearn::TMat< T >::length(), p_mesh, PLERROR, and vertex_ppt.
{ int n_pts = num_vertices( *p_mesh ); if( coords.length() != n_pts ) { PLERROR( "setVertexCoords: coords.length()=%d different from n_pts=%d", coords.length(), n_pts ); } else { property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh ); vertex_iterator vi, vi_end; tie( vi, vi_end ) = vertices( *p_mesh ); for( int i=0 ; i<n_pts ; i++, vi++ ) { vertex_ppt_map[ *vi ]->coord << coords(i); } } }
void PLearn::SurfaceMesh::setVertexCoordsAndFeatures | ( | const Mat & | coords, |
const Mat & | features | ||
) | [virtual] |
Definition at line 326 of file SurfaceMesh.cc.
References i, PLearn::TMat< T >::length(), p_mesh, PLERROR, and vertex_ppt.
{ int n_pts = num_vertices( *p_mesh ); if( coords.length() != n_pts ) { PLERROR( "setVertexCoordsAndFeatures:" " coords.length()=%d different from n_pts=%d", coords.length(), n_pts ); } if( features.length() != n_pts ) { PLERROR( "setVertexCoordsAndFeatures:" " features.length()=%d different from n_pts=%d", features.length(), n_pts ); } else { property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh ); vertex_iterator vi, vi_end; tie( vi, vi_end ) = vertices( *p_mesh ); for( int i=0 ; i<n_pts ; i++, vi++ ) { vertex_ppt_map[ *vi ]->coord << coords(i); vertex_ppt_map[ *vi ]->features << features(i); } } }
void PLearn::SurfaceMesh::setVertexFeatures | ( | const Mat & | features | ) | [virtual] |
Definition at line 304 of file SurfaceMesh.cc.
References i, PLearn::TMat< T >::length(), p_mesh, PLERROR, and vertex_ppt.
{ int n_pts = num_vertices( *p_mesh ); if( features.length() != n_pts ) { PLERROR( "setVertexFeatures: features.length()=%d different from n_pts=%d", features.length(), n_pts ); } else { property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh ); vertex_iterator vi, vi_end; tie( vi, vi_end ) = vertices( *p_mesh ); for( int i=0 ; i<n_pts ; i++, vi++ ) { vertex_ppt_map[ *vi ]->features << features(i); } } }
void PLearn::SurfaceMesh::setVertexNorms | ( | const Mat & | coords | ) | [virtual] |
Definition at line 398 of file SurfaceMesh.cc.
References i, PLearn::TMat< T >::length(), p_mesh, PLERROR, and vertex_ppt.
{ int n_pts = num_vertices( *p_mesh ); if( norms.length() != n_pts ) { PLERROR( "setVertexNorms: norms.length()=%d different from n_pts=%d", norms.length(), n_pts ); } else { property_map< graph, vertex_ppt_t >::type vertex_ppt_map = get( vertex_ppt, *p_mesh ); vertex_iterator vi, vi_end; tie( vi, vi_end ) = vertices( *p_mesh ); for( int i=0 ; i<n_pts ; i++, vi++ ) { vertex_ppt_map[ *vi ]->norm << norms(i); } } }
void PLearn::SurfaceMesh::writeVRMLBoundaries | ( | string | filename | ) | [virtual] |
Definition at line 1212 of file SurfaceMesh.cc.
References PLearn::endl(), getEdge(), i, PLearn::TVec< T >::length(), mg, PLERROR, PLearn::pout, verbosity, and writeVRMLCoordinate3_().
{ if( verbosity >= 1 ) pout << "\nwriteVRMLBoundaries " << filename << endl; ofstream out( filename.c_str(), ios::trunc ); if( !out ) { PLERROR( "Cannot open file: %s.\n", filename.c_str() ); } /* map used to remember points' index in the vrml file */ map< vertex_descriptor, int > pts_indices; out << "#VRML V1.0 ascii\n\n" << "Separator {\n" << " Material {\n" << " diffuseColor [ 1 1 1 ]\n" << " }\n\n"; writeVRMLCoordinate3_( out, pts_indices ); out << " IndexedLineSet {\n" << " coordIndex [ # line format:\n" /* << "# indices of the points, -1 (end of face)" << " # face index" << " # adjacent faces' indices" // << " # face normal" << " # edges' boundary flags" */ << "\n"; TVec< MFace > faces = mg->faces; for( int i=0 ; i < faces.length() ; i++ ) { MFace face = faces[i]; TVec< vertex_descriptor > pts = face->pts; TVec<int> adj_faces = face->adj_faces; Vec face_norm = face->face_norm; TVec< edge_descriptor > edges = face->edges; if( getEdge( edges[0] )->bf == 1 ) { out << pts_indices[ pts[0] ] <<", "<< pts_indices[ pts[1] ] << ", -1,\n"; } if( getEdge( edges[1] )->bf == 1 ) { out << pts_indices[ pts[1] ] <<", "<< pts_indices[ pts[2] ] << ", -1,\n"; } if( getEdge( edges[2] )->bf == 1 ) { out << pts_indices[ pts[2] ] <<", "<< pts_indices[ pts[0] ] << ", -1,\n"; } } out << " ]\n" << " }\n" << "}\n"; }
void PLearn::SurfaceMesh::writeVRMLCoordinate3_ | ( | ofstream & | out, |
map< vertex_descriptor, int > & | pts_indices | ||
) | [protected, virtual] |
Definition at line 889 of file SurfaceMesh.cc.
References PLearn::mv(), PLearn::norm(), p_mesh, and vertex_ppt.
Referenced by writeVRMLBoundaries(), writeVRMLFile(), writeVRMLIndexedFaceSet(), and writeVRMLIndexedLineSet().
{ out << " Coordinate3 {\n" << " point [ #line format:\n" << "# point coordinates" << " # point index" << " # normal vector" << " # boundary flag" << "\n" ; vertex_iterator vi, vi_end; int vtx_counter=0; for( tie( vi, vi_end )=vertices( *p_mesh ) ; vi != vi_end ; vi++ ) { MVertex mv = get( vertex_ppt, *p_mesh, *vi ); Vec coord = mv->coord; // property_map< graph, vertex_index_t >::type pts_indices; Vec norm = mv->norm; pts_indices[ *vi ] = vtx_counter; vtx_counter++ ; out << " " << coord[0] << " " << coord[1] << " " << coord[2] << "," /* comments */ // point number << " # " << pts_indices[ *vi ] // normal vector << " # " << norm[0] << " " << norm[1] << " "<< norm[2] // boundary flag << " # " << mv->bf << "\n"; } out << " ]\n" << " }\n\n"; }
void PLearn::SurfaceMesh::writeVRMLFile | ( | string | filename | ) | [virtual] |
Definition at line 1119 of file SurfaceMesh.cc.
References PLearn::endl(), mesh_type, PLERROR, PLearn::pout, verbosity, writeVRMLCoordinate3_(), writeVRMLIndexedFaceSet_(), and writeVRMLIndexedLineSet_().
{ if( verbosity >= 1 ) pout << "\nwriteVRMLFile " << filename << endl; ofstream out( filename.c_str(), ios::trunc ); if( !out ) { PLERROR( "Cannot open file: %s.\n", filename.c_str() ); } /* map used to remember points' index in the vrml file */ map< vertex_descriptor, int > pts_indices; out << "#VRML V1.0 ascii\n\n" << "Separator {\n" << " Material {\n" << " diffuseColor [ 1 1 1 ]\n" << " }\n\n"; writeVRMLCoordinate3_( out, pts_indices ); if( mesh_type == "FaceSet" ) writeVRMLIndexedFaceSet_( out, pts_indices ); else if( mesh_type == "LineSet" ) writeVRMLIndexedLineSet_( out, pts_indices ); out << "}\n"; }
void PLearn::SurfaceMesh::writeVRMLIndexedFaceSet | ( | string | filename | ) | [virtual] |
Definition at line 1151 of file SurfaceMesh.cc.
References PLearn::endl(), PLERROR, PLearn::pout, verbosity, writeVRMLCoordinate3_(), and writeVRMLIndexedFaceSet_().
{ if( verbosity >= 1 ) pout << "\nwriteVRMLIndexedFaceSet " << filename << endl; ofstream out( filename.c_str(), ios::trunc ); if( !out ) { PLERROR( "Cannot open file: %s.\n", filename.c_str() ); } /* map used to remember points' index in the vrml file */ map< vertex_descriptor, int > pts_indices; out << "#VRML V1.0 ascii\n\n" << "Separator {\n" << " Material {\n" << " diffuseColor [ 1 1 1 ]\n" << " }\n\n" ; writeVRMLCoordinate3_( out, pts_indices ); writeVRMLIndexedFaceSet_( out, pts_indices ); out << "}\n"; }
void PLearn::SurfaceMesh::writeVRMLIndexedFaceSet_ | ( | ofstream & | out, |
map< vertex_descriptor, int > & | pts_indices | ||
) | [protected, virtual] |
Definition at line 933 of file SurfaceMesh.cc.
References getEdge(), i, PLearn::TVec< T >::length(), and mg.
Referenced by writeVRMLFile(), and writeVRMLIndexedFaceSet().
{ out << " IndexedFaceSet {\n" << " coordIndex [ # line format:\n" << "# indices of the points, -1 (end of face)" << " # face index" << " # adjacent faces' indices" // << " # face normal" << " # edges' boundary flags" << "\n"; TVec< MFace > faces = mg->faces; for( int i=0 ; i < faces.length() ; i++ ) { MFace face = faces[i]; TVec< vertex_descriptor > pts = face->pts; TVec<int> adj_faces = face->adj_faces; Vec face_norm = face->face_norm; TVec< edge_descriptor > edges = face->edges; out << " " << pts_indices[ pts[0] ] << ", " << pts_indices[ pts[1] ] << ", " << pts_indices[ pts[2] ] << ", -1," /* comments */ // index << " # " << i // index of adjacent faces << " # " << adj_faces[0] << " " << adj_faces[1] << " " << adj_faces[2] // face normal /* not calculated yet << "# " << face_norm[0] << " " << face_norm[0] << " " << face_norm[0] */ // edges' boundary flags << " # " << getEdge( edges[0] )->bf << " " << getEdge( edges[1] )->bf << " " << getEdge( edges[2] )->bf << "\n"; } out << " ]\n" << " }\n"; }
void PLearn::SurfaceMesh::writeVRMLIndexedLineSet | ( | string | filename | ) | [virtual] |
Definition at line 1183 of file SurfaceMesh.cc.
References PLearn::endl(), PLERROR, PLearn::pout, verbosity, writeVRMLCoordinate3_(), and writeVRMLIndexedLineSet_().
{ if( verbosity >= 1 ) pout << "\nwriteVRMLIndexedLineSet " << filename << endl; ofstream out( filename.c_str(), ios::trunc ); if( !out ) { PLERROR( "Cannot open file: %s.\n", filename.c_str() ); } /* map used to remember points' index in the vrml file */ map< vertex_descriptor, int > pts_indices; out << "#VRML V1.0 ascii\n\n" << "Separator {\n" << " Material {\n" << " diffuseColor [ 1 1 1 ]\n" << " }\n\n" ; writeVRMLCoordinate3_( out, pts_indices ); writeVRMLIndexedLineSet_( out, pts_indices ); out << "}\n"; }
void PLearn::SurfaceMesh::writeVRMLIndexedLineSet_ | ( | ofstream & | out, |
map< vertex_descriptor, int > & | pts_indices | ||
) | [protected, virtual] |
Definition at line 984 of file SurfaceMesh.cc.
References p_mesh.
Referenced by writeVRMLFile(), and writeVRMLIndexedLineSet().
{ out << " IndexedLineSet {\n" << " coordIndex [ # line format:\n" << "# indices of the points, -1 (end of edge)" << "\n"; edge_iterator ei, ei_end; for( tie( ei, ei_end )=edges( *p_mesh ) ; ei != ei_end ; ei ++ ) { vertex_descriptor src = source( *ei, *p_mesh ); vertex_descriptor tgt = target( *ei, *p_mesh ); out << " " << pts_indices[ src ] <<", "<< pts_indices[ tgt ] << ", -1,\n"; } out << " ]\n" << " }\n"; }
Reimplemented from PLearn::Object.
Definition at line 121 of file SurfaceMesh.h.
bool PLearn::SurfaceMesh::computed_vtx_norm [protected] |
Definition at line 73 of file SurfaceMesh.h.
Referenced by findNormals(), and getVertexNorms().
Definition at line 82 of file SurfaceMesh.h.
Referenced by build_(), declareOptions(), readVRMLFile(), readVRMLIndexedFaceSet(), readVRMLIndexedLineSet(), and writeVRMLFile().
MGraph PLearn::SurfaceMesh::mg [protected] |
Definition at line 72 of file SurfaceMesh.h.
Referenced by addFace(), buildEdges(), createSurfaceMesh(), getFace(), getResolution(), makeDeepCopyFromShallowCopy(), numFaces(), setFace(), setResolution(), SurfaceMesh(), writeVRMLBoundaries(), and writeVRMLIndexedFaceSet_().
Definition at line 81 of file SurfaceMesh.h.
Referenced by addEdge(), addVertex(), averageSphereRadius(), buildBoundaries(), buildEdges(), cacheNeighborFaces(), computeResolution(), delOrphanVertices(), delVertex(), findNormals(), getEdge(), getVertex(), getVertexCoords(), getVertexCoordsAndFeatures(), getVertexDescriptors(), getVertexNorms(), makeDeepCopyFromShallowCopy(), numEdges(), numVertices(), setEdge(), setVertex(), setVertexCoords(), setVertexCoordsAndFeatures(), setVertexFeatures(), setVertexNorms(), SurfaceMesh(), writeVRMLCoordinate3_(), and writeVRMLIndexedLineSet_().
Level of verbosity.
If 0 should not write anything on perr. If >0 may write some info on the steps performed along the way. The level of details written should depend on this value.
Definition at line 87 of file SurfaceMesh.h.
Referenced by declareOptions(), readVRMLIndexedFaceSet(), readVRMLIndexedLineSet(), writeVRMLBoundaries(), writeVRMLFile(), writeVRMLIndexedFaceSet(), and writeVRMLIndexedLineSet().