COPY.CPP
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 #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;
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 }