Пример #1
0
 /** @return */
 public double getFaceArea() {
   if (_halfedge == null) {
     return 0;
   }
   final WB_Coord n = getFaceNormal();
   if (WB_Vector.getLength3D(n) < 0.5) {
     return 0;
   }
   final double x = WB_Math.fastAbs(n.xd());
   final double y = WB_Math.fastAbs(n.yd());
   final double z = WB_Math.fastAbs(n.zd());
   double area = 0;
   int coord = 3;
   if ((x >= y) && (x >= z)) {
     coord = 1;
   } else if ((y >= x) && (y >= z)) {
     coord = 2;
   }
   HE_Halfedge he = _halfedge;
   do {
     switch (coord) {
       case 1:
         area +=
             (he.getVertex().yd()
                 * (he.getNextInFace().getVertex().zd() - he.getPrevInFace().getVertex().zd()));
         break;
       case 2:
         area +=
             (he.getVertex().xd()
                 * (he.getNextInFace().getVertex().zd() - he.getPrevInFace().getVertex().zd()));
         break;
       case 3:
         area +=
             (he.getVertex().xd()
                 * (he.getNextInFace().getVertex().yd() - he.getPrevInFace().getVertex().yd()));
         break;
     }
     he = he.getNextInFace();
   } while (he != _halfedge);
   switch (coord) {
     case 1:
       area *= (0.5 / x);
       break;
     case 2:
       area *= (0.5 / y);
       break;
     case 3:
       area *= (0.5 / z);
   }
   return WB_Math.fastAbs(area);
 }
Пример #2
0
 /** @return */
 public boolean isDegenerate() {
   return WB_Vector.getLength3D(getFaceNormal()) < 0.5;
 }