#ifndef __SCRIPTOR_H__ #define __SCRIPTOR_H__ /* * File : scriptor.h * COPYRIGHT (C) 2012 - 2014, Shenzhen Besting Co., Ltd. Geomative R&D Team . * * Change Logs: * Date Author Notes * 2014-11-28 jimmy.lee initial implementation * 2014-11-28 by jimmy.lee 关于3D脚本相关算法及接口已经全部开发完毕.包括脚本格式及生成. 具体API参考scriptor.h 运行demo.exe生成脚本. 用法: void scr(const char *name, int only45, int x0, int y0, int x1, int y1, int zonec, ...); demo.exe示例: scr("Pole-Pole", 45, 4,5,6,7, 4, 0,1,2,3) scr("Pole-Dipole", 45, 1,1,6,9, 4, 0,1,2,3) scr("Dipole-Dipole", 45, 1,1,12,12, 4, 0,1,2,3) */ #include #ifdef __cplusplus extern "C" { #endif /* 备注: 由于VC6不支持C99,故C中没有bool类型 但由于程序由C++和C组成,编译成Dll会产生莫名的错误,故在此将bool转换成int */ // typedef unsigned bool; // #define false 0 // #define true 1 struct _pos { int x; int y; }; struct _rect { int x0, y0; int x1, y1; // int distance_x, distance_y; //add by waston }; //typedef struct _pos _pos; struct _point { struct _point *next, *prev; struct _pos C1, C2, P1, P2; int TSN; int A, B, M, N; double KS; int SF; void *user_data; }; //typedef struct _point _point; //class CGeoScriptor struct _scriptor; enum _medium_3d_type { MEDIUM_TYPE_UNKNOW = -1, MEDIUM_TYPE_PolePole = 22, MEDIUM_TYPE_PoleDipole = 23, MEDIUM_TYPE_DipoleDipole = 24, MEDIUM_TYPE_Schlumberger = 25, MEDIUM_TYPE_WennerAlfa = 26, MEDIUM_TYPE_WennerBeta = 27, MEDIUM_TYPE_Gradient = 28, }; #define ONLY_45DIAGONAL 0x01 // #define rect_width(r) (abs((r)->x1 - (r)->x0)) // #define rect_height(r) (abs((r)->y1 - (r)->y0)) int rect_width(struct _rect *r); int rect_height(struct _rect *r); void rect_init(struct _rect *r, int x0, int y0, int x1, int y1); // API: /* 获取scriptor名称. */ const char *scr_get_name(struct _scriptor *scr); /* 设置scriptor名称, 返回装置类型(medium_type). 只有三种名称是有效的: "Pole-Pole" : 返回 MEDIUM_TYPE_PolePole; "Pole-Dipole" : 返回 MEDIUM_TYPE_PoleDipole; "Dipole-Dipole" : 返回 MEDIUM_TYPE_DipoleDipole; */ int scr_set_name(struct _scriptor *scr, const char *name); /* 获取/设置scriptor矩阵rect. */ struct _rect *scr_get_rect(struct _scriptor *scr); void scr_set_rect(struct _scriptor *scr, struct _rect *rect); /* 获取scriptor电极总数. */ int scr_get_pole_count(struct _scriptor *scr); /* 设置初始的电极位置. tag:"C1"/"C2"/"P1"/"P2" x,y:待设的坐标. */ int scr_init_pole(struct _scriptor *scr, const char *tag, int x, int y); /* 2015.6.18新增的接口: */ int scr_set_pole_step(struct _scriptor *scr, int x_step, int y_step); int scr_get_pole_step(struct _scriptor *scr, int *x_step, int *y_step); int scr_set_spacing(struct _scriptor *scr, double spacing_x, double spacing_y); int scr_get_spacing(struct _scriptor *scr, double *spacing_x, double *spacing_y); /* 获取/设置scriptor起始电极. */ int scr_get_pole_start(struct _scriptor *scr); //BOOL scr_set_pole_start(struct _scriptor *scr, int startpole); int scr_set_pole_start(struct _scriptor *scr, int startpole); /* 设置scriptor生成的测点方向(区域),即以C1为参考点,其它点相对C1所在的方向(区域). 参数enable: 是否是能所设zones. (6) (5)\ | /(7) (4) - - (0) o---> (x) (3)/ | \(1) | (2) v (y) 示例: int zone1[4] = {0,1,2,3}; int zone2[2] = {1,3}; scr_set_zone(scr, true, 4, zone1); // 0,1,2,3区域使能(生成) scr_set_zone(scr, false, 2, zone2); // 取消1,3区域生成 */ //void scr_set_zone(struct _scriptor *scr, bool enable, int zonec, int zonev[]); void scr_set_zone(struct _scriptor *scr, int enable, int zonec, int zonev[]); /* 获取zone_index对应的区域是否生成, 返回:true-该区生成, false-该区不生成. */ //BOOL scr_get_zone(struct _scriptor *scr, int zone_index); int scr_get_zone(struct _scriptor *scr, int zone_index); /* 获取装置类型medium_type */ int scr_get_type(struct _scriptor *scr); /* 获取/设置scriptor flags. flags: ONLY_45DIAGONAL or NOT. */ unsigned int scr_get_flags(struct _scriptor *scr); //void scr_set_flags(struct _scriptor *scr, unsigned int flags, BOOL enable); void scr_set_flags(struct _scriptor *scr, unsigned int flags, int enable); /* 获取/追加/移除/清空scriptor的测点. */ struct _point *scr_get_points(struct _scriptor *scr); void scr_append_points(struct _scriptor *scr, struct _point *points); void scr_remove_point(struct _scriptor *scr, struct _point *point); void scr_flush_points(struct _scriptor *scr); /* 执行测点生成. */ //BOOL scr_generate(struct _scriptor *scr); int scr_generate(struct _scriptor *scr); /* scriptor初始化/创建/销毁 flags: ONLY_45DIAGONAL or NOT. */ int scr_init(struct _scriptor *scr, const char *name, int flags, struct _rect *rect, int zonec, int zonev[]); //BOOL scr_init(struct _scriptor *scr, const char *name, int flags, struct _rect *rect, int zonec, int zonev[]); struct _scriptor *scr_create(const char *name, int flags, struct _rect *rect, int zone_count, ...); void scr_destroy(struct _scriptor *scr); /* _pos坐标与_pole电极号 互转. rect:所在矩阵rect. start:起始电极 */ int pos_to_pole(struct _rect *rect, int start, int x_step, int y_step, struct _pos *pos); //BOOL pole_to_pos(struct _rect *rect, int start, struct _pos *pos, int pole); int pole_to_pos(struct _rect *rect, int start, int x_step, int y_step, struct _pos *pos, int pole); int pole_to_pos_3d(struct _rect *rect, int start, int x_step, int y_step, struct _pos *pos, int iElecNum, int iLineDirection); int pole_to_pos_by_normal_axis(struct _rect *rect, int start, int x_step, int y_step, struct _pos *pos, int pole); int pos_to_pole_by_normal_axis(struct _rect *rect, int start, int x_step, int y_step, struct _pos *pos, int pole); #ifdef __cplusplus } #endif #endif