Example #1
0
INSOLID_TYPE Brick :: BoxInSolid (const BoxSphere<3> & box) const
{
  bool inside = 1;
  bool outside = 0;

  Point<3> p[8];
  for (int j = 0; j < 8; j++)
    p[j] = box.GetPointNr(j);

  for (int i = 0; i < 6; i++)
    {
      bool outsidei = 1;
      for (int j = 0; j < 8; j++)
	{
	  double val = faces[i]->Plane::CalcFunctionValue (p[j]);

	  if (val > 0)  inside = 0;
	  if (val < 0)  outsidei = 0;
	}
      if (outsidei) outside = 1;
    }

  if (outside) return IS_OUTSIDE;
  if (inside) return IS_INSIDE;
  return DOES_INTERSECT;
}
Example #2
0
void Brick :: Reduce (const BoxSphere<3> & box)
{
  double val;
  Point<3> p[8];
  for(int j=0;j<8;j++)
    p[j]=box.GetPointNr(j);

  for (int i = 0; i < 6; i++)
    {
      bool hasout = 0;
      bool hasin = 0;
      for (int j = 0; j < 8; j++)
	{
	  val = faces[i]->Plane::CalcFunctionValue (p[j]);
	  if (val > 0)  hasout = 1;
	  else if (val < 0)  hasin = 1;
	  if (hasout && hasin) break;
	}
      surfaceactive[i] =  hasout && hasin;
    }
}