Exemplo n.º 1
0
void block_setRootInstance(Block *block, Segment *segment) {
	block = block_getPositiveOrientation(block);
	segment = segment_getPositiveOrientation(segment);
	assert(block_getInstance(block, segment_getName(segment)) == segment);
	end_setRootInstance(block_get5End(block), segment_get5Cap(segment));
	end_setRootInstance(block_get3End(block), segment_get3Cap(segment));
}
Exemplo n.º 2
0
void block_check(Block *block) {
	//Check is connected to flower properly
	cactusCheck(flower_getBlock(block_getFlower(block), block_getName(block)) == block_getPositiveOrientation(block));
	//Check we have actually set built blocks for the flower..
	cactusCheck(flower_builtBlocks(block_getFlower(block)));

	//Checks the two ends are block ends.
	End *_5End = block_get5End(block);
	End *_3End = block_get3End(block);
	cactusCheck(end_isBlockEnd(_5End));
	cactusCheck(end_isBlockEnd(_3End));
	cactusCheck(end_getOrientation(_5End) == block_getOrientation(block));
	cactusCheck(end_getOrientation(_3End) == block_getOrientation(block));
	cactusCheck(end_getBlock(_5End) == block);
	cactusCheck(end_getBlock(_3End) == block);
	cactusCheck(end_getSide(_5End)); //Check the sides of the ends are consistent.
	cactusCheck(!end_getSide(_3End));

	cactusCheck(block_getLength(block) > 0); //check block has non-zero length

	//Check reverse
	Block *rBlock = block_getReverse(block);
	cactusCheck(rBlock != NULL);
	cactusCheck(block_getReverse(block) == rBlock);
	cactusCheck(block_getOrientation(block) == !block_getOrientation(rBlock));
	cactusCheck(block_getLength(block) == block_getLength(rBlock));
	cactusCheck(block_get5End(block) == end_getReverse(block_get3End(rBlock)));
	cactusCheck(block_get3End(block) == end_getReverse(block_get5End(rBlock)));
	cactusCheck(block_getInstanceNumber(block) == block_getInstanceNumber(rBlock));
	if(block_getInstanceNumber(block) > 0) {
		cactusCheck(block_getFirst(block) == segment_getReverse(block_getFirst(rBlock)));
		if(block_getRootInstance(block) == NULL) {
			cactusCheck(block_getRootInstance(rBlock) == NULL);
		}
		else {
			cactusCheck(block_getRootInstance(block) == segment_getReverse(block_getRootInstance(rBlock)));
		}
	}

	//For each segment calls segment_check.
	Block_InstanceIterator *iterator = block_getInstanceIterator(block);
	Segment *segment;
	while((segment = block_getNext(iterator)) != NULL) {
		segment_check(segment);
	}
	block_destructInstanceIterator(iterator);
}
Exemplo n.º 3
0
void flower_removeBlock(Flower *flower, Block *block) {
    block = block_getPositiveOrientation(block);
    assert(stSortedSet_search(flower->blocks, block) != NULL);
    stSortedSet_remove(flower->blocks, block);
}
Exemplo n.º 4
0
void flower_addBlock(Flower *flower, Block *block) {
    block = block_getPositiveOrientation(block);
    assert(stSortedSet_search(flower->blocks, block) == NULL);
    stSortedSet_insert(flower->blocks, block);
}