Example #1
0
BOOL CRVTrackerDrawPoly::OnNewEdge()
{
	// Geometry/brush mode only, please
	if ((m_pView->GetEditMode() != BRUSH_EDITMODE) && 
		(m_pView->GetEditMode() != GEOMETRY_EDITMODE))
		return FALSE;

	// Get the brush
	CEditBrush *pBrush = &m_pView->DrawingBrush();

	// Make sure we've got at least two points specified
	if (pBrush->m_Points.GetSize() < 2)
		return FALSE;

	// Get the splitting polygon & its points
	CPolyRef rPoly;
	if (!FindSplittingInfo(rPoly, pBrush->m_Points[0], pBrush->m_Points[1]))
		return FALSE;

	// Set up an undo
	PreActionList actionList;
	actionList.AddTail(new CPreAction(ACTION_MODIFYNODE, rPoly.m_pBrush->AsNode()));
	m_pView->GetRegionDoc()->Modify(&actionList, TRUE);

	// Get rid of extra points (the splitting doesn't like them in the list..)
	while (pBrush->m_Points.GetSize() > 2)
		pBrush->m_Points.Remove(pBrush->m_Points.GetSize() - 1);

	// Clear the selected objects that are sub-brush (To make sure we don't crash)
	m_pView->ClearSelections(TRUE, TRUE, TRUE, FALSE);

	// Split the polygon
	m_pView->SplitPolyWithEdge(rPoly, pBrush->m_Points);

	// Clean up the brush
	CLinkedList<CEditBrush*> brushList;
	brushList.AddTail(rPoly.m_pBrush);
	m_pView->GetRegion()->CleanupGeometry(&brushList);

	return TRUE;
}
Example #2
0
ENDI * GetEndiInfo(EUI64 * pId)
{
    ENDI   *pEndi;
    int         nIndex;

    nIndex = g_EndListHash.Find(pId, sizeof(EUI64));
    if (nIndex == -1)
    {
        pEndi = (ENDI *) MALLOC(sizeof(ENDI));
        memset(pEndi, 0, sizeof(ENDI));
        memcpy(&pEndi->id, pId, sizeof(EUI64));
        pEndi->stream.pszBuffer = (char *)MALLOC(1024);
        memset(pEndi->stream.pszBuffer, 0, 1024);

        pEndi->position = (int)g_EndiList.AddTail(pEndi);

        g_EndListHash.Update(pId, sizeof(EUI64), pEndi->position);

        return pEndi;
    }

    pEndi = g_EndiList.Get((POSITION)nIndex);
    return pEndi;
}