关于TRIANGLE二维三角网格生成器在windows下的配置说明

      近期须要用到三角网格生成的一些东西,所以就把TRIANGLE这个库编译了一下,发现编译过程还是略微有些纠结,于是就想到写下来。希望以后有些童鞋看到少走一些弯路。

     首先很感谢eryar的帮助,很感谢!

     在编译之前还是先看一下eryar的博文:

     http://www.cnblogs.com/opencascade/p/3632705.html

     我是在visual studio 2010 windows环境以下编译的。

     刚開始磕磕绊绊的也编译完了,可是在c++以下是不能使用的。所以求助eryar才最后成功:

     直接上代码吧,triangle头文件更改例如以下:

    

#ifndef _TRIANGLE_HEADER_
#define _TRIANGLE_HEADER_
#ifdef _cplusplus
extern "C"{
#endif///更改这里,博客加粗改颜色之后成代码了,不知为什么

#define REAL double
#define ANSI_DECLARATORS
#define VOID int
#include "triangle.h"

struct triangulateio {
  REAL *pointlist;                                               /* In / out */
  REAL *pointattributelist;                                      /* In / out */
  int *pointmarkerlist;                                          /* In / out */
  int numberofpoints;                                            /* In / out */
  int numberofpointattributes;                                   /* In / out */

  int *trianglelist;                                             /* In / out */
  REAL *triangleattributelist;                                   /* In / out */
  REAL *trianglearealist;                                         /* In only */
  int *neighborlist;                                             /* Out only */
  int numberoftriangles;                                         /* In / out */
  int numberofcorners;                                           /* In / out */
  int numberoftriangleattributes;                                /* In / out */

  int *segmentlist;                                              /* In / out */
  int *segmentmarkerlist;                                        /* In / out */
  int numberofsegments;                                          /* In / out */

  REAL *holelist;                        /* In / pointer to array copied out */
  int numberofholes;                                      /* In / copied out */

  REAL *regionlist;                      /* In / pointer to array copied out */
  int numberofregions;                                    /* In / copied out */

  int *edgelist;                                                 /* Out only */
  int *edgemarkerlist;            /* Not used with Voronoi diagram; out only */
  REAL *normlist;                /* Used only with Voronoi diagram; out only */
  int numberofedges;                                             /* Out only */
};

#ifdef ANSI_DECLARATORS
void triangulate(char *, struct triangulateio *, struct triangulateio *,struct triangulateio *);
void trifree(VOID *memptr);
#else /* not ANSI_DECLARATORS */
void triangulate();
void trifree();
#endif /* not ANSI_DECLARATORS */
#ifdef _cplusplus
}
#endif///更改这里,博客加粗改颜色之后成代码了,不知为什么
#endif


同一时候在triangle.c里面改动:

将:

/* #define NO_TIMER */

/* #define TRILIBRARY*/

改为:

#define NO_TIMER

#define TRILIBRARY

也就是将这两个宏定义打开就OK了。


成功生成lib库



posted @ 2017-05-23 11:08  claireyuancy  阅读(547)  评论(0编辑  收藏  举报