Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

ISMesh.H

Go to the documentation of this file.
00001 
00011 #ifndef ISMESH_H
00012 #define ISMESH_H
00013 
00014 #include "ISVertex.H"
00015 #include "ISEdge.H"
00016 #include "ISFace.H"
00017 #include "ISTriStrip.H"
00018 #include "Color.H"
00019 #include "BBox.H"
00020 
00021 // Gluebase includes
00022 #define OUTSIDE_GLUE_CORE
00023 #include <std/hash.H>
00024 #include <mlib/points.H>
00025 
00026 #include "streamwrap.H"
00027 
00028 class ISMesh
00029 {
00030  public:
00031   ISMesh(Cstr_ptr &name=str_ptr::null_str(),
00032        int numv=0, int nume=0, int numf=0);
00033   virtual ~ISMesh();  
00034 
00035   virtual ISVertex* addTriStripVertex(ISVertex *v, int triStripNum);
00036   
00037   virtual ISVertex* addVertex(ISVertex *v);
00038   virtual ISVertex* addVertex(cWpt &loc);
00039   virtual ISVertex* addVertex(cWpt &loc, cWvec &norm);
00040 
00041   virtual ISEdge* addEdge(ISEdge *e);
00042   virtual ISEdge* addEdge(ISVertex *u, ISVertex *v);
00043   virtual ISEdge* addEdge(int i, int j);
00044 
00045   // isolated=1 by default, 0 if the face belongs to a tri-strip
00046   virtual ISFace* addFace(ISFace *f, Wvec normal=Wvec(0,0,0), int isolated=1);  
00047   virtual ISFace* addFace(ISVertex *u, ISVertex *v, ISVertex *w, 
00048             Wvec normal=Wvec(0,0,0), int isolated=1, bool debug=1);
00049   virtual ISFace* addFace(int i, int j, int k, 
00050             Wvec normal=Wvec(0,0,0), int isolated=1, bool debug=1);
00051   
00052 
00053   virtual ISFace* lookupFace(ISVertex *u, ISVertex *v, ISVertex *w);
00054 
00055   virtual int removeVertex(ISVertex *v);
00056   virtual int removeEdge(ISEdge *e);
00057   virtual int removeFace(ISFace *f);
00058   virtual int removeAll();
00059 
00060 
00061   virtual BBox bbox() { return _bbox; }
00062 
00063   virtual double volume();
00064   virtual double surfaceArea();
00065 
00066   virtual void print() {
00067     cout << "Mesh: " << _name << endl;
00068     cout << "      nverts = " << nverts() << endl;
00069     cout << "      nedges = " << nedges() << endl;
00070     cout << "      nfaces = " << nfaces() << endl;
00071   }
00072   
00073   // transform the entire geometry
00074   virtual void transform(cWtransf &xform);
00075   
00076   // size of lists:
00077   int empty()  const   { return _verts.empty(); }
00078   int nverts() const   { return _verts.num(); }
00079   int nedges() const   { return _edges.num(); }
00080   int nfaces() const   { return _faces.num(); }
00081   int ntriStrips() const { return _triStrips.num(); }
00082   int nisoFaces()  const { return _isolatedFaces.num(); }
00083   
00084   cARRAY<ISVertex*>&   verts() const { return _verts; }
00085   cARRAY<ISEdge*>&     edges() const { return _edges; }
00086   cARRAY<ISFace*>&     faces() const { return _faces; }
00087   cARRAY<TriStrip*>& tristrips()     const { return _triStrips; }
00088   cARRAY<ISFace*>&     isolatedFaces() const { return _isolatedFaces; }
00089 
00090 
00091   int validVertIndices(int i, int j) const {
00092     return (_verts.valid_index(i) && _verts.valid_index(j));
00093   }
00094   int validVertIndices(int i, int j, int k) const {
00095     return (_verts.valid_index(i) && _verts.valid_index(j) &&
00096         _verts.valid_index(k));
00097   }
00098 
00099   
00100   // this is set automatically when Vertex::setColor() is called
00101   void setUseVertexColors(int value) {
00102     _useVertexColors = value;
00103   }
00104 
00105   // this is set automatically when Vertex::setTexCoords() is called
00106   void setUseTexCoords(int value) {
00107     _useTexCoords = value;
00108   }
00109 
00110   // added 4.3.03 amcclain
00111   inline int getUseTexCoords() { return _useTexCoords; }
00112   
00113   // this is set automatically when Vertex::setNormal() is called
00114   void setUseVertexNormals(int value) {
00115     _useVertexNormals = value;
00116   }
00117 
00118   void draw(bool useAlpha=false,double alpha=1.0);
00119 
00120   bool readVRML(istream *is);
00121   void writeVRML(ostream *ofs);
00122   
00123 
00124   /************************************************************
00125    * Added by dlemmerm on 11/21/02
00126    ************************************************************/
00127   double rayIntersect( Wvec v, Wpt p );
00128   
00129   // returns 1 if this point intersects
00130   // any of the faces of this mesh within a threshold.  pobj is a point 
00131   // within object space.  that is, it has already been transformed with
00132   // pobj = MeshObj::xform().invert() * pworld;
00133   int pointIntersect(Wpt pobj);
00134 
00135   void cleanUp(double epsilon);
00136 
00137  protected:
00138 
00139   ARRAY<ISVertex*>    _verts;
00140   ARRAY<ISEdge*>      _edges;
00141   ARRAY<ISFace*>      _faces;
00142 
00143   ARRAY<TriStrip*>  _triStrips;
00144   ARRAY<ISFace*>      _isolatedFaces;   // faces not in a tri-strip
00145 
00146   str_ptr _name;
00147   BBox _bbox;
00148 
00149   int _useVertexColors;
00150   int _useTexCoords;
00151   int _useVertexNormals;
00152 
00153 };
00154 
00155 #endif

Generated on Mon Sep 15 16:27:56 2003 for inspace by doxygen1.2.18