Exemple #1
0
// FillHole - plug up a dynamically punched authorization hole
//
bool
IpVerify::FillHole(DCpermission perm, MyString& id)
{
	HolePunchTable_t* table = PunchedHoleArray[perm];
	if (table == NULL) {
		return false;
	}

	int count;
	if (table->lookup(id, count) == -1) {
		return false;
	}
	if (table->remove(id) == -1) {
		EXCEPT("IpVerify::FillHole: table entry removal error");
	}

	count--;

	if (count != 0) {
		if (table->insert(id, count) == -1) {
			EXCEPT("IpVerify::FillHole: "
			           "table entry insertion error");
		}
	}

	if (count == 0) {
		dprintf(D_SECURITY,
		        "IpVerify::FillHole: "
		            "removed %s-level opening for %s\n",
		        PermString(perm),
		        id.Value());
	}
	else {
		dprintf(D_SECURITY,
		        "IpVerify::FillHole: "
		            "open count at level %s for %s now %d\n",
		        PermString(perm),
		        id.Value(),
		        count);
	}

	DCpermissionHierarchy hierarchy( perm );
	DCpermission const *implied_perms=hierarchy.getImpliedPerms();
	for(; implied_perms[0] != LAST_PERM; implied_perms++ ) {
		if( perm != implied_perms[0] ) {
			FillHole(implied_perms[0],id);
		}
	}

	return true;
}
bool CMeshCutting::CutMesh(KW_Mesh& Mesh)
{
	if (this->hCuttingClosedCurveVertex3d.empty())
	{
		return false;
	}
	vector<Halfedge_handle> hhClosedCurve;
	GetClosedStrokeHH(hhClosedCurve);
	DeleteFacets(Mesh,hhClosedCurve);
	FillHole(Mesh,hhClosedCurve);
//	this->hCuttingClosedCurveVertex3d.clear();

	return true;
}
Exemple #3
0
// The resulting hull will not contain interior points
// Note that this is a cheap and cheerful implementation that can only handle
// reasonably small point sets. However, except for the final hull it doesn't do any dynamic
// memory allocation - all the work happens on the stack.
Hull* Hull::MakeHull(int numPoints, const Point3* pPoints)
{
    assert(numPoints >= 4);
    assert(pPoints);

    // check first 4 points are disjoint
    // TODO: make it search points so it can cope better with this
    assert(Length(pPoints[1] - pPoints[0]) > 0.01f);
    assert(Length(pPoints[2] - pPoints[0]) > 0.01f);
    assert(Length(pPoints[3] - pPoints[0]) > 0.01f);
    assert(Length(pPoints[2] - pPoints[1]) > 0.01f);
    assert(Length(pPoints[3] - pPoints[1]) > 0.01f);
    assert(Length(pPoints[3] - pPoints[2]) > 0.01f);

    s_pPoints = pPoints;

    // put all temp faces on a free list
    TmpFace tmpFaces[kMaxFaces];

    s_firstFreeTmpFace = 0;
    s_firstUsedTmpFace = -1;
    s_pTmpFaces = tmpFaces;

    for (short i = 0; i < kMaxEdges; i++)
    {
        tmpFaces[i].m_index = i;
        tmpFaces[i].m_next = i + 1;
    }
    tmpFaces[kMaxFaces - 1].m_next = -1;

    // put all temp edges on a free list
    TmpEdge tmpEdges[kMaxEdges];

    s_firstFreeTmpEdge = 0;
    s_firstUsedTmpEdge = -1;
    s_pTmpEdges = tmpEdges;

    for (short i = 0; i < kMaxEdges; i++)
    {
        tmpEdges[i].m_index = i;
        tmpEdges[i].m_next = i + 1;
    }
    tmpEdges[kMaxEdges - 1].m_next = -1;

    // make initial tetrahedron
    Plane plane = Plane(pPoints[0], pPoints[1], pPoints[2]);

    Scalar dot = Dot(plane, pPoints[3]);
    assert(Abs(dot) > 0.01f);			// first 4 points are co-planar

    if (IsNegative(dot))
    {
        AddTmpFace(0, 1, 2);
        AddTmpFace(1, 0, 3);
        AddTmpFace(0, 2, 3);
        AddTmpFace(2, 1, 3);
    }
    else
    {
        AddTmpFace(2, 1, (short)0);
        AddTmpFace(1, 2, 3);
        AddTmpFace(2, 0, 3);
        AddTmpFace(0, 1, 3);
    }

    // merge all remaining points
    for (int i = 4; i < numPoints; i++)
        if (RemoveVisibleFaces(pPoints[i]) > 0)
            FillHole(i);

    return MakeHullFromTemp();
}