static void FillRightOrientedTriangle (HDC hDc) { long y = points [LOW_POINT].y; long leftEdge = points [LOW_POINT].x; long rightEdge = points [LOW_POINT].x; long leftDx = longEdge->dx; long leftDy = longEdge->dy; long rightDx; long rightDy; long leftConst = Floor (longEdge->dx, longEdge->dy); long rightConst; long leftMod = Mod (longEdge->dx, longEdge->dy); long rightMod; long leftNumer = -1; long rightNumer = -1; rightConst = Floor (lowEdge->dx, lowEdge->dy); rightDx = lowEdge->dx; rightDy = lowEdge->dy; rightMod = Mod (rightDx, rightDy); while (lowEdge->dy--) { WriteRow (hDc, leftEdge, rightEdge, y++); leftEdge += leftConst + Floor (Mod (leftNumer, leftDy) + leftMod, leftDy); rightEdge += rightConst + Floor (Mod (rightNumer, rightDy) + rightMod, rightDy); leftNumer += leftDx; rightNumer += rightDx; } rightConst = Floor (topEdge->dx, topEdge->dy); rightDx = topEdge->dx; rightDy = topEdge->dy; rightMod = Mod (rightDx, rightDy); while (topEdge->dy--) { WriteRow (hDc, leftEdge, rightEdge, y++); leftEdge += leftConst + Floor (Mod (leftNumer, leftDy) + leftMod, leftDy); rightEdge += rightConst + Floor (Mod (rightNumer, rightDy) + rightMod, rightDy); leftNumer += leftDx; rightNumer += rightDx; } }
bool FDataTableExporterJSON::WriteTable(const UDataTable& InDataTable) { if (!InDataTable.RowStruct) { return false; } JsonWriter->WriteArrayStart(); // Iterate over rows for (auto RowIt = InDataTable.RowMap.CreateConstIterator(); RowIt; ++RowIt) { JsonWriter->WriteObjectStart(); { // RowName const FName RowName = RowIt.Key(); JsonWriter->WriteValue(TEXT("Name"), RowName.ToString()); // Now the values uint8* RowData = RowIt.Value(); WriteRow(InDataTable.RowStruct, RowData); } JsonWriter->WriteObjectEnd(); } JsonWriter->WriteArrayEnd(); return true; }
void DrawTriangle (HDC hDc, POINT p0, POINT p1, POINT p2, COLORREF color) { int i, j; BOOL left; points [0] = p0; points [1] = p1; points [2] = p2; for (j = 0; j < NUM_POINTS; j++) { for (i = 0; i < NUM_POINTS - 1; i++) { if (points [i].y > points [i + 1].y) // Sort y values in ascending order { SwapPoints (&points [i], &points [i + 1]); } } } longEdge->dx = points [HIGH_POINT].x - points [LOW_POINT].x; longEdge->dy = points [HIGH_POINT].y - points [LOW_POINT].y; topEdge->dx = points [HIGH_POINT].x - points [MID_POINT].x; topEdge->dy = points [HIGH_POINT].y - points [MID_POINT].y; lowEdge->dx = points [MID_POINT].x - points [LOW_POINT].x; lowEdge->dy = points [MID_POINT].y - points [LOW_POINT].y; triangle.color = color; if (!topEdge->dx && !lowEdge->dx) // Degenerate case { WriteColumn (hDc, points [LOW_POINT].x, points [LOW_POINT].y, points [HIGH_POINT].y); return; } if (!longEdge->dy) // Degenerate case { WriteRow (hDc, points [LOW_POINT].x, points [HIGH_POINT].x, points [LOW_POINT].y); return; } left = topEdge->dx * lowEdge->dy > lowEdge->dx * topEdge->dy; // Find common denominator and compare inverse slopes (left ? FillLeftOrientedTriangle : FillRightOrientedTriangle) (hDc); }
void ReadXMLCommand :: TableToCSV( const ALib::XMLElement * e, IOManager & io, unsigned int idx ) { const ALib::XMLElement * table = FindTable( e ); if ( table == 0 ) { CSVTHROW( "No XML table found in " << io.InFileName( idx ) ); } for ( unsigned int i = 0; i < table->ChildCount(); i++ ) { const ALib::XMLElement * ce = table->ChildElement( i ); if ( ce && ce->Name() == "tr" ) { WriteRow( ce, io ); } } }
int FileSplitCommand :: Execute( ALib::CommandLine & cmd ) { GetSkipOptions( cmd ); ProcessFlags( cmd ); IOManager io( cmd ); CSVRow row; while( io.ReadCSV( row ) ) { if ( Skip( row ) ) { continue; } if ( Pass( row ) ) { io.WriteRow( row ); } else { WriteRow( io, row ); } } mOutFile.flush(); return 0; }