예제 #1
0
TESStesselator* tessNewTess( TESSalloc* alloc )
{
	TESStesselator* tess;

	if (alloc == NULL)
		alloc = &defaulAlloc;
	
	/* Only initialize fields which can be changed by the api.  Other fields
	* are initialized where they are used.
	*/

	tess = (TESStesselator *)alloc->memalloc( alloc->userData, sizeof( TESStesselator ));
	if ( tess == NULL ) {
		return 0;          /* out of memory */
	}
	tess->alloc = *alloc;
	/* Check and set defaults. */
	if (tess->alloc.meshEdgeBucketSize == 0)
		tess->alloc.meshEdgeBucketSize = 512;
	if (tess->alloc.meshVertexBucketSize == 0)
		tess->alloc.meshVertexBucketSize = 512;
	if (tess->alloc.meshFaceBucketSize == 0)
		tess->alloc.meshFaceBucketSize = 256;
	if (tess->alloc.dictNodeBucketSize == 0)
		tess->alloc.dictNodeBucketSize = 512;
	if (tess->alloc.regionBucketSize == 0)
		tess->alloc.regionBucketSize = 256;
	
	tess->normal[0] = 0;
	tess->normal[1] = 0;
	tess->normal[2] = 0;

	tess->bmin[0] = 0;
	tess->bmin[1] = 0;
	tess->bmax[0] = 0;
	tess->bmax[1] = 0;

	tess->windingRule = TESS_WINDING_ODD;

	if (tess->alloc.regionBucketSize < 16)
		tess->alloc.regionBucketSize = 16;
	if (tess->alloc.regionBucketSize > 4096)
		tess->alloc.regionBucketSize = 4096;
	tess->regionPool = createBucketAlloc( &tess->alloc, "Regions",
										 sizeof(ActiveRegion), tess->alloc.regionBucketSize );

	// Initialize to begin polygon.
	tess->mesh = NULL;

	tess->outOfMemory = 0;
	tess->vertexIndexCounter = 0;
	
	tess->vertices = 0;
	tess->vertexIndices = 0;
	tess->vertexCount = 0;
	tess->elements = 0;
	tess->elementCount = 0;

	return tess;
}
예제 #2
0
파일: dict.c 프로젝트: hoodie/libavg
/* really tessDictListNewDict */
Dict *dictNewDict(TESSalloc* alloc, void *frame, int (*leq)(void *frame, DictKey key1, DictKey key2))
{
    Dict *dict = (Dict *)alloc->memalloc(alloc->userData, sizeof(Dict));
    DictNode *head;

    if (dict == NULL) {
        return NULL;
    }

    head = &dict->head;

    head->key = NULL;
    head->next = head;
    head->prev = head;

    dict->frame = frame;
    dict->leq = leq;

    if (alloc->dictNodeBucketSize < 16) {
        alloc->dictNodeBucketSize = 16;
    }
    if (alloc->dictNodeBucketSize > 4096) {
        alloc->dictNodeBucketSize = 4096;
    }
    dict->nodePool = createBucketAlloc(alloc, "Dict", sizeof(DictNode), alloc->dictNodeBucketSize);

    return dict;
}
예제 #3
0
/* tessMeshNewMesh() creates a new mesh with no edges, no vertices,
* and no loops (what we usually call a "face").
*/
TESSmesh *tessMeshNewMesh( TESSalloc* alloc )
{
    TESSvertex *v;
    TESSface *f;
    TESShalfEdge *e;
    TESShalfEdge *eSym;
    TESSmesh *mesh = (TESSmesh *)alloc->memalloc( alloc->userData, sizeof( TESSmesh ));
    if (mesh == NULL) {
        return NULL;
    }

    if (alloc->meshEdgeBucketSize < 16)
        alloc->meshEdgeBucketSize = 16;
    if (alloc->meshEdgeBucketSize > 4096)
        alloc->meshEdgeBucketSize = 4096;

    if (alloc->meshVertexBucketSize < 16)
        alloc->meshVertexBucketSize = 16;
    if (alloc->meshVertexBucketSize > 4096)
        alloc->meshVertexBucketSize = 4096;

    if (alloc->meshFaceBucketSize < 16)
        alloc->meshFaceBucketSize = 16;
    if (alloc->meshFaceBucketSize > 4096)
        alloc->meshFaceBucketSize = 4096;

    mesh->edgeBucket = createBucketAlloc( alloc, "Mesh Edges", sizeof(EdgePair), alloc->meshEdgeBucketSize );
    mesh->vertexBucket = createBucketAlloc( alloc, "Mesh Vertices", sizeof(TESSvertex), alloc->meshVertexBucketSize );
    mesh->faceBucket = createBucketAlloc( alloc, "Mesh Faces", sizeof(TESSface), alloc->meshFaceBucketSize );

    v = &mesh->vHead;
    f = &mesh->fHead;
    e = &mesh->eHead;
    eSym = &mesh->eHeadSym;

    v->next = v->prev = v;
    v->anEdge = NULL;

    f->next = f->prev = f;
    f->anEdge = NULL;
    f->trail = NULL;
    f->marked = FALSE;
    f->inside = FALSE;

    e->next = e;
    e->Sym = eSym;
    e->Onext = NULL;
    e->Lnext = NULL;
    e->Org = NULL;
    e->Lface = NULL;
    e->winding = 0;
    e->activeRegion = NULL;

    eSym->next = eSym;
    eSym->Sym = e;
    eSym->Onext = NULL;
    eSym->Lnext = NULL;
    eSym->Org = NULL;
    eSym->Lface = NULL;
    eSym->winding = 0;
    eSym->activeRegion = NULL;

    return mesh;
}
예제 #4
0
파일: tess.c 프로젝트: Aidoru/openscad
int stackInit( EdgeStack *stack, TESSalloc *alloc )
{
	stack->top = NULL;
	stack->nodeBucket = createBucketAlloc( alloc, "CDT nodes", sizeof(EdgeStackNode), 512 );
	return stack->nodeBucket != NULL;
}