コード例 #1
0
ファイル: model_hydrodynamic.c プロジェクト: jburguete/swocs
/**
 * \fn void model_node_parameters_hydrodynamic(Model *model, Node *node)
 * \brief Ffunction to calculate the numerical parameters of a node with the
 *   hydrodynamic model.
 * \param model
 * \brief model struct.
 * \param node
 * \brief node struct.
 */
void model_node_parameters_hydrodynamic(Model *model, Node *node)
{
	double beta_u, cm;
	node_width(node);
	node_perimeter(node);
	node_critical_velocity(node);
	if (node->U[0] <= 0.)
	{
		node->s = node->U[1] = node->u = node->f = node->Sf = node->F = node->T
			= node->Kx = node->KxA = beta_u = cm = 0.;
		node->beta = 1.;
	}
	else if (node->h < model->minimum_depth)
	{
		node->s = node->U[2] / node->U[0];
		node->U[1] = node->u = node->f = node->Sf = node->F = node->T = node->Kx
			= node->KxA = beta_u = 0.;
		node->beta = 1.;
		cm = node->c;
	}
	else
	{
		node->s = node->U[2] / node->U[0];
		node->u = node->U[1] / node->U[0];
		model->node_friction(node);
		beta_u = node->beta * node->u;
		node->F = node->U[0] * beta_u * node->u + G * node->h * node->h
			* (0.5 * node->B0 + 1./3. * node->Z * node->h);
		node->T = node->U[1] * node->s;
		model->node_diffusion(node);
		node->KxA = node->Kx * node->U[0];
		cm = sqrt(node->c * node->c + (node->beta - 1.) * beta_u * node->u);
	}
	node->l1 = beta_u + cm;
	node->l2 = beta_u - cm;
	model->node_infiltration(node);
	node->Pi = node->P * node->i;
}
コード例 #2
0
ファイル: XeTeX_mac.c プロジェクト: luigiScarso/mflua
void
DoAtsuiLayout(void* p, int justify)
{
	memoryword*	node = (memoryword*)p;

	unsigned	f = native_font(node);
	if (fontarea[f] != AAT_FONT_FLAG) {
		fprintf(stderr, "internal error: do_atsui_layout called for non-ATSUI font\n");
		exit(1);
	}

	if (sTextLayout == 0)
		InitializeLayout();

	OSStatus	status = noErr;
	
	long		txtLen = native_length(node);
	const UniChar*	txtPtr = (UniChar*)(node + native_node_size);

	status = ATSUSetTextPointerLocation(sTextLayout, txtPtr, 0, txtLen, txtLen);
	
	// we're using this font in AAT mode, so fontlayoutengine[f] is actually an ATSUStyle
	ATSUStyle	style = (ATSUStyle)(fontlayoutengine[native_font(node)]);
	status = ATSUSetRunStyle(sTextLayout, style, 0, txtLen);

	ATSUAttributeTag		tags[] = { kATSULineWidthTag, kATSULineJustificationFactorTag };
	ItemCount				numTags = sizeof(tags) / sizeof(ATSUAttributeTag);
	if (justify) {
		ByteCount				valSizes[] = { sizeof(Fixed), sizeof(Fract) };
		Fixed					wid = FixedTeXtoPSPoints(node_width(node));
		Fract					just = fract1;
		ATSUAttributeValuePtr	valPtrs[] = { &wid, &just };
		status = ATSUSetLayoutControls(sTextLayout, numTags, tags, valSizes, valPtrs);
	}
	
	ItemCount	count;
	ATSLayoutRecord*	layoutRec = NULL;
	status = ATSUDirectGetLayoutDataArrayPtrFromTextLayout(sTextLayout, 0,
		kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, (void*)&layoutRec, &count);

	int i;
	int	realGlyphCount = 0;
	int lastRealGlyph = 0;
	for (i = 0; i < count; ++i)
		if (layoutRec[i].glyphID < 0xfffe) {
			lastRealGlyph = i;
			++realGlyphCount;
		}

	void*		glyph_info = xmalloc(realGlyphCount * native_glyph_info_size);
	FixedPoint*	locations = (FixedPoint*)glyph_info;
	UInt16*		glyphIDs = (UInt16*)(locations + realGlyphCount);

	Fixed		lsUnit = justify ? 0 : fontletterspace[f];
	Fixed		lsDelta = 0;

	realGlyphCount = 0;
	for (i = 0; i < count; ++i) {
		if (layoutRec[i].glyphID < 0xfffe) {
			if ((layoutRec[i].flags & kATSGlyphInfoIsAttachment) && (lsDelta != 0))
				lsDelta -= lsUnit;
			glyphIDs[realGlyphCount] = layoutRec[i].glyphID;
			locations[realGlyphCount].y = 0;	/* FIXME: won't handle baseline offsets */
			locations[realGlyphCount].x = FixedPStoTeXPoints(layoutRec[i].realPos) + lsDelta;
			lsDelta += lsUnit;
			++realGlyphCount;
		}
	}
	if (lsDelta != 0)
		lsDelta -= lsUnit;

	native_glyph_count(node) = realGlyphCount;
	native_glyph_info_ptr(node) = glyph_info;
	
	if (!justify)
		node_width(node) = FixedPStoTeXPoints(layoutRec[count-1].realPos) + lsDelta;

	ATSUDirectReleaseLayoutDataArrayPtr(NULL, kATSUDirectDataLayoutRecordATSLayoutRecordCurrent, (void*)&layoutRec);

	if (justify)
		ATSUClearLayoutControls(sTextLayout, numTags, tags);
}