VTK.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
00026
00027
00028 #include "vtk.hh"
00029 #include <stdlib.h>
00030 #include <stdio.h>
00031 #include <math.h>
00032 #include <windows.h>
00033
00034 #define UNIT 32768L
00035 #define DESELECTED 0
00036 #define SELECTED 1
00037 #define INEDITOR 6
00038
00039 #ifdef __cplusplus
00040 extern "C" {
00041 #endif
00042
00043 #include "struct.h"
00044 #include "dstruct.h"
00045
00046 #ifdef __cplusplus
00047 }
00048 #endif
00049
00050 #include "vtk.h"
00051
00052 #include "sfx2vtk.h"
00053 #include "sfx2vtk.cpp"
00054
00055 static HWND hParent;
00056 static HINSTANCE hThisInstance;
00057
00058 static BOOL CALLBACK SfxDlgProc(HWND hwnd, UINT msg,
00059 WPARAM wparam, LPARAM lparam);
00060
00061 #if __WATCOMC__
00062 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00063 #else
00064 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00065 #endif
00066 switch (dwReason) {
00067 case DLL_PROCESS_ATTACH: {
00068 hThisInstance=(HINSTANCE)hDLL;
00069 if(hDLL == NULL)MessageBeep(MB_OK);
00070 break;
00071 }
00072 case DLL_PROCESS_DETACH:
00073 break;
00074 }
00075 return TRUE;
00076 }
00077
00078
00079 extern "C" BOOL _Xmodeler
00080 (HWND parent_window,HWND info_window,X__STRUCTURE *lpevi){
00081 HCURSOR hSave;
00082 static struct bp {
00083 float f;
00084 } d;
00085 lpEVI=lpevi;
00086 hParent=parent_window;
00087 d.f=0.8;
00088 if(DialogBoxParam(hThisInstance,MAKEINTRESOURCE(DLG_VTK),hParent,
00089 (DLGPROC)SfxDlgProc,(LPARAM)&d) == FALSE)return FALSE;
00090 hSave=SetCursor(LoadCursor(NULL,IDC_WAIT));
00091 {
00092 #if 0
00093 SfxReader sfxinput;
00094 SfxWriter sfxoutput;
00095
00096 SfxPointReader sfxpointinput;
00097 SfxEdgeReader sfxedgeinput;
00098 vtkRenderMaster rm;
00099 vtkRenderWindow *renWin;
00100 vtkRenderer *aren;
00101 vtkActor *actor1, *actor2;
00102 vtkCubeSource *cube1,*cube2;
00103 vtkAppendPolyData *cube;
00104 vtkConeSource *cone;
00105 vtkLineSource *line;
00106 vtkPointSource *pts;
00107 vtkImplicitModeller *imp;
00108 vtkContourFilter *cf;
00109 vtkPolyMapper *mapper, *omapper;
00110 vtkOutlineFilter *outline;
00111 vtkRenderWindowInteractor *iren;
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 cube1 = new vtkCubeSource(1,2,3);
00126 cube2 = new vtkCubeSource(2,3,4);
00127 cube2->SetCenter(3,3,3);
00128
00129 cube = new vtkAppendPolyData;
00130 cube->AddInput(cube1->GetOutput());
00131 cube->AddInput(cube2->GetOutput());
00132
00133 imp = new vtkImplicitModeller;
00134
00135
00136 imp->SetInput(sfxedgeinput.GetOutput());
00137
00138 imp->SetSampleDimensions(25,25,25);
00139 imp->SetMaximumDistance(0.1);
00140
00141
00142 cf = new vtkContourFilter;
00143
00144
00146
00147 vtkSphere *sph1 = new vtkSphere;
00148 sph1->SetRadius(1.0);
00149 vtkSphere *sph2 = new vtkSphere;
00150 sph2->SetRadius(0.5);
00151 sph2->SetCenter(0.0,0.0,0.5);
00152 vtkImplicitBoolean *ibool = new vtkImplicitBoolean;
00153 ibool->AddFunction(sph1);
00154 ibool->AddFunction(sph2);
00155 ibool->SetOperationType(VTK_DIFFERENCE);
00156 vtkSampleFunction *sam = new vtkSampleFunction;
00157 sam->SetSampleDimensions(25,25,25);
00158 sam->SetImplicitFunction(ibool);
00159
00160 cf->SetInput(sam->GetOutput());
00161 cf->SetValue(0, 0.0);
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194 vtkCleanPolyData *cp = new vtkCleanPolyData;
00195 cp->SetTolerance(0.0001);
00196 cp->SetInput(cf->GetOutput());
00197
00198 vtkTriangleFilter *tf = new vtkTriangleFilter;
00199 tf->SetInput(cp->GetOutput());
00200
00201 sfxoutput.SetInput(tf->GetOutput());
00202 sfxoutput.Write();
00203
00204 delete tf;
00205 delete cp;
00206 delete cf;
00207 delete imp;
00208 #endif
00209
00210 }
00211 SetCursor(hSave);
00212 return TRUE;
00213 }
00214
00215 static BOOL CALLBACK SfxDlgProc(HWND hwnd, UINT msg,
00216 WPARAM wparam, LPARAM lparam){
00217 BOOL err;
00218 double f;
00219 int i;
00220 static struct bp {
00221 float f;
00222 } *dp;
00223 char str[32];
00224 switch( msg ) {
00225 case WM_INITDIALOG:
00226 dp=(struct bp *)lparam;
00227 CentreDlgOnS(hwnd);
00228 return (TRUE);
00229 case WM_COMMAND:
00230 switch(LOWORD(wparam)){
00231 case IDCANCEL:
00232 EndDialog(hwnd,FALSE);
00233 return(TRUE);
00234 case IDOK:
00235 EndDialog(hwnd,TRUE);
00236 return(TRUE);
00237 default:
00238 break;
00239 }
00240 break;
00241 default: break;
00242 }
00243 return(FALSE);
00244 }
00245