A mathematical model for simulation of the internal structure of 3D or conventional fabric is developed and incorporated in computer code. The model accounts for yarn crimp, compression and deflections within a fabric structure. The energy principles are used to compute yarn positions. The model allows computation of fabric mass. thickness, yarn crimp factor, fabric porosity and production of pictures of fabric cross-sections in any direction. The model is meant to be used in the textile industry, paper-making industry and industry of composite materials.