亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? zarraytrace.cpp

?? zemax與matlab調(diào)用程序
?? CPP
?? 第 1 頁(yè) / 共 3 頁(yè)
字號(hào):
// zArrayTrace.cpp Derived from.
// Zclient: ZEMAX client template program
// Originally written by Kenneth Moore June 1997
// Copyright 1997-2001 Kenneth Moore
//
// Modified by D Griffith, November 2003
// Converted to DLL, calleable as Matlab mex.
// Implements mass ray-tracing as documented in the Zemax Manual
// $Revision: 1.0 $

// The zclient program is responsible for establishing communication
// with the ZEMAX server. All data from ZEMAX can be obtained by calling
// PostRequestMessage or PostArrayTraceMessage with the item name and a buffer to hold the data.
//
// Zclient will call UserFunction when the DDE communication link is established and ready.
// Zclient will automatically terminate the connection when UserFunction returns.
//
// Version 1.1 modified to support Array ray tracing September, 1997
// Version 1.2 modified for faster execution October, 1997
// Version 1.3 modified for faster execution November, 1997
// Version 1.4 modified to fix memory leak January, 1998
// Version 1.5 modified to add support for long path names and quotes November, 1998
// Version 1.6 modified to fix missing support for long path names and quotes in MakeEmptyWindow March, 1999
// Version 1.7 modified to fix memory leak in WM_DDE_ACK, March 1999
// Version 1.8 modified to add E-field data to DDERAYDATA for ZEMAX 10.0, December 2000
// Version 1.9 modified PostRequestMessage and PostArrayTraceMessage to return -1 if data failed (usually because of a timeout) or 0 otherwise, April 2001

#include <windows.h>
#include <dde.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include "mex.h"

#define WM_USER_INITIATE (WM_USER + 1)
#define DDE_TIMEOUT 5000

typedef struct
	{
    double x, y, z, l, m, n, opd, intensity;
	double Exr, Exi, Eyr, Eyi, Ezr, Ezi;
	int wave, error, vigcode, want_opd;
	}DDERAYDATA;
/* Here are the field names for the DDERAYDATA struct */
#define NUMFIELDS 18
const char *FieldNames[NUMFIELDS] = {"x", "y", "z", "l", "m", "n", "opd", "intensity", 
									 "Exr","Exi","Eyr","Eyi", "Ezr", "Ezi",
									 "wave", "error", "vigcode", "want_opd"};


LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
void WaitForData(HWND hwnd);
char *GetString(char *szBuffer, int n, char *szSubString);
void remove_quotes(char *s);
int  PostRequestMessage(char *szItem, char *szBuffer);
int  PostArrayTraceMessage(char *szBuffer, DDERAYDATA *RD);
void CenterWindow(HWND hwnd);
void UserFunction(void);
void MakeEmptyWindow(int text, char *szAppName, char *szOptions);
void Get_2_5_10(double cmax, double *cscale);
int myGetInt(mxArray *ScalarNumeric);


/* global variables used by the client code */
char szAppName[] = "ZemaxClient";
int GotData, ngNumRays;
char szGlobalBuffer[5000], szCommandLine[260];
HINSTANCE globalhInstance;
HWND hwndServer, hwndClient;
DDERAYDATA *rdpGRD = NULL;
mxArray *gplhs;
mxArray *dval; /* Temporary variable */
const mxArray *gprhs;
int nfields, nelems, mode, numrays;
DDERAYDATA *MyRayData;
unsigned int DDE_Timeout;


/* BEEP related stuff - mainly for debugging*/
void BEEP(int freq, int duration);
bool isNTxyz();
void DoEvents();

void BEEP(int freq, int duration)
    {
        	if(isNTxyz() == false){
        	int tmp;
        	long frq = 1190000L / (long)freq;
        _outp(67, 0xb6);
        _outp(66, frq & 0xff);
        _outp(66, (frq >> 8) & 0xff);
        	tmp = _inp(97);
        _outp(97, tmp | 0x03);
        	long firstTick;
        	firstTick = GetTickCount();
        	do{DoEvents();}
        	while((GetTickCount() - firstTick) <= (long)duration);
        	tmp = _inp(97);
        _outp(97, tmp & 0xfc);}
        	else{Beep(freq, duration);}
    }

bool isNTxyz()
    {
        	OSVERSIONINFO osVerInfo;
        	memset(&osVerInfo, 0, sizeof(OSVERSIONINFO));
        	osVerInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
        	GetVersionEx(&osVerInfo);
        	if(osVerInfo.dwPlatformId == VER_PLATFORM_WIN32_NT)
        	{return true;}
        	else{return false;}
        	return false;
    }

void DoEvents()
    {
        MSG msg;
        while(PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)){DispatchMessage(&msg);}
    }
/* End of BEEP-related stuff */





int CALLBACK LibMain(HANDLE hInstance, WORD wDataSeg, WORD wHeapSize, LPSTR lpszCmdLine)
{
	//if (wHeapSize > 0)
        //   UnlockDate (0);    //Unlocks the data segment of the library.
		globalhInstance = (HINSTANCE)hInstance;
//BEEP(500,500); //debug
        return 1;
}




//int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)

void mexFunction(
    int nlhs, mxArray *plhs[],
    int nrhs, const mxArray *prhs[])

{
HWND       hwnd;
MSG        msg;
WNDCLASSEX wndclass;
int nfields, field_num, elem_num, FieldIndex;
char FieldName[10];
mxClassID ClassID;

wndclass.cbSize        = sizeof (wndclass);
wndclass.style         = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc   = WndProc;
wndclass.cbClsExtra    = 0;
wndclass.cbWndExtra    = 0;
wndclass.hInstance     = globalhInstance;
wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName  = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm       = LoadIcon (NULL, IDI_APPLICATION);
RegisterClassEx (&wndclass);

hwnd = CreateWindow (szAppName, "ZEMAX Client", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, globalhInstance, NULL);
UpdateWindow (hwnd);

// Check the number of arguments. There must be one lhs and one or two rhs.
if (nrhs < 1)
	mexErrMsgTxt("One input DDERaydata struct is required.");

if (nrhs > 2)
	mexErrMsgTxt("Too many input arguments. Type help zArrayTrace");

if (nlhs > 1)
	mexErrMsgTxt("Too many output arguments.");

if (nrhs == 2) // There is a timeout argument as well ?
	{
	if (mxIsNumeric(prhs[1]))
		switch (mxGetClassID(prhs[1])) // We cater for all numeric classes you know
			{
			case mxDOUBLE_CLASS : DDE_Timeout = (unsigned int)*mxGetPr(prhs[1]); break;
			case mxSINGLE_CLASS : DDE_Timeout = (unsigned int)*(float *)mxGetData(prhs[1]); break;
			case mxINT8_CLASS   : DDE_Timeout = (unsigned int)*(char *)mxGetData(prhs[1]); break;
			case mxUINT8_CLASS  : DDE_Timeout = (unsigned int)*(unsigned char *)mxGetData(prhs[1]); break;
			case mxINT16_CLASS  : DDE_Timeout = (unsigned int)*(short *)mxGetData(prhs[1]); break;
			case mxUINT16_CLASS : DDE_Timeout = (unsigned int)*(unsigned short *)mxGetData(prhs[1]); break;
			case mxINT32_CLASS  : DDE_Timeout = (unsigned int)*(int *)mxGetData(prhs[1]); break;
			case mxUINT32_CLASS : DDE_Timeout = *(unsigned int *)mxGetData(prhs[1]); break;
			}
	else
		{
		mexPrintf("Second argument must be numeric timeout in milliseconds - default assumed.");
		DDE_Timeout = DDE_TIMEOUT;
		}
	}
else 
	DDE_Timeout = DDE_TIMEOUT; // Use the default defined above


// Set a global pointer to the rhs that we can pick up later if need be
gprhs = prhs[0];

gplhs = plhs[0];



// Set a global pointer to the lhs that we can pick up later.
gplhs = plhs[0];

if (!mxIsStruct(gprhs))
    mexErrMsgTxt("Input must be a structure.");

// Get the number of fields in the struct
nfields = mxGetNumberOfFields(gprhs); 
// mexPrintf("Fields : %i\n", nfields); //debug

nelems  = mxGetNumberOfElements(gprhs); 
// mexPrintf("Elements : %i\n", nelems); //debug

// It turns out to be wise to check that the user has correctly specified the 


// Here we insert the Matlab struct data into the global raydata struct array MyRayData

// Firstly we must establish how much memory is required and allocate the memory for the ray data.
// Mode 5 requires a whole lot of memory for a single ray, this is the most difficult case.
// So find out if the user want mode 5.

dval = mxGetField(gprhs, 0, "opd"); /* Get the opd field from the first element */
if (dval == NULL) mode = 0;
else mode = myGetInt(dval);
if (mode > 5) // This is mode 5
	{
	// nelems = mode - 4; // Not sure this is correct
	numrays = mode - 5;
	mode = 5;
	mexPrintf("Mode 5 ... \n"); //debug
	}
else
	{
	dval = mxGetField(gprhs, 0 , "error"); //This is supposedly the number of rays - has the user screwed up or not
	if (dval != NULL)
		{
		numrays = myGetInt(dval);
	    if ((nelems-1) != numrays)
			{
			mexPrintf("Field \"error\" set to %i does not correspond with array size of %i.\n", numrays, nelems);
			mexErrMsgTxt("Aborted.");
			}
		}
	else // The user did not even set the error field.
		{
		mexPrintf("The \"error\" field was not set. Should be set to the number of rays.\n");
		mexErrMsgTxt("Aborted.");
		}	
	}


// Allocate the memory using the Matlab routine.
MyRayData = (DDERAYDATA *)mxCalloc(numrays+1, sizeof(DDERAYDATA));

if (MyRayData == NULL) mexErrMsgTxt("Unable to allocate memory for the DDERAYDATA structure.");

mexPrintf("Got to after mxCalloc\n"); //debug

// Now copy the Matlab struct array into the MyRayData struct array.
// mxCalloc zeroes out the memory, so it should be OK to just insert the fields that do have values
for (field_num=0; field_num<nfields; field_num++) // Run through the fields in the struct and prepare to put into MyRayData
	{
	strcpy(FieldName, mxGetFieldNameByNumber(gprhs, field_num));
	// mexPrintf("%s\n", FieldName); //debug
	FieldIndex = 0;
	if      (strcmp("x",			FieldName)==0) FieldIndex = 1;
	else if (strcmp("y",			FieldName)==0) FieldIndex = 2;
	else if (strcmp("z",			FieldName)==0) FieldIndex = 3;
	else if (strcmp("l",			FieldName)==0) FieldIndex = 4;
	else if (strcmp("m",			FieldName)==0) FieldIndex = 5;
	else if (strcmp("n",			FieldName)==0) FieldIndex = 6;
	else if (strcmp("opd",			FieldName)==0) FieldIndex = 7;
	else if (strcmp("intensity",	FieldName)==0) FieldIndex = 8;
	else if (strcmp("Exr",			FieldName)==0) FieldIndex = 9;
	else if (strcmp("Exi",			FieldName)==0) FieldIndex = 10;
	else if (strcmp("Eyr",			FieldName)==0) FieldIndex = 11;
	else if (strcmp("Eyi",			FieldName)==0) FieldIndex = 12;
	else if (strcmp("Ezr",			FieldName)==0) FieldIndex = 13;
	else if (strcmp("Ezi",			FieldName)==0) FieldIndex = 14;
	else if (strcmp("wave",			FieldName)==0) FieldIndex = 15;
	else if (strcmp("error",		FieldName)==0) FieldIndex = 16;
	else if (strcmp("vigcode",		FieldName)==0) FieldIndex = 17;
	else if (strcmp("want_opd",		FieldName)==0) FieldIndex = 18;
	else mexPrintf("Warning : Unknown field \"%s\"\n", FieldName);

	for (elem_num=0; elem_num<nelems; elem_num++) // Run through the elements which have values and pop them into MyRayData
		{
		dval = mxGetField(gprhs, elem_num, FieldName);
		if (dval != NULL) // No value here, move on
			{
		    if (mxIsNumeric(dval)) // We will cater for all numeric classes just to be thorough
				{
				ClassID = mxGetClassID(dval);
				switch (ClassID)
				{
				case mxDOUBLE_CLASS : // The data is a double
		            // mexPrintf("%f\n", *mxGetPr(dval)); // debug
				    // sharp end - will have to put in a switch statement for every numeric type - ouch.
					switch (FieldIndex)
						{
					    case  1: MyRayData[elem_num].x			= (double)*mxGetPr(dval); break;
						case  2: MyRayData[elem_num].y			= (double)*mxGetPr(dval); break;
					    case  3: MyRayData[elem_num].z			= (double)*mxGetPr(dval); break;
						case  4: MyRayData[elem_num].l			= (double)*mxGetPr(dval); break;					    
						case  5: MyRayData[elem_num].m			= (double)*mxGetPr(dval); break;
						case  6: MyRayData[elem_num].n			= (double)*mxGetPr(dval); break;					    
						case  7: MyRayData[elem_num].opd		= (double)*mxGetPr(dval); break;
						case  8: MyRayData[elem_num].intensity	= (double)*mxGetPr(dval); break;					    
						case  9: MyRayData[elem_num].Exr		= (double)*mxGetPr(dval); break;
						case 10: MyRayData[elem_num].Exi		= (double)*mxGetPr(dval); break;
					    case 11: MyRayData[elem_num].Eyr		= (double)*mxGetPr(dval); break;
						case 12: MyRayData[elem_num].Eyi		= (double)*mxGetPr(dval); break;
					    case 13: MyRayData[elem_num].Exr		= (double)*mxGetPr(dval); break;
						case 14: MyRayData[elem_num].Ezi		= (double)*mxGetPr(dval); break;
					    case 15: MyRayData[elem_num].wave		= (int)*mxGetPr(dval); break;
						case 16: MyRayData[elem_num].error		= (int)*mxGetPr(dval); break;
					    case 17: MyRayData[elem_num].vigcode	= (int)*mxGetPr(dval); break;
						case 18: MyRayData[elem_num].want_opd	= (int)*mxGetPr(dval); break;
						} break;
				case mxSINGLE_CLASS : // The data is a single precision float
					 // mexPrintf("%f\n", *(float *)mxGetData(dval)); //debug
					 switch (FieldIndex)
						{
					    case  1: MyRayData[elem_num].x			= (double)*(float *)mxGetData(dval); break;
						case  2: MyRayData[elem_num].y			= (double)*(float *)mxGetData(dval); break;
					    case  3: MyRayData[elem_num].z			= (double)*(float *)mxGetData(dval); break;
						case  4: MyRayData[elem_num].l			= (double)*(float *)mxGetData(dval); break;					    
						case  5: MyRayData[elem_num].m			= (double)*(float *)mxGetData(dval); break;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本一区二区三级电影在线观看 | 国产盗摄一区二区三区| 国产精品乱人伦一区二区| 在线成人小视频| 99精品欧美一区| 久久99国产精品麻豆| 一级做a爱片久久| 国产精品免费看片| 欧美xxx久久| 欧美乱妇15p| 日本精品一级二级| 成人免费观看av| 国产一区91精品张津瑜| 视频在线观看一区| 亚洲一区二区三区四区五区黄| 国产亚洲一区二区在线观看| 欧美一区二区三区免费大片| 色综合久久久网| 成人av电影在线| 国产精品一二三四| 久久国产欧美日韩精品| 婷婷开心久久网| 亚洲图片自拍偷拍| 一区二区三区电影在线播| 国产精品久久久久aaaa樱花| 国产在线精品免费| 青椒成人免费视频| 日日夜夜一区二区| 午夜国产不卡在线观看视频| 一区二区三区中文字幕精品精品| 中文字幕亚洲在| 中文字幕一区二区三区av| 国产日韩欧美一区二区三区乱码 | 久久久亚洲精品一区二区三区| 4438成人网| 制服丝袜日韩国产| 9191成人精品久久| 欧美精品乱人伦久久久久久| 欧美性一二三区| 精品视频一区二区三区免费| 欧洲国内综合视频| 欧美日韩中文字幕一区二区| 欧美亚洲国产一区在线观看网站| 91极品视觉盛宴| 在线观看区一区二| 欧美高清视频不卡网| 欧美一区二区精品久久911| 日韩一区和二区| 2023国产精品自拍| 国产调教视频一区| 自拍偷拍欧美激情| 亚洲国产另类av| 视频一区中文字幕| 精品夜夜嗨av一区二区三区| 国产精品一区二区免费不卡 | 色呦呦日韩精品| 欧美日韩在线播放三区| 91麻豆精品91久久久久久清纯| 在线综合视频播放| 国产日韩欧美高清| 亚洲日本青草视频在线怡红院| 一区二区不卡在线视频 午夜欧美不卡在 | 欧美羞羞免费网站| 日韩欧美自拍偷拍| 欧美国产日韩精品免费观看| 亚洲精品亚洲人成人网在线播放| 香蕉久久夜色精品国产使用方法| 免费成人性网站| 成人国产精品免费| 欧美日韩卡一卡二| 欧美精品一区二区三区高清aⅴ| 国产色91在线| 亚洲一区成人在线| 狠狠色丁香久久婷婷综合_中| 成人网页在线观看| 9191成人精品久久| 国产精品嫩草影院com| 亚洲大尺度视频在线观看| 国产精品一区二区久激情瑜伽| 一本到不卡免费一区二区| 日韩欧美国产一区二区三区 | 捆绑紧缚一区二区三区视频| 成人性生交大片免费看视频在线| 91国产视频在线观看| 精品成人a区在线观看| 亚洲欧美日韩一区| 国模冰冰炮一区二区| 欧美亚洲国产bt| 欧美极品xxx| 欧美精品高清视频| 国产精品国产成人国产三级| 日本不卡1234视频| 91官网在线免费观看| 久久亚洲精精品中文字幕早川悠里| 亚洲主播在线观看| 成人亚洲精品久久久久软件| 日韩一级大片在线| 一区二区三区丝袜| 国产69精品久久久久毛片| 3d成人h动漫网站入口| 亚洲日本丝袜连裤袜办公室| 国内精品嫩模私拍在线| 欧美吻胸吃奶大尺度电影| 欧美高清一级片在线观看| 看电影不卡的网站| 欧美日韩午夜在线视频| 中文字幕亚洲视频| 国产91精品在线观看| 欧美大片在线观看一区| 亚洲国产一区二区三区 | 一本久久综合亚洲鲁鲁五月天| 精品理论电影在线| 水野朝阳av一区二区三区| 91丨porny丨最新| 国产精品三级av| 国产麻豆成人传媒免费观看| 欧美一区二区三级| 午夜精品久久久久影视| 在线影院国内精品| 亚洲欧美自拍偷拍| 成人动漫一区二区| 久久久国产精华| 国产在线观看一区二区| 精品少妇一区二区三区免费观看 | 国产精品一区二区三区网站| 欧美一级搡bbbb搡bbbb| 三级成人在线视频| 亚洲精品成人天堂一二三| 成人性生交大片免费看在线播放| 久久亚洲私人国产精品va媚药| 久久66热re国产| 欧美成人a视频| 精品一区二区三区在线播放| 日韩欧美在线影院| 美女视频黄频大全不卡视频在线播放| 欧美美女一区二区在线观看| 亚洲国产三级在线| 7777精品伊人久久久大香线蕉超级流畅 | 最新不卡av在线| 91在线视频18| 一区二区免费在线| 欧美日韩激情在线| 日韩电影在线一区| 日韩一区二区三区电影| 激情小说欧美图片| 中文在线免费一区三区高中清不卡| 国产一区二区三区最好精华液| 久久久久久夜精品精品免费| 国产精品91一区二区| 国产精品理论在线观看| av福利精品导航| 亚洲一区中文在线| 欧美一区二区视频在线观看2022 | 国产一区二区三区精品视频| 国产日韩影视精品| 95精品视频在线| 午夜视频在线观看一区| 日韩限制级电影在线观看| 国产自产高清不卡| 亚洲同性gay激情无套| 欧美三级三级三级爽爽爽| 美女精品一区二区| 欧美国产视频在线| 欧美在线小视频| 精品制服美女丁香| 国产精品电影一区二区| 欧美在线|欧美| 激情久久五月天| 亚洲靠逼com| 日韩欧美123| 97se亚洲国产综合自在线| 香港成人在线视频| 国产亚洲精品bt天堂精选| 色欲综合视频天天天| 捆绑紧缚一区二区三区视频| 国产精品女主播av| 538在线一区二区精品国产| 国产精品中文字幕一区二区三区| 日韩一区在线看| 日韩一区二区三区观看| 成人av在线一区二区| 日本免费在线视频不卡一不卡二| 国产日韩亚洲欧美综合| 欧美日韩精品电影| 成人av网址在线| 免费成人在线观看| 99久久国产综合精品麻豆| 日本v片在线高清不卡在线观看| 国产日韩精品一区| 91精品国产一区二区三区蜜臀 | 色综合天天狠狠| 老司机免费视频一区二区三区| 一区在线观看视频| 精品国产露脸精彩对白| 欧美色视频一区| 成人av免费在线播放| 国产在线观看一区二区| 日韩高清不卡一区二区| 亚洲欧美日本韩国| 国产欧美日韩亚州综合 |