Пример #1
0
void TaxiwayProc::MoveCenterPoint(DistanceUnit dx,DistanceUnit dy,UINT centerPointID)
{
	ASSERT(centerPointID< (UINT)m_location.getCount());
	Point & pt=m_location[centerPointID];
	pt.setX(pt.getX()+dx);pt.setY(pt.getY()+dy);
	initSegments();
}
Пример #2
0
 void MatlabAdapter::init()
 {
     initModel();
     initSegments();
     initJoints();
     initGenCoords();
     //printMap();
 }
Пример #3
0
void TaxiwayProc::CalculateSegment(){
	
	UINT nptCount=m_location.getCount();
	if(nptCount<2)return;	
	
	Path & path=m_location;
	Point  p_pre=path.getPoint(0);
	Point  p_this=path.getPoint(0);
	Point  p_next=path.getPoint(1);
	//get first segment;	
	ARCVector2 k;
	k.reset(p_this,p_next);
	k.Rotate(90);
	k.Normalize();	
	if((int)m_vSegments.size()!=nptCount)initSegments();
	std::vector<TAXIWAYSEGMENT>::iterator segitr=m_vSegments.begin();
	
	(*segitr).ptdir=k;
	segitr++;
	//get mid segment;
	ARCVector2 k1;
	ARCVector2 k2;
	for(UINT i=1;i<nptCount-1;i++)
	{		
		
		p_this=path.getPoint(i);
		p_next=path.getPoint(i+1);
		k1.reset(p_pre,p_this);
		k2.reset(p_this,p_next);
		k1.Normalize();
		k2.Normalize();
		k=k1+k2;
		k.Rotate(90);
		k.Normalize();		
		/*double dCosVal = k1.GetCosOfTwoVector( k );
		double dAngle = acos( dCosVal );
		DistanceUnit dAdjustedWidth=1.0/sin(dAngle);		*/
		(* segitr).ptdir=k;
		
		/*(* segitr).length_left= m_dWidth*dAdjustedWidth;
		(* segitr).length_right= m_dWidth * dAdjustedWidth;*/

		segitr++;
		p_pre=p_this;
		p_this=p_next;

	}
	//get the last segment ;
	p_this=path.getPoint(nptCount-2);
	p_next=path.getPoint(nptCount-1);
	k.reset(p_this,p_next);
	k.Rotate(90);
	k.Normalize();	
	(*segitr).ptdir=k;
	
}
Пример #4
0
Strand::Strand(const Vector &position, int segs, int dist) : RenderObject(), Segmented(dist, dist)
{
	cull = false;
	segments.resize(segs);
	for (int i = 0; i < segments.size(); i++)
	{
		segments[i] = new RenderObject;
	}
	initSegments(position);
}
Пример #5
0
void TaxiwayProc::removePoint(UINT ptID){
	ASSERT(ptID<(UINT)m_location.getCount());
	ASSERT(ptID<m_vSegments.size());
	std::vector<TAXIWAYSEGMENT> ::iterator itr=m_vSegments.begin();
	for(size_t i=0;i<ptID;i++){
		itr++;
	}
	m_vSegments.erase(itr);
	m_location.RemovePointAt(ptID);
	initSegments();
}
Пример #6
0
main(){
     initSegments();
     srand(time(0)); // To Generate unique random numbers each time program starts
     int FIFO_pf=0,LRU_pf=0;
     int node_numbers[NUM_OF_REFERENCES],page_numbers[NUM_OF_REFERENCES],i;
     for(i=0;i<NUM_OF_REFERENCES;++i){
         node_numbers[i] = random_400();  
         page_numbers[i] = node_numbers[i]/4;            
         }
     //Nodes to page Numbers conversion 
     
     //Simulation
     FIFOSimulate(page_numbers,&FIFO_pf);
     LRUSimulate(page_numbers,&LRU_pf);
     printf("In FIFO %i\n", FIFO_pf);
     printf("IN LRU %i",LRU_pf); 
     getch();
     }
Пример #7
0
NumericValControl::NumericValControl(
	BRect												frame,
	const char*									name,
	BMessage*										message,
	uint16											wholeDigits,
	uint16											fractionalDigits,
	bool												negativeVisible,
	align_mode									alignMode,
	align_flags									alignFlags) :

	ValControl(frame, name, 0, message, alignMode, alignFlags, UPDATE_ASYNC, false),
	m_wholeDigits(wholeDigits),
	m_fractionalDigits(fractionalDigits),
	m_param(0) {

	setDefaultConstraints(negativeVisible);
	initSegments();
}
Пример #8
0
void SightLightScene::setupNodes()
{
    //添加背景图
    auto visSize = Director::getInstance()->getVisibleSize();
    auto background = Sprite::create("res/sightlight/background.png");
    background->setPosition(0,0);
    background->setAnchorPoint(Vec2(0,0));
    addChild(background,1);
    
    //创建两个DrawNode,一个用来画静态线段,一个画动态线段
    _staticDraw = DrawNode::create();
    addChild(_staticDraw,100);
    _touchDraw = DrawNode::create();
//    addChild(_touchDraw,100);
    
    //创建ClippingNode,设置底板和模板
    _clip = ClippingNode::create();
    _clip->setInverted(false);
    _clip->setAlphaThreshold(255.0f);
    
    auto foreground = Sprite::create("res/sightlight/foreground.png");
    foreground->setPosition(0,0);
    foreground->setAnchorPoint(Vec2(0,0));
    
    _clip->addChild(foreground);
    _clip->setStencil(_touchDraw);
    addChild(_clip,101);
    
    //画线段,并保存所有不重复的端点
    initSegments();
    initPoints();
    
    //触摸监听
    auto listener = EventListenerTouchOneByOne::create();
    listener->onTouchBegan = [this](Touch *touch,Event* event) {
        this->onTouchMoved(touch, event);
        return true;
    };
    listener->onTouchMoved = CC_CALLBACK_2(SightLightScene::onTouchMoved,this);
    getEventDispatcher()->addEventListenerWithSceneGraphPriority(listener, this);
}
Пример #9
0
__USE_CORTEX_NAMESPACE

// ---------------------------------------------------------------- //
// ctor/dtor/accessors
// ---------------------------------------------------------------- //

// parameter-linked ctor
NumericValControl::NumericValControl(
	BRect												frame,
	const char*									name,
	BContinuousParameter*				param,
	uint16											wholeDigits,
	uint16											fractionalDigits,
	align_mode									alignMode,
	align_flags									alignFlags) :
	
	ValControl(frame, name, 0, 0, alignMode, alignFlags, UPDATE_ASYNC, false),
	m_param(param),
	m_wholeDigits(wholeDigits),
	m_fractionalDigits(fractionalDigits) {
	
	// ensure that the parameter represents a continuous value
	ASSERT(
		m_param->ValueType() == B_FLOAT_TYPE ||
		m_param->ValueType() == B_DOUBLE_TYPE 
		
		/*||  unimplemented so far
		m_pParam->ValueType() == B_INT8_TYPE ||
		m_pParam->ValueType() == B_UINT8_TYPE ||
		m_pParam->ValueType() == B_INT16_TYPE ||
		m_pParam->ValueType() == B_UINT16_TYPE ||
		m_pParam->ValueType() == B_INT32_TYPE ||
		m_pParam->ValueType() == B_UINT32_TYPE ||
		m_pParam->ValueType() == B_INT64_TYPE ||
		m_pParam->ValueType() == B_UINT64_TYPE*/ );
	
	initConstraintsFromParam();
	initSegments();
	mediaParameterChanged();
}
Пример #10
0
void TaxiwayProc::SetWidth(double width){
	m_dWidth=width;
	initSegments();
}
Пример #11
0
/*-----------------------------------
            Main for testing
-----------------------------------*/
int main()
{
	//some values/const needed for testing
	int test_port_num = 12345;
	const char* test_ip_addr = "localhost";
	char test_tracker_filename[] = "name.track";
	
	//test file handle
	FILE* test_file_h;
	
	test_file_h = fopen( test_tracker_filename, "a+" );
	
	for( int n=0; n<10; n++ )
	{
		srand(time(NULL));
		fprintf( test_file_h, "\r\n%s:%d:%d:%d:%d",
					test_ip_addr,
					test_port_num,
					rand(),
					rand(),
					rand()
					);
	}
	fclose( test_file_h );

	//run tracker_file_parser()
	tracker_file_parser( 	test_tracker_filename,
							tracked_file_info.filename,
							tracked_file_info.filesize,
							tracked_file_info.description,
							tracked_file_info.md5
							);

	if( TEST_MODE == 1 )
	{
		long test_start = rand();
		long test_end = rand();
		long test_time_stamp = 1999999999;

	
		printf( "\n\r[TEST] Testing commitPendingChunks() & findNextChunk() with start_byte = %ld, end_byte = %ld ...\n",
				test_start,
				test_end
				);
	
		//construct test_chunk struct, could use appendChunk() instead
		for( int n=0; n<2; n++ )
		{
			pending_chunks.push_back( chunks_struct() );
			strcpy( pending_chunks[n].ip_addr, test_ip_addr );
			pending_chunks[n].port_num = test_port_num;
			pending_chunks[n].start_byte = test_start;
			pending_chunks[n].end_byte = test_end;
			pending_chunks[n].time_stamp = test_time_stamp;
			test_port_num++;
			test_time_stamp++;
		}
	
		//test commitPendingChunks()
		commitPendingChunks( test_tracker_filename );
	
		int next_chunk_i = findNextChunk( test_start, test_end );
		if( next_chunk_i >= 0 )
		{
			printf( "[TEST] Chunk[%d] is the next chunk, ip = %s, port = %d, time_stamp = %ld\n",
				next_chunk_i,
				live_chunks[ next_chunk_i ].ip_addr,
				live_chunks[ next_chunk_i ].port_num,
				live_chunks[ next_chunk_i ].time_stamp
				);
		}
		else printf( "[TEST] No next chunk found\n" );
	
		//test isLiveChunk()
		printf( "[TEST] Testing isLiveChunk() ... \n\r" );
		int test_rtn;
		test_rtn = isLiveChunk( live_chunks[1] );
		if( test_rtn != NOT_LIVE_CHUNK ) printf( "[TEST] test_chunk is live @ live_chunks[%d]!\n\r", test_rtn );
		else printf( "[TEST] test_chunk is offline!\n\r" );
		
		printf( "[TEST] Testing createNewTracker() ... \n\r" );
		char dog_file[] = "dog.jpg";
		char dog_track[] = "dog.jpg.track";
		
		test_file_h = fopen( dog_file, "r" );
		fseek( test_file_h, 0, SEEK_END ); 				// seek to end of file
		long dog_size = ftell( test_file_h ); 			// get current file pointer
		fseek( test_file_h, 0, SEEK_SET ); 				// seek back to beginning of file
		fclose( test_file_h );
		
		printf( "[TEST] Testing file: \"%s\" with filesize = %ld ... \n", dog_file, dog_size );
		
		initSegments( dog_size );
		printf( "[TEST] Segment vector initialized\n" );
		
		int client_i = 4;
		
		for(int n=client_i*4; n<(client_i+1)*4; n++ )
		{
			appendSegment( dog_track, dog_size, n, test_port_num );
			printf( "[TEST] Segment[%d] appended\n", n );
		}
		
		char myfile_path[40];
		myFilePath( 1, myfile_path );
		printf( "\r[TEST] Testing myFile() : %s\n", myfile_path );
		
		printf( "\r[TEST] Testing fileSperator() and fileCat() ... \n" );
		fileSperator( dog_file );
		fileCat( dog_file );
		printf( "\r[TEST] Testing fileSperator() and fileCat() ... \n" );
		
		printf( "\n[TEST] Testing DONE!\n\n" );
	}

	return 0;
}
Пример #12
0
void init() {
	initSegments();
}