关于几何关系的代码说明
很多朋友需要这方面的资料,尤其是代码。我在陆续挖掘和整理的过程中,推翻了自己的开源的设想,形成了一个库——cgal32.dll(win32版,标准C库)。
一、这是基于几个原因:
1、库中个别地方代码采用了非商业开源的代码。我没有权利去公开它们。
2、只有不开源,我写的库大家才能免费使用。免除大家在道德和法律上面临的风险。
3、我做了大量工作,使自己本身免除道德和法律上的风险。
4、我声明我个人拥有这些库(编译后)的版权。今后任何个人和公司可以免费使用库,但不能声明拥有版权(或其他权利,包括出售库本身的权利)。我拥有库的源代码90%以上的版权。
二、关于cgal32.dll:
1、cgal32.dll与CGAL开源项目(www.cgal.org)没有任何关系,我也没看过和下载过它们的代码。
2、我使用ANSI C构建cgal32.dll库,以使其适应跨平台的需要。虽然目前只有WIN32版本,但以后会出LINUX等版本。
3、cgal32.dll主要完成空间几何的定义和运算。空间几何包括:点(点集)、线(多线)、面、体和面片。运算包括:Union、Difference、XOR、Intersection。
4、我的目标是把cgal32发展成为具有巨大潜力的解决人们在空间几何领域的诸多问题。
5、目前功能简单,还不提供下载,请谅解。
三、附部分头文件:
/*=============================================================================
cgal.h
cheungmine-Allrightsreserved
Sep.8,2010
==============================================================================*/
#ifndef_CGAL_H_INCLUDED
#define _CGAL_H_INCLUDED
#include < stdio.h >
#include < float .h >
#include < assert.h >
#include < memory.h >
#ifdef__cplusplus
extern " C " ... {
#endif
#ifdefCGAL_DLLEXPORT
#defineCGAL_CALL__declspec(dllexport)
#defineCGAL_CALL1(x)__declspec(dllexport)x
#endif
#ifndefCGAL_CALL
#defineCGAL_CALL
#endif
#ifndefCGAL_CALL1
#defineCGAL_CALL1(x)xCGAL_CALL/**//*Forexample:CGAL_CALL1(char*)foo();*/
#endif
#include"cgalerr.h"
#include"cgaldef.h"
/**//*==============================================================================
LibraryFunctions-cgal.c
==============================================================================*/
voidCGAL_CALLCGAL_init(doubleepsilon);/**//*mustcallthisfirstofallinprocess-wide*/
voidCGAL_CALLCGAL_fini(intreserved);
BOOLCGAL_CALLCGAL_blob_alloc(cg_blob_t*blob);
voidCGAL_CALLCGAL_blob_free(cg_blob_t*blob);
doubleCGAL_CALLCGAL_get_epsilon();/**//*Smallestsuchthatx+epsilon!=x*/
intCGAL_CALLCGAL_get_precision();/**//*decimaldigitsofprecision*/
CGAL_CALL1(constchar*)CGAL_get_result_msg(intrcode);
RESULTCGAL_CALLCGAL_gzip_deflate(cg_blob_t*in_plain,cg_blob_t*out_compressed);/**//*compress*/
RESULTCGAL_CALLCGAL_gzip_inflate(cg_blob_t*in_compressed,cg_blob_t*out_decompressed);/**//*uncompress*/
/**//*==============================================================================
PolygonFunctions-polygon.c
==============================================================================*/
BOOLCGAL_CALLCG_polygon_create(cg_polygon*polygon);
voidCGAL_CALLCG_polygon_destroy(cg_polygonpolygon);
voidCGAL_CALLCG_polygon_clear(cg_polygonpolygon);
voidCGAL_CALLCG_polygon_read(FILE*infile,cg_polygonpolygon);
voidCGAL_CALLCG_polygon_write(FILE*outfile,constcg_polygonpolygon);
voidCGAL_CALLCG_polygon_add_part(cg_polygonpolygon,constcg_vertexlist_t*part,intis_hole);
BOOLCGAL_CALLCG_polygon_is_null(constcg_polygonpolygon);
intCGAL_CALLCG_polygon_get_parts(constcg_polygonpolygon,int*part_holes/**//*calleeallocmemory,NULLforretrievingpartscount.*/);
intCGAL_CALLCG_polygon_get_vertices(constcg_polygonpolygon,intpart_index,cg_vertex_t*vertices/**//*calleeallocmemory,NULLforretrievingverticescountofpartbyindex*/);
BOOLCGAL_CALLCG_polygon_part_is_hole(constcg_polygonpolygon,intpart_index);
doubleCGAL_CALLCG_polygon_get_area(constcg_polygonpolygon);
doubleCGAL_CALLCG_polygon_get_length(constcg_polygonpolygon);
voidCGAL_CALLCG_polygon_get_extent(constcg_polygonpolygon,cg_rect_t*extent);
BOOLCGAL_CALLCG_polygon_get_relation(CG_RELATIONrel,cg_polygonprimary,cg_polygonsecondary);
voidCGAL_CALLCG_polygon_clip(CG_OPCLIPopclip,cg_polygonsubject,cg_polygonclip,cg_polygonresult);
voidCGAL_CALLCG_polygon_makeup(cg_polygonpolygon);
voidCGAL_CALLCG_polygon_copy(constcg_polygoninpl,cg_polygonoutpl);
BOOLCGAL_CALLCG_polygon_pt_inside(constcg_polygonpolygon,constcg_vertex_t*pt);
voidCGAL_CALLCG_polygon_to_tristrip(cg_polygonpolygon,cg_tristriptristrip);
voidCGAL_CALLCG_rect_to_polygon(constcg_rect_t*rc,cg_polygonoutpl);
voidCGAL_CALLCG_circle_to_polygon(doublecenter_xp,doublecenter_yp,doubleradius,intmax_circle_points,cg_polygonoutpl);
voidCGAL_CALLCG_line_make_buffer(constcg_vertex_t*start,constcg_vertex_t*end,doubledistance,intmcp,cg_polygonout_pl);
voidCGAL_CALLCG_vertices_make_buffer(constcg_vertex_t*vertices,intnum_vertices,doubledistance,intmcp,cg_polygonoutpl);
voidCGAL_CALLCG_polyline_make_buffer(constcg_vertexlist_t*vl,doubledistance,intmcp,intclosed,cg_polygonout_pl);
voidCGAL_CALLCG_polygon_make_buffer(cg_polygoninpl,doubledistance,intmcp,cg_polygonoutpl);
/**//*==============================================================================
Trilist/Trinet/Trifan/TristripFunctions-tri.c
==============================================================================*/
BOOLCGAL_CALLCG_tristrip_create(cg_tristrip*tristrip);
voidCGAL_CALLCG_tristrip_free(cg_tristriptristrip);
intCGAL_CALLCG_tristrip_get_strips(constcg_tristriptristrip);
intCGAL_CALLCG_tristrip_get_vertices(constcg_tristriptristrip,intstrip_index,cg_vertex_t*vertices);
voidCGAL_CALLCG_tristrip_clip(CG_OPCLIPopclip,cg_polygonsubject,cg_polygonclip,cg_tristripresult);
/**//*==============================================================================
VertexandLineFunctions-cgal.c
==============================================================================*/
doubleCGAL_CALLCG_vertex_get_dist(constcg_vertex_t*p,constcg_vertex_t*q);
doubleCGAL_CALLCG_vertex_get_dist_sq(constcg_vertex_t*p,constcg_vertex_t*q);
doubleCGAL_CALLCG_vertex_get_area(constcg_vertex_t*vl,intnum_vertices);
doubleCGAL_CALLCG_vertex_get_length(constcg_vertex_t*vl,intnum_vertices,intclosed);
voidCGAL_CALLCG_vertex_get_extent(constcg_vertex_t*vl,intnum_vertices,cg_rect_t*rc);
BOOLCGAL_CALLCG_vertex_is_equal(constcg_vertex_t*p,constcg_vertex_t*q);
voidCGAL_CALLCG_vertex_offset(cg_vertex_t*vertices,intnum_vertices,doubledx,doubledy);
BOOLCGAL_CALLCG_line_offset(cg_vertex_t*start,cg_vertex_t*end,doubled);/**//*d>0totheleft,d<0totheright*/
BOOLCGAL_CALLCG_vertices_pt_inside(constcg_vertex_t*vertices,intnum_vertices,constcg_vertex_t*pt);
/**//*==============================================================================
RectFunctions-cgal.c
==============================================================================*/
BOOLCGAL_CALLCG_rect_pt_inside(constcg_rect_t*rect,constcg_vertex_t*pt);
BOOLCGAL_CALLCG_rect_is_overlapped(constcg_rect_t*rc1,constcg_rect_t*rc2);
BOOLCGAL_CALLCG_rect_clip_line(constcg_rect_t*rect,cg_vertex_t*p,cg_vertex_t*q);
/**//*==============================================================================
ShapeFunctions-shape.c
==============================================================================*/
BOOLCGAL_CALLCG_shape_create(cg_shape*shape);
voidCGAL_CALLCG_shape_destroy(cg_shapeshape);
voidCGAL_CALLCG_shape_clear(cg_shapeshape);
voidCGAL_CALLCG_shape_read(FILE*infile,cg_shapeshape);
voidCGAL_CALLCG_shape_write(FILE*outfile,constcg_shapeshape);
size_tCGAL_CALLCG_shape_get_byte_size(constcg_shapeshape);
RESULTCGAL_CALLCG_shape_read_blob(constcg_blob_t*blob,cg_shapeshape);
size_tCGAL_CALLCG_shape_write_blob(cg_blob_t*blob,constcg_shapeshape);
voidCGAL_CALLCG_shape_copy(constcg_shapein_shape,cg_shapeout_shape);
BOOLCGAL_CALLCG_shape_is_null(constcg_shapeshape);
intCGAL_CALLCG_shape_get_type(constcg_shapeshape);
intCGAL_CALLCG_shape_get_parts(constcg_shapeshape,int*part_offsets);
intCGAL_CALLCG_shape_get_subparts(constcg_shapeshape,intpart_index,int*subpart_offsets);
intCGAL_CALLCG_shape_get_vertices(constcg_shapeshape,intpart_index,intsubpart_index,cg_vertex_t*vertices);
intCGAL_CALLCG_shape_get_all_subparts(constcg_shapeshape,int*subpart_offsets);
intCGAL_CALLCG_shape_get_all_vertices(constcg_shapeshape,cg_vertex_t*vertices);
voidCGAL_CALLCG_polygon_to_shape(cg_polygonpl,cg_shapesp);
voidCGAL_CALLCG_shapeto_polygon(constcg_shapesp,cg_polygonpl);
/**//*==============================================================================
ObjectFunctions-object.c
==============================================================================*/
/**//*==============================================================================
GemoetryFunctions-geometry.c
==============================================================================*/
BOOLCGAL_CALLCG_geometry_create(cg_geometry*g);
voidCGAL_CALLCG_geometry_destroy(cg_geometryg);
voidCGAL_CALLCG_geometry_clear(cg_geometryg);
BOOLCGAL_CALLCG_geometry_is_null(constcg_geometryg);
size_tCGAL_CALLCG_geometry_get_byte_size(constcg_geometryg);
size_tCGAL_CALLCG_geometry_write_blob(cg_blob_t*blob,constcg_geometryg);
RESULTCGAL_CALLCG_geometry_read_blob(constcg_blob_t*blob,constcg_geometryg);
RESULTCGAL_CALLCG_shape_to_geometry(constcg_shapesp,cg_geometryg);
/**//*=============================================================================*/
#ifdef__cplusplus
}
#endif
#endif /*ndef_CGAL_H_INCLUDED*/
cgal.h
cheungmine-Allrightsreserved
Sep.8,2010
==============================================================================*/
#ifndef_CGAL_H_INCLUDED
#define _CGAL_H_INCLUDED
#include < stdio.h >
#include < float .h >
#include < assert.h >
#include < memory.h >
#ifdef__cplusplus
extern " C " ... {
#endif
#ifdefCGAL_DLLEXPORT
#defineCGAL_CALL__declspec(dllexport)
#defineCGAL_CALL1(x)__declspec(dllexport)x
#endif
#ifndefCGAL_CALL
#defineCGAL_CALL
#endif
#ifndefCGAL_CALL1
#defineCGAL_CALL1(x)xCGAL_CALL/**//*Forexample:CGAL_CALL1(char*)foo();*/
#endif
#include"cgalerr.h"
#include"cgaldef.h"
/**//*==============================================================================
LibraryFunctions-cgal.c
==============================================================================*/
voidCGAL_CALLCGAL_init(doubleepsilon);/**//*mustcallthisfirstofallinprocess-wide*/
voidCGAL_CALLCGAL_fini(intreserved);
BOOLCGAL_CALLCGAL_blob_alloc(cg_blob_t*blob);
voidCGAL_CALLCGAL_blob_free(cg_blob_t*blob);
doubleCGAL_CALLCGAL_get_epsilon();/**//*Smallestsuchthatx+epsilon!=x*/
intCGAL_CALLCGAL_get_precision();/**//*decimaldigitsofprecision*/
CGAL_CALL1(constchar*)CGAL_get_result_msg(intrcode);
RESULTCGAL_CALLCGAL_gzip_deflate(cg_blob_t*in_plain,cg_blob_t*out_compressed);/**//*compress*/
RESULTCGAL_CALLCGAL_gzip_inflate(cg_blob_t*in_compressed,cg_blob_t*out_decompressed);/**//*uncompress*/
/**//*==============================================================================
PolygonFunctions-polygon.c
==============================================================================*/
BOOLCGAL_CALLCG_polygon_create(cg_polygon*polygon);
voidCGAL_CALLCG_polygon_destroy(cg_polygonpolygon);
voidCGAL_CALLCG_polygon_clear(cg_polygonpolygon);
voidCGAL_CALLCG_polygon_read(FILE*infile,cg_polygonpolygon);
voidCGAL_CALLCG_polygon_write(FILE*outfile,constcg_polygonpolygon);
voidCGAL_CALLCG_polygon_add_part(cg_polygonpolygon,constcg_vertexlist_t*part,intis_hole);
BOOLCGAL_CALLCG_polygon_is_null(constcg_polygonpolygon);
intCGAL_CALLCG_polygon_get_parts(constcg_polygonpolygon,int*part_holes/**//*calleeallocmemory,NULLforretrievingpartscount.*/);
intCGAL_CALLCG_polygon_get_vertices(constcg_polygonpolygon,intpart_index,cg_vertex_t*vertices/**//*calleeallocmemory,NULLforretrievingverticescountofpartbyindex*/);
BOOLCGAL_CALLCG_polygon_part_is_hole(constcg_polygonpolygon,intpart_index);
doubleCGAL_CALLCG_polygon_get_area(constcg_polygonpolygon);
doubleCGAL_CALLCG_polygon_get_length(constcg_polygonpolygon);
voidCGAL_CALLCG_polygon_get_extent(constcg_polygonpolygon,cg_rect_t*extent);
BOOLCGAL_CALLCG_polygon_get_relation(CG_RELATIONrel,cg_polygonprimary,cg_polygonsecondary);
voidCGAL_CALLCG_polygon_clip(CG_OPCLIPopclip,cg_polygonsubject,cg_polygonclip,cg_polygonresult);
voidCGAL_CALLCG_polygon_makeup(cg_polygonpolygon);
voidCGAL_CALLCG_polygon_copy(constcg_polygoninpl,cg_polygonoutpl);
BOOLCGAL_CALLCG_polygon_pt_inside(constcg_polygonpolygon,constcg_vertex_t*pt);
voidCGAL_CALLCG_polygon_to_tristrip(cg_polygonpolygon,cg_tristriptristrip);
voidCGAL_CALLCG_rect_to_polygon(constcg_rect_t*rc,cg_polygonoutpl);
voidCGAL_CALLCG_circle_to_polygon(doublecenter_xp,doublecenter_yp,doubleradius,intmax_circle_points,cg_polygonoutpl);
voidCGAL_CALLCG_line_make_buffer(constcg_vertex_t*start,constcg_vertex_t*end,doubledistance,intmcp,cg_polygonout_pl);
voidCGAL_CALLCG_vertices_make_buffer(constcg_vertex_t*vertices,intnum_vertices,doubledistance,intmcp,cg_polygonoutpl);
voidCGAL_CALLCG_polyline_make_buffer(constcg_vertexlist_t*vl,doubledistance,intmcp,intclosed,cg_polygonout_pl);
voidCGAL_CALLCG_polygon_make_buffer(cg_polygoninpl,doubledistance,intmcp,cg_polygonoutpl);
/**//*==============================================================================
Trilist/Trinet/Trifan/TristripFunctions-tri.c
==============================================================================*/
BOOLCGAL_CALLCG_tristrip_create(cg_tristrip*tristrip);
voidCGAL_CALLCG_tristrip_free(cg_tristriptristrip);
intCGAL_CALLCG_tristrip_get_strips(constcg_tristriptristrip);
intCGAL_CALLCG_tristrip_get_vertices(constcg_tristriptristrip,intstrip_index,cg_vertex_t*vertices);
voidCGAL_CALLCG_tristrip_clip(CG_OPCLIPopclip,cg_polygonsubject,cg_polygonclip,cg_tristripresult);
/**//*==============================================================================
VertexandLineFunctions-cgal.c
==============================================================================*/
doubleCGAL_CALLCG_vertex_get_dist(constcg_vertex_t*p,constcg_vertex_t*q);
doubleCGAL_CALLCG_vertex_get_dist_sq(constcg_vertex_t*p,constcg_vertex_t*q);
doubleCGAL_CALLCG_vertex_get_area(constcg_vertex_t*vl,intnum_vertices);
doubleCGAL_CALLCG_vertex_get_length(constcg_vertex_t*vl,intnum_vertices,intclosed);
voidCGAL_CALLCG_vertex_get_extent(constcg_vertex_t*vl,intnum_vertices,cg_rect_t*rc);
BOOLCGAL_CALLCG_vertex_is_equal(constcg_vertex_t*p,constcg_vertex_t*q);
voidCGAL_CALLCG_vertex_offset(cg_vertex_t*vertices,intnum_vertices,doubledx,doubledy);
BOOLCGAL_CALLCG_line_offset(cg_vertex_t*start,cg_vertex_t*end,doubled);/**//*d>0totheleft,d<0totheright*/
BOOLCGAL_CALLCG_vertices_pt_inside(constcg_vertex_t*vertices,intnum_vertices,constcg_vertex_t*pt);
/**//*==============================================================================
RectFunctions-cgal.c
==============================================================================*/
BOOLCGAL_CALLCG_rect_pt_inside(constcg_rect_t*rect,constcg_vertex_t*pt);
BOOLCGAL_CALLCG_rect_is_overlapped(constcg_rect_t*rc1,constcg_rect_t*rc2);
BOOLCGAL_CALLCG_rect_clip_line(constcg_rect_t*rect,cg_vertex_t*p,cg_vertex_t*q);
/**//*==============================================================================
ShapeFunctions-shape.c
==============================================================================*/
BOOLCGAL_CALLCG_shape_create(cg_shape*shape);
voidCGAL_CALLCG_shape_destroy(cg_shapeshape);
voidCGAL_CALLCG_shape_clear(cg_shapeshape);
voidCGAL_CALLCG_shape_read(FILE*infile,cg_shapeshape);
voidCGAL_CALLCG_shape_write(FILE*outfile,constcg_shapeshape);
size_tCGAL_CALLCG_shape_get_byte_size(constcg_shapeshape);
RESULTCGAL_CALLCG_shape_read_blob(constcg_blob_t*blob,cg_shapeshape);
size_tCGAL_CALLCG_shape_write_blob(cg_blob_t*blob,constcg_shapeshape);
voidCGAL_CALLCG_shape_copy(constcg_shapein_shape,cg_shapeout_shape);
BOOLCGAL_CALLCG_shape_is_null(constcg_shapeshape);
intCGAL_CALLCG_shape_get_type(constcg_shapeshape);
intCGAL_CALLCG_shape_get_parts(constcg_shapeshape,int*part_offsets);
intCGAL_CALLCG_shape_get_subparts(constcg_shapeshape,intpart_index,int*subpart_offsets);
intCGAL_CALLCG_shape_get_vertices(constcg_shapeshape,intpart_index,intsubpart_index,cg_vertex_t*vertices);
intCGAL_CALLCG_shape_get_all_subparts(constcg_shapeshape,int*subpart_offsets);
intCGAL_CALLCG_shape_get_all_vertices(constcg_shapeshape,cg_vertex_t*vertices);
voidCGAL_CALLCG_polygon_to_shape(cg_polygonpl,cg_shapesp);
voidCGAL_CALLCG_shapeto_polygon(constcg_shapesp,cg_polygonpl);
/**//*==============================================================================
ObjectFunctions-object.c
==============================================================================*/
/**//*==============================================================================
GemoetryFunctions-geometry.c
==============================================================================*/
BOOLCGAL_CALLCG_geometry_create(cg_geometry*g);
voidCGAL_CALLCG_geometry_destroy(cg_geometryg);
voidCGAL_CALLCG_geometry_clear(cg_geometryg);
BOOLCGAL_CALLCG_geometry_is_null(constcg_geometryg);
size_tCGAL_CALLCG_geometry_get_byte_size(constcg_geometryg);
size_tCGAL_CALLCG_geometry_write_blob(cg_blob_t*blob,constcg_geometryg);
RESULTCGAL_CALLCG_geometry_read_blob(constcg_blob_t*blob,constcg_geometryg);
RESULTCGAL_CALLCG_shape_to_geometry(constcg_shapesp,cg_geometryg);
/**//*=============================================================================*/
#ifdef__cplusplus
}
#endif
#endif /*ndef_CGAL_H_INCLUDED*/
/*
=============================================================================
cgaldef.h
cgaldef.h
cheungmine-Allrightsreserved
Sep.8,2007
============================================================================= */
#ifndef_CGALDEF_H_INCLUDED
#define _CGALDEF_H_INCLUDED
#ifndefCG_PI
#define CG_PI3.1415926535897932384626433832795
#endif
#ifndefCG_HFPI
#define CG_HFPI1.5707963267948966192313216916398
#endif
#ifndefCG_BIPI
#define CG_BIPI6.283185307179586476925286766559
#endif
#ifndefTRUE
#define FALSE0
#define TRUE1
#endif
typedef int BOOL;
typedefunsigned char BYTE;
typedefunsigned int size_t;
/* =============================================================================
OpaqueStructHandles
============================================================================= */
typedef struct _cg_polygon_t * cg_polygon;
typedef struct _cg_trilist_t * cg_trilist;
typedef struct _cg_trinet_t * cg_trinet;
typedef struct _cg_trifan_t * cg_trifan;
typedef struct _cg_tristrip_t * cg_tristrip;
typedef struct _cg_trilistZ_t * cg_trilistZ;
typedef struct _cg_trinetZ_t * cg_trinetZ;
typedef struct _cg_trifanZ_t * cg_trifanZ;
typedef struct _cg_tristripZ_t * cg_tristripZ;
typedef struct _cg_shape_t * cg_shape;
typedef struct _cg_arclist_t * cg_arclist;
typedef struct _cg_arclistZ_t * cg_arclistZ;
typedef struct _cg_object_t * cg_object;
typedef struct _cg_patch_t * cg_patch;
typedef struct _cg_patchZ_t * cg_patchZ;
typedef struct _cg_geometry_t * cg_geometry;
/* =============================================================================
PublicTypes
============================================================================= */
/* shapetype */
typedef enum
{
SHP_NULL = 0 , /* Nulltype */
SHP_POINT = 1 , /* Pointtype */
SHP_LINE = 2 , /* Linetype */
SHP_POLYGON = 3 /* Polygontype */
}CG_SHAPETYPE;
/* arctype */
typedef enum
{
ARC_LINE = 1 ,
ARC_CIRCLE_P = 2 ,
ARC_CIRCLE_C = 3 ,
ARC_ELLIPSE = 4 ,
ARC_SPLINE = 10 ,
ARC_BEZIER = 20
}CG_ARCTYPE;
/* 3DObjectTypes-standardobjectprimitives */
typedef enum
{
OBJ_BOX = 1 ,
OBJ_CONE = 2 ,
OBJ_SPERE = 3 ,
OBJ_HEMISPHERE = 4 ,
OBJ_GEOSPHERE = 5 ,
OBJ_CYLINDER = 6 ,
OBJ_TUBE = 7 ,
OBJ_TORUS = 8 ,
OBJ_PYRMID = 9 ,
OBJ_PLANE = 10
}CG_OBJECTTYPE;
/* extendedobjectprimitives */
typedef enum
{
OBJEX_ELLIPSOID = 16 ,
OBJEX_OVAL = 17 ,
OBJEX_HEDRA = 18 ,
OBJEX_CHAMFERBOX = 19 ,
OBJEX_CHAMFERCYL = 20 ,
OBJEX_SPINDLE = 21 ,
OBJEX_GENGON = 22 ,
OBJEX_PRISM = 23 ,
OBJEX_HOSE = 24 ,
OBJEX_L_EXT = 25 ,
OBJEX_C_EXT = 26 ,
OBJEX_CAPSULE = 27 ,
OBJEX_TORUSKNOT = 28 ,
OBJEX_OILTANK = 29 ,
OBJEX_RINGWAVE = 30 ,
OBJ_TEAPOT = 31
}CG_OBJECTTYPE_EX;
/* Patchtype */
typedef enum
{
PAT_TRILIST = 1 ,
PAT_TRINET = 2 ,
PAT_TRIFAN = 3 ,
PAT_TRISTRIP = 4
}CG_PATCHTYPE;
/* 3DPatchtype */
typedef enum
{
PAT_TRILISTZ = 5 ,
PAT_TRINETZ = 6 ,
PAT_TRIFANZ = 7 ,
PAT_TRISTRIPZ = 8
}CG_PATCHZTYPE;
/* Geometrytype */
typedef enum
{
GT_NULL = 0 ,
GT_SHAPE = 1 ,
GT_VERTEX = 2 ,
GT_VERTEXZ = 3 ,
GT_POLYLINE = 4 ,
GT_POLYLINEZ = 5 ,
GT_POLYGON = 6 ,
GT_ARCLIST = 7 , /* Compoundarcline */
GT_ARCLISTZ = 8 , /* Compoundarcwithz */
GT_PATCH = 9 ,
GT_PATCHZ = 10 ,
GT_OBJECT = 11 /* Object */
}CG_GEOMETRYTYPE;
/* =============================================================================
EnumConstants
============================================================================= */
typedef enum /* Setoperationtype */
{
CG_DIFF, /* Difference */
CG_INT, /* Intersection */
CG_XOR, /* Exclusiveor */
CG_UNION /* Union */
}CG_OPCLIP;
typedef enum /* relationships */
{
REL_CONTAIN = 0 , /* TRUEiftheprimaryshapewhollycontainsthesecondaryshape */
REL_CROSS = 1 , /* TRUEiftheintersectionoftheinteriorsisalowerdimensionthanthemaximumdimensionofthetwoshapes */
REL_DISJOINT = 2 , /* TRUEiftheintersectionoftwoshapesisempty */
REL_EQUAL = 3 , /* TRUEifthetwosuppliedshapesareidentical */
REL_OVERLAP = 4 , /* TRUEiftheintersectionoftwoshapesresultsinanobjectofthesamegeometricdimension */
REL_TOUCH = 5 , /* TRUEifthetwosuppliedshapesshareacommonboundary */
REL_WITHIN = 6 /* TRUEifprimary_shapeiswhollycontainedwithinsecondary_shape */
}CG_RELATION;
/* =============================================================================
PublicStructTypes
============================================================================= */
/* Vertexstructure */
typedef struct
{
union{
struct { double x,y;};
double _v[ 2 ];
};
}cg_vertex_t,cg_point_t;
/* Linestructure */
typedef struct
{
union{
struct { double x1,y1,x2,y2;};
struct {cg_point_tstart,end;};
cg_point_t_p[ 2 ];
double _v[ 4 ];
};
}cg_edge_t,cg_line_t;
/* Vertexliststructure */
typedef struct
{
int num_vertices; /* Numberofverticesinlist */
cg_vertex_t * vertex; /* Vertexarraypointer */
}cg_vertexlist_t,cg_pointlist_t,cg_polyline_t;
/* rectangletype */
typedef struct
{
union{
struct {
union{
struct { double min_x,min_y;};
cg_vertex_t_min;
};
union{
struct { double max_x,max_y;};
cg_vertex_t_max;
};
};
double _v[ 4 ];
};
}cg_rect_t;
/* 3Drect-boxtype */
typedef struct
{
union{
struct {
union{
struct { double min_x,min_y,max_x,max_y;};
cg_rect_t_rc;
};
double min_z,max_z;
};
double _v[ 6 ];
};
}cg_rectZ_t,cg_box_t;
/* circleCRstruct */
typedef struct
{
union{
struct { double xp,yp;};
cg_vertex_t_cp;
};
double r;
}cg_circle_t;
/* Pointstructure */
typedef struct
{
union{
struct {
union{
struct { double x,y;};
cg_vertex_t_p;
};
double z;
};
double _v[ 3 ];
};
}cg_vector_t,cg_pointZ_t,cg_vertexZ_t;
/* 3DVertexliststructure */
typedef struct
{
int num_vertices; /* Numberofvertices */
cg_vector_t * vertex; /* Vertexarray */
}cg_vectorlist_t,cg_pointlistZ_t,cg_vertexlistZ_t;
/* Trianglestruct */
typedef struct
{
union{
struct {cg_vertex_tv0,v1,v2;};
cg_vertex_t_v[ 3 ];
};
}cg_tri_t;
/* 3DTrianglestruct */
typedef struct
{
union{
struct {cg_vector_tv0,v1,v2;};
cg_vector_t_v[ 3 ];
};
cg_vector_tn; /* Normalvector */
}cg_triZ_t;
/* trianglevertexindexstruct */
typedef struct
{
union{
struct { int i0,i1,i2;};
int _vi[ 3 ];
};
}cg_triindex_t;
/* BLOBstruct */
typedef struct
{
BYTE * chunk;
size_tsize;
}cg_blob_t;
/* ============================================================================ */
#endif /*ndef_CGALDEF_H_INCLUDED*/
Sep.8,2007
============================================================================= */
#ifndef_CGALDEF_H_INCLUDED
#define _CGALDEF_H_INCLUDED
#ifndefCG_PI
#define CG_PI3.1415926535897932384626433832795
#endif
#ifndefCG_HFPI
#define CG_HFPI1.5707963267948966192313216916398
#endif
#ifndefCG_BIPI
#define CG_BIPI6.283185307179586476925286766559
#endif
#ifndefTRUE
#define FALSE0
#define TRUE1
#endif
typedef int BOOL;
typedefunsigned char BYTE;
typedefunsigned int size_t;
/* =============================================================================
OpaqueStructHandles
============================================================================= */
typedef struct _cg_polygon_t * cg_polygon;
typedef struct _cg_trilist_t * cg_trilist;
typedef struct _cg_trinet_t * cg_trinet;
typedef struct _cg_trifan_t * cg_trifan;
typedef struct _cg_tristrip_t * cg_tristrip;
typedef struct _cg_trilistZ_t * cg_trilistZ;
typedef struct _cg_trinetZ_t * cg_trinetZ;
typedef struct _cg_trifanZ_t * cg_trifanZ;
typedef struct _cg_tristripZ_t * cg_tristripZ;
typedef struct _cg_shape_t * cg_shape;
typedef struct _cg_arclist_t * cg_arclist;
typedef struct _cg_arclistZ_t * cg_arclistZ;
typedef struct _cg_object_t * cg_object;
typedef struct _cg_patch_t * cg_patch;
typedef struct _cg_patchZ_t * cg_patchZ;
typedef struct _cg_geometry_t * cg_geometry;
/* =============================================================================
PublicTypes
============================================================================= */
/* shapetype */
typedef enum
{
SHP_NULL = 0 , /* Nulltype */
SHP_POINT = 1 , /* Pointtype */
SHP_LINE = 2 , /* Linetype */
SHP_POLYGON = 3 /* Polygontype */
}CG_SHAPETYPE;
/* arctype */
typedef enum
{
ARC_LINE = 1 ,
ARC_CIRCLE_P = 2 ,
ARC_CIRCLE_C = 3 ,
ARC_ELLIPSE = 4 ,
ARC_SPLINE = 10 ,
ARC_BEZIER = 20
}CG_ARCTYPE;
/* 3DObjectTypes-standardobjectprimitives */
typedef enum
{
OBJ_BOX = 1 ,
OBJ_CONE = 2 ,
OBJ_SPERE = 3 ,
OBJ_HEMISPHERE = 4 ,
OBJ_GEOSPHERE = 5 ,
OBJ_CYLINDER = 6 ,
OBJ_TUBE = 7 ,
OBJ_TORUS = 8 ,
OBJ_PYRMID = 9 ,
OBJ_PLANE = 10
}CG_OBJECTTYPE;
/* extendedobjectprimitives */
typedef enum
{
OBJEX_ELLIPSOID = 16 ,
OBJEX_OVAL = 17 ,
OBJEX_HEDRA = 18 ,
OBJEX_CHAMFERBOX = 19 ,
OBJEX_CHAMFERCYL = 20 ,
OBJEX_SPINDLE = 21 ,
OBJEX_GENGON = 22 ,
OBJEX_PRISM = 23 ,
OBJEX_HOSE = 24 ,
OBJEX_L_EXT = 25 ,
OBJEX_C_EXT = 26 ,
OBJEX_CAPSULE = 27 ,
OBJEX_TORUSKNOT = 28 ,
OBJEX_OILTANK = 29 ,
OBJEX_RINGWAVE = 30 ,
OBJ_TEAPOT = 31
}CG_OBJECTTYPE_EX;
/* Patchtype */
typedef enum
{
PAT_TRILIST = 1 ,
PAT_TRINET = 2 ,
PAT_TRIFAN = 3 ,
PAT_TRISTRIP = 4
}CG_PATCHTYPE;
/* 3DPatchtype */
typedef enum
{
PAT_TRILISTZ = 5 ,
PAT_TRINETZ = 6 ,
PAT_TRIFANZ = 7 ,
PAT_TRISTRIPZ = 8
}CG_PATCHZTYPE;
/* Geometrytype */
typedef enum
{
GT_NULL = 0 ,
GT_SHAPE = 1 ,
GT_VERTEX = 2 ,
GT_VERTEXZ = 3 ,
GT_POLYLINE = 4 ,
GT_POLYLINEZ = 5 ,
GT_POLYGON = 6 ,
GT_ARCLIST = 7 , /* Compoundarcline */
GT_ARCLISTZ = 8 , /* Compoundarcwithz */
GT_PATCH = 9 ,
GT_PATCHZ = 10 ,
GT_OBJECT = 11 /* Object */
}CG_GEOMETRYTYPE;
/* =============================================================================
EnumConstants
============================================================================= */
typedef enum /* Setoperationtype */
{
CG_DIFF, /* Difference */
CG_INT, /* Intersection */
CG_XOR, /* Exclusiveor */
CG_UNION /* Union */
}CG_OPCLIP;
typedef enum /* relationships */
{
REL_CONTAIN = 0 , /* TRUEiftheprimaryshapewhollycontainsthesecondaryshape */
REL_CROSS = 1 , /* TRUEiftheintersectionoftheinteriorsisalowerdimensionthanthemaximumdimensionofthetwoshapes */
REL_DISJOINT = 2 , /* TRUEiftheintersectionoftwoshapesisempty */
REL_EQUAL = 3 , /* TRUEifthetwosuppliedshapesareidentical */
REL_OVERLAP = 4 , /* TRUEiftheintersectionoftwoshapesresultsinanobjectofthesamegeometricdimension */
REL_TOUCH = 5 , /* TRUEifthetwosuppliedshapesshareacommonboundary */
REL_WITHIN = 6 /* TRUEifprimary_shapeiswhollycontainedwithinsecondary_shape */
}CG_RELATION;
/* =============================================================================
PublicStructTypes
============================================================================= */
/* Vertexstructure */
typedef struct
{
union{
struct { double x,y;};
double _v[ 2 ];
};
}cg_vertex_t,cg_point_t;
/* Linestructure */
typedef struct
{
union{
struct { double x1,y1,x2,y2;};
struct {cg_point_tstart,end;};
cg_point_t_p[ 2 ];
double _v[ 4 ];
};
}cg_edge_t,cg_line_t;
/* Vertexliststructure */
typedef struct
{
int num_vertices; /* Numberofverticesinlist */
cg_vertex_t * vertex; /* Vertexarraypointer */
}cg_vertexlist_t,cg_pointlist_t,cg_polyline_t;
/* rectangletype */
typedef struct
{
union{
struct {
union{
struct { double min_x,min_y;};
cg_vertex_t_min;
};
union{
struct { double max_x,max_y;};
cg_vertex_t_max;
};
};
double _v[ 4 ];
};
}cg_rect_t;
/* 3Drect-boxtype */
typedef struct
{
union{
struct {
union{
struct { double min_x,min_y,max_x,max_y;};
cg_rect_t_rc;
};
double min_z,max_z;
};
double _v[ 6 ];
};
}cg_rectZ_t,cg_box_t;
/* circleCRstruct */
typedef struct
{
union{
struct { double xp,yp;};
cg_vertex_t_cp;
};
double r;
}cg_circle_t;
/* Pointstructure */
typedef struct
{
union{
struct {
union{
struct { double x,y;};
cg_vertex_t_p;
};
double z;
};
double _v[ 3 ];
};
}cg_vector_t,cg_pointZ_t,cg_vertexZ_t;
/* 3DVertexliststructure */
typedef struct
{
int num_vertices; /* Numberofvertices */
cg_vector_t * vertex; /* Vertexarray */
}cg_vectorlist_t,cg_pointlistZ_t,cg_vertexlistZ_t;
/* Trianglestruct */
typedef struct
{
union{
struct {cg_vertex_tv0,v1,v2;};
cg_vertex_t_v[ 3 ];
};
}cg_tri_t;
/* 3DTrianglestruct */
typedef struct
{
union{
struct {cg_vector_tv0,v1,v2;};
cg_vector_t_v[ 3 ];
};
cg_vector_tn; /* Normalvector */
}cg_triZ_t;
/* trianglevertexindexstruct */
typedef struct
{
union{
struct { int i0,i1,i2;};
int _vi[ 3 ];
};
}cg_triindex_t;
/* BLOBstruct */
typedef struct
{
BYTE * chunk;
size_tsize;
}cg_blob_t;
/* ============================================================================ */
#endif /*ndef_CGALDEF_H_INCLUDED*/