Beispiel #1
0
static void on26_read_block( PIA *pi, char * buf, int count )

{       int     k, a, b;

        switch (pi->mode) {

        case 0: w0(1); P1; w0(1); P2; w0(2); P1; w0(0x18); P2; w0(0); P1;
		udelay(10);
		for (k=0;k<count;k++) {
                        w2(6); a = r1();
                        w2(4); b = r1();
                        buf[k] = j44(a,b);
                }
		w0(2); P1; w0(8); P2; 
                break;

        case 1: w0(1); P1; w0(1); P2; w0(2); P1; w0(0x19); P2; w0(0); P1;
		udelay(10);
                for (k=0;k<count/2;k++) {
                        w2(0x26); buf[2*k] = r0();  
			w2(0x24); buf[2*k+1] = r0();
                }
                w0(2); P1; w0(9); P2;
                break;

        case 2: w3(1); w3(1); w2(5); w4(1); w2(4);
		w3(0); w3(0); w2(0x24);
		udelay(10);
                for (k=0;k<count;k++) buf[k] = r4();
                w2(4);
                break;

        case 3: w3(1); w3(1); w2(5); w4(1); w2(4);
                w3(0); w3(0); w2(0x24);
                udelay(10);
                for (k=0;k<count/2;k++) ((u16 *)buf)[k] = r4w();
                w2(4);
                break;

        case 4: w3(1); w3(1); w2(5); w4(1); w2(4);
                w3(0); w3(0); w2(0x24);
                udelay(10);
                for (k=0;k<count/4;k++) ((u32 *)buf)[k] = r4l();
                w2(4);
                break;

        }
}
Beispiel #2
0
static void epat_write_block( PIA *pi, char * buf, int count )   

{	int ph, k;

	switch (pi->mode) {

	case 0:
	case 1:
	case 2: w0(0x67); w2(1); w2(5);
		ph = 0;
		for(k=0;k<count;k++) {
		  	w0(buf[k]);
			w2(4+ph);
			ph = 1 - ph;
		}
		w2(7); w2(4);
		break;

	case 3: w3(0xc0); 
		for(k=0;k<count;k++) w4(buf[k]);
		w2(4);
		break;

	case 4: w3(0xc0); 
		for(k=0;k<(count/2);k++) w4w(((u16 *)buf)[k]);
		w2(4);
		break;

	case 5: w3(0xc0); 
		for(k=0;k<(count/4);k++) w4l(((u32 *)buf)[k]);
		w2(4);
		break;

	}
}
  void runTestMulti()
  {
    TranslatedTagDifferencer uut;
    Settings s;
    s.set(ConfigOptions::getTranslatedTagDifferencerScriptKey(),
          "translations/HootTest.js");
    // ignore the UFI
    s.set(ConfigOptions::getTranslatedTagDifferencerIgnoreListKey(), "UFI");
    uut.setConfiguration(s);

    shared_ptr<OsmMap> map(new OsmMap());
    WayPtr w1(new Way(Status::Unknown1, -1, 0));
    w1->getTags()["name"] = "foo";
    w1->getTags()["highway"] = "road";

    WayPtr w2(new Way(Status::Unknown1, -1, 0));
    w2->getTags()["name"] = "foo";
    w2->getTags()["highway"] = "road";
    w2->getTags()["bridge"] = "yes";

    // creates one record in w1 and two in w2.
    CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0 / 11.0, uut.diff(map, w1, w2), 1e-5);

    WayPtr w3(new Way(Status::Unknown1, -1, 0));
    w3->getTags()["name"] = "foo";
    w3->getTags()["highway"] = "road";
    w3->getTags()["bridge"] = "yes";

    WayPtr w4(new Way(Status::Unknown1, -1, 0));
    w4->getTags()["name"] = "bar";
    w4->getTags()["highway"] = "road";
    w4->getTags()["bridge"] = "yes";

    CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0 / 11.0, uut.diff(map, w3, w4), 1e-5);
  }
Beispiel #4
0
//A triangular prism (no boundary edges)
void SubdivScene::scenario3() {

  VertexData w1(5,0,0);
  w1.colour(1,0,0);
  VertexData w2(0,0,10);
  w2.colour(1,1,0);
  VertexData w3(-5,0,0);
  w3.colour(0,0,1);
  VertexData w4(0,10,0);
  
  HDS.beginPolygon(w1);
  HDS.nextVertex(w2);
  Edge& e = HDS.nextVertex(w3); //edge from w3 to w1
  e.vertex->print();
  Face& f = HDS.endPolygon();

  HDS.beginPolygon(e);
  HDS.nextVertex(w4);
  HDS.endPolygon(); 
  const std::vector<Vertex*>& vList = HDS.getVertexList();
  Vertex* list[3] = { vList[2], vList[1], vList[3] };
  HDS.makePolygon(3, list);
  Vertex* list2[3] = { vList[1], vList[0], vList[3] };
  HDS.makePolygon(3, list2);

  const std::vector<Face*> fList = HDS.getFaceList();

  for(unsigned int i=0; i< fList.size(); i++) {
    HDS.checkConsistency(*fList[i]);
  }
}
Beispiel #5
0
static void dstr_write_block( PIA *pi, char * buf, int count )

{       int	k;

        w0(0x81); P1;
        if (pi->mode) { w0(0x19); } else { w0(9); }
        P2; w0(0x82); P1; P3; w0(0x20); P1;

        switch (pi->mode) {

        case 0:
        case 1: for (k=0;k<count;k++) {
                        w2(5); w0(buf[k]); w2(7);
                }
                w2(5); w2(4);
                break;

        case 2: w2(0xc5);
                for (k=0;k<count;k++) w4(buf[k]);
		w2(0xc4);
                break;

        case 3: w2(0xc5);
                for (k=0;k<count/2;k++) w4w(((u16 *)buf)[k]);
                w2(0xc4);
                break;

        case 4: w2(0xc5);
                for (k=0;k<count/4;k++) w4l(((u32 *)buf)[k]);
                w2(0xc4);
                break;

        }
}
int main()
{
  Widget w1;    // calls default ctor

  Widget w2{};  // also calls default ctor

  Widget w3();  // most vexing parse! declares a function!

  Widget w4({});  // calls std::init_list ctor
                  // with empty list

  Widget w5{{}};  // ditto

  auto w6{w5};  // calls copy ctor, not
                // std::list_init<int> ctor, even
                // though Widget converts to int

  auto w7{std::move(w5)};  // ditto, but for move ctor
                           // (Item 28 has info on std::move)

  std::vector<int> v1(10, 20);  // use non-std::initializer_list
                                // ctor: create 10-element
                                // std::vector, all elements have
                                // value of 20

  std::vector<int> v2{10, 20};  // use std::initializer_list ctor:
                                // create 2-element std::vector,
                                // element values are 10 and 20
}
Beispiel #7
0
static int on26_read_regr( PIA *pi, int cont, int regr )

{       int     a, b, r;

	r = (regr<<2) + 1 + cont;

        switch (pi->mode)  {

        case 0: w0(1); P1; w0(r); P2; w0(0); P1; 
		w2(6); a = r1(); w2(4);
		w2(6); b = r1(); w2(4);
		w2(6); w2(4); w2(6); w2(4);
                return j44(a,b);

        case 1: w0(1); P1; w0(r); P2; w0(0); P1;
		w2(0x26); a = r0(); w2(4); w2(0x26); w2(4);
                return a;

	case 2:
	case 3:
        case 4: w3(1); w3(1); w2(5); w4(r); w2(4);
		w3(0); w3(0); w2(0x24); a = r4(); w2(4);
		w2(0x24); r4(); w2(4);
                return a;

        }
        return -1;
}       
Beispiel #8
0
//______________________________________________________________________________
void WriteARCalibration()
{
    // load CaLib
    gSystem->Load("libCaLib.so");
    
    // write tagger calibration file
    TCWriteARCalib w(kDETECTOR_TAGG, "FP.dat");
    w.Write("new_FP.dat", "LD2_Dec_07", 13840);

    // write CB calibration file
    TCWriteARCalib w1(kDETECTOR_CB, "NaI.dat");
    w1.Write("new_NaI.dat", "LD2_Dec_07", 13840);

    // write TAPS calibration file
    TCWriteARCalib w2(kDETECTOR_TAPS, "BaF2.dat");
    w2.Write("new_BaF2.dat", "LD2_Dec_07", 13090);

    // write PID calibration file
    TCWriteARCalib w3(kDETECTOR_PID, "PID.dat");
    w3.Write("new_PID.dat", "LD2_Dec_07", 13840);

    // write Veto calibration file
    TCWriteARCalib w4(kDETECTOR_VETO, "Veto.dat");
    w4.Write("new_Veto.dat", "LD2_Dec_07", 13840);

    gSystem->Exit(0);
}
static void comm_write_block( PIA *pi, char * buf, int count )

{       int	k;

        switch (pi->mode) {

        case 0:
        case 1: w0(0x68); P1;
        	for (k=0;k<count;k++) {
                        w2(5); w0(buf[k^1]); w2(7);
                }
                w2(5); w2(4);
                break;

        case 2: w3(0x48); (void)r1();
                for (k=0;k<count;k++) w4(buf[k^1]);
                break;

        case 3: w3(0x48); (void)r1();
                for (k=0;k<count/2;k++) w4w(pi_swab16(buf,k));
                break;

        case 4: w3(0x48); (void)r1();
                for (k=0;k<count/4;k++) w4l(pi_swab32(buf,k));
                break;


        }
}
void main()
{	
	int i,j,m=2;
	double y[50],y1[5];
	srand((unsigned)time(NULL));
	FILE *fp;
	fp=fopen("filter.xls","w+");
	for(N=1;N<=N1;N++)
	{
		for(i=0;i<n;i++)
		{
			z[i]=0;
			z[i]=w1();
		}
		w3();
		w4();
		y[N-1]=asd;
		fprintf(fp,"%d\t%lf\n",N,y[N-1]);
	}
	//
	for(i=m;i<N1-m;i++)
	{
		y1[0]=(1.0/5.0)*(3*y[i-2]+2*y[i-1]+y[i]-y[i+2]);
		y1[1]=(1.0/10.0)*(4*y[i-2]+3*y[i-1]+2*y[i]+y[i+1]);
		y1[2]=(1.0/5.0)*(y[i-2]+y[i-1]+y[i]+y[i+1]+y[i+2]);
		y1[3]=(1.0/10.0)*(y[i-1]+2*y[i]+3*y[i+1]+4*y[i+2]);
		y1[4]=(1.0/5.0)*(-y[i-2]+y[i]+2*y[i+1]+3*y[i+2]);
		for(j=0;j<(2*m+1);j++)
		{
			y[i-m+j]=y1[j];
		}
	}
	fprintf(fp,"\n");
	for(N=1;N<=N1;N++)
	{
		fprintf(fp,"%d\t%f\n",N,y[N-1]+0.0003);// 0.0003 for better presentation
	}
	//
	for(i=m;i<N1-m;i++)
	{
		y1[0]=(1.0/70.0)*(69*y[i-2]+4*y[i-1]-6*y[i]+4*y[i+1]-y[i+2]);
		y1[1]=(1.0/35.0)*(2*y[i-2]+27*y[i-1]+12*y[i]-8*y[i+1]+2*y[i+2]);
		y1[2]=(1.0/35.0)*(-3*y[i-2]+12*y[i-1]+17*y[i]+12*y[i+1]-3*y[i+2]);
		y1[3]=(1.0/35.0)*(2*y[i-2]-8*y[i-1]+12*y[i]+27*y[i+1]+2*y[i+2]);
		y1[4]=(1.0/70.0)*(-y[i-2]+4*y[i-1]-6*y[i]+4*y[i+1]+69*y[i+2]);
		for(j=0;j<(2*m+1);j++)
		{
			y[i-m+j]=y1[j];
		}
	}
	fprintf(fp,"\n");
	for(N=1;N<=N1;N++)
	{
		fprintf(fp,"%d\t%f\n",N,y[N-1]+0.0006);//0.0006 for plotting
	}
	fclose(fp);
}
Beispiel #11
0
  shared_ptr<OsmMap> createTestMap()
  {
    shared_ptr<OsmMap> map(new OsmMap());
    _map = map;

    shared_ptr<Node> n1 = createNode(0.0, 0.0);
    n1->setTag("building", "yes");
    n1->setTag("name", "n1");

    shared_ptr<Way> w1(new Way(Status::Unknown1, map->createNextWayId(), 13.0));
    w1->setTag("area", "yes");
    w1->setTag("building", "yes");
    w1->setTag("name", "w1");
    w1->addNode(createNode(0.1, 0.0)->getId());
    w1->addNode(createNode(0.2, 0.0)->getId());
    w1->addNode(createNode(0.2, 0.1)->getId());
    w1->addNode(w1->getNodeId(0));
    map->addWay(w1);

    shared_ptr<Way> w2(new Way(Status::Unknown1, map->createNextWayId(), 13.0));
    w2->setTag("highway", "track");
    w2->setTag("name", "w2");
    w2->addNode(createNode(0.3, 0.0)->getId());
    w2->addNode(createNode(0.3, 0.1)->getId());
    map->addWay(w2);

    shared_ptr<Way> w3(new Way(Status::Unknown1, map->createNextWayId(), 13.0));
    w3->setTag("highway", "road");
    w3->setTag("name", "w3");
    w3->addNode(createNode(0.4, 0.0)->getId());
    w3->addNode(createNode(0.4, 0.1)->getId());
    map->addWay(w3);

    shared_ptr<Way> w4(new Way(Status::Unknown1, map->createNextWayId(), 13.0));
    w4->addNode(createNode(0.5, 0.0)->getId());
    w4->addNode(createNode(0.7, 0.0)->getId());
    w4->addNode(createNode(0.6, 0.1)->getId());
    w4->addNode(w4->getNodeId(0));
    map->addWay(w4);

    shared_ptr<Way> w5(new Way(Status::Unknown1, map->createNextWayId(), 13.0));
    w5->addNode(createNode(0.55, 0.01)->getId());
    w5->addNode(createNode(0.65, 0.01)->getId());
    w5->addNode(createNode(0.6, 0.05)->getId());
    w5->addNode(w5->getNodeId(0));
    map->addWay(w5);

    shared_ptr<Relation> r1(new Relation(Status::Unknown1, 1, 15.0, "multipolygon"));
    r1->setTag("building", "yes");
    r1->setTag("name", "r1");
    r1->addElement("outer", w4->getElementId());
    r1->addElement("inner", w5->getElementId());
    map->addRelation(r1);

    return map;
  }
Beispiel #12
0
static void  fit3_write_regr( PIA *pi, int cont, int regr, int val)

{	if (cont == 1) return;

	switch (pi->mode) {

	case 0:
	case 1: w2(0xc); w0(regr); w2(0x8); w2(0xc);
		w0(val); w2(0xd);
		w0(0);   w2(0xc);
		break;

	case 2: w2(0xc); w0(regr); w2(0x8); w2(0xc);
		w4(val); w4(0);
		w2(0xc);
		break;

	}
}
Beispiel #13
0
static void on26_write_block( PIA *pi, char * buf, int count )

{       int	k;

        switch (pi->mode) {

        case 0: 
        case 1: w0(1); P1; w0(1); P2; 
		w0(2); P1; w0(0x18+pi->mode); P2; w0(0); P1;
		udelay(10);
		for (k=0;k<count/2;k++) {
                        w2(5); w0(buf[2*k]); 
			w2(7); w0(buf[2*k+1]);
                }
                w2(5); w2(4);
		w0(2); P1; w0(8+pi->mode); P2;
                break;

        case 2: w3(1); w3(1); w2(5); w4(1); w2(4);
		w3(0); w3(0); w2(0xc5);
		udelay(10);
                for (k=0;k<count;k++) w4(buf[k]);
		w2(0xc4);
                break;

        case 3: w3(1); w3(1); w2(5); w4(1); w2(4);
                w3(0); w3(0); w2(0xc5);
                udelay(10);
                for (k=0;k<count/2;k++) w4w(((u16 *)buf)[k]);
                w2(0xc4);
                break;

        case 4: w3(1); w3(1); w2(5); w4(1); w2(4);
                w3(0); w3(0); w2(0xc5);
                udelay(10);
                for (k=0;k<count/4;k++) w4l(((u32 *)buf)[k]);
                w2(0xc4);
                break;

        }

}
Beispiel #14
0
static void on26_write_regr( PIA *pi, int cont, int regr, int val )

{       int  r;

        r = (regr<<2) + 1 + cont;

        switch (pi->mode)  {

        case 0:
        case 1: w0(1); P1; w0(r); P2; w0(0); P1;
		w0(val); P2; w0(val); P2;
		break;

	case 2:
	case 3:
        case 4: w3(1); w3(1); w2(5); w4(r); w2(4);
		w3(0); w3(0); 
		w2(5); w4(val); w2(4);
		w2(5); w4(val); w2(4);
                break;
        }
}
Beispiel #15
0
static void  kbic_write_regr( PIA *pi, int cont, int regr, int val)

{       int  s;

        s = cont_map[cont];

        switch (pi->mode) {

	case 0: 
        case 1:
	case 2:	w0(regr|0x10|s); w2(4); w2(6); w2(4); 
		w0(val); w2(5); w2(4);
		break;

	case 3:
	case 4:
	case 5: w0(0x20|s); w2(4); w2(6); w2(4); w3(regr);
		w4(val); w4(val);
		w2(4); w2(0); w2(4);
                break;

	}
}
Beispiel #16
0
int main(void) {
    Word w1("beast");
    Word w2("dough");
    Word w3("happy");
    Word w4("question");

    std::cout << "Let's go" << std::endl;
    std::cout << w1.pigLatinify() << std::endl;
    std::cout << w2.pigLatinify() << std::endl;
    std::cout << w3.pigLatinify() << std::endl;
    std::cout << w4.pigLatinify() << std::endl;

    return 0;
}
Beispiel #17
0
// A triangle
void SubdivScene::scenario1() {

  VertexData w1(1,0,0);
  w1.colour(1,0,0);
  VertexData w2(0,1,0);
  w2.colour(1,1,0);
  VertexData w3(0,0,0);
  w3.colour(0,0,1);
  VertexData w4(0,1,1);
  HDS.beginPolygon(w1);
  HDS.nextVertex(w2);
  Edge& e = HDS.nextVertex(w3);
  Face& f = HDS.endPolygon();
}
Beispiel #18
0
static void kbic_write_block( PIA *pi, char * buf, int count )

{       int     k;

        switch (pi->mode) {

        case 0:
        case 1:
        case 2: w0(0x90); w2(4); w2(6); w2(4); 
		for(k=0;k<count/2;k++) {
			w0(buf[2*k+1]); w2(0); w2(4); 
			w0(buf[2*k]);   w2(5); w2(4); 
		}
		break;

        case 3: w0(0xa0); w2(4); w2(6); w2(4); w3(0);
		for(k=0;k<count/2;k++) {
			w4(buf[2*k+1]); 
                        w4(buf[2*k]);
                }
		w2(4); w2(0); w2(4);
		break;

	case 4: w0(0xa0); w2(4); w2(6); w2(4); w3(0);
                for(k=0;k<count/2;k++) w4w(pi_swab16(buf,k));
                w2(4); w2(0); w2(4);
                break;

        case 5: w0(0xa0); w2(4); w2(6); w2(4); w3(0);
                for(k=0;k<count/4;k++) w4l(pi_swab32(buf,k));
                w2(4); w2(0); w2(4);
                break;

        }

}
static void comm_write_regr( PIA *pi, int cont, int regr, int val )

{       int  r;

        r = regr + cont_map[cont];

        switch (pi->mode)  {

        case 0:
        case 1: w0(r); P1; w0(val); P2;
		break;

	case 2:
	case 3:
        case 4: w3(r); (void)r1(); w4(val);
                break;
        }
}
Beispiel #20
0
static void fit3_write_block( PIA *pi, char * buf, int count )

{	int k;

        switch (pi->mode) {

	case 0:
        case 1: w2(0xc); w0(0); w2(0x8); w2(0xc);
                for (k=0;k<count/2;k++) {
 		    w0(buf[2*k  ]); w2(0xd);
 		    w0(buf[2*k+1]); w2(0xc);
		}
		break;

        case 2: w2(0xc); w0(0); w2(0x8); w2(0xc);
                for (k=0;k<count;k++) w4(buf[k]);
                w2(0xc);
		break;
	}
}
Beispiel #21
0
static void epat_write_regr( PIA *pi, int cont, int regr, int val)

{	int r;

	r = regr + cont_map[cont];

	switch (pi->mode) {

	case 0:
	case 1:
	case 2:	w0(0x60+r); w2(1); w0(val); w2(4);
		break;

	case 3:
	case 4:
	case 5: w3(0x40+r); w4(val);
		break;

	}
}
Beispiel #22
0
static void epia_write_regr( PIA *pi, int cont, int regr, int val)

{       int  r;

	regr += cont_map[cont];

        switch (pi->mode)  {

        case 0:
        case 1:
        case 2: r = regr^0x19;
                w0(r); w2(1); w0(val); w2(3); w2(4);
                break;

	case 3:
	case 4:
        case 5: r = regr^0x40;
                w3(r); w4(val); w2(4);
                break;
        }
}
Beispiel #23
0
static void epia_write_block( PIA *pi, char * buf, int count )

{       int     ph, k, last, d;

        switch (pi->mode) {

        case 0:
        case 1:
        case 2: w0(0xa1); w2(1); w2(3); w2(1); w2(5);
                ph = 0;  last = 0x8000;
                for (k=0;k<count;k++) {
                        d = buf[k];
                        if (d != last) { last = d; w0(d); }
                        w2(4+ph);
                        ph = 1 - ph;
                }
                w2(7); w2(4);
                break;

        case 3: if (count < 512) WR(0x84,1);
		w3(0x40);
                for (k=0;k<count;k++) w4(buf[k]);
		if (count < 512) WR(0x84,0);
                break;

        case 4: if (count < 512) WR(0x84,1);
		w3(0x40);
                for (k=0;k<count/2;k++) w4w(((u16 *)buf)[k]);
		if (count < 512) WR(0x84,0);
                break;

        case 5: if (count < 512) WR(0x84,1);
		w3(0x40);
                for (k=0;k<count/4;k++) w4l(((u32 *)buf)[k]);
		if (count < 512) WR(0x84,0);
                break;

        }

}
Beispiel #24
0
static void dstr_write_regr(  PIA *pi, int cont, int regr, int val )

{       int  r;

        r = regr + cont_map[cont];

	w0(0x81); P1; 
	if (pi->mode >= 2) { w0(0x11); } else { w0(1); }
	P2; w0(r); P1;
	
        switch (pi->mode)  {

        case 0:
        case 1: w0(val); w2(5); w2(7); w2(5); w2(4);
		break;

	case 2:
	case 3:
        case 4: w4(val); 
                break;
        }
}
Beispiel #25
0
	void testVec5Equal() {
		glam::Vector<float, 5> v(1, 2, 3.5, 100, 0.00001);
		TS_ASSERT(v == v);
		TS_ASSERT(!(v != v));
		glam::Vector<float, 5> v2(1, 2, 3.5, 100, 0.00001);
		TS_ASSERT(v == v2);
		glam::Vector<float, 5> w(0, 2, 3.5, 200, 0.0001);
		TS_ASSERT(v != w);
		glam::Vector<float, 5> w1(1, 2, 3.5, 100, 0.00001);
		TS_ASSERT(glam::all(glam::equal(v, w1)));
		glam::Vector<float, 5> w2(1, 2, 3.5, 100, 0.0001);
		TS_ASSERT(!glam::all(glam::equal(v, w2)));
		TS_ASSERT(glam::any(glam::equal(v, w2)));
		glam::Vector<float, 5> w3(0, 0, 0, 0, 0);
		TS_ASSERT(!glam::all(glam::equal(v, w3)));
		TS_ASSERT(!glam::any(glam::equal(v, w3)));
		TS_ASSERT(glam::all(glam::notEqual(v, w3)));
		TS_ASSERT(glam::any(glam::notEqual(v, w3)));
		glam::Vector<float, 5> w4(0.0001, 100, 3.5, 2, 1);
		TS_ASSERT(!glam::all(glam::equal(v, w4)));
		TS_ASSERT(glam::any(glam::equal(v, w4)));
		TS_ASSERT(glam::any(glam::notEqual(v, w4)));
	}
Beispiel #26
0
void VectorTest::test_constructor(void)
{
   message += "test_constructor\n";

   std::string file_name = "../data/vector.dat";

   // Default 

   Vector<bool> v1;

   assert_true(v1.size() == 0, LOG);   

   // Size

   Vector<bool> v2(1);

   assert_true(v2.size() == 1, LOG);

   // Size initialization

   Vector<bool> v3(1, false);

   assert_true(v3.size() == 1, LOG);
   assert_true(v3[0] == false, LOG);

   // File

   Vector<int> v4(3, 0);
   v4.save(file_name);

   Vector<int> w4(file_name);
   
   assert_true(w4.size() == 3, LOG);
   assert_true(w4 == 0, LOG);

   // Sequential

   Vector<int> v6(10, 5, 50);

   assert_true(v6.size() == 9, LOG);
   assert_true(v6[0] == 10, LOG);
   assert_true(v6[8] == 50, LOG);

   Vector<double> v7(3.0, 0.2, 3.8);

   assert_true(v7.size() == 5, LOG);
   assert_true(v7[0] == 3.0, LOG);
   assert_true(v7[4] == 3.8, LOG);

   Vector<int> v8(9, -1, 1);

   assert_true(v8.size() == 9, LOG);
   assert_true(v8[0] == 9, LOG);
   assert_true(v8[8] == 1, LOG);

   // Copy

   Vector<std::string> v5(1, "hello");

   Vector<std::string> w5(v5);

   assert_true(w5.size() == 1, LOG);
   assert_true(w5[0] == "hello", LOG);

}
Beispiel #27
0
void init_mine_mesh(GLShape& base_mesh, GLShape& wheel_mesh) {
    float d = 0.025f;
    float x0 = 1.5f * d;
    float x1 = 2.0f * d;
    float y0 = 3.0f * d;
    float y1 = 4.0f * d;
    float z0 = d * 0.25f;
    float z1 = d;
    
    Vector3 p0(-x1, 0.0f, z1);
    Vector3 p1(-x0, 0.0f, z1);
    Vector3 p2(-x0, y0, z0);
    Vector3 p3(x0, y0, z0);
    Vector3 p4(x0, 0.0f, z1);
    Vector3 p5(x1, 0.0f, z1);
    Vector3 p6(x1, y1, 0.0f);
    Vector3 p7(-x1, y1, 0.0f);
    
    Vector3 q0(-x1, 0.0f, -z1);
    Vector3 q1(-x0, 0.0f, -z1);
    Vector3 q2(-x0, y0, -z0);
    Vector3 q3(x0, y0, -z0);
    Vector3 q4(x0, 0.0f, -z1);
    Vector3 q5(x1, 0.0f, -z1);
    Vector3 q6(x1, y1, 0.0f);
    Vector3 q7(-x1, y1, 0.0f);
    
    base_mesh = {
        p0, p1, p2, p0, p2, p7, p2, p3, p6, p2, p6, p7, p3, p4, p5, p3, p5, p6,
        q0, q1, q2, q0, q2, q7, q2, q3, q6, q2, q6, q7, q3, q4, q5, q3, q5, q6
    };
    
    std::vector<Vector2> wheel = circle(Vector2(), 3.0f * d, 16);
    wheel = cut(wheel, circle(Vector2(), 2.5f * d, 16));
    
    wheel_mesh = to_xy(triangulate(wheel));
    
    Vector3 w0(-d * 0.25f, -2.75f * d, 0.0f);
    Vector3 w1(d * 0.25f, -2.75f * d, 0.0f);
    Vector3 w2(d * 0.25f, 2.75f * d, 0.0f);
    Vector3 w3(-d * 0.25f, 2.75f * d, 0.0f);
    
    Vector3 w4(-d * 2.75f, -0.25f * d, 0.0f);
    Vector3 w5(d * 2.75f, -0.25f * d, 0.0f);
    Vector3 w6(d * 2.75f, 0.25f * d, 0.0f);
    Vector3 w7(-d * 2.75f, 0.25f * d, 0.0f);
    
    wheel_mesh.push_back(w0);
    wheel_mesh.push_back(w1);
    wheel_mesh.push_back(w2);
    wheel_mesh.push_back(w0);
    wheel_mesh.push_back(w2);
    wheel_mesh.push_back(w3);
    
    wheel_mesh.push_back(w4);
    wheel_mesh.push_back(w5);
    wheel_mesh.push_back(w6);
    wheel_mesh.push_back(w4);
    wheel_mesh.push_back(w6);
    wheel_mesh.push_back(w7);
}