Difference between revisions of "User Guide"
Line 1: | Line 1: | ||
− | |||
==Introduction== | ==Introduction== | ||
− | There are several ways to interface with TexGen. The | + | There are several ways to interface with TexGen. A little bit of technical information is necessary to understand how this all fits together. The core TexGen functionality has been written in C++, on top of this a Python interface exists that has access to all the C++ functions of TexGen. There are many advantages of a Python interface that may not be immediatly obvious to the end user. |
− | + | A user friendly Graphical User Interface has been built on top of the Python interface to provide a quick and easy method to interface with TexGen. But the real power comes with writing small Python scripts which will be discussed later. | |
− | |||
− | |||
− | |||
==Graphical User Interface== | ==Graphical User Interface== | ||
− | + | ... | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
==Python Interface== | ==Python Interface== | ||
− | [http://www.python.org/ Python] is a high level interpreted programming language. In the case of TexGen it is used as a scripting language to allow easy access to TexGen functionality. Python has been embedded in the TexGen GUI which allows the GUI to run python scripts. It is not the goal of this | + | [http://www.python.org/ Python] is a high level interpreted programming language. In the case of TexGen it is used as a scripting language to allow easy access to TexGen functionality. Python has been embedded in the TexGen GUI which allows the GUI to run python scripts. It is not the goal of this tutorial to teach Python programming. There are many resources online for that. A few of them are listed below: |
* [http://www.poromenos.org/tutorials/python Learn Python in 10 minutes] - Quick introduction to Python for competent programmers. | * [http://www.poromenos.org/tutorials/python Learn Python in 10 minutes] - Quick introduction to Python for competent programmers. | ||
Line 27: | Line 15: | ||
* [http://diveintopython.org/ Dive Into Python] - In depth book covering advanced subjects in a comprehensive manner. [http://diveintopython.org/toc/index.html HTML Version] | * [http://diveintopython.org/ Dive Into Python] - In depth book covering advanced subjects in a comprehensive manner. [http://diveintopython.org/toc/index.html HTML Version] | ||
− | + | An advanced knowledge of Python is not needed in order to write simple TexGen scripts. However, bear in mind that Python is a very powerful language with many libraries included for performing common tasks. I suggest you try to follow through the examples below and if you get stuck refer to one of the documents above. | |
===Example Script=== | ===Example Script=== | ||
− | In this example, we will create a simple 2x2 plain weave model with a Python script. The first step is to create an instance of the <code>CTextileWeave2D</code> class and give it a name, <code>weave</code>: | + | First of all, a Python script is just a plain ASCII text file with a ''.py'' extension. To create one simple open up your favorite text editor. Notepad will do if you have nothing else but I suggest a freeware text editor like [http://www.pspad.com/ PSPad]. |
+ | |||
+ | All Python code will be shown in a box like this one. | ||
+ | |||
+ | In this example, we will create a simple 2x2 plain weave model with a Python script. Its time to dive in and see some actual Python code. At this point if you are completely lost please refer back to the resources on Python programming. The first step is to create an instance of the <code>CTextileWeave2D</code> class and give it a name, <code>weave</code>: | ||
weave = CTextileWeave2D(2, 2, 1, 0.2, True) | weave = CTextileWeave2D(2, 2, 1, 0.2, True) | ||
Line 40: | Line 32: | ||
* Thickness of the fabrics | * Thickness of the fabrics | ||
* Refine model (True/False) | * Refine model (True/False) | ||
− | The only parameter that really needs an explanation here is the Refine model option, this controls | + | |
+ | The only parameter that really needs an explanation here is the Refine model option, this controls whether or not the interference correction algorithm will be applied to keep the yarn volumes from intersecting which is a common problem. The interference correction algorithm generally does a good job but is not instantaneous so sometimes it can be beneficial to switch it off. | ||
This is the bare minimum information necessary to create a 2D woven fabric. In the following steps we will add more information to create the model the way we want it. | This is the bare minimum information necessary to create a 2D woven fabric. In the following steps we will add more information to create the model the way we want it. | ||
− | Let's set the weave pattern, this determines whether a warp or weft yarn will appear on top at a particular cross over. Cross overs are arranged in 2d grid of | + | Let's set the weave pattern, this determines whether a warp or weft yarn will appear on top at a particular cross over. Cross overs are arranged in 2d grid where the size of the grid depends on the number of warp and weft yarns created. To swap the positions of the weft and warp yarns, we call the function <code>SwapPosition</code> with the grid coordinates of the cross over. In order to create a plain weave we need to do this on two diagonally opposite cross overs like so: |
weave.SwapPosition(0, 0) | weave.SwapPosition(0, 0) | ||
Line 52: | Line 45: | ||
AddTextile(weave) | AddTextile(weave) | ||
+ | |||
+ | Thats it! This is a very simple script but it will generate a plain weave model. To recap your Python script should look like this: | ||
+ | |||
+ | weave = CTextileWeave2D(2, 2, 1, 0.2, True) | ||
+ | weave.SwapPosition(0, 0) | ||
+ | weave.SwapPosition(1, 1) | ||
+ | AddTextile(weave) | ||
+ | |||
+ | Save it to disk as ''PlainWeave.py'' or give it whatever name you want as long as it has a ''.py'' extension. |
Revision as of 15:06, 3 November 2006
Introduction
There are several ways to interface with TexGen. A little bit of technical information is necessary to understand how this all fits together. The core TexGen functionality has been written in C++, on top of this a Python interface exists that has access to all the C++ functions of TexGen. There are many advantages of a Python interface that may not be immediatly obvious to the end user.
A user friendly Graphical User Interface has been built on top of the Python interface to provide a quick and easy method to interface with TexGen. But the real power comes with writing small Python scripts which will be discussed later.
Graphical User Interface
...
Python Interface
Python is a high level interpreted programming language. In the case of TexGen it is used as a scripting language to allow easy access to TexGen functionality. Python has been embedded in the TexGen GUI which allows the GUI to run python scripts. It is not the goal of this tutorial to teach Python programming. There are many resources online for that. A few of them are listed below:
- Learn Python in 10 minutes - Quick introduction to Python for competent programmers.
- Python Tutorial - Official Python tutorial (requires some programming knowledge).
- How to Think Like a Computer Scientist: Learning with Python - Book on Python programming for beginners. HTML Version
- Dive Into Python - In depth book covering advanced subjects in a comprehensive manner. HTML Version
An advanced knowledge of Python is not needed in order to write simple TexGen scripts. However, bear in mind that Python is a very powerful language with many libraries included for performing common tasks. I suggest you try to follow through the examples below and if you get stuck refer to one of the documents above.
Example Script
First of all, a Python script is just a plain ASCII text file with a .py extension. To create one simple open up your favorite text editor. Notepad will do if you have nothing else but I suggest a freeware text editor like PSPad.
All Python code will be shown in a box like this one.
In this example, we will create a simple 2x2 plain weave model with a Python script. Its time to dive in and see some actual Python code. At this point if you are completely lost please refer back to the resources on Python programming. The first step is to create an instance of the CTextileWeave2D
class and give it a name, weave
:
weave = CTextileWeave2D(2, 2, 1, 0.2, True)
The CTextileWeave2D
class takes 5 parameters in the order shown below:
- Number of weft yarns in the unit cell
- Number of warp yarns in the unit cell
- Spacing between the yarns
- Thickness of the fabrics
- Refine model (True/False)
The only parameter that really needs an explanation here is the Refine model option, this controls whether or not the interference correction algorithm will be applied to keep the yarn volumes from intersecting which is a common problem. The interference correction algorithm generally does a good job but is not instantaneous so sometimes it can be beneficial to switch it off.
This is the bare minimum information necessary to create a 2D woven fabric. In the following steps we will add more information to create the model the way we want it.
Let's set the weave pattern, this determines whether a warp or weft yarn will appear on top at a particular cross over. Cross overs are arranged in 2d grid where the size of the grid depends on the number of warp and weft yarns created. To swap the positions of the weft and warp yarns, we call the function SwapPosition
with the grid coordinates of the cross over. In order to create a plain weave we need to do this on two diagonally opposite cross overs like so:
weave.SwapPosition(0, 0) weave.SwapPosition(1, 1)
Now lets add our weave
model to the database of models so that TexGen can render it:
AddTextile(weave)
Thats it! This is a very simple script but it will generate a plain weave model. To recap your Python script should look like this:
weave = CTextileWeave2D(2, 2, 1, 0.2, True) weave.SwapPosition(0, 0) weave.SwapPosition(1, 1) AddTextile(weave)
Save it to disk as PlainWeave.py or give it whatever name you want as long as it has a .py extension.