コード例 #1
0
ファイル: test_framebuffer.cpp プロジェクト: sondrele/NTNU
void can_project_micropolygon() {
    MeshPoint mp1(-10, -10, 100);
    MeshPoint mp2(10, -10, 100);
    MeshPoint mp3(-10, 10, 100);
    MeshPoint mp4(10, 10, 100);
    MicroPolygon poly;
    poly.a = mp1;
    poly.b = mp2;
    poly.c = mp3;
    poly.d = mp4;

    FrameBuffer fb(500, 500);
    fb.projectMicroPolygon(poly);

    ASSERT_EQUAL_FLOAT(poly.a.getX(), 206.699, 0.1);
    ASSERT_EQUAL_FLOAT(poly.a.getY(), 206.699, 0.1);

    ASSERT_EQUAL_FLOAT(poly.b.getX(), 293.301, 0.1);
    ASSERT_EQUAL_FLOAT(poly.b.getY(), 206.699, 0.1);

    ASSERT_EQUAL_FLOAT(poly.c.getX(), 206.699, 0.1);
    ASSERT_EQUAL_FLOAT(poly.c.getY(), 293.301, 0.1);

    ASSERT_EQUAL_FLOAT(poly.d.getX(), 293.301, 0.1);
    ASSERT_EQUAL_FLOAT(poly.d.getY(), 293.301, 0.1);
}
コード例 #2
0
ファイル: test_framebuffer.cpp プロジェクト: sondrele/NTNU
void can_project_mesh_point() {
    FrameBuffer fb(500, 500);
    MeshPoint mp(0, 0, 100);
    fb.projectAndScalePoint(mp);

    ASSERT_EQUAL_FLOAT(mp.getX(), 250, 0.1);
    ASSERT_EQUAL_FLOAT(mp.getY(), 250, 0.1);

    MeshPoint mp2(-10, -10, 100);
    fb.projectAndScalePoint(mp2);

    ASSERT_EQUAL_FLOAT(mp2.getX(), 206.699, 0.1);
    ASSERT_EQUAL_FLOAT(mp2.getY(), 206.699, 0.1);
}
コード例 #3
0
ファイル: mime-test.cpp プロジェクト: acklinr/cxxtools
        void serializeMultipartToEntity()
        {
            cxxtools::MimeMultipart mp;
            mp.addObject();
            mp.addObject();

            cxxtools::SerializationInfo si;
            si <<= mp;

            cxxtools::MimeEntity me;
            si >>= me;

            CXXTOOLS_UNIT_ASSERT(me.isMultipart());

            cxxtools::MimeMultipart mp2(me);
            CXXTOOLS_UNIT_ASSERT_EQUALS(mp2.size(), 2);
        }
コード例 #4
0
capd::map::CnCoeff<MatrixType> linearSubstitution(
      const MatrixType& N,
      const capd::map::CnCoeff<MatrixType>& s,
      const MatrixType& M
   )
{
   typedef capd::vectalg::Multiindex::MultiindexVector MultiindexVector;
   typedef typename MatrixType::ScalarType ScalarType;
   int dimension = s.dimension();
   int rank = s.rank();

   capd::vectalg::Multiindex::IndicesSet indices;
   capd::vectalg::Multiindex::generateList(dimension,rank,indices);
   if(dimension!=M.numberOfRows() || dimension!=M.numberOfColumns() || dimension!=N.numberOfRows() || dimension!=N.numberOfColumns() )
   {
      throw std::runtime_error("normalForms::linearSubstitution - incompatible dimensions");
   }
   
   capd::map::CnCoeff<MatrixType> result (dimension,rank);

   for(int r=1;r<=rank;++r)
   {
      capd::vectalg::Multipointer mp = s.first(r);
      do{
         typename capd::map::CnCoeff<MatrixType>::VectorType temp(dimension);
         
         MultiindexVector::iterator b=indices[r-1].begin(), e=indices[r-1].end();
         while(b!=e)
         {
            ScalarType product = M((*b)[0]+1,mp[0]+1);
            for(int j=1;j<r;++j)
               product *= M((*b)[j]+1,mp[j]+1);

            capd::vectalg::Multipointer mp2(b->dimension(),b->begin());
            std::sort(mp2.begin(),mp2.end());
            temp += s(mp2)*product;
            ++b;
         }

         result(mp) = N*temp;
      }while(s.next(mp));
   }

   return result;
}
コード例 #5
0
ファイル: test_framebuffer.cpp プロジェクト: sondrele/NTNU
void bounding_box_for_microPolygon_has_right_coords() {
    MeshPoint mp1(-10, -10, 100);
    MeshPoint mp2(10, -10, 100);
    MeshPoint mp3(-10, 10, 100);
    MeshPoint mp4(10, 10, 100);
    MicroPolygon poly;
    poly.a = mp1;
    poly.b = mp2;
    poly.c = mp3;
    poly.d = mp4;

    FrameBuffer fb(500, 500);
    fb.projectMicroPolygon(poly);

    BoundingBox box = poly.getBoundingBox();
    ASSERT_EQUAL_INT(box.X_start, 206);
    ASSERT_EQUAL_INT(box.Y_start, 206);
    ASSERT_EQUAL_INT(box.X_stop, 294);
    ASSERT_EQUAL_INT(box.Y_stop, 294);
}
コード例 #6
0
int main(int argc, char** argv) {
    BinarySerializer bs;
    Point<double> p(2);
    p.mX[0] = 1;
    p.mX[1] = 2;
    bs << p;
    MultiPoint<double> mp(2,2);
    mp.mParam.mX[0] = 1;
    mp.mParam.mX[1] = 2;
    mp.mCrit.mX[0] = 3;
    mp.mCrit.mX[1] = 4;
    bs << mp;
    Point<double> q(2);
    bs.reset();
    bs >> q;
    //rintf("%s\n", q.toString().c_str());
    BNB_ASSERT((p.mX[0] == q.mX[0]) && (p.mX[1] == q.mX[1]));
    MultiPoint<double> mq(2,2);
    bs >> mq;
    //printf("%s\n", mq.toString().c_str());
    BNB_ASSERT((mp.mParam.mX[0] == mq.mParam.mX[0]) && (mp.mParam.mX[1] == mq.mParam.mX[1]));
    BNB_ASSERT((mp.mCrit.mX[0] == mq.mCrit.mX[0]) && (mp.mCrit.mX[1] == mq.mCrit.mX[1]));
    MultiPoint<double> mp1(2,3);
    mp1.mParam.mX[0] = 0;
    mp1.mParam.mX[1] = 1;
    mp1.mCrit.mX[0] = 3;
    mp1.mCrit.mX[1] = 4;
    mp1.mCrit.mX[2] = 5;
    MultiPoint<double> mp2(2,3);
    mp2.mParam.mX[0] = 10;
    mp2.mParam.mX[1] = 11;
    mp2.mCrit.mX[0] = 5;
    mp2.mCrit.mX[1] = 4;
    mp2.mCrit.mX[2] = 3;
    MPSimpBag<double> mpsbag;
    mpsbag.put(mp1);
    mpsbag.put(mp2);
    bs.reset();
    bs << mpsbag;
    bs.reset();
    MPSimpBag<double> mpsbagn;
    bs >> mpsbagn;
    //printf("%s\n", mpsbagn.toString().c_str());
    BNB_ASSERT(mpsbagn.size() == 2);
    bs.reset();

    Box<double> bx1(2);
    bx1.mA[0] = 1;
    bx1.mA[1] = 2;
    bx1.mB[0] = 3;
    bx1.mB[1] = 4;
    bs << bx1;
    Box<double> bx2(2);
    bs.reset();
    bs >> bx2;
    //printf("%s\n", BoxUtils::toString(bx2).c_str());
    BNB_ASSERT(bx1.mA[0] == bx2.mA[0]);
    BNB_ASSERT(bx1.mA[1] == bx2.mA[1]);
    BNB_ASSERT(bx1.mB[0] == bx2.mB[0]);
    BNB_ASSERT(bx1.mB[1] == bx2.mB[1]);
    
    SimpBoxBag<double> sb;
    sb.put(bx1);
    sb.put(bx2);
    bs.reset();
    bs << sb;
    bs.reset();
    SimpBoxBag<double> sb1;
    bs >> sb1;
    //printf("sb1: %s\n", sb1.toString().c_str());
    BNB_ASSERT(sb1.size() == 2);
    return 0;
}
コード例 #7
0
ファイル: pi.c プロジェクト: AG-Systems/compiler
int main()
{
	write(mp2(10000));
	return 0;
}
コード例 #8
0
ファイル: filterQTView.cpp プロジェクト: findMF/findMFHCS
int main(int argc, char *argv[])
{
  b_po::variables_map vmgeneral;
  parsecommandlineExtract(argc, argv, vmgeneral);
  ralab::findmf::apps::Params aparam;
  analysisParameters(aparam,vmgeneral);
  int res = 0;
  boost::filesystem::path p1,p2;

  {
    // LOG(INFO)  << "i::::" << i << std::endl;
    p1 = ralab::findmf::createOutputs(aparam.infile,"");
    p2 = ralab::findmf::createOutputs(aparam.infile,"filtered");

    if( !boost::filesystem::exists(aparam.infile) )
    {
      return -1;
    }

    ralab::findmf::datastruct::MSFileInfoPtr sip;
    try{
      ralab::findmf::SwathPropertiesReader swathPropReader(aparam.infile);
      sip = swathPropReader.getSwathInfo();
    } catch(std::exception & e){
      std::cerr << "infile : " << aparam.infile << std::endl;
      std::cerr  << "can't open file: " << e.what() << std::endl;
      return 0;
    }

    double ppm = aparam.ppm;
    pwiz::msdata::MSDataPtr msdataptr = pwiz::msdata::MSDataPtr(new pwiz::msdata::MSDataFile(aparam.infile));
    ralab::findmf::LCMSImageReader sm(msdataptr, sip, ppm, aparam.rt2sum_ );
    ralab::findmf::datastruct::LCMSImage mp;
    sm.getMap( 0 , aparam.minmass, aparam.maxmass, mp);
    // LOG(INFO) << " " << mp.getMZsize() << " " << mp.getRTsize();

    ralab::findmf::datastruct::LCMSImage mp2( mp );
    {
      ralab::findmf::LCMSImageFilterGauss imgf;
      // imgf.filterMap( mp2.getImageMap().getMap() , aparam.mzpixelwidth , aparam.rtpixelwidth, aparam.mzscale, aparam.rtscale);

      imgf.filter( mp2.getImageMap().getMap() , aparam.mzpixelwidth , aparam.rtpixelwidth, aparam.mzscale, aparam.rtscale);
      mp2.getImageMap().updateImageRange();
      std::cout << mp2.getImageMap().getImageMin() << std::endl;
      //imgf.filterMap();
    }

    // feature finding
    ralab::findmf::FeatureFinderLocalMax ff;
    ff.findFeature( mp2.getImageMap().getMap() , aparam.minintensity );

    ralab::findmf::datastruct::FeaturesMap map;
    map.setMapDescription(mp2.getMapDescription());
    ralab::findmf::ComputeFeatureStatistics cfs;
    cfs.extractFeatures(map,mp2.getImageMap().getMap(),ff.getLabels());

    //this writes the accessor....
   cfs.writeFeatures(aparam.outdir , p1.stem().string() );

    ralab::FeaturesMapPrinter fp;
    fp.writeFeatures(aparam.outdir , p1.stem().string(), map);

    ralab::MultiArrayVisSegments<int> mavL( ff.getLabels() );
    //write filtered data into mzML file

    //TODO check why this isn't working
    sm.write( p2.string() , mp2 );

    if(1){
      QApplication app(argc, argv);
      ralab::TwoPaneledImageWidget tpi;
      ralab::MultiArrayVisLog<float> adapt2( mp2.getImageMap().getMap() );

      ralab::MultiArrayVisAsinh<float> adapt1( mp2.getImageMap().getMap() );
      ralab::MultiArrayVisLog<float> adapt0( mp.getImageMap().getMap() );

      tpi.setTopMap(&mavL);
      //tpi.setBottomMap(&adapt0);
      tpi.setBottomMap(&adapt0);

      tpi.show();
      res = app.exec();
    }
  }
  return res;
}
コード例 #9
0
CPatcher_EnableFSAA::CPatcher_EnableFSAA( void )
{
	patchname = "Enable FSAA";

	addrReadFSAA = CAddr::Addr(CGameOptionMgr_ReadFSAA);
	addrReadFSAAQuality = CAddr::Addr(CGameOptionMgr_ReadFSAAQuality);

	if (!addrReadFSAA ||
        !addrReadFSAAQuality)
	{
		WriteLog("Patch initialization failed: %s.\n", patchname.c_str());
		WriteLog("   Missing dependency.\n");
		return;
	}

	vector<WORD> patch1;
	vector<WORD> backup1;
	backup1 +=
		0x89, 0x7E, 0x10,						// +3B: MOV [ESI+10h], EDI
		0x89, 0x7E, 0x14,						// +3E: MOV [ESI+14h], EDI
		0xE8, -1, -1, -1, -1,					// +41: CALL pleione::CGameOptionMgr::ReadDithering(void)
		0x8B, 0xCE,								// +46: MOV ECX, ESI
		0x88, 0x46, 0x4C,						// +48: MOV [ESI+4Ch], AL
		0xE8, -1, -1, -1, -1,					// +4B: CALL xxxxxxxx
		0x8B, 0xCE,								// +50: MOV ECX, ESI
		0x88, 0x46, 0x4D;						// +52: MOV [ESI+4Dh], AL

	patch1 +=
		0xE9, 0x01FF, 0x01FF, 0x01FF, 0x01FF,	// +3B: JMP LONG patchFSAA
		0x90,									//      NOP
		-1, -1, -1, -1, -1, -1, -1,	-1, -1, -1,
		-1, -1, -1, -1, -1,	-1, -1,	-1, -1, -1;

	MemoryPatch mp1( NULL, patch1, backup1 );
	mp1.Search( L"Pleione.dll" );
	mp1.PatchRelativeAddress( 0x01, (LPBYTE)patchFSAA );

	addrTargetReturn = mp1.GetAddr() + 6;	// Size of patch

	vector<WORD> patch2;
	vector<WORD> backup2;
	backup2 +=
		0x83, 0x4D, 0xFC, 0xFF,				// +59E: OR [EBP-04h], 0xFFFFFFFF
		0x8D, 0x4D, 0x08,					// +5A2: LEA ECX, [EBP+08h]
		0xFF, 0xD6,							// +5A5: CALL ESI
		0x8B, 0x8B, 0x1C, 0x01, 0x00, 0x00,	// +5A7: MOV ECX, [EBX+11Ch]
		0x8B, 0x01,							// +5AD: MOV EAX, [ECX]
		0x6A, 0x00,							// +5AF: PUSH 0x00
		0xFF, 0x50, 0x4C,					// +5B1: CALL DWORD PTR [EAX+4Ch]
		0x6A, 0x0B;							// +5B4: PUSH 0x0B
	patch2 +=
		-1, -1, -1, -1, -1, -1, -1, -1, -1,
		-1, -1, -1, -1, -1, -1, -1, -1,
		0x6A, 0x01,							// +5AF: PUSH 0x00 => PUSH 0x01
		-1, -1, -1, -1, -1;

	MemoryPatch mp2( NULL, patch2, backup2 );
	mp2.Search( L"Pleione.dll" );
	
	patches += mp1;
	patches += mp2;
	if (CheckPatches())
		WriteLog("Patch initialization successful: %s.\n", patchname.c_str());
	else
		WriteLog("Patch initialization failed: %s.\n", patchname.c_str());
}