Ejemplo n.º 1
0
void imageCompareBase::setLeftToOriginalImage() {

  imagePtr container =
    getImageFromIndex(imageNameToIndex(Original()));

  if (container) {
    setLeftImage(container);
    setCur(container);
  }
}
Ejemplo n.º 2
0
void imageCompareBase::deleteLR(const leftRightAccessor& lra) {

  // don't delete original
  const QString imageName = lra.image()->name();
  if (!lra.image()->isOriginal()) {
    deleteImageActions(imageName);
    // determine the replacement image
    comboBox* box = lra.imageListBox();
    box->removeItem(box->findText(imageName));
    QString replacement;
    if (box->findText(Original()) != -1) {
      replacement = Original();
    }
    else if (box->count() > 0) {
      // the most recent image
      replacement = box->itemText(box->count() - 1);
    }
    if (!replacement.isNull()) {
      if (leftImage() && leftImage()->name() == imageName) {
        setLeftImage(getImageFromName(replacement));
        setCur(leftImage());
      }
      else if (rightImage() && rightImage()->name() == imageName) {
        setRightImage(getImageFromName(replacement));
        setCur(rightImage());
      }
      else {
        qWarning() << "Deleting an image not shown:" << imageName;
      }
    }
    else {
      imageListEmpty();
      return;
    }
  }
}
Ejemplo n.º 3
0
int main()
{
    long res;
    int i;
    
    PreOriginal(6, 8);
    for (i=0; i<1000000; i++)
    {
        res = Original(6, 8);
    }
    if (((unsigned int)(res)) != (unsigned int)(0x2dc6c1))
    {
        printf ("***ERROR res %lx is unexpected\n", res);
        exit (-1);
    }
    return 0;
}
Ejemplo n.º 4
0
void Points::Rotate(char axis, int point_count, std::string title)
{
    int g=point_count;

    std::vector<int> index(g*g);
    std::vector<int> rindex(g*g);
    std::vector<int> It(g);
    std::vector<double> theta(g);
    std::vector<double> phi(g);
    std::vector<double> theta_rotated(g);
    std::vector<double> phi_rotated(g);



    std::vector<double> theta_index(g*g);
    std::vector<double> phi_index(g*g);
    Points::kernel_map.resize(g);
    Points::weight_map.resize(g);
    Points::fkernel_map.resize(g);
    Points::theta_prime.resize(g*g);
    Points:: phi_prime.resize(g*g);

    std::vector<std::vector<double> > kern(g);
    std::vector<std::vector<double> > fkern(g);
    std::vector<std::vector<double> > weight(g);
    std::vector<std::vector<double> > rkern(g);
    std::vector<std::vector<double> > rkern2(g);
    std::vector<std::vector<double> > rotated_kern(g);
    std::vector<double> r_weight(g*g);
    std::vector<std::vector<double> > rfkernel_value(g);

    std::vector<Vex> Original(g);
    std::vector<Vex> Rotated(g);
    Points::TtoZ.resize(g);

    theta=Points::Theta;
    phi=Points::Phi;






    if(axis=='X')
    {
        theta_rotated=Points::theta_rotatedX;
        phi_rotated=Points::phi_rotatedX;

    }
    else if(axis=='Y')
    {

        theta_rotated=Points::theta_rotatedY;
        phi_rotated=Points::phi_rotatedY;

    }
    else if(axis=='Z')
    {

        theta_rotated=Points::theta_rotatedZ;
        phi_rotated=Points::phi_rotatedZ;

    }
    else
    {

    }


    std::vector<int> i_it(g*g);
    std::vector<int> j_it(g*g);


      for(int i=0; i<g; i++)
    {

        Original[i].SphericaltoXYZ(theta[i],phi[i],1.0);
        Rotated[i].SphericaltoXYZ(theta_rotated[i], phi_rotated[i], 1.0);

       // std::cout <<"x, y, z =" << Original[i].GetX() << ", " << Original[i].GetY() << ", "<< Original[i].GetZ() << ", "<< std::endl;
    }


    for(int i=0; i<g; i++)
    {
        kern[i].resize(g);
        fkern[i].resize(g);
        weight[i].resize(g);

        rkern[i].resize(g);
        rkern2[i].resize(g);

        //std::cout << "original xyz = ("  << Original[i].GetX() << ", " << Original[i].GetY() << ", " << Original[i].GetZ() << ")" << std::endl;


    }



//------------ load unroated kernel matrix from file ------------------//


    std::cout <<axis+title << std::endl;
    std::ifstream kernel_read(title);
    kernel_read.precision(15);
    kernel_read.clear();                 // clear fail and eof bits
    kernel_read.seekg(0, std::ios::beg); // back to the start!

    int u=0;

    for(int i=0; i<g; i++)
    {
        kernel_map[i].resize(g);
        fkernel_map[i].resize(g);
        weight_map[i].resize(g);

        for(int j=0; j<g; j++)
        {
            //kernel_read >> theta_index[u] >> phi_index[u] >> kern[i][j] >> fkern[i][j] >> weight[i][j];
            kernel_read >> kern[i][j] >> fkern[i][j] >> weight[i][j];
            u++;
        }

    }

    kernel_read.close();


//--------------find index that matches rotation -----------------------//


    for(int i=0; i<g; i++)
    {
        for(int j=0; j<g; j++)
        {
            if(Original[i]==Rotated[j])
            {
                Points::TtoZ[i] = Rotated[j];
                It[i]=j;
            }
        }
    }





//-------------------use rotated index to map kernel ------------------------//

    for(int i=0; i<g; i++)
    {
        Points::theta_prime[i]=theta[ It[i] ];
        Points::phi_prime[i]=phi[ It[i] ];

        for(int j=0; j<g; j++)
        {
            Points::kernel_map[i][j]=kern[ It[i] ][ It[j] ];
            Points::fkernel_map[i][j]=fkern[ It[i] ][ It[j] ];
            Points::weight_map[i][j]=weight[ It[i] ][ It[j] ];

        }

    }




    std::cout << std::endl;
    std::cout << "Rotation Passed! " <<  std::endl;
    std::cout << std::endl;

}
	bool TestWithType(FAutomationTestBase* Test)
	{
		int32 NumLeaks = 0;
		
		// Test that move-assigning the expression node correctly assigns the data, and calls the destructors successfully
		{
			TGuardValue<int32*> LeakCounter(T::LeakCount, &NumLeaks);
			
			FExpressionNode Original(T(1));
			FExpressionNode New = MoveTemp(Original);
			
			int32 ResultingId = New.Cast<T>()->Id;
			if (ResultingId != 1)
			{
				Test->AddError(FString::Printf(TEXT("Expression node move operator did not operate correctly. Expected moved-to state to be 1, it's actually %d."), ResultingId));
				return false;
			}

			// Try assigning it over the top again
			Original = FExpressionNode(T(1));
			New = MoveTemp(Original);

			ResultingId = New.Cast<T>()->Id;
			if (ResultingId != 1)
			{
				Test->AddError(FString::Printf(TEXT("Expression node move operator did not operate correctly. Expected moved-to state to be 1, it's actually %d."), ResultingId));
				return false;
			}

			// Now try running it all through a parser
			FTokenDefinitions TokenDefs;
			FExpressionGrammar Grammar;
			FOperatorJumpTable JumpTable;

			// Only valid tokens are a, b, and +
			TokenDefs.DefineToken([](FExpressionTokenConsumer& Consumer){
				auto Token = Consumer.GetStream().GenerateToken(1);
				if (Token.IsSet())
				{
					switch(Consumer.GetStream().PeekChar())
					{
					case 'a': Consumer.Add(Token.GetValue(), T(1)); break;
					case '+': Consumer.Add(Token.GetValue(), FOperator()); break;
					}
				}
				return TOptional<FExpressionError>();
			});

			Grammar.DefinePreUnaryOperator<FOperator>();
			Grammar.DefineBinaryOperator<FOperator>(1);

			JumpTable.MapPreUnary<FOperator>([](const T& A)					{ return T(A.Id); });
			JumpTable.MapBinary<FOperator>([](const T& A, const T& B)		{ return T(A.Id); });

			ExpressionParser::Evaluate(TEXT("+a"), TokenDefs, Grammar, JumpTable);
			ExpressionParser::Evaluate(TEXT("a+a"), TokenDefs, Grammar, JumpTable);
			ExpressionParser::Evaluate(TEXT("+a++a"), TokenDefs, Grammar, JumpTable);
		}

		if (NumLeaks != 0)
		{
			Test->AddError(FString::Printf(TEXT("Expression node did not call wrapped type's destructors correctly. Potentially resulted in %d leaks."), NumLeaks));
			return false;
		}

		return true;
	}