Alphabetical Class Index  Class Hierarchy   File Members   Compound Members   File List  

HOpCreateNurbs3D.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2000 by Tech Soft 3D, LLC.
00003 // The information contained herein is confidential and proprietary to
00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under
00005 // civil and criminal statutes.  Tech Soft 3D shall pursue its civil
00006 // and criminal remedies in the event of unauthorized use or misappropriation
00007 // of its trade secrets.  Use of this information by anyone other than
00008 // authorized employees of Tech Soft 3D, LLC. is granted only under a
00009 // written non-disclosure agreement, expressly prescribing the scope and
00010 // manner of such use.
00011 //
00012 // $Id: ed136440f0acf5b3f0b99ec09e542b8023ce7fe6 $
00013 //
00014 
00022 #ifndef _OpCreateNurbs3D_H
00023 #define _OpCreateNurbs3D_H
00024 
00025 #ifdef H_PACK_8
00026 #pragma pack(push)
00027 #pragma pack(8)
00028 #endif
00029 
00030 #include "HTools.h"
00031 #include "HBaseOperator.h"
00032 
00033 
00037 enum HSurfaceType 
00038 {
00039     InternalNurbsType,          
00040     NurbsType,                  
00041     ChakinSubdivisionType       
00042 };
00043 
00044 
00045 class HNurbsSurface;
00046 
00047 
00049 
00061 class MVO_API HOpCreateNurbs3D : public HBaseOperator
00062 {
00063 public:
00071     HOpCreateNurbs3D (HBaseView* view, int DoRepeat=0, int DoCapture=1);
00072     virtual ~HOpCreateNurbs3D();
00073 
00079     virtual HBaseOperator * Clone();
00080     
00084     virtual const char * GetName();  
00090     virtual int OnLButtonDown(HEventInfo &hevent);
00091 
00097     virtual int OnLButtonUp(HEventInfo &hevent);
00098 
00105     virtual int OnLButtonDownAndMove(HEventInfo &hevent);
00106  
00115     static HC_KEY InsertNurbs(HBaseView *pView, HNurbsSurface *pNurbsSurface, bool emit_message);
00116 
00117 
00124     static void InsertNurbsFromMessage(const char *in_data, unsigned int data_length, HBaseView *m_pView);
00125 
00135     static void EmitModifyControlPointMessage(HBaseView *pView, HC_KEY key, int control_point, float x, float y, float z);
00136 
00143     static void ModifyControlPointFromMessage(const char *in_data, unsigned int data_length, HBaseView *pView);
00144 
00153     static void EmitFinishNurbsEditing(HBaseView *pView, HC_KEY key, bool emit_message);
00154  
00161     static void FinishNurbsEditingFromMessage(const char *in_data, unsigned int data_length, HBaseView *pView);
00162 
00163 
00164 protected:
00165 
00166 private:
00167     HPoint m_last_point;
00168     int     m_mnnum;
00169     float   m_gwidth;
00170     int     m_gran;
00171     int     m_degree;
00172     HC_KEY  m_NurbsKey;
00173     HNurbsSurface *m_pNurbsSurface;
00174 
00175     
00176  
00177 };
00178 
00179 
00181 
00188 class MVO_API HNurbsSurface
00189 {
00190 public:
00191 
00193     HNurbsSurface()
00194     {
00195         m_nurbsKey = 0;
00196         m_numUVertices = 0;
00197         m_numVVertices = 0;
00198         m_pVertices = 0;
00199         m_pNurbs = 0;
00200         m_degree = 0;
00201         m_tesselationLevel = 0;
00202         m_pNurbs = 0;
00203         m_pVertices = 0;
00204         m_vertexDistance = 0;
00205         m_verticesKey = 0;
00206         m_surfaceMeshKey = 0;
00207 
00208     }
00209     ~HNurbsSurface()
00210     {
00211         H_SAFE_DELETE_ARRAY(m_pVertices);
00212         H_SAFE_DELETE_ARRAY(m_pNurbs);
00213     }
00214 
00219     void Init(HC_KEY key);
00220 
00233     HC_KEY Init( HPoint * center, HPoint * axis, 
00234             int num_u_vertices, int num_v_vertices, 
00235             int degree, int tesselation_level, 
00236             float distance, HSurfaceType stype);
00237 
00241     void Recalculate();
00242  
00246     HC_KEY GetKey();
00247 
00248     
00252     void DisplayVertices(); 
00253 
00257     void HideVertices();
00258 
00262     void EnableSelectability();
00263 
00267     void DisableSelectability();
00268 
00276     void UpdateVertex(int vertexnum, float x, float y, float z);
00277 
00283     void ShowVertex(int vertexnum, HPoint &v);
00284     
00290     void CreateDefaultVertices(HPoint * center, HPoint * axis);
00291 
00293     HC_KEY GetSurfaceMeshKey() { return m_surfaceMeshKey; }
00294  
00295 private:
00296   
00297     HC_KEY m_nurbsKey;
00298     HC_KEY m_verticesKey;
00299     HC_KEY m_surfaceMeshKey;
00300     int m_numUVertices;
00301     int m_numVVertices;
00302     int m_degree;
00303     int m_tesselationLevel;
00304     float m_vertexDistance;
00305     HPoint *m_pVertices;
00306     HPoint *m_pNurbs;
00307     HSurfaceType m_surfaceType;
00308     
00309 
00310     void UpdateVertices(); 
00311     void UpdateParameters();
00312     float nip(int i,int p, float u, float *uv);
00313     void InsertNurbsMesh(HPoint *pNurbs);
00314     void InsertChakinSubdivionSurface(HPoint *pNurbs);
00315     void CalculateCornerPoint(HPoint &p1, HPoint &p2, HPoint &res, float factor); 
00316     void SubdivideSurface(HPoint *old_surface, HPoint *ssurf, int xlen, int ylen, int &new_xlen, int &new_ylen, bool xrefine);
00317 
00318     void GetVerticesFromHOOPS();
00319     void GetParametersFromHOOPS();
00320 
00321 };
00322  
00323 
00324 
00325 #ifdef H_PACK_8
00326 #pragma pack(pop)
00327 #endif
00328 
00329 #endif
00330 
00331 
00332 
00333