int RenderableObject::CreateUnitSphere(vector<FACET3>& facets, int iterations)
{
    int i,j,n,nstart;
    glm::vec3 p1(1.0,1.0,1.0),  p2(-1.0,-1.0,1.0);
    glm::vec3 p3(1.0,-1.0,-1.0), p4(-1.0,1.0,-1.0); 

    p1 = glm::normalize(p1);
    p2 = glm::normalize(p2);
    p3 = glm::normalize(p3);
    p4 = glm::normalize(p4);

    facets[0].p1 = p1; facets[0].p2 = p2; facets[0].p3 = p3;
    facets[1].p1 = p2; facets[1].p2 = p1; facets[1].p3 = p4;
    facets[2].p1 = p2; facets[2].p2 = p4; facets[2].p3 = p3;
    facets[3].p1 = p1; facets[3].p2 = p3; facets[3].p3 = p4;

    n = 4;

    for (i=1;i<iterations;i++) 
    {
        nstart = n;

        for (j=0;j<nstart;j++) 
        {

            /* Create initially copies for the new facets */
            facets[n  ] = facets[j];
            facets[n+1] = facets[j];
            facets[n+2] = facets[j];

            /* Calculate the midpoints */
            p1 = MidPoint(facets[j].p1,facets[j].p2);
            p2 = MidPoint(facets[j].p2,facets[j].p3);
            p3 = MidPoint(facets[j].p3,facets[j].p1);

            /* Replace the current facet */
            facets[j].p2 = p1;
            facets[j].p3 = p3;

            /* Create the changed vertices in the new facets */
            facets[n  ].p1 = p1;
            facets[n  ].p3 = p2;
            facets[n+1].p1 = p3;
            facets[n+1].p2 = p2;
            facets[n+2].p1 = p1;
            facets[n+2].p2 = p2;
            facets[n+2].p3 = p3;
            n += 3;
        }
    }

    for (j=0;j<n;j++) 
    {
        facets[j].p1 = glm::normalize(facets[j].p1);
        facets[j].p2 = glm::normalize(facets[j].p2);
        facets[j].p3 = glm::normalize(facets[j].p3);
    }

    return(n);
}
Example #2
0
	void Draw :: MidPoint(int X1, int Y1, int X2, int Y2 , COLORREF selcolor) {
		int dx = X2 - X1, dy = Y2 - Y1, d, dNE, dE;
		float m = (float) dy / (float) dx;
		if (m >= -1 && m <= 1) {
			if (X1 > X2) {
				MidPoint(X2, Y2, X1, Y1 , selcolor);  return;
			}
			if (dy < 0) 
				m = -1 , dy = -dy;
			 else
				m = 1;
			SetPixel(ps.hdc, X1, int(Y1), selcolor);
			d = 2 * dy - dx , dNE = 2 * dy , dE = 2 * dy - 2 * dx;
			while (X1 < X2) {
				X1++;
				if (d < 0)
					d += dNE;
				else {
					Y1 += m , d += dE;
				}
				SetPixel(ps.hdc, X1, int(Y1), selcolor);
			}
		} else {
			if (Y1 > Y2) {
				MidPoint(X2, Y2, X1, Y1 , selcolor); return;
			}
			(dx < 0) ? m = -1 , dx = -dx : m = 1;
			SetPixel(ps.hdc, X1, int(Y1), selcolor);
			d = 2 * dx - dy , dNE = 2 * dx , dE = 2 * dx - 2 * dy;
			while (Y1 < Y2) {
				Y1++ , (d < 0) ?d += dNE : X1 += m , d += dE;
				SetPixel(ps.hdc, X1, int(Y1), selcolor);
			}
		}
	}
int main()
{


	double euler, midpoint, kutta, euler1, midpoint1, kutta1, euler2, midpoint2, kutta2;

	euler = Euler(0.0, 2.4, 0.1, -1.0, df);
	midpoint = MidPoint(0.0, 2.4, 0.2, -1.0, df);
	kutta = RungeKutta(0.0, 2.4, 0.4, -1.0, df);


	euler1 = Euler(0.0, 2.4, 0.01, -1.0, df);
	midpoint1 = MidPoint(0.0, 2.4, 0.02, -1.0, df);
	kutta1 = RungeKutta(0.0, 2.4, 0.04, -1.0, df);


	euler2 = Euler(0.0, 2.4, 0.001, -1.0, df);
	midpoint2 = MidPoint(0.0, 2.4, 0.002, -1.0, df);
	kutta2 = RungeKutta(0.0, 2.4, 0.004, -1.0, df);


	
	printf("Método  h  y(2.4) \n--------------------------\n");
	printf("Euler        0.1  %lf    \nMidpoint     0.2  %lf \nRunge Kutta  0.4  %lf  \n--------------------------\n", euler, midpoint, kutta);
	printf("Euler        0.01  %lf    \nMidpoint     0.02  %lf \nRunge Kutta  0.04  %lf  \n--------------------------\n", euler1, midpoint1, kutta1);
	printf("Euler        0.001  %lf    \nMidpoint     0.002  %lf \nRunge Kutta  0.004  %lf  \n--------------------------\n", euler2, midpoint2, kutta2);


	system("pause");
	return 0;
}
Example #4
0
/*
	Refine a triangular mesh by bisecting each edge
	Forms 3 new triangles for each existing triangle on each iteration
	Could be made more efficient for drawing if the triangles were
	ordered in a fan or strip!
*/
void DomeSplitFace(DOMEFACE *f,int *n)
{
	int i;
	int n1,n2;

	n1 = *n;
	n2 = *n;

	for (i=0;i<n1;i++) {

		f[n2].p[0] = MidPoint(f[i].p[0],f[i].p[1]);
      f[n2].p[1] = f[i].p[1];
      f[n2].p[2] = MidPoint(f[i].p[1],f[i].p[2]);
      f[n2].u[0] = LinearInterpolate(f[i].u[0],f[i].u[1],0.5);
      f[n2].u[1] = f[i].u[1];
      f[n2].u[2] = LinearInterpolate(f[i].u[1],f[i].u[2],0.5);
      f[n2].v[0] = LinearInterpolate(f[i].v[0],f[i].v[1],0.5);
      f[n2].v[1] = f[i].v[1];
      f[n2].v[2] = LinearInterpolate(f[i].v[1],f[i].v[2],0.5);

      f[n2+1].p[0] = MidPoint(f[i].p[1],f[i].p[2]);
      f[n2+1].p[1] = f[i].p[2];
      f[n2+1].p[2] = MidPoint(f[i].p[2],f[i].p[0]);
      f[n2+1].u[0] = LinearInterpolate(f[i].u[1],f[i].u[2],0.5);
      f[n2+1].u[1] = f[i].u[2];
      f[n2+1].u[2] = LinearInterpolate(f[i].u[2],f[i].u[0],0.5);
      f[n2+1].v[0] = LinearInterpolate(f[i].v[1],f[i].v[2],0.5);
      f[n2+1].v[1] = f[i].v[2];
      f[n2+1].v[2] = LinearInterpolate(f[i].v[2],f[i].v[0],0.5);

      f[n2+2].p[0] = MidPoint(f[i].p[0],f[i].p[1]);
      f[n2+2].p[1] = MidPoint(f[i].p[1],f[i].p[2]);
      f[n2+2].p[2] = MidPoint(f[i].p[2],f[i].p[0]);
      f[n2+2].u[0] = LinearInterpolate(f[i].u[0],f[i].u[1],0.5);
      f[n2+2].u[1] = LinearInterpolate(f[i].u[1],f[i].u[2],0.5);
      f[n2+2].u[2] = LinearInterpolate(f[i].u[2],f[i].u[0],0.5);
      f[n2+2].v[0] = LinearInterpolate(f[i].v[0],f[i].v[1],0.5);
      f[n2+2].v[1] = LinearInterpolate(f[i].v[1],f[i].v[2],0.5);
      f[n2+2].v[2] = LinearInterpolate(f[i].v[2],f[i].v[0],0.5);

      //f[i].p[0] = f[i].p[0];
      f[i].p[1] = MidPoint(f[i].p[0],f[i].p[1]);
      f[i].p[2] = MidPoint(f[i].p[0],f[i].p[2]);
      //f[i].u[0] = f[i].u[0];
      f[i].u[1] = LinearInterpolate(f[i].u[0],f[i].u[1],0.5);
      f[i].u[2] = LinearInterpolate(f[i].u[0],f[i].u[2],0.5);
      //f[i].v[0] = f[i].v[0];
      f[i].v[1] = LinearInterpolate(f[i].v[0],f[i].v[1],0.5);
      f[i].v[2] = LinearInterpolate(f[i].v[0],f[i].v[2],0.5);

		n2 += 3;
	}

	*n = n2;
}
Example #5
0
/*
   Create a triangular facet approximation to a sphere
   Unit radius
   Return the number of facets created.
   The number of facets will be (4^iterations) * 8
*/
int MakeNSphere(TF *f,int iterations)
{
   int i,it;
   double a;
   XYZ p[6] = {0,0,1,  0,0,-1,  -1,-1,0,  1,-1,0,  1,1,0, -1,1,0};
   XYZ pa,pb,pc;
   int nt = 0,ntold;

   /* Create the level 0 object */
   a = 1 / sqrt(2.0);
   for (i=0;i<6;i++) {
      p[i].x *= a;
      p[i].y *= a;
   }
   f[0].p[0] = p[0]; f[0].p[1] = p[3]; f[0].p[2] = p[4];
   f[1].p[0] = p[0]; f[1].p[1] = p[4]; f[1].p[2] = p[5];
   f[2].p[0] = p[0]; f[2].p[1] = p[5]; f[2].p[2] = p[2];
   f[3].p[0] = p[0]; f[3].p[1] = p[2]; f[3].p[2] = p[3];
   f[4].p[0] = p[1]; f[4].p[1] = p[4]; f[4].p[2] = p[3];
   f[5].p[0] = p[1]; f[5].p[1] = p[5]; f[5].p[2] = p[4];
   f[6].p[0] = p[1]; f[6].p[1] = p[2]; f[6].p[2] = p[5];
   f[7].p[0] = p[1]; f[7].p[1] = p[3]; f[7].p[2] = p[2];
   nt = 8;

   if (iterations < 1)
      return(nt);

   /* Bisect each edge and move to the surface of a unit sphere */
   for (it=0;it<iterations;it++) {
      ntold = nt;
      for (i=0;i<ntold;i++) {
         pa = MidPoint(f[i].p[0],f[i].p[1]);
         pb = MidPoint(f[i].p[1],f[i].p[2]);
         pc = MidPoint(f[i].p[2],f[i].p[0]);
         Normalise(&pa);
         Normalise(&pb);
         Normalise(&pc);
         f[nt].p[0] = f[i].p[0]; f[nt].p[1] = pa;        f[nt].p[2] = pc; nt++;
         f[nt].p[0] = pa;        f[nt].p[1] = f[i].p[1]; f[nt].p[2] = pb; nt++;
         f[nt].p[0] = pb;        f[nt].p[1] = f[i].p[2]; f[nt].p[2] = pc; nt++;
         f[i].p[0] = pa;
         f[i].p[1] = pb;
         f[i].p[2] = pc;
      }
   }

   return(nt);
}
Example #6
0
void EdgeItem::UpdatePath( void ){
//    if( points )
//        delete []points;
    points.clear();
    QPainterPath m_path;
    m_path.moveTo(0, 0);

    QPointF control = MidPoint();
    double dist = DistancePoint(QPointF(0, 0) , control) + DistancePoint(control, m_endPoint);

    int maxPointsCount = 8;
    pointsCount = (int)(dist / m_selectDistance) + 1;
    if(pointsCount > maxPointsCount ){
        pointsCount = maxPointsCount;
    }
//    points = new QPointF[pointsCount];
    QPointF point;
    for (int i = 0; i < pointsCount; i++){
        point = BezierValue( (double) i / ( pointsCount - 1), control );
        m_path.lineTo( point );
//        m_path.addEllipse(point, 3,3);
        points << point + pos();
    }

    setPath( m_path );
    UpdateArrow();
}
Example #7
0
// 采用近似估计的算法
// 如果是闭合等值线,则搜索整个多边形中最长的边
// 如果是开放等值线,则搜索20%--80%范围内的多边形中最长边
void SearchLabelPostion( const PointArray& cnpts, DT_Point& tpt, double& angle )
{
    if( cnpts.empty() ) return;

    // 通常情况下,等值线至少有3个点
    int s = 0, t = cnpts.size();
    if( !IsPointEqual( cnpts.front(), cnpts.back() ) )
    {
        s = cnpts.size() / 5;
        t = cnpts.size() - s;
    }

    int pos = s;
    double maxDist = Distance_2( cnpts[0], cnpts[1] );
    for( int i = s; i < t - 1; i++ )
    {
        double dist = Distance_2( cnpts[i], cnpts[i + 1] );
        if( dist > maxDist )
        {
            pos = i;
            maxDist = dist;
        }
    }
    tpt = MidPoint( cnpts[pos], cnpts[pos + 1] );
    angle = Direction( cnpts[pos], cnpts[pos + 1] );
}
bool Streamline::MidPointMethod(Vector CurrPos, Vector& NextPos, float fStepSize){

	Vector vDerivative(0.0f, 0.0f, 0.0f) ;

	if( !this->DerivativeAtPosition(CurrPos, vDerivative) )			// if the position is out of bound
		return false ;

	// now get the midpoint
	// k1 = h*Derivative
	// we are doing fStepSize/2 to get k1/2
	// Midpoint will have X0 + k1/2 which is mid point between the current position 
	// and next position according to euler step
	vDerivative.ScalarMult(fStepSize/2 ); 
	Vector MidPoint(0.0, 0.0, 0.0) ;
	MidPoint.VectorX = CurrPos.X() + vDerivative.X() ;
	MidPoint.VectorY = CurrPos.Y() + vDerivative.Y() ;
	MidPoint.VectorZ = CurrPos.Z() + vDerivative.Z() ;

	// Now get the derivative at midPoint
	if( !this->DerivativeAtPosition(MidPoint, vDerivative) )			// if the position is out of bound
		return false ;
	// Now find the next position according to this derivative
	vDerivative.ScalarMult(fStepSize);									// now take the full step
	NextPos.VectorX = CurrPos.X() + vDerivative.X() ;
	NextPos.VectorY = CurrPos.Y() + vDerivative.Y() ;
	NextPos.VectorZ = CurrPos.Z() + vDerivative.Z() ;

	return true;
}
Example #9
0
File: ND.c Project: bialk/SPOOLES
/*
   ------------------------------------------------
   purpose -- to split a subregion with a X-Z plane

   created -- 95nov16, cca
   ------------------------------------------------
*/
static void
SplitY ( 
   int   n1, 
   int   n2, 
   int   n3, 
   int   newToOld[], 
   int   west, 
   int   east, 
   int   south, 
   int   north,
   int   bottom, 
   int   top 
) {
int   i, k, k1, k2, k3, m, m1, north1, north2, south1, south2 ;

m1 = MidPoint(south, north, n2/2) ;
south1 = south ;
north1 = m1 - 1 ;
south2 = m1 + 1 ;
north2 = north ;
k1 = 0 ;
k2 = k1 + (m1 - south) * (east - west + 1) * (top - bottom + 1) ;
k3 = k2 + (north - m1) * (east - west + 1) * (top - bottom + 1) ;
if ( m1 > south ) {
#  if DEBUG > 0
   fprintf(stdout, "\n SplitY : calling ND(%d:%d,%d:%d,%d:%d)",
           west, east, south1, north1, bottom, top) ;
#  endif
   mkNDperm(n1, n2, n3, newToOld + k1, 
      west, east, south1, north1, bottom, top) ; }
if ( north > m1 ) {
#  if DEBUG > 0
   fprintf(stdout, "\n SplitY : calling ND(%d:%d,%d:%d,%d:%d)",
           west, east, south2, north2, bottom, top) ;
#  endif
   mkNDperm(n1, n2, n3, newToOld + k2, 
      west, east, south2, north2, bottom, top) ; }
#  if DEBUG > 0
   fprintf(stdout, "\n SplitY : ordering (%d:%d,%d:%d,%d:%d)",
           west, east, m1, m1, bottom, top) ;
#  endif
m = k3 ;
for ( k = bottom ; k <= top ; k++ ) {
   for ( i = west ; i <= east ; i++ ) {
#     if DEBUG > 0
      fprintf(stdout, "\n SplitY : newToOld[%d] = %d",
              m, i + m1 * n1 + k * n1 * n2) ;
#     endif
      newToOld[m++] = i + m1 * n1 + k * n1 * n2 ; } }

return ; }
Example #10
0
void EdgeItem::UpdateArrow(){

    double c,d,l;
    d=(m_endPoint - pos()).x();
    c=(m_endPoint - pos()).y();

    double angle = atan2( c, d);
    double anglep = angle + 3.1415 / 180 * 15;
    double anglem = angle - 3.1415 / 180 * 15;
    QPointF control = MidPoint();
    control = BezierValue( 0.5, control );
    m_arrowPath = QPainterPath();
    m_arrowPath.moveTo( control );
    m_arrowPath.lineTo( control.x()  - 10  * cos( anglem ), control.y() - 10  * sin( anglem) );
    m_arrowPath.moveTo( control );
    m_arrowPath.lineTo( control.x() - 10  * cos( anglep ), control.y() - 10  * sin( anglep) );
}
void myCircle::drawCircle(HDC hdc)
{
     switch(drawingAlgorithm)
     {
                             case 3:
                                  drawSimple(hdc);
                                  break;
                             case 4:
                                  PolarAlgorithm(hdc);
                                  break;
                             case 5:
                                  MidPoint(hdc);
                                  break;
                             default:
                                     break;
     }
}
Example #12
0
File: ND.c Project: bialk/SPOOLES
/*
   ------------------------------------------------
   purpose -- to split a subregion with a Y-Z plane
   ------------------------------------------------
*/
static void
SplitX ( 
   int   n1, 
   int   n2, 
   int   n3, 
   int   newToOld[], 
   int   west,  
   int   east,  
   int   south,  
   int   north,  
   int   bottom,  
   int   top 
) {
int   east1, east2, j, k, k1, k2, k3, m, m1, west1, west2 ;

m1 = MidPoint(west, east, n1/2) ;
west1 = west ;
east1 = m1 - 1 ;
west2 = m1 + 1 ;
east2 = east ;
k1 = 0 ;
k2 = k1 + (m1 - west) * (north - south + 1) * (top - bottom + 1) ;
k3 = k2 + (east - m1) * (north - south + 1) * (top - bottom + 1) ;
if ( m1 > west ) {
#  if DEBUG > 0
   fprintf(stdout, "\n SplitX : 1. calling ND") ;
#  endif
   mkNDperm(n1, n2, n3, newToOld + k1, 
      west1, east1, south, north, bottom, top) ; }
if ( east > m1 ) {
#  if DEBUG > 0
   fprintf(stdout, "\n SplitX : 2. calling ND") ;
#  endif
   mkNDperm(n1, n2, n3, newToOld + k2, 
      west2, east2, south, north, bottom, top) ; }
#  if DEBUG > 0
fprintf(stdout, "\n SplitX : 3. calling ND") ;
fprintf(stdout, "\n m1 = %d, south = %d, north = %d",
        m1, south, north) ;
#  endif
m = k3 ;
for ( k = bottom ; k <= top ; k++ ) {
   for ( j = south ; j <= north ; j++ ) {
      newToOld[m++] = m1 + j * n1 + k * n1 * n2 ; } }

return ; }
Example #13
0
void SearchLabelPostion( const PointArray& cnpts, double tolerance, double width, LabelArray& la )
{
    // 计算近似多边形
    PointArray polygon;
    ApproximatePolygon( cnpts, polygon, tolerance );

    double c = 0.85;
    // 在多边形上查找标注点
    for( int i = 0; i < ( int )polygon.size() - 1; i++ )
    {
        DT_Point p1 = polygon[i], p2 = polygon[i + 1];
        if( Distance( p1, p2 )*c > width )
        {
            DT_Label label = {MidPoint( p1, p2 ), Direction( p1, p2 )};
            la.push_back( label );
        }
    }
}
Example #14
0
File: ND.c Project: bialk/SPOOLES
/*
   ------------------------------------------------
   purpose -- to split a subregion with a X-Y plane

   created -- 95nov16, cca
   ------------------------------------------------
*/
static void
SplitZ ( 
   int   n1, 
   int   n2, 
   int   n3, 
   int   newToOld[], 
   int   west, 
   int   east, 
   int   south, 
   int   north,
   int   bottom, 
   int   top 
) {
int   bottom1, bottom2, i, j, k1, k2, k3, m, m1, top1, top2 ;

m1 = MidPoint(bottom, top, n2/2) ;
bottom1 = bottom ;
top1    = m1 - 1 ;
bottom2 = m1 + 1 ;
top2    = top    ;
k1 = 0 ;
k2 = k1 + (m1 - bottom) * (east - west + 1) * (north - south + 1) ;
k3 = k2 + (top - m1) * (east - west + 1) * (north - south + 1) ;
if ( m1 > bottom ) {
#  if DEBUG > 0
   fprintf(stdout, "\n SplitZ : 1. calling ND") ;
#  endif
   mkNDperm(n1, n2, n3, newToOld + k1, 
      west, east, south, north, bottom1, top1) ; }
if ( top > m1 ) {
#  if DEBUG > 0
   fprintf(stdout, "\n SplitZ : 2. calling ND") ;
#  endif
   mkNDperm(n1, n2, n3, newToOld + k2, 
      west, east, south, north, bottom2, top2) ; }
#  if DEBUG > 0
fprintf(stdout, "\n SplitZ : 3. calling ND") ;
#  endif
m = k3 ;
for ( j = south ; j <= north ; j++ ) {
   for ( i = west ; i <= east ; i++ ) {
      newToOld[m++] = i + j * n1 + m1 * n1 * n2 ; } }

return ; }
Example #15
0
agbool	CAGimageSegs::TextureMidPoint(agint32 nRows, agint32 nCols, agreal64 ExcludePixelsPercent, CAGreal64Array* pOutTextures)
{
	pOutTextures->RemoveAll();

	CAGbaseArray<AGBU_POINT> centers;
	if(!MidPoint(&centers))	return agfalse;

	CAGint32Array center_pixels;
	GetNumberPixelsOfBounds(&center_pixels);
	if(center_pixels.GetSize()==0)		return agfalse;

	agint32 nTotalPixels=(m_rcBound.right-m_rcBound.left)*(m_rcBound.top-m_rcBound.bottom);
	if(nTotalPixels<0)	throw _T("Fatal error");
	if(nTotalPixels==0)	return agfalse;

	return CAGfeatUtil::TextureMidPoint(&centers, m_rcBound,		nRows, nCols, 
						&center_pixels,			nTotalPixels, 
						ExcludePixelsPercent,	pOutTextures);
}
Example #16
0
double NodeSimpleShape::GetRotationAngle()
{
	DocCoord MidPoint((Parallel[0].x + Parallel[1].x)/2, (Parallel[0].y + Parallel[1].y)/2);

	DocRect Bounds(Parallel[0],Parallel[0]);
	Bounds.IncludePoint(Parallel[1]);
	Bounds.IncludePoint(Parallel[2]);
	Bounds.IncludePoint(Parallel[3]);
	DocCoord Centre((Bounds.LowCorner().x+Bounds.HighCorner().x)/2,
											(Bounds.LowCorner().y+Bounds.HighCorner().y)/2);

	DocCoord Offset = MidPoint - Centre;

	double Angle = atan2((double)Offset.y, (double)Offset.x);
	if (Angle == HUGE_VAL)
		Angle = 0.0;

	return Angle;
}
Example #17
0
static void outpoly() {
	int i;
	int vab,vca;
#ifdef DBG
	printf("  outpoly, npoly = %d \n", npoly);
#endif
	/* check to make sure poly faces away from origin: if not, flip it */
	check_facing();	

	if (subdiv_sides) {
		DPoint midp;
		int nxti = 0;
		for (i=npoly-1; i>=0; i--) {
			pol[2*i] = pol[i];
			MidPoint(&midp,&verts[pol[i]],&verts[pol[nxti]]);
			pol[2*i+1] = reg_vert(&midp);
			nxti = 2*i;
			}
		npoly *= 2;
		}

	if (center_verts||star_axis[curax]||state.scale_axis[curax]!=1.0) {
		DPoint sum;
		int nc,nxt;
		sum.x = sum.y = sum.z = 0.0;
		for (i=0; i<npoly; i++) {
			sum.x += verts[pol[i]].x;
			sum.y += verts[pol[i]].y;
			sum.z += verts[pol[i]].z;
			}
		sum.x /= (float)npoly;
		sum.y /= (float)npoly;
		sum.z /= (float)npoly;

		if (state.scale_axis[curax]!=1.0) {
			ScaleVect(&sum,state.scale_axis[curax]);
			nc = reg_vert(&sum);
			for (i=0; i<npoly; i++) {
				nxt = (i==npoly-1)?0:i+1;
				outface(nc,pol[i],pol[nxt],1,1,1);
				}
			}
		else {
			nc = reg_vert(&sum);
			for (i=0; i<npoly; i++) {
				nxt = (i==npoly-1)?0:i+1;
				outface(nc,pol[i],pol[nxt],0,1,0);
				}
			}
		}
	else  {
		for (i=1; i<npoly-1; i++) {
			vab = vca = 0;
			if (i==1) vab = 1;
			if	(i==npoly-2) vca = 1;
#ifdef DBG2
			printf("         face (%d,%d,%d) vis = (%d %d %d) \n",
				pol[0],pol[i],pol[i+1],vab,1,vca);
#endif
			outface(pol[0],pol[i],pol[i+1],vab,1,vca);
#ifdef DBG2
			{
			double l = dist(pol[i],pol[i+1]);
			printf(" side length = %.6f \n",l);
			}
#endif

		
			}
		}
	}