cgma
GMem.hpp
Go to the documentation of this file.
00001 #ifndef GMEM_HPP
00002 #define GMEM_HPP
00003 
00004 // Include for CubitBoolean
00005 #include "CubitDefines.h"
00006 #include "CGMUtilConfigure.h"
00007 
00008 class CubitTransformMatrix;
00009 
00010 //- A point in 3D space.
00011 struct GPoint
00012 {
00013    float x;
00014    float y;
00015    float z;
00016 };
00017 
00018 typedef struct
00019 {
00020    GPoint at;
00021    GPoint from;
00022    GPoint up;
00023    float width;
00024    float height;
00025    CubitBoolean isCentered;
00026 } CubitViewParam;
00027 
00028 class CUBIT_UTIL_EXPORT GMem
00029 {
00030 private:
00031      // These are made private to make them essentially read-only,
00032      // although you still have direct access to the array elements.
00033    GPoint *pointList; // x, y, z vector
00034    int ptsSize;   // size of points vector
00035    int fListSize; // size of facetList vector
00036    int *facetList; // number of points in face, indices of points in face
00037    CubitBoolean pointsConsolidated;
00038    
00039    void consolidate_few_points( double tolerance );
00040    void consolidate_many_points( double tolerance );
00041    
00042 public:
00043    int pointListCount;  // number valid points stored in points vector
00044    int fListCount;      // number valid integers stored in facetList.
00045     // If you always use triangles, this will be 4 times the number of polygons.
00046    
00047      // Constructor/Destructor take care of dynamic memory.
00048    GMem();
00049    ~GMem();
00050    
00051      // These are high-level functions that don't require you
00052      // to know exactly what the internals are
00053    void allocate_tri(int num_tri);
00054    void allocate_polylines(int num_lines);
00055    void allocate_more_polylines(int num_lines);
00056    void clean_out();
00057    
00058      // The rest give you a little more direct control over the internals
00059    
00060      // Whether points at the same coords have been merged
00061    void points_consolidated(CubitBoolean yes_no)
00062       { pointsConsolidated = yes_no; }
00063    CubitBoolean points_consolidated()
00064       { return pointsConsolidated; }
00065    void consolidate_points( double tolerance );
00066    
00067      // Access to the arrays without letting the client
00068      // change the pointer directly.
00069    GPoint* point_list()
00070       { return pointList; }
00071    int* facet_list()
00072       { return facetList; }
00073    
00074      // Swap one array for another.  Requiring a function call
00075      // instead of direct access makes it more likely that
00076      // dynamic memory and count values will be handled correctly.
00077      //    Important!!!!!!!!!!!
00078      // The array passed in must have been allocated by 'new',
00079      // and must not be deleted outside of GMem!!!!!
00080    void replace_point_list(GPoint new_point_list[], int num_valid_points,
00081                            int array_size);
00082    void replace_facet_list(int new_facet_list[], int num_valid_entries,
00083                            int array_size);
00084    
00085      // Read only access to the array sizes
00086    int point_list_size()
00087       { return ptsSize; }
00088    int facet_list_size()
00089       { return fListSize; }
00090 
00091      // Copy constructor and operator=
00092    GMem(const GMem& from);
00093    GMem& operator=(const GMem& from);
00094 
00095      // transformation functions - transform the display data
00096    void transform(CubitTransformMatrix &transform);
00097 };
00098 
00099 #endif
00100 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines