Skip to content

Commit 72e861b

Browse files
committed
add check if any inner points are in polygon when adding inner point
1 parent 2e3264e commit 72e861b

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

libsrc/meshing/adfront3.cpp

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,54 @@ void AdFront3 :: SetStartFront (int /* baseelnp */)
787787
*/
788788
}
789789

790+
bool AdFront3 :: PointInsideGroup(const NgArray<PointIndex, PointIndex::BASE> &grouppindex,
791+
const NgArray<MiniElement2d> &groupfaces) const
792+
{
793+
for(auto pi : Range(points))
794+
{
795+
const auto& p = points[pi].P();
796+
bool found = false;
797+
for(const auto& f : groupfaces)
798+
{
799+
for(auto i : Range(3))
800+
if(grouppindex.Get(f.PNum(i+1)) == pi)
801+
{
802+
found = true;
803+
break;
804+
}
805+
}
806+
if(found)
807+
continue;
808+
809+
// "random" direction
810+
Vec<3> dir = { 0.123871, 0.15432,-0.43989 };
811+
DenseMatrix a(3), ainv(3);
812+
Vector b(3), u(3);
813+
814+
int count = 0;
815+
for(const auto& f : groupfaces)
816+
{
817+
const auto& p1 = points[grouppindex.Get(f.PNum(1))].P();
818+
auto v1 = points[grouppindex.Get(f.PNum(2))].P() - p1;
819+
auto v2 = points[grouppindex.Get(f.PNum(3))].P() - p1;
820+
for(auto i : Range(3))
821+
{
822+
a(i,0) = v1[i];
823+
a(i,1) = v2[i];
824+
a(i,2) = -dir[i];
825+
b(i) = p[i] - p1[i];
826+
}
827+
CalcInverse (a, ainv);
828+
ainv.Mult (b, u);
829+
if (u(0) >= 0 && u(1) >= 0 && u(0)+u(1) <= 1 &&
830+
u(2) > 0)
831+
count++;
832+
}
833+
if (count % 2 == 1)
834+
return true;
835+
}
836+
return false;
837+
}
790838

791839
bool AdFront3 :: Inside (const Point<3> & p) const
792840
{

libsrc/meshing/adfront3.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ class AdFront3
262262
void GetIntersectingFaces (const Point<3> & pmin, const Point<3> & pmax,
263263
NgArray<int> & ifaces) const;
264264

265+
bool PointInsideGroup(const NgArray<PointIndex, PointIndex::BASE> &grouppindex,
266+
const NgArray<MiniElement2d>& groupfaces) const;
267+
265268
///
266269
void GetFaceBoundingBox (int i, Box3d & box) const;
267270

libsrc/meshing/meshing3.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
372372
onlytri = 0;
373373

374374
if (onlytri && groupfaces.Size() <= 20 + 2*stat.qualclass &&
375-
FindInnerPoint (grouppoints, groupfaces, inp))
375+
FindInnerPoint (grouppoints, groupfaces, inp) &&
376+
!adfront->PointInsideGroup(grouppindex, groupfaces))
376377
{
377378
(*testout) << "inner point found" << endl;
378379

rules/tetrules.rls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ endrule
139139

140140
rule "Tetrahedron Vis a Vis Point (1)"
141141

142-
quality 100
142+
quality 20
143143

144144
mappoints
145145
(0, 0, 0);

0 commit comments

Comments
 (0)