Commit ce629e5b authored by Célestin Marot's avatar Célestin Marot
Browse files

computing intersection later, new bound on quality might eliminate the need to...

computing intersection later, new bound on quality might eliminate the need to compute it altogether
parent 64d82806
......@@ -251,10 +251,17 @@ static inline int tet_tri_intersection(SPRCavity* SPR,
uint8_t tet[4],
unsigned triangleID)
{
if(bboxes_intersect(tetBbox, &SPR->triangles.bbox[triangleID])==0)
return 0;
uint8_t* tri = SPR->triangles.array[triangleID].node;
SPRBbox triangleBbox;
SPRBbox_from(&triangleBbox, SPR->points.array[tri[0]].coord);
SPRBbox_add(&triangleBbox, SPR->points.array[tri[1]].coord);
SPRBbox_add(&triangleBbox, SPR->points.array[tri[2]].coord);
SPRBbox_add(&triangleBbox, SPR->points.array[tri[3]].coord);
if(bboxes_intersect(tetBbox, &triangleBbox)==0)
return 0;
#ifndef NDEBUG
int v = get_orient3d(SPR, tet[0], tet[1], tet[2], tet[3]);
if(v>=0) {
......@@ -690,14 +697,14 @@ static double get_quality_map(SPRCavity* SPR,
}
static void compute_bbox(SPRCavity* SPR, uint16_t triangleID)
{
SPRTriangle* f = &SPR->triangles.array[triangleID];
SPRBbox* bbox = &SPR->triangles.bbox[triangleID];
SPRBbox_from(bbox, SPR->points.array[f->node[0]].coord);
SPRBbox_add(bbox, SPR->points.array[f->node[1]].coord);
SPRBbox_add(bbox, SPR->points.array[f->node[2]].coord);
}
// static void compute_bbox(SPRCavity* SPR, uint16_t triangleID)
// {
// SPRTriangle* f = &SPR->triangles.array[triangleID];
// SPRBbox* bbox = &SPR->triangles.bbox[triangleID];
// SPRBbox_from(bbox, SPR->points.array[f->node[0]].coord);
// SPRBbox_add(bbox, SPR->points.array[f->node[1]].coord);
// SPRBbox_add(bbox, SPR->points.array[f->node[2]].coord);
// }
/* Compute the worst face (the face that we should begin with)
......@@ -762,15 +769,11 @@ static inline uint16_t best_face_heuristic(SPRCavity* SPR, double* qualMax)
static inline void compute_candidates(SPRCavity* SPR,
SPRStep* step,
double qualMax,
uint16_t triangleID)
double qualMax)
{
const int nPts = SPR->points.num;
const int nfaces = SPR->triangles.num;
SPRTet* tet = &step->tet;
SPRBbox* triangleBbox = &SPR->triangles.bbox[triangleID];
uint8_t num = 0;
uint8_t score[SPR_MAX_PTS];
......@@ -791,22 +794,6 @@ static inline void compute_candidates(SPRCavity* SPR,
if(qual<=SPR->tetrahedra.quality)
continue;
int stop = 0;
SPRBbox tetBbox = *triangleBbox;
SPRBbox_add(&tetBbox, SPR->points.array[tet->node[3]].coord);
// test intersection with boundary triangles
for (int otherFaceID=0; otherFaceID<nfaces; otherFaceID++)
{
if(tet_tri_intersection(SPR, &tetBbox, tet->node, otherFaceID)){
stop = 1;
break;
}
}
if(stop)
continue;
// those heuristics can be changed in many way
// if you have some theory validating some choice,
// you can give a higher/lower score depending on
......@@ -883,7 +870,6 @@ static void add_face(SPRCavity* SPR,
SPR->triangles.array[SPR->triangles.num].node[3] = v0;
add_face_map(SPR, v0, v1, v2, SPR->triangles.num);
increment_3valences(SPR, v0, v1, v2);
compute_bbox(SPR, SPR->triangles.num);
SPR->triangles.num++;
}
......@@ -897,7 +883,6 @@ static void remove_face(SPRCavity* SPR, uint16_t triangleID)
SPRTriangle* last = &SPR->triangles.array[SPR->triangles.num-1];
add_face_map(SPR, last->node[0], last->node[1], last->node[2], triangleID);
*del = *last;
SPR->triangles.bbox[triangleID] = SPR->triangles.bbox[SPR->triangles.num-1];
}
SPR->triangles.num--;
......@@ -978,7 +963,6 @@ static inline void SPR_init(SPRCavity* SPR)
v[3] = v[0];
increment_3valences(SPR, v[0], v[1], v[2]);
add_face_map(SPR, v[0], v[1], v[2], i);
compute_bbox(SPR, i);
}
/* interior points should have a positive valence */
......@@ -1047,7 +1031,7 @@ int hxtSPR(SPRCavity* SPR)
step->tet = SPR->triangles.array[triangleID];
// create (and order) the candidate array
compute_candidates(SPR, step, qualMax, triangleID);
compute_candidates(SPR, step, qualMax);
// remove the face from the map
remove_face(SPR, triangleID);
......@@ -1067,6 +1051,25 @@ int hxtSPR(SPRCavity* SPR)
if(qual <= SPR->tetrahedra.quality)
continue;
int stop = 0;
SPRBbox tetBbox;
SPRBbox_from(&tetBbox, SPR->points.array[step->tet.node[0]].coord);
SPRBbox_add(&tetBbox, SPR->points.array[step->tet.node[1]].coord);
SPRBbox_add(&tetBbox, SPR->points.array[step->tet.node[2]].coord);
SPRBbox_add(&tetBbox, SPR->points.array[step->tet.node[3]].coord);
// test intersection with boundary triangles
for (int otherFaceID=0; otherFaceID<SPR->triangles.num; otherFaceID++)
{
if(tet_tri_intersection(SPR, &tetBbox, step->tet.node, otherFaceID)){
stop = 1;
break;
}
}
if(stop)
continue;
SPR->num_search_nodes++;
for (int f=0; f<3; f++) {
......
......@@ -126,7 +126,6 @@ typedef struct {
* hxtSPR() might shuffle what you put in here */
struct {
SPRTriangle array[SPR_MAX_FACES];
SPRBbox bbox[SPR_MAX_FACES]; // filled internally
int num;
} triangles;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment