BrunoLevy / geogram

a programming library with geometric algorithms
Other
1.87k stars 128 forks source link

How to compute the power Diagram ? I got the error when follow the tutorial in the repos #114

Closed liu411417492 closed 2 months ago

liu411417492 commented 1 year ago

I want to compute Power Diagram in my project, and I follow the tutorial in your repos,but when i run this code "delaunay_->copy_Laguerre_cell_fromDelaunay(i, C, W);" i got the Error: “Abnormal program termination: received signal 11 (SIGSEGV)”

And i notice that when i comment out the code : "delaunay_->set_weights(weights_vec.data());" then everything is ok .So i want to know is there anything to pay attention to when set the weight vector?

——————————————————————————————————————————————————————————

Here is the code

function(){

using namespace GEO;

GEO::initialize();

Stopwatch Wtot("Total time");

if (InitPara) { CmdLine::import_arg_group("standard"); CmdLine::import_arg_group("algo"); GEO::CmdLine::import_arg_group("co3ne"); GEO::CmdLine::import_arg_group("pre"); GEO::CmdLine::import_arg_group("post"); GEO::CmdLine::import_arg_group("remesh"); GEO::CmdLine::import_arg_group("opt"); GEO::CmdLine::import_arg_group("tet"); }

GEO::Mesh gm_pts; mesh_load("sample-10000.xyz", gm_pts); // read 1w points gm_pts.facets.clear();

PeriodicDelaunay3d::IncidentTetrahedra W; SmartPointer delaunay = new PeriodicDelaunay3d(false, 1.0);

delaunay_->set_vertices(gm_pts.vertices.nb(), gm_pts.vertices.pointptr(0)); delaunay->set_keeps_infinite(true);

GEO::vector weights_vec; for (auto i = 0; i < gm_pts.vertices.nb(); i++) {

double* p = gm_pts.vertices.point_ptr(i);

weights_vec.push_back(std::abs(p[2]));

}

delaunay_->set_weights(weights_vec.data());

delaunay_->compute();

ConvexCell C; //delaunay_->copy_Laguerre_cell_from_Delaunay(0, C);

delaunay_->copy_Laguerre_cell_fromDelaunay(0, C, W);

return; }

liu411417492 commented 1 year ago

and i found in function copy_Laguerre_cell_from_Delaunay line 3667 called funtion get_incident_tets(i,W); in this function and in line 3568 code : t = index_t(v_tocell[v]); running assert geo_debug_assert(i < size()); and then report error

BrunoLevy commented 1 year ago

Hello, I'll try to help you, To start, a little question: as far as I understand, you are using the z coordinate of the points as the weights ? why ?

liu411417492 commented 1 year ago

Hello, I'll try to help you, To start, a little question: as far as I understand, you are using the z coordinate of the points as the weights ? why ?

oh i have a algorithm to compute the weights and it is too long so i didn't copy the code

the weights i used in the project is vary from [0,C] and C is the constant value; so i use the z coordinate of the points as the weight for example

liu411417492 commented 1 year ago

by the way ,my partner found that v_tocell in delaunay_->compute() didn't update for the all time ,because the multiple thread0 is always return ,but when i comment out the return ,it didnt report error, but the result is also wrong. TAT ![Uploading 13b547fa1fe4ede6cb86d7c041f507f.png…]()

BrunoLevy commented 12 months ago

(I'm sorry I am a bit slow to answer, need to finish a batch of changes / bugfixes then I'll come back to you right after).