当前位置: 首页>>代码示例>>C++>>正文


C++ p1函数代码示例

本文整理汇总了C++中p1函数的典型用法代码示例。如果您正苦于以下问题:C++ p1函数的具体用法?C++ p1怎么用?C++ p1使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了p1函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: switch

void core::RestrictedLineF::setP2(const QPointF &p2)
{
	switch(lineConstrain){
		case RestrictedLineF::HorizontalLeft:

			if(p2.x() <= p1().x()){
				QLineF::setP2(QPointF(p2.x(), p1().y()));
			}else{
				QLineF::setP2(p1());
			}

			break;
		case RestrictedLineF::HorizontalRight:
			if(p2.x() >= p1().x()){
				QLineF::setP2(QPointF(p2.x(), p1().y()));
			}else{
				QLineF::setP2(p1());
			}
			break;
		case RestrictedLineF::Horizontal:
			QLineF::setP2(QPointF(p2.x(), p1().y()));
			break;
		case RestrictedLineF::VerticalUp:
			if(p2.y() <= p1().y()){
				QLineF::setP2(QPointF(p1().x(), p2.y()));
			}else{
				QLineF::setP2(p1());
			}
			break;
		case RestrictedLineF::VerticalDown:
			if(p2.y() >= p1().y()){
				QLineF::setP2(QPointF(p1().x(), p2.y()));
			}else{
				QLineF::setP2(p1());
			}
			break;
		case RestrictedLineF::Vertical:
			QLineF::setP2(QPointF(p1().x(), p2.y()));
			break;
		case RestrictedLineF::None:
			QLineF::setP2(p2);
			break;
		case RestrictedLineF::Both:
		default:
			break;

	}
}
开发者ID:VARPERTecnology,项目名称:INSYDE,代码行数:48,代码来源:restrictedlinef.cpp

示例2: max

void VisibilityLayout::layout(GraphAttributes &GA, const UpwardPlanRep &UPROrig)
{
	UpwardPlanRep UPR = UPROrig;

	//clear some data
	for(edge e : GA.constGraph().edges) {
		GA.bends(e).clear();
	}

	int minGridDist = 1;
	for(node v : GA.constGraph().nodes) {
		if (minGridDist < max(GA.height(v), GA.width(v)))
			minGridDist = (int) max(GA.height(v), GA.width(v));
	}
	minGridDist = max(minGridDist*2+1, m_grid_dist);

	CombinatorialEmbedding &gamma = UPR.getEmbedding();
	//add edge (s,t)
	adjEntry adjSrc = nullptr;
	for(adjEntry adj : UPR.getSuperSource()->adjEntries) {
		if (gamma.rightFace(adj) == gamma.externalFace())
			adjSrc = adj;
			break;
	}

	OGDF_ASSERT(adjSrc != nullptr);

	edge e_st = UPR.newEdge(adjSrc, UPR.getSuperSink()); // on the right
	gamma.computeFaces();
	gamma.setExternalFace(gamma.rightFace(e_st->adjSource()));

	constructVisibilityRepresentation(UPR);

	// the preliminary postion
	NodeArray<int> xPos(UPR);
	NodeArray<int> yPos(UPR);

	// node Position
	for(node v : UPR.nodes) {
		NodeSegment vVis = nodeToVis[v];
		int x = (int) (vVis.x_l + vVis.x_r)/2 ; // median positioning
		xPos[v] = x;
		yPos[v] = vVis.y;

		if (UPR.original(v) != nullptr) {
			node vOrig = UPR.original(v);
			//final position
			GA.x(vOrig) = x * minGridDist;
			GA.y(vOrig)	= vVis.y * minGridDist;
		}
	}

	//compute bendpoints
	for(edge e : GA.constGraph().edges) {
		const List<edge> &chain = UPR.chain(e);
		for(edge eUPR : chain) {
			EdgeSegment eVis = edgeToVis[eUPR];
			if (chain.size() == 1) {
				if ((yPos[eUPR->target()] - yPos[eUPR->source()]) > 1) {
					DPoint p1(eVis.x*minGridDist, (yPos[eUPR->source()]+1)*minGridDist);
					DPoint p2(eVis.x*minGridDist, (yPos[eUPR->target()]-1)*minGridDist);
					GA.bends(e).pushBack(p1);
					if (yPos[eUPR->source()]+1 != yPos[eUPR->target()]-1)
						GA.bends(e).pushBack(p2);
				}
			}
			else {
				//short edge
				if ((yPos[eUPR->target()] - yPos[eUPR->source()]) == 1) {
					if (UPR.original(eUPR->target()) == nullptr) {
						node tgtUPR = eUPR->target();
						DPoint p(xPos[tgtUPR]*minGridDist, yPos[tgtUPR]*minGridDist);
						GA.bends(e).pushBack(p);
					}
				}
				//long edge
				else {
					DPoint p1(eVis.x*minGridDist, (yPos[eUPR->source()]+1)*minGridDist);
					DPoint p2(eVis.x*minGridDist, (yPos[eUPR->target()]-1)*minGridDist);
					GA.bends(e).pushBack(p1);
					if (yPos[eUPR->source()]+1 != yPos[eUPR->target()]-1)
						GA.bends(e).pushBack(p2);
					if (UPR.original(eUPR->target()) == nullptr) {
						node tgtUPR = eUPR->target();
						DPoint p(xPos[tgtUPR]*minGridDist, yPos[tgtUPR]*minGridDist);
						GA.bends(e).pushBack(p);
					}
				}
			}
		}

		DPolyline &poly = GA.bends(e);
		DPoint pSrc(GA.x(e->source()), GA.y(e->source()));
		DPoint pTgt(GA.x(e->target()), GA.y(e->target()));
		poly.normalize(pSrc, pTgt);
	}
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:97,代码来源:VisibilityLayout.cpp

示例3: serialization_test

  void serialization_test()
  {
    std::string file("test");

    bool tbIn = true,tbOut;
    char tcIn = 't',tcOut;
    unsigned char tucIn = 'u',tucOut;
    short tsIn = 6,tsOut;
    int tiIn = -10,tiOut;
    unsigned int tuiIn = 10,tuiOut;
    float tfIn = 1.0005,tfOut;
    double tdIn = 1.000000005,tdOut;

    int* tinpIn = NULL,*tinpOut = NULL;
    float* tfpIn = new float,*tfpOut = NULL;
    *tfpIn = 1.11101;

    std::string tstrIn("test12345"),tstrOut;

    Test2 tObjIn,tObjOut;
    int ti = 2;
    tObjIn.ti = &ti;


    Test1 test1,test2,test3;
    test1.ts = "100";
    test2.ts = "200";
    test3.ts = "300";

    Test1 testA, testC;
    testA.tt = &test1;
    testA.ts = "test123";
    testA.tvt.push_back(&test2);
    testA.tvt.push_back(&test3);

    Test1 testB = testA;
    testB.ts = "400";
    testB.tvt.pop_back();

    std::pair<int,bool> tPairIn(10,true);
    std::pair<int,bool> tPairOut;

    std::vector<int> tVector1In ={1,2,3,4,5};
    std::vector<int> tVector1Out;

    std::pair<int,bool> p1(10,1);
    std::pair<int,bool> p2(1,0);
    std::pair<int,bool> p3(10000,1);
    std::vector<std::pair<int,bool> > tVector2In ={p1,p2,p3};
    std::vector<std::pair<int,bool> > tVector2Out;

    std::set<std::pair<int,bool> > tSetIn ={p1,p2,p3};
    std::set<std::pair<int,bool> > tSetOut;

    std::map<int,bool> tMapIn ={p1,p2,p3};
    std::map<int,bool> tMapOut;

    Eigen::Matrix<float,3,3> tDenseMatrixIn;
    tDenseMatrixIn << Eigen::Matrix<float,3,3>::Random();
    tDenseMatrixIn.coeffRef(0,0) = 1.00001;
    Eigen::Matrix<float,3,3> tDenseMatrixOut;

    Eigen::Matrix<float,3,3,Eigen::RowMajor> tDenseRowMatrixIn;
    tDenseRowMatrixIn << Eigen::Matrix<float,3,3,Eigen::RowMajor>::Random();
    Eigen::Matrix<float,3,3,Eigen::RowMajor> tDenseRowMatrixOut;

    Eigen::SparseMatrix<double> tSparseMatrixIn;
    tSparseMatrixIn.resize(3,3);
    tSparseMatrixIn.insert(0,0) = 1.3;
    tSparseMatrixIn.insert(1,1) = 10.2;
    tSparseMatrixIn.insert(2,2) = 100.1;
    tSparseMatrixIn.finalize();
    Eigen::SparseMatrix<double> tSparseMatrixOut;

    // binary serialization

    igl::serialize(tbIn,file);
    igl::deserialize(tbOut,file);
    assert(tbIn == tbOut);

    igl::serialize(tcIn,file);
    igl::deserialize(tcOut,file);
    assert(tcIn == tcOut);

    igl::serialize(tucIn,file);
    igl::deserialize(tucOut,file);
    assert(tucIn == tucOut);

    igl::serialize(tsIn,file);
    igl::deserialize(tsOut,file);
    assert(tsIn == tsOut);

    igl::serialize(tiIn,file);
    igl::deserialize(tiOut,file);
    assert(tiIn == tiOut);

    igl::serialize(tuiIn,file);
    igl::deserialize(tuiOut,file);
    assert(tuiIn == tuiOut);

//.........这里部分代码省略.........
开发者ID:JiaranZhou,项目名称:libigl,代码行数:101,代码来源:serialization_test.cpp

示例4: toState


//.........这里部分代码省略.........

		/* Revert to the original DelayReq interval, and ignore the one for the last master */
		ptpClock->logMinDelayReqInterval = rtOpts->initial_delayreq;

		/* force a IGMP refresh per reset */
		if (rtOpts->do_IGMP_refresh) {
			netRefreshIGMP(&ptpClock->netPath, rtOpts, ptpClock);
		}
		

		DBG("state PTP_LISTENING\n");
		INFO("  now in state PTP_LISTENING\n");
		timerStart(ANNOUNCE_RECEIPT_TIMER, 
			   (ptpClock->announceReceiptTimeout) * 
			   (pow(2,ptpClock->logAnnounceInterval)), 
			   ptpClock->itimer);
		ptpClock->portState = PTP_LISTENING;
		break;

	case PTP_MASTER:
		DBG("state PTP_MASTER\n");
		INFO("  now in state PTP_MASTER\n");
		
		timerStart(SYNC_INTERVAL_TIMER, 
			   pow(2,ptpClock->logSyncInterval), ptpClock->itimer);
		DBG("SYNC INTERVAL TIMER : %f \n",
		    pow(2,ptpClock->logSyncInterval));
		timerStart(ANNOUNCE_INTERVAL_TIMER, 
			   pow(2,ptpClock->logAnnounceInterval), 
			   ptpClock->itimer);
		timerStart(PDELAYREQ_INTERVAL_TIMER, 
			   pow(2,ptpClock->logMinPdelayReqInterval), 
			   ptpClock->itimer);
		ptpClock->portState = PTP_MASTER;
		break;

	case PTP_PASSIVE:
		DBG("state PTP_PASSIVE\n");
		INFO("  now in state PTP_PASSIVE\n");

		
		timerStart(PDELAYREQ_INTERVAL_TIMER, 
			   pow(2,ptpClock->logMinPdelayReqInterval), 
			   ptpClock->itimer);
		timerStart(ANNOUNCE_RECEIPT_TIMER, 
			   (ptpClock->announceReceiptTimeout) * 
			   (pow(2,ptpClock->logAnnounceInterval)), 
			   ptpClock->itimer);
		ptpClock->portState = PTP_PASSIVE;
		p1(ptpClock, rtOpts);
		break;

	case PTP_UNCALIBRATED:
		DBG("state PTP_UNCALIBRATED\n");
		ptpClock->portState = PTP_UNCALIBRATED;
		break;

	case PTP_SLAVE:
		DBG("state PTP_SLAVE\n");
		INFO("  now in state PTP_SLAVE\n");
		
		initClock(rtOpts, ptpClock);
		
		ptpClock->waitingForFollow = FALSE;
		ptpClock->waitingForDelayResp = FALSE;

		// FIXME: clear these vars inside initclock
		clearTime(&ptpClock->pdelay_req_send_time);
		clearTime(&ptpClock->pdelay_req_receive_time);
		clearTime(&ptpClock->pdelay_resp_send_time);
		clearTime(&ptpClock->pdelay_resp_receive_time);
		
		timerStart(OPERATOR_MESSAGES_TIMER,
			   OPERATOR_MESSAGES_INTERVAL,
			   ptpClock->itimer);
		
		timerStart(ANNOUNCE_RECEIPT_TIMER,
			   (ptpClock->announceReceiptTimeout) * 
			   (pow(2,ptpClock->logAnnounceInterval)), 
			   ptpClock->itimer);
		
		/*
		 * Previously, this state transition would start the delayreq timer immediately.
		 * However, if this was faster than the first received sync, then the servo would drop the delayResp
		 * Now, we only start the timer after we receive the first sync (in handle_sync())
		 */
		ptpClock->waiting_for_first_sync = TRUE;
		ptpClock->waiting_for_first_delayresp = TRUE;

		ptpClock->portState = PTP_SLAVE;
		break;

	default:
		DBG("to unrecognized state\n");
		break;
	}

	if (rtOpts->displayStats)
		displayStats(rtOpts, ptpClock);
}
开发者ID:swatbotics,项目名称:darwin,代码行数:101,代码来源:protocol.c

示例5: getTimeMonotonic


//.........这里部分代码省略.........
          bestPlate.characters = plateResult.topNPlates[bestPlateIndex].characters;
          bestPlate.matches_template = plateResult.topNPlates[bestPlateIndex].matches_template;
          bestPlate.overall_confidence = plateResult.topNPlates[bestPlateIndex].overall_confidence;
          bestPlate.character_details = plateResult.topNPlates[bestPlateIndex].character_details;
          
          plateResult.bestPlate = bestPlate;
        }

        timespec plateEndTime;
        getTimeMonotonic(&plateEndTime);
        plateResult.processing_time_ms = diffclock(platestarttime, plateEndTime);
        if (config->debugTiming)
        {
          cout << "Result Generation Time: " << diffclock(resultsStartTime, plateEndTime) << "ms." << endl;
        }

        if (plateResult.topNPlates.size() > 0)
        {
          plateDetected = true;
          response.results.plates.push_back(plateResult);
        }
      }

      if (!plateDetected)
      {
        // Not a valid plate
        // Check if this plate has any children, if so, send them back up for processing
        for (unsigned int childidx = 0; childidx < plateRegion.children.size(); childidx++)
        {
          plateQueue.push(plateRegion.children[childidx]);
        }
      }

    }

    // Unwarp plate regions if necessary
    prewarp->projectPlateRegions(warpedPlateRegions, grayImg.cols, grayImg.rows, true);
    response.plateRegions = warpedPlateRegions;
    
    timespec endTime;
    getTimeMonotonic(&endTime);
    response.results.total_processing_time_ms = diffclock(startTime, endTime);

    if (config->debugTiming)
    {
      cout << "Total Time to process image: " << diffclock(startTime, endTime) << "ms." << endl;
    }

    if (config->debugGeneral && config->debugShowImages)
    {
      for (unsigned int i = 0; i < regionsOfInterest.size(); i++)
      {
        rectangle(img, regionsOfInterest[i], Scalar(0,255,0), 2);
      }

      for (unsigned int i = 0; i < response.plateRegions.size(); i++)
      {
        rectangle(img, response.plateRegions[i].rect, Scalar(0, 0, 255), 2);
      }

      for (unsigned int i = 0; i < response.results.plates.size(); i++)
      {
        // Draw a box around the license plate 
        for (int z = 0; z < 4; z++)
        {
          AlprCoordinate* coords = response.results.plates[i].plate_points;
          Point p1(coords[z].x, coords[z].y);
          Point p2(coords[(z + 1) % 4].x, coords[(z + 1) % 4].y);
          line(img, p1, p2, Scalar(255,0,255), 2);
        }
        
        // Draw the individual character boxes
        for (int q = 0; q < response.results.plates[i].bestPlate.character_details.size(); q++)
        {
          AlprChar details = response.results.plates[i].bestPlate.character_details[q];
          line(img, Point(details.corners[0].x, details.corners[0].y), Point(details.corners[1].x, details.corners[1].y), Scalar(0,255,0), 1);
          line(img, Point(details.corners[1].x, details.corners[1].y), Point(details.corners[2].x, details.corners[2].y), Scalar(0,255,0), 1);
          line(img, Point(details.corners[2].x, details.corners[2].y), Point(details.corners[3].x, details.corners[3].y), Scalar(0,255,0), 1);
          line(img, Point(details.corners[3].x, details.corners[3].y), Point(details.corners[0].x, details.corners[0].y), Scalar(0,255,0), 1);
        }
      }


      displayImage(config, "Main Image", img);

      // Sleep 1ms
      sleep_ms(1);

    }


    if (config->debugPauseOnFrame)
    {
      // Pause indefinitely until they press a key
      while ((char) cv::waitKey(50) == -1)
      {}
    }

    return response;
  }
开发者ID:naellis,项目名称:openalpr,代码行数:101,代码来源:alpr_impl.cpp

示例6: PRECONDITION

    void AngleBendContrib::getGrad(double *pos,double *grad) const {
      PRECONDITION(dp_forceField,"no owner");
      PRECONDITION(pos,"bad vector");
      PRECONDITION(grad,"bad vector");

      double dist1=this->dp_forceField->distance(this->d_at1Idx,this->d_at2Idx,pos);
      double dist2=this->dp_forceField->distance(this->d_at2Idx,this->d_at3Idx,pos);

      //std::cout << "\tAngle("<<this->d_at1Idx<<","<<this->d_at2Idx<<","<<this->d_at3Idx<<") " << dist1 << " " << dist2 << std::endl;
      
      RDGeom::Point3D p1(pos[3*this->d_at1Idx],
       pos[3*this->d_at1Idx+1],
       pos[3*this->d_at1Idx+2]);
      RDGeom::Point3D p2(pos[3*this->d_at2Idx],
       pos[3*this->d_at2Idx+1],
       pos[3*this->d_at2Idx+2]);
      RDGeom::Point3D p3(pos[3*this->d_at3Idx],
       pos[3*this->d_at3Idx+1],
       pos[3*this->d_at3Idx+2]);
      double *g1=&(grad[3*this->d_at1Idx]);
      double *g2=&(grad[3*this->d_at2Idx]);
      double *g3=&(grad[3*this->d_at3Idx]);

      RDGeom::Point3D p12=p1-p2;
      RDGeom::Point3D p32=p3-p2;
      double cosTheta = p12.dotProduct(p32)/(dist1*dist2);
      double sinTheta = std::max(sqrt(1.0-cosTheta*cosTheta),1e-8);

      //std::cerr << "GRAD: " << cosTheta << " (" << acos(cosTheta)<< "), ";
      //std::cerr << sinTheta << " (" << asin(sinTheta)<< ")" << std::endl;
    
      // use the chain rule:
      // dE/dx = dE/dTheta * dTheta/dx

      // dE/dTheta is independent of cartesians:
      double dE_dTheta=getThetaDeriv(cosTheta,sinTheta);
    
      // -------
      // dTheta/dx is trickier:
      double dCos_dS1=1./dist1 * (p32.x/dist2 - cosTheta*p12.x/dist1);
      double dCos_dS2=1./dist1 * (p32.y/dist2 - cosTheta*p12.y/dist1);
      double dCos_dS3=1./dist1 * (p32.z/dist2 - cosTheta*p12.z/dist1);

      double dCos_dS4=1./dist2 * (p12.x/dist1 - cosTheta*p32.x/dist2);
      double dCos_dS5=1./dist2 * (p12.y/dist1 - cosTheta*p32.y/dist2);
      double dCos_dS6=1./dist2 * (p12.z/dist1 - cosTheta*p32.z/dist2);

    
      g1[0] += dE_dTheta*dCos_dS1/(-sinTheta);
      g1[1] += dE_dTheta*dCos_dS2/(-sinTheta);
      g1[2] += dE_dTheta*dCos_dS3/(-sinTheta);

      g2[0] += dE_dTheta*(-dCos_dS1 - dCos_dS4)/(-sinTheta);
      g2[1] += dE_dTheta*(-dCos_dS2 - dCos_dS5)/(-sinTheta);
      g2[2] += dE_dTheta*(-dCos_dS3 - dCos_dS6)/(-sinTheta);
    
      g3[0] += dE_dTheta*dCos_dS4/(-sinTheta);
      g3[1] += dE_dTheta*dCos_dS5/(-sinTheta);
      g3[2] += dE_dTheta*dCos_dS6/(-sinTheta);

    }
开发者ID:dawnmy,项目名称:rdkit,代码行数:61,代码来源:AngleBend.cpp

示例7: run_main

int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Bound_Ptr_Test"));


  // =========================================================================
  // The following test uses the ACE_Strong_Bound_Ptr in a single
  // thread of control, hence we use the ACE_Null_Mutex

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) performing synchronous test...\n")));

  Parent *parent1 = 0;
  ACE_NEW_RETURN (parent1,
                  Parent,
                  -1);
  ACE_Weak_Bound_Ptr<Parent, ACE_Null_Mutex> p8;
  {
    // Must get the pointer from the parent object's weak_self_ member.
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p(parent1->weak_self_);
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p1(p);
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p2(p);
    ACE_Weak_Bound_Ptr<Parent, ACE_Null_Mutex> p3(p);
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p4(p);
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p5 = p2;
    ACE_Strong_Bound_Ptr<Parent, ACE_Null_Mutex> p6 = p3;
    ACE_Weak_Bound_Ptr<Parent, ACE_Null_Mutex> p7(p1);
    p8 = p2;
    p->child_->do_something ();
  }
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) Parent instance count is %d, expecting 0\n"),
              Parent::instance_count_));
  if (Parent::instance_count_ != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) parent instance count not 0...\n")),
                         -1);
    }
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) Child instance count is %d, expecting 0\n"),
              Child::instance_count_));
  if (Child::instance_count_ != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) child instance count not 0...\n")),
                         -1);
    }
  // Weak pointer should now be set to null.
  if(!p8.null ())
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) p8 not nill...\n")),
                         -1);
    }

  Printer *printer1 = 0;
  ACE_NEW_RETURN (printer1,
                  Printer ("I am printer 1"),
                  -1);
  ACE_Weak_Bound_Ptr<Printer, ACE_Null_Mutex> r9;
  {
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r(printer1);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r1(r);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r2(r);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r3(r);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r4(r);
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r5 = r2;
    ACE_Strong_Bound_Ptr<Printer, ACE_Null_Mutex> r6 = r1;
    ACE_Weak_Bound_Ptr<Printer, ACE_Null_Mutex> r7(r1);
    ACE_Weak_Bound_Ptr<Printer, ACE_Null_Mutex> r8 = r2;
    r9 = r3;
    r9->print ();
  }
  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) Printer instance count is %d, expecting 0\n"),
              Printer::instance_count_));
  if (Printer::instance_count_ != 0)
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) Printer instance count not 0...\n")),
                         -1);
    }
  // Weak pointer should now be set to null.
  if (!r9.null ())
    {
      ACE_ERROR_RETURN ((LM_ERROR,
                         ACE_TEXT ("(%t) r9 not nill...\n")),
                         -1);
    }

#if defined (ACE_HAS_THREADS)

  // =========================================================================
  // The following test uses the ACE_Strong_Bound_Ptr in multiple
  // threads of control.

  ACE_DEBUG ((LM_DEBUG,
              ACE_TEXT ("(%t) performing asynchronous test...\n")));
//.........这里部分代码省略.........
开发者ID:PGSeungminLee,项目名称:CGSF,代码行数:101,代码来源:Bound_Ptr_Test.cpp

示例8: tcp_stats

/*
 * Dump TCP statistics structure.
 */
void
tcp_stats(u_long off, char *name)
{
	struct tcpstat tcpstat;

	if (off == 0)
		return;
	printf("%s:\n", name);
	kread(off, (char *)&tcpstat, sizeof (tcpstat));

#define	p(f, m) if (tcpstat.f || sflag <= 1) \
	printf(m, tcpstat.f, plural(tcpstat.f))
#define	p1(f, m) if (tcpstat.f || sflag <= 1) \
	printf(m, tcpstat.f)
#define	p2(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
	printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2, plural(tcpstat.f2))
#define	p2a(f1, f2, m) if (tcpstat.f1 || tcpstat.f2 || sflag <= 1) \
	printf(m, tcpstat.f1, plural(tcpstat.f1), tcpstat.f2)
#define	p3(f, m) if (tcpstat.f || sflag <= 1) \
	printf(m, tcpstat.f, plurales(tcpstat.f))

	p(tcps_sndtotal, "\t%u packet%s sent\n");
	p2(tcps_sndpack,tcps_sndbyte,
	    "\t\t%u data packet%s (%qd byte%s)\n");
	p2(tcps_sndrexmitpack, tcps_sndrexmitbyte,
	    "\t\t%u data packet%s (%qd byte%s) retransmitted\n");
	p(tcps_sndrexmitfast, "\t\t%qd fast retransmitted packet%s\n");
	p2a(tcps_sndacks, tcps_delack,
	    "\t\t%u ack-only packet%s (%u delayed)\n");
	p(tcps_sndurg, "\t\t%u URG only packet%s\n");
	p(tcps_sndprobe, "\t\t%u window probe packet%s\n");
	p(tcps_sndwinup, "\t\t%u window update packet%s\n");
	p(tcps_sndctrl, "\t\t%u control packet%s\n");
	p(tcps_outhwcsum, "\t\t%u packet%s hardware-checksummed\n");
	p(tcps_rcvtotal, "\t%u packet%s received\n");
	p2(tcps_rcvackpack, tcps_rcvackbyte, "\t\t%u ack%s (for %qd byte%s)\n");
	p(tcps_rcvdupack, "\t\t%u duplicate ack%s\n");
	p(tcps_rcvacktoomuch, "\t\t%u ack%s for unsent data\n");
	p2(tcps_rcvpack, tcps_rcvbyte,
	    "\t\t%u packet%s (%qu byte%s) received in-sequence\n");
	p2(tcps_rcvduppack, tcps_rcvdupbyte,
	    "\t\t%u completely duplicate packet%s (%qd byte%s)\n");
	p(tcps_pawsdrop, "\t\t%u old duplicate packet%s\n");
	p2(tcps_rcvpartduppack, tcps_rcvpartdupbyte,
	    "\t\t%u packet%s with some duplicate data (%qd byte%s duplicated)\n");
	p2(tcps_rcvoopack, tcps_rcvoobyte,
	    "\t\t%u out-of-order packet%s (%qd byte%s)\n");
	p2(tcps_rcvpackafterwin, tcps_rcvbyteafterwin,
	    "\t\t%u packet%s (%qd byte%s) of data after window\n");
	p(tcps_rcvwinprobe, "\t\t%u window probe%s\n");
	p(tcps_rcvwinupd, "\t\t%u window update packet%s\n");
	p(tcps_rcvafterclose, "\t\t%u packet%s received after close\n");
	p(tcps_rcvbadsum, "\t\t%u discarded for bad checksum%s\n");
	p(tcps_rcvbadoff, "\t\t%u discarded for bad header offset field%s\n");
	p1(tcps_rcvshort, "\t\t%u discarded because packet too short\n");
	p1(tcps_rcvnosec, "\t\t%u discarded for missing IPsec protection\n");
	p1(tcps_rcvmemdrop, "\t\t%u discarded due to memory shortage\n");
	p(tcps_inhwcsum, "\t\t%u packet%s hardware-checksummed\n");
	p(tcps_rcvbadsig, "\t\t%u bad/missing md5 checksum%s\n");
	p(tcps_rcvgoodsig, "\t\t%qd good md5 checksum%s\n");
	p(tcps_connattempt, "\t%u connection request%s\n");
	p(tcps_accepts, "\t%u connection accept%s\n");
	p(tcps_connects, "\t%u connection%s established (including accepts)\n");
	p2(tcps_closed, tcps_drops,
	    "\t%u connection%s closed (including %u drop%s)\n");
	p(tcps_conndrained, "\t%qd connection%s drained\n");
	p(tcps_conndrops, "\t%u embryonic connection%s dropped\n");
	p2(tcps_rttupdated, tcps_segstimed,
	    "\t%u segment%s updated rtt (of %u attempt%s)\n");
	p(tcps_rexmttimeo, "\t%u retransmit timeout%s\n");
	p(tcps_timeoutdrop, "\t\t%u connection%s dropped by rexmit timeout\n");
	p(tcps_persisttimeo, "\t%u persist timeout%s\n");
	p(tcps_keeptimeo, "\t%u keepalive timeout%s\n");
	p(tcps_keepprobe, "\t\t%u keepalive probe%s sent\n");
	p(tcps_keepdrops, "\t\t%u connection%s dropped by keepalive\n");
	p(tcps_predack, "\t%u correct ACK header prediction%s\n");
	p(tcps_preddat, "\t%u correct data packet header prediction%s\n");
	p3(tcps_pcbhashmiss, "\t%u PCB cache miss%s\n");

	p(tcps_ecn_accepts, "\t%u ECN connection%s accepted\n");
	p(tcps_ecn_rcvece, "\t\t%u ECE packet%s received\n");
	p(tcps_ecn_rcvcwr, "\t\t%u CWR packet%s received\n");
	p(tcps_ecn_rcvce, "\t\t%u CE packet%s received\n");
	p(tcps_ecn_sndect, "\t\t%u ECT packet%s sent\n");
	p(tcps_ecn_sndece, "\t\t%u ECE packet%s sent\n");
	p(tcps_ecn_sndcwr, "\t\t%u CWR packet%s sent\n");
	p1(tcps_cwr_frecovery, "\t\t\tcwr by fastrecovery: %u\n");
	p1(tcps_cwr_timeout, "\t\t\tcwr by timeout: %u\n");
	p1(tcps_cwr_ecn, "\t\t\tcwr by ecn: %u\n");

	p(tcps_badsyn, "\t%u bad connection attempt%s\n");
	p1(tcps_sc_added, "\t%qd SYN cache entries added\n");
	p(tcps_sc_collisions, "\t\t%qd hash collision%s\n");
	p1(tcps_sc_completed, "\t\t%qd completed\n");
	p1(tcps_sc_aborted, "\t\t%qd aborted (no space to build PCB)\n");
	p1(tcps_sc_timed_out, "\t\t%qd timed out\n");
	p1(tcps_sc_overflowed, "\t\t%qd dropped due to overflow\n");
//.........这里部分代码省略.........
开发者ID:MarginC,项目名称:kame,代码行数:101,代码来源:inet.c

示例9: main

int main(int argc, char **argv)
{
  plan_tests(41);

  FlatPoint p1(fixed_one, fixed_one);
  FlatPoint p2(fixed_one, fixed_two);
  FlatPoint p3(fixed(3), fixed_ten);

  // test cross()
  ok1(equals(p1.CrossProduct(p2), 1));
  ok1(equals(p2.CrossProduct(p1), -1));
  ok1(equals(p1.CrossProduct(p3), 7));
  ok1(equals(p3.CrossProduct(p1), -7));
  ok1(equals(p2.CrossProduct(p3), 4));
  ok1(equals(p3.CrossProduct(p2), -4));

  // test mul_y()
  p2.MultiplyY(fixed_two);
  ok1(equals(p2.x, 1));
  ok1(equals(p2.y, 4));

  // test sub()
  p2.Subtract(p1);
  ok1(equals(p2.x, 0));
  ok1(equals(p2.y, 3));

  // test add()
  p2.Add(p3);
  ok1(equals(p2.x, 3));
  ok1(equals(p2.y, 13));

  // test rotate()
  p2.Rotate(Angle::Degrees(fixed(-90)));
  ok1(equals(p2.x, 13));
  ok1(equals(p2.y, -3));

  p2.Rotate(Angle::Degrees(fixed(45)));
  p2.Rotate(Angle::Degrees(fixed(45)));
  ok1(equals(p2.x, 3));
  ok1(equals(p2.y, 13));

  // test d()
  ok1(equals(p2.Distance(p3), 3));
  ok1(equals(p3.Distance(p2), 3));

  // test mag_sq()
  ok1(equals(p1.MagnitudeSquared(), 2));
  ok1(equals(p2.MagnitudeSquared(), 178));
  ok1(equals(p3.MagnitudeSquared(), 109));

  // test mag()
  ok1(equals(p1.Magnitude(), 1.4142135623730950488016887242097));
  ok1(equals(p2.Magnitude(), 13.341664064126333712489436272508));
  ok1(equals(p3.Magnitude(), 10.440306508910550179757754022548));

  // test dot()
  ok1(equals(p1.DotProduct(p2), 16));
  ok1(equals(p2.DotProduct(p1), 16));
  ok1(equals(p1.DotProduct(p3), 13));
  ok1(equals(p3.DotProduct(p1), 13));
  ok1(equals(p2.DotProduct(p3), 139));
  ok1(equals(p3.DotProduct(p2), 139));

  // test ==
  ok1(p1 == p1);
  ok1(p2 == p2);
  ok1(p3 == p3);
  /*
  // Test #2 fails due to floating point inaccuracies
  ok1(p1 == FlatPoint(fixed_one, fixed_one));
  ok1(p2 == FlatPoint(fixed(3), fixed(13)));
  ok1(p3 == FlatPoint(fixed(3), fixed_ten));
  */

  // test *
  p2 = p3 * fixed(1.5);
  ok1(equals(p2.x, 4.5));
  ok1(equals(p2.y, 15));

  // test +
  p2 = p1 + p3;
  ok1(equals(p2.x, 4));
  ok1(equals(p2.y, 11));

  // test +=
  p2 += p1;
  ok1(equals(p2.x, 5));
  ok1(equals(p2.y, 12));

  // test -
  p2 = p3 - p1;
  ok1(equals(p2.x, 2));
  ok1(equals(p2.y, 9));

  return exit_status();
}
开发者ID:davidswelt,项目名称:XCSoar,代码行数:96,代码来源:TestFlatPoint.cpp

示例10: enemy

void EnemyList::checkCollisions(PlayerProjectiles& playerProjectiles)
{
	for (unsigned int i = 0; i < enemyList.size(); i++)
	{
		Point enemy(enemyList[i].getCompX(), enemyList[i].getCompY());
		for (unsigned int j = 0; j < playerProjectiles.getSize(); j++)
		{
			Bullet* b = playerProjectiles.getBullet(j);
			Point bulPoint(b->getX(), b->getY());
			if (enemyList[i].enemyType == 0 && Collision().checkCollision(playerProjectiles.getVector()[j].box, enemy, 0.97))
			{
				b->destroy();
				enemyList[i].enemyHP--;
				Explosion explosion;
				if (enemyList[i].enemyHP <= 0)
				{
					enemyList[i].destroyed = true;
					if (enemyList[i].enemyType == 0)
					{
						explosion = Explosion(enemyList[i].compX, enemyList[i].compY, 1, explosionTextureID);
					}
					else
					{
						explosion = Explosion(enemyList[i].compX, enemyList[i].compY, 2, explosionTextureID);
					}
					
					explosionList.addExplosion(explosion);
				}
			}
			else if (enemyList[i].enemyType == 1 && Collision().isIntersect(enemyList[i].box,
				enemy,
				b->box,
				bulPoint,
				28,
				minTransDist))
			{
				b->destroy();
				enemyList[i].enemyHP--;
				if (enemyList[i].enemyHP <= 0)
				{
					enemyList[i].destroyed = true;
					Explosion explosion(enemyList[i].compX, enemyList[i].compY, 1, explosionTextureID);
					explosionList.addExplosion(explosion);
				}
			}
		}

		for (unsigned int j = 0; j < enemyList.size(); j++)
		{
			Point p2(enemyList[j].getCompX(), enemyList[j].getCompY());
			if (i != j && Collision().isIntersect(enemyList[i].box, enemy, enemyList[j].box, p2, 28, minTransDist))
			{
				if (enemyList[i].enemyType == 1)
				{
					enemyList[j].setMinTransDist(minTransDist.pointX, minTransDist.pointY);
				}
				else if (enemyList[j].enemyType == 1)
				{
					enemyList[i].setMinTransDist(minTransDist.pointX, minTransDist.pointY);
				}
				else
				{
					enemyList[i].setMinTransDist(minTransDist.pointX * 0.5, minTransDist.pointY * 0.5);
					enemyList[j].setMinTransDist(-minTransDist.pointX * 0.5, -minTransDist.pointY * 0.5);
				}
			}
		}

		Point playerPos(playerShipX, playerShipY);
		//std::cout << playerPos.pointX << "\t" << playerPos.pointY << "\t" << enemy.pointX << "\t" << enemy.pointY << std::endl;
		BoundingQuad lineBox(playerPos, playerPos, enemy, enemy);
		bool result = true;
		for (unsigned int j = 0; j < asteroidMapListRef->asteroidField.size(); j++)
		{
			Point p2(asteroidMapListRef->asteroidField[j].getRoidX(), asteroidMapListRef->asteroidField[j].getRoidY());
			if (Collision().isIntersect(enemyList[i].box, 
				enemy,
				asteroidMapListRef->asteroidField[j].box, 
				p2,
				28,
				minTransDist))
			{
				enemyList[i].setMinTransDist(minTransDist.pointX * 2, minTransDist.pointY * 2);
				enemyList[i].turnAround();
			}
			if (!Collision().hasLineOfSight(enemy, playerPos, lineBox, asteroidMapListRef->asteroidField[j].box, p2, 28))
			{
				result = false;
			}
		}
		enemyList[i].setLOS(result);
	}

	for (unsigned int i = 0; i < playerProjectiles.getSize(); i++)
	{
		Bullet* b = playerProjectiles.getBullet(i);
		Point p1(b->getX(), b->getY());
		
		for (unsigned int j = 0; j < asteroidMapListRef->asteroidField.size(); j++)
		{
//.........这里部分代码省略.........
开发者ID:twiztedcyph,项目名称:GraphicsCW,代码行数:101,代码来源:EnemyList.cpp

示例11: al_get_time

void Enemy_Avatar_Wander_Character_Role::update(Area_Manager *area)
{
	if (al_get_time() >= next_check) {
		next_check = al_get_time() + (General::rand()%1000)/1000.0*5.0 + 5.0;
		const float radius = 200.0f;
		Map_Entity *player = area->get_entity(0);
		int layer = player->get_layer();
		General::Point<float> player_pos = player->get_position();
		Area_Loop *loop = GET_AREA_LOOP;
		if (!player->input_is_disabled() && layer == entity->get_layer() && !area->point_is_in_no_enemy_zone(player_pos.x, player_pos.y) && !area->get_in_speech_loop() && (!loop || loop->battle_event_is_done()) && loop->get_num_jumping() == 0) {
			General::Point<float> this_pos = entity->get_position();
			if (General::distance(player_pos.x, player_pos.y, this_pos.x, this_pos.y) <= radius) {
				float dx = player_pos.x - this_pos.x;
				float dy = player_pos.y - this_pos.y;
				float angle1 = atan2(dy, dx) + M_PI / 2.0f;
				float angle2 = angle1 + M_PI;
				General::Point<float> pp1(
					player_pos.x + cos(angle1) * General::TILE_SIZE/2,
					player_pos.y + sin(angle1) * General::TILE_SIZE/2
				);
				General::Point<float> pp2(
					player_pos.x + cos(angle2) * General::TILE_SIZE/2,
					player_pos.y + sin(angle2) * General::TILE_SIZE/2
				);
				General::Point<float> tp1(
					this_pos.x + cos(angle1) * General::TILE_SIZE/2,
					this_pos.y + sin(angle1) * General::TILE_SIZE/2
				);
				General::Point<float> tp2(
					this_pos.x + cos(angle2) * General::TILE_SIZE/2,
					this_pos.y + sin(angle2) * General::TILE_SIZE/2
				);
				std::vector< General::Line<float> > *lines = area->get_collision_lines();
				bool collision = false;
				for (size_t i = 0; i < lines[layer].size(); i++) {
					General::Point<float> p1(lines[layer][i].x1, lines[layer][i].y1);
					General::Point<float> p2(lines[layer][i].x2, lines[layer][i].y2);
					if (checkcoll_line_line(&pp1, &tp1, &p1, &p2, NULL)) {
						collision = true;
						break;
					}
					if (checkcoll_line_line(&pp2, &tp2, &p1, &p2, NULL)) {
						collision = true;
						break;
					}
				}
				if (!collision) {
					Battle_Event_Type type = (Battle_Event_Type)(General::rand() % 3);

					float *inputs = player->get_inputs();

					player->set_panning_to_entity(entity->get_id());
					player->set_input_disabled(true);

					if (type != BATTLE_EVENT_SIGHTED && (inputs[Map_Entity::X] != 0.0f || inputs[Map_Entity::Y] != 0.0f)) {
						General::Direction d = player->get_direction();
						float a;
						if (d == General::DIR_N) {
							player->get_animation_set()->set_sub_animation("trip-up");
							a = M_PI / 2;
						}
						else if (d == General::DIR_S) {
							player->get_animation_set()->set_sub_animation("trip-down");
							a = M_PI * 3 / 2;
						}
						else if (d == General::DIR_E) {
							player->get_animation_set()->set_sub_animation("trip");
							a = M_PI;
						}
						else {
							player->get_animation_set()->set_sub_animation("trip");
							a = 0;
						}
						a += ((General::rand()%1000)/1000.0f)*M_PI/3 - M_PI/6;
						player->get_animation_set()->reset();
						if (type == BATTLE_EVENT_TRIPPED) {
							engine->play_sample("sfx/trip.ogg");
						}
						else if (type == BATTLE_EVENT_SLIPPED) {
							engine->play_sample("sfx/slip.ogg");
							lua_State *stack = area->get_lua_state();
							Lua::call_lua(stack, "toss_banana", "iddd>", layer, player_pos.x, player_pos.y, a);
						}
					}
					else {
						engine->play_sample("sfx/enemy_alerted.ogg");
						player->update_direction(false);
					}
					GET_AREA_LOOP->set_battle_was_event(type);
					entity->kamikaze(this_pos.x + dx * 0.9f, this_pos.y + dy * 0.9f);
					return;
				}
			}
		}
	}

	Wander_Character_Role::update(area);
}
开发者ID:LibreGames,项目名称:crystal-picnic,代码行数:98,代码来源:enemy_avatar_wander_character_role.cpp

示例12: drawRect

void drawRect(cv::Mat image,cv::Rect rect)
{
    cv::Point p1(rect.x,rect.y);
    cv::Point p2(rect.x+rect.width,rect.y+rect.height);
    cv::rectangle(image,p1,p2,cv::Scalar(0,255,0),1);
}
开发者ID:han1157,项目名称:HyperLPR,代码行数:6,代码来源:test_fastdeskew.cpp

示例13: test_RT


//.........这里部分代码省略.........
  std::cout << std::endl << " number of vertices : " 
      << T1.number_of_vertices() << std::endl;

  std::cout << " number of inserted points : " ;
  Weighted_point r[10];
  for ( m=0; m<10; m++) {
    if ( (m%2)== 0 ) 
      r[m] = Weighted_point( Point( m,0,0 ), 1 );
    else 
      r[m] = Weighted_point( Point( -m,0,0 ), 1 );
    T1.insert( r[m] );
    count++;
    if (count <10)
      std::cout << count << '\b' ;
    else
      if (count < 100)
  std::cout << count << '\b' << '\b' ;
      else
  std::cout << count << '\b' << '\b' << '\b' ;
    std::cout.flush();  
  }
  assert( T1.is_valid() );
  std::cout << std::endl << " number of vertices : " 
      << T1.number_of_vertices() << std::endl;
  assert( T1.dimension()==1 );

  // The following is distilled from a bug report by Wulue Zhao
  // ([email protected]), a student of Tamal Dey.
  Point pt0(0,0,0);
  Point pt1( 1,0,0), pt2(2,0,0),  pt3(3,0,0);
  Point pt4(-1,0,0), pt5(-2,0,0), pt6(-3,0,0);

  Weighted_point wp0(pt0,10.0);
  Weighted_point wp1(pt1,0.0),  wp2(pt2,0.0),  wp3(pt3,0.0);
  Weighted_point wp4(pt4,0.0),  wp5(pt5,0.0),  wp6(pt6,0.0);

  Cls T11;

  T11.insert(wp0);
  T11.insert(wp1);
  T11.insert(wp2);
  T11.insert(wp3);
  T11.insert(wp4);
  T11.insert(wp5);
  T11.insert(wp6);

  assert(T11.is_valid());

  // And another distilled bug report from the same guy.
 {
  Point p1(-0.07, 0.04, 0.04);
  Point p2(0.09, 0.04, 0.04);
  Point p3(0.09, -0.05, 0.04);
  Point p4(0.05, -0.05, 0.04);
  Point p5(0.05, 0.0, 0.04);
  Point p6(-0.07, 0.0, 0.04);
  Point p7(-0.07, 0.04, -0.04);
  Point p8(0.09, 0.04, -0.04);
  Point p9(0.09, -0.05, -0.04);
  Point p10(0.05, -0.05, -0.04);
  Point p11(0.05, 0.0, -0.04);
  Point p12(-0.07, 0.0, -0.04);

  Weighted_point wp1(p1,0);
  Weighted_point wp2(p2,0);
  Weighted_point wp3(p3,0);
开发者ID:Asuzer,项目名称:cgal,代码行数:67,代码来源:test_regular_3.cpp

示例14: logln


//.........这里部分代码省略.........
    }

    // Added by Ken Liu testing set/getMinimumExponentDigits
    int8_t MinimumExponentDigits = 0;
    pat.setMinimumExponentDigits(2);
    MinimumExponentDigits = pat.getMinimumExponentDigits();
    logln((UnicodeString)"MinimumExponentDigits (should be 2) is " + (int8_t) MinimumExponentDigits);
    if(MinimumExponentDigits != 2) {
        errln((UnicodeString)"ERROR: setMinimumExponentDigits() failed");
    }

    // Added by Ken Liu testing set/getRoundingIncrement
    double RoundingIncrement = 0.0;
    pat.setRoundingIncrement(2.0);
    RoundingIncrement = pat.getRoundingIncrement();
    logln((UnicodeString)"RoundingIncrement (should be 2.0) is " + (double) RoundingIncrement);
    if(RoundingIncrement != 2.0) {
        errln((UnicodeString)"ERROR: setRoundingIncrement() failed");
    }
    //end of Ken's Adding

    UnicodeString funkyPat;
    funkyPat = pat.toPattern(funkyPat);
    logln((UnicodeString)"Pattern is " + funkyPat);

    UnicodeString locPat;
    locPat = pat.toLocalizedPattern(locPat);
    logln((UnicodeString)"Localized pattern is " + locPat);

// ======= Test applyPattern()

    logln((UnicodeString)"Testing applyPattern()");

    UnicodeString p1("#,##0.0#;(#,##0.0#)");
    logln((UnicodeString)"Applying pattern " + p1);
    status = U_ZERO_ERROR;
    pat.applyPattern(p1, status);
    if(U_FAILURE(status)) {
        errln((UnicodeString)"ERROR: applyPattern() failed with " + (int32_t) status);
    }
    UnicodeString s2;
    s2 = pat.toPattern(s2);
    logln((UnicodeString)"Extracted pattern is " + s2);
    if(s2 != p1) {
        errln((UnicodeString)"ERROR: toPattern() result did not match pattern applied");
    }

    if(pat.getSecondaryGroupingSize() != 0) {
        errln("FAIL: Secondary Grouping Size should be 0, not %d\n", pat.getSecondaryGroupingSize());
    }

    if(pat.getGroupingSize() != 3) {
        errln("FAIL: Primary Grouping Size should be 3, not %d\n", pat.getGroupingSize());
    }

    UnicodeString p2("#,##,##0.0# FF;(#,##,##0.0# FF)");
    logln((UnicodeString)"Applying pattern " + p2);
    status = U_ZERO_ERROR;
    pat.applyLocalizedPattern(p2, status);
    if(U_FAILURE(status)) {
        errln((UnicodeString)"ERROR: applyPattern() failed with " + (int32_t) status);
    }
    UnicodeString s3;
    s3 = pat.toLocalizedPattern(s3);
    logln((UnicodeString)"Extracted pattern is " + s3);
    if(s3 != p2) {
开发者ID:Acorld,项目名称:WinObjC-Heading,代码行数:67,代码来源:dcfmapts.cpp

示例15: BRepPrimAPI_MakeCylinder

// add a pad hole or slot
bool PCBMODEL::AddPadHole( KICADPAD* aPad )
{
    if( NULL == aPad || !aPad->IsThruHole() )
        return false;

    if( !aPad->m_drill.oval )
    {
        TopoDS_Shape s = BRepPrimAPI_MakeCylinder( aPad->m_drill.size.x * 0.5,
            m_thickness * 2.0 ).Shape();
        gp_Trsf shift;
        shift.SetTranslation( gp_Vec( aPad->m_position.x, aPad->m_position.y, -m_thickness * 0.5 ) );
        BRepBuilderAPI_Transform hole( s, shift );
        m_cutouts.push_back( hole.Shape() );
        return true;
    }

    // slotted hole
    double angle_offset = 0.0;
    double rad;     // radius of the slot
    double hlen;    // half length of the slot

    if( aPad->m_drill.size.x < aPad->m_drill.size.y )
    {
        angle_offset = M_PI_2;
        rad = aPad->m_drill.size.x * 0.5;
        hlen = aPad->m_drill.size.y * 0.5 - rad;
    }
    else
    {
        rad = aPad->m_drill.size.y * 0.5;
        hlen = aPad->m_drill.size.x * 0.5 - rad;
    }

    DOUBLET c0( -hlen, 0.0 );
    DOUBLET c1( hlen, 0.0 );
    DOUBLET p0( -hlen, rad );
    DOUBLET p1( -hlen, -rad );
    DOUBLET p2(  hlen, -rad );
    DOUBLET p3( hlen, rad );

    angle_offset += aPad->m_rotation;
    double dlim = (double)std::numeric_limits< float >::epsilon();

    if( angle_offset < -dlim || angle_offset > dlim )
    {
        double vsin = sin( angle_offset );
        double vcos = cos( angle_offset );

        double x = c0.x * vcos - c0.y * vsin;
        double y = c0.x * vsin + c0.y * vcos;
        c0.x = x;
        c0.y = y;

        x = c1.x * vcos - c1.y * vsin;
        y = c1.x * vsin + c1.y * vcos;
        c1.x = x;
        c1.y = y;

        x = p0.x * vcos - p0.y * vsin;
        y = p0.x * vsin + p0.y * vcos;
        p0.x = x;
        p0.y = y;

        x = p1.x * vcos - p1.y * vsin;
        y = p1.x * vsin + p1.y * vcos;
        p1.x = x;
        p1.y = y;

        x = p2.x * vcos - p2.y * vsin;
        y = p2.x * vsin + p2.y * vcos;
        p2.x = x;
        p2.y = y;

        x = p3.x * vcos - p3.y * vsin;
        y = p3.x * vsin + p3.y * vcos;
        p3.x = x;
        p3.y = y;
    }

    c0.x += aPad->m_position.x;
    c0.y += aPad->m_position.y;
    c1.x += aPad->m_position.x;
    c1.y += aPad->m_position.y;
    p0.x += aPad->m_position.x;
    p0.y += aPad->m_position.y;
    p1.x += aPad->m_position.x;
    p1.y += aPad->m_position.y;
    p2.x += aPad->m_position.x;
    p2.y += aPad->m_position.y;
    p3.x += aPad->m_position.x;
    p3.y += aPad->m_position.y;

    OUTLINE oln;
    oln.SetMinSqDistance( m_minDistance2 );
    KICADCURVE crv0, crv1, crv2, crv3;

    // crv0 = arc
    crv0.m_start = c0;
    crv0.m_end = p0;
//.........这里部分代码省略.........
开发者ID:KiCad,项目名称:kicad-source-mirror,代码行数:101,代码来源:oce_utils.cpp


注:本文中的p1函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。