Ejemplo n.º 1
0
static brkp *ClearPoint( memory_expr def_seg )
{
    address addr;
    if( CurrToken == T_MUL ) {
        Scan();
        ReqEOC();
        while( BrkList != NULL ) {
            RemovePoint( BrkList );
        }
    } else {
        RemovePoint( BPNotNull( PointBreak( def_seg, &addr ) ) );
    }
    return( NULL );
}
Ejemplo n.º 2
0
void PointFini( void )
{
    SetRecord( false );
    while( BrkList != NULL ) {
        RemovePoint( BrkList );
    }
}
Ejemplo n.º 3
0
bool RemoveBreak( address addr )
{
    brkp        *bp;

    bp = FindBreak( addr );
    if( bp == NULL ) return( FALSE );
    RemovePoint( bp );
    return( TRUE );
}
Ejemplo n.º 4
0
bool RemoveBreak( address addr )
{
    brkp        *bp;

    bp = FindBreak( addr );
    if( bp == NULL )
        return( false );
    RemovePoint( bp );
    return( true );
}
Ejemplo n.º 5
0
int Actor::RemovePointsInsideArea(Area& area) {
	int n = 0;
	for(unsigned int i = 0; i < mArea.GetPoints().size(); ++i) {
		Point p = mArea.GetPointAt(mArea.GetPoints().begin(), i);
		if(area.IsPointInside(p)) {
			RemovePoint(p);
			n++;
		}
	}
	return n;
}
Ejemplo n.º 6
0
void SteerLib::GJK_EPA::FindEars(std::vector<struct triangle>& triangles, std::vector<Util::Vector> shape, std::vector<struct edges> edges)
{
	std::queue<Util::Vector> ears;

	// Get initial ears
	UpdateEars(ears, edges, shape);

	// Loop while there are still more than 3 points in the shape
	while(shape.size() > 3) {
		Util::Vector ear = ears.front();
		Util::Vector n1, n2;
		
		// Get Neighbors of ear
		for (int i = 0; i < edges.size(); i++) {
			if (edges[i].point == ear) {
				n1 = edges[i].neighbor1;
				n2 = edges[i].neighbor2;
				break;
			}
		}

		// Make triangle out of ear and its two neighbors
		struct triangle t = { ear, n1, n2 };
		triangles.push_back(t);

		// Remove edge that has the ear
		// Points that have the ear as its neighbor are neighbored
		RemoveEdge(edges, ear);
		
		// Remove ear from shape
		RemovePoint(shape, ear);

		// Remove ear from queue
		ears.pop();		

		// Update queue since new ears could have been found
		UpdateEars(ears, edges, shape);
	}

	// Add the last three points as a triangle
	struct triangle t = { shape[0], shape[1], shape[2] };
	triangles.push_back(t);

	if (PRINT_TRIANGLES) {
		for (int i = 0; i < triangles.size(); i++) {
			printf("Triangle %d\n", i + 1);
			printf("<%f, %f, %f> - ", triangles[i].p1.x, triangles[i].p1.y, triangles[i].p1.z);
			printf("<%f, %f, %f> - ", triangles[i].p2.x, triangles[i].p2.y, triangles[i].p2.z);
			printf("<%f, %f, %f>\n", triangles[i].p3.x, triangles[i].p3.y, triangles[i].p3.z);
			printf("**************\n");
		}
	}
}
Ejemplo n.º 7
0
void ClearAllModBreaks( mod_handle handle )
{
    brkp        *bp, *next;
    mod_handle  mh;

    for( bp = BrkList; bp != NULL; bp = next ) {
        next = bp->next;
        DeAliasAddrMod( bp->loc.addr, &mh );
        if( mh == handle ) {
            RemovePoint( bp );
        }
    }
}
Ejemplo n.º 8
0
void
VectorPath::CleanUp()
{
	if (fPointCount == 0)
		return;

	bool notify = false;

	// remove last point if it is coincident with the first
	if (fClosed && fPointCount >= 1) {
		if (fPath[0].point == fPath[fPointCount - 1].point) {
			fPath[0].point_in = fPath[fPointCount - 1].point_in;
			_SetPointCount(fPointCount - 1);
			notify = true;
		}
	}

	for (int32 i = 0; i < fPointCount; i++) {
		// check for unnecessary, duplicate points
		if (i > 0) {
			if (fPath[i - 1].point == fPath[i].point
				&& fPath[i - 1].point == fPath[i - 1].point_out
				&& fPath[i].point == fPath[i].point_in) {
				// the previous point can be removed
				BPoint in = fPath[i - 1].point_in;
				if (RemovePoint(i - 1)) {
					i--;
					fPath[i].point_in = in;
					notify = true;
				}
			}
		}
		// re-establish connections of in-out control points if
		// they line up with the main control point
		if (fPath[i].point_in == fPath[i].point_out
			|| fPath[i].point == fPath[i].point_out
			|| fPath[i].point == fPath[i].point_in
			|| (fabs(agg::calc_line_point_distance(fPath[i].point_in.x,
					fPath[i].point_in.y, fPath[i].point.x, fPath[i].point.y,
					fPath[i].point_out.x, fPath[i].point_out.y)) < 0.01
				&& fabs(agg::calc_line_point_distance(fPath[i].point_out.x,
					fPath[i].point_out.y, fPath[i].point.x, fPath[i].point.y,
					fPath[i].point_in.x, fPath[i].point_in.y)) < 0.01)) {
			fPath[i].connected = true;
			notify = true;
		}
	}

	if (notify)
		_NotifyPathChanged();
}
Ejemplo n.º 9
0
extern void ToggleBreak( address addr )
{
    brkp        *bp;

    if( IS_NIL_ADDR( addr ) ) return;
    bp = FindBreak( addr );
    if( bp == NULL ) {
        AddBreak( addr );
    } else if( bp->status.b.active ) {
        ActPoint( bp, FALSE );
    } else {
        RemovePoint( bp );
    }
}
Ejemplo n.º 10
0
void Game::HandleEvent(SDL_Event &event)
{
    if (event.user.code == COLLISION_ASTEROID_PLANET)
    {
        RemovePoint();

        DestroyBody((b2Body*)event.user.data1);
    }
    else if (event.user.code == COLLISION_BOMB_PLANET)
    {
        RemovePoint();

        DestroyBody((b2Body*)event.user.data1);
    }
    else if (event.user.code == COLLISION_ASTEROID_BOMB)
    {
        // blow up bomb
        ((Bomb*)((b2Body*)event.user.data2)->GetUserData())->Detonate((b2Body*)event.user.data1);
    }
    else if (event.user.code == DELETE_BODY)
    {
        DestroyBody((b2Body*)event.user.data1);
    }
}
Ejemplo n.º 11
0
void CPointsCollection::RemovePointY(double y, BOOL bReScan)
{
	SSinglePoint ssp;
	BOOL bFit = FALSE;
	for (int i=0; i<GetSize(); i++)
	{
		if (GetPoint(i, &ssp) != -1)
		{
			if (ssp.y == y)
			{
				RemovePoint(i, FALSE);
				i-=1;
				bFit = TRUE;
			};
		};
	};
	if (bReScan) RescanPoints();	
}
Ejemplo n.º 12
0
int CPointsCollection::EditPoint(int index, double x, double y, BOOL bRescan)
{
	if (index<0 || index>=GetSize()) return -1;
	int ret;
	SSinglePoint ssp(x, y);
	//if bSortX not specified - just replace given point
	RemovePoint(index, FALSE);
	if (!bSortX)
	{
		InsertPoint(index, ssp.x, ssp.y, bRescan);
		ret = index;
	} else
	{
		int res;
		ret = AddPoint(&ssp, bRescan, &res);
	};
	return ret;
}
Ejemplo n.º 13
0
	void OnClick(UINT cmd_id)
	{
		while (captured > 0)
			RemovePoint();

		if (cmd_id == command)
		{
			app->DoCmd(Visio::visCmdDRPointerTool);
			command = 0;
		}
		else
		{
			if (command == 0)
				app->DoCmd(Visio::visCmdDRConnectionTool);

			command = cmd_id;
		}

		SetNeedUpdate(true);
	}
Ejemplo n.º 14
0
extern void DUIRemoveBreak( void *bp )
/***********************************/
{
    RemovePoint( bp );
}
Ejemplo n.º 15
0
void DUIRemoveBreak( brkp *bp )
/***********************************/
{
    RemovePoint( bp );
}
Ejemplo n.º 16
0
int CPointsCollection::AddPoint(double _x, double _y, BOOL bReScan, int* res)
{
	int index;
	//adjust max and min
	if (GetSize() == 0)
	{
		max_x = min_x = _x;
		max_y = min_y = _y;
	} else
	{
		if (max_x<_x) max_x = _x;
		if (min_x>_x) min_x = _x;
		if (max_y<_y) max_y = _y;
		if (min_y>_y) min_y = _y;
	};
	SSinglePoint ssp(_x, _y);
	SSinglePoint spoint;
	long array_size = GetSize();
	if (!bSortX)
	{//if there is no sort - just add the point to the end of array
		points.push_back(ssp);
		index = array_size;
	} else
	{
		//find the place for new element
		if (array_size == 0)
		{
			points.push_back(ssp);
			index = array_size;
		} else
		{
			//check lower bound
			GetPoint(0, &spoint);
			if (_x<spoint.x)
			{
				index = 0;
				points.insert(points.begin() + index, ssp);
			} else
			{
				//check upper bound
				GetPoint(array_size-1, &spoint);
				if (_x>spoint.x)
				{
					points.push_back(ssp);
					index = array_size;
				} else
				{
					index = 0;
					BOOL bFit = FALSE;
					for (int i=0; i<array_size; i++)
					{
						GetPoint(i, &spoint);
						if (spoint.x == _x)
						{
							index = i;
							bFit = TRUE;
							break;
						};
						if (_x<spoint.x)
						{
							index = i;
							break;
						};
					};
					if (bFit)
					{
						if (bKeepSameX)
						{
							points.insert(points.begin() + index, ssp);
						} else
						{
							RemovePoint(index, FALSE);//do not rescan right away - cause we add one more point right after
							points.insert(points.begin() + index, ssp);
							//need to recalculate extremums
							if (bReScan) RescanPoints();
						};
					} else
					{
						//just insert point before index
						points.insert(points.begin() + index, ssp);
					};
				};
			};
		};
	};
	return index;
}
Ejemplo n.º 17
0
void CurveEditHandleButton(int button, int state, int x, int y)
{
  float fx, fy;
  int point;

  fy = -(((float)y - ((float)CurveWHeight/NUM_JOINTS * EditingCurve)) /
       ((float)CurveWHeight/NUM_JOINTS) - 0.5) * 180.0,
  fx = (float)x/CurveWWidth;
  
  if (state == GLUT_DOWN && button == GLUT_LEFT_BUTTON &&
                            CurveDownBtn == -1) {
    CurvePickedPoint = -1;
    
    for (point = 0; point < RotCurve[EditingCurve].numpoints; point++) {
      if (fabs(RotCurve[EditingCurve].xcoords[point] - fx) < 0.01 &&
	  fabs(RotCurve[EditingCurve].angles[point] - fy) < 4) {
	CurvePickedPoint = point;
	CurveLastX = x;
	CurveLastY = y;
	glutIdleFunc(CurveCPointDrag);
	break;
      }
    }
   if (CurvePickedPoint == -1)
     CurveHandleButton(button, state, x, y);
    CurveDownBtn = button;


  } else if (state == GLUT_DOWN && button == GLUT_MIDDLE_BUTTON &&
                                   CurveDownBtn == -1) {

    for (point = 3; point < RotCurve[EditingCurve].numpoints - 1; point += 3) {
      if (fabs(RotCurve[EditingCurve].xcoords[point] - fx) < 0.01 &&
	  fabs(RotCurve[EditingCurve].angles[point] - fy) < 4) {
	break;
      }
    }
    if (point >= 3 && point < RotCurve[EditingCurve].numpoints - 1)
      RemovePoint(point);
    else if (fabs(Walk_cycle[0][EditingCurve][(int)(fx*CYCLE_SIZE)] - fy) < 4)
      AddPoint(fx);
    ComputeCurve(EditingCurve);
    MakeJointLists(EditingCurve);    
    RedisplayBoth();

  } else if (button == GLUT_LEFT_BUTTON && button == CurveDownBtn) {

    y = MAX(y, 0); y = MIN(y, CurveWHeight);
    x = MAX(x, 0); x = MIN(x, CurveWWidth);
    fy = -(((float)y - ((float)CurveWHeight/NUM_JOINTS * EditingCurve)) /
         ((float)CurveWHeight/NUM_JOINTS) - 0.5) * 180.0,
    fx = (float)x/CurveWWidth;
    CurveDownBtn = -1;
    if (CurvePickedPoint != -1) {
      fx = CurveEditConstrain(fx);
      RotCurve[EditingCurve].xcoords[CurvePickedPoint] = fx;
      RotCurve[EditingCurve].angles[CurvePickedPoint] = fy;        
      ComputeCurve(EditingCurve);
      MakeJointLists(EditingCurve);
      glutIdleFunc(NULL);
      RedisplayBoth();
    }
  }
}  
Ejemplo n.º 18
0
	void Execute()
	{
		Visio::IVCellPtr cell_x0 = points[0].shape->CellsSRC[Visio::visSectionConnectionPts][points[0].row][0];
		double x0 = cell_x0->ResultIU;

		Visio::IVCellPtr cell_y0 = points[0].shape->CellsSRC[Visio::visSectionConnectionPts][points[0].row][1];
		double y0 = cell_y0->ResultIU;

		Visio::IVCellPtr cell_x1 = points[1].shape->CellsSRC[Visio::visSectionConnectionPts][points[1].row][0];
		double x1 = cell_x1->ResultIU;

		Visio::IVCellPtr cell_y1 = points[1].shape->CellsSRC[Visio::visSectionConnectionPts][points[1].row][1];
		double y1 = cell_y1->ResultIU;

		double page_x0, page_y0;
		points[0].shape->XYToPage(x0, y0, &page_x0, &page_y0);

		double page_x1, page_y1;
		points[1].shape->XYToPage(x1, y1, &page_x1, &page_y1);

		double dx = page_x1 - page_x0;
		double dy = page_y1 - page_y0;

		Visio::IVWindowPtr window;
		if (FAILED(app->get_ActiveWindow(&window)) || window == NULL)
			return;

		Visio::IVSelectionPtr selection;
		if (FAILED(window->get_Selection(&selection)) || selection == NULL)
			return;

		switch (command)
		{

		case ID_TwoPointsMove:
			{
				RemovePoint();

				selection->Move(dx, dy);
				break;
			}

		case ID_TwoPointsCopy:
			{
				RemovePoint();

				Point saved = points[0];
				RemovePoint();

				double x1, y1, x2, y2;
				selection->BoundingBox(Visio::visBBoxUprightWH, &x1, &y1, &x2, &y2);

				selection->Duplicate();

				Visio::IVSelectionPtr new_selection;
				if (FAILED(window->get_Selection(&new_selection)) || new_selection == NULL)
					return;

				double dup_x1, dup_y1, dup_x2, dup_y2;
				new_selection->BoundingBox(Visio::visBBoxUprightWH, &dup_x1, &dup_y1, &dup_x2, &dup_y2);

				dx -= (dup_x1 - x1);
				dy -= (dup_y1 - y1);

				new_selection->Move(dx, dy);

				AddPoint(saved);

				window->Selection = selection;
				break;
			}
		}
	}
double NaturalNeighbourInterpolation (glm::vec3 point, DelaunayTriangulation* dt)
{
	Vertex p;
	p.m_Point[0] =  point.x;
	p.m_Point[1] =  point.y;
	p.m_Point[2] =  point.z;
	p.m_VoronoiVolume = -1;

	ArrayList* neighbours;
	ArrayList* neighbourSimplices;
  
	AddPoint(&p, dt);    

	neighbours = NewArrayList();  
	neighbourSimplices = NewArrayList();  
	LastNaturalNeighbours(&p, dt, neighbours, neighbourSimplices);

	double pointVolume;

	std::vector<double> neighbourVolumes;
	std::vector<double> neighbourWeights;
	neighbourVolumes.resize (ArrayListSize(neighbours));
	neighbourWeights.resize (ArrayListSize(neighbours));

	for (int i = 0; i < ArrayListSize(neighbours); i++)
	{
		Vertex* thisVertex  = static_cast<Vertex*> (GetFromArrayList(neighbours, i));
		Simplex* thisSimplex = static_cast<Simplex*> (GetFromArrayList(neighbourSimplices, i));  
		VoronoiCell* voronoiCell = GetVoronoiCell(thisVertex, thisSimplex, dt);    
		neighbourVolumes[i]  = VoronoiCellVolume(voronoiCell, thisVertex);  
		FreeVoronoiCell(voronoiCell, dt); 
	}

	Simplex* simplex = static_cast<Simplex*> (GetFromArrayList(neighbourSimplices, 0));
	VoronoiCell* pointCell = GetVoronoiCell(&p, simplex, dt);
	pointVolume = VoronoiCellVolume(pointCell, &p);
	FreeVoronoiCell(pointCell, dt);
         
	RemovePoint(dt);

	for (int i = 0; i < ArrayListSize(neighbours); i++)
	{
		Vertex* neighbourVertex   = static_cast<Vertex*> (GetFromArrayList(neighbours, i));  
  
		if (neighbourVertex->m_VoronoiVolume < 0)
		{
			Simplex* s = FindAnyNeighbour(neighbourVertex, dt->m_Conflicts);
			VoronoiCell* voronoiCell      = GetVoronoiCell(neighbourVertex, s, dt);
			neighbourVertex->m_VoronoiVolume = VoronoiCellVolume(voronoiCell, neighbourVertex);
			FreeVoronoiCell(voronoiCell, dt);
		}
		double neighbourVol = neighbourVertex->m_VoronoiVolume-neighbourVolumes[i];
		
		assert (neighbourVolumes[i]>= -0.001);
		neighbourWeights[i] = neighbourVol/pointVolume;
	}

	double result = CalculateValue (neighbours, neighbourWeights);

	for (int i = 0; i <ArrayListSize(dt->m_Updates); i++)
	  Push(dt->m_RemovedSimplices, GetFromArrayList(dt->m_Updates, i));

	EmptyArrayList(dt->m_Conflicts);
	EmptyArrayList(dt->m_Updates);
  
	FreeArrayList(neighbours, nullptr);
	FreeArrayList(neighbourSimplices, nullptr);

	return result;
}