コード例 #1
0
ファイル: StructArray.cpp プロジェクト: kalwalt/ofxVTerrain
void DLine2FromString(const char *data, DLine2 &line)
{
	// Speed/memory optimization: quick check of how many vertices
	//  there are, then preallocate that many
	uint verts = 0;
	for (size_t i = 0; i < strlen(data); i++)
		if (data[i] == ',')
			verts++;
	line.Empty();
	line.SetMaxSize(verts);

	double x, y;
	while (sscanf(data, "%lf,%lf", &x, &y) == 2)
	{
		line.Append(DPoint2(x,y));
		data = strchr(data, ' ');
		if (!data)
			break;
		data++;
	}
}