1

known:

  • -i command is used to insert point set(with .node) into a hull(maybe plc,maybe .stl file)

    In the official documentation:

    The -i switch indicates that a list of additional points is going to be inserted into an existing tetrahedral mesh. The list of additional nodes is read from files xxx.a.node, where xxx stands for the input file name (i.e., xxx.poly or xxx.smesh, or xxx.ele, ...).

  • I've done inserting points in bounding box and generating CDT with tetgen.exe and tetview.exe.

    Enter in cmd:

tetgen -i Stanford_Bunny.stl

enter image description here

problem:

However, I am getting an error when using tetgen's -i command in my own project. Commands such as -p can be used.

tetgenio in, out, addin,bgmin;
    in.firstnumber = 0;

    char* infile = new char[100];
    strcpy_s(infile, 100, "C:/delaunay3/data/source/Stanford_Bunny");//use strcpy_s 
    in.load_stl(infile);

    char* add_nodefile = new char[1024];
    strcpy_s(add_nodefile, 100, "C:/delaunay3/data/source/Stanford_Bunny.a");
    addin.load_node(add_nodefile);

    tetgenbehavior* b = new tetgenbehavior();
    b->plc = 1;
    b->quality = 0;             //-q
    b->fixedvolume = 0;         //-a
    b->regionattrib = 0;        //-A
    b->edgesout = 1;            //-e(all edge)
    b->facesout = 0;            //-f(all face)
    b->insertaddpoints = 1;     //-i

    tetrahedralize(b, &in, &out, &addin);

    char* s_nodefile = new char[100];
    char* s_edgefile = new char[100];
    char* s_elefile = new char[100];
    char* s_facefile = new char[100];
    strcpy_s(s_nodefile, 100, "C:/delaunay3/data/s_example");//use strcpy_s
    strcpy_s(s_edgefile, 100, "C:/delaunay3/data/s_exampl");
    strcpy_s(s_elefile, 100, "C:/delaunay3/data/s_example");
    strcpy_s(s_facefile, 100, "C:/delaunay3/data/s_example");
    out.save_nodes(s_nodefile);
    out.save_edges(s_edgefile);
    out.save_elements(s_elefile);
    out.save_faces(s_facefile);

    cout << "plc = " << b->plc<<endl;
    cout << "quality = " << b->quality << endl;
    cout << "edgesout = " << b->edgesout << endl;
    cout << "insertaddpoints = " << b->insertaddpoints << endl;

result:

Exception thrown at 0x7A0DBCFD (ucrtbased.dll) (in delaunay3.exe): 0xC0000005: Access violation while reading location 0xDDDDDDD4.

enter image description here enter image description here

enter image description here

I used four parameters intetrahedralize(b, &in, &out, &addin);, I don't know if this is the cause.The program can be run by calling -p with three arguments.

Long Lu
  • 11
  • 3

1 Answers1

0

there is a simple solution: call the console interface directly

  1. firstly, add this in tetgen.h
int tetgen(int argc, char* argv[]); //
  1. secondly, use not TETLIBRARY way in tetgen.cxx
int tetgen(int argc, char* argv[])  //change this and others place
//int main(int argc, char *argv[])
  1. thirdly
char* cmd = (char*)"-i";
char* file_name = (char*)"./example.poly";  //with example.a.node in the same file
void tetgen_methord(char* cmd, char* file_name)     
{
    char* all[3] = { (char*)"tetgen", cmd, file_name };
    tetgen(3, all);
}

it's funny but efficient

Long Lu
  • 11
  • 3