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

Generated on Thu Jul 8 15:19:28 2004 for inspace by doxygen 1.3.4