cleanup solid checks

This commit is contained in:
Joachim Schöberl 2020-10-17 17:08:58 +02:00
parent ad69a9d5a5
commit cdbe7fd892
4 changed files with 48 additions and 87 deletions

View File

@ -6,21 +6,6 @@
namespace netgen
{
//using namespace netgen;
/*
SolidIterator :: SolidIterator ()
{
;
}
SolidIterator :: ~SolidIterator ()
{
;
}
*/
// int Solid :: cntnames = 0;
@ -201,31 +186,11 @@ namespace netgen
case TERM: case TERM_REF:
return prim->PointInSolid (p, eps);
case SECTION:
{
auto res1 = s1->PointInSolid (p, eps);
auto res2 = s2->PointInSolid (p, eps);
if (res1 == IS_INSIDE && res2 == IS_INSIDE) return IS_INSIDE;
if (res1 == IS_OUTSIDE || res2 == IS_OUTSIDE) return IS_OUTSIDE;
return DOES_INTERSECT;
}
return Intersection (s1->PointInSolid (p, eps), s2->PointInSolid (p, eps));
case UNION:
{
auto res1 = s1->PointInSolid (p, eps);
auto res2 = s2->PointInSolid (p, eps);
if (res1 == IS_INSIDE || res2 == IS_INSIDE) return IS_INSIDE;
if (res1 == IS_OUTSIDE && res2 == IS_OUTSIDE) return IS_OUTSIDE;
return DOES_INTERSECT;
}
return Union (s1->PointInSolid (p, eps), s2->PointInSolid (p, eps));
case SUB:
{
auto res1 = s1->PointInSolid (p, eps);
switch (res1)
{
case IS_INSIDE: return IS_OUTSIDE;
case IS_OUTSIDE: return IS_INSIDE;
default: return DOES_INTERSECT;
}
}
return Complement (s1->PointInSolid (p, eps));
case ROOT:
return s1->PointInSolid (p, eps);
}
@ -240,31 +205,11 @@ namespace netgen
case TERM: case TERM_REF:
return prim->VecInSolid (p, v, eps);
case SECTION:
{
auto res1 = s1->VecInSolid (p, v, eps);
auto res2 = s2->VecInSolid (p, v, eps);
if (res1 == IS_INSIDE && res2 == IS_INSIDE) return IS_INSIDE;
if (res1 == IS_OUTSIDE || res2 == IS_OUTSIDE) return IS_OUTSIDE;
return DOES_INTERSECT;
}
return Intersection (s1->VecInSolid (p, v, eps), s2->VecInSolid (p, v, eps));
case UNION:
{
auto res1 = s1->VecInSolid (p, v, eps);
auto res2 = s2->VecInSolid (p, v, eps);
if (res1 == IS_INSIDE || res2 == IS_INSIDE) return IS_INSIDE;
if (res1 == IS_OUTSIDE && res2 == IS_OUTSIDE) return IS_OUTSIDE;
return DOES_INTERSECT;
}
return Union (s1->VecInSolid (p, v, eps), s2->VecInSolid (p, v, eps));
case SUB:
{
auto res1 = s1->VecInSolid (p, v, eps);
switch (res1)
{
case IS_INSIDE: return IS_OUTSIDE;
case IS_OUTSIDE: return IS_INSIDE;
default: return DOES_INTERSECT;
}
}
return Complement (s1->VecInSolid (p, v, eps));
case ROOT:
return s1->VecInSolid (p, v, eps);
}
@ -280,31 +225,11 @@ namespace netgen
case TERM: case TERM_REF:
return prim->VecInSolid2 (p, v1, v2, eps);
case SECTION:
{
auto res1 = s1->VecInSolid2 (p, v1, v2, eps);
auto res2 = s2->VecInSolid2 (p, v1, v2, eps);
if (res1 == IS_INSIDE && res2 == IS_INSIDE) return IS_INSIDE;
if (res1 == IS_OUTSIDE || res2 == IS_OUTSIDE) return IS_OUTSIDE;
return DOES_INTERSECT;
}
return Intersection (s1->VecInSolid2 (p, v1, v2, eps), s2->VecInSolid2 (p, v1, v2, eps));
case UNION:
{
auto res1 = s1->VecInSolid2 (p, v1, v2, eps);
auto res2 = s2->VecInSolid2 (p, v1, v2, eps);
if (res1 == IS_INSIDE || res2 == IS_INSIDE) return IS_INSIDE;
if (res1 == IS_OUTSIDE && res2 == IS_OUTSIDE) return IS_OUTSIDE;
return DOES_INTERSECT;
}
return Union (s1->VecInSolid2 (p, v1, v2, eps), s2->VecInSolid2 (p, v1, v2, eps));
case SUB:
{
auto res1 = s1->VecInSolid2 (p, v1, v2, eps);
switch (res1)
{
case IS_INSIDE: return IS_OUTSIDE;
case IS_OUTSIDE: return IS_INSIDE;
default: return DOES_INTERSECT;
}
}
return Complement (s1->VecInSolid2 (p, v1, v2, eps));
case ROOT:
return s1->VecInSolid2 (p, v1, v2, eps);
}
@ -315,6 +240,8 @@ namespace netgen
bool Solid :: IsIn (const Point<3> & p, double eps) const
{
return PointInSolid (p,eps) != IS_OUTSIDE;
/*
switch (op)
{
case TERM: case TERM_REF:
@ -332,10 +259,13 @@ namespace netgen
return s1->IsIn (p, eps);
}
return 0;
*/
}
bool Solid :: IsStrictIn (const Point<3> & p, double eps) const
{
return PointInSolid (p,eps) == IS_INSIDE;
/*
switch (op)
{
case TERM: case TERM_REF:
@ -353,11 +283,14 @@ namespace netgen
return s1->IsStrictIn (p, eps);
}
return 0;
*/
}
bool Solid :: VectorIn (const Point<3> & p, const Vec<3> & v,
double eps) const
{
return VecInSolid (p,v,eps) != IS_OUTSIDE;
/*
Vec<3> hv;
switch (op)
{
@ -376,11 +309,14 @@ namespace netgen
return s1->VectorIn(p, v, eps);
}
return 0;
*/
}
bool Solid :: VectorStrictIn (const Point<3> & p, const Vec<3> & v,
double eps) const
{
return VecInSolid (p,v,eps) == IS_INSIDE;
/*
Vec<3> hv;
switch (op)
{
@ -401,6 +337,7 @@ namespace netgen
return s1->VectorStrictIn(p, v, eps);
}
return 0;
*/
}
@ -443,6 +380,8 @@ namespace netgen
bool Solid::VectorIn2 (const Point<3> & p, const Vec<3> & v1,
const Vec<3> & v2, double eps) const
{
return VecInSolid2 (p,v1,v2,eps) != IS_OUTSIDE;
/*
switch (op)
{
case TERM: case TERM_REF:
@ -460,11 +399,14 @@ namespace netgen
return s1->VectorIn2 (p, v1, v2, eps);
}
// return 0;
*/
}
bool Solid :: VectorStrictIn2 (const Point<3> & p, const Vec<3> & v1, const Vec<3> & v2,
double eps) const
{
return VecInSolid2 (p,v1,v2,eps) == IS_INSIDE;
/*
switch (op)
{
case TERM: case TERM_REF:
@ -481,6 +423,7 @@ namespace netgen
case ROOT:
return s1->VectorStrictIn2 (p, v1, v2, eps);
}
*/
}

View File

@ -33,6 +33,26 @@ namespace netgen
};
inline INSOLID_TYPE Intersection (INSOLID_TYPE ina, INSOLID_TYPE inb)
{
if (ina == IS_INSIDE && inb == IS_INSIDE) return IS_INSIDE;
if (ina == IS_OUTSIDE || inb == IS_OUTSIDE) return IS_OUTSIDE;
return DOES_INTERSECT;
}
inline INSOLID_TYPE Union (INSOLID_TYPE ina, INSOLID_TYPE inb)
{
if (ina == IS_INSIDE || inb == IS_INSIDE) return IS_INSIDE;
if (ina == IS_OUTSIDE && inb == IS_OUTSIDE) return IS_OUTSIDE;
return DOES_INTERSECT;
}
inline INSOLID_TYPE Complement (INSOLID_TYPE in)
{
if (in == IS_INSIDE) return IS_OUTSIDE;
if (in == IS_OUTSIDE) return IS_INSIDE;
return DOES_INTERSECT;
}
class Solid
{

View File

@ -2148,7 +2148,7 @@ namespace netgen
for (int i = 0; i < specpoints.Size(); i++)
if (specpoints[i].unconditional)
uncond.Set (specpoint2point[i]);
uncond.SetBit (specpoint2point[i]);
for (int i = 0; i < specpoints.Size(); i++)
specpoints[i].unconditional = uncond.Test (specpoint2point[i]);

View File

@ -213,8 +213,6 @@ namespace netgen
INSOLID_TYPE;
class DummySurface : public Surface
{
virtual double CalcFunctionValue (const Point<3> & /* point */) const