コード例 #1
0
ファイル: gblend.cpp プロジェクト: eradman/xara-cairo
BOOL GBlend::Blend1to1()
{
    if ( IsCurve(Type0) || IsCurve(Type1) )
    {
        if ( IsntCurve(Type0) )
        {
            P01.x = (2*P00.x+P03.x)/3 ;
            P02.x = (P00.x+2*P03.x)/3 ;
            P01.y = (2*P00.y+P03.y)/3 ;
            P02.y = (P00.y+2*P03.y)/3 ;
        }
        if ( IsntCurve(Type1) )
        {
            P11.x = (2*P10.x+P13.x)/3 ;
            P12.x = (P10.x+2*P13.x)/3 ;
            P11.y = (2*P10.y+P13.y)/3 ;
            P12.y = (P10.y+2*P13.y)/3 ;
        }
        if ( !BlendCurve( P01,P02,P03, P11,P12,P13 ) )
            return FALSE ;
    }
    else if ( !BlendPoint( PT_LINETO, P03, P13 ) )
        return FALSE ;
    P00 = P03 ;
    ReadPath0() ;
    P10 = P13 ;
    ReadPath1() ;
    return TRUE ;
}
コード例 #2
0
ファイル: C_Parameter.cpp プロジェクト: nsights/nSIGHTS
double Parameter::GetParValue() const
{
  // sanity checks
  if (IsCurve())
    GenAppInternalError("Parameter::GetParValue() #1");
  if (IsRadial())
    GenAppInternalError("Parameter::GetParValue() #2");
  if (IsTime())
    GenAppInternalError("Parameter::GetParValue() #3");


  switch (parameterType)
  {
  case ptFixed : {
    return parVal.GetMetricVal();
  }
  case ptVary : {
    if (varyParVal.varyIndex < 0)
      return nullReal;
    return varyParVal.GetVaryVal();
  }
  case ptOpt : {
    return optParVal.GetParEstimate();
  }
  case ptSample : {
    int currIndex = sampParVal.GetTrialIndex();
    if (currIndex < 0)
      return nullReal;
    return sampParVal.GetCurrentValue(currIndex);
  }
  }

  GenAppInternalError("Parameter::GetParValue() #3");

  // to satisfy the compiler
  return nullReal;
}
コード例 #3
0
ファイル: gblend.cpp プロジェクト: vata/xarino
BOOL GBlend::BlendMtoN()
{
	UINT32 t ;
	while ( IsntEnd(Type0) || IsntEnd(Type1) )
	{
		if ( LPtr1==EndLengthPtr1-1 )
			MatchLast( LPtr0, EndLengthPtr0, *LPtr1+Length1-Length0, Match0, Total0 ) ;
		else
			Match    ( LPtr0, EndLengthPtr0, *LPtr1+Length1-Length0, Match0, Total0 ) ;
		if ( LPtr0==EndLengthPtr0-1 )
			MatchLast( LPtr1, EndLengthPtr1, *LPtr0+Length0-Length1, Match1, Total1 ) ;
		else
			Match    ( LPtr1, EndLengthPtr1, *LPtr0+Length0-Length1, Match1, Total1 ) ;
		if ( abs(Match0)<abs(Match1) )
		{
			if ( Total0!=1 )
			{
				Match0 += *LPtr1+Length1-Length0 ;
				if ( IsntCurve(Type1) )
				{
					P11.x = (2*P10.x+P13.x)/3 ; P12.x = (P10.x+2*P13.x)/3 ;
					P11.y = (2*P10.y+P13.y)/3 ; P12.y = (P10.y+2*P13.y)/3 ;
				}
				for ( t=2 ; t<=Total0 ; t++ )
				{
					if ( IsCurve(Type0) || IsCurve(Type1) )
					{
						if ( IsntCurve(Type0) )
						{
							P01.x = (2*P00.x+P03.x)/3 ; P02.x = (P00.x+2*P03.x)/3 ;
							P01.y = (2*P00.y+P03.y)/3 ; P02.y = (P00.y+2*P03.y)/3 ;
						}
						Split( P10,P11,P12,P13, *LPtr0,Match0 ) ;
						if ( !BlendCurve( P01,P02,P03, L1,L2,M ) )
							return FALSE ;
						P10 = M ;
						P11 = R1 ;
						P12 = R2 ;
					}
					else
					{
						P10.x += MulDiv(P13.x-P10.x,*LPtr0,Match0) ;
						P10.y += MulDiv(P13.y-P10.y,*LPtr0,Match0) ;
						if ( !BlendPoint( PT_LINETO, P03, P10 ) )
							return FALSE ;
					}
					P00 = P03 ;
					Match0 -= *LPtr0 ;
					ReadPath0() ;
				}
			}
		}
		else
		{
			if ( Total1!=1 )
			{
				Match1 += *LPtr0+Length0-Length1 ;
				if ( IsntCurve(Type0) )
				{
					P01.x = (2*P00.x+P03.x)/3 ; P02.x = (P00.x+2*P03.x)/3 ;
					P01.y = (2*P00.y+P03.y)/3 ; P02.y = (P00.y+2*P03.y)/3 ;
				}
				for ( t=2 ; t<=Total1 ; t++ )
				{
					if ( IsCurve(Type0) || IsCurve(Type1) )
					{
						if ( IsntCurve(Type1) )
						{
							P11.x = (2*P10.x+P13.x)/3 ; P12.x = (P10.x+2*P13.x)/3 ;
							P11.y = (2*P10.y+P13.y)/3 ; P12.y = (P10.y+2*P13.y)/3 ;
						}
						Split( P00,P01,P02,P03, *LPtr1,Match1 ) ;
						if ( !BlendCurve( L1,L2,M, P11,P12,P13 ) )
							return FALSE ;
						P00 = M ;
						P01 = R1 ;
						P02 = R2 ;
					}
					else
					{
						P00.x += MulDiv(P03.x-P00.x,*LPtr1,Match1) ;
						P00.y += MulDiv(P03.y-P00.y,*LPtr1,Match1) ;
						if ( !BlendPoint( PT_LINETO, P00, P13 ) )
							return FALSE ;
					}
					P10 = P13 ;
					Match1 -= *LPtr1 ;
					ReadPath1()	;
				}
			}
		}
		if ( !Blend1to1() )
			return FALSE ;
	} /* while */
	return TRUE ;
}
コード例 #4
0
ファイル: fuzzclip.cpp プロジェクト: Amadiro/xara-cairo
size_t FuzzyClip(
		PPOINT	IPoints,
		PBYTE	ITypes,
		size_t	ILength,
		BOOL	IsClosed,
		RECT	*InnerRect,
		RECT	*OuterRect,
		PPOINT	pOPoints,
		PBYTE	pOTypes,
		size_t	pOMaxLength
	)
{
	IRect		= (GRECT*) InnerRect ;
	ORect		= (GRECT*) OuterRect ;
	OPoints		= pOPoints ;
	OTypes		= pOTypes ;
	OMaxLength	= pOMaxLength ;
	OLength		= 0 ;

	if ( ILength <= 0 )
		return 0 ;

	try {

		Index = 0 ;
		while ( Index<ILength )
		{
			OFirstPoint = TRUE ;
			POINT StartPoint = IPoints[Index++] ;
			LastSector = GetSector( StartPoint ) ;
			LastPoint = StartPoint ;
			while ( Index<ILength && (IsLine(ITypes[Index]) || IsCurve(ITypes[Index])) )
			{
				if ( IsLine(ITypes[Index]) )
				{
					ClipLine( LastPoint,IPoints[Index] ) ;
					LastPoint = IPoints[Index++] ;
				}
				else
				{
					ClipCurve( LastPoint,IPoints[Index],IPoints[Index+1],IPoints[Index+2] ) ;
					LastPoint = IPoints[Index+2] ;
					Index += 3 ;
				}
			}
			if ( IsClosed || (ITypes[Index-1] & PT_CLOSEFIGURE) )
			{
				ClipLine( LastPoint,StartPoint ) ;
				if ( !OFirstPoint )
					*(OTypes-1) |= PT_CLOSEFIGURE ;
			}
			if ( !OFirstPoint && IsMove(*(OTypes-1)) )
			{
				OTypes-- ;
				OPoints-- ;
				OLength-- ;
			}
		}

	} catch ( INT32 ) {
		OLength = (size_t)-1 ;
	}

	return OLength ;
}