This paper presents geometric and algebraic algorithms and relevant optimizing operators for 3D computer modelling of yarns in fabric. New algorithms and approaches are successfully employed to create more realistic and flexible geometry models with consideration of the differential and topological structure of yarns. By using asymptotic iterative approximation, we have developed a new algorithm for creating B-spline curves using periodic interpolation, where the actual curve shape passes through the control points of B-spline. The generator for irregular cross-sections of yarn in complex fabric structures is created with variability in both shape and size along the yarn path represented by combined spline curves, which allows the complicated shapes of yarn cross-sections in fabrics as the yarns are flattened by the compression at the crossovers. An algorithm of differential geometry is employed to track the vector of tangent orientation of the yarn path in 3D space to get the normal plane of yarn for creating the correct cross-section of yarn. The method described is demonstrated by the visualization of woven fabrics. The approach established can then be further generalized for more different and complicated fabrics (including braided fabrics and knitted fabrics) and 3D fabric.