COPY.CPP

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 1.0 - Modelling, Animation and Rendering Package
00003 Copyright (C) 2000 OpenFX Development Team
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You may contact the OpenFX development team via elecronic mail
00020 at core@openfx.org, or visit our website at http://openfx.org for
00021 further information and support details.
00022 -- */
00023 
00024 /*  TESSEL.C  */
00025 #include <stdlib.h>
00026 #include <stdio.h>
00027 #include <math.h>
00028 #include <windows.h>
00029 
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033 
00034 #include "struct.h"
00035 #include "dstruct.h"
00036 
00037 #ifdef __cplusplus
00038 }
00039 #endif
00040 
00041 #include "copy.h"
00042 
00043 #define DESELECTED 0
00044 #define SELECTED   1
00045 
00046 
00047 static HWND      hParent;
00048 static HINSTANCE hThisInstance;
00049 
00050 
00051 #if __WATCOMC__
00052 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00053 #else
00054 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00055 #endif
00056   switch (dwReason) {
00057     case DLL_PROCESS_ATTACH: {
00058       hThisInstance=(HINSTANCE)hDLL;
00059       if(hDLL == NULL)MessageBox ( GetFocus()," NULL instance",NULL, MB_OK);
00060       break;
00061     }
00062     case DLL_PROCESS_DETACH:
00063       break;
00064   }
00065   return TRUE;
00066 }
00067 
00068 #if __SC__
00069 #pragma startaddress(DllMain)
00070 #endif
00071 
00072 extern "C" BOOL _Xmodeler
00073  (HWND parent_window,HWND info_window,X__STRUCTURE *lpevi){
00074  lpEVI=lpevi;
00075  hParent=parent_window;
00076  if(MessageBox(hParent,"Copy selected faces ?","Copy",MB_OKCANCEL)
00077                == IDCANCEL)return FALSE;
00078  else{
00079  HCURSOR hSave;
00080  vertex *vp,*V0,*V1,*V2,*Vp;
00081  edge   *ep;
00082  face   *fp;
00083  long   i,Nvert1,Nedge1,Nface1;
00084  long x,y,z;
00085  if(NvertSelect == 0 || NvertSelect > 32000)return FALSE;
00086  hSave=SetCursor(LoadCursor(NULL,IDC_WAIT));
00087  if(!UpdateVertexHeap(Nvert+NvertSelect))return FALSE;
00088  for(Nedge1=0,ep=MainEp,i=0;i<Nedge;i++){
00089    V0=(MainVp+ep->V[0]); V1=(MainVp+ep->V[1]);
00090    if(V0->status == SELECTED && V1->status == SELECTED)Nedge1++;
00091    ep++;
00092  }
00093  if(!UpdateEdgeHeap(Nedge+Nedge1))return FALSE;
00094  for(Nface1=0,fp=MainFp,i=0;i<Nface;i++){
00095    V0=(MainVp+fp->V[0]); V1=(MainVp+fp->V[1]); V2=(MainVp+fp->V[2]);
00096    if(V0->status == SELECTED &&
00097       V1->status == SELECTED &&
00098       V2->status == SELECTED)Nface1++;
00099    fp++;
00100  }
00101  if(!UpdateFaceHeap(Nface+Nface1))return FALSE;
00102  Nvert1=Nvert; Nedge1=Nedge; Nface1=Nface;
00103  vp=MainVp; for(i=0;i<Nvert1;i++){
00104    if(vp->status == SELECTED){
00105      CreateVertex();
00106      Vp=(MainVp+Nvert-1);
00107      Vp->xyz[0]=vp->xyz[0];
00108      Vp->xyz[1]=vp->xyz[1];
00109      Vp->xyz[2]=vp->xyz[2];
00110      Vp->gp=vp->gp;
00111      if(Vp->gp == 1){
00112        Vp->x=vp->x;
00113        Vp->y=vp->y;
00114        NvertGlue++;
00115      }
00116      Vp->status=DESELECTED;
00117      vp->id=Nvert-1;
00118      NvertSelect--; NvertDeselect++;
00119    }
00120    else{
00121      vp->id = -1;  /* needed by copy+flip+weld */
00122    }
00123    vp++;
00124  }
00125  if(Nedge > 0)for(ep=MainEp,i=0;i<Nedge1;i++){
00126    V0=(MainVp+ep->V[0]); V1=(MainVp+ep->V[1]);
00127    if(V0->status == SELECTED &&
00128       V1->status == SELECTED){
00129       CreateEdge(V0->id,V1->id);
00130    }
00131    ep++;
00132  }
00133  if(Nface > 0)for(fp=MainFp,i=0;i<Nface1;i++){
00134    V0=(MainVp+fp->V[0]); V1=(MainVp+fp->V[1]); V2=(MainVp+fp->V[2]);
00135    if(V0->status == SELECTED &&
00136       V1->status == SELECTED &&
00137       V2->status == SELECTED) {
00138      CreateFace(V0->id,V1->id,V2->id);
00139      CopyFaceProp(fp,(MainFp+Nface-1));
00140    }
00141    fp++;
00142  }
00143  vp=MainVp; for(i=0;i<Nvert1;i++){
00144    if(vp->status == SELECTED){
00145     vp->status=DESELECTED;
00146     (MainVp+vp->id)->status=SELECTED;
00147    }
00148    vp++;
00149  }
00150  SetCursor(hSave);
00151  }
00152  return TRUE;
00153 }

Generated on Sun Apr 27 14:20:10 2014 for OpenFX by  doxygen 1.5.6