MeshLoader.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SOFA_COMPONENT_TOPOLOGY_MESHLOADER_H
00026 #define SOFA_COMPONENT_TOPOLOGY_MESHLOADER_H
00027
00028 #include <string>
00029 #include <sofa/helper/fixed_array.h>
00030 #include <sofa/helper/vector.h>
00031
00032 #include <sofa/core/objectmodel/BaseObject.h>
00033 #include <sofa/helper/io/MeshTopologyLoader.h>
00034
00035 namespace sofa
00036 {
00037
00038 namespace component
00039 {
00040
00041 class MeshLoader : public virtual core::objectmodel::BaseObject,
00042 public helper::io::MeshTopologyLoader
00043 {
00044 public:
00045 typedef unsigned int index_type;
00046 typedef index_type PointID;
00047 typedef index_type EdgeID;
00048 typedef index_type TriangleID;
00049 typedef index_type QuadID;
00050 typedef index_type TetraID;
00051 typedef index_type HexaID;
00052
00053 typedef helper::fixed_array<SReal,3> Point;
00054 typedef helper::fixed_array<PointID,2> Edge;
00055 typedef helper::fixed_array<PointID,3> Triangle;
00056 typedef helper::fixed_array<PointID,4> Quad;
00057 typedef helper::fixed_array<PointID,4> Tetra;
00058 typedef helper::fixed_array<PointID,8> Hexa;
00059
00060 typedef helper::vector<Point> SeqPoints;
00061 typedef helper::vector<Edge> SeqEdges;
00062 typedef helper::vector<Triangle> SeqTriangles;
00063 typedef helper::vector<Quad> SeqQuads;
00064 typedef helper::vector<Tetra> SeqTetras;
00065 typedef helper::vector<Hexa> SeqHexas;
00066
00067 MeshLoader();
00068
00069 virtual ~MeshLoader() {}
00070
00071 virtual void clear();
00072
00073 virtual bool load(const char* filename);
00074
00075
00076 void setFilename(std::string f)
00077 {
00078 filename.setValue(f);
00079 }
00080
00081 const std::string &getFilename() const
00082 {
00083 return filename.getValue();
00084 }
00085
00086 double getPX(int i) const { return seqPoints.getValue()[i][0]; }
00087 double getPY(int i) const { return seqPoints.getValue()[i][1]; }
00088 double getPZ(int i) const { return seqPoints.getValue()[i][2]; }
00089
00090 int getNbPoints() const;
00091 const SeqPoints& getPoints() const;
00092 const SeqEdges& getEdges() const;
00093 const SeqTriangles& getTriangles() const;
00094 const SeqQuads& getQuads() const;
00095 const SeqTetras& getTetras() const;
00096 const SeqHexas& getHexas() const;
00097
00098 void parse(core::objectmodel::BaseObjectDescription* arg);
00099
00100 protected:
00101
00102 void addPoint(double px, double py, double pz);
00103 void addLine( int a, int b );
00104 void addTriangle( int a, int b, int c );
00105 void addTetra( int a, int b, int c, int d );
00106 void addQuad( int a, int b, int c, int d );
00107 void addCube( int a, int b, int c, int d, int e, int f, int g, int h );
00108
00109 protected:
00110 Data<SeqPoints> seqPoints;
00111 Data<SeqEdges> seqEdges;
00112 Data<SeqTriangles> seqTriangles;
00113 Data<SeqQuads> seqQuads;
00114 Data<SeqTetras> seqTetras;
00115 Data<SeqHexas> seqHexas;
00116
00117 Data< std::string > filename;
00118 };
00119
00120 }
00121
00122 }
00123
00124 #endif