* *ShortCut* - short-cut header files will be created, redirecting to same-named header located in *src*;
* "HardLink* - hard links to headers located in *src* will be created.
* For optional third-party libraries, set corresponding environment variable <i>HAVE_<LIBRARY_NAME></i> to either *false*, e.g.:
-~~~~~
+~~~~
export HAVE_FREEIMAGE=false
-~~~~~
+~~~~
Alternatively, or when *custom.sh* or *custom.bat* does not exist, you can launch **genconf** tool to configure environment interactively:
Launch **genproj** tool with option *cbp* to update content of *inc* folder and generate project files after changes in OCCT code affecting layout or composition of source files:
-~~~~~
+~~~~
$ cd /dev/OCCT/opencascade-7.0.0
$ ./genproj cbp
-~~~~~
+~~~~
The generated Code::Blocks project are placed into subfolder *adm/<OS>/cbp*.
To build all toolkits, click **Build->Build workspace** in the menu bar.
To start *DRAWEXE*, which has been built with **Code::Blocks** on Mac OS X, run the script
-~~~~~
+~~~~
./draw.sh cbp [d]
-~~~~~
+~~~~
Option *d* is used if OCCT has been built in **Debug** mode.
@subsection build_occt_genproj Building with Genproj tool
@note To use **genproj** and **genconf** tools you need to have Tcl installed and accessible by PATH.
If Tcl is not found, the tool may prompt you to enter the path to directory where Tcl can be found.
-~~~~~
+~~~~
$ genproj.bat
-~~~~~
+~~~~
Note that if *custom.bat* is not present, **genproj** will start **genconf** to configure environment.
* *ShortCut* - short-cut header files will be created, redirecting to same-named header located in *src*;
* "HardLink* - hard links to headers located in *src* will be created.
* For optional third-party libraries, set corresponding environment variable <i>HAVE_<LIBRARY_NAME></i> to either *false*, e.g.:
-~~~~~
+~~~~
export HAVE_FREEIMAGE=false
-~~~~~
+~~~~
Alternatively, or when *custom.sh* does not exist, you can launch *genconf.sh* to configure environment interactively:
For instance, in Terminal application:
-~~~~~
+~~~~
$ cd /dev/OCCT/opencascade-7.0.0
$ ./genproj
-~~~~~
+~~~~
<h2>Building</h2>
1.Open Terminal application
2.Enter <i>\<OCCT_ROOT_DIR\></i>:
-~~~~~
+~~~~
cd \<OCCT_ROOT_DIR\>
-~~~~~
+~~~~
3.Run the script
-~~~~~
+~~~~
./draw_cbp.sh xcd [d]
-~~~~~
+~~~~
Option *d* is used if OCCT has been built in **Debug** mode.
* *ShortCut* - short-cut header files will be created, redirecting to same-named header located in *src*;
* "HardLink* - hard links to headers located in *src* will be created.
* For optional third-party libraries, set corresponding environment variable <i>HAVE_<LIBRARY_NAME></i> to either *false*, e.g.:
-~~~~~
+~~~~
export HAVE_FREEIMAGE=false
-~~~~~
+~~~~
Alternatively, or when *custom.sh* or *custom.bat* does not exist, you can launch **genconf** tool to configure
environment interactively:
Launch **genproj** tool with option *cbp* to update content of *inc* folder and generate project files after changes in
OCCT code affecting layout or composition of source files:
-~~~~~
+~~~~
$ cd /dev/OCCT/opencascade-7.0.0
$ ./genproj cbp
-~~~~~
+~~~~
The generated Code::Blocks project are placed into subfolder *adm/<OS>/cbp*.
To build all toolkits, click **Build->Build workspace** in the menu bar.
To start *DRAWEXE*, which has been built with **Code::Blocks** on Mac OS X, run the script
-~~~~~
+~~~~
./draw_cbp.sh cbp [d]
-~~~~~
+~~~~
Option *d* is used if OCCT has been built in **Debug** mode.
Camel Case style is preferred for names.
For example:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer awidthofbox; // this is bad
Standard_Integer width_of_box; // this is bad
Standard_Integer aWidthOfBox; // this is OK
-~~~~~
+~~~~
@subsection occt_coding_rules_2_2 Names of development units
Names of public classes and other types (structures, enums, typedefs) should match the common pattern: name of the package followed by underscore and suffix (the own name of the type):
-~~~~~
+~~~~{.cpp}
<package-name>_<class-name>
-~~~~~
+~~~~
Static methods related to the whole package are defined in the class with the same name as package (without suffix).
Such types should be given own names using *typedef* statement, located in same-named header file.
For example, see definition in the file *TColStd_IndexedDataMapOfStringString.hxx*:
-~~~~~
+~~~~{.cpp}
typedef NCollection_IndexedDataMap<TCollection_AsciiString,TCollection_AsciiString,TCollection_AsciiString> TColStd_IndexedDataMapOfStringString;
-~~~~~
+~~~~
### Names of functions
It is preferred to start names of public methods from an upper case character and to start names of protected and private methods from a lower case character.
-~~~~~{.cpp}
+~~~~{.cpp}
class MyPackage_MyClass
{
void setIntegerValue (const Standard_Integer theValue);
};
-~~~~~
+~~~~
@subsection occt_coding_rules_2_3 Names of variables
See the following examples:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer Elapsed_Time = 0; // this is bad - possible class name
Standard_Integer gp = 0; // this is bad - existing package name
Standard_Integer aGp = 0; // this is OK
Standard_Integer _KERNEL = 0; // this is bad
Standard_Integer THE_KERNEL = 0; // this is OK
-~~~~~
+~~~~
### Names of function parameters
See the following examples:
-~~~~~{.cpp}
+~~~~{.cpp}
void Package_MyClass::MyFunction (const gp_Pnt& p); // this is bad
void Package_MyClass::MyFunction (const gp_Pnt& theP); // this is OK
void Package_MyClass::MyFunction (const gp_Pnt& thePoint); // this is preferred
-~~~~~
+~~~~
### Names of class member variables
See the following examples:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer counter; // This is bad
Standard_Integer myC; // This is OK
Standard_Integer myCounter; // This is preferred
-~~~~~
+~~~~
### Names of global variables
See the following examples:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer MyPackage_myGlobalVariable = 0;
Standard_Integer MyPackage_MyClass_myGlobalVariable = 0;
-~~~~~
+~~~~
Static constants within the file should be written in upper-case and begin with prefix *THE_*:
-~~~~~{.cpp}
+~~~~{.cpp}
namespace
{
static const Standard_Real THE_CONSTANT_COEF = 3.14;
};
-~~~~~
+~~~~
### Names of local variables
See the following example:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer theI; // this is bad
Standard_Integer i; // this is bad
Standard_Integer index; // this is bad
Standard_Integer anIndex; // this is OK
-~~~~~
+~~~~
### Avoid dummy names
Avoid dummy names, such as <i>i, j, k</i>. Such names are meaningless and easy to mix up.
See the following examples for preferred style:
-~~~~~{.cpp}
+~~~~{.cpp}
void Average (const Standard_Real** theArray,
Standard_Integer theRowsNb,
Standard_Integer theRowLen,
theResult /= Standard_Real(aRowsNb * aRowLen);
}
}
-~~~~~
+~~~~
@section occt_coding_rules_3 Formatting rules
* For better readability it is also recommended to surround conventional operators by a space character.
Examples:
-~~~~~{.cpp}
+~~~~{.cpp}
while (true) // NOT: while( true ) ...
{
DoSomething (theA, theB, theC, theD); // NOT: DoSomething(theA,theB,theC,theD);
{
theA = (theB + theC) * theD; // NOT: theA=(theB+theC)*theD
}
-~~~~~
+~~~~
### Declaration of pointers and references
Examples:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer *theVariable; // not recommended
Standard_Integer * theVariable; // not recommended
Standard_Integer* theVariable; // this is OK
Standard_Integer** theVariable; // this is OK
Standard_Integer *theA, theB, **theC; // not recommended (declare each variable independently)
-~~~~~
+~~~~
### Separate logical blocks
See the following example:
-~~~~~{.cpp}
+~~~~{.cpp}
// check arguments
Standard_Integer anArgsNb = argCount();
if (anArgsNb < 3 || isSmthInvalid)
// do our job
...
...
-~~~~~
+~~~~
Notice that multiple blank lines should be avoided.
See the following example:
-~~~~~{.cpp}
+~~~~{.cpp}
// =======================================================================
// function : TellMeSmthGood
// purpose : Gives me good news
{
...
}
-~~~~~
+~~~~
### Block layout [MANDATORY]
Figure brackets <i>{ }</i> and each operator <i>(for, if, else, try, catch)</i> should be written on a dedicated line.
In general, the layout should be as follows:
-~~~~~{.cpp}
+~~~~{.cpp}
while (expression)
{
...
}
-~~~~~
+~~~~
Entering a block increases and leaving a block decreases the indentation by one tabulation.
Single-line conditional operators <i>(if, while, for,</i> etc.) can be written without brackets on the following line.
-~~~~~{.cpp}
+~~~~{.cpp}
if (!myIsInit) return Standard_False; // bad
if (thePtr == NULL) // OK
{
DoSomething();
}
-~~~~~
+~~~~
Having all code in the same line is less convenient for debugging.
In comparisons, put the variable (in the current context) on the left side and constant on the right side of expression.
That is, the so called "Yoda style" is to be avoided.
-~~~~~{.cpp}
+~~~~{.cpp}
if (NULL != thePointer) // Yoda style, not recommended
if (thePointer != NULL) // OK
if (THE_LIMIT == theValue) // bad style (global constant vs. variable)
if (theValue == THE_LIMIT) // OK
-~~~~~
+~~~~
### Alignment
Use alignment wherever it enhances the readability. See the following example:
-~~~~~{.cpp}
+~~~~{.cpp}
MyPackage_MyClass anObject;
Standard_Real aMinimum = 0.0;
Standard_Integer aVal = theVal;
case 3:
default: computeSomethingElseYet(); break;
}
-~~~~~
+~~~~
### Indentation of comments
See the following example:
-~~~~~{.cpp}
+~~~~{.cpp}
while (expression) //bad comment
{
// this is a long multi-line comment
DoSomething(); // maybe, enough
DoSomethingMore(); // again
}
-~~~~~
+~~~~
### Early return statement
Write like this:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer ComputeSumm (const Standard_Integer* theArray,
const Standard_Size theSize)
{
... computing summ ...
return aSumm;
}
-~~~~~
+~~~~
Rather than:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer ComputeSumm (const Standard_Integer* theArray,
const Standard_Size theSize)
{
}
return aSumm;
}
-~~~~~
+~~~~
This helps to improve readability and reduce the unnecessary indentation depth.
The source or header file should include only minimal set of headers necessary for compilation, without duplicates (considering nested includes).
-~~~~~{.cpp}
+~~~~{.cpp}
// the header file of implemented class
#include <PackageName_ClassName.hxx>
// system headers
#include <iostream>
#include <windows.h>
-~~~~~
+~~~~
@section occt_coding_rules_4 Documentation rules
Declaration of overriding method should contains specifiers "virtual" and "override"
(using Standard_OVERRIDE alias for compatibility with old compilers).
-~~~~~{.cpp}
+~~~~{.cpp}
class MyPackage_BaseClass
{
Standard_EXPORT virtual Standard_Boolean Perform() Standard_OVERRIDE;
};
-~~~~~
+~~~~
This makes class definition more clear (virtual methods become highlighted).
Declare a cycle variable in the header of the *for()* statement if not used out of cycle.
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Real aMinDist = Precision::Infinite();
for (NCollection_Sequence<gp_Pnt>::Iterator aPntIter (theSequence);
aPntIter.More(); aPntIter.Next())
{
aMinDist = Min (aMinDist, theOrigin.Distance (aPntIter.Value()));
}
-~~~~~
+~~~~
### Condition statements within zero
Avoid usage of C-style comparison for non-boolean variables:
-~~~~~{.cpp}
+~~~~{.cpp}
void Function (Standard_Integer theValue,
Standard_Real* thePointer)
{
DoSome2();
}
}
-~~~~~
+~~~~
@section occt_coding_rules_7 Portability issues
Use the same form of new and delete.
-~~~~~{.cpp}
+~~~~{.cpp}
aPtr1 = new TypeA[n]; ... ; delete[] aPtr1;
aPtr2 = new TypeB(); ... ; delete aPtr2;
aPtr3 = Standard::Allocate (4096); ... ; Standard::Free (aPtr3);
-~~~~~
+~~~~
### Methods managing dynamical allocation [MANDATORY]
Every variable should be initialized.
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer aTmpVar1; // bad
Standard_Integer aTmpVar2 = 0; // OK
-~~~~~
+~~~~
Uninitialized variables might be kept only within performance-sensitive code blocks and only when their initialization is guaranteed by subsequent code.
Don't check floats for equality or non-equality; check for GT, GE, LT or LE.
-~~~~~{.cpp}
+~~~~{.cpp}
if (Abs (theFloat1 - theFloat2) < theTolerance)
{
DoSome();
}
-~~~~~
+~~~~
Package *Precision* provides standard values for SI units and widely adopted by existing modeling algorithms:
List class data members in the constructor's initialization list in the order they are declared.
-~~~~~{.cpp}
+~~~~{.cpp}
class MyPackage_MyClass
{
Standard_Integer myPropertyB;
};
-~~~~~
+~~~~
### Initialization over assignment
Prefer initialization over assignment in class constructors.
-~~~~~{.cpp}
+~~~~{.cpp}
MyPackage_MyClass()
: myPropertyA (1) // preferred
{
myPropertyB = 2; // not recommended
}
-~~~~~
+~~~~
### Optimize caching
On x86 this code
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Real anArray[4096][2];
for (Standard_Integer anIter = 0; anIter < 4096; ++anIter)
{
anArray[anIter][0] = anArray[anIter][1];
}
-~~~~~
+~~~~
is more efficient then
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Real anArray[2][4096];
for (Standard_Integer anIter = 0; anIter < 4096; ++anIter)
{
anArray[0][anIter] = anArray[1][anIter];
}
-~~~~~
+~~~~
since linear access does not invalidate cache too often.
Command should warn the user about unknown arguments, including cases when extra parameters have been pushed for the command with a fixed number of arguments.
-~~~~~{.cpp}
+~~~~{.cpp}
if (theArgsNb != 3)
{
std::cout << "Syntax error - wrong number of arguments!\n";
}
DBRep::Set (aResName, aFaceShape);
return 0;
-~~~~~
+~~~~
### Message printing
Any command with a long list of obligatory parameters should be considered as ill-formed by design.
Optional parameters should start with flag name (with '-' prefix) and followed by its values:
-~~~~~{.tcl}
+~~~~{.php}
myCommand -flag1 value1 value2 -flag2 value3
-~~~~~
+~~~~
### Arguments parser
Functions *Draw::Atof()* and *Draw::Atoi()* support expressions and read values in C-locale.
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Real aPosition[3] = {0.0, 0.0, 0.0};
for (Standard_Integer anArgIter = 1; anArgIter < theArgsNb; ++anArgIter)
{
return 1;
}
}
-~~~~~
+~~~~
@section occt_coding_rules_11 Examples
@endverbatim
-~~~~~
+~~~~{.cpp}
#include <Package_Class.hxx>
// ==========================================================
// function : Square
{
++myCounter;
}
-~~~~~
+~~~~
### TCL script for Draw Harness
-~~~~~{.tcl}
+~~~~{.tcl}
# show fragments (solids) in shading with different colors
proc DisplayColored {theShape} {
set aSolids [uplevel #0 explode $theShape so]
DisplayColored c
vfit
vdump $imagedir/${casename}.png 512 512
-~~~~~
+~~~~
### GLSL program:
-~~~~~{.fs}
+~~~~{.cpp}
vec3 Ambient; //!< Ambient contribution of light sources
vec3 Diffuse; //!< Diffuse contribution of light sources
vec3 Specular; //!< Specular contribution of light sources
normalize (View),
Position);
}
-~~~~~
+~~~~
Make sure to configure Git so that the user name is equal to your username
on the OCCT development portal, and set SafeCrLf option to true:
-~~~~~
+~~~~
> git config --global user.name "Your User Name"
> git config --global user.email your@mail.address
> git config --global your@mail.address
-~~~~~
+~~~~
@section occt_gitguide_3 Getting access to the repository
On Windows, you might need to start **Git Bash** command prompt window.
Use the following command to generate SSH keys:
-~~~~~
+~~~~
> ssh-keygen -t rsa -C "your@mail.address"
-~~~~~
+~~~~
The last argument is an optional comment, which can be included with the public key and used to distinguish between different keys (if you have many). The common practice is to put here your mail address or workstation name.
* From command line by command:
-~~~~~
+~~~~
> git clone gitolite@git.dev.opencascade.org:occt <path>
-~~~~~
+~~~~
where <i>\<path\></i> is the path to the new folder which will be created for the repository.
In the console:
-~~~~~
+~~~~
> git checkout -b CR12345 origin/master
-~~~~~
+~~~~
In TortoiseGit:
* Go to the local copy of the repository.
If you need to switch to another branch, use Git command checkout for that.
In the console:
-~~~~~
+~~~~
> git checkout CR12345
-~~~~~
+~~~~
In TortoiseGit: right-click in the explorer window and select in the context menu **TortoiseGit** -> **Switch/Checkout**.
* In the console:
-~~~~~
+~~~~
> git diff
…
> git commit -a -m "Write meaningful commit message here"
-~~~~~
+~~~~
Option -a tells the command to automatically include (stage) files
that have been modified or deleted, but it will omit the new files that might have been added by you.
To find new unstaged files and them to commit, use commands:
-~~~~~
+~~~~
> git status -s
?? file1.hxx
?? file2.cxx
> git add file1.hxx file2.cxx
-~~~~~
+~~~~
* In TortoiseGit: right-click in the explorer window and select in the context menu <b>Git Commit -> CR…</b>:
* In the console:
-~~~~~
+~~~~
> git push "origin" CR12345:CR12345
-~~~~~
+~~~~
* In TortoiseGit: right-click in the explorer window and select in the context menu, TortoiseGit -> **Push**
Use Git command *fetch* with option *prune* to get the update of all branches from the remote repository and to clean your local repository from the remote branches that have been deleted.
* In the console:
-~~~~~
+~~~~
> git fetch --prune
-~~~~~
+~~~~
* In TortoiseGit: right-click in the explorer window and select in the context menu **TortoiseGit** -> **Fetch**. Check in **Prune** check-box.
This operation is required in particular to update your local master branch when the remote master changes.
* In console:
-~~~~~
+~~~~
> git pull
-~~~~~
+~~~~
* In TortoiseGit: right-click in the explorer window and select in the context menu **TortoiseGit** -> **Pull**.
Remove the local branches that you do not need any more. Note that you cannot delete the current branch. It means that you need to switch to another one (e.g. master) if the branch you are going to delete is the current one.
* In the console:
-~~~~~
+~~~~
> git branch -d CR12345
-~~~~~
+~~~~
* In TortoiseGit: right-click in the explorer window and select in the context menu **TortoiseGit** -> **Git Show Log**.
Example (Windows)
-~~~~~{.tcl}
+~~~~{.php}
set env(CSF_TestDataPath) $env(CSF_TestDataPath)\;d:/occt/test-data
-~~~~~
+~~~~
Note that variable *CSF_TestDataPath* is set to default value at DRAW start, pointing at the folder <i>$CASROOT/data</i>.
In this example, subdirectory <i>d:/occt/test-data</i> is added to this path. Similar code could be used on Linux and Mac OS X except that on non-Windows platforms colon ":" should be used as path separator instead of semicolon ";".
Example:
-~~~~~
+~~~~{.php}
Draw[]> testgrid
-~~~~~
+~~~~
To run only a subset of test cases, give masks for group, grid, and test case names to be executed.
Each argument is a list of file masks separated with commas or spaces; by default "*" is assumed.
Example:
-~~~~~
+~~~~{.php}
Draw[]> testgrid bugs caf,moddata*,xde
-~~~~~
+~~~~
As the tests progress, the result of each test case is reported.
At the end of the log a summary of test cases is output,
Example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
+~~~~{.php}
Tests summary
CASE 3rdparty export A1: OK
Total cases: 208 BAD, 31 SKIPPED, 3 IMPROVEMENT, 1791 OK
Elapsed time: 1 Hours 14 Minutes 33.7384512019 Seconds
Detailed logs are saved in D:/occt/results_2012-06-04T0919
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The tests are considered as non-regressive if only OK, BAD (i.e. known problem), and SKIPPED (i.e. not executed, typically because of lack of a data file) statuses are reported. See @ref testmanual_details_results "Interpretation of test results" for details.
If necessary, a non-default output directory can be specified using option <i> -outdir</i> followed by a path to the directory. This directory should be new or empty; use option <i>-overwrite</i> to allow writing results in the existing non-empty directory.
Example:
-~~~~~
+~~~~{.php}
Draw[]> testgrid -outdir d:/occt/last_results -overwrite
-~~~~~
+~~~~
In the output directory, a cumulative HTML report <i>summary.html</i> provides links to reports on each test case. An additional report in JUnit-style XML format can be output for use in Jenkins or other continuous integration system.
To re-run the test cases, which were detected as regressions on the previous run, option <i>-regress dirname</i> should be used.
<i>dirname</i> is a path to the directory containing the results of the previous run. Only the test cases with *FAILED* and *IMPROVEMENT* statuses will be tested.
Example:
-~~~~~
+~~~~{.php}
Draw[]> testgrid -regress d:/occt/last_results
-~~~~~
+~~~~
Type <i>help testgrid</i> in DRAW prompt to get help on options supported by *testgrid* command:
-~~~~~
+~~~~{.php}
Draw[3]> help testgrid
testgrid: Run all tests, or specified group, or one grid
Use: testgrid [groupmask [gridmask [casemask]]] [options...]
Here "dirname" is a path to the directory containing the results of the previous run.
Groups, grids, and test cases to be executed can be specified by the list of file
masks separated by spaces or commas; default is all (*).
-~~~~~
+~~~~
@subsubsection testmanual_1_3_3 Running a Single Test
Example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
+~~~~{.php}
Draw[1]> test blend simple A1
CASE blend simple A1: OK
Draw[2]>
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Note that normally an intermediate output of the script is not shown. The detailed log of the test can be obtained after the test execution by running command <i>"dlog get"</i>.
Type <i>help test</i> in DRAW prompt to get help on options supported by *test* command:
-~~~~~
+~~~~{.php}
Draw[3]> help test
test: Run specified test case
Use: test group grid casename [options...]
-beep: play sound signal at the end of the test
-errors: show all lines from the log report that are recognized as errors
This key will be ignored if the "-echo" key is already set.
-~~~~~
+~~~~
@subsubsection testmanual_intro_quick_create Creating a New Test
Use prefix <i>bug</i> followed by Mantis issue ID and, if necessary, additional suffixes, for naming the test script, data files, and DRAW commands specific for this test case.
-1. If the test requires C++ code, add it as new DRAW command(s) in one of files in *QABugs* package.
-2. Add script(s) for the test case in the subfolder corresponding to the relevant OCCT module of the group *bugs* <i>($CASROOT/tests/bugs)</i>. See @ref testmanual_5_2 "the correspondence map".
-3. In the test script:
- * Load all necessary DRAW modules by command *pload*.
- * Use command *locate_data_file* to get a path to data files used by test script. (Make sure to have this command not inside catch statement if it is used.)
- * Use DRAW commands to reproduce the tested situation.
- * Make sure that in case of failure the test produces a message containing word "Error" or other recognized by the test system as error (add new error patterns in file parse.rules if necessary).
- * If the test case reports error due to an existing problem and the fix is not available, add @ref testmanual_3_6 "TODO" statement for each error to mark it as a known problem. The TODO statements must be specific so as to match the actually generated messages but not all similar errors.
- * To check expected output which should be obtained as the test result, add @ref testmanual_3_7 "REQUIRED" statement for each line of output to mark it as required.
- * If the test case produces error messages (contained in parse.rules), which are expected in that test and should not be considered as its failure (e.g. test for *checkshape* command), add REQUIRED statement for each error to mark it as required output.
-4. To check whether the data files needed for the test are already present in the database, use DRAW command *testfile* (see below).
+1. If the test requires C++ code, add it as new DRAW command(s) in one of files in *QABugs* package.
+2. Add script(s) for the test case in the subfolder corresponding to the relevant OCCT module of the group *bugs* <i>($CASROOT/tests/bugs)</i>. See @ref testmanual_5_2 "the correspondence map".
+3. In the test script:
+ * Load all necessary DRAW modules by command *pload*.
+ * Use command *locate_data_file* to get a path to data files used by test script. (Make sure to have this command not inside catch statement if it is used.)
+ * Use DRAW commands to reproduce the tested situation.
+ * Make sure that in case of failure the test produces a message containing word "Error" or other recognized by the test system as error (add new error patterns in file parse.rules if necessary).
+ * If the test case reports error due to an existing problem and the fix is not available, add @ref testmanual_3_6 "TODO" statement for each error to mark it as a known problem. The TODO statements must be specific so as to match the actually generated messages but not all similar errors.
+ * To check expected output which should be obtained as the test result, add @ref testmanual_3_7 "REQUIRED" statement for each line of output to mark it as required.
+ * If the test case produces error messages (contained in parse.rules), which are expected in that test and should not be considered as its failure (e.g. test for *checkshape* command), add REQUIRED statement for each error to mark it as required output.
+4. To check whether the data files needed for the test are already present in the database, use DRAW command *testfile* (see below).
If the data file is already present, use it for a new test instead of adding a duplicate.
If the data file(s) are not yet present in the test database, put them to a folder and add it to the environment variable *CSF_TestDataPath* to be found by the test system.
The location of the data files, which need to be accessed by OCC team and put to the official database, should be provided in the comment to Mantis issue, clearly indicating how the names of the files used by the test script match the actual names of the files.
The simplest way is to attach the data files to the Mantis issue, with the same names as used by the test script.
-5. Check that the test case runs as expected (test for fix: OK with the fix, FAILED without the fix; test for existing problem: BAD), and integrate it to the Git branch created for the issue.
+5. Check that the test case runs as expected (test for fix: OK with the fix, FAILED without the fix; test for existing problem: BAD), and integrate it to the Git branch created for the issue.
Example:
* Added files:
-~~~~~
+~~~~{.php}
git status -short
A tests/bugs/heal/data/bug210_a.brep
A tests/bugs/heal/data/bug210_b.brep
A tests/bugs/heal/bug210_1
A tests/bugs/heal/bug210_2
-~~~~~
+~~~~
* Test script
-~~~~~{.tcl}
+~~~~{.php}
puts "OCC210 (case 1): Improve FixShape for touching wires"
restore [locate_data_file bug210_a.brep] a
fixshape result a 0.01 0.01
checkshape result
-~~~~~
+~~~~
DRAW command *testfile* should be used to check the data files used by the test for possible duplication of content or names.
The command accepts the list of paths to files to be checked (as a single argument) and gives a conclusion on each of the files, for instance:
-~~~~~
+~~~~{.php}
Draw[1]> testfile [glob /my/data/path/bug12345*]
Collecting info on test data files repository...
Checking new file(s)...
* /my/data/path/case_8_wire4.brep: error
name is already used by existing file
--> //server/occt_tests_data/public/brep/case_8_wire4.brep
-~~~~~
+~~~~
@section testmanual_2 Organization of Test Scripts
Example:
-~~~~~
+~~~~
caf
mesh
offset
-~~~~~
+~~~~
Test group *bugs* is used to collect the tests coming from bug reports. Group *demo* collects tests of the test system, DRAW, samples, etc.
This test group contains file *grids.list*, which defines an ordered list of grids in this group in the following format:
-~~~~~~~~~~~~~~~~~
+~~~~
001 gridname1
002 gridname2
...
NNN gridnameN
-~~~~~~~~~~~~~~~~~
+~~~~
Example:
-~~~~~~~~~~~~~~~~~
+~~~~
001 basic
002 advanced
-~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection testmanual_2_2_3 File "begin"
Example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
+~~~~{.php}
pload TOPTEST ;# load topological command
set cpulimit 300 ;# set maximum time allowed for script execution
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection testmanual_2_2_4 File "end"
See @ref testmanual_3 "Creation and modification of tests" chapter for more information.
Example:
-~~~~~
+~~~~{.php}
if { [isdraw result] } {
checkshape result
} else {
puts "Error: The result shape can not be built"
}
puts "TEST COMPLETED"
-~~~~~
+~~~~
@subsubsection testmanual_2_2_5 File "parse.rules"
Example:
-~~~~~
+~~~~
FAILED /\b[Ee]xception\b/ exception
FAILED /\bError\b/ error
SKIPPED /Cannot open file for reading/ data file is missing
SKIPPED /Could not read file .*, abandon/ data file is missing
-~~~~~
+~~~~
Lines starting with a *#* character and blank lines are ignored to allow comments and spacing.
Example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
+~~~~
FAILED /\\bFaulty\\b/ bad shape
IGNORE /^Error [23]d = [\d.-]+/ debug output of blend command
IGNORE /^Tcl Exception: tolerance ang : [\d.-]+/ blend failure
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection testmanual_2_2_6 Directory "data"
The test group may contain subdirectory *data*, where test scripts shared by different test grids can be put. See also @ref testmanual_2_3_5 "Directory data".
Example:
-~~~~~
+~~~~
caf
basic
bugs
presentation
-~~~~~
+~~~~
Here *caf* is the name of the test group and *basic*, *bugs*, *presentation*, etc. are the names of grids.
Example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
+~~~~{.php}
set command bopfuse ;# command tested in this grid
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection testmanual_2_3_3 File "end"
Example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
+~~~~{.php}
vdump $imagedir/${casename}.png ;# makes a snap-shot of AIS viewer
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection testmanual_2_3_4 File "cases.list"
Example:
-~~~~~
+~~~~
../data/simple
-~~~~~
+~~~~
This option is used for creation of several grids of tests with the same data files and operations but performed with differing parameters. The common scripts are usually located place in the common
subdirectory of the test group, <i>data/simple</i> for example.
Example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
+~~~~{.php}
pcylinder c1 10 20 ;# create first cylinder
pcylinder c2 5 20 ;# create second cylinder
ttranslate c2 5 0 10 ;# translate second cylinder to x,y,z
bsection result c1 c2 ;# create a section of two cylinders
checksection result ;# will output error message if result is bad
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The test case can have any name (except for the reserved names *begin, end, data, cases.list* and *parse.rules*).
For systematic grids it is usually a capital English letter followed by a number.
Example:
-~~~~~
+~~~~
A1
A2
B1
B2
-~~~~~
+~~~~
Such naming facilitates compact representation of tests execution results in tabular format within HTML reports.
Example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.tcl}
+~~~~
bug12345_coaxial
bug12345_orthogonal_1
bug12345_orthogonal_2
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
If the new test corresponds to a functionality already covered by the existing systematic test grid (e.g. group *mesh* for *BRepMesh* issues), this test can be added (or moved later by OCC team) to that grid.
Usually the script represents a set of commands that a person would run interactively to perform the operation and see its results, with additional comments to explain what happens.
Example:
-~~~~~
+~~~~{.php}
# Simple test of fusing box and sphere
box b 10 10 10
sphere s 5
bfuse result b s
checkshape result
-~~~~~
+~~~~
Make sure that file *parse.rules* in the grid or group directory contains a regular expression to catch possible messages indicating the failure of the test.
For instance, for catching errors reported by *checkshape* command relevant grids define a rule to recognize its report by the word *Faulty*:
-~~~~~
+~~~~
FAILED /\bFaulty\b/ bad shape
-~~~~~
+~~~~
For the messages generated in the script it is recommended to use the word 'Error' in the error message.
Example:
-~~~~~
+~~~~{.php}
set expected_length 11
if { [expr $actual_length - $expected_length] > 0.001 } {
puts "Error: The length of the edge should be $expected_length"
}
-~~~~~
+~~~~
At the end, the test script should output *TEST COMPLETED* string to mark a successful completion of the script. This is often done by the *end* script in the grid.
Example:
-~~~~~
+~~~~{.php}
checkresult $result $::dirname/$::groupname/$::gridname/data/${::casename}.txt
-~~~~~
+~~~~
CAD models and other data files which are not going to change over time should be stored separately from the source repository.
Use Tcl procedure *locate_data_file* to get a path to such data files, instead of coding the path explicitly.
Example:
-~~~~~
+~~~~{.php}
stepread [locate_data_file CAROSKI_COUPELLE.step] a *
-~~~~~
+~~~~
When the test needs to produce some snapshots or other artefacts, use Tcl variable *imagedir* as the location where such files should be put.
* Command *testgrid* sets this variable to the subdirectory of the results folder corresponding to the grid.
The image format (defined by extension) should be *png*.
Example:
-~~~~~
+~~~~{.php}
xwd $::imagedir/${::casename}.png
vdisplay result; vfit
vdump $::imagedir/${::casename}-axo.png
vfront; vfit
vdump $::imagedir/${::casename}-front.png
-~~~~~
+~~~~
would produce:
-~~~~~
+~~~~
A1.png
A1-axo.png
A1-front.png
-~~~~~
+~~~~
Note that OCCT must be built with FreeImage support to be able to produce usable images.
If the test produces an invalid result at a certain moment then the corresponding bug should be created in the OCCT issue tracker located at https://tracker.dev.opencascade.org, and the problem should be marked as TODO in the test script.
The following statement should be added to such a test script:
-~~~~~
+~~~~{.php}
puts "TODO BugNumber ListOfPlatforms: RegularExpression"
-~~~~~
+~~~~
Here:
* *BugNumber* is the bug ID in the tracker. For example: #12345.
* *ListOfPlatforms* is a list of platforms, at which the bug is reproduced (Linux, Windows, MacOS, or All). Note that the platform name is custom for the OCCT test system; Use procedure *checkplatform* to get the platform name.
Example:
-~~~~~
+~~~~{.php}
Draw[2]> checkplatform
Windows
-~~~~~
+~~~~
* RegularExpression is a regular expression, which should be matched against the line indicating the problem in the script output.
Example:
-~~~~~
+~~~~{.php}
puts "TODO #22622 Mandriva2008: Abort .* an exception was raised"
-~~~~~
+~~~~
The parser checks the test output and if an output line matches the *RegularExpression* then it will be assigned a BAD status instead of FAILED.
Example:
-~~~~~
+~~~~{.php}
puts "TODO OCC22817 All: exception.+There are no suitable edges"
puts "TODO OCC22817 All: \\*\\* Exception \\*\\*"
puts "TODO OCC22817 All: TEST INCOMPLETE"
-~~~~~
+~~~~
@subsection testmanual_3_7 Marking required output
To check the obtained test output matches the expected results considered correct, add REQUIRED statement for each specific message.
For that, the following statement should be added to the corresponding test script:
-~~~~~
+~~~~{.php}
puts "REQUIRED ListOfPlatforms: RegularExpression"
-~~~~~
+~~~~
Here *ListOfPlatforms* and *RegularExpression* have the same meaning as in TODO statements described above.
The REQUIRED statement can also be used to mask the message that would normally be interpreted as error (according to the rules defined in *parse.rules*) but should not be considered as such within the current test.
Example:
-~~~~~
+~~~~{.php}
puts "REQUIRED Linux: Faulty shapes in variables faulty_1 to faulty_5"
-~~~~~
+~~~~
This statement notifies test system that errors reported by *checkshape* command are expected in that test case, and test should be considered as OK if this message appears, despite of presence of general rule stating that 'Faulty' signals failure.
For example, let us assume that *d:/occt* contains an up-to-date version of OCCT sources with tests, and the test data archive is unpacked to *d:/test-data*):
-~~~~~
+~~~~{.php}
set env(CASROOT) d:/occt
set env(CSF_TestScriptsPath) $env(CASROOT)/tests
source $env(CASROOT)/src/DrawResources/TestCommands.tcl
set env(CSF_TestDataPath) $env(CASROOT)/data;d:/test-data
return
-~~~~~
+~~~~
Note that on older versions of OCCT the tests are run in compatibility mode and thus not all output of the test command can be captured; this can lead to absence of some error messages (can be reported as either a failure or an improvement).
Use Tcl command <i>_path_separator</i> to insert a platform-dependent separator to the path list.
For example:
-~~~~~
+~~~~{.php}
set env(CSF_TestScriptsPath) \
$env(TestScriptsPath)[_path_separator]d:/MyOCCTProject/tests
set env(CSF_TestDataPath) \
d:/occt/test-data[_path_separator]d:/MyOCCTProject/data
return ;# this is to avoid an echo of the last command above in cout
-~~~~~
+~~~~
@subsection testmanual_4_3 Parallel execution of tests
OCCT test system provides a dedicated command *testdiff* for comparing CPU time of execution, memory usage, and images produced by the tests.
-~~~~~
+~~~~{.php}
testdiff dir1 dir2 [groupname [gridname]] [options...]
-~~~~~
+~~~~
Here *dir1* and *dir2* are directories containing logs of two test runs.
Possible options are:
* <i>-save \<filename\> </i> -- saves the resulting log in a specified file (<i>$dir1/diff-$dir2.log</i> by default). HTML log is saved with the same name and extension .html;
* <i>-status {same|ok|all}</i> -- allows filtering compared cases by their status:
- * *same* -- only cases with same status are compared (default);
- * *ok* -- only cases with OK status in both logs are compared;
- * *all* -- results are compared regardless of status;
+ * *same* -- only cases with same status are compared (default);
+ * *ok* -- only cases with OK status in both logs are compared;
+ * *all* -- results are compared regardless of status;
* <i>-verbose \<level\> </i> -- defines the scope of output data:
- * 1 -- outputs only differences;
- * 2 -- additionally outputs the list of logs and directories present in one of directories only;
- * 3 -- (by default) additionally outputs progress messages;
+ * 1 -- outputs only differences;
+ * 2 -- additionally outputs the list of logs and directories present in one of directories only;
+ * 3 -- (by default) additionally outputs progress messages;
* <i>-image [filename]</i> - compare images and save the resulting log in specified file (<i>$dir1/diffimage-$dir2.log</i> by default)
* <i>-cpu [filename]</i> - compare overall CPU and save the resulting log in specified file (<i>$dir1/diffcpu-$dir2.log</i> by default)
* <i>-memory [filename]</i> - compare memory delta and save the resulting log in specified file (<i>$dir1/diffmemory-$dir2.log</i> by default)
Example:
-~~~~~
+~~~~{.php}
Draw[]> testdiff results/CR12345-2012-10-10T08:00 results/master-2012-10-09T21:20
-~~~~~
+~~~~
Particular tests can generate additional data that need to be compared by *testdiff* command.
For that, for each parameter to be controlled, the test should produce the line containing keyword "COUNTER* followed by arbitrary name of the parameter, then colon and numeric value of the parameter.
Example of test code:
-~~~~~
+~~~~{.php}
puts "COUNTER Memory heap usage at step 5: [meminfo h]"
-~~~~~
+~~~~
@section testmanual_5 APPENDIX
DRAW module: VISUALIZATION.
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| export | vexport | export of images to different formats |
-| fonts | vtrihedron, vcolorscale, vdrawtext | display of fonts |
+| export | vexport | export of images to different formats |
+| fonts | vtrihedron, vcolorscale, vdrawtext | display of fonts |
@subsubsection testmanual_5_1_2 blend
DRAW module: MODELING.
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| simple | blend | fillets on simple shapes |
-| complex | blend | fillets on complex shapes, non-trivial geometry |
-| tolblend_simple | tolblend, blend | |
-| buildevol | buildevol | |
-| tolblend_buildvol | tolblend, buildevol | use of additional command tolblend |
-| bfuseblend | bfuseblend | |
-| encoderegularity | encoderegularity | |
+| simple | blend | fillets on simple shapes |
+| complex | blend | fillets on complex shapes, non-trivial geometry |
+| tolblend_simple | tolblend, blend | |
+| buildevol | buildevol | |
+| tolblend_buildvol | tolblend, buildevol | use of additional command tolblend |
+| bfuseblend | bfuseblend | |
+| encoderegularity | encoderegularity | |
@subsubsection testmanual_5_1_3 boolean
* <i>_simple</i> -- for tests operating on simple shapes (boxes, cylinders, toruses, etc.);
* <i>_complex</i> -- for tests dealing with complex shapes.
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| bcommon_2d | bcommon | Common operation (old algorithm), 2d |
-| bcommon_complex | bcommon | Common operation (old algorithm), complex shapes |
-| bcommon_simple | bcommon | Common operation (old algorithm), simple shapes |
-| bcut_2d | bcut | Cut operation (old algorithm), 2d |
-| bcut_complex | bcut | Cut operation (old algorithm), complex shapes |
-| bcut_simple | bcut | Cut operation (old algorithm), simple shapes |
-| bcutblend | bcutblend | |
-| bfuse_2d | bfuse | Fuse operation (old algorithm), 2d |
-| bfuse_complex | bfuse | Fuse operation (old algorithm), complex shapes |
-| bfuse_simple | bfuse | Fuse operation (old algorithm), simple shapes |
-| bopcommon_2d | bopcommon | Common operation, 2d |
-| bopcommon_complex | bopcommon | Common operation, complex shapes |
-| bopcommon_simple | bopcommon | Common operation, simple shapes |
-| bopcut_2d | bopcut | Cut operation, 2d |
-| bopcut_complex | bopcut | Cut operation, complex shapes |
-| bopcut_simple | bopcut | Cut operation, simple shapes |
-| bopfuse_2d | bopfuse | Fuse operation, 2d |
-| bopfuse_complex | bopfuse | Fuse operation, complex shapes |
-| bopfuse_simple | bopfuse | Fuse operation, simple shapes |
-| bopsection | bopsection | Section |
-| boptuc_2d | boptuc | |
-| boptuc_complex | boptuc | |
-| boptuc_simple | boptuc | |
-| bsection | bsection | Section (old algorithm) |
+| bcommon_2d | bcommon | Common operation (old algorithm), 2d |
+| bcommon_complex | bcommon | Common operation (old algorithm), complex shapes |
+| bcommon_simple | bcommon | Common operation (old algorithm), simple shapes |
+| bcut_2d | bcut | Cut operation (old algorithm), 2d |
+| bcut_complex | bcut | Cut operation (old algorithm), complex shapes |
+| bcut_simple | bcut | Cut operation (old algorithm), simple shapes |
+| bcutblend | bcutblend | |
+| bfuse_2d | bfuse | Fuse operation (old algorithm), 2d |
+| bfuse_complex | bfuse | Fuse operation (old algorithm), complex shapes |
+| bfuse_simple | bfuse | Fuse operation (old algorithm), simple shapes |
+| bopcommon_2d | bopcommon | Common operation, 2d |
+| bopcommon_complex | bopcommon | Common operation, complex shapes |
+| bopcommon_simple | bopcommon | Common operation, simple shapes |
+| bopcut_2d | bopcut | Cut operation, 2d |
+| bopcut_complex | bopcut | Cut operation, complex shapes |
+| bopcut_simple | bopcut | Cut operation, simple shapes |
+| bopfuse_2d | bopfuse | Fuse operation, 2d |
+| bopfuse_complex | bopfuse | Fuse operation, complex shapes |
+| bopfuse_simple | bopfuse | Fuse operation, simple shapes |
+| bopsection | bopsection | Section |
+| boptuc_2d | boptuc | |
+| boptuc_complex | boptuc | |
+| boptuc_simple | boptuc | |
+| bsection | bsection | Section (old algorithm) |
@subsubsection testmanual_5_1_4 bugs
DRAW module: OCAFKERNEL.
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| basic | | Basic attributes |
-| bugs | | Saving and restoring of document |
-| driver | | OCAF drivers |
-| named_shape | | *TNaming_NamedShape* attribute |
-| presentation | | *AISPresentation* attributes |
-| tree | | Tree construction attributes |
-| xlink | | XLink attributes |
+| basic | | Basic attributes |
+| bugs | | Saving and restoring of document |
+| driver | | OCAF drivers |
+| named_shape | | *TNaming_NamedShape* attribute |
+| presentation | | *AISPresentation* attributes |
+| tree | | Tree construction attributes |
+| xlink | | XLink attributes |
@subsubsection testmanual_5_1_6 chamfer
The test grid name is constructed depending on the type of the tested chamfers. Additional suffix <i>_complex</i> is used for test cases involving complex geometry (e.g. intersections of edges forming a chamfer); suffix <i>_sequence</i> is used for grids where chamfers are computed sequentially.
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| equal_dist | | Equal distances from edge |
-| equal_dist_complex | | Equal distances from edge, complex shapes |
-| equal_dist_sequence | | Equal distances from edge, sequential operations |
-| dist_dist | | Two distances from edge |
-| dist_dist_complex | | Two distances from edge, complex shapes |
-| dist_dist_sequence | | Two distances from edge, sequential operations |
-| dist_angle | | Distance from edge and given angle |
-| dist_angle_complex | | Distance from edge and given angle |
-| dist_angle_sequence | | Distance from edge and given angle |
+| equal_dist | | Equal distances from edge |
+| equal_dist_complex | | Equal distances from edge, complex shapes |
+| equal_dist_sequence | | Equal distances from edge, sequential operations |
+| dist_dist | | Two distances from edge |
+| dist_dist_complex | | Two distances from edge, complex shapes |
+| dist_dist_sequence | | Two distances from edge, sequential operations |
+| dist_angle | | Distance from edge and given angle |
+| dist_angle_complex | | Distance from edge and given angle |
+| dist_angle_sequence | | Distance from edge and given angle |
@subsubsection testmanual_5_1_7 de
Test cases check transfer status, shape and attributes against expected reference values.
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
| iges_1, iges_2, iges_3 | igesbrep, brepiges, ReadIges, WriteIges | IGES tests |
| step_1, step_2, step_3, step_4, step_5 | stepread, stepwrite, ReadStep, WriteStep | STEP tests |
This group allows demonstrating how testing cases are created, and testing DRAW commands and the test system as a whole.
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| draw | getsource, restore | Basic DRAW commands |
-| testsystem | | Testing system |
-| samples | | OCCT samples |
+| draw | getsource, restore | Basic DRAW commands |
+| testsystem | | Testing system |
+| samples | | OCCT samples |
@subsubsection testmanual_5_1_9 draft
DRAW module: MODELING.
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| Angle | depouille | Drafts with angle (inclined walls) |
+| Angle | depouille | Drafts with angle (inclined walls) |
@subsubsection testmanual_5_1_10 feat
DRAW module: MODELING (package *BRepTest*).
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| featdprism | | |
-| featlf | | |
-| featprism | | |
-| featrevol | | |
-| featrf | | |
+| featdprism | | |
+| featlf | | |
+| featprism | | |
+| featrevol | | |
+| featrf | | |
@subsubsection testmanual_5_1_11 heal
DRAW module: XSDRAW
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| fix_shape | fixshape | Shape healing |
-| fix_gaps | fixwgaps | Fixing gaps between edges on a wire |
-| same_parameter | sameparameter | Fixing non-sameparameter edges |
-| same_parameter_locked | sameparameter | Fixing non-sameparameter edges |
-| fix_face_size | DT_ApplySeq | Removal of small faces |
-| elementary_to_revolution | DT_ApplySeq | Conversion of elementary surfaces to revolution |
-| direct_faces | directfaces | Correction of axis of elementary surfaces |
-| drop_small_edges | fixsmall | Removal of small edges |
-| split_angle | DT_SplitAngle | Splitting periodic surfaces by angle |
-| split_angle_advanced | DT_SplitAngle | Splitting periodic surfaces by angle |
-| split_angle_standard | DT_SplitAngle | Splitting periodic surfaces by angle |
-| split_closed_faces | DT_ClosedSplit | Splitting of closed faces |
-| surface_to_bspline | DT_ToBspl | Conversion of surfaces to b-splines |
-| surface_to_bezier | DT_ShapeConvert | Conversion of surfaces to bezier |
-| split_continuity | DT_ShapeDivide | Split surfaces by continuity criterion |
+| fix_shape | fixshape | Shape healing |
+| fix_gaps | fixwgaps | Fixing gaps between edges on a wire |
+| same_parameter | sameparameter | Fixing non-sameparameter edges |
+| same_parameter_locked | sameparameter | Fixing non-sameparameter edges |
+| fix_face_size | DT_ApplySeq | Removal of small faces |
+| elementary_to_revolution | DT_ApplySeq | Conversion of elementary surfaces to revolution |
+| direct_faces | directfaces | Correction of axis of elementary surfaces |
+| drop_small_edges | fixsmall | Removal of small edges |
+| split_angle | DT_SplitAngle | Splitting periodic surfaces by angle |
+| split_angle_advanced | DT_SplitAngle | Splitting periodic surfaces by angle |
+| split_angle_standard | DT_SplitAngle | Splitting periodic surfaces by angle |
+| split_closed_faces | DT_ClosedSplit | Splitting of closed faces |
+| surface_to_bspline | DT_ToBspl | Conversion of surfaces to b-splines |
+| surface_to_bezier | DT_ShapeConvert | Conversion of surfaces to bezier |
+| split_continuity | DT_ShapeDivide | Split surfaces by continuity criterion |
| split_continuity_advanced | DT_ShapeDivide | Split surfaces by continuity criterion |
| split_continuity_standard | DT_ShapeDivide | Split surfaces by continuity criterion |
-| surface_to_revolution_advanced | DT_ShapeConvertRev | Convert elementary surfaces to revolutions, complex cases |
-| surface_to_revolution_standard | DT_ShapeConvertRev | Convert elementary surfaces to revolutions, simple cases |
-| update_tolerance_locked | updatetolerance | Update the tolerance of shape so that it satisfy the rule: toler(face)<=toler(edge)<=toler(vertex) |
+| surface_to_revolution_advanced | DT_ShapeConvertRev | Convert elementary surfaces to revolutions, complex cases |
+| surface_to_revolution_standard | DT_ShapeConvertRev | Convert elementary surfaces to revolutions, simple cases |
+| update_tolerance_locked | updatetolerance | Update the tolerance of shape so that it satisfy the rule: toler(face)<=toler(edge)<=toler(vertex) |
@subsubsection testmanual_5_1_12 mesh
DRAW modules: MODELING (package *MeshTest*), VISUALIZATION (package *ViewerTest*)
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| advanced_shading | vdisplay | Shading, complex shapes |
-| standard_shading | vdisplay | Shading, simple shapes |
-| advanced_mesh | mesh | Meshing of complex shapes |
-| standard_mesh | mesh | Meshing of simple shapes |
-| advanced_incmesh | incmesh | Meshing of complex shapes |
-| standard_incmesh | incmesh | Meshing of simple shapes |
+| advanced_shading | vdisplay | Shading, complex shapes |
+| standard_shading | vdisplay | Shading, simple shapes |
+| advanced_mesh | mesh | Meshing of complex shapes |
+| standard_mesh | mesh | Meshing of simple shapes |
+| advanced_incmesh | incmesh | Meshing of complex shapes |
+| standard_incmesh | incmesh | Meshing of simple shapes |
| advanced_incmesh_parallel | incmesh | Meshing of complex shapes, parallel mode |
| standard_incmesh_parallel | incmesh | Meshing of simple shapes, parallel mode |
DRAW module: MODELING (package *BRepTest*)
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| after_trim | mkface | |
-| after_offset | mkface | |
-| after_extsurf_and_offset | mkface | |
-| after_extsurf_and_trim | mkface | |
-| after_revsurf_and_offset | mkface | |
-| mkplane | mkplane | |
+| after_trim | mkface | |
+| after_offset | mkface | |
+| after_extsurf_and_offset | mkface | |
+| after_extsurf_and_trim | mkface | |
+| after_revsurf_and_offset | mkface | |
+| mkplane | mkplane | |
@subsubsection testmanual_5_1_14 nproject
DRAW module: MODELING (package *BRepTest*)
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| Base | nproject | |
+| Base | nproject | |
@subsubsection testmanual_5_1_15 offset
DRAW module: MODELING (package *BRepTest*)
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| compshape | offsetcompshape | Offset of shapes with removal of some faces |
-| faces_type_a | offsetparameter, offsetload, offsetperform | Offset on a subset of faces with a fillet |
-| faces_type_i | offsetparameter, offsetload, offsetperform | Offset on a subset of faces with a sharp edge |
-| shape_type_a | offsetparameter, offsetload, offsetperform | Offset on a whole shape with a fillet |
-| shape_type_i | offsetparameter, offsetload, offsetperform | Offset on a whole shape with a fillet |
-| shape | offsetshape | |
-| wire_closed_outside_0_005, wire_closed_outside_0_025, wire_closed_outside_0_075, wire_closed_inside_0_005, wire_closed_inside_0_025, wire_closed_inside_0_075, wire_unclosed_outside_0_005, wire_unclosed_outside_0_025, wire_unclosed_outside_0_075 | mkoffset | 2d offset of closed and unclosed planar wires with different offset step and directions of offset ( inside / outside ) |
-
+| compshape | offsetcompshape | Offset of shapes with removal of some faces |
+| faces_type_a | offsetparameter, offsetload, offsetperform | Offset on a subset of faces with a fillet |
+| faces_type_i | offsetparameter, offsetload, offsetperform | Offset on a subset of faces with a sharp edge |
+| shape_type_a | offsetparameter, offsetload, offsetperform | Offset on a whole shape with a fillet |
+| shape_type_i | offsetparameter, offsetload, offsetperform | Offset on a whole shape with a fillet |
+| shape | offsetshape | |
+| wire_closed_outside_0_005, wire_closed_outside_0_025, wire_closed_outside_0_075, wire_closed_inside_0_005, wire_closed_inside_0_025, wire_closed_inside_0_075, wire_unclosed_outside_0_005, wire_unclosed_outside_0_025, wire_unclosed_outside_0_075 | mkoffset | 2d offset of closed and unclosed planar wires with different offset step and directions of offset ( inside / outside ) |
+
@subsubsection testmanual_5_1_16 pipe
This group allows testing construction of pipes (sweeping of a contour along profile).
DRAW module: MODELING (package *BRepTest*)
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| Standard | pipe | |
+| Standard | pipe | |
@subsubsection testmanual_5_1_17 prism
DRAW module: MODELING (package *BRepTest*)
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| seminf | prism | |
+| seminf | prism | |
@subsubsection testmanual_5_1_18 sewing
DRAW module: MODELING (package *BRepTest*)
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| tol_0_01 | sewing | Sewing faces with tolerance 0.01 |
-| tol_1 | sewing | Sewing faces with tolerance 1 |
+| tol_0_01 | sewing | Sewing faces with tolerance 0.01 |
+| tol_1 | sewing | Sewing faces with tolerance 1 |
| tol_100 | sewing | Sewing faces with tolerance 100 |
@subsubsection testmanual_5_1_19 thrusection
This group allows testing construction of shell or a solid passing through a set of sections in a given sequence (loft).
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| solids | thrusection | Lofting with resulting solid |
-| not_solids | thrusection | Lofting with resulting shell or face |
+| solids | thrusection | Lofting with resulting solid |
+| not_solids | thrusection | Lofting with resulting shell or face |
@subsubsection testmanual_5_1_20 xcaf
This group allows testing extended data exchange packages.
-| Grid | Commands | Functionality |
+| Grid | Commands | Functionality |
| :---- | :----- | :------- |
-| dxc, dxc_add_ACL, dxc_add_CL, igs_to_dxc, igs_add_ACL, brep_to_igs_add_CL, stp_to_dxc, stp_add_ACL, brep_to_stp_add_CL, brep_to_dxc, add_ACL_brep, brep_add_CL | | Subgroups are divided by format of source file, by format of result file and by type of document modification. For example, *brep_to_igs* means that the source shape in brep format was added to the document, which was saved into igs format after that. The postfix *add_CL* means that colors and layers were initialized in the document before saving and the postfix *add_ACL* corresponds to the creation of assembly and initialization of colors and layers in a document before saving. |
-
+| dxc, dxc_add_ACL, dxc_add_CL, igs_to_dxc, igs_add_ACL, brep_to_igs_add_CL, stp_to_dxc, stp_add_ACL, brep_to_stp_add_CL, brep_to_dxc, add_ACL_brep, brep_add_CL | | Subgroups are divided by format of source file, by format of result file and by type of document modification. For example, *brep_to_igs* means that the source shape in brep format was added to the document, which was saved into igs format after that. The postfix *add_CL* means that colors and layers were initialized in the document before saving and the postfix *add_ACL* corresponds to the creation of assembly and initialization of colors and layers in a document before saving. |
+
@subsection testmanual_5_2 Mapping of OCCT functionality to grid names in group *bugs*
-| OCCT Module / Mantis category | Toolkits | Test grid in group bugs |
+| OCCT Module / Mantis category | Toolkits | Test grid in group bugs |
| :---------- | :--------- | :---------- |
-| Application Framework | PTKernel, TKPShape, TKCDF, TKLCAF, TKCAF, TKBinL, TKXmlL, TKShapeSchema, TKPLCAF, TKBin, TKXml, TKPCAF, FWOSPlugin, TKStdLSchema, TKStdSchema, TKTObj, TKBinTObj, TKXmlTObj | caf |
-| Draw | TKDraw, TKTopTest, TKViewerTest, TKXSDRAW, TKDCAF, TKXDEDRAW, TKTObjDRAW, TKQADraw, DRAWEXE, Problems of testing system | draw |
+| Application Framework | PTKernel, TKPShape, TKCDF, TKLCAF, TKCAF, TKBinL, TKXmlL, TKShapeSchema, TKPLCAF, TKBin, TKXml, TKPCAF, FWOSPlugin, TKStdLSchema, TKStdSchema, TKTObj, TKBinTObj, TKXmlTObj | caf |
+| Draw | TKDraw, TKTopTest, TKViewerTest, TKXSDRAW, TKDCAF, TKXDEDRAW, TKTObjDRAW, TKQADraw, DRAWEXE, Problems of testing system | draw |
| Shape Healing | TKShHealing | heal |
-| Mesh | TKMesh, TKXMesh | mesh |
-| Data Exchange | TKIGES | iges |
-| Data Exchange | TKSTEPBase, TKSTEPAttr, TKSTEP209, TKSTEP | step |
-| Data Exchange | TKSTL, TKVRML | stlvrml |
-| Data Exchange | TKXSBase, TKXCAF, TKXCAFSchema, TKXDEIGES, TKXDESTEP, TKXmlXCAF, TKBinXCAF | xde |
-| Foundation Classes | TKernel, TKMath | fclasses |
-| Modeling_algorithms | TKGeomAlgo, TKTopAlgo, TKPrim, TKBO, TKBool, TKHLR, TKFillet, TKOffset, TKFeat, TKXMesh | modalg |
-| Modeling Data | TKG2d, TKG3d, TKGeomBase, TKBRep | moddata |
-| Visualization | TKService, TKV2d, TKV3d, TKOpenGl, TKMeshVS, TKNIS | vis |
+| Mesh | TKMesh, TKXMesh | mesh |
+| Data Exchange | TKIGES | iges |
+| Data Exchange | TKSTEPBase, TKSTEPAttr, TKSTEP209, TKSTEP | step |
+| Data Exchange | TKSTL, TKVRML | stlvrml |
+| Data Exchange | TKXSBase, TKXCAF, TKXCAFSchema, TKXDEIGES, TKXDESTEP, TKXmlXCAF, TKBinXCAF | xde |
+| Foundation Classes | TKernel, TKMath | fclasses |
+| Modeling_algorithms | TKGeomAlgo, TKTopAlgo, TKPrim, TKBO, TKBool, TKHLR, TKFillet, TKOffset, TKFeat, TKXMesh | modalg |
+| Modeling Data | TKG2d, TKG3d, TKGeomBase, TKBRep | moddata |
+| Visualization | TKService, TKV2d, TKV3d, TKOpenGl, TKMeshVS, TKNIS | vis |
@subsection testmanual_5_3 Recommended approaches to checking test results
Run command *checkshape* on the result (or intermediate) shape and make sure that *parse.rules* of the test grid or group reports bad shapes (usually recognized by word "Faulty") as error.
Example
-~~~~~
+~~~~{.php}
checkshape result
-~~~~~
+~~~~
To check the number of faults in the shape command *checkfaults* can be used.
Use: checkfaults shape source_shape [ref_value=0]
The default syntax of *checkfaults* command:
-~~~~~
+~~~~{.php}
checkfaults results a_1
-~~~~~
+~~~~
The command will check the number of faults in the source shape (*a_1*) and compare it
with number of faults in the resulting shape (*result*). If shape *result* contains
more faults, you will get an error:
-~~~~~
+~~~~{.php}
checkfaults results a_1
Error : Number of faults is 5
-~~~~~
+~~~~
It is possible to set the reference value for comparison (reference value is 4):
-~~~~~
+~~~~{.php}
checkfaults results a_1 4
-~~~~~
+~~~~
If number of faults in the resulting shape is unstable, reference value should be set to "-1".
As a result command *checkfaults* will return the following error:
-~~~~~
+~~~~{.php}
checkfaults results a_1 -1
Error : Number of faults is UNSTABLE
-~~~~~
+~~~~
@subsubsection testmanual_5_3_2 Shape tolerance
The maximal tolerance of sub-shapes of each kind of the resulting shape can be extracted from output of tolerance command as follows:
-~~~~~
+~~~~{.php}
set tolerance [tolerance result]
regexp { *FACE +: +MAX=([-0-9.+eE]+)} $tolerance dummy max_face
regexp { *EDGE +: +MAX=([-0-9.+eE]+)} $tolerance dummy max_edgee
regexp { *VERTEX +: +MAX=([-0-9.+eE]+)} $tolerance dummy max_vertex
-~~~~~
+~~~~
It is possible to use command *checkmaxtol* to check maximal tolerance of shape and compare it with reference value.
* <i>-multi_tol</i> -- tolerance multiplier.
The default syntax of *checkmaxtol* command for comparison with the reference value:
-~~~~~
+~~~~{.php}
checkmaxtol result -ref 0.00001
-~~~~~
+~~~~
There is an opportunity to compare max tolerance of resulting shape with max tolerance of source shape.
In the following example command *checkmaxtol* gets max tolerance among objects *a_1* and *a_2*.
Then it chooses the maximum value between founded tolerance and value -min_tol (0.000001)
and multiply it on the coefficient -multi_tol (i.e. 2):
-~~~~~
+~~~~{.php}
checkmaxtol result -source {a_1 a_2} -min_tol 0.000001 -multi_tol 2
-~~~~~
+~~~~
If the value of maximum tolerance more than founded tolerance for comparison, the command will return an error.
Also, command *checkmaxtol* can be used to get max tolerance of the shape:
-~~~~~
+~~~~{.php}
set maxtol [checkmaxtol result]
-~~~~~
+~~~~
@subsubsection testmanual_5_3_3 Shape volume, area, or length
Use command *vprops, sprops,* or *lprops* to correspondingly measure volume, area, or length of the shape produced by the test. The value can be extracted from the result of the command by *regexp*.
Example:
-~~~~~
+~~~~{.php}
# check area of shape result with 1% tolerance
regexp {Mass +: +([-0-9.+eE]+)} [sprops result] dummy area
if { abs($area - $expected) > 0.1 + 0.01 * abs ($area) } {
puts "Error: The area of result shape is $area, while expected $expected"
}
-~~~~~
+~~~~
@subsubsection testmanual_5_3_4 Memory leaks
The command *checktrend* (defined in *tests/bugs/begin*) can be used to analyze a sequence of memory measurements and to get a statistically based evaluation of the leak presence.
Example:
-~~~~~
+~~~~{.php}
set listmem {}
for {set i 1} {$i < 100} {incr i} {
# run suspect operation
break
}
}
-~~~~~
+~~~~
@subsubsection testmanual_5_3_5 Visualization
The following command sequence allows you to take a snapshot of the viewer, give it the name of the test case, and save in the directory indicated by Tcl variable *imagedir*.
-~~~~~
+~~~~{.php}
vinit
vclear
vdisplay result
vfit
vzfit
vdump $imagedir/${casename}_shading.png
-~~~~~
+~~~~
This image will be included in the HTML log produced by *testgrid* command and will be checked for non-regression through comparison of images by command *testdiff*.
* <i>-vdispmode N</i> -- sets *vdispmode* for 3d viewer (default value is 1)
* <i>-screenshot</i> -- makes a screenshot of already created viewer
* The procedure can check a property of shape (length, area or volume) and compare it with value *N*:
- * <i>-l [N]</i>
- * <i>-s [N]</i>
- * <i>-v [N]</i>
- * If the current property is equal to value *N*, the shape is marked as valid in the procedure.
- * If value *N* is not given, the procedure will mark the shape as valid if the current property is non-zero.
+ * <i>-l [N]</i>
+ * <i>-s [N]</i>
+ * <i>-v [N]</i>
+ * If the current property is equal to value *N*, the shape is marked as valid in the procedure.
+ * If value *N* is not given, the procedure will mark the shape as valid if the current property is non-zero.
* <i>-with {a b c}</i> -- displays shapes *a, b* and *c* together with the shape (if the shape is valid)
* <i>-otherwise {d e f}</i> -- displays shapes *d, e* and *f* instead of the shape (if the shape is NOT valid)
Note that is required to use either option <i> -2d </i> or option <i> -3d</i>.
Examples:
-~~~~~
+~~~~{.php}
checkview -display result -2d -path ${imagedir}/${test_image}.png
checkview -display result -3d -path ${imagedir}/${test_image}.png
checkview -display result_2d -2d v2d -path ${imagedir}/${test_image}.png
-~~~~~
+~~~~
-~~~~~
+~~~~{.php}
box a 10 10 10
box b 5 5 5 10 10 10
bcut result b a
set result_vertices [explode result v]
checkview -display result -2d -with ${result_vertices} -otherwise { a b } -l -path ${imagedir}/${test_image}.png
-~~~~~
+~~~~
-~~~~~
+~~~~{.php}
box a 10 10 10
box b 5 5 5 10 10 10
bcut result b a
vdisplay a b
vfit
checkview -screenshot -3d -path ${imagedir}/${test_image}.png
-~~~~~
+~~~~
@subsubsection testmanual_5_3_6 Number of free edges
* <i>-tol N</i> -- used tolerance (default -0.01);
* <i>-type N</i> -- used type, possible values are "closed" and "opened" (default "closed").
-~~~~~
+~~~~{.php}
checkfreebounds result 13
-~~~~~
+~~~~
Option <i>-tol N</i> defines tolerance for command *freebounds*, which is used within command *checkfreebounds*.
If the number of free edges in the resulting shape is unstable, the reference value should be set to "-1".
As a result command *checkfreebounds* will return the following error:
-~~~~~
+~~~~{.php}
checkfreebounds result -1
Error : Number of free edges is UNSTABLE
-~~~~~
+~~~~
@subsubsection testmanual_5_3_7 Compare numbers
Use: checkreal name value expected tol_abs tol_rel
-~~~~~
+~~~~{.php}
checkreal "Some important value" $value 5 0.0001 0.01
-~~~~~
+~~~~
@subsubsection testmanual_5_3_8 Check number of sub-shapes
the same sub-shapes with different location as different sub-shapes.
* <i>-m msg</i> -- prints "msg" in case of error
-~~~~~
+~~~~{.php}
checknbshapes result -vertex 8 -edge 4
-~~~~~
+~~~~
@subsubsection testmanual_5_3_9 Check pixel color
Next example will compare color of point with coordinates x=100 y=100 with RGB color R=1 G=0 B=0.
If colors are not equal, procedure will check the nearest ones points (5x5 area)
-~~~~~
+~~~~{.php}
checkcolor 100 100 1 0 0
-~~~~~
+~~~~
@subsubsection testmanual_5_3_10 Compute length, area and volume of input shape
Options <i> -l, -s </i> and <i> -v</i> are independent and can be used in any order. Tolerance *epsilon* is the same for all options.
-~~~~~
+~~~~{.php}
checkprops result -s 6265.68
checkprops result -s -equal FaceBrep
-~~~~~
+~~~~
@subsubsection testmanual_5_3_11 Parse output dump and compare it with reference values
* <i>-ref VALUE</i> -- list of reference values for each parameter in *NAME*;
* <i>-eps EPSILON</i> -- the epsilon defines relative precision of computation.
-~~~~~
+~~~~{.php}
checkdump result -name {Center Axis XAxis YAxis Radii} -ref {{-70 0} {-1 -0} {-1 -0} {0 -1} {20 10}} -eps 0.01
-~~~~~
+~~~~
@subsubsection testmanual_5_3_12 Compute length of input curve
* <i>-equal CURVE</i> -- compares the length of input curves. Puts error if they are not equal;
* <i>-notequal CURVE</i> -- compares the length of input curves. Puts error if they are equal.
-~~~~~
+~~~~{.php}
checklength cp1 -l 7.278
checklength res -l -equal ext_1
-~~~~~
+~~~~
@subsubsection testmanual_5_3_13 Check maximum deflection, number of triangles and nodes in mesh
Command *checktrinfo* can be used to to check the maximum deflection, as well as the number of nodes and triangles in mesh.
Examples:
Comparison with some reference values:
-~~~~~
+~~~~{.php}
checktrinfo result -tri 129 -nod 131 -defl 0.01
-~~~~~
+~~~~
Comparison with another mesh:
-~~~~~
+~~~~{.php}
checktrinfo result -ref [tringo a]
-~~~~~
+~~~~
Comparison of deflection with the max possible value:
-~~~~~
+~~~~{.php}
checktrinfo result -max_defl 1
-~~~~~
+~~~~
Check that the current values are not equal to zero:
-~~~~~
+~~~~{.php}
checktrinfo result -tri -nod -defl
-~~~~~
+~~~~
Check that the number of triangles and the number of nodes are not equal to some specific values:
-~~~~~
+~~~~{.php}
checktrinfo result -tri !10 -nod !8
-~~~~~
+~~~~
It is possible to compare current values with reference values with some tolerances.
Use options <i>-tol_\* </i> for that.
-~~~~~
+~~~~{.php}
checktrinfo result -defl 1 -tol_abs_defl 0.001
-~~~~~
+~~~~
In some cases the objects to be inspected are available in DRAW as results of DRAW commands. In other cases, however, it is necessary to inspect intermediate objects created by the debugged algorithm. To support this, DRAW provides a set of commands allowing the developer to store intermediate objects directly from the debugger stopped at some point during the program execution (usually at a breakpoint).
-~~~~~
+~~~~{.php}
const char* Draw_Eval (const char *theCommandStr)
-~~~~~
+~~~~
Evaluates a DRAW command or script.
A command is passed as a string parameter.
-~~~~~
+~~~~{.php}
const char* DBRep_Set (const char* theNameStr, void* theShapePtr)
-~~~~~
+~~~~
Sets the specified shape as a value of DRAW interpreter variable with the given name.
- *theNameStr* -- the DRAW interpreter variable name to set.
- *theShapePtr* -- a pointer to *TopoDS_Shape* variable.
-~~~~~
+~~~~{.php}
const char* DBRep_SetComp (const char* theNameStr, void* theListPtr)
-~~~~~
+~~~~
Makes a compound from the specified list of shapes and sets it as a value of DRAW interpreter variable with the given name.
- *theNameStr* -- the DRAW interpreter variable name to set.
- *theListPtr* -- a pointer to *TopTools_ListOfShape* variable.
-~~~~~
+~~~~{.php}
const char* DrawTrSurf_Set (const char* theNameStr, void* theHandlePtr)
const char* DrawTrSurf_SetPnt (const char* theNameStr, void* thePntPtr)
const char* DrawTrSurf_SetPnt2d (const char* theNameStr, void* thePnt2dPtr)
-~~~~~
+~~~~
Sets the specified geometric object as a value of DRAW interpreter variable with the given name.
- *theNameStr* -- the DRAW interpreter variable name to set.
The following functions are provided by *TKBRep* toolkit and can be used from debugger prompt:
-~~~~~
+~~~~{.php}
const char* BRepTools_Write (const char* theFileNameStr, void* theShapePtr)
-~~~~~
+~~~~
Saves the specified shape to a file with the given name.
- *theFileNameStr* -- the name of the file where the shape is saved.
- *theShapePtr* -- a pointer to *TopoDS_Shape* variable.
-~~~~~
+~~~~{.php}
const char* BRepTools_Dump (void* theShapePtr)
const char* BRepTools_DumpLoc (void* theShapePtr)
-~~~~~
+~~~~
Dumps shape or its location to cout.
- *theShapePtr* -- a pointer to *TopoDS_Shape* variable.
The following function is provided by *TKMesh* toolkit:
-~~~~~
+~~~~{.php}
const char* BRepMesh_Dump (void* theMeshHandlePtr, const char* theFileNameStr)
-~~~~~
+~~~~
Stores mesh produced in parametric space to BREP file.
- *theMeshHandlePtr* -- a pointer to *Handle(BRepMesh_DataStructureOfDelaun)* variable.
The following functions are provided by *TKTopTest* toolkit:
-~~~~~
+~~~~{.php}
const char* MeshTest_DrawLinks(const char* theNameStr, void* theFaceAttr)
const char* MeshTest_DrawTriangles(const char* theNameStr, void* theFaceAttr)
-~~~~~
+~~~~
Sets the edges or triangles from mesh data structure of type *Handle(BRepMesh_FaceAttribute)* as DRAW interpreter variables, assigning a unique name in the form "<theNameStr>_<index>" to each object.
- *theNameStr* -- the prefix to use in names of objects.
The following additional function is provided by *TKGeomBase* toolkit:
-~~~~~
+~~~~{.php}
const char* GeomTools_Dump (void* theHandlePtr)
-~~~~~
+~~~~
Dump geometric object to cout.
- *theHandlePtr* -- a pointer to the geometric variable (<i>Handle</i> to *Geom_Geometry* or *Geom2d_Curve* or descendant) to be set.
Json output for Bnd_OBB (using command 'bounding v -obb -dumpJson'):
-~~~~~
+~~~~{.java}
"Bnd_OBB": {
"Center": {
"gp_XYZ": [1, 2, 3]
"HDims[2]": 0,
"IsAABox": 1,
}
-~~~~~
+~~~~
@section occt_debug_vstudio Using Visual Studio debugger
For example, assume that you are debugging a function, where local variable *TopoDS_Edge* *anEdge1* is of interest.
The following set of commands in the Command window will save this edge to file *edge1.brep*, then put it to DRAW variable *e1* and show it maximized in the axonometric DRAW view:
-~~~~~
+~~~~{.php}
>? ({,,TKBRep.dll}BRepTools_Write)("d:/edge1.brep",(void*)&anEdge1)
0x04a2f234 "d:/edge1.brep"
>? ({,,TKDraw.dll}DBRep_Set)("e1",(void*)&anEdge1)
0x0369eba8 "e1"
>? ({,,TKDraw.dll}Draw_Eval)("donly e1; axo; fit")
0x029a48f0 ""
-~~~~~
+~~~~
For convenience it is possible to define aliases to commands in this window, for instance (here ">" is prompt provided by the command window; in the Immediate window this symbol should be entered manually):
-~~~~~
+~~~~{.php}
>alias deval ? ({,,TKDraw}Draw_Eval)
>alias dsetshape ? ({,,TKDraw}DBRep_Set)
>alias dsetcomp ? ({,,TKDraw}DBRep_SetComp)
>alias dumploc ? ({,,TKBRep}BRepTools_DumpLoc)
>alias dumpmesh ? ({,,TKMesh}BRepMesh_Dump)
>alias dumpgeom ? ({,,TKGeomBase}GeomTools_Dump)
-~~~~~
+~~~~
Note that aliases are stored in the Visual Studio user's preferences and it is sufficient to define them once on a workstation. With these aliases, the above example can be reproduced easier (note the space symbol after alias name!):
-~~~~~
+~~~~{.php}
>saveshape ("d:/edge1.brep",(void*)&anEdge1)
0x04a2f234 "d:/edge1.brep"
>dsetshape ("e1",(void*)&anEdge1)
0x0369eba8 "e1"
>deval ("donly e1; axo; fit")
0x029a48f0 ""
-~~~~~
+~~~~
Note that there is no guarantee that the call will succeed and will not affect the program execution, thus use this feature at your own risk. In particular, the commands interacting with window system (such as *axo*, *vinit*, etc.) are known to cause application crash when the program is built in 64-bit mode. To avoid this, it is recommended to prepare all necessary view windows in advance, and arrange these windows to avoid overlapping with the Visual Studio window, to ensure that they are visible during debug.
### \[AutoExpand\] section
-~~~~~
+~~~~{.cpp}
; Open CASCADE classes
Standard_Transient=<,t> count=<count,d>
Handle_Standard_Transient=<entity,x> count=<entity->count,d> <,t>
gp_Vec2d=<coord.x,g>, <coord.y,g>
gp_Mat2d={<matrix[0][0],g>,<matrix[0][1],g>}, {<matrix[1][0],g>,<matrix[1][1],g>}
gp_Ax1=loc={<loc.coord.x,g>, <loc.coord.y,g>, <loc.coord.z,g>} vdir={<vdir.coord.x,g>, <vdir.coord.y,g>, <vdir.coord.z,g>}
-~~~~~
+~~~~
### \[Visualizer\] section
-~~~~~
+~~~~{.cpp}
; Open CASCADE classes
NCollection_Handle<*> {
#array( expr: ((TCollection_HAsciiString*)$e.entity)->myString.mystring[$i],
size: ((TCollection_HAsciiString*)$e.entity)->myString.mylength) ) )
}
-~~~~~
+~~~~
In Visual Studio 2012 and later, visualizers can be put in a separate file in subdirectory *Visualizers*. See file *occt.natvis* for example.
7. Run DRAW and perform tests as usual, keeping in mind that running with sanitizer is much heavier than normal build:
> ./draw.sh relwithdeb <br>
-> Draw[]> testgrid -parallel 0
+
+~~~~{.php}
+Draw[]> testgrid -parallel 0
+~~~~
Note that when running tests under sanitizers, behavior may be different.
Known problems (as of CLang 6.0) are:
| Component | Requirement |
| --------- | ----------- |
| Minimum memory | 512 MB, 1 GB recommended |
-| Free disk space (complete installation) | 600 MB approx. |
+| Free disk space (complete installation) | 1,5 GB approx. |
On desktop, 3D viewer for optimal performance requires graphics processing unit (GPU) supporting OpenGL 3.3 or above.
Ray tracing requires OpenGL 4.0+ or OpenGL 3.3+ with *GL_ARB_texture_buffer_object_rgb32* extension.
## Implementation of Attribute Transformation in a HXX file
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~
\#include <TDF_Attribute.hxx>
\#include <gp_Ax3.hxx>
gp_Pnt myFirstPoint;
gp_Pnt mySecondPoint;
};
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
## Implementation of Attribute Transformation in a CPP file
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
\#include <MyPackage_Transformation.hxx>
//=======================================================================
MyPackage_Transformation::MyPackage_Transformation():myType(gp_Identity){
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
## Implementation of typical actions with standard OCAF attributes.
This is an example of the code for iteration and execution of functions.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
// The scope of functions is defined.
Handle(TFunction_Scope) scope = TFunction_Scope::Set( anyLabel );
} // end of iteration of current functions
} // end of iteration of functions.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
### Example 2: Cylinder function driver
This is an example of the code for a cylinder function driver. To make the things clearer, the methods
<i>\::Arguments()</i> and <i>\::Results()</i> from the base class are also mentioned.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
// A virtual method ::Arguments() returns a list of arguments of the function.
CylinderDriver::Arguments( TDF_LabelList& args )
return 0;
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
#### Usage of the GF algorithm on C++ level
-~~~~
+~~~~{.cpp}
BOPAlgo_Builder aBuilder;
// Setting arguments
TopTools_ListOfShape aLSObjects = …; // Objects
#### Usage of the GF algorithm on Tcl level
-~~~~
+~~~~{.cpp}
# prepare the arguments
box b1 10 10 10
box b2 3 4 5 10 10 10
@subsubsection specification__boolean_8_3_1 API
On the low level the Splitter algorithm is implemented in class *BOPAlgo_Splitter*. The usage of this algorithm looks as follows:
-~~~~~
+~~~~{.cpp}
BOPAlgo_Splitter aSplitter;
// Setting arguments and tools
TopTools_ListOfShape aLSObjects = …; // Objects
}
//
const TopoDS_Shape& aResult = aSplitter.Shape(); // result of the operation
-~~~~~
+~~~~
@subsubsection specification__boolean_8_3_2 DRAW
The command *bsplit* implements the Splitter algorithm in DRAW. Similarly to the *bbuild* command for the General Fuse algorithm, the *bsplit* command should be used after the Pave Filler is filled.
-~~~~~
+~~~~{.cpp}
# s1 s2 s3 - objects
# t1 t2 t3 - tools
bclearobjects
baddtools t1 t2 t3
bfillds
bsplit result
-~~~~~
+~~~~
@subsection specification__boolean_8_4 Examples
Splitting a face by the set of edges:
-~~~~
+~~~~{.cpp}
# draw script for reproducing
bclearobjects
bcleartools
Splitting a plate by the set of cylinders:
-~~~~
+~~~~{.cpp}
# draw script for reproducing:
bclearobjects
bcleartools
#### C++ Level
The usage of the algorithm on the API level:
-~~~~
+~~~~{.cpp}
BOPAlgo_MakerVolume aMV;
// Set the arguments
TopTools_ListOfShape aLS = …; // arguments
#### Tcl Level
To use the algorithm in Draw the command mkvolume has been implemented. The usage of this command is following:
-~~~~
+~~~~{.php}
Usage: mkvolume r b1 b2 ... [-c] [-ni] [-ai]
Options:
-c - use this option to have input compounds considered as set of separate arguments (allows passing multiple arguments as one compound);
#### DRAW usage
The following set of new commands has been implemented to run the algorithm in DRAW Test Harness:
-~~~~
+~~~~{.php}
bcbuild : Initialization of the Cells Builder. Use: *bcbuild r*
bcadd : Add parts to result. Use: *bcadd r s1 (0,1) s2 (0,1) ... [-m material [-u]]*
bcaddall : Add all parts to result. Use: *bcaddall r [-m material [-u]]*
~~~~
Here is the example of the algorithm use on the DRAW level:
-~~~~
+~~~~{.php}
psphere s1 15
psphere s2 15
psphere s3 15
@subsection specification__boolean_10c_Cells_2 Examples
The following simple example illustrates the possibilities of the algorithm working on a cylinder and a sphere intersected by a plane:
-~~~~
+~~~~{.php}
pcylinder c 10 30
psphere s 15
ttranslate s 0 0 30
@figure{/specification/boolean_operations/images/cells_algorithm_001.png,"Arguments",160}
-~~~~
+~~~~{.php}
bclearobjects
bcleartools
baddobjects c s f
#### 1. Common for all arguments
-~~~~
+~~~~{.php}
bcremoveall
bcadd res c 1 s 1 f 1
~~~~
#### 2. Common between cylinder and face
-~~~~
+~~~~{.php}
bcremoveall
bcadd res f 1 c 1
~~~~
#### 3. Common between cylinder and sphere
-~~~~
+~~~~{.php}
bcremoveall
bcadd res c 1 s 1
~~~~
#### 4. Fuse of cylinder and sphere
-~~~~
+~~~~{.php}
bcremoveall
bcadd res c 1 -m 1
bcadd res s 1 -m 1
#### 5. Parts of the face inside solids - FUSE(COMMON(f, c), COMMON(f, s))
-~~~~
+~~~~{.php}
bcremoveall
bcadd res f 1 s 1 -m 1
bcadd res f 1 c 1 -m 1
@figure{/specification/boolean_operations/images/cells_algorithm_006_1.png,"Parts of the face inside solids",160}
-~~~~
+~~~~{.php}
bcremoveint res
~~~~
#### 6. Part of the face outside solids
-~~~~
+~~~~{.php}
bcremoveall
bcadd res f 1 c 0 s 0
~~~~
#### 7. Fuse operation (impossible using standard Boolean Fuse operation)
-~~~~
+~~~~{.php}
bcremoveall
bcadd res c 1 -m 1
bcadd res s 1 -m 1
* 1 - for partial coincidence;
* 2 - for full coincidence
-~~~~
+~~~~{.php}
bglue 1
~~~~
* 0 - default value, the safe mode is switched off;
* 1 - the safe mode will be switched on.
-~~~~
+~~~~{.php}
bnondestructive 1
~~~~
* 0 - disabling the classification;
* 1 - default value, enabling the classification.
-~~~~
+~~~~{.php}
bcheckinverted 0
~~~~
To enable/disable the usage of OBB in the operation in DRAW it is necessary to call the *buseobb* command with the appropriate value:
* 0 - disabling the usage of OBB;
* 1 - enabling the usage of OBB.
-~~~~
+~~~~{.php}
buseobb 1
~~~~
These messages can be localized; for that put translated version to separate file and load it in the application by call to *Message_MsgFile::Load()* .
Here is the example of how to use this system:
-~~~~~
+~~~~{.php}
BOPAlgo_PaveFiller aPF;
aPF.SetArguments(...);
aPF.Perform();
}
...
}
-~~~~~
+~~~~
DRAW commands executing Boolean operations output errors and warnings generated by these operations in textual form.
Additional option allows saving shapes for which warnings have been generated, as DRAW variables.
To activate this option, run command *bdrawwarnshapes* with argument 1 (or with 0 to deactivate):
-~~~~
+~~~~{.php}
bdrawwarnshapes 1
~~~~
Example of the overlapping faces:
-~~~~
+~~~~{.php}
plane p 0 0 0 0 0 1
mkface f1 p -10 10 -10 10
mkface f2 p 0 20 -10 10
But in the CUT operation on the same edges, the tool edge will be Deleted from the result and, thus, will not have any Modified shapes.
Example of the intersecting edges:
-~~~~
+~~~~{.php}
line l1 0 0 0 1 0 0
mkedge e1 l1 -10 10
As for the operation with intersecting faces, consider the following example:
-~~~~
+~~~~{.php}
plane p1 0 0 0 0 0 1
mkface f1 p1 -10 10 -10 10
Here is the simple example of simplification of the result of Fuse operation of two boxes:
-~~~~
+~~~~{.php}
bsimplify -f 1
box b1 10 10 15
#### C++ Level
-~~~~
+~~~~{.cpp}
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <BRepAlgoAPI_BuilderAlgo.hxx>
#### Tcl Level
-~~~~
+~~~~{.php}
# prepare the arguments
box b1 10 10 10
box b2 3 4 5 10 10 10
#### C++ Level
-~~~~
+~~~~{.cpp}
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include <BRepAlgoAPI_Splitter.hxx>
#### Tcl Level
-~~~~
+~~~~{.php}
# prepare the arguments
# objects
box b1 10 10 10
#### C++ Level
-~~~~
+~~~~{.cpp}
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include < BRepAlgoAPI_Common.hxx>
#### Tcl Level
-~~~~
+~~~~{.php}
# prepare the arguments
box b1 10 10 10
box b2 7 0 4 10 10 10
#### C++ Level
-~~~~
+~~~~{.cpp}
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include < BRepAlgoAPI_Fuse.hxx>
#### Tcl Level
-~~~~
+~~~~{.php}
# prepare the arguments
box b1 10 10 10
box b2 7 0 4 10 10 10
#### C++ Level
-~~~~
+~~~~{.cpp}
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include < BRepAlgoAPI_Cut.hxx>
#### Tcl Level
-~~~~
+~~~~{.php}
# prepare the arguments
box b1 10 10 10
box b2 7 0 4 10 10 10
#### C++ Level
-~~~~
+~~~~{.cpp}
#include <TopoDS_Shape.hxx>
#include <TopTools_ListOfShape.hxx>
#include < BRepAlgoAPI_Section.hxx>
#### Tcl Level
-~~~~
+~~~~{.php}
# prepare the arguments
box b1 10 10 10
box b2 3 4 5 10 10 10
The following sample code reads a shape from ASCII file and writes it to a binary one:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Shape aShape;
if (BRepTools::Read (aShape, "source_file.txt")) {
BinTools::Write (aShape, "result_file.bin");
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section specification__brep_format_3 Format Common Structure
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<3D curve record 2> = "2" <_> <3D circle center> <_> <3D circle N> <_> <3D circle Dx> <_> <3D circle Dy> <_> <3D circle radius> <_\n>;
<3D circle center> = <3D point>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<3D curve record 3> = "3" <_> <3D ellipse center> <_> <3D ellipse N> <_> <3D ellipse Dmaj> <_> <3D ellipse Dmin> <_> <3D ellipse Rmaj> <_> <3D ellipse Rmin> <_\n>;
<3D ellipse center> = <3D point>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<3D curve record 4> = "4" <_> <3D parabola origin> <_> <3D parabola N> <_> <3D parabola Dx> <_> <3D parabola Dy> <_> <3D parabola focal length> <_\n>;
<3D parabola origin> = <3D point>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<3D curve record 5> = "5" <_> <3D hyperbola origin> <_> <3D hyperbola N> <_> <3D hyperbola Dx> <_> <3D hyperbola Dy> <_> <3D hyperbola Kx> <_> <3D hyperbola Ky> <_\n>;
<3D hyperbola origin> = <3D point>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<3D curve record 7> = "7" <_> <3D B-spline rational flag> <_> "0" <_> <3D B-spline degree> <_>
<3D B-spline pole count> <_> <3D B-spline multiplicity knot count> <3D B-spline weight poles>
<_\n> <3D B-spline multiplicity knots> <_\n>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<3D curve record 8> = "8" <_> <3D trimmed curve u min> <_> <3D trimmed curve u max> <_\n> <3D curve record>;
<3D trimmed curve u min> = <real>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<surface record 8> = "8" <_> <Bezier surface u rational flag> <_> <Bezier surface v rational flag> <_> <Bezier surface u degree> <_> <Bezier surface v degree> <_>
<Bezier surface weight poles>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<2D curve record 2> = "2" <_> <2D circle center> <_> <2D circle Dx> <_> <2D circle Dy> <_> <2D circle radius> <_\n>;
<2D circle center> = <2D point>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<2D curve record 7> = "7" <_> <2D B-spline rational flag> <_> "0" <_> <2D B-spline degree> <_> <2D B-spline pole count> <_> <2D B-spline multiplicity knot count> <2D B-spline weight poles> <_\n> <2D B-spline multiplicity knots> <_\n>;
<2D B-spline rational flag> = <flag>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<triangulations> = <triangulation header> <_\n> <triangulation records>;
<triangulation header> = "Triangulations" <_> <triangulation count>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<edge data> = <_> <edge data tolerance> <_> <edge data same parameter flag> <_> edge data same range flag> <_> <edge data degenerated flag> <_\n> <edge data representations>;
<edge data tolerance> = <real>;
**BNF-like Definition**
-~~~~
+~~~~{.cpp}
<face data> = <face data natural restriction flag> <_> <face data tolerance> <_> <surface number> <_> <location number> <\n> ["2" <_> <triangulation number>];
<face data natural restriction flag> = <flag>;
Since all the points you will define are only used to create the profile's curves, an object with a limited lifetime will do. Choose the *gp_Pnt* class.
To instantiate a *gp_Pnt* object, just specify the X, Y, and Z coordinates of the points in the global Cartesian coordinate system:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Pnt aPnt1(-myWidth / 2., 0, 0);
gp_Pnt aPnt2(-myWidth / 2., -myThickness / 4., 0);
gp_Pnt aPnt3(0, -myThickness / 2., 0);
gp_Pnt aPnt4(myWidth / 2., -myThickness / 4., 0);
gp_Pnt aPnt5(myWidth / 2., 0, 0);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Once your objects are instantiated, you can use methods provided by the class to access and modify its data. For example, to get the X coordinate of a point:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Standard_Real xValue1 = aPnt1.X();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection OCCT_TUTORIAL_SUB2_2 Profile: Defining the Geometry
With the help of the previously defined points, you can compute a part of the bottle's profile geometry. As shown in the figure below, it will consist of two segments and one arc.
Both of these classes return a *Geom_TrimmedCurve* manipulated by handle. This entity represents a base curve (line or circle, in our case), limited between two of its parameter values. For example, circle C is parameterized between 0 and 2PI. If you need to create a quarter of a circle, you create a *Geom_TrimmedCurve* on C limited between 0 and M_PI/2.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(Geom_TrimmedCurve) aArcOfCircle = GC_MakeArcOfCircle(aPnt2,aPnt3,aPnt4);
Handle(Geom_TrimmedCurve) aSegment1 = GC_MakeSegment(aPnt1, aPnt2);
Handle(Geom_TrimmedCurve) aSegment2 = GC_MakeSegment(aPnt4, aPnt5);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
All *GC* classes provide a casting method to obtain a result automatically with a function-like call. Note that this method will raise an exception if construction has failed. To handle possible errors more explicitly, you may use the *IsDone* and *Value* methods. For example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
GC_MakeSegment mkSeg (aPnt1, aPnt2);
Handle(Geom_TrimmedCurve) aSegment1;
if(mkSegment.IsDone()){
else {
// handle error
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection OCCT_TUTORIAL_SUB2_3 Profile: Defining the Topology
However, the *TopoDS* package provides only the data structure of the topological entities. Algorithm classes available to compute standard topological objects can be found in the *BRepBuilderAPI* package.
To create an edge, you use the BRepBuilderAPI_MakeEdge class with the previously computed curves:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aSegment1);
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aArcOfCircle);
TopoDS_Edge aEdge3 = BRepBuilderAPI_MakeEdge(aSegment2);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
In Open CASCADE Technology, you can create edges in several ways. One possibility is to create an edge directly from two points, in which case the underlying geometry of this edge is a line, bounded by two vertices being automatically computed from the two input points. For example, aEdge1 and aEdge3 could have been computed in a simpler way:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aPnt1, aPnt3);
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(aPnt4, aPnt5);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
To connect the edges, you need to create a wire with the *BRepBuilderAPI_MakeWire* class. There are two ways of building a wire with this class:
When building a wire from less than four edges, as in the present case, you can use the constructor directly as follows:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Wire aWire = BRepBuilderAPI_MakeWire(aEdge1, aEdge2, aEdge3);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection OCCT_TUTORIAL_SUB2_4 Profile: Completing the Profile
* X axis is located at (0, 0, 0) - use the *gp_Pnt* class.
* X axis direction is (1, 0, 0) - use the *gp_Dir* class. A *gp_Dir* instance is created out of its X, Y and Z coordinates.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Pnt aOrigin(0, 0, 0);
gp_Dir xDir(1, 0, 0);
gp_Ax1 xAxis(aOrigin, xDir);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The second and simplest way is to use the geometric constants defined in the gp package (origin, main directions and axis of the global coordinate system). To get the X axis, just call the *gp::OX* method:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Ax1 xAxis = gp::OX();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
As previously explained, the 3D geometric transformation is defined with the *gp_Trsf* class. There are two different ways to use this class:
Since the simplest approach is always the best one, you should use the SetMirror method with the axis as the center of symmetry.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Trsf aTrsf;
aTrsf.SetMirror(xAxis);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
You now have all necessary data to apply the transformation with the BRepBuilderAPI_Transform class by specifying:
* the shape on which the transformation must be applied.
* the geometric transformation
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepBuilderAPI_Transform aBRepTrsf(aWire, aTrsf);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
*BRepBuilderAPI_Transform* does not modify the nature of the shape: the result of the reflected wire remains a wire. But the function-like call or the *BRepBuilderAPI_Transform::Shape* method returns a *TopoDS_Shape* object:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Shape aMirroredShape = aBRepTrsf.Shape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
What you need is a method to consider the resulting reflected shape as a wire. The *TopoDS* global functions provide this kind of service by casting a shape into its real type. To cast the transformed wire, use the *TopoDS::Wire* method.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Wire aMirroredWire = TopoDS::Wire(aMirroredShape);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The bottle's profile is almost finished. You have created two wires: *aWire* and *aMirroredWire*. You need to concatenate them to compute a single shape. To do this, you use the *BRepBuilderAPI_MakeWire* class as follows:
* create an instance of *BRepBuilderAPI_MakeWire*.
* add all edges of the two wires by using the *Add* method on this object.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepBuilderAPI_MakeWire mkWire;
mkWire.Add(aWire);
mkWire.Add(aMirroredWire);
TopoDS_Wire myWireProfile = mkWire.Wire();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section sec3 Building the Body
To create a face, use the *BRepBuilderAPI_MakeFace* class. As previously explained, a face is a part of a surface bounded by a closed wire. Generally, *BRepBuilderAPI_MakeFace* computes a face out of a surface and one or more wires.
When the wire lies on a plane, the surface is automatically computed.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Face myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The *BRepPrimAPI* package provides all the classes to create topological primitive constructions: boxes, cones, cylinders, spheres, etc. Among them is the *BRepPrimAPI_MakePrism* class. As specified above, the prism is defined by:
You want the solid to be finite, swept along the Z axis and to be myHeight height. The vector, defined with the *gp_Vec* class on its X, Y and Z coordinates, is:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Vec aPrismVec(0, 0, myHeight);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
All the necessary data to create the main body of your bottle is now available. Just apply the *BRepPrimAPI_MakePrism* class to compute the solid:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Shape myBody = BRepPrimAPI_MakePrism(myFaceProfile, aPrismVec);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection OCCT_TUTORIAL_SUB3_2 Applying Fillets
* Add the fillet descriptions (an edge and a radius) using the *Add* method (you can add as many edges as you need).
* Ask for the resulting filleted shape with the *Shape* method.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepFilletAPI_MakeFillet mkFillet(myBody);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
To add the fillet description, you need to know the edges belonging to your shape. The best solution is to explore your solid to retrieve its edges. This kind of functionality is provided with the *TopExp_Explorer* class, which explores the data structure described in a *TopoDS_Shape* and extracts the sub-shapes you specifically need.
Generally, this explorer is created by providing the following information:
* the shape to explore
* the type of sub-shapes to be found. This information is given with the *TopAbs_ShapeEnum* enumeration.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopExp_Explorer anEdgeExplorer(myBody, TopAbs_EDGE);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
An explorer is usually applied in a loop by using its three main methods:
* *Next()* to move onto the next sub-shape to explore.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
while(anEdgeExplorer.More()){
TopoDS_Edge anEdge = TopoDS::Edge(anEdgeExplorer.Current());
//Add edge to fillet algorithm
...
anEdgeExplorer.Next();
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
In the explorer loop, you have found all the edges of the bottle shape. Each one must then be added in the *BRepFilletAPI_MakeFillet* instance with the *Add()* method. Do not forget to specify the radius of the fillet along with it.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
mkFillet.Add(myThickness / 12., anEdge);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Once this is done, you perform the last step of the procedure by asking for the filleted shape.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
myBody = mkFillet.Shape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection OCCT_TUTORIAL_SUB3_3 Adding the Neck
To position the cylinder, you need to define a coordinate system with the *gp_Ax2* class defining a right-handed coordinate system from a point and two directions - the main (Z) axis direction and the X direction (the Y direction is computed from these two).
To align the neck with the center of the top face, being in the global coordinate system (0, 0, *myHeight*), with its normal on the global Z axis, your local coordinate system can be defined as follows:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Pnt neckLocation(0, 0, myHeight);
gp_Dir neckAxis = gp::DZ();
gp_Ax2 neckAx2(neckLocation, neckAxis);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
To create a cylinder, use another class from the primitives construction package: the *BRepPrimAPI_MakeCylinder* class. The information you must provide is:
* the coordinate system where the cylinder will be located;
* the radius and height.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Standard_Real myNeckRadius = myThickness / 4.;
Standard_Real myNeckHeight = myHeight / 10;
BRepPrimAPI_MakeCylinder MKCylinder(neckAx2, myNeckRadius, myNeckHeight);
TopoDS_Shape myNeck = MKCylinder.Shape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
You now have two separate parts: a main body and a neck that you need to fuse together.
The *BRepAlgoAPI* package provides services to perform Boolean operations between shapes, and especially: *common* (Boolean intersection), *cut* (Boolean subtraction) and *fuse* (Boolean union).
Use *BRepAlgoAPI_Fuse* to fuse the two shapes:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
myBody = BRepAlgoAPI_Fuse(myBody, myNeck);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection OCCT_TUTORIAL_SUB3_4 Creating a Hollowed Solid
To find the face with such characteristics, you will once again use an explorer to iterate on all the bottle's faces to find the appropriate one.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
for(TopExp_Explorer aFaceExplorer(myBody, TopAbs_FACE) ; aFaceExplorer.More() ; aFaceExplorer.Next()){
TopoDS_Face aFace = TopoDS::Face(aFaceExplorer.Current());
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
For each detected face, you need to access the geometric properties of the shape: use the *BRep_Tool* class for that. The most commonly used methods of this class are:
* *Curve* to access the 3D curve of an edge;
* *Point* to access the 3D point of a vertex.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
As you can see, the *BRep_Tool::Surface* method returns an instance of the *Geom_Surface* class manipulated by handle. However, the *Geom_Surface* class does not provide information about the real type of the object *aSurface*, which could be an instance of *Geom_Plane*, *Geom_CylindricalSurface*, etc.
All objects manipulated by handle, like *Geom_Surface*, inherit from the *Standard_Transient* class which provides two very useful methods concerning types:
DynamicType returns the real type of the object, but you need to compare it with the existing known types to determine whether *aSurface* is a plane, a cylindrical surface or some other type.
To compare a given type with the type you seek, use the *STANDARD_TYPE* macro, which returns the type of a class:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
if(aSurface->DynamicType() == STANDARD_TYPE(Geom_Plane)){
//
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
If this comparison is true, you know that the *aSurface* real type is *Geom_Plane*. You can then convert it from *Geom_Surface* to *Geom_Plane* by using the *DownCast()* method provided by each class inheriting *Standard_Transient*. As its name implies, this static method is used to downcast objects to a given type with the following syntax:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurface);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Remember that the goal of all these conversions is to find the highest face of the bottle lying on a plane. Suppose that you have these two global variables:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Face faceToRemove;
Standard_Real zMax = -1;
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
You can easily find the plane whose origin is the biggest in Z knowing that the location of the plane is given with the *Geom_Plane::Location* method. For example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Pnt aPnt = aPlane->Location();
Standard_Real aZ = aPnt.Z();
if(aZ > zMax){
zMax = aZ;
faceToRemove = aFace;
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
You have now found the top face of the neck. Your final step before creating the hollowed solid is to put this face in a list. Since more than one face can be removed from the initial solid, the *BRepOffsetAPI_MakeThickSolid* constructor takes a list of faces as arguments.
Open CASCADE Technology provides many collections for different kinds of objects: see *TColGeom* package for collections of objects from *Geom* package, *TColgp* package for collections of objects from gp package, etc.
The collection for shapes can be found in the *TopTools* package. As *BRepOffsetAPI_MakeThickSolid* requires a list, use the *TopTools_ListOfShape* class.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopTools_ListOfShape facesToRemove;
facesToRemove.Append(faceToRemove);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
All the necessary data are now available so you can create your hollowed solid by calling the *BRepOffsetAPI_MakeThickSolid* MakeThickSolidByJoin method:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepOffsetAPI_MakeThickSolid BodyMaker;
BodyMaker.MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50, 1.e-3);
myBody = BodyMaker.Shape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section sec4 Building the Threading
Notice that one of the cylindrical surfaces is smaller than the neck. There is a good reason for this: after the thread creation, you will fuse it with the neck. So, we must make sure that the two shapes remain in contact.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(Geom_CylindricalSurface) aCyl1 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 0.99);
Handle(Geom_CylindricalSurface) aCyl2 = new Geom_CylindricalSurface(neckAx2, myNeckRadius * 1.05);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection OCCT_TUTORIAL_SUB4_2 Defining 2D Curves
* To define a 2D direction (unit vector) from its X and Y coordinates, use the gp_Dir2d class. The coordinates will automatically be normalized.
* To define a 2D right-handed coordinate system, use the *gp_Ax2d* class, which is computed from a point (origin of the coordinate system) and a direction - the X direction of the coordinate system. The Y direction will be automatically computed.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Pnt2d aPnt(2. * M_PI, myNeckHeight / 2.);
gp_Dir2d aDir(2. * M_PI, myNeckHeight / 4.);
gp_Ax2d anAx2d(aPnt, aDir);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
You will now define the curves. As previously mentioned, these thread profiles are computed on two cylindrical surfaces. In the following figure, curves on the left define the base (on *aCyl1* surface) and the curves on the right define the top of the thread's shape (on *aCyl2* surface).
Your ellipses are defined as follows:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Standard_Real aMajor = 2. * M_PI;
Standard_Real aMinor = myNeckHeight / 10;
Handle(Geom2d_Ellipse) anEllipse1 = new Geom2d_Ellipse(anAx2d, aMajor, aMinor);
Handle(Geom2d_Ellipse) anEllipse2 = new Geom2d_Ellipse(anAx2d, aMajor, aMinor / 4);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
To describe portions of curves for the arcs drawn above, you define *Geom2d_TrimmedCurve* trimmed curves out of the created ellipses and two parameters to limit them.
As the parametric equation of an ellipse is P(U) = O + (MajorRadius * cos(U) * XDirection) + (MinorRadius * sin(U) * YDirection), the ellipses need to be limited between 0 and M_PI.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(Geom2d_TrimmedCurve) anArc1 = new Geom2d_TrimmedCurve(anEllipse1, 0, M_PI);
Handle(Geom2d_TrimmedCurve) anArc2 = new Geom2d_TrimmedCurve(anEllipse2, 0, M_PI);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The last step consists in defining the segment, which is the same for the two profiles: a line limited by the first and the last point of one of the arcs.
To access the point corresponding to the parameter of a curve or a surface, you use the Value or D0 method (meaning 0th derivative), D1 method is for first derivative, D2 for the second one.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Pnt2d anEllipsePnt1 = anEllipse1->Value(0);
gp_Pnt2d anEllipsePnt2;
anEllipse1->D0(M_PI, anEllipsePnt2);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
When creating the bottle's profile, you used classes from the *GC* package, providing algorithms to create elementary geometries.
In 2D geometry, this kind of algorithms is found in the *GCE2d* package. Class names and behaviors are similar to those in *GC*. For example, to create a 2D segment out of two points:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(Geom2d_TrimmedCurve) aSegment = GCE2d_MakeSegment(anEllipsePnt1, anEllipsePnt2);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection OCCT_TUTORIAL_SUB4_3 Building Edges and Wires
To compute the edges out of these curves, once again use the *BRepBuilderAPI_MakeEdge* class. One of its constructors allows you to build an edge out of a curve described in the 2D parametric space of a surface.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Edge anEdge1OnSurf1 = BRepBuilderAPI_MakeEdge(anArc1, aCyl1);
TopoDS_Edge anEdge2OnSurf1 = BRepBuilderAPI_MakeEdge(aSegment, aCyl1);
TopoDS_Edge anEdge1OnSurf2 = BRepBuilderAPI_MakeEdge(anArc2, aCyl2);
TopoDS_Edge anEdge2OnSurf2 = BRepBuilderAPI_MakeEdge(aSegment, aCyl2);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Now, you can create the two profiles of the threading, lying on each surface.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Wire threadingWire1 = BRepBuilderAPI_MakeWire(anEdge1OnSurf1, anEdge2OnSurf1);
TopoDS_Wire threadingWire2 = BRepBuilderAPI_MakeWire(anEdge1OnSurf2, anEdge2OnSurf2);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Remember that these wires were built out of a surface and 2D curves.
One important data item is missing as far as these wires are concerned: there is no information on the 3D curves. Fortunately, you do not need to compute this yourself, which can be a difficult task since the mathematics can be quite complex.
When a shape contains all the necessary information except 3D curves, Open CASCADE Technology provides a tool to build them automatically. In the BRepLib tool package, you can use the *BuildCurves3d* method to compute 3D curves for all the edges of a shape.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepLib::BuildCurves3d(threadingWire1);
BRepLib::BuildCurves3d(threadingWire2);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection OCCT_TUTORIAL_SUB4_4 Creating Threading
* Use the *CheckCompatibility* method to activate (or deactivate) the option that checks whether the wires have the same number of edges. In this case, wires have two edges each, so you can deactivate this option.
* Ask for the resulting loft shape with the Shape method.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepOffsetAPI_ThruSections aTool(Standard_True);
aTool.AddWire(threadingWire1); aTool.AddWire(threadingWire2);
aTool.CheckCompatibility(Standard_False);
TopoDS_Shape myThreading = aTool.Shape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section sec5 Building the Resulting Compound
You are almost done building the bottle. Use the *TopoDS_Compound* and *BRep_Builder* classes to build single shape from *myBody* and *myThreading*:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Compound aRes;
BRep_Builder aBuilder;
aBuilder.MakeCompound (aRes);
aBuilder.Add (aRes, myBody);
aBuilder.Add (aRes, myThreading);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Congratulations! Your bottle is complete. Here is the result snapshot of the Tutorial application:
Complete definition of MakeBottle function (defined in the file src/MakeBottle.cxx of the Tutorial):
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Shape MakeBottle(const Standard_Real myWidth, const Standard_Real myHeight,
const Standard_Real myThickness)
{
return aRes;
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Porting of user applications from an earlier OCCT version to version 6.5.1 requires taking into account the following major changes:
* Method *Graphic3d_Structure::Groups()* now returns *Graphic3d_SequenceOfGroup*. If this method has been used, the application code should be updated to iterate another collection type or, if *Graphic3d_HSetOfGroup* is required, to fill its own collection:
-~~~~
+~~~~{.cpp}
const Graphic3d_SequenceOfGroup& aGroupsSeq = theStructure.Groups();
Handle(Graphic3d_HSetOfGroup) aGroupSet = new Graphic3d_HSetOfGroup();
Standard_Integer aLen = aGroupsSeq.Length();
* If the callback mechanism in call_togl_redraw function was used in the application code, it is necessary to revise it to take into account the new callback execution and provide a check of reason value of Aspect_GraphicCallbackStruct in callback methods to confirm that the callback code is executed at the right moment. Now the callbacks are executed before redrawing the underlayer, before redrawing the overlayer and at the end of redrawing. The information about the moment when the callback is invoked is provided with the reason value in form of an additional bit flag <i>(OCC_PRE_REDRAW, OCC_PRE_OVERLAY)</i>. The state of OpenGl changed in callback methods will not be restored automatically, which might lead to unwanted behavior in redrawing procedure.
* The print method used in the application code might need to be revised to take into account the ability to choose between print algorithms: tile and stretch. The stretch algorithm will be selected by default during porting.
* It is recommended to *BRepMesh_DiscretFactory* users, to check *BRepMesh_DiscretFactory::SetDefault()* return value to determine plugin availability / validity. *BRepMesh_DiscretFactory::Discret()* method now returns handle instead of pointer. The code should be updated in the following manner:
-~~~~
+~~~~{.cpp}
Handle(BRepMesh_DiscretRoot) aMeshAlgo = BRepMesh_DiscretFactory::Get().Discret (theShape, theDeflection, theAngularToler);
if (!aMeshAlgo.IsNull()) {}
~~~~
Porting of user applications from an earlier OCCT version to version 6.5.4 requires taking into account the following major changes:
* The code using obsolete classes *Aspect_PixMap, Xw_PixMap* and *WNT_PixMap* should be rewritten implementing class *Image_PixMap*, which is now retrieved by *ToPixMap* methods as argument. A sample code using *ToPixMap* is given below:
-~~~~
+~~~~{.cpp}
#include <Image_AlienPixMap.hxx>
void dump (Handle(V3d_View)& theView3D)
{
* Interactive selection of 2D presentations should be set up inside *ComputeSelection()* virtual method of a custom interactive object class, using standard sensitive entities from *Select3D* package and standard or custom entity owners derived from *SelectMgr_EntityOwner* base.
Refer to the Visualization User's Guide for further details concerning OCCT 3D visualization and selection classes. See also *Viewer2D* OCCT sample application, which shows how 2D drawing can be implemented using TKV3d API.
* Run-time graphic driver library loading mechanism based on *CSF_GraphicShr* environment variable usage has been replaced by explicit linking against *TKOpenGl* library. The code sample below shows how the graphic driver should be created and initialized in the application code:
-~~~~
+~~~~{.cpp}
// initialize a new viewer with OpenGl graphic driver
Handle(Graphic3d_GraphicDriver) aGraphicDriver =
new OpenGl_GraphicDriver ("TKOpenGl");
Now the method *SelectMgr_Selection::Sensitive()* does not return *SelectBasics_SensitiveEntity*. It returns an instance of *SelectMgr_SensitiveEntity*, which belongs to a different class hierarchy (thus *DownCast()* will fail). To access base sensitive it is necessary to use method *SelectMgr_SensitiveEntity::BaseSensitive()*. For example:
-~~~~
+~~~~{.cpp}
Handle(SelectMgr_Selection) aSelection = anInteractiveObject->Selection (aMode);
for (aSelection->Init(); aSelection->More(); aSelection->Next())
{
Here is an example of overlap/inclusion test for a box:
-~~~~
+~~~~{.cpp}
if (!theMgr.IsOverlapAllowed()) // check for inclusion
{
Standard_Boolean isInside = Standard_True;
This tool is a Tcl script, thus Tcl should be available on your workstation to run it.
Example:
-~~~~~
+~~~~{.php}
$ tclsh
% source <path_to_occt>/adm/upgrade.tcl
% upgrade -recurse -all -src=<path_to_your_sources>
-~~~~~
+~~~~
On Windows, the helper batch script *upgrade.bat* can be used, provided that Tcl is either available in *PATH*, or configured via *custom.bat* script (for instance, if you use OCCT installed from Windows installer package). Start it from the command prompt:
-~~~~~
+~~~~
cmd> <path_to_occt>\upgrade.bat -recurse -all -inc=<path_to_occt>\inc -src=<path_to_your_sources> [options]
-~~~~~
+~~~~
Run the upgrade tool without arguments to see the list of available options.
The upgrade tool performs the following changes in the code.
1. Replaces macro *DEFINE_STANDARD_RTTI* by *DEFINE_STANDARD_RTTIEXT*, with second argument indicating base class for the main argument class (if inheritance is recognized by the script):
-~~~~~
+~~~~{.cpp}
DEFINE_STANDARD_RTTI(Class) -> DEFINE_STANDARD_RTTIEXT(Class, Base)
-~~~~~
+~~~~
@note If macro *DEFINE_STANDARD_RTTI* with two arguments (used in intermediate development versions of OCCT 7.0) is found, the script will convert it to either *DEFINE_STANDARD_RTTIEXT* or *DEFINE_STANDARD_RTTI_INLINE*.
The former case is used if current file is header and source file with the same name is found in the same folder.
The latter variant defines all methods for RTTI as inline, and does not require *IMPLEMENT_STANDARD_RTTIEXT* macro.
2. Replaces forward declarations of collection classes previously generated from CDL generics (defined in *TCollection* package) by inclusion of the corresponding header:
-~~~~~
+~~~~{.cpp}
class TColStd_Array1OfReal; -> #include <TColStd_Array1OfReal.hxx>
-~~~~~
+~~~~
3. Replaces underscored names of *Handle* classes by usage of a macro:
-~~~~~
+~~~~{.cpp}
Handle_Class -> Handle(Class)
-~~~~~
+~~~~
This change is not applied if the source or header file is recognized as containing the definition of Qt class with signals or slots, to avoid possible compilation errors of MOC files caused by inability of MOC to recognize macros (see https://doc.qt.io/qt-4.8/signalsandslots.html).
The file is considered as defining a Qt object if it contains strings *Q_OBJECT* and either *slots:* or *signals:*.
4. Removes forward declarations of classes with names <i>Handle(C)</i> or *Handle_C*, replacing them either by forward declaration of its argument class, or (for files defining Qt objects) <i>\#include</i> statement for a header with the name of the argument class and extension .hxx:
-~~~~~
+~~~~{.cpp}
class Handle(TColStd_HArray1OfReal); -> #include <TColStd_HArray1OfReal.hxx>
-~~~~~
+~~~~
5. Removes <i> \#includes </i> of files <i>Handle_...hxx</i> that have disappeared in OCCT 7.0:
-~~~~~
+~~~~{.cpp}
#include <Handle_Geom_Curve.hxx> ->
-~~~~~
+~~~~
6. Removes *typedef* statements that use *Handle* macro to generate the name:
-~~~~~
+~~~~{.cpp}
typedef NCollection_Handle<Message_Msg> Handle(Message_Msg); ->
-~~~~~
+~~~~
7. Converts C-style casts applied to Handles into calls to <i>DownCast()</i> method:
-~~~~~
+~~~~{.cpp}
((Handle(A)&)b) -> Handle(A)::DownCast(b)
(Handle(A)&)b -> Handle(A)::DownCast(b)
(*((Handle(A)*)&b)) -> Handle(A)::DownCast(b)
*((Handle(A)*)&b) -> Handle(A)::DownCast(b)
(*(Handle(A)*)&b) -> Handle(A)::DownCast(b)
-~~~~~
+~~~~
8. Moves <i>Handle()</i> macro out of namespace scope:
-~~~~~
+~~~~{.cpp}
Namespace::Handle(Class) -> Handle(Namespace::Class)
-~~~~~
+~~~~
9. Converts local variables of reference type, which are initialized by a temporary object returned by call to <i>DownCast()</i>, to the variables of non-reference type (to avoid using references to destroyed memory):
-~~~~~
+~~~~{.cpp}
const Handle(A)& a = Handle(B)::DownCast (b); -> Handle(A) a (Handle(B)::DownCast (b));
-~~~~~
+~~~~
10. Adds <i>\#include</i> for all classes used as argument to macro <i>STANDARD_TYPE()</i>, except for already included ones;
As long as the upgrade routine runs, some information messages are sent to the standard output.
In some cases the warnings or errors like the following may appear:
-~~~~~
+~~~~
Error in {HEADER_FILE}: Macro DEFINE_STANDARD_RTTI used for class {CLASS_NAME} whose declaration is not found in this file, cannot fix
-~~~~~
+~~~~
Be sure to check carefully all reported errors and warnings, as the corresponding code will likely require manual corrections.
In some cases these messages may help you to detect errors in your code, for instance, cases where *DEFINE_STANDARD_RTTI* macro is used with incorrect class name as an argument.
For example, the following lines will fail to compile if *Geom_Line.hxx* is not included:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Line) aLine = 0;
if (aLine != aCurve) {...}
if (aCurve->IsKind(STANDARD_TYPE(Geom_Line)) {...}
aLine = Handle(Geom_Line)::DownCast (aCurve);
-~~~~~
+~~~~
Note that it is not necessary to include header of the class to declare Handle to it.
However, if you define a class *B* that uses Handle(*A*) in its fields, or contains a method returning Handle(*A*), it is advisable to have header defining *A* included in the header of *B*.
The problem is that operator <i> const handle<T2>& </i> is defined for any type *T2*, thus the compiler cannot make the right choice.
Example:
-~~~~~
+~~~~{.cpp}
void func (const Handle(Geom_Curve)&);
void func (const Handle(Geom_Surface)&);
Handle(Geom_TrimmedCurve) aCurve = new Geom_TrimmedCurve (...);
func (aCurve); // ambiguity error in VC++ 10
-~~~~~
+~~~~
Note that this problem can be avoided in many cases if macro *OCCT_HANDLE_NOCAST* is used, see @ref upgrade_occt700_cdl_nocast "below".
To resolve this ambiguity, change your code so that argument type should correspond exactly to the function signature.
In some cases this can be done by using the relevant type for the corresponding variable, like in the example above:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Curve) aCurve = new Geom_TrimmedCurve (...);
-~~~~~
+~~~~
Other variants consist in assigning the argument to a local variable of the correct type and using the direct cast or constructor:
-~~~~~
+~~~~{.cpp}
const Handle(Geom_Curve)& aGCurve (aTrimmedCurve);
func (aGCurve); // OK - argument has exact type
func (static_cast(aCurve)); // OK - direct cast
func (Handle(Geom_Curve)(aCurve)); // OK - temporary handle is constructed
-~~~~~
+~~~~
Another possibility consists in defining additional template variant of the overloaded function causing ambiguity, and using *SFINAE* to resolve the ambiguity.
This technique can be illustrated by the definition of the template variant of method <i>IGESData_IGESWriter::Send()</i>.
For example:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Geometry) aC = GC_MakeLine (p, v); // compiler error
-~~~~~
+~~~~
The problem is that the class *GC_MakeLine* has a user-defined conversion to <i>const Handle(Geom_TrimmedCurve)&,</i> which is not the same as the type of the local variable *aC*.
To resolve this, use method <i>Value()</i>:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Geometry) aC = GC_MakeLine (p, v).Value(); // ok
-~~~~~
+~~~~
or use variable of the appropriate type:
-~~~~~
+~~~~{.cpp}
Handle(Geom_TrimmedCurve) aC = GC_MakeLine (p, v); // ok
-~~~~~
+~~~~
A similar problem appears with GCC compiler, when *const* handle to derived type is used to construct handle to base type via assignment (and in some cases in return statement), for instance:
-~~~~~
+~~~~{.cpp}
const Handle(Geom_Line) aLine;
Handle(Geom_Curve) c1 = aLine; // GCC error
Handle(Geom_Curve) c2 (aLine); // ok
-~~~~~
+~~~~
This problem is specific to GCC and it does not appear if macro *OCCT_HANDLE_NOCAST* is used, see @ref upgrade_occt700_cdl_nocast "below".
1. Explicit definitions of static functions with names generated by macro *STANDARD_TYPE()*, which are artifacts of old implementation of RTTI, should be removed.
Example:
-~~~~~
+~~~~{.cpp}
const Handle(Standard_Type)& STANDARD_TYPE(math_GlobOptMin)
{
static Handle(Standard_Type) _atype = new Standard_Type ("math_GlobOptMin", sizeof (math_GlobOptMin));
return _atype;
}
-~~~~~
+~~~~
2. Incorrect location of closing parenthesis of *Handle()* macro that was not detectable in OCCT 6.x will cause a compiler error and must be corrected.
Example (note misplaced closing parenthesis):
-~~~~~
+~~~~{.cpp}
aBSpline = Handle( Geom2d_BSplineCurve::DownCast(BS->Copy()) );
-~~~~~
+~~~~
#### Use of class Standard_AncestorIterator
Handles in OCCT 7.0 do not have the operator of conversion to <i>Standard_Transient*,</i> which was present in earlier versions.
This is done to prevent possible unintended errors like this:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Line) aLine = ...;
Handle(Geom_Surface) aSurf = ...;
...
if (aLine == aSurf) {...} // will cause a compiler error in OCCT 7.0, but not OCCT 6.x
-~~~~~
+~~~~
The places where this implicit cast has been used should be corrected manually.
The typical situation is when Handle is passed to stream:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Line) aLine = ...;
os << aLine; // in OCCT 6.9.0, resolves to operator << (void*)
-~~~~~
+~~~~
Call method <i>get()</i> explicitly to output the address of the Handle.
Method *DownCast()* in OCCT 7.0 is made templated; if its argument is not a base class, "deprecated" compiler warning is generated.
This is done to prevent possible unintended errors like this:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Surface) aSurf = ;
Handle(Geom_Line) aLine =
Handle(Geom_Line)::DownCast (aSurf); // will cause a compiler warning in OCCT 7.0, but not OCCT 6.x
-~~~~~
+~~~~
The places where this cast has been used should be corrected manually.
If down casting is used in a template context where the argument can have the same or unrelated type so that *DownCast()* may be not available in all cases, use C++ *dynamic_cast<>* instead, e.g.:
-~~~~~
+~~~~{.cpp}
template <class T>
bool CheckLine (const Handle(T) theArg)
{
Handle(Geom_Line) aLine = dynamic_cast<Geom_Line> (theArg.get());
...
}
-~~~~~
+~~~~
@subsubsection upgrade_occt700_cdl_runtime Possible runtime problems
Example:
-~~~~~
+~~~~{.cpp}
// note that DownCast() returns new temporary object!
const Handle(Geom_BoundedCurve)& aBC =
Handle(Geom_TrimmedCurve)::DownCast(aCurve);
aBC->Transform (T); // access violation in OCCT 7.0
-~~~~~
+~~~~
@subsubsection upgrade_occt700_cdl_nocast Option to avoid cast of handle to reference to base type
In OCCT 6.x and earlier versions the handle classes formed a hierarchy echoing the hierarchy of the corresponding object classes .
This automatically enabled the possibility to use the handle to a derived class in all contexts where the handle to a base class was needed, e.g. to pass it in a function by reference without copying:
-~~~~
+~~~~{.cpp}
Standard_Boolean GetCurve (Handle(Geom_Curve)& theCurve);
....
Handle(Geom_Line) aLine;
The code that relies on the possibility of casting to base should be amended to always use the handle of argument type in function call and to use *DownCast()* to safely convert the result to the desired type.
For instance, the code from the example below can be changed as follows:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Line) aLine;
Handle(Geom_Curve) aCurve;
if (GetCurve (aCure) && !(aLine = Handle(Geom_Line)::DownCast (aCurve)).IsNull()) {
// use aLine safely
}
-~~~~~
+~~~~
@subsubsection upgrade_occt700_cdl_compat Preserving compatibility with OCCT 6.x
3. Define macros *DEFINE_STANDARD_RTTIEXT* and *DEFINE_STANDARD_RTTI_INLINE* when building with previous versions of OCCT, resolving to *DEFINE_STANDARD_RTTI* with single argument
Example:
-~~~~~
+~~~~{.cpp}
#if OCC_VERSION_HEX < 0x070000
#define DEFINE_STANDARD_RTTIEXT(C1,C2) DEFINE_STANDARD_RTTI(C1)
#define DEFINE_STANDARD_RTTI_INLINE(C1,C2) DEFINE_STANDARD_RTTI(C1)
#endif
-~~~~~
+~~~~
@subsubsection upgrade_occt700_cdl_wok Applications based on CDL and WOK
The recommended approach is to use sorting algorithms provided by STL.
For instance:
-~~~~~
+~~~~{.cpp}
#include <SortTools_StraightInsertionSortOfReal.hxx>
#include <SortTools_ShellSortOfReal.hxx>
#include <TCollection_CompareOfReal.hxx>
...
TCollection_CompareOfReal aCompReal;
SortTools_StraightInsertionSortOfReal::Sort(aValues, aCompReal);
-~~~~~
+~~~~
can be replaced by:
-~~~~~
+~~~~{.cpp}
#include <algorithm>
...
TCollection_Array1OfReal aValues = ...;
...
std::stable_sort (aValues.begin(), aValues.end());
-~~~~~
+~~~~
@subsection upgrade_occt700_2dlayers On-screen objects and ColorScale
The property of *V3d_View* storing the global *ColorScale* object has been removed with associated methods *V3d_View::ColorScaleDisplay(), V3d_View::ColorScaleErase(), V3d_View::ColorScaleIsDisplayed()* and *V3d_View::ColorScale()* as well as the classes *V3d_ColorScale, V3d_ColorScaleLayerItem* and *Aspect_ColorScale*.
Here is an example of creating *ColorScale* using the updated API:
-~~~~~
+~~~~{.cpp}
Handle(AIS_ColorScale) aCS = new AIS_ColorScale();
// configuring
Standard_Integer aWidth, aHeight;
aCS->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0));
aCS->SetToUpdate();
theContextAIS->Display (aCS);
-~~~~~
+~~~~
To see how 2d objects are implemented in OCCT you can call Draw commands *vcolorscale, vlayerline* or *vdrawtext* (with <i>-2d</i> option).
Draw command *vcolorscale* now requires the name of *ColorScale* object as argument.
To display this object use command *vdisplay*. For example:
-~~~~~
+~~~~{.php}
pload VISUALIZATION
vinit
vcolorscale cs -demo
vfit
vlayerline 0 300 300 300 10
vdrawtext t "2D-TEXT" -2d -pos 0 150 0 -color red
-~~~~~
+~~~~
Here is a small example in C++ illustrating how to display a custom AIS object in 2d:
-~~~~~
+~~~~{.cpp}
Handle(AIS_InteractiveContext) aContext = ...;
Handle(AIS_InteractiveObject) anObj =...; // create an AIS object
anObj->SetZLayer(Graphic3d_ZLayerId_TopOSD); // display object in overlay
anObj->SetTransformPersistence (Graphic3d_TMF_2d, gp_Pnt (-1,-1,0)); // set 2d flag, coordinate origin is set to down-left corner
aContext->Display (anObj); // display the object
-~~~~~
+~~~~
@subsection upgrade_occt700_userdraw UserDraw and Visual3d
Old APIs based on global callback functions for creating *UserDraw* objects and for performing custom OpenGL rendering within the view have been dropped.
*UserDraw* callbacks are no more required since *OpenGl_Group* now inherits *Graphic3d_Group* and thus can be accessed directly from *AIS_InteractiveObject*:
-~~~~~
+~~~~{.cpp}
//! Class implementing custom OpenGL element.
class UserDrawElement : public OpenGl_Element {};
// invalidate bounding box of the scene
thePrsMgr->StructureManager()->Update();
}
-~~~~~
+~~~~
To perform a custom OpenGL code within the view, it is necessary to inherit from class *OpenGl_View*.
See the following code sample:
-~~~~~
+~~~~{.cpp}
//! Custom view.
class UserView : public OpenGl_View
{
}
};
-~~~~~
+~~~~
@subsection upgrade_occt700_localcontext Deprecation of Local Context
* *BRepOffsetAPI_MakeOffsetShape::PerformByJoin()* - method has been added. This method is old algorithm behaviour.
The code below shows new calling procedure:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepOffsetAPI_MakeOffsetShape OffsetMaker;
OffsetMaker.PerformByJoin(Shape, OffsetValue, Tolerance);
NewShape = OffsetMaker.Shape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Class *BRepOffsetAPI_MakeThickSolid*:
* *BRepOffsetAPI_MakeThickSolid::BRepOffsetAPI_MakeThickSolid()* - constructor with parameters has been deleted.
* *BRepOffsetAPI_MakeThickSolid::MakeThickSolidByJoin()* - method has been added. This method is old algorithm behaviour.
The code below shows new calling procedure:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepOffsetAPI_MakeThickSolid BodyMaker;
BodyMaker.MakeThickSolidByJoin(myBody, facesToRemove, -myThickness / 50, 1.e-3);
myBody = BodyMaker.Shape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection upgrade_720_highlight Highlight style
The code example below demonstrates how to read shapes from a storage driver using *StdStorage* class.
-~~~~
+~~~~{.cpp}
// aDriver should be created and opened for reading
Handle(StdStorage_Data) aData;
The following code demonstrates how to write shapes in OCCT 7.2.0 using *StdStorage* class.
-~~~~
+~~~~{.cpp}
// Create a file driver
NCollection_Handle<Storage_BaseDriver> aFileDriver(new FSD_File());
Example of usage:
Case 1 (explicit parameters):
-~~~~
+~~~~{.cpp}
#include <IMeshData_Status.hxx>
#include <IMeshTools_Parameters.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
As aspects for different primitive types have been merged, Graphic3d_Group does no more provide per-type aspect properties.
Existing code relying on old behavior and putting interleaved per-type aspects into single Graphic3d_Group should be updated.
For example, the following pseudo-code will not work anymore, because all *SetGroupPrimitivesAspect* calls will setup the same property:
-~~~~
+~~~~{.cpp}
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->SetGroupPrimitivesAspect (myDrawer->LineAspect()->Aspect()); //!< overrides previous aspect
~~~~
To solve the problem, the code should be modified to either put primitives into dedicated groups (preferred approach), or using *SetPrimitivesAspect* in proper order:
-~~~~
+~~~~{.cpp}
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
As result, the following methods of *Graphic3d_MaterialAspect* class have been removed: SetReflectionMode(), SetReflectionModeOn(), Ambient(), Diffuse(), Emissive(), Specular(), SetAmbient(), SetDiffuse(), SetSpecular(), SetEmissive().
Previously, computation of final value required the following code:
-~~~~
+~~~~{.cpp}
Graphic3d_MaterialAspect theMaterial; Quantity_Color theInteriorColor;
Graphic3d_Vec3 anAmbient (0.0f);
if (theMaterial.ReflectionMode (Graphic3d_TOR_AMBIENT))
~~~~
New code looks like this:
-~~~~
+~~~~{.cpp}
Graphic3d_MaterialAspect theMaterial; Quantity_Color theInteriorColor;
Graphic3d_Vec3 anAmbient = theMaterial.AmbientColor();
if (theMaterial.MaterialType (Graphic3d_MATERIAL_ASPECT)) { anAmbient *= (Graphic3d_Vec3 )theInteriorColor; }
Parameters of *Text* in *Graphic3d_Group* are moved into a new *Graphic3d_Text* class. *AddText* of *Graphic3d_Group* should be used instead of the previous *Text*.
The previous code:
-~~~~
+~~~~{.cpp}
Standard_Real x, y, z;
theAttachmentPoint.Coord(x,y,z);
theGroup->Text (theText,
theAspect->VerticalJustification());
~~~~
should be replaced by the new code:
-~~~~
+~~~~{.cpp}
Handle(Graphic3d_Text) aText = new Graphic3d_Text (theAspect->Height());
aText->SetText (theText.ToExtString());
aText->SetPosition (theAttachmentPoint);
@subsection upgrade_750_Booleans Changes in Boolean operations algorithm
* TreatCompound method has been moved from *BOPAlgo_Tools* to *BOPTools_AlgoTools*. Additionally, the map parameter became optional:
-~~~~
+~~~~{.cpp}
void BOPTools_AlgoTools::TreatCompound (const TopoDS_Shape& theS,
TopTools_ListOfShape& theLS,
TopTools_MapOfShape* theMap = NULL);
The code that used operator << for messenger, should be ported as follows.
Before the change:
-~~~~~
+~~~~{.cpp}
Handle(Message_Messenger) theMessenger = ...;
theMessenger << "Value = " << anInteger << Message_EndLine;
-~~~~~
+~~~~
After the change, single-line variant:
-~~~~~
+~~~~{.cpp}
Handle(Message_Messenger) theMessenger = ...;
theMessenger->SendInfo() << "Value = " << anInteger << std::endl;
-~~~~~
+~~~~
After the change, extended variant:
-~~~~~
+~~~~{.cpp}
Handle(Message_Messenger) theMessenger = ...;
Message_Messenger::StreamBuffer aSender = theMessenger->SendInfo();
aSender << "Array: [ ";
for (int i = 0; i < aNb; ++i) { aSender << anArray[i] << " "; }
aSender << "]" << std::endl; // aSender can be used further for other messages
-~~~~~
+~~~~
@subsection upgrade_750_message_printer Message_Printer interface change
Note that neither *TDataStd_Application* nor *TDocStd_Document* is protected from concurrent access from several threads.
Such protection, if necessary, shall be implemented on the application level.
For an example, access to labels and attributes could be protected by mutex if there is a probability that different threads access the same labels / attributes:
-~~~~~
+~~~~{.cpp}
{
Standard_Mutex::Sentry aSentry (myMainLabelAccess);
TDF_Label aChildLab = aDocument->Main().NewChild();
TDataStd_Integer::Set(aChildLab, 0);
}
-~~~~~
+~~~~
@subsection upgrade_750_draw_hotkeys Draw Harness hotkeys
Geom_RectangularTrimmedSurface sequentially trimming in U and V directions already no longer loses the first trim.
For example:
-~~~~~
+~~~~{.cpp}
Handle(Geom_RectangularTrimmedSurface) ST = new Geom_RectangularTrimmedSurface (Sbase, u1, u2, Standard_True); // trim along U
Handle(Geom_RectangularTrimmedSurface) ST1 = new Geom_RectangularTrimmedSurface (ST, v1, v2, Standard_False); // trim along V
-~~~~~
+~~~~
gives different result.
In current version ST1 - surface trimmed only along V, U trim is removed;
After modification ST1 - surface trimmed along U and V, U trim is kept.
This document is a reference manual. It contains a full description of each command. All descriptions have the format illustrated below for the exit command.
-~~~~~
+~~~~{.php}
exit
-~~~~~
+~~~~
Terminates the Draw, TCL session. If the commands are read from a file using the source command, this will terminate the file.
**Example:**
-~~~~~
+~~~~{.php}
# this is a very short example
exit
-~~~~~
+~~~~
@subsection occt_draw_1_3 Getting started
Each key defines a sequence of either further (nested) keys or a name of the dynamic library. Keys can be nested down to an arbitrary level. However, cyclic dependencies between the keys are not checked.
**Example:** (excerpt from DrawPlugin):
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~
OCAF : VISUALIZATION, OCAFKERNEL
VISUALIZATION : AISV
OCAFKERNEL : DCAF
DCAF : TKDCAF
AISV : TKViewerTest
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_1_3_3 Activation of commands implemented in the plug-in
To load a plug-in declared in the resource file and to activate the commands the following command must be used in Test Harness:
-~~~~~
+~~~~{.php}
pload [-PluginFileName] [[Key1] [Key2]...]
-~~~~~
+~~~~
-where:
+Where:
* <i>-PluginFileName</i> -- defines the name of a plug-in resource file (prefix "-" is mandatory) described above. If this parameter is omitted then the default name *DrawPlugin* is used.
* *Key* -- defines the key(s) enumerating plug-ins to be loaded. If no keys are specified then the key named *DEFAULT* is used (if there is no such key in the file then no plug-ins are loaded).
According to the OCCT resource file management rules, to access the resource file the environment variable *CSF_PluginFileNameDefaults* (and optionally *CSF_PluginFileNameUserDefaults*) must be set and point to the directory storing the resource file. If it is omitted then the plug-in resource file will be searched in the <i>$CASROOT/src/DrawResources</i> directory.
-~~~~~
+~~~~{.php}
Draw[] pload -DrawPlugin OCAF
-~~~~~
+~~~~
This command will search the resource file *DrawPlugin* using variable *CSF_DrawPluginDefaults* (and *CSF_DrawPluginUserDefaults*) and will start with the OCAF key. Since the *DrawPlugin* is the file shipped with Open CASCADE Technology it will be found in the <i>$CASROOT/src/DrawResources</i> directory (unless this location is redefined by user's variables). The OCAF key will be recursively extracted into two toolkits/plug-ins: *TKDCAF* and *TKViewerTest* (e.g. on Windows they correspond to *TKDCAF.dll* and *TKViewerTest.dll*). Thus, commands implemented for Visualization and OCAF will be loaded and activated in Test Harness.
-~~~~~
+~~~~{.php}
Draw[] pload (equivalent to pload -DrawPlugin DEFAULT).
-~~~~~
+~~~~
This command will find the default DrawPlugin file and the DEFAULT key. The latter finally maps to the TKTopTest toolkit which implements basic modeling commands.
The basic program for TCL is a script. A script consists of one or more commands. Commands are separated by new lines or semicolons.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
set a 24
set b 15
set a 25; set b 15
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Each command consists of one or more *words*; the first word is the name of a command and additional words are arguments to that command.
Variable substitution is triggered by the $ character (as with csh), the content of the variable is substituted; { } may be used as in csh to enclose the name of the variable.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# set a variable value
set file documentation
puts $file #to display file contents on the screen
# a last one,
# delete files NEWdocumentation and OLDdocumentation
foreach prefix {NEW OLD} {rm $prefix$file}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Command substitution is triggered by the [ ] characters. The brackets must enclose a valid script. The script is evaluated and the result is substituted.
Compare command construction in csh.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
set degree 30
set pi 3.14159265
# expr is a command evaluating a numeric expression
set radian [expr $pi*$degree/180]
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Backslash substitution is triggered by the backslash character. It is used to insert special characters like $, [ , ] , etc. It is also useful to insert a new line, a backslash terminated line is continued on the following line.
Double quote *quoting* enables the definition of a string with space and tabs as a single word. Substitutions are still performed inside the inverted commas " ".
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# set msg to ;the price is 12.00;
set price 12.00
set msg ;the price is $price;
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Braces *quoting* prevents all substitutions. Braces are also nested. The main use of braces is to defer evaluation when defining procedures and control structures. Braces are used for a clearer presentation of TCL scripts on several lines.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
set x 0
# this will loop for ever
# because while argument is ;0 < 3;
{
set x [expr $x+1]
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Comments start with a \# character as the first non-blank character in a command. To add a comment at the end of the line, the comment must be preceded by a semi-colon to end the preceding command.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# This is a comment
set a 1 # this is not a comment
set b 1; # this is a comment
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The number of words is never changed by substitution when parsing in TCL. For example, the result of a substitution is always a single word. This is different from csh but convenient as the behavior of the parser is more predictable. It may sometimes be necessary to force a second round of parsing. **eval** accomplishes this: it accepts several arguments, concatenates them and executes the resulting script.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~{.php}
# I want to delete two files
set files ;foo bar;
exec rm $files
# a second evaluation will do it
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_draw_2_3 Accessing variables in TCL and Draw
Draw numeric variables can be used within an expression anywhere a Draw command requires a numeric value. The *expr* command is useless in this case as the variables are stored not as strings but as floating point values.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# dset is used for numeric variables
# pi is a predefined Draw variable
dset angle pi/3 radius 10
point p radius*cos(angle) radius*sin(angle) 0
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
It is recommended that you use TCL variables only for strings and Draw for numerals. That way, you will avoid the *expr* command. As a rule, Geometry and Topology require numbers but no strings.
@subsubsection occt_draw_2_3_1 set, unset
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
set varname [value]
unset varname [varname varname ...]
-~~~~~
+~~~~
*set* assigns a string value to a variable. If the variable does not already exist, it is created.
*unset* deletes variables. It is also used to delete Draw variables.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
set a "Hello world"
set b "Goodbye"
set a
== "Hello world"
unset a b
set a
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
**Note**, that the *set* command can set only one variable, unlike the *dset* command.
Syntax
-~~~~~
+~~~~{.php}
dset var1 value1 vr2 value2 ...
dval name
-~~~~~
+~~~~
*dset* assigns values to Draw numeric variables. The argument can be any numeric expression including Draw numeric variables. Since all Draw commands expect a numeric expression, there is no need to use $ or *expr*. The *dset* command can assign several variables. If there is an odd number of arguments, the last variable will be assigned a value of 0. If the variable does not exist, it will be created.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# z is set to 0
dset x 10 y 15 z
== 0
# "puts" prints a string
puts ;x = [dval x], cos(x/pi) = [dval cos(x/pi)];
== x = 10, cos(x/pi) = -0.99913874099467914
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
**Note,** that in TCL, parentheses are not considered to be special characters. Do not forget to quote an expression if it contains spaces in order to avoid parsing different words. <i>(a + b)</i> is parsed as three words: <i>"(a + b)"</i> or <i>(a+b)</i> are correct.
@subsubsection occt_draw_2_3_3 del, dall
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
del varname_pattern [varname_pattern ...]
dall
-~~~~~
+~~~~
*del* command does the same thing as *unset*, but it deletes the variables matched by the pattern.
This allows you to insert lists within lists.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# a list of 3 strings
;a b c;
# a list of two strings the first is a list of 2
;{a b} c;
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Many TCL commands return lists and **foreach** is a useful way to create loops on list elements.
Syntax
-~~~~~
+~~~~{.php}
if condition script [elseif script .... else script]
-~~~~~
+~~~~
**If** evaluates the condition and the script to see whether the condition is true.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
if {$x > 0} {
puts ;positive;
} elseif {$x == 0} {
} else {
puts ;negative;
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_2_5_2 while, for, foreach
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
while condition script
for init condition reinit script
foreach varname list script
-~~~~~
+~~~~
The three loop structures are similar to their C or csh equivalent. It is important to use braces to delay evaluation. **foreach** will assign the elements of the list to the variable before evaluating the script. \
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# while example
dset x 1.1
while {[dval x] < 100} {
}
# foreach example
foreach object {crapo tomson lucas} {display $object}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_2_5_3 break, continue
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
break
continue
-~~~~~
+~~~~
Within loops, the **break** and **continue** commands have the same effect as in C.
**break** interrupts the innermost loop and **continue** jumps to the next iteration.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# search the index for which t$i has value ;secret;
for {set i 1} {$i <= 100} {incr i} {
if {[set t$i] == ;secret;} break;
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_draw_2_6 Procedures
Syntax:
-~~~~~
+~~~~{.php}
proc argumentlist script
-~~~~~
+~~~~
**proc** defines a procedure. An argument may have a default value. It is then a list of the form {argument value}. The script is the body of the procedure.
**return** gives a return value to the procedure.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# simple procedure
proc hello {} {
puts ;hello world;
return [expr n*[fact [expr n -1]]]
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_2_6_2 global, upvar
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
global varname [varname ...]
upvar varname localname [varname localname ...]
-~~~~~
+~~~~
**global** accesses high level variables. Unlike C, global variables are not visible in procedures.
**Note** that in the following examples the \$ character is always necessarily used to access the arguments.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# convert degree to radian
# pi is a global variable
proc deg2rad (degree} {
upvar linename l
line l $x $y cos($angle) sin($angle)
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section occt_draw_3 Basic Commands
@subsubsection occt_draw_3_1_1 help
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
help [command [helpstring group]]
-~~~~~
+~~~~
Provides help or modifies the help information.
Specifying the command returns its syntax and in some cases, information on the command, The joker \* is automatically added at the end so that all completing commands are returned as well.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# Gives help on all commands starting with *a*
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_3_1_2 source
Syntax:
-~~~~~
+~~~~{.php}
source filename
-~~~~~
+~~~~
Executes a file.
The **exit** command will terminate the file.
@subsubsection occt_draw_3_1_3 spy
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
spy [filename]
-~~~~~
+~~~~
Saves interactive commands in the file. If spying has already been performed, the current file is closed. **spy** without an argument closes the current file and stops spying. If a file already exists, the file is overwritten. Commands are not appended.
The file created by **spy** can be executed with the **source** command.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# all commands will be saved in the file ;session;
spy session
# the file ;session; is closed and commands are not saved
spy
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_3_1_4 cpulimit
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
cpulimit [nbseconds]
-~~~~~
+~~~~
**cpulimit**limits a process after the number of seconds specified in nbseconds. It is used in tests to avoid infinite loops. **cpulimit** without arguments removes all existing limits.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
#limit cpu to one hour
cpulimit 3600
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_3_1_5 wait
Syntax:
-~~~~~
+~~~~{.php}
wait [nbseconds]
-~~~~~
+~~~~
Suspends execution for the number of seconds specified in *nbseconds*. The default value is ten (10) seconds. This is a useful command for a slide show.
-~~~~~
+~~~~{.php}
# You have ten seconds ...
wait
-~~~~~
+~~~~
@subsubsection occt_draw_3_1_6 chrono
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
chrono [ name start/stop/reset/show/restart/[counter text]]
-~~~~~
+~~~~
Without arguments, **chrono** activates Draw chronometers. The elapsed time ,cpu system and cpu user times for each command will be printed.
* display the current time with specified text (output example - *COUNTER text: N*), command <i>testdiff</i> will compare such outputs between two test runs (counter).
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
chrono
==Chronometers activated.
ptorus t 20 5
==Elapsed time: 0 Hours 0 Minutes 0.0318 Seconds
==CPU user time: 0.01 seconds
==CPU system time: 0 seconds
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_draw_3_2 Variable management commands
@subsubsection occt_draw_3_2_1 isdraw, directory
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
isdraw varname
directory [pattern]
-~~~~~
+~~~~
**isdraw** tests to see if a variable is a Draw variable. **isdraw** will return 1 if there is a Draw value attached to the variable.
Use **directory** to return a list of all Draw global variables matching a pattern.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
set a 1
isdraw a
=== 0
# to destroy all Draw objects with name containing curve
foreach var [directory *curve*] {unset $var}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_3_2_2 whatis, dump
Syntax:
-~~~~~
+~~~~{.php}
whatis varname [varname ...]
dump varname [varname ...]
-~~~~~
+~~~~
**whatis** returns short information about a Draw variable. This is usually the type name.
**dump** returns a brief type description, the coordinates, and if need be, the parameters of a Draw variable.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
circle c 0 0 1 0 5
whatis c
c is a 2d curve
XAxis :1, 0
YAxis :-0, 1
Radius :5
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
**Note** The behavior of *whatis* on other variables (not Draw) is not excellent.
@subsubsection occt_draw_3_2_3 renamevar, copy
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
renamevar varname tovarname [varname tovarname ...]
copy varname tovarname [varname tovarname ...]
-~~~~~
+~~~~
* **renamevar** changes the name of a Draw variable. The original variable will no longer exist. Note that the content is not modified. Only the name is changed.
* **copy** creates a new variable with a copy of the content of an existing variable. The exact behavior of **copy** is type dependent; in the case of certain topological variables, the content may still be shared.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
circle c1 0 0 1 0 5
renamevar c1 c2
# curves are copied, c2 will not be modified
copy c2 c3
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_3_2_4 datadir, save, restore
Syntax:
-~~~~~
+~~~~{.php}
datadir [directory]
save variable [filename]
restore filename [variablename]
-~~~~~
+~~~~
* **datadir** without arguments prints the path of the current data directory.
* **datadir** with an argument sets the data directory path. \
The exact content of the file is type-dependent. They are usually ASCII files and so, architecture independent.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# note how TCL accesses shell environment variables
# using $env()
datadir
restore theBox
== theBox
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_draw_3_3 User defined commands
#### In *DrawTrSurf* package:
-~~~~~
+~~~~{.php}
void Set(Standard_CString& Name,const gp_Pnt& G) ;
void Set(Standard_CString& Name,const gp_Pnt2d& G) ;
void Set(Standard_CString& Name,
const Handle(Poly_Polygon3D)& P) ;
void Set(Standard_CString& Name,
const Handle(Poly_Polygon2D)& P) ;
-~~~~~
+~~~~
#### In *DBRep* package:
-~~~~~
+~~~~{.php}
void Set(const Standard_CString Name,
const TopoDS_Shape& S) ;
-~~~~~
+~~~~
Example of *DrawTrSurf*
-~~~~~
+~~~~{.php}
Handle(Geom2d_Circle) C1 = new Geom2d_Circle
(gce_MakeCirc2d (gp_Pnt2d(50,0,) 25));
DrawTrSurf::Set(char*, C1);
-~~~~~
+~~~~
Example of *DBRep*
-~~~~~
+~~~~{.php}
TopoDS_Solid B;
B = BRepPrimAPI_MakeBox (10,10,10);
DBRep::Set(char*,B);
-~~~~~
+~~~~
@subsubsection occt_draw_3_3_2 get
#### In *DrawTrSurf* package:
-~~~~~
+~~~~{.php}
Handle_Geom_Geometry Get(Standard_CString& Name) ;
-~~~~~
+~~~~
#### In *DBRep* package:
-~~~~~
+~~~~{.php}
TopoDS_Shape Get(Standard_CString& Name,
const TopAbs_ShapeEnum Typ = TopAbs_SHAPE,
const Standard_Boolean Complain
= Standard_True) ;
-~~~~~
+~~~~
Example of *DrawTrSurf*
-~~~~~
+~~~~{.php}
Standard_Integer MyCommand
(Draw_Interpretor& theCommands,
Standard_Integer argc, char** argv)
// name
Handle (Geom_Geometry) aGeom= DrawTrSurf::Get(argv[1]);
}
-~~~~~
+~~~~
Example of *DBRep*
-~~~~~
+~~~~{.php}
Standard_Integer MyCommand
(Draw_Interpretor& theCommands,
Standard_Integer argc, char** argv)
// name
TopoDS_Solid B = DBRep::Get(argv[1]);
}
-~~~~~
+~~~~
@section occt_draw_4 Graphic Commands
@subsubsection occt_draw_4_1_1 view, delete
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
view index type [X Y W H]
delete [index]
-~~~~~
+~~~~
**view** is the basic view creation command: it creates a new view with the given index. If a view with this index already exits, it is deleted. The view is created with default parameters and X Y W H are the position and dimensions of the window on the screen. Default values are 0, 0, 500, 500.
The index, the type, the current zoom are displayed in the window title .
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# this is the content of the mu4 procedure
proc mu4 {} {
delete
view 3 +Y+Z 728 20 400 400
view 4 AXON 728 450 400 400
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
See also: **axo, pers, top, bottom, left, right, front, back, mu4, v2d, av2d, smallview**
@subsubsection occt_draw_4_1_2 axo, pers, top, ...
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
axo
pers
...
smallview type
-~~~~~
+~~~~
All these commands are procedures used to define standard screen layout. They delete all existing views and create new ones. The layout usually complies with the European convention, i.e. a top view is under a front view.
Syntax:
-~~~~~
+~~~~{.php}
mu [index] value
2dmu [index] value
zoom [index] value
wzoom
-~~~~~
+~~~~
* **mu** (magnify up) increases the zoom in one or several views by a factor of 10%.
* **md** (magnify down) decreases the zoom by the inverse factor. **2dmu** and **2dmd**
* **wzoom** (window zoom) allows you to select the area you want to zoom in on with the mouse. You will be prompted to give two of the corners of the area that you want to magnify and the rectangle so defined will occupy the window of the view.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# set a zoom of 2.5
zoom 2.5
mu 1
# magnify by 20%
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
See also: **fit**, **2dfit**
@subsubsection occt_draw_4_14 pu, pd, pl, pr, 2dpu, 2dpd, 2dpl, 2dpr
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
pu [index]
pd [index]
-~~~~~
+~~~~
The <i>p_</i> commands are used to pan. **pu** and **pd** pan up and down respectively; **pl** and **pr** pan to the left and to the right respectively. Each time the view is displaced by 40 pixels. When no index is given, all views will pan in the direction specified.
-~~~~~
+~~~~{.php}
# you have selected one anonometric view
pu
# or
# you have selected an mu4 view; the object in the third view will pan up
pu 3
-~~~~~
+~~~~
See also: **fit**, **2dfit**
@subsubsection occt_draw_4_1_5 fit, 2dfit
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
fit [index]
2dfit [index]
-~~~~~
+~~~~
**fit** computes the best zoom and pans on the content of the view. The content of the view will be centered and fit the whole window.
When fitting all views a unique zoom is computed for all the views. All views are on the same scale.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# fit only view 1
fit 1
# fit all 2d views
2dfit
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
See also: **zoom**, **mu**, **pu**
@subsubsection occt_draw_4_1_6 u, d, l, r
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
u [index]
d [index]
l [index]
r [index]
-~~~~~
+~~~~
**u**, **d**, **l**, **r** Rotate the object in view around its axis by five degrees up, down, left or right respectively. This command is restricted to axonometric and perspective views.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# rotate the view up
u
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_4_1_7 focal, fu, fd
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
focal [f]
fu [index]
fd [index]
-~~~~~
+~~~~
* **focal** changes the vantage point in perspective views. A low f value increases the perspective effect; a high one give a perspective similar to that of an axonometric view. The default value is 500.
* **fu** and **fd** increase or decrease the focal value by 10%. **fd** makes the eye closer to the object.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
pers
repeat 10 fd
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
**Note**: Do not use a negative or null focal value.
@subsubsection occt_draw_4_1_8 color
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
color index name
-~~~~~
+~~~~
**color** sets the color to a value. The index of the *color* is a value between 0 and 15. The name is an X window color name. The list of these can be found in the file *rgb.txt* in the X library directory.
The default values are: 0 White, 1 Red, 2 Green, 3 Blue, 4 Cyan, 5 Gold, 6 Magenta, 7 Marron, 8 Orange, 9 Pink, 10 Salmon, 11 Violet, 12 Yellow, 13 Khaki, 14 Coral.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# change the value of blue
color 3 "navy blue"
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
**Note** that the color change will be visible on the next redraw of the views, for example, after *fit* or *mu*, etc.
@subsubsection occt_draw_4_1_9 dtext
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
dtext [x y [z]] string
-~~~~~
+~~~~
**dtext** displays a string in all 3d or 2d views. If no coordinates are given, a graphic selection is required. If two coordinates are given, the text is created in a 2d view at the position specified. With 3 coordinates, the text is created in a 3d view.
The coordinates are real space coordinates.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# mark the origins
dtext 0 0 bebop
dtext 0 0 0 bebop
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_4_1_10 hardcopy, hcolor, xwd
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
hardcopy [index]
hcolor index width gray
xwd [index] filename
-~~~~~
+~~~~
* **hardcopy** creates a postcript file called a4.ps in the current directory. This file contains the postscript description of the view index, and will allow you to print the view.
* **hcolor** lets you change the aspect of lines in the postscript file. It allows to specify a width and a gray level for one of the 16 colors. **width** is measured in points with default value as 1, **gray** is the gray level from 0 = black to 1 = white with default value as 0. All colors are bound to the default values at the beginning.
* **xwd** creates an X window xwd file from an active view. By default, the index is set to1. To visualize an xwd file, use the unix command **xwud**.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# all blue lines (color 3)
# will be half-width and gray
hcolor 3 0.5
# make an xwd file and display it
xwd theview
xwud -in theview
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
**Note:** When more than one view is present, specify the index of the view.
@subsubsection occt_draw_4_1_11 wclick, pick
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
wclick
pick index X Y Z b [nowait]
-~~~~~
+~~~~
**wclick** defers an event until the mouse button is clicked. The message <code>just click</code> is displayed.
**Note** that the results are stored in Draw numeric variables.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# make a circle at mouse location
pick index x y z b
circle c x y z 0 0 1 1 0 0 0 30
circle c x y z 0 0 1 1 0 0 0 30
repaint
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
See also: **repaint**
* If you do not see what you expected while executing loops or sourcing files, use the **repaint** and **dflush** commands.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# OK use dot to dump an object on the screen
dump .
# give a name to a graphic object
renamevar . x
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_4_1_12 autodisplay
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
autodisplay [0/1]
-~~~~~
+~~~~
By default, Draw automatically displays any graphic object as soon as it is created. This behavior known as autodisplay can be removed with the command **autodisplay**. Without arguments, **autodisplay** toggles the autodisplay mode. The command always returns the current mode.
When **autodisplay** is off, using the dot return argument is ineffective.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# c is displayed
circle c 0 0 1 0 5
# c is erased, but not displayed
display c
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_4_1_13 display, donly
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
display varname [varname ...]
donly varname [varname ...]
-~~~~~
+~~~~
* **display** makes objects visible.
* **donly** *display only* makes objects visible and erases all other objects. It is very useful to extract one object from a messy screen.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
\# to see all objects
foreach var [directory] {display $var}
\# to select two objects and erase the other ones
donly . .
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_4_1_14 erase, clear, 2dclear
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
erase [varname varname ...]
clear
2dclear
-~~~~~
+~~~~
**erase** removes objects from all views. **erase** without arguments erases everything in 2d and 3d.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
# erase eveerything with a name starting with c_
foreach var [directory c_*] {erase $var}
# clear 2d views
2dclear
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_4_1_14_1 disp, don, era
These commands have the same meaning as correspondingly display, donly and erase, but with the difference that they evaluate the arguments using glob pattern rules.
For example, to display all objects with names d_1, d_2, d_3, etc. it is enough to run the command:
-~~~~~{.cpp}
+~~~~{.php}
disp d_*
-~~~~~
+~~~~
@subsubsection occt_draw_4_1_15 repaint, dflush
Syntax:
-~~~~~
+~~~~{.php}
repaint
dflush
-~~~~~
+~~~~
* **repaint** forces repainting of views.
* **dflush** flushes the graphic buffers.
@subsubsection occt_draw_4_2_1 vinit
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vinit
-~~~~~
+~~~~
Creates a new View window with the specified *view_name*.
By default the view is created in the viewer and in the graphic driver shared with the active view.
-~~~~
+~~~~{.php}
name = {driverName/viewerName/viewName | viewerName/viewName | viewName}
~~~~
@subsubsection occt_draw_4_2_2 vhelp
Syntax:
-~~~~~
+~~~~{.php}
vhelp
-~~~~~
+~~~~
Displays help in the 3D viewer window. The help consists in a list of hotkeys and their functionalities.
@subsubsection occt_draw_4_2_3 vtop
Syntax:
-~~~~~
+~~~~{.php}
vtop
-~~~~~
+~~~~
Displays top view in the 3D viewer window. Orientation +X+Y.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
vinit
box b 10 10 10
vdisplay b
vfit
vtop
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_4_2_4 vaxo
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vaxo
-~~~~~
+~~~~
Displays axonometric view in the 3D viewer window. Orientation +X-Y+Z.
**Example:**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.php}
vinit
box b 10 10 10
vdisplay b
vfit
vaxo
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_draw_4_2_5 vsetbg
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vsetbg imagefile [filltype]
-~~~~~
+~~~~
Loads image file as background. *filltype* must be NONE, CENTERED, TILED or STRETCH.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vsetbg myimage.brep CENTERED
-~~~~~
+~~~~
@subsubsection occt_draw_4_2_6 vclear
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vclear
-~~~~~
+~~~~
Removes all objects from the viewer.
@subsubsection occt_draw_4_2_7 vrepaint
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vrepaint
-~~~~~
+~~~~
Forcibly redisplays the shape in the 3D viewer window.
@subsubsection occt_draw_4_2_8 vfit
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vfit
-~~~~~
+~~~~
Automatic zoom/panning. Objects in the view are visualized to occupy the maximum surface.
@subsubsection occt_draw_4_2_9 vzfit
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vzfit
-~~~~~
+~~~~
Automatic depth panning. Objects in the view are visualized to occupy the maximum 3d space.
@subsubsection occt_draw_4_2_10 vreadpixel
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vreadpixel xPixel yPixel [{rgb|rgba|depth|hls|rgbf|rgbaf}=rgba] [name]
-~~~~~
+~~~~
Read pixel value for active view.
@subsubsection occt_draw_4_2_11 vselect
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vselect x1 y1 [x2 y2 [x3 y3 ... xn yn]] [-allowoverlap 0|1] [shift_selection = 0|1]
-~~~~~
+~~~~
Emulates different types of selection:
@subsubsection occt_draw_4_2_12 vmoveto
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
vmoveto x y
-~~~~~
+~~~~
Emulates cursor movement to pixel position (x,y).
@subsubsection occt_draw_4_2_13 vviewparams
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vviewparams [-scale [s]] [-eye [x y z]] [-at [x y z]] [-up [x y z]] [-proj [x y z]] [-center x y] [-size sx]
-~~~~~
+~~~~
Gets or sets the current view parameters.
* If called without arguments, all view parameters are printed.
* The options are:
@subsubsection occt_draw_4_2_14 vchangeselected
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vchangeselected shape
-~~~~~
+~~~~
Adds a shape to selection or removes one from it.
@subsubsection occt_draw_4_2_16 vnbselected
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vnbselected
-~~~~~
+~~~~
Returns the number of selected objects in the interactive context.
@subsubsection occt_draw_4_2_19 vhlr
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vhlr is_enabled={on|off} [show_hidden={1|0}]
-~~~~~
+~~~~
Hidden line removal algorithm:
* <i>is_enabled</i> applies HLR algorithm.
* <i>show_hidden</i> if equals to 1, hidden lines are drawn as dotted ones.
@subsubsection occt_draw_4_2_20 vhlrtype
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vhlrtype algo_type={algo|polyalgo} [shape_1 ... shape_n]
-~~~~~
+~~~~
Changes the type of HLR algorithm used for shapes.
If the algo_type is algo, the exact HLR algorithm is used, otherwise the polygonal algorithm is used for defined shapes.
@subsubsection occt_draw_4_2_21 vcamera
Syntax:
-~~~~~
+~~~~{.php}
vcamera [-ortho] [-projtype]
[-persp]
[-fovy [Angle]] [-distance [Distance]]
[-stereo] [-leftEye] [-rightEye]
[-iod [Distance]] [-iodType [absolute|relative]]
[-zfocus [Value]] [-zfocusType [absolute|relative]]
-~~~~~
+~~~~
Manages camera parameters.
Prints the current value when the option is called without argument.
* -zfocusType -- focus type, absolute or relative.
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 10 10 10
vdisplay b
vfit
vcamera -persp
-~~~~~
+~~~~
@subsubsection occt_draw_4_2_22 vstereo
Syntax:
-~~~~~
+~~~~{.php}
vstereo [0|1] [-mode Mode] [-reverse {0|1}] [-anaglyph Filter]
-~~~~~
+~~~~
Defines the stereo output mode. The following modes are available:
* quadBuffer -- OpenGL QuadBuffer stereo, requires driver support. Should be called BEFORE *vinit*!
* redCyan, redCyanSimple, yellowBlue, yellowBlueSimple, greenMagentaSimple.
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 10 10 10
vdisplay b
vcamera -stereo -iod 1
vcamera -lefteye
vcamera -righteye
-~~~~~
+~~~~
@subsubsection occt_draw_4_2_23 vfrustumculling
Syntax:
-~~~~~
+~~~~{.php}
vfrustumculling [toEnable]
-~~~~~
+~~~~
Enables/disables objects clipping.
@subsubsection occt_draw_4_3_1 vdisplay
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vdisplay [-noupdate|-update] [-local] [-mutable] [-neutral]
[-trsfPers {pan|zoom|rotate|trihedron|full|none}=none] [-trsfPersPos X Y [Z]] [-3d|-2d|-2dTopDown]
[-dispMode mode] [-highMode mode]
[-layer index] [-top|-topmost|-overlay|-underlay]
[-redisplay]
name1 [name2] ... [name n]
-~~~~~
+~~~~
Displays named objects.
Option <i>-local</i> enables display of objects in the local selection context.
* *redisplay* recomputes presentation of objects.
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 40 40 40 10 10 10
psphere s 20
vdisplay s b
vfit
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_2 vdonly
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vdonly [-noupdate|-update] [name1] ... [name n]
-~~~~~
+~~~~
Displays only selected or named objects. If there are no selected or named objects, nothing is done.
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 40 40 40 10 10 10
psphere s 20
vdonly b
vfit
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_3 vdisplayall
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vdisplayall [-local]
-~~~~~
+~~~~
Displays all erased interactive objects (see vdir and vstate).
Option <i>-local</i> enables displaying objects in the local selection context.
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 40 40 40 10 10 10
psphere s 20
vdisplayall
vfit
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_4 verase
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
verase [name1] [name2] … [name n]
-~~~~~
+~~~~
Erases some selected or named objects. If there are no selected or named objects, the whole viewer is erased.
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b1 40 40 40 10 10 10
box b2 -40 -40 -40 10 10 10
verase b1
# erase second box and sphere
verase
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_5 veraseall
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
veraseall
-~~~~~
+~~~~
Erases all objects displayed in the viewer.
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b1 40 40 40 10 10 10
box b2 -40 -40 -40 10 10 10
verase b1
# erase second box and sphere
verseall
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_6 vsetdispmode
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vsetdispmode [name] mode(0,1,2,3)
-~~~~~
+~~~~
Sets display mode for all, selected or named objects.
* *0* (*WireFrame*),
* *3* (*Exact HideLineremoval*).
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 10 10 10
vdisplay b
vsetdispmode 1
vfit
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_7 vdisplaytype
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vdisplaytype type
-~~~~~
+~~~~
Displays all objects of a given type.
The following types are possible: *Point*, *Axis*, *Trihedron*, *PlaneTrihedron*, *Line*, *Circle*, *Plane*, *Shape*, *ConnectedShape*, *MultiConn.Shape*, *ConnectedInter.*, *MultiConn.*, *Constraint* and *Dimension*.
@subsubsection occt_draw_4_3_8 verasetype
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
verasetype type
-~~~~~
+~~~~
Erases all objects of a given type.
Possible type is *Point*, *Axis*, *Trihedron*, *PlaneTrihedron*, *Line*, *Circle*, *Plane*, *Shape*, *ConnectedShape*, *MultiConn.Shape*, *ConnectedInter.*, *MultiConn.*, *Constraint* and *Dimension*.
@subsubsection occt_draw_4_3_9 vtypes
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vtypes
-~~~~~
+~~~~
Makes a list of known types and signatures in AIS.
@subsubsection occt_draw_4_3_10 vaspects
Syntax:
-~~~~~
+~~~~{.php}
vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults]
[-setVisibility 0|1]
[-setColor ColorName] [-setcolor R G B] [-unsetColor]
[-isoontriangulation 0|1]
[-setMaxParamValue {value}]
-~~~~~
+~~~~
Manages presentation properties of all, selected or named objects.
* *-subshapes* -- assigns presentation properties to the specified sub-shapes.
If *-defaults* option is used there should not be any names of objects and *-subshapes* specifier.
Aliases:
-~~~~~
+~~~~{.php}
vsetcolor [-noupdate|-update] [name] ColorName
-~~~~~
+~~~~
Manages presentation properties (color, material, transparency) of all objects, selected or named.
**Color**. The *ColorName* can be: *BLACK*, *MATRAGRAY*, *MATRABLUE*, *ALICEBLUE*, *ANTIQUEWHITE*, *ANTIQUEWHITE1*, *ANTIQUEWHITE2*, *ANTIQUEWHITE3*, *ANTIQUEWHITE4*, *AQUAMARINE1*, *AQUAMARINE2*, *AQUAMARINE4*, *AZURE*, *AZURE2*, *AZURE3*, *AZURE4*, *BEIGE*, *BISQUE*, *BISQUE2*, *BISQUE3*, *BISQUE4*, *BLANCHEDALMOND*, *BLUE1*, *BLUE2*, *BLUE3*, *BLUE4*, *BLUEVIOLET*, *BROWN*, *BROWN1*, *BROWN2*, *BROWN3*, *BROWN4*, *BURLYWOOD*, *BURLYWOOD1*, *BURLYWOOD2*, *BURLYWOOD3*, *BURLYWOOD4*, *CADETBLUE*, *CADETBLUE1*, *CADETBLUE2*, *CADETBLUE3*, *CADETBLUE4*, *CHARTREUSE*, *CHARTREUSE1*, *CHARTREUSE2*, *CHARTREUSE3*, *CHARTREUSE4*, *CHOCOLATE*, *CHOCOLATE1*, *CHOCOLATE2*, *CHOCOLATE3*, *CHOCOLATE4*, *CORAL*, *CORAL1*, *CORAL2*, *CORAL3*, *CORAL4*, *CORNFLOWERBLUE*, *CORNSILK1*, *CORNSILK2*, *CORNSILK3*, *CORNSILK4*, *CYAN1*, *CYAN2*, *CYAN3*, *CYAN4*, *DARKGOLDENROD*, *DARKGOLDENROD1*, *DARKGOLDENROD2*, *DARKGOLDENROD3*, *DARKGOLDENROD4*, *DARKGREEN*, *DARKKHAKI*, *DARKOLIVEGREEN*, *DARKOLIVEGREEN1*, *DARKOLIVEGREEN2*, *DARKOLIVEGREEN3*, *DARKOLIVEGREEN4*, *DARKORANGE*, *DARKORANGE1*, *DARKORANGE2*, *DARKORANGE3*, *DARKORANGE4*, *DARKORCHID*, *DARKORCHID1*, *DARKORCHID2*, *DARKORCHID3*, *DARKORCHID4*, *DARKSALMON*, *DARKSEAGREEN*, *DARKSEAGREEN1*, *DARKSEAGREEN2*, *DARKSEAGREEN3*, *DARKSEAGREEN4*, *DARKSLATEBLUE*, *DARKSLATEGRAY1*, *DARKSLATEGRAY2*, *DARKSLATEGRAY3*, *DARKSLATEGRAY4*, *DARKSLATEGRAY*, *DARKTURQUOISE*, *DARKVIOLET*, *DEEPPINK*, *DEEPPINK2*, *DEEPPINK3*, *DEEPPINK4*, *DEEPSKYBLUE1*, *DEEPSKYBLUE2*, *DEEPSKYBLUE3*, *DEEPSKYBLUE4*, *DODGERBLUE1*, *DODGERBLUE2*, *DODGERBLUE3*, *DODGERBLUE4*, *FIREBRICK*, *FIREBRICK1*, *FIREBRICK2*, *FIREBRICK3*, *FIREBRICK4*, *FLORALWHITE*, *FORESTGREEN*, *GAINSBORO*, *GHOSTWHITE*, *GOLD*, *GOLD1*, *GOLD2*, *GOLD3*, *GOLD4*, *GOLDENROD*, *GOLDENROD1*, *GOLDENROD2*, *GOLDENROD3*, *GOLDENROD4*, *GRAY*, *GRAY0*, *GRAY1*, *GRAY10*, *GRAY11*, *GRAY12*, *GRAY13*, *GRAY14*, *GRAY15*, *GRAY16*, *GRAY17*, *GRAY18*, *GRAY19*, *GRAY2*, *GRAY20*, *GRAY21*, *GRAY22*, *GRAY23*, *GRAY24*, *GRAY25*, *GRAY26*, *GRAY27*, *GRAY28*, *GRAY29*, *GRAY3*, *GRAY30*, *GRAY31*, *GRAY32*, *GRAY33*, *GRAY34*, *GRAY35*, *GRAY36*, *GRAY37*, *GRAY38*, *GRAY39*, *GRAY4*, *GRAY40*, *GRAY41*, *GRAY42*, *GRAY43*, *GRAY44*, *GRAY45*, *GRAY46*, *GRAY47*, *GRAY48*, *GRAY49*, *GRAY5*, *GRAY50*, *GRAY51*, *GRAY52*, *GRAY53*, *GRAY54*, *GRAY55*, *GRAY56*, *GRAY57*, *GRAY58*, *GRAY59*, *GRAY6*, *GRAY60*, *GRAY61*, *GRAY62*, *GRAY63*, *GRAY64*, *GRAY65*, *GRAY66*, *GRAY67*, *GRAY68*, *GRAY69*, *GRAY7*, *GRAY70*, *GRAY71*, *GRAY72*, *GRAY73*, *GRAY74*, *GRAY75*, *GRAY76*, *GRAY77*, *GRAY78*, *GRAY79*, *GRAY8*, *GRAY80*, *GRAY81*, *GRAY82*, *GRAY83*, *GRAY85*, *GRAY86*, *GRAY87*, *GRAY88*, *GRAY89*, *GRAY9*, *GRAY90*, *GRAY91*, *GRAY92*, *GRAY93*, *GRAY94*, *GRAY95*, *GREEN*, *GREEN1*, *GREEN2*, *GREEN3*, *GREEN4*, *GREENYELLOW*, *GRAY97*, *GRAY98*, *GRAY99*, *HONEYDEW*, *HONEYDEW2*, *HONEYDEW3*, *HONEYDEW4*, *HOTPINK*, *HOTPINK1*, *HOTPINK2*, *HOTPINK3*, *HOTPINK4*, *INDIANRED*, *INDIANRED1*, *INDIANRED2*, *INDIANRED3*, *INDIANRED4*, *IVORY*, *IVORY2*, *IVORY3*, *IVORY4*, *KHAKI*, *KHAKI1*, *KHAKI2*, *KHAKI3*, *KHAKI4*, *LAVENDER*, *LAVENDERBLUSH1*, *LAVENDERBLUSH2*, *LAVENDERBLUSH3*, *LAVENDERBLUSH4*, *LAWNGREEN*, *LEMONCHIFFON1*, *LEMONCHIFFON2*, *LEMONCHIFFON3*, *LEMONCHIFFON4*, *LIGHTBLUE*, *LIGHTBLUE1*, *LIGHTBLUE2*, *LIGHTBLUE3*, *LIGHTBLUE4*, *LIGHTCORAL*, *LIGHTCYAN1*, *LIGHTCYAN2*, *LIGHTCYAN3*, *LIGHTCYAN4*, *LIGHTGOLDENROD*, *LIGHTGOLDENROD1*, *LIGHTGOLDENROD2*, *LIGHTGOLDENROD3*, *LIGHTGOLDENROD4*, *LIGHTGOLDENRODYELLOW*, *LIGHTGRAY*, *LIGHTPINK*, *LIGHTPINK1*, *LIGHTPINK2*, *LIGHTPINK3*, *LIGHTPINK4*, *LIGHTSALMON1*, *LIGHTSALMON2*, *LIGHTSALMON3*, *LIGHTSALMON4*, *LIGHTSEAGREEN*, *LIGHTSKYBLUE*, *LIGHTSKYBLUE1*, *LIGHTSKYBLUE2*, *LIGHTSKYBLUE3*, *LIGHTSKYBLUE4*, *LIGHTSLATEBLUE*, *LIGHTSLATEGRAY*, *LIGHTSTEELBLUE*, *LIGHTSTEELBLUE1*, *LIGHTSTEELBLUE2*, *LIGHTSTEELBLUE3*, *LIGHTSTEELBLUE4*, *LIGHTYELLOW*, *LIGHTYELLOW2*, *LIGHTYELLOW3*, *LIGHTYELLOW4*, *LIMEGREEN*, *LINEN*, *MAGENTA1*, *MAGENTA2*, *MAGENTA3*, *MAGENTA4*, *MAROON*, *MAROON1*, *MAROON2*, *MAROON3*, *MAROON4*, *MEDIUMAQUAMARINE*, *MEDIUMORCHID*, *MEDIUMORCHID1*, *MEDIUMORCHID2*, *MEDIUMORCHID3*, *MEDIUMORCHID4*, *MEDIUMPURPLE*, *MEDIUMPURPLE1*, *MEDIUMPURPLE2*, *MEDIUMPURPLE3*, *MEDIUMPURPLE4*, *MEDIUMSEAGREEN*, *MEDIUMSLATEBLUE*, *MEDIUMSPRINGGREEN*, *MEDIUMTURQUOISE*, *MEDIUMVIOLETRED*, *MIDNIGHTBLUE*, *MINTCREAM*, *MISTYROSE*, *MISTYROSE2*, *MISTYROSE3*, *MISTYROSE4*, *MOCCASIN*, *NAVAJOWHITE1*, *NAVAJOWHITE2*, *NAVAJOWHITE3*, *NAVAJOWHITE4*, *NAVYBLUE*, *OLDLACE*, *OLIVEDRAB*, *OLIVEDRAB1*, *OLIVEDRAB2*, *OLIVEDRAB3*, *OLIVEDRAB4*, *ORANGE*, *ORANGE1*, *ORANGE2*, *ORANGE3*, *ORANGE4*, *ORANGERED*, *ORANGERED1*, *ORANGERED2*, *ORANGERED3*, *ORANGERED4*, *ORCHID*, *ORCHID1*, *ORCHID2*, *ORCHID3*, *ORCHID4*, *PALEGOLDENROD*, *PALEGREEN*, *PALEGREEN1*, *PALEGREEN2*, *PALEGREEN3*, *PALEGREEN4*, *PALETURQUOISE*, *PALETURQUOISE1*, *PALETURQUOISE2*, *PALETURQUOISE3*, *PALETURQUOISE4*, *PALEVIOLETRED*, *PALEVIOLETRED1*, *PALEVIOLETRED2*, *PALEVIOLETRED3*, *PALEVIOLETRED4*, *PAPAYAWHIP*, *PEACHPUFF*, *PEACHPUFF2*, *PEACHPUFF3*, *PEACHPUFF4*, *PERU*, *PINK*, *PINK1*, *PINK2*, *PINK3*, *PINK4*, *PLUM*, *PLUM1*, *PLUM2*, *PLUM3*, *PLUM4*, *POWDERBLUE*, *PURPLE*, *PURPLE1*, *PURPLE2*, *PURPLE3*, *PURPLE4*, *RED*, *RED1*, *RED2*, *RED3*, *RED4*, *ROSYBROWN*, *ROSYBROWN1*, *ROSYBROWN2*, *ROSYBROWN3*, *ROSYBROWN4*, *ROYALBLUE*, *ROYALBLUE1*, *ROYALBLUE2*, *ROYALBLUE3*, *ROYALBLUE4*, *SADDLEBROWN*, *SALMON*, *SALMON1*, *SALMON2*, *SALMON3*, *SALMON4*, *SANDYBROWN*, *SEAGREEN*, *SEAGREEN1*, *SEAGREEN2*, *SEAGREEN3*, *SEAGREEN4*, *SEASHELL*, *SEASHELL2*, *SEASHELL3*, *SEASHELL4*, *BEET*, *TEAL*, *SIENNA*, *SIENNA1*, *SIENNA2*, *SIENNA3*, *SIENNA4*, *SKYBLUE*, *SKYBLUE1*, *SKYBLUE2*, *SKYBLUE3*, *SKYBLUE4*, *SLATEBLUE*, *SLATEBLUE1*, *SLATEBLUE2*, *SLATEBLUE3*, *SLATEBLUE4*, *SLATEGRAY1*, *SLATEGRAY2*, *SLATEGRAY3*, *SLATEGRAY4*, *SLATEGRAY*, *SNOW*, *SNOW2*, *SNOW3*, *SNOW4*, *SPRINGGREEN*, *SPRINGGREEN2*, *SPRINGGREEN3*, *SPRINGGREEN4*, *STEELBLUE*, *STEELBLUE1*, *STEELBLUE2*, *STEELBLUE3*, *STEELBLUE4*, *TAN*, *TAN1*, *TAN2*, *TAN3*, *TAN4*, *THISTLE*, *THISTLE1*, *THISTLE2*, *THISTLE3*, *THISTLE4*, *TOMATO*, *TOMATO1*, *TOMATO2*, *TOMATO3*, *TOMATO4*, *TURQUOISE*, *TURQUOISE1*, *TURQUOISE2*, *TURQUOISE3*, *TURQUOISE4*, *VIOLET*, *VIOLETRED*, *VIOLETRED1*, *VIOLETRED2*, *VIOLETRED3*, *VIOLETRED4*, *WHEAT*, *WHEAT1*, *WHEAT2*, *WHEAT3*, *WHEAT4*, *WHITE*, *WHITESMOKE*, *YELLOW*, *YELLOW1*, *YELLOW2*, *YELLOW3*, *YELLOW4* and *YELLOWGREEN*.
-~~~~~
+~~~~{.php}
vaspects [name] [-setcolor ColorName] [-setcolor R G B] [-unsetcolor]
vsetcolor [name] ColorName
vunsetcolor [name]
-~~~~~
+~~~~
**Transparency. The *Transp* may be between 0.0 (opaque) and 1.0 (fully transparent).
**Warning**: at 1.0 the shape becomes invisible.
-~~~~~
+~~~~{.php}
vaspects [name] [-settransparency Transp] [-unsettransparency]
vsettransparency [name] Transp
vunsettransparency [name]
-~~~~~
+~~~~
**Material**. The *MatName* can be *BRASS*, *BRONZE*, *COPPER*, *GOLD*, *PEWTER*, *PLASTER*, *PLASTIC*, *SILVER*, *STEEL*, *STONE*, *SHINY_PLASTIC*, *SATIN*, *METALIZED*, *NEON_GNC*, *CHROME*, *ALUMINIUM*, *OBSIDIAN*, *NEON_PHC*, *JADE*, *WATER*, *GLASS*, *DIAMOND* or *CHARCOAL*.
-~~~~~
+~~~~{.php}
vaspects [name] [-setmaterial MatName] [-unsetmaterial]
vsetmaterial [name] MatName
vunsetmaterial [name]
-~~~~~
+~~~~
**Line width**. Specifies width of the edges. The *LineWidth* may be between 0.0 and 10.0.
-~~~~~
+~~~~{.php}
vaspects [name] [-setwidth LineWidth] [-unsetwidth]
vsetwidth [name] LineWidth
vunsetwidth [name]
-~~~~~
+~~~~
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 10 10 10
vdisplay b
vsetdispmode b 1
vaspects -setcolor red -settransparency 0.2
vrotate 10 10 10
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_11 vsetshading
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vsetshading shapename [coefficient]
-~~~~~
+~~~~
Sets deflection coefficient that defines the quality of the shape’s representation in the shading mode. Default coefficient is 0.0008.
**Example:**
-~~~~~
+~~~~{.php}
vinit
psphere s 20
vdisplay s
vfit
vsetdispmode 1
vsetshading s 0.005
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_12 vunsetshading
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vunsetshading [shapename]
-~~~~~
+~~~~
Sets default deflection coefficient (0.0008) that defines the quality of the shape’s representation in the shading mode.
@subsubsection occt_draw_4_3_13 vsetam
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vsetam [shapename] mode
-~~~~~
+~~~~
Activates selection mode for all selected or named shapes:
* *0* for *shape* itself,
* *7* (*compounds*).
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 10 10 10
vdisplay b
vfit
vsetam b 2
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_14 vunsetam
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vunsetam
-~~~~~
+~~~~
Deactivates all selection modes for all shapes.
@subsubsection occt_draw_4_3_15 vdump
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vdump <filename>.{png|bmp|jpg|gif} [-width Width -height Height]
[-buffer rgb|rgba|depth=rgb]
[-stereo mono|left|right|blend|sideBySide|overUnder=mono]
-~~~~~
+~~~~
Extracts the contents of the viewer window to a image file.
@subsubsection occt_draw_4_3_16 vdir
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vdir
-~~~~~
+~~~~
Displays the list of displayed objects.
@subsubsection occt_draw_4_3_17 vsub
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vsub 0/1(on/off)[shapename]
-~~~~~
+~~~~
Hilights/unhilights named or selected objects which are displayed at neutral state with subintensity color.
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 10 10 10
psphere s 20
vfit
vsetdispmode 1
vsub b 1
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_20 vsensdis
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vsensdis
-~~~~~
+~~~~
Displays active entities (sensitive entities of one of the standard types corresponding to active selection modes).
@subsubsection occt_draw_4_3_21 vsensera
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vsensera
-~~~~~
+~~~~
Erases active entities.
@subsubsection occt_draw_4_3_23 vr
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vr filename
-~~~~~
+~~~~
Reads shape from BREP-format file and displays it in the viewer.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vr myshape.brep
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_24 vstate
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vstate [-entities] [-hasSelected] [name1] ... [nameN]
-~~~~~
+~~~~
Reports show/hidden state for selected or named objects:
* *entities* -- prints low-level information about detected entities;
@subsubsection occt_draw_4_3_25 vraytrace
Syntax:
-~~~~~
+~~~~{.php}
vraytrace [0/1]
-~~~~~
+~~~~
Turns on/off ray tracing renderer.
@subsubsection occt_draw_4_3_26 vrenderparams
Syntax:
-~~~~~
+~~~~{.php}
vrenderparams [-rayTrace|-raster] [-rayDepth 0..10] [-shadows {on|off}]
[-reflections {on|off}] [-fsaa {on|off}] [-gleam {on|off}]
[-gi {on|off}] [-brng {on|off}] [-env {on|off}]
[-shadin {color|flat|gouraud|phong}]
-~~~~~
+~~~~
Manages rendering parameters:
* rayTrace -- Enables GPU ray-tracing
The command is intended to control presentation quality depending on hardware capabilities and performance.
**Example:**
-~~~~~
+~~~~{.php}
vinit
box b 10 10 10
vdisplay b
vfit
vraytrace 1
vrenderparams -shadows 1 -reflections 1 -fsaa 1
-~~~~~
+~~~~
@subsubsection occt_draw_4_3_27 vshaderprog
Syntax:
-~~~~~
+~~~~{.php}
'vshaderprog [name] pathToVertexShader pathToFragmentShader'
or 'vshaderprog [name] off' to disable GLSL program
or 'vshaderprog [name] phong' to enable per-pixel lighting calculations
-~~~~~
+~~~~
Enables rendering using a shader program.
@subsubsection occt_draw_4_3_28 vsetcolorbg
Syntax:
-~~~~~
+~~~~{.php}
vsetcolorbg r g b
-~~~~~
+~~~~
Sets background color.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vsetcolorbg 200 0 200
-~~~~~
+~~~~
@subsection occt_draw_4_4 AIS viewer -- object commands
@subsubsection occt_draw_4_4_1 vtrihedron
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vtrihedron name [-dispMode {wf|sh|wireframe|shading}]
[-origin x y z ]
[-zaxis u v w -xaxis u v w ]
|YArrow|ZArrow|XOYAxis|YOZAxis"
|XOZAxis|Whole} value]
-~~~~~
+~~~~
Creates a new *AIS_Trihedron* object or changes existing trihedron. If no argument is set, the default trihedron (0XYZ) is created.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vtrihedron tr1
vtrihedron t2 -color XAxis Quantity_NOC_RED
vtrihedron t2 -color YAxis Quantity_NOC_GREEN
vtrihedron t2 -color ZAxis|Origin Quantity_NOC_BLUE1
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_2 vplanetri
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vplanetri name
-~~~~~
+~~~~
Creates a plane from a trihedron selection. If no arguments are set, the default plane is created.
@subsubsection occt_draw_4_4_3 vsize
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vsize [name] [size]
-~~~~~
+~~~~
Changes the size of a named or selected trihedron. If the name is not defined: it affects the selected trihedrons otherwise nothing is done. If the value is not defined, it is set to 100 by default.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vtrihedron tr1
vtrihedron tr2 0 0 0 1 0 0 1 0 0
vsize tr2 400
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_4 vaxis
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vaxis name [Xa Ya Za Xb Yb Zb]
-~~~~~
+~~~~
Creates an axis. If the values are not defined, an axis is created by interactive selection of two vertices or one edge
**Example:**
-~~~~~
+~~~~{.php}
vinit
vtrihedron tr
vaxis axe1 0 0 0 1 0 0
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_5 vaxispara
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vaxispara name
-~~~~~
+~~~~
Creates an axis by interactive selection of an edge and a vertex.
@subsubsection occt_draw_4_4_6 vaxisortho
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vaxisotrho name
-~~~~~
+~~~~
Creates an axis by interactive selection of an edge and a vertex. The axis will be orthogonal to the selected edge.
@subsubsection occt_draw_4_4_7 vpoint
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vpoint name [Xa Ya Za]
-~~~~~
+~~~~
Creates a point from coordinates. If the values are not defined, a point is created by interactive selection of a vertice or an edge (in the center of the edge).
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p 0 0 0
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_8 vplane
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vplane name [AxisName] [PointName]
vplane name [PointName] [PointName] [PointName]
vplane name [PlaneName] [PointName]
-~~~~~
+~~~~
Creates a plane from named or interactively selected entities.
TypeOfSensitivity:
* 1 -- Boundary
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p1 0 50 0
vaxis axe1 0 0 0 0 0 1
vtrihedron tr
vplane plane1 axe1 p1
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_9 vplanepara
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vplanepara name
-~~~~~
+~~~~
Creates a plane from interactively selected vertex and face.
@subsubsection occt_draw_4_4_10 vplaneortho
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vplaneortho name
-~~~~~
+~~~~
Creates a plane from interactive selected face and coplanar edge.
@subsubsection occt_draw_4_4_11 vline
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vline name [PointName] [PointName]
vline name [Xa Ya Za Xb Yb Zb]
-~~~~~
+~~~~
Creates a line from coordinates, named or interactively selected vertices.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vtrihedron tr
vpoint p1 0 50 0
vpoint p2 50 0 0
vline line1 p1 p2
vline line2 0 0 0 50 0 1
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_12 vcircle
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vcircle name [PointName PointName PointName IsFilled]
vcircle name [PlaneName PointName Radius IsFilled]
-~~~~~
+~~~~
Creates a circle from named or interactively selected entities. Parameter IsFilled is defined as 0 or 1.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vtrihedron tr
vpoint p1 0 50 0
vpoint p2 50 0 0
vpoint p3 0 0 0
vcircle circle1 p1 p2 p3 1
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_13 vtri2d
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vtri2d name
-~~~~~
+~~~~
Creates a plane with a 2D trihedron from an interactively selected face.
@subsubsection occt_draw_4_4_14 vselmode
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vselmode [object] mode_number is_turned_on=(1|0)
-~~~~~
+~~~~
Sets the selection mode for an object. If the object value is not defined, the selection mode is set for all displayed objects.
*Mode_number* is a non-negative integer encoding different interactive object classes.
* 0 if mode is to be switched off
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p1 0 0 0
vpoint p2 50 0 0
vpoint p3 25 40 0
vtriangle triangle1 p1 p2 p3
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_15 vconnect
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vconnect vconnect name Xo Yo Zo object1 object2 ... [color=NAME]
-~~~~~
+~~~~
Creates *AIS_ConnectedInteractive* object from the input object and location and displays it.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p1 0 0 0
vpoint p2 50 0 0
restore CrankArm.brep obj
vdisplay obj
vconnect new obj 100100100 1 0 0 0 0 1
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_16 vtriangle
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vtriangle name PointName PointName PointName
-~~~~~
+~~~~
Creates and displays a filled triangle from named points.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p1 0 0 0
vpoint p2 50 0 0
vpoint p3 25 40 0
vtriangle triangle1 p1 p2 p3
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_17 vsegment
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vsegment name PointName PointName
-~~~~~
+~~~~
Creates and displays a segment from named points.
**Example:**
-~~~~~
+~~~~{.php}
Vinit
vpoint p1 0 0 0
vpoint p2 50 0 0
vsegment segment p1 p2
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_18 vpointcloud
Syntax:
-~~~~~
+~~~~{.php}
vpointcloud name shape [-randColor] [-normals] [-noNormals]
-~~~~~
+~~~~
Creates an interactive object for an arbitrary set of points from the triangulated shape.
Additional options:
* *normals* -- generates a normal per point (default);
* *noNormals* -- does not generate a normal per point.
-~~~~~
+~~~~{.php}
vpointcloud name x y z r npts {surface|volume} [-randColor] [-normals] [-noNormals]
-~~~~~
+~~~~
Creates an arbitrary set of points (npts) randomly distributed on a spheric surface or within a spheric volume (x y z r).
Additional options:
* *randColor* -- generates a random color per point;
* *noNormals* -- does not generate a normal per point.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpointcloud pc 0 0 0 100 100000 surface -randColor
vfit
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_19 vclipplane
Syntax:
-~~~~~
+~~~~{.php}
vclipplane maxplanes <view_name> -- gets plane limit for the view.
vclipplane create <plane_name> -- creates a new plane.
vclipplane delete <plane_name> -- deletes a plane.
vclipplane change <plane_name> capping texorigin <tx> <ty> -- sets texture origin.
vclipplane change <plane_name> capping texrotate <angle> -- sets texture rotation.
vclipplane change <plane_name> capping hatch on/off/<id> -- sets hatching mask.
-~~~~~
+~~~~
Manages clipping planes
**Example:**
-~~~~~
+~~~~{.php}
vinit
vclipplane create pln1
vclipplane change pln1 equation 1 0 0 -0.1
vfit
vrotate 10 10 10
vselect 100 100
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_20 vdimension
Syntax:
-~~~~~
+~~~~{.php}
vdimension name {-angle|-length|-radius|-diameter} -shapes shape1 [shape2 [shape3]]
[-text 3d|2d wf|sh|wireframe|shading IntegerSize]
[-label left|right|hcenter|hfit top|bottom|vcenter|vfit]
[-autovalue] [-value CustomRealValue] [-textvalue CustomTextValue]
[-dispunits DisplayUnitsString]
[-modelunits ModelUnitsString] [-showunits | -hideunits]
-~~~~~
+~~~~
Builds angle, length, radius or diameter dimension interactive object **name**.
**Attention:** length dimension can't be built without working plane.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p1 0 0 0
vpoint p2 50 50 0
vcircle circle p1 p2 p3 0
vdimension dim3 -radius -shapes circle
vfit
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_21 vdimparam
Syntax:
-~~~~~
+~~~~{.php}
vdimparam name [-text 3d|2d wf|sh|wireframe|shading IntegerSize]
[-label left|right|hcenter|hfit top|bottom|vcenter|vfit]
[-arrow external|internal|fit]
[-dispunits DisplayUnitsString]
[-modelunits ModelUnitsString]
[-showunits | -hideunits]
-~~~~~
+~~~~
Sets parameters for angle, length, radius and diameter dimension **name**.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p1 0 0 0
vpoint p2 50 50 0
vfit
vdimparam dim1 -textvalue "w_1"
vdimparam dim1 -autovalue
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_22 vangleparam
Syntax:
-~~~~~
+~~~~{.php}
vangleparam name [-type interior|exterior]
[-showarrow first|second|both|none]
-~~~~~
+~~~~
Sets parameters for angle dimension **name**.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p1 0 0 0
vpoint p2 10 0 0
vdimension dim1 -angle -plane xoy -shapes p1 p2 p3
vfit
vangleparam dim1 -type exterior -showarrow first
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_23 vlengthparam
Syntax:
-~~~~~
+~~~~{.php}
vlengthparam name [-type interior|exterior]
[-showarrow first|second|both|none]
-~~~~~
+~~~~
Sets parameters for length dimension **name**.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p1 20 20 0
vpoint p2 80 80 0
vfit
vzoom 0.5
vlengthparam dim1 -direction ox
-~~~~~
+~~~~
@subsubsection occt_draw_4_4_24 vmovedim
Syntax:
-~~~~~
+~~~~{.php}
vmovedim [name] [x y z]
-~~~~~
+~~~~
Moves picked or named (if **name** parameter is defined) dimension
to picked mouse position or input point with coordinates **x**,**y**,**z**.
are adjusted.
**Example:**
-~~~~~
+~~~~{.php}
vinit
vpoint p1 0 0 0
vpoint p2 50 50 0
vdimension dim1 -length -plane xoy -shapes p1 p2
vmovedim dim1 -10 30 0
-~~~~~
+~~~~
@subsection occt_draw_4_5 AIS viewer -- Mesh Visualization Service
@subsubsection occt_draw_4_5_1 meshfromstl
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshfromstl meshname file
-~~~~~
+~~~~
Creates a *MeshVS_Mesh* object based on STL file data. The object will be displayed immediately.
**Example:**
-~~~~~
+~~~~{.php}
meshfromstl mesh myfile.stl
-~~~~~
+~~~~
@subsubsection occt_draw_4_5_2 meshdispmode
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshdispmode meshname displaymode
-~~~~~
+~~~~
Changes the display mode of object **meshname**. The **displaymode** is integer, which can be:
* *1* for *wireframe*,
* *3* for *shrink* mode.
**Example:**
-~~~~~
+~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshdispmode mesh 2
-~~~~~
+~~~~
@subsubsection occt_draw_4_5_3 meshselmode
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshselmode meshname selectionmode
-~~~~~
+~~~~
Changes the selection mode of object **meshname**. The *selectionmode* is integer OR-combination of mode flags. The basic flags are the following:
* *1* -- node selection;
* *8* -- faces.
**Example:**
-~~~~~
+~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshselmode mesh 1
-~~~~~
+~~~~
@subsubsection occt_draw_4_5_4 meshshadcolor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshshadcolor meshname red green blue
-~~~~~
+~~~~
Changes the face interior color of object **meshname**. The *red*, *green* and *blue* are real values between *0* and *1*.
**Example:**
-~~~~~
+~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshshadcolormode mesh 0.5 0.5 0.5
-~~~~~
+~~~~
@subsubsection occt_draw_4_5_5 meshlinkcolor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshlinkcolor meshname red green blue
-~~~~~
+~~~~
Changes the color of face borders for object **meshname**. The *red*, *green* and *blue* are real values between *0* and *1*.
**Example:**
-~~~~~
+~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshlinkcolormode mesh 0.5 0.5 0.5
-~~~~~
+~~~~
@subsubsection occt_draw_4_5_6 meshmat
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshmat meshname material
-~~~~~
+~~~~
Changes the material of object **meshname**.
* *20 -- UserDefined*
**Example:**
-~~~~~
+~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshmat mesh JADE
-~~~~~
+~~~~
@subsubsection occt_draw_4_5_7 meshshrcoef
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshshrcoef meshname shrinkcoefficient
-~~~~~
+~~~~
Changes the value of shrink coefficient used in the shrink mode. In the shrink mode the face is shown as a congruent part of a usual face, so that *shrinkcoefficient* controls the value of this part. The *shrinkcoefficient* is a positive real number.
**Example:**
-~~~~~
+~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshshrcoef mesh 0.05
-~~~~~
+~~~~
@subsubsection occt_draw_4_5_8 meshshow
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshshow meshname
-~~~~~
+~~~~
Displays **meshname** in the viewer (if it is erased).
**Example:**
-~~~~~
+~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshshow mesh
-~~~~~
+~~~~
@subsubsection occt_draw_4_5_9 meshhide
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshhide meshname
-~~~~~
+~~~~
Hides **meshname** in the viewer.
**Example:**
-~~~~~
+~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshhide mesh
-~~~~~
+~~~~
@subsubsection occt_draw_4_5_10 meshhidesel
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshhidesel meshname
-~~~~~
+~~~~
Hides only selected entities. The other part of **meshname** remains visible.
@subsubsection occt_draw_4_5_11 meshshowsel
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshshowsel meshname
-~~~~~
+~~~~
Shows only selected entities. The other part of **meshname** becomes invisible.
@subsubsection occt_draw_4_5_12 meshshowall
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshshowall meshname
-~~~~~
+~~~~
Changes the state of all entities to visible for **meshname**.
@subsubsection occt_draw_4_5_13 meshdelete
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
meshdelete meshname
-~~~~~
+~~~~
Deletes MeshVS_Mesh object **meshname**.
**Example:**
-~~~~~
+~~~~{.php}
vinit
meshfromstl mesh myfile.stl
meshdelete mesh
-~~~~~
+~~~~
@subsection occt_draw_4_6 VIS Viewer commands
A specific plugin with alias *VIS* should be loaded to have access to VIS functionality in DRAW Test Harness:
-~~~~
+~~~~{.php}
\> pload VIS
~~~~
@subsubsection occt_draw_4_6_1 ivtkinit
Syntax:
-~~~~~
+~~~~{.php}
ivtkinit
-~~~~~
+~~~~
Creates a window for VTK viewer.
@subsubsection occt_draw_4_6_2 ivtkdisplay
Syntax:
-~~~~~
+~~~~{.php}
ivtkdisplay name1 [name2] …[name n]
-~~~~~
+~~~~
Displays named objects.
**Example:**
-~~~~~
+~~~~{.php}
ivtkinit
# create cone
pcone c 5 0 10
ivtkdisplay c
-~~~~~
+~~~~
@figure{/user_guides/draw_test_harness/images/draw_image002.png,"",261}
@subsubsection occt_draw_4_6_3 ivtkerase
Syntax:
-~~~~~
+~~~~{.php}
ivtkerase [name1] [name2] … [name n]
-~~~~~
+~~~~
Erases named objects. If no arguments are passed, erases all displayed objects.
**Example:**
-~~~~~
+~~~~{.php}
ivtkinit
# create a sphere
psphere s 10
ivtkerase cy
# erase the sphere and the cone
ivtkerase s c
-~~~~~
+~~~~
@subsubsection occt_draw_4_6_4 ivtkfit
Syntax:
-~~~~~
+~~~~{.php}
ivtkfit
-~~~~~
+~~~~
Automatic zoom/panning.
@subsubsection occt_draw_4_6_5 ivtkdispmode
Syntax:
-~~~~~
+~~~~{.php}
ivtksetdispmode [name] {0|1}
-~~~~~
+~~~~
Sets display mode for a named object. If no arguments are passed, sets the given display mode for all displayed objects
The possible modes are: 0 (WireFrame) and 1 (Shading).
**Example:**
-~~~~~
+~~~~{.php}
ivtkinit
# create a cone
pcone c 5 0 10
ivtkdisplay c
# set shading mode for the cone
ivtksetdispmode c 1
-~~~~~
+~~~~
@figure{/user_guides/draw_test_harness/images/draw_image003.png,"",262}
@subsubsection occt_draw_4_6_6 ivtksetselmode
Syntax:
-~~~~~
+~~~~{.php}
ivtksetselmode [name] mode {0|1}
-~~~~~
+~~~~
Sets selection mode for a named object. If no arguments are passed, sets the given selection mode for all the displayed objects.
**Example:**
-~~~~~
+~~~~{.php}
ivtkinit
# load a shape from file
restore CrankArm.brep a
ivtkdisplay a
# set the face selection mode
ivtksetselmode a 4 1
-~~~~~
+~~~~
@figure{/user_guides/draw_test_harness/images/draw_image004.png,"",291}
@subsubsection occt_draw_4_6_7 ivtkmoveto
Syntax:
-~~~~~
+~~~~{.php}
ivtkmoveto x y
-~~~~~
+~~~~
Imitates mouse cursor moving to point with the given display coordinates **x**,**y**.
**Example:**
-~~~~~
+~~~~{.php}
ivtkinit
pcone c 5 0 10
ivtkdisplay c
ivtkmoveto 40 50
-~~~~~
+~~~~
@subsubsection occt_draw_4_6_8 ivtkselect
Syntax:
-~~~~~
+~~~~{.php}
ivtkselect x y
-~~~~~
+~~~~
Imitates mouse cursor moving to point with the given display coordinates and performs selection at this point.
**Example:**
-~~~~~
+~~~~{.php}
ivtkinit
pcone c 5 0 10
ivtkdisplay c
ivtkselect 40 50
-~~~~~
+~~~~
@subsubsection occt_draw_4_6_9 ivtkdump
Syntax:
-~~~~~
+~~~~{.php}
ivtkdump *filename* [buffer={rgb|rgba|depth}] [width height] [stereoproj={L|R}]
-~~~~~
+~~~~
Dumps the contents of VTK viewer to image. It supports:
* dumping in different raster graphics formats: PNG, BMP, JPEG, TIFF or PNM.
* dumping of stereo projections (left or right).
**Example:**
-~~~~~
+~~~~{.php}
ivtkinit
pcone c 5 0 10
ivtkdisplay c
ivtkdump D:/ConeSnapshot.png rgb 768 768
-~~~~~
+~~~~
@subsubsection occt_draw_4_6_10 ivtkbgcolor
Syntax:
-~~~~~
+~~~~{.php}
ivtkbgcolor r g b [r2 g2 b2]
-~~~~~
+~~~~
Sets uniform background color or gradient background if second triple of parameters is set. Color parameters r,g,b have to be chosen in the interval [0..255].
**Example:**
-~~~~~
+~~~~{.php}
ivtkinit
ivtkbgcolor 200 220 250
-~~~~~
+~~~~
@figure{/user_guides/draw_test_harness/images/draw_image005.png,"",196}
-~~~~~
+~~~~{.php}
ivtkbgcolor 10 30 80 255 255 255
-~~~~~
+~~~~
@figure{/user_guides/draw_test_harness/images/draw_image006.png,"",190}
@subsubsection occt_draw_5_1_1 NewDocument
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
NewDocument docname [format]
-~~~~~
+~~~~
Creates a new **docname** document with MDTV-Standard or described format.
**Example:**
-~~~~~
+~~~~{.php}
# Create new document with default (MDTV-Standard) format
NewDocument D
# Create new document with BinOcaf format
NewDocument D2 BinOcaf
-~~~~~
+~~~~
@subsubsection occt_draw_5_1_2 IsInSession
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
IsInSession path
-~~~~~
+~~~~
Returns *0*, if **path** document is managed by the application session, *1* -- otherwise.
**Example:**
-~~~~~
+~~~~{.php}
IsInSession /myPath/myFile.std
-~~~~~
+~~~~
@subsubsection occt_draw_5_1_3 ListDocuments
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ListDocuments
-~~~~~
+~~~~
Makes a list of documents handled during the session of the application.
@subsubsection occt_draw_5_1_4 Open
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
Open path docname [-stream]
-~~~~~
+~~~~
Retrieves the document of file **docname** in the path **path**. Overwrites the document, if it is already in session.
option <i>-stream</i> activates usage of alternative interface of OCAF persistence working with C++ streams instead of file names.
**Example:**
-~~~~~
+~~~~{.php}
Open /myPath/myFile.std D
-~~~~~
+~~~~
@subsubsection occt_draw_5_1_5 Close
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
Close docname
-~~~~~
+~~~~
Closes **docname** document. The document is no longer handled by the applicative session.
**Example:**
-~~~~~
+~~~~{.php}
Close D
-~~~~~
+~~~~
@subsubsection occt_draw_5_1_6 Save
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
Save docname
-~~~~~
+~~~~
Saves **docname** active document.
**Example:**
-~~~~~
+~~~~{.php}
Save D
-~~~~~
+~~~~
@subsubsection occt_draw_5_1_7 SaveAs
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SaveAs docname path [-stream]
-~~~~~
+~~~~
Saves the active document in the file **docname** in the path **path**. Overwrites the file if it already exists.
option <i>-stream</i> activates usage of alternative interface of OCAF persistence working with C++ streams instead of file names.
**Example:**
-~~~~~
+~~~~{.php}
SaveAs D /myPath/myFile.std
-~~~~~
+~~~~
@subsection occt_draw_5_2 Basic commands
@subsubsection occt_draw_5_2_1 Label
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
Label docname entry
-~~~~~
+~~~~
Creates the label expressed by <i>\<entry\></i> if it does not exist.
Example
-~~~~~
+~~~~{.php}
Label D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_2_2 NewChild
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
NewChild docname [taggerlabel = Root label]
-~~~~~
+~~~~
Finds (or creates) a *TagSource* attribute located at father label of <i>\<taggerlabel\></i> and makes a new child label.
Example
-~~~~~
+~~~~{.php}
# Create new child of root label
NewChild D
# Create new child of existing label
Label D 0:2
NewChild D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_2_3 Children
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
Children docname label
-~~~~~
+~~~~
Returns the list of attributes of label.
Example
-~~~~~
+~~~~{.php}
Children D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_2_4 ForgetAll
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ForgetAll docname label
-~~~~~
+~~~~
Forgets all attributes of the label.
Example
-~~~~~
+~~~~{.php}
ForgetAll D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_3 Application commands
@subsubsection occt_draw_5_3_1 Main
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
Main docname
-~~~~~
+~~~~
Returns the main label of the framework.
**Example:**
-~~~~~
+~~~~{.php}
Main D
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_2 UndoLimit
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
UndoLimit docname [value=0]
-~~~~~
+~~~~
Sets the limit on the number of Undo Delta stored. **0** will disable Undo on the document. A negative *value* means that there is no limit. Note that by default Undo is disabled. Enabling it will take effect with the next call to *NewCommand*. Of course, this limit is the same for Redo
**Example:**
-~~~~~
+~~~~{.php}
UndoLimit D 100
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_3 Undo
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
Undo docname [value=1]
-~~~~~
+~~~~
Undoes **value** steps.
**Example:**
-~~~~~
+~~~~{.php}
Undo D
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_4 Redo
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
Redo docname [value=1]
-~~~~~
+~~~~
Redoes **value** steps.
**Example:**
-~~~~~
+~~~~{.php}
Redo D
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_5 OpenCommand
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
OpenCommand docname
-~~~~~
+~~~~
Opens a new command transaction.
**Example:**
-~~~~~
+~~~~{.php}
OpenCommand D
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_6 CommitCommand
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
CommitCommand docname
-~~~~~
+~~~~
Commits the Command transaction.
**Example:**
-~~~~~
+~~~~{.php}
CommitCommand D
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_7 NewCommand
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
NewCommand docname
-~~~~~
+~~~~
This is a shortcut for Commit and Open transaction.
**Example:**
-~~~~~
+~~~~{.php}
NewCommand D
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_8 AbortCommand
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AbortCommand docname
-~~~~~
+~~~~
Aborts the Command transaction.
**Example:**
-~~~~~
+~~~~{.php}
AbortCommand D
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_9 Copy
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
Copy docname entry Xdocname Xentry
-~~~~~
+~~~~
Copies the contents of *entry* to *Xentry*. No links are registered.
**Example:**
-~~~~~
+~~~~{.php}
Copy D1 0:2 D2 0:4
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_10 UpdateLink
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
UpdateLink docname [entry]
-~~~~~
+~~~~
Updates external reference set at *entry*.
**Example:**
-~~~~~
+~~~~{.php}
UpdateLink D
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_11 CopyWithLink
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
CopyWithLink docname entry Xdocname Xentry
-~~~~~
+~~~~
Aborts the Command transaction.
Copies the content of *entry* to *Xentry*. The link is registered with an *Xlink* attribute at *Xentry* label.
**Example:**
-~~~~~
+~~~~{.php}
CopyWithLink D1 0:2 D2 0:4
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_12 UpdateXLinks
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
UpdateXLinks docname entry
-~~~~~
+~~~~
Sets modifications on labels impacted by external references to the *entry*. The *document* becomes invalid and must be recomputed
**Example:**
-~~~~~
+~~~~{.php}
UpdateXLinks D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_3_13 DumpDocument
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
DumpDocument docname
-~~~~~
+~~~~
Displays parameters of *docname* document.
**Example:**
-~~~~~
+~~~~{.php}
DumpDocument D
-~~~~~
+~~~~
@subsection occt_draw_5_4 Data Framework commands
@subsubsection occt_draw_5_4_1 MakeDF
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
MakeDF dfname
-~~~~~
+~~~~
Creates a new data framework.
**Example:**
-~~~~~
+~~~~{.php}
MakeDF D
-~~~~~
+~~~~
@subsubsection occt_draw_5_4_2 ClearDF
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ClearDF dfname
-~~~~~
+~~~~
Clears a data framework.
**Example:**
-~~~~~
+~~~~{.php}
ClearDF D
-~~~~~
+~~~~
@subsubsection occt_draw_5_4_3 CopyDF
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
CopyDF dfname1 entry1 [dfname2] entry2
-~~~~~
+~~~~
Copies a data framework.
**Example:**
-~~~~~
+~~~~{.php}
CopyDF D 0:2 0:4
-~~~~~
+~~~~
@subsubsection occt_draw_5_4_4 CopyLabel
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
CopyLabel dfname fromlabel tolablel
-~~~~~
+~~~~
Copies a label.
**Example:**
-~~~~~
+~~~~{.php}
CopyLabel D1 0:2 0:4
-~~~~~
+~~~~
@subsubsection occt_draw_5_4_5 MiniDumpDF
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
MiniDumpDF dfname
-~~~~~
+~~~~
Makes a mini-dump of a data framework.
**Example:**
-~~~~~
+~~~~{.php}
MiniDumpDF D
-~~~~~
+~~~~
@subsubsection occt_draw_5_4_6 XDumpDF
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XDumpDF dfname
-~~~~~
+~~~~
Makes an extended dump of a data framework.
**Example:**
-~~~~~
+~~~~{.php}
XDumpDF D
-~~~~~
+~~~~
@subsection occt_draw_5_5 General attributes commands
@subsubsection occt_draw_5_5_1 SetInteger
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetInteger dfname entry value
-~~~~~
+~~~~
Finds or creates an Integer attribute at *entry* label and sets *value*.
**Example:**
-~~~~~
+~~~~{.php}
SetInteger D 0:2 100
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_2 GetInteger
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetInteger dfname entry [drawname]
-~~~~~
+~~~~
Gets a value of an Integer attribute at *entry* label and sets it to *drawname* variable, if it is defined.
**Example:**
-~~~~~
+~~~~{.php}
GetInteger D 0:2 Int1
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_3 SetReal
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetReal dfname entry value
-~~~~~
+~~~~
Finds or creates a Real attribute at *entry* label and sets *value*.
**Example:**
-~~~~~
+~~~~{.php}
SetReal D 0:2 100.
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_4 GetReal
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetReal dfname entry [drawname]
-~~~~~
+~~~~
Gets a value of a Real attribute at *entry* label and sets it to *drawname* variable, if it is defined.
**Example:**
-~~~~~
+~~~~{.php}
GetReal D 0:2 Real1
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_5 SetIntArray
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetIntArray dfname entry lower upper value1 value2 …
-~~~~~
+~~~~
Finds or creates an IntegerArray attribute at *entry* label with lower and upper bounds and sets **value1*, *value2*...
**Example:**
-~~~~~
+~~~~{.php}
SetIntArray D 0:2 1 4 100 200 300 400
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_6 GetIntArray
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetIntArray dfname entry
-~~~~~
+~~~~
Gets a value of an *IntegerArray* attribute at *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
GetIntArray D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_7 SetRealArray
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetRealArray dfname entry lower upper value1 value2 …
-~~~~~
+~~~~
Finds or creates a RealArray attribute at *entry* label with lower and upper bounds and sets *value1*, *value2*…
**Example:**
-~~~~~
+~~~~{.php}
GetRealArray D 0:2 1 4 100. 200. 300. 400.
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_8 GetRealArray
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetRealArray dfname entry
-~~~~~
+~~~~
Gets a value of a RealArray attribute at *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
GetRealArray D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_9 SetComment
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetComment dfname entry value
-~~~~~
+~~~~
Finds or creates a Comment attribute at *entry* label and sets *value*.
**Example:**
-~~~~~
+~~~~{.php}
SetComment D 0:2 "My comment"
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_10 GetComment
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetComment dfname entry
-~~~~~
+~~~~
Gets a value of a Comment attribute at *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
GetComment D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_11 SetExtStringArray
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetExtStringArray dfname entry lower upper value1 value2 …
-~~~~~
+~~~~
Finds or creates an *ExtStringArray* attribute at *entry* label with lower and upper bounds and sets *value1*, *value2*…
**Example:**
-~~~~~
+~~~~{.php}
SetExtStringArray D 0:2 1 3 *string1* *string2* *string3*
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_12 GetExtStringArray
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetExtStringArray dfname entry
-~~~~~
+~~~~
Gets a value of an ExtStringArray attribute at *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
GetExtStringArray D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_13 SetName
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetName dfname entry value
-~~~~~
+~~~~
Finds or creates a Name attribute at *entry* label and sets *value*.
**Example:**
-~~~~~
+~~~~{.php}
SetName D 0:2 *My name*
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_14 GetName
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetName dfname entry
-~~~~~
+~~~~
Gets a value of a Name attribute at *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
GetName D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_15 SetReference
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetReference dfname entry reference
-~~~~~
+~~~~
Creates a Reference attribute at *entry* label and sets *reference*.
**Example:**
-~~~~~
+~~~~{.php}
SetReference D 0:2 0:4
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_16 GetReference
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetReference dfname entry
-~~~~~
+~~~~
Gets a value of a Reference attribute at *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
GetReference D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_17 SetUAttribute
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetUAttribute dfname entry localGUID
-~~~~~
+~~~~
Creates a UAttribute attribute at *entry* label with *localGUID*.
**Example:**
-~~~~~
+~~~~{.php}
set localGUID "c73bd076-22ee-11d2-acde-080009dc4422"
SetUAttribute D 0:2 ${localGUID}
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_18 GetUAttribute
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetUAttribute dfname entry loacalGUID
-~~~~~
+~~~~
Finds a *UAttribute* at *entry* label with *localGUID*.
**Example:**
-~~~~~
+~~~~{.php}
set localGUID "c73bd076-22ee-11d2-acde-080009dc4422"
GetUAttribute D 0:2 ${localGUID}
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_19 SetFunction
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetFunction dfname entry ID failure
-~~~~~
+~~~~
Finds or creates a *Function* attribute at *entry* label with driver ID and *failure* index.
**Example:**
-~~~~~
+~~~~{.php}
set ID "c73bd076-22ee-11d2-acde-080009dc4422"
SetFunction D 0:2 ${ID} 1
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_20 GetFunction
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetFunction dfname entry ID failure
-~~~~~
+~~~~
Finds a Function attribute at *entry* label and sets driver ID to *ID* variable and failure index to *failure* variable.
**Example:**
-~~~~~
+~~~~{.php}
GetFunction D 0:2 ID failure
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_21 NewShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
NewShape dfname entry [shape]
-~~~~~
+~~~~
Finds or creates a Shape attribute at *entry* label. Creates or updates the associated *NamedShape* attribute by *shape* if *shape* is defined.
**Example:**
-~~~~~
+~~~~{.php}
box b 10 10 10
NewShape D 0:2 b
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_22 SetShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetShape dfname entry shape
-~~~~~
+~~~~
Creates or updates a *NamedShape* attribute at *entry* label by *shape*.
**Example:**
-~~~~~
+~~~~{.php}
box b 10 10 10
SetShape D 0:2 b
-~~~~~
+~~~~
@subsubsection occt_draw_5_5_23 GetShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetShape2 dfname entry shape
-~~~~~
+~~~~
Sets a shape from NamedShape attribute associated with *entry* label to *shape* draw variable.
**Example:**
-~~~~~
+~~~~{.php}
GetShape2 D 0:2 b
-~~~~~
+~~~~
@subsection occt_draw_5_6 Geometric attributes commands
@subsubsection occt_draw_5_6_1 SetPoint
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetPoint dfname entry point
-~~~~~
+~~~~
Finds or creates a Point attribute at *entry* label and sets *point* as generated in the associated *NamedShape* attribute.
**Example:**
-~~~~~
+~~~~{.php}
point p 10 10 10
SetPoint D 0:2 p
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_2 GetPoint
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetPoint dfname entry [drawname]
-~~~~~
+~~~~
Gets a vertex from *NamedShape* attribute at *entry* label and sets it to *drawname* variable, if it is defined.
**Example:**
-~~~~~
+~~~~{.php}
GetPoint D 0:2 p
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_3 SetAxis
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetAxis dfname entry axis
-~~~~~
+~~~~
Finds or creates an Axis attribute at *entry* label and sets *axis* as generated in the associated *NamedShape* attribute.
**Example:**
-~~~~~
+~~~~{.php}
line l 10 20 30 100 200 300
SetAxis D 0:2 l
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_4 GetAxis
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetAxis dfname entry [drawname]
-~~~~~
+~~~~
Gets a line from *NamedShape* attribute at *entry* label and sets it to *drawname* variable, if it is defined.
**Example:**
-~~~~~
+~~~~{.php}
GetAxis D 0:2 l
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_5 SetPlane
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetPlane dfname entry plane
-~~~~~
+~~~~
Finds or creates a Plane attribute at *entry* label and sets *plane* as generated in the associated *NamedShape* attribute.
**Example:**
-~~~~~
+~~~~{.php}
plane pl 10 20 30 -1 0 0
SetPlane D 0:2 pl
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_6 GetPlane
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetPlane dfname entry [drawname]
-~~~~~
+~~~~
Gets a plane from *NamedShape* attribute at *entry* label and sets it to *drawname* variable, if it is defined.
**Example:**
-~~~~~
+~~~~{.php}
GetPlane D 0:2 pl
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_7 SetGeometry
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetGeometry dfname entry [type] [shape]
-~~~~~
+~~~~
Creates a Geometry attribute at *entry* label and sets *type* and *shape* as generated in the associated *NamedShape* attribute if they are defined. *type* must be one of the following: *any, pnt, lin, cir, ell, spl, pln, cyl*.
**Example:**
-~~~~~
+~~~~{.php}
point p 10 10 10
SetGeometry D 0:2 pnt p
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_8 GetGeometryType
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetGeometryType dfname entry
-~~~~~
+~~~~
Gets a geometry type from Geometry attribute at *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
GetGeometryType D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_9 SetConstraint
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetConstraint dfname entry keyword geometrie [geometrie …]
SetConstraint dfname entry "plane" geometrie
SetConstraint dfname entry "value" value
-~~~~~
+~~~~
1. Creates a Constraint attribute at *entry* label and sets *keyword* constraint between geometry(ies).
*keyword* must be one of the following:
3. Sets value for the existing constraint.
**Example:**
-~~~~~
+~~~~{.php}
SetConstraint D 0:2 "value" 5
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_10 GetConstraint
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetConstraint dfname entry
-~~~~~
+~~~~
Dumps a Constraint attribute at *entry* label
**Example:**
-~~~~~
+~~~~{.php}
GetConstraint D 0:2
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_11 SetVariable
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetVariable dfname entry isconstant(0/1) units
-~~~~~
+~~~~
Creates a Variable attribute at *entry* label and sets *isconstant* flag and *units* as a string.
**Example:**
-~~~~~
+~~~~{.php}
SetVariable D 0:2 1 "mm"
-~~~~~
+~~~~
@subsubsection occt_draw_5_6_12 GetVariable
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
GetVariable dfname entry isconstant units
-~~~~~
+~~~~
Gets an *isconstant* flag and units of a Variable attribute at *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
GetVariable D 0:2 isconstant units
puts "IsConstant=${isconstant}"
puts "Units=${units}"
-~~~~~
+~~~~
@subsection occt_draw_5_7 Tree attributes commands
@subsubsection occt_draw_5_7_1 RootNode
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
RootNode dfname treenodeentry [ID]
-~~~~~
+~~~~
Returns the ultimate father of *TreeNode* attribute identified by its *treenodeentry* and its *ID* (or default ID, if *ID* is not defined).
@subsubsection occt_draw_5_7_2 SetNode
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
SetNode dfname treenodeentry [ID]
-~~~~~
+~~~~
Creates a *TreeNode* attribute on the *treenodeentry* label with its tree *ID* (or assigns a default ID, if the *ID* is not defined).
@subsubsection occt_draw_5_7_3 AppendNode
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AppendNode dfname fatherentry childentry [fatherID]
-~~~~~
+~~~~
Inserts a *TreeNode* attribute with its tree *fatherID* (or default ID, if *fatherID* is not defined) on *childentry* as last child of *fatherentry*.
@subsubsection occt_draw_5_7_4 PrependNode
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
PrependNode dfname fatherentry childentry [fatherID]
-~~~~~
+~~~~
Inserts a *TreeNode* attribute with its tree *fatherID* (or default ID, if *fatherID* is not defined) on *childentry* as first child of *fatherentry*.
@subsubsection occt_draw_5_7_5 InsertNodeBefore
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
InsertNodeBefore dfname treenodeentry beforetreenode [ID]
-~~~~~
+~~~~
Inserts a *TreeNode* attribute with tree *ID* (or default ID, if *ID* is not defined) *beforetreenode* before *treenodeentry*.
@subsubsection occt_draw_5_7_6 InsertNodeAfter
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
InsertNodeAfter dfname treenodeentry aftertreenode [ID]
-~~~~~
+~~~~
Inserts a *TreeNode* attribute with tree *ID* (or default ID, if *ID* is not defined) *aftertreenode* after *treenodeentry*.
@subsubsection occt_draw_5_7_7 DetachNode
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
DetachNode dfname treenodeentry [ID]
-~~~~~
+~~~~
Removes a *TreeNode* attribute with tree *ID* (or default ID, if *ID* is not defined) from *treenodeentry*.
@subsubsection occt_draw_5_7_8 ChildNodeIterate
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ChildNodeIterate dfname treenodeentry alllevels(0/1) [ID]
-~~~~~
+~~~~
Iterates on the tree of *TreeNode* attributes with tree *ID* (or default ID, if *ID* is not defined). If *alllevels* is set to *1* it explores not only the first, but all the sub Step levels.
**Example:**
-~~~~~
+~~~~{.php}
Label D 0:2
Label D 0:3
Label D 0:4
==0:7
==0:6
==0:5
-~~~~~
+~~~~
@subsubsection occt_draw_5_7_9 InitChildNodeIterator
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
InitChildNodeIterator dfname treenodeentry alllevels(0/1) [ID]
-~~~~~
+~~~~
Initializes the iteration on the tree of *TreeNode* attributes with tree *ID* (or default ID, if *ID* is not defined). If *alllevels* is set to *1* it explores not only the first, but also all sub Step levels.
**Example:**
-~~~~~
+~~~~{.php}
InitChildNodeIterate D 0:5 1
set aChildNumber 0
for {set i 1} {$i < 100} {incr i} {
}
}
puts "aChildNumber=$aChildNumber"
-~~~~~
+~~~~
@subsubsection occt_draw_5_7_10 ChildNodeMore
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ChildNodeMore
-~~~~~
+~~~~
Returns TRUE if there is a current item in the iteration.
@subsubsection occt_draw_5_7_11 ChildNodeNext
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ChildNodeNext
-~~~~~
+~~~~
Moves to the next Item.
@subsubsection occt_draw_5_7_12 ChildNodeValue
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ChildNodeValue
-~~~~~
+~~~~
Returns the current treenode of *ChildNodeIterator*.
@subsubsection occt_draw_5_7_13 ChildNodeNextBrother
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ChildNodeNextBrother
-~~~~~
+~~~~
Moves to the next *Brother*. If there is none, goes up. This method is interesting only with *allLevels* behavior.
@subsubsection occt_draw_5_8_1 AISInitViewer
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISInitViewer docname
-~~~~~
+~~~~
Creates and sets *AISViewer* attribute at root label, creates AIS viewer window.
**Example:**
-~~~~~
+~~~~{.php}
AISInitViewer D
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_2 AISRepaint
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISRepaint docname
-~~~~~
+~~~~
Updates the AIS viewer window.
**Example:**
-~~~~~
+~~~~{.php}
AISRepaint D
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_3 AISDisplay
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISDisplay docname entry [not_update]
-~~~~~
+~~~~
Displays a presantation of *AISobject* from *entry* label in AIS viewer. If *not_update* is not defined then *AISobject* is recomputed and all visualization settings are applied.
**Example:**
-~~~~~
+~~~~{.php}
AISDisplay D 0:5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_4 AISUpdate
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISUpdate docname entry
-~~~~~
+~~~~
Recomputes a presentation of *AISobject* from *entry* label and applies the visualization setting in AIS viewer.
**Example:**
-~~~~~
+~~~~{.php}
AISUpdate D 0:5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_5 AISErase
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISErase docname entry
-~~~~~
+~~~~
Erases *AISobject* of *entry* label in AIS viewer.
**Example:**
-~~~~~
+~~~~{.php}
AISErase D 0:5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_6 AISRemove
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISRemove docname entry
-~~~~~
+~~~~
Erases *AISobject* of *entry* label in AIS viewer, then *AISobject* is removed from *AIS_InteractiveContext*.
**Example:**
-~~~~~
+~~~~{.php}
AISRemove D 0:5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_7 AISSet
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISSet docname entry ID
-~~~~~
+~~~~
Creates *AISPresentation* attribute at *entry* label and sets as driver ID. ID must be one of the following: *A* (*axis*), *C* (*constraint*), *NS* (*namedshape*), *G* (*geometry*), *PL* (*plane*), *PT* (*point*).
**Example:**
-~~~~~
+~~~~{.php}
AISSet D 0:5 NS
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_8 AISDriver
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISDriver docname entry [ID]
-~~~~~
+~~~~
Returns DriverGUID stored in *AISPresentation* attribute of an *entry* label or sets a new one. ID must be one of the following: *A* (*axis*), *C* (*constraint*), *NS* (*namedshape*), *G* (*geometry*), *PL* (*plane*), *PT* (*point*).
**Example:**
-~~~~~
+~~~~{.php}
# Get Driver GUID
AISDriver D 0:5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_9 AISUnset
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISUnset docname entry
-~~~~~
+~~~~
Deletes *AISPresentation* attribute (if it exists) of an *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
AISUnset D 0:5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_10 AISTransparency
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISTransparency docname entry [transparency]
-~~~~~
+~~~~
Sets (if *transparency* is defined) or gets the value of transparency for *AISPresentation* attribute of an *entry* label.
**Example:**
-~~~~~
+~~~~{.php}
AISTransparency D 0:5 0.5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_11 AISHasOwnTransparency
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISHasOwnTransparency docname entry
-~~~~~
+~~~~
Tests *AISPresentation* attribute of an *entry* label by own transparency.
**Example:**
-~~~~~
+~~~~{.php}
AISHasOwnTransparency D 0:5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_12 AISMaterial
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISMaterial docname entry [material]
-~~~~~
+~~~~
Sets (if *material* is defined) or gets the value of transparency for *AISPresentation* attribute of an *entry* label. *material* is integer from 0 to 20 (see @ref occt_draw_4_5_6 "meshmat" command).
**Example:**
-~~~~~
+~~~~{.php}
AISMaterial D 0:5 5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_13 AISHasOwnMaterial
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISHasOwnMaterial docname entry
-~~~~~
+~~~~
Tests *AISPresentation* attribute of an *entry* label by own material.
**Example:**
-~~~~~
+~~~~{.php}
AISHasOwnMaterial D 0:5
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_14 AISColor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISColor docname entry [color]
-~~~~~
+~~~~
Sets (if *color* is defined) or gets value of color for *AISPresentation* attribute of an *entry* label. *color* is integer from 0 to 516 (see color names in *vsetcolor*).
**Example:**
-~~~~~
+~~~~{.php}
AISColor D 0:5 25
-~~~~~
+~~~~
@subsubsection occt_draw_5_8_15 AISHasOwnColor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
AISHasOwnColor docname entry
-~~~~~
+~~~~
Tests *AISPresentation* attribute of an *entry* label by own color.
**Example:**
-~~~~~
+~~~~{.php}
AISHasOwnColor D 0:5
-~~~~~
+~~~~
@section occt_draw_6 Geometry commands
@subsubsection occt_draw_6_2_1 point
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
point name x y [z]
-~~~~~
+~~~~
Creates a 2d or 3d point, depending on the number of arguments.
**Example:**
-~~~~~
+~~~~{.php}
# 2d point
point p1 1 2
# 3d point
point p2 10 20 -5
-~~~~~
+~~~~
@subsubsection occt_draw_6_2_2 line
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
line name x y [z] dx dy [dz]
-~~~~~
+~~~~
Creates a 2d or 3d line. *x y z* are the coordinates of the line’s point of origin; *dx, dy, dz* give the direction vector.
A 2d line will be represented as *x y dx dy*, and a 3d line as *x y z dx dy dz* . A line is parameterized along its length starting from the point of origin along the direction vector. The direction vector is normalized and must not be null. Lines are infinite, even though their representation is not.
**Example:**
-~~~~~
+~~~~{.php}
# a 2d line at 45 degrees of the X axis
line l 2 0 1 1
# a 3d line through the point 10 0 0 and parallel to Z
line l 10 0 0 0 0 1
-~~~~~
+~~~~
@subsubsection occt_draw_6_2_3 circle
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
circle name x y [z [dx dy dz]] [ux uy [uz]] radius
-~~~~~
+~~~~
Creates a 2d or a 3d circle.
The circle is parameterized by the angle in [0,2*pi] starting from the origin and. Note that the specification of origin direction and plane is the same for all analytical curves and surfaces.
**Example:**
-~~~~~
+~~~~{.php}
# A 2d circle of radius 5 centered at 10,-2
circle c1 10 -2 5
# full 3d circle, axis X, origin on Z
circle c5 10 20 -5 1 0 0 0 0 1 17
-~~~~~
+~~~~
@subsubsection occt_draw_6_2_4 ellipse
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ellipse name x y [z [dx dy dz]] [ux uy [uz]] firstradius secondradius
-~~~~~
+~~~~
Creates a 2d or 3d ellipse. In a 2d ellipse, the first two arguments define the center; in a 3d ellipse, the first three. The axis system is given by *firstradius*, the major radius, and *secondradius*, the minor radius. The parameter range of the ellipse is [0,2.*pi] starting from the X axis and going towards the Y axis. The Draw ellipse is parameterized by an angle:
-~~~~~
+~~~~{.php}
P(u) = O + firstradius*cos(u)*Xdir + secondradius*sin(u)*Ydir
-~~~~~
-where:
+~~~~
+Where:
* P is the point of parameter *u*,
* *O, Xdir* and *Ydir* are respectively the origin, *X Direction* and *Y Direction* of its local coordinate system.
**Example:**
-~~~~~
+~~~~{.php}
# default 2d ellipse
ellipse e1 10 5 20 10
# 3d ellipse in the X,Z plane with axis 1, 0 ,1
ellipse e4 0 0 0 0 1 0 1 0 1 25 5
-~~~~~
+~~~~
@subsubsection occt_draw_6_2_5 hyperbola
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
hyperbola name x y [z [dx dy dz]] [ux uy [uz]] firstradius secondradius
-~~~~~
+~~~~
Creates a 2d or 3d conic. The first arguments define the center. The axis system is given by *firstradius*, the major radius, and *secondradius*, the minor radius. Note that the hyperbola has only one branch, that in the X direction.
The Draw hyperbola is parameterized as follows:
-~~~~~
+~~~~{.php}
P(U) = O + firstradius*Cosh(U)*XDir + secondradius*Sinh(U)*YDir
-~~~~~
-where:
+~~~~
+Where:
* *P* is the point of parameter *U*,
* *O, XDir* and *YDir* are respectively the origin, *X Direction* and *YDirection* of its local coordinate system.
**Example:**
-~~~~~
+~~~~{.php}
# default 2d hyperbola, with asymptotes 1,1 -1,1
hyperbola h1 0 0 30 30
# 3d hyperbola, in the XY plane
hyperbola h3 0 0 0 50 50
-~~~~~
+~~~~
@subsubsection occt_draw_6_2_6 parabola
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
parabola name x y [z [dx dy dz]] [ux uy [uz]] FocalLength
-~~~~~
+~~~~
Creates a 2d or 3d parabola. in the axis system defined by the first arguments. The origin is the apex of the parabola.
The *Geom_Parabola* is parameterized as follows:
-~~~~~
+~~~~{.php}
P(u) = O + u*u/(4.*F)*XDir + u*YDir
-~~~~~
+~~~~
-where:
+Where:
* *P* is the point of parameter *u*,
* *O, XDir* and *YDir* are respectively the origin, *X Direction* and *Y Direction* of its local coordinate system,
* *F* is the focal length of the parabola.
**Example:**
-~~~~~
+~~~~{.php}
# 2d parabola
parabola p1 0 0 50
# 3d parabola in the Y-Z plane, convexity +Z
parabola p3 0 0 0 1 0 0 0 0 1 50
-~~~~~
+~~~~
@subsubsection occt_draw_6_2_7 beziercurve, 2dbeziercurve
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
beziercurve name nbpole pole, [weight]
2dbeziercurve name nbpole pole, [weight]
-~~~~~
+~~~~
Creates a 3d rational or non-rational Bezier curve. Give the number of poles (control points,) and the coordinates of the poles *(x1 y1 z1 [w1] x2 y2 z2 [w2])*. The degree will be *nbpoles-1*. To create a rational curve, give weights with the poles. You must give weights for all poles or for none. If the weights of all the poles are equal, the curve is polynomial, and therefore non-rational.
**Example:**
-~~~~~
+~~~~{.php}
# a rational 2d bezier curve (arc of circle)
2dbeziercurve ci 3 0 0 1 10 0 sqrt(2.)/2. 10 10 1
# a 3d bezier curve, not rational
beziercurve cc 4 0 0 0 10 0 0 10 0 10 10 10 10
-~~~~~
+~~~~
@subsubsection occt_draw_6_2_8 bsplinecurve, 2dbsplinecurve, pbsplinecurve, 2dpbsplinecurve
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
bsplinecurve name degree nbknots knot, umult pole, weight
2dbsplinecurve name degree nbknots knot, umult pole, weight
pbsplinecurve name degree nbknots knot, umult pole, weight (periodic)
2dpbsplinecurve name degree nbknots knot, umult pole, weight (periodic)
-~~~~~
+~~~~
Creates 2d or 3d bspline curves; the **pbsplinecurve** and **2dpbsplinecurve** commands create periodic bspline curves.
* For a periodic curve: Sum of multiplicities - last multiplicity
**Example:**
-~~~~~
+~~~~{.php}
# a bspline curve with 4 poles and 3 knots
bsplinecurve bc 2 3 0 3 1 1 2 3 \
10 0 7 1 7 0 7 1 3 0 8 1 0 0 7 1
-0.25 h/6 1 \
-0.5 -h/3 0.5 \
0 -h/3 1
-~~~~~
+~~~~
**Note** that you can create the **NURBS** subset of bspline curves and surfaces by trimming analytical curves and surfaces and executing the command *convert*.
@subsubsection occt_draw_6_2_9 uiso, viso
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
uiso name surface u
viso name surface u
-~~~~~
+~~~~
Creates a U or V isoparametric curve from a surface.
**Example:**
-~~~~~
+~~~~{.php}
# create a cylinder and extract iso curves
cylinder c 10
uiso c1 c pi/6
viso c2 c
-~~~~~
+~~~~
**Note** that this cannot be done from offset surfaces.
@subsubsection occt_draw_6_2_10 to3d, to2d
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
to3d name curve2d [plane]
to2d name curve3d [plane]
-~~~~~
+~~~~
Create respectively a 3d curve from a 2d curve and a 2d curve from a 3d curve. The transformation uses a planar surface to define the XY plane in 3d (by default this plane is the default OXYplane). **to3d** always gives a correct result, but as **to2d** is not a projection, it may surprise you. It is always correct if the curve is planar and parallel to the plane of projection. The points defining the curve are projected on the plane. A circle, however, will remain a circle and will not be changed to an ellipse.
**Example:**
-~~~~~
+~~~~{.php}
# the following commands
circle c 0 0 5
plane p -2 1 0 1 2 3
# will create the same circle as
circle c -2 1 0 1 2 3 5
-~~~~~
+~~~~
See also: **project**
@subsubsection occt_draw_6_2_11 project
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
project name curve3d surface
-~~~~~
+~~~~
Computes a 2d curve in the parametric space of a surface corresponding to a 3d curve. This can only be used on analytical surfaces.
If we, for example, intersect a cylinder and a plane and project the resulting ellipse on the cylinder, this will create a 2d sinusoid-like bspline.
-~~~~~
+~~~~{.php}
cylinder c 5
plane p 0 0 0 0 1 1
intersect i c p
project i2d i c
-~~~~~
+~~~~
@subsection occt_draw_6_3 Surface creation
@subsubsection occt_draw_6_3_1 plane
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
plane name [x y z [dx dy dz [ux uy uz]]]
-~~~~~
+~~~~
Creates an infinite plane.
Note that this definition will be used for all analytical surfaces.
**Example:**
-~~~~~
+~~~~{.php}
# a plane through the point 10,0,0 perpendicular to X
# with U direction on Y
plane p1 10 0 0 1 0 0 0 1 0
# an horixontal plane with origin 10, -20, -5
plane p2 10 -20 -5
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_2 cylinder
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
cylinder name [x y z [dx dy dz [ux uy uz]]] radius
-~~~~~
+~~~~
A cylinder is defined by a coordinate system, and a radius. The surface generated is an infinite cylinder with the Z axis as the axis. The U parameter is the angle starting from X going in the Y direction.
**Example:**
-~~~~~
+~~~~{.php}
# a cylinder on the default Z axis, radius 10
cylinder c1 10
dset lo pi/3. la pi/4.
cylinder c3 0 0 0 cos(la)*cos(lo) cos(la)*sin(lo)
sin(la) 10
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_3 cone
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
cone name [x y z [dx dy dz [ux uy uz]]] semi-angle radius
-~~~~~
+~~~~
Creates a cone in the infinite coordinate system along the Z-axis. The radius is that of the circle at the intersection of the cone and the XY plane. The semi-angle is the angle formed by the cone relative to the axis; it should be between -90 and 90. If the radius is 0, the vertex is the origin.
**Example:**
-~~~~~
+~~~~{.php}
# a cone at 45 degrees at the origin on Z
cone c1 45 0
# a cone on axis Z with radius r1 at z1 and r2 at z2
cone c2 0 0 z1 180.*atan2(r2-r1,z2-z1)/pi r1
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_4 sphere
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
sphere name [x y z [dx dy dz [ux uy uz]]] radius
-~~~~~
+~~~~
Creates a sphere in the local coordinate system defined in the **plane** command. The sphere is centered at the origin.
To parameterize the sphere, *u* is the angle from X to Y, between 0 and 2*pi. *v* is the angle in the half-circle at angle *u* in the plane containing the Z axis. *v* is between -pi/2 and pi/2. The poles are the points Z = +/- radius; their parameters are u,+/-pi/2 for any u in 0,2*pi.
**Example:**
-~~~~~
+~~~~{.php}
# a sphere at the origin
sphere s1 10
# a sphere at 10 10 10, with poles on the axis 1,1,1
sphere s2 10 10 10 1 1 1 10
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_5 torus
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
torus name [x y z [dx dy dz [ux uy uz]]] major minor
-~~~~~
+~~~~
Creates a torus in the local coordinate system with the given major and minor radii. *Z* is the axis for the major radius. The major radius may be lower in value than the minor radius.
To parameterize a torus, *u* is the angle from X to Y; *v* is the angle in the plane at angle *u* from the XY plane to Z. *u* and *v* are in 0,2*pi.
**Example:**
-~~~~~
+~~~~{.php}
# a torus at the origin
torus t1 20 5
# a torus in another coordinate system
torus t2 10 5 -2 2 1 0 20 5
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_6 beziersurf
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
beziersurf name nbupoles nbvolpes pole, [weight]
-~~~~~
+~~~~
Use this command to create a bezier surface, rational or non-rational. First give the numbers of poles in the u and v directions.
Weights may be omitted, but if you give one weight you must give all of them.
**Example:**
-~~~~~
+~~~~{.php}
# a non-rational degree 2,3 surface
beziersurf s 3 4 \
0 0 0 10 0 5 20 0 0 \
0 10 2 10 10 3 20 10 2 \
0 20 10 10 20 20 20 20 10 \
0 30 0 10 30 0 20 30 0
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_7 bsplinesurf, upbsplinesurf, vpbsplinesurf, uvpbsplinesurf
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
bsplinesurf name udegree nbuknots uknot umult ... nbvknot vknot
vmult ... x y z w ...
upbsplinesurf ...
vpbsplinesurf ...
uvpbsplinesurf ...
-~~~~~
+~~~~
* **bsplinesurf** generates bspline surfaces;
* **upbsplinesurf** creates a bspline surface periodic in u;
See *bsplinecurve* to compute the number of poles, the poles are first given in U as in the *beziersurf* command. You must give weights if the surface is rational.
**Example:**
-~~~~~
+~~~~{.php}
# create a bspline surface of degree 1 2
# with two knots in U and three in V
bsplinesurf s \
0 10 2 1 10 10 3 1 \
0 20 10 1 10 20 20 1 \
0 30 0 1 10 30 0 1
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_8 trim, trimu, trimv
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
trim newname name [u1 u2 [v1 v2] [usense vsense]]
trimu newname name u1 u2 [usense]
trimv newname name v1 v2 [vsense]
-~~~~~
+~~~~
The **trim** commands create trimmed curves or trimmed surfaces. Note that trimmed curves and surfaces are classes of the *Geom* package.
* *trim* creates either a new trimmed curve from a curve or a new trimmed surface in u and v from a surface.
**Note** that a trimmed curve or surface contains a copy of the basis geometry: modifying that will not modify the trimmed geometry. Trimming trimmed geometry will not create multiple levels of trimming. The basis geometry will be used.
**Example:**
-~~~~~
+~~~~{.php}
# create a 3d circle
circle c 0 0 0 10
# trim an infinite cylinder
cylinder cy 10
trimv cy cy 0 50
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_9 offset
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
offset name basename distance [dx dy dz]
-~~~~~
+~~~~
Creates offset curves or surfaces at a given distance from a basis curve or surface. Offset curves and surfaces are classes from the *Geom *package.
The offset curve or surface copies the basic geometry, which can be modified later.
**Example:**
-~~~~~
+~~~~{.php}
# graphic demonstration that the outline of a torus
# is the offset of an ellipse
smallview +X+Y
ellipse e 0 0 0 50 50*sin(angle)
# note that the distance can be negative
offset l1 e 20 0 0 1
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_10 revsurf
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
revsurf name curvename x y z dx dy dz
-~~~~~
+~~~~
Creates a surface of revolution from a 3d curve.
To parameterize a surface of revolution: u is the angle of rotation around the axis. Its origin is given by the position of the meridian on the surface. v is the parameter of the meridian.
**Example:**
-~~~~~
+~~~~{.php}
# another way of creating a torus like surface
circle c 50 0 0 20
revsurf s c 0 0 0 0 1 0
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_11 extsurf
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
extsurf newname curvename dx dy dz
-~~~~~
+~~~~
Creates a surface of linear extrusion from a 3d curve. The basis curve is swept in a given direction,the *direction of extrusion* defined by a vector.
To parameterize a surface of extrusion: *u* is the parameter along the extruded curve; the *v* parameter is along the direction of extrusion.
**Example:**
-~~~~~
+~~~~{.php}
# an elliptic cylinder
ellipse e 0 0 0 10 5
extsurf s e 0 0 1
# to make it finite
trimv s s 0 10
-~~~~~
+~~~~
@subsubsection occt_draw_6_3_12 convert
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
convert newname name
-~~~~~
+~~~~
Creates a 2d or 3d NURBS curve or a NURBS surface from any 2d curve, 3d curve or surface. In other words, conics, beziers and bsplines are turned into NURBS. Offsets are not processed.
**Example:**
-~~~~~
+~~~~{.php}
# turn a 2d arc of a circle into a 2d NURBS
circle c 0 0 5
trim c c 0 pi/3
plane p
trim p p -1 1 -1 1
convert p1 p
-~~~~~
+~~~~
**Note** that offset curves and surfaces are not processed by this command.
@subsubsection occt_draw_6_4_1 reverse, ureverse, vreverse
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
reverse curvename
ureverse surfacename
vreverse surfacename
-~~~~~
+~~~~
The **reverse** command reverses the parameterization and inverses the orientation of a 2d or 3d curve. Note that the geometry is modified. To keep the curve or the surface, you must copy it before modification.
Reversing a parameter on an analytical surface may create an indirect coordinate system.
**Example:**
-~~~~~
+~~~~{.php}
# reverse a trimmed 2d circle
circle c 0 0 5
trim c c pi/4 pi/2
# dumping c will show that it is now trimmed between
# 3*pi/2 and 7*pi/4 i.e. 2*pi-pi/2 and 2*pi-pi/4
-~~~~~
+~~~~
@subsubsection occt_draw_6_4_2 exchuv
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
exchuv surfacename
-~~~~~
+~~~~
For a bezier or bspline surface this command exchanges the u and v parameters.
**Example:**
-~~~~~
+~~~~{.php}
# exchanging u and v on a spline (made from a cylinder)
cylinder c 5
trimv c c 0 10
convert c1 c
exchuv c1
-~~~~~
+~~~~
@subsubsection occt_draw_6_4_3 segment, segsur
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
segment curve Ufirst Ulast
segsur surface Ufirst Ulast Vfirst Vlast
-~~~~~
+~~~~
**segment** and **segsur** segment a bezier curve and a bspline curve or surface respectively.
This command must not be confused with **trim** which creates a new geometry.
**Example:**
-~~~~~
+~~~~{.php}
# segment a bezier curve in half
beziercurve c 3 0 0 0 10 0 0 10 10 0
segment c ufirst ulast
-~~~~~
+~~~~
@subsubsection occt_draw_6_4_4 iincudeg, incvdeg
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
incudeg surfacename newdegree
incvdeg surfacename newdegree
-~~~~~
+~~~~
**incudeg** and **incvdeg** increase the degree in the U or V parameter of a bezier or bspline surface.
**Example:**
-~~~~~
+~~~~{.php}
# make a planar bspline and increase the degree to 2 3
plane p
trim p p -1 1 -1 1
convert p1 p
incudeg p1 2
incvdeg p1 3
-~~~~~
+~~~~
**Note** that the geometry is modified.
@subsubsection occt_draw_6_4_5 cmovep, movep, movecolp, moverowp
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
cmovep curve index dx dy [dz]
movep surface uindex vindex dx dy dz
movecolp surface uindex dx dy dz
moverowp surface vindex dx dy dz
-~~~~~
+~~~~
**move** methods translate poles of a bezier curve, a bspline curve or a bspline surface.
* **cmovep** and **movep** translate one pole with a given index.
* **movecolp** and **moverowp** translate a whole column (expressed by the *uindex*) or row (expressed by the *vindex*) of poles.
**Example:**
-~~~~~
+~~~~{.php}
# start with a plane
# transform to bspline, raise degree and add relief
plane p
movecolp p1 2 0 0 5
moverowp p1 2 0 0 5
movep p1 2 2 0 0 5
-~~~~~
+~~~~
@subsubsection occt_draw_6_4_6 insertpole, rempole, remcolpole, remrowpole
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
insertpole curvename index x y [z] [weight]
rempole curvename index
remcolpole surfacename index
remrowpole surfacename index
-~~~~~
+~~~~
**insertpole** inserts a new pole into a 2d or 3d bezier curve. You may add a weight for the pole. The default value for the weight is 1. The pole is added at the position after that of the index pole. Use an index 0 to insert the new pole before the first one already existing in your drawing.
**remcolpole** and **remrowpole** remove a column or a row of poles from a bezier surface. A column is in the v direction and a row in the u direction The resulting degree must be at least 1; i.e there will be two rows and two columns left.
**Example:**
-~~~~~
+~~~~{.php}
# start with a segment, insert a pole at end
# then remove the central pole
beziercurve c 2 0 0 0 10 0 0
insertpole c 2 10 10 0
rempole c 2
-~~~~~
+~~~~
@subsubsection occt_draw_6_4_7 insertknot, insertuknot, insertvknot
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
insertknot name knot [mult = 1] [knot mult ...]
insertuknot surfacename knot mult
insertvknot surfacename knot mult
-~~~~~
+~~~~
**insertknot** inserts knots in the knot sequence of a bspline curve. You must give a knot value and a target multiplicity. The default multiplicity is 1. If there is already a knot with the given value and a multiplicity lower than the target one, its multiplicity will be raised.
**insertuknot** and **insertvknot** insert knots in a surface.
**Example:**
-~~~~~
+~~~~{.php}
# create a cylindrical surface and insert a knot
cylinder c 10
trim c c 0 pi/2 0 10
convert c1 c
insertuknot c1 pi/4 1
-~~~~~
+~~~~
@subsubsection occt_draw_6_4_8 remknot, remuknot, remvknot
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
remknot index [mult] [tol]
remuknot index [mult] [tol]
remvknot index [mult] [tol]
-~~~~~
+~~~~
**remknot** removes a knot from the knot sequence of a curve or a surface. Give the index of the knot and optionally, the target multiplicity. If the target multiplicity is not 0, the multiplicity of the knot will be lowered. As the curve may be modified, you are allowed to set a tolerance to control the process. If the tolerance is low, the knot will only be removed if the curve will not be modified.
By default, if no tolerance is given, the knot will always be removed.
**Example:**
-~~~~~
+~~~~{.php}
# bspline circle, remove a knot
circle c 0 0 5
convert c1 c
incd c1 5
remknot c1 2
-~~~~~
+~~~~
**Note** that Curves or Surfaces may be modified.
@subsubsection occt_draw_6_4_9 setperiodic, setnotperiodic, setuperiodic, setunotperiodic, setvperiodic, setvnotperiodic
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
setperiodic curve
setnotperiodic curve
setuperiodic surface
setunotperiodic surface
setvperiodic surface
setvnotperiodic surface
-~~~~~
+~~~~
**setperiodic** turns a bspline curve into a periodic bspline curve; the knot vector stays the same and excess poles are truncated. The curve may be modified if it has not been closed. **setnotperiodic** removes the periodicity of a periodic curve. The pole table mau be modified. Note that knots are added at the beginning and the end of the knot vector and the multiplicities are knots set to degree+1 at the start and the end.
**setuperiodic** and **setvperiodic** make the u or the v parameter of bspline surfaces periodic; **setunotperiodic**, and **setvnotperiodic** remove periodicity from the u or the v parameter of bspline surfaces.
**Example:**
-~~~~~
+~~~~{.php}
# a circle deperiodicized
circle c 0 0 5
convert c1 c
setnotperiodic c1
-~~~~~
+~~~~
@subsubsection occt_draw_6_4_10 setorigin, setuorigin, setvorigin
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
setorigin curvename index
setuorigin surfacename index
setuorigin surfacename index
-~~~~~
+~~~~
These commands change the origin of the parameters on periodic curves or surfaces. The new origin must be an existing knot. To set an origin other than an existing knot, you must first insert one with the *insertknot* command.
**Example:**
-~~~~~
+~~~~{.php}
# a torus with new U and V origins
torus t 20 5
convert t1 t
setuorigin t1 2
setvorigin t1 2
-~~~~~
+~~~~
@subsection occt_draw_6_5 Transformations
@subsubsection occt_draw_6_5_1 translate, dtranslate
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
translate name [names ...] dx dy dz
2dtranslate name [names ...] dx dy
-~~~~~
+~~~~
The **Translate** command translates 3d points, curves and surfaces along a vector *dx,dy,dz*. You can translate more than one object with the same command.
For 2d points or curves, use the **2dtranslate** command.
**Example:**
-~~~~~
+~~~~{.php}
# 3d translation
point p 10 20 30
circle c 10 20 30 5
torus t 10 20 30 5 2
translate p c t 0 0 15
-~~~~~
+~~~~
*NOTE*
*Objects are modified by this command.*
@subsubsection occt_draw_6_5_2 rotate, 2drotate
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
rotate name [name ...] x y z dx dy dz angle
2drotate name [name ...] x y angle
-~~~~~
+~~~~
The **rotate** command rotates a 3d point curve or surface. You must give an axis of rotation with a point *x,y,z*, a vector *dx,dy,dz* and an angle in degrees.
For a 2d rotation, you need only give the center point and the angle. In 2d or 3d, the angle can be negative.
**Example:**
-~~~~~
+~~~~{.php}
# make a helix of circles. create a script file with
this code and execute it using **source**.
circle c0 10 0 0 3
translate c$i 0 0 3
rotate c$i 0 0 0 0 0 1 36
}
-~~~~~
+~~~~
@subsubsection occt_draw_6_5_3 pmirror, lmirror, smirror, dpmirror, dlmirror
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
pmirror name [names ...] x y z
lmirror name [names ...] x y z dx dy dz
smirror name [names ...] x y z dx dy dz
2dpmirror name [names ...] x y
2dlmirror name [names ...] x y dx dy
-~~~~~
+~~~~
The mirror commands perform a mirror transformation of 2d or 3d geometry.
* **2dlmirror** is the axis symmetry mirror in 2D.
**Example:**
-~~~~~
+~~~~{.php}
# build 3 images of a torus
torus t 10 10 10 1 2 3 5 1
copy t t1
lmirror t2 0 0 0 1 0 0
copy t t3
smirror t3 0 0 0 1 0 0
-~~~~~
+~~~~
@subsubsection occt_draw_6_5_4 pscale, dpscale
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
pscale name [name ...] x y z s
2dpscale name [name ...] x y s
-~~~~~
+~~~~
The **pscale** and **2dpscale** commands transform an object by point scaling. You must give the center and the scaling factor. Because other scalings modify the type of the object, they are not provided. For example, a sphere may be transformed into an ellipsoid. Using a scaling factor of -1 is similar to using **pmirror**.
**Example:**
-~~~~~
+~~~~{.php}
# double the size of a sphere
sphere s 0 0 0 10
pscale s 0 0 0 2
-~~~~~
+~~~~
@subsection occt_draw_6_6 Curve and surface analysis
@subsubsection occt_draw_6_6_1 coord
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
coord P x y [z]
-~~~~~
+~~~~
Sets the x, y (and optionally z) coordinates of the point P.
**Example:**
-~~~~~
+~~~~{.php}
# translate a point
point p 10 5 5
translate p 5 0 0
coord p x y z
# x value is 15
-~~~~~
+~~~~
@subsubsection occt_draw_6_6_2 cvalue, 2dcvalue
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
cvalue curve U x y z [d1x d1y d1z [d2x d2y d2z]]
2dcvalue curve U x y [d1x d1y [d2x d2y]]
-~~~~~
+~~~~
For a curve at a given parameter, and depending on the number of arguments, **cvalue** computes the coordinates in *x,y,z*, the first derivative in *d1x,d1y,d1z* and the second derivative in *d2x,d2y,d2z*.
Let on a bezier curve at parameter 0 the point is the first pole; the first derivative is the vector to the second pole multiplied by the degree; the second derivative is the difference first to the second pole, second to the third pole multipied by *degree-1* :
-~~~~~
+~~~~{.php}
2dbeziercurve c 4 0 0 1 1 2 1 3 0
2dcvalue c 0 x y d1x d1y d2x d2y
# values of x y d1x d1y d2x d2y
# are 0 0 3 3 0 -6
-~~~~~
+~~~~
@subsubsection occt_draw_6_6_3 svalue
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
svalue surfname U v x y z [dux duy duz dvx dvy dvz [d2ux d2uy d2uz d2vx d2vy d2vz d2uvx d2uvy d2uvz]]
-~~~~~
+~~~~
Computes points and derivatives on a surface for a pair of parameter values. The result depends on the number of arguments. You can compute the first and the second derivatives.
**Example:**
-~~~~~
+~~~~{.php}
# display points on a sphere
sphere s 10
for {dset t 0} {[dval t] <= 1} {dset t t+0.01} {
svalue s t*2*pi t*pi-pi/2 x y z
point . x y z
}
-~~~~~
+~~~~
@subsubsection occt_draw_6_6_4 localprop, minmaxcurandinf
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
localprop curvename U
minmaxcurandinf curve
-~~~~~
+~~~~
**localprop** computes the curvature of a curve.
**minmaxcurandinf** computes and prints the parameters of the points where the curvature is minimum and maximum on a 2d curve.
**Example:**
-~~~~~
+~~~~{.php}
# show curvature at the center of a bezier curve
beziercurve c 3 0 0 0 10 2 0 20 0 0
localprop c 0.5
== Curvature : 0.02
-~~~~~
+~~~~
@subsubsection occt_draw_6_6_5 parameters
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
parameters surf/curve x y z U [V]
-~~~~~
+~~~~
Returns the parameters on the surface of the 3d point *x,y,z* in variables *u* and *v*. This command may only be used on analytical surfaces: plane, cylinder, cone, sphere and torus.
**Example:**
-~~~~~
+~~~~{.php}
# Compute parameters on a plane
plane p 0 0 10 1 1 0
parameters p 5 5 5 u v
# the values of u and v are : 0 5
-~~~~~
+~~~~
@subsubsection occt_draw_6_6_6 proj, 2dproj
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
proj name x y z
2dproj name xy
-~~~~~
+~~~~
Use **proj** to project a point on a 3d curve or a surface and **2dproj** for a 2d curve.
Let us project a point on a torus
-~~~~~
+~~~~{.php}
torus t 20 5
proj t 30 10 7
== ext_1 ext_2 ext_3 ext_4
-~~~~~
+~~~~
@subsubsection occt_draw_6_6_7 surface_radius
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
surface_radius surface u v [c1 c2]
-~~~~~
+~~~~
Computes the main curvatures of a surface at parameters *(u,v)*. If there are extra arguments, their curvatures are stored in variables *c1* and *c2*.
Let us compute curvatures of a cylinder:
-~~~~~
+~~~~{.php}
cylinder c 5
surface_radius c pi 3 c1 c2
== Min Radius of Curvature : -5
== Min Radius of Curvature : infinite
-~~~~~
+~~~~
@subsection occt_draw_6_7 Intersections
@subsubsection occt_draw_6_7_1 intersect
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
intersect name surface1 surface2
-~~~~~
+~~~~
Intersects two surfaces; if there is one intersection curve it will be named *name*, if there are more than one they will be named *name_1*, *name_2*, ...
**Example:**
-~~~~~
+~~~~{.php}
# create an ellipse
cone c 45 0
plane p 0 0 40 0 1 5
intersect e c p
-~~~~~
+~~~~
@subsubsection occt_draw_6_7_2 2dintersect
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
2dintersect curve1 [curve2] [-tol tol] [-state]
-~~~~~
+~~~~
Displays the intersection points between 2d curves.
Options:
-state - allows printing the intersection state for each point.
**Example:**
-~~~~~
+~~~~{.php}
# intersect two 2d ellipses
ellipse e1 0 0 5 2
ellipse e2 0 0 0 1 5 2
2dintersect e1 e2 -tol 1.e-10 -state
-~~~~~
+~~~~
@subsubsection occt_draw_6_7_3 intconcon
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
intconcon curve1 curve2
-~~~~~
+~~~~
Displays the intersection points between two 2d curves.
Curves must be only conic sections: 2d lines, circles, ellipses,
hyperbolas, parabolas. The algorithm from *IntAna2d_AnaIntersection* is used.
**Example:**
-~~~~~
+~~~~{.php}
# intersect two 2d ellipses
ellipse e1 0 0 5 2
ellipse e2 0 0 0 1 5 2
intconcon e1 e2
-~~~~~
+~~~~
@subsection occt_draw_6_8 Approximations
@subsubsection occt_draw_6_8_1 appro, dapprox
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
appro result nbpoint [curve]
2dapprox result nbpoint [curve / x1 y1 x2 y2]
-~~~~~
+~~~~
These commands fit a curve through a set of points. First give the number of points, then choose one of the three ways available to get the points. If you have no arguments, click on the points. If you have a curve argument or a list of points, the command launches computation of the points on the curve.
Let us pick points and they will be fitted
-~~~~~
+~~~~{.php}
2dapprox c 10
-~~~~~
+~~~~
@subsubsection occt_draw_6_8_2 surfapp, grilapp, surfint
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
surfapp name nbupoints nbvpoints x y z ....
or
surfapp name nbupoints nbvpoints surf [periodic_flag = 0]
grilapp name nbupoints nbvpoints xo dx yo dy z11 z12 ...
surfint name surf nbupoints nbvpoints [periodic_flag = 0]
-~~~~~
+~~~~
* **surfapp** fits a surface through an array of u and v points, nbupoints*nbvpoints.
* **grilapp** has the same function, but the x,y coordinates of the points are on a grid starting at x0,y0 with steps dx,dy.
If **periodic_flag** = 1, algorithm uses first row of array as last row and builds periodical surface.
**Example:**
-~~~~~
+~~~~{.php}
# a surface using the same data as in the beziersurf
example sect 4.4
surfapp s 3 4 \
0 10 2 10 10 3 20 10 2 \
0 20 10 10 20 20 20 20 10 \
0 30 0 10 30 0 20 30 0
-~~~~~
+~~~~
@subsection occt_draw_6_9 Projections
@subsubsection occt_draw_6_9_1 projponf
Syntax:
-~~~~~
+~~~~{.php}
projponf face pnt [extrema flag: -min/-max/-minmax] [extrema algo: -g(grad)/-t(tree)]
-~~~~~
+~~~~
**projponf** projects point *pnt* on the face *face*.
You can change the Extrema options:
-minmax - to look for MinMax solutions.
**Example**
-~~~~~
+~~~~{.php}
plane p 0 0 0 0 0 1
mkface f p
point pnt 5 5 10
# proj dist = 10
# uvproj = 5 5
# pproj = 5 5 0
-~~~~~
+~~~~
@subsection occt_draw_6_10 Constraints
@subsubsection occt_draw_6_10_1 cirtang
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
cirtang result [-t <Tolerance>] -c <curve> -p <point> -r <Radius>...
-~~~~~
+~~~~
Builds all circles satisfying the condition:
1. the circle must be tangent to every given curve;
Only following set of input data is supported: Curve-Curve-Curve, Curve-Curve-Point, Curve-Curve-Radius, Curve-Point-Point, Curve-Point-Radius, Point-Point-Point, Point-Point-Radius. The solutions will be stored in variables *result_1*, *result_2*, etc.
**Example:**
-~~~~~
+~~~~{.php}
# a point, a line and a radius. 2 solutions of type Curve-Point-Radius (C-P-R)
point p 0 0
line l 10 0 -1 1
cirtang c -p p -c l -r 4
== Solution of type C-P-R is: c_1 c_2
-~~~~~
+~~~~
Additionally it is possible to create a circle(s) with given center and tangent to the given curve (Curve-Point type).
**Example:**
-~~~~~
+~~~~{.php}
point pp 1 1
2dbsplinecurve cc 1 2 0 2 1 2 -10 -5 1 10 -5 1
cirtang r -p pp -c cc
== Solution of type C-P is: r_1 r_2
-~~~~~
+~~~~
@subsubsection occt_draw_6_10_2 lintan
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
lintan name curve curve [angle]
-~~~~~
+~~~~
Builds all 2d lines tangent to two curves. If the third angle argument is given the second curve must be a line and **lintan** will build all lines tangent to the first curve and forming the given angle with the line. The angle is given in degrees. The solutions are named *name_1*, *name_2*, etc.
**Example:**
-~~~~~
+~~~~{.php}
# lines tangent to 2 circles, 4 solutions
circle c1 -10 0 10
circle c2 10 0 5
circle c1 -10 0 1
line l 2 0 1 1
lintan l1 c1 l 15
-~~~~~
+~~~~
@subsection occt_draw_6_11 Display
@subsubsection occt_draw_6_11_1 dmod, discr, defle
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
dmode name [name ...] u/d
discr name [name ...] nbintervals
defle name [name ...] deflection
-~~~~~
+~~~~
**dmod** command allows choosing the display mode for a curve or a surface.
If the curve or the isolines seem to present too many angles, you can either increase the discretization or lower the deflection, depending on the mode. This will increase the number of points.
**Example:**
-~~~~~
+~~~~{.php}
# increment the number of points on a big circle
circle c 0 0 50 50
discr 100
# change the mode
dmode c u
-~~~~~
+~~~~
@subsubsection occt_draw_6_11_2 nbiso
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
nbiso name [names...] nuiso nviso
-~~~~~
+~~~~
Changes the number of isoparametric curves displayed on a surface in the U and V directions. On a bspline surface, isoparametric curves are displayed by default at knot values. Use *nbiso* to turn this feature off.
**Example:**
Let us display 35 meridians and 15 parallels on a sphere:
-~~~~~
+~~~~{.php}
sphere s 20
nbiso s 35 15
-~~~~~
+~~~~
@subsubsection occt_draw_6_11_3 clpoles, shpoles
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
clpoles name
shpoles name
-~~~~~
+~~~~
On bezier and bspline curves and surfaces, the control polygon is displayed by default: *clpoles* erases it and *shpoles* restores it.
Let us make a bezier curve and erase the poles
-~~~~~
+~~~~{.php}
beziercurve c 3 0 0 0 10 0 0 10 10 0
clpoles c
-~~~~~
+~~~~
@subsubsection occt_draw_6_11_4 clknots, shknots
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
clknots name
shknots name
-~~~~~
+~~~~
By default, knots on a bspline curve or surface are displayed with markers at the points with parametric value equal to the knots. *clknots* removes them and *shknots* restores them.
**Example:**
-~~~~~
+~~~~{.php}
# hide the knots on a bspline curve
bsplinecurve bc 2 3 0 3 1 1 2 3 \
10 0 7 1 7 0 7 1 3 0 8 1 0 0 7 1
clknots bc
-~~~~~
+~~~~
@section occt_draw_7 Topology commands
@subsubsection occt_draw_7_1_1 isos, discretisation
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
isos [name ...][nbisos]
discretisation nbpoints
-~~~~~
+~~~~
Determines or changes the number of isoparametric curves on shapes.
*discretisation* changes the default number of points used to display the curves. The default value is 30.
**Example:**
-~~~~~
+~~~~{.php}
# Display only the edges (the wireframe)
isos 0
-~~~~~
+~~~~
**Warning**: don’t confuse *isos* and *discretisation* with the geometric commands *nbisos* and *discr*.
@subsubsection occt_draw_7_1_2 orientation, complement, invert, normals, range
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
orientation name [name ...] F/R/E/I
complement name [name ...]
invert name
normals s (length = 10), disp normals
range name value value
-~~~~~
+~~~~
* **orientation** -- assigns the orientation of simple and complex shapes to one of the following four values: *FORWARD, REVERSED, INTERNAL, EXTERNAL*.
* **complement** -- changes the current orientation of shapes to its complement: *FORWARD* to *REVERSED* and *INTERNAL* to *EXTERNAL*.
* **range** -- defines the length of a selected edge by defining the values of a starting point and an end point.
**Example:**
-~~~~~
+~~~~{.php}
# to invert normals of a box
box b 10 20 30
normals b 5
# to define the length of the edge as starting from 0
and finishing at 1
range e 0 1
-~~~~~
+~~~~
@subsubsection occt_draw_7_1_3 explode, exwire, nbshapes
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
explode name [C/So/Sh/F/W/E/V]
exwire name
nbshapes name
-~~~~~
+~~~~
**explode** extracts subshapes from an entity. The subshapes will be named *name_1*, *name_2*, ... Note that they are not copied but shared with the original.
**nbshapes** counts the number of shapes of each type in an entity.
**Example:**
-~~~~~
+~~~~{.php}
# on a box
box b 10 20 30
COMPSOLID : 0
COMPOUND : 0
SHAPE : 34
-~~~~~
+~~~~
@subsubsection occt_draw_7_1_4 emptycopy, add, compound
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
emptycopy [newname] name
add name toname
compound [name ...] compoundname
-~~~~~
+~~~~
**emptycopy** returns an empty shape with the same orientation, location, and geometry as the target shape, but with no sub-shapes. If the **newname** argument is not given, the new shape is stored with the same name. This command is used to modify a frozen shape. A frozen shape is a shape used by another one. To modify it, you must **emptycopy** it. Its subshape may be reinserted with the **add** command.
On the other hand, **compound** is a safe way to achieve a similar result. It creates a compound from shapes. If no shapes are given, the compound is empty.
**Example:**
-~~~~~
+~~~~{.php}
# a compound with three boxes
box b1 0 0 0 1 1 1
box b2 3 0 0 1 1 1
box b3 6 0 0 1 1 1
compound b1 b2 b3 c
-~~~~~
+~~~~
@subsubsection occt_draw_7_1_5 compare
Syntax:
-~~~~~
+~~~~{.php}
compare shape1 shape2
-~~~~~
+~~~~
**compare** compares the two shapes *shape1* and *shape2* using the methods *TopoDS_Shape::IsSame()* and *TopoDS_Shape::IsEqual()*.
**Example**
-~~~~~
+~~~~{.php}
box b1 1 1 1
copy b1 b2
compare b1 b2
box b2 1 1 1
compare b1 b2
# shapes are not same
-~~~~~
+~~~~
@subsubsection occt_draw_7_1_6 issubshape
Syntax:
-~~~~~
+~~~~{.php}
issubshape subshape shape
-~~~~~
+~~~~
**issubshape** checks if the shape *subshape* is sub-shape of the shape *shape* and gets its index in the shape.
**Example**
-~~~~~
+~~~~{.php}
box b 1 1 1
explode b f
issubshape b_2 b
# b_2 is sub-shape of b. Index in the shape: 2.
-~~~~~
+~~~~
@subsection occt_draw_7_2 Curve and surface topology
@subsubsection occt_draw_7_2_1 vertex
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vertex name [x y z / p edge]
-~~~~~
+~~~~
Creates a vertex at either a 3d location x,y,z or the point at parameter p on an edge.
**Example:**
-~~~~~
+~~~~{.php}
vertex v1 10 20 30
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_1a mkpoint
Syntax:
-~~~~~
+~~~~{.php}
mkpoint name vertex
-~~~~~
+~~~~
Creates a point from the coordinates of a given vertex.
**Example:**
-~~~~~
+~~~~{.php}
mkpoint p v1
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_2 edge, mkedge, uisoedge, visoedge
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
edge name vertex1 vertex2
mkedge edge curve [surface] [pfirst plast] [vfirst [pfirst] vlast [plast]]
uisoedge edge face u v1 v2
visoedge edge face v u1 u2
-~~~~~
+~~~~
* **edge** creates a straight line edge between two vertices.
* **mkedge** generates edges from curves<.Two parameters can be given for the vertices: the first and last parameters of the curve are given by default. Vertices can also be given with their parameters, this option allows blocking the creation of new vertices. If the parameters of the vertices are not given, they are computed by projection on the curve. Instead of a 3d curve, a 2d curve and a surface can be given.
**Example:**
-~~~~~
+~~~~{.php}
# straight line edge
vertex v1 10 0 0
vertex v2 10 10 0
# The trimming is removed by mkedge
trim c c 0 pi/2
mkedge e2 c
-~~~~~
+~~~~
* **visoedge** and **uisoedge** are commands that generate a *uiso* parameter edge or a *viso* parameter edge.
**Example:**
-~~~~~
+~~~~{.php}
# to create an edge between v1 and v2 at point u
# to create the example plane
plane p
# to create the edge in the plane at the u axis point
0.5, and between the v axis points v=0.2 and v =0.8
uisoedge e p 0.5 0.20 0.8
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_3 wire, polyline, polyvertex
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
wire wirename e1/w1 [e2/w2 ...]
polyline name x1 y1 z1 x2 y2 z2 ...
polyvertex name v1 v2 ...
-~~~~~
+~~~~
**wire** creates a wire from edges or wires. The order of the elements should ensure that the wire is connected, and vertex locations will be compared to detect connection. If the vertices are different, new edges will be created to ensure topological connectivity. The original edge may be copied in the new one.
**polyvertex** creates a polygonal wire from vertices.
**Example:**
-~~~~~
+~~~~{.php}
# create two polygonal wires
# glue them and define as a single wire
polyline w1 0 0 0 10 0 0 10 10 0
polyline w2 10 10 0 0 10 0 0 0 0
wire w w1 w2
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_4 profile
Syntax
-~~~~~
+~~~~{.php}
profile name [code values] [code values] ...
-~~~~~
+~~~~
**profile** builds a profile in a plane using a moving point and direction. By default, the profile is closed and a face is created. The original point is 0 0, and direction is 1 0 situated in the XY plane.
Code letters are not case-sensitive.
**Example:**
-~~~~~
+~~~~{.php}
# to create a triangular plane using a vertex at the
origin, in the xy plane
profile p O 0 0 0 X 1 Y 0 x 1 y 1
-~~~~~
+~~~~
**Example:**
-~~~~~
+~~~~{.php}
# to create a contour using the different code
possibilities
# to create the plane with the same contour
profile p F 1 0 x 2 y 1 c 1 45 l 1 tt 1.5 1.5 xx 0.2 yy 2 c 1 290 ix 0 r 90 ix -0.3
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_5 bsplineprof
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
bsplineprof name [S face] [W WW]
-~~~~~
+~~~~
* for an edge : \<digitizes\> ... <mouse button 2>
* to end profile : <mouse button 3>
The profile shape definition is the suffix; no suffix produces a face, **w** is a closed wire, **ww** is an open wire.
**Example:**
-~~~~~
+~~~~{.php}
#to view the xy plane
top
#to create a 2d curve with the mouse
==
# click mb1 to create the second curve
# click mb3 to create the face
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_6 mkoffset
**mkoffset** creates a parallel wire in the same plane using a face or an existing continuous set of wires as a reference. The number of occurrences is not limited.
The offset distance defines the spacing and the positioning of the occurrences.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
mkoffset result shape nboffset stepoffset [jointype(a/i) [alt]]
-~~~~~
-where:
+~~~~
+Where:
* *result* - the base name for the resulting wires. The index of the occurrence (starting with 1) will be added to this name, so the resulting wires will have the names - *result_1*, *result_2* ...;
* *shape* - input shape (face or compound of wires);
* *nboffset* - the number of the parallel occurrences;
**Example:**
-~~~~~
+~~~~{.php}
# Create a box and select a face
box b 1 2 3
explode b f
# Create one interior parallel contour with an offset value of 0.4
mkoffset r b_1 1 -0.4
-~~~~~
+~~~~
**Note** that on a concave input contour for an interior step *mkoffset* command may produce several wires which will be contained in a single compound.
**Example:**
-~~~~~
+~~~~{.php}
# to create the example contour
profile p F 0 0 x 2 y 4 tt 1 1 tt 0 4 w
# creates an incoherent interior offset
# creates two incoherent wires
mkoffset r p 1 -0.55
# r_1 is a compound of two wires
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_7 mkplane, mkface
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
mkplane name wire
mkface name surface [ufirst ulast vfirst vlast]
-~~~~~
+~~~~
**mkplane** generates a face from a planar wire. The planar surface will be constructed with an orientation which keeps the face inside the wire.
**mkface** generates a face from a surface. Parameter values can be given to trim a rectangular area. The default boundaries are those of the surface.
**Example:**
-~~~~~
+~~~~{.php}
# make a polygonal face
polyline f 0 0 0 20 0 0 20 10 0 10 10 0 10 20 0 0 20 0 0 0 0
mkplane f f
cylinder g 10
trim g g -pi/3 pi/2 0 15
mkface g g
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_8 mkcurve, mksurface
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
mkcurve curve edge
mksurface name face
-~~~~~
+~~~~
**mkcurve** creates a 3d curve from an edge. The curve will be trimmed to the edge boundaries.
**mksurface** creates a surface from a face. The surface will not be trimmed.
**Example:**
-~~~~~
+~~~~{.php}
# make a line
vertex v1 0 0 0
vertex v2 10 0 0
edge e v1 v2
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_9 pcurve
-Syntax:
+Syntax:
-~~~~~
+~~~~{.php}
pcurve [name edgename] facename
-~~~~~
+~~~~
Extracts the 2d curve of an edge on a face. If only the face is specified, the command extracts all the curves and colors them according to their orientation. This is useful in checking to see if the edges in a face are correctly oriented, i.e. they turn counter-clockwise. To make curves visible, use a fitted 2d view.
**Example:**
-~~~~~
+~~~~{.php}
# view the pcurves of a face
plane p
trim p p -1 1 -1 1
av2d; # a 2d view
pcurve p
2dfit
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_10 chfi2d
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
chfi2d result face [edge1 edge2 (F radius/CDD d1 d2/CDA d ang) ....
-~~~~~
+~~~~
Creates chamfers and fillets on 2D objects. Select two adjacent edges and:
Let us create a 2d fillet:
-~~~~~
+~~~~{.php}
top
profile p x 2 y 2 x -2
chfi2d cfr p . . F 0.3
#select an edge
==Pick an object
#select an edge
-~~~~~
+~~~~
Let us create a 2d chamfer using two distances:
-~~~~~
+~~~~{.php}
profile p x 2 y 2 x -2
chfi2d cfr p . . CDD 0.3 0.6
==Pick an object
#select an edge
==Pick an object
#select an edge
-~~~~~
+~~~~
Let us create a 2d chamfer using a defined distance and angle
-~~~~~
+~~~~{.php}
top
profile p x 2 y 2 x -2
chfi2d cfr p . . CDA 0.3 75
#select an edge
==Pick an object
#select an edge
-~~~~~
+~~~~
@subsubsection occt_draw_7_2_11 nproject
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
nproject pj e1 e2 e3 ... surf -g -d [dmax] [Tol
[continuity [maxdeg [maxseg]]]
-~~~~~
+~~~~
Creates a shape projection which is normal to the target surface.
**Example:**
-~~~~~
+~~~~{.php}
# create a curved surface
line l 0 0 0 1 0 0
trim l l 0 2
donly p e
# create the normal projection of the shape(circle)
nproject r e p
-~~~~~
+~~~~
@subsection occt_draw_7_3 Primitives
@subsubsection occt_draw_7_3_1 box, wedge
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
box name [x y z] dx dy dz
wedge name dx dy dz ltx / xmin zmin xmax xmax
-~~~~~
+~~~~
**box** creates a box parallel to the axes with dimensions *dx,dy,dz*. *x,y,z* is the corner of the box. It is the default origin.
The other faces are defined between these faces. The face in the *y=yd* plane may be degenerated into a line if *ltx = 0*, or a point if *xmin = xmax* and *ymin = ymax*. In these cases, the line and the point both have 5 faces each. To position the wedge use the *ttranslate* and *trotate* commands.
**Example:**
-~~~~~
+~~~~{.php}
# a box at the origin
box b1 10 20 30
# a pyramid
wedge w3 20 20 20 10 10 10 10
-~~~~~
+~~~~
@subsubsection occt_draw_7_3_2 pcylinder, pcone, psphere, ptorus
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
pcylinder name [plane] radius height [angle]
pcone name [plane] radius1 radius2 height [angle]
pcone name [plane] radius1 radius2 height [angle]
psphere name [plane] radius1 [angle1 angle2] [angle]
ptorus name [plane] radius1 radius2 [angle1 angle2] [angle]
-~~~~~
+~~~~
All these commands create solid blocks in the default coordinate system, using the Z axis as the axis of revolution and the X axis as the origin of the angles. To use another system, translate and rotate the resulting solid or use a plane as first argument to specify a coordinate system. All primitives have an optional last argument which is an angle expressed in degrees and located on the Z axis, starting from the X axis. The default angle is 360.
**ptorus** creates a solid torus with the given radii, centered on the origin, which is a point along the z axis. If two angles increasing in degree in the range 0 -- 360 are given, the solid will be bounded by two planar surfaces at those positions on the circle.
**Example:**
-~~~~~
+~~~~{.php}
# a can shape
pcylinder cy 5 10
# half torus
ptorus to 20 5 0 90
-~~~~~
+~~~~
@subsubsection occt_draw_7_3_3 halfspace
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
halfspace result face/shell x y z
-~~~~~
+~~~~
**halfspace** creates an infinite solid volume based on a face in a defined direction. This volume can be used to perform the boolean operation of cutting a solid by a face or plane.
**Example:**
-~~~~~
+~~~~{.php}
box b 0 0 0 1 2 3
explode b f
==b_1 b_2 b_3 b_4 b_5 b_6
halfspace hr b_3 0.5 0.5 0.5
-~~~~~
+~~~~
@subsection occt_draw_7_4 Sweeping
@subsubsection occt_draw_7_4_1 prism
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
prism result base dx dy dz [Copy | Inf | SemiInf]
-~~~~~
+~~~~
Creates a new shape by sweeping a shape in a direction. Any shape can be swept: a vertex gives an edge; an edge gives a face; and a face gives a solid.
The shape is swept along the vector *dx dy dz*. The original shape will be shared in the result unless *Copy* is specified. If *Inf* is specified the prism is infinite in both directions. If *SemiInf* is specified the prism is infinite in the *dx,dy,dz* direction, and the length of the vector has no importance.
**Example:**
-~~~~~
+~~~~{.php}
# sweep a planar face to make a solid
polyline f 0 0 0 10 0 0 10 5 0 5 5 0 5 15 0 0 15 0 0 0 0
mkplane f f
-~~~~~
+~~~~
@subsubsection occt_draw_7_4_2 revol
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
revol result base x y z dx dy dz angle [Copy]
-~~~~~
+~~~~
Creates a new shape by sweeping a base shape through an angle along the axis *x,y,z dx,dy,dz*. As with the prism command, the shape can be of any type and is not shared if *Copy* is specified.
**Example:**
-~~~~~
+~~~~{.php}
# shell by wire rotation
polyline w 0 0 0 10 0 0 10 5 0 5 5 0 5 15 0 0 15 0
revol s w 20 0 0 0 1 0 90
-~~~~~
+~~~~
@subsubsection occt_draw_7_4_3 pipe
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
pipe name wire_spine Profile
-~~~~~
+~~~~
Creates a new shape by sweeping a shape known as the profile along a wire known as the spine.
**Example:**
-~~~~~
+~~~~{.php}
# sweep a circle along a bezier curve to make a solid
pipe
wire profile profile
mkplane profile profile
pipe p spine profile
-~~~~~
+~~~~
@subsubsection occt_draw_7_4_4 mksweep, addsweep, setsweep, deletesweep, buildsweep, simulsweep
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
mksweep wire
addsweep wire[vertex][-M][-C] [auxiilaryshape]
deletesweep wire
setsweep options [arg1 [arg2 [...]]]
simulsweep r [n] [option]
buildsweep [r] [option] [Tol]
-~~~~~
+~~~~
options are :
* *-FR* : Tangent and Normal are defined by a Frenet trihedron
* **buildsweep** -- creates the sweep using the arguments defined by all the commands.
**Example:**
-~~~~~
+~~~~{.php}
#create a sweep based on a semi-circular wire using the
Frenet algorithm
#create a circular figure
addsweep w -R
# to simulate the sweep with a visual approximation
simulsweep w 3
-~~~~~
+~~~~
@subsubsection occt_draw_7_4_5 thrusections
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
thrusections [-N] result issolid isruled wire1 wire2 [..wire..]
-~~~~~
+~~~~
**thrusections** creates a shape using wires that are positioned in different planes. Each wire selected must have the same number of edges and vertices.
A bezier curve is generated between the vertices of each wire. The option *[-N]* means that no check is made on wires for direction.
**Example:**
-~~~~~
+~~~~{.php}
#create three wires in three planes
polyline w1 0 0 0 5 0 0 5 5 0 2 3 0
polyline w2 0 1 3 4 1 3 4 4 3 1 3 3
==thrusections th issolid isruled w1 w2 w3
Tolerances obtenues -- 3d : 0
-- 2d : 0
-~~~~~
+~~~~
@subsection occt_draw_7_5 Topological transformation
@subsubsection occt_draw_7_5_1 tcopy
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tcopy name toname [name toname ...]
-~~~~~
+~~~~
Copies the structure of one shape, including the geometry, into another, newer shape.
**Example:**
-~~~~~
+~~~~{.php}
# create an edge from a curve and copy it
beziercurve c 3 0 0 0 10 0 0 20 10 0
mkedge e1 c
tcopy e1 e2
ttranslate e2 0 5 0
# now modify the curve, only e1 and e2 will be modified
-~~~~~
+~~~~
@subsubsection occt_draw_7_5_2 tmove, treset
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tmove name [name ...] shape
reset name [name ...]
-~~~~~
+~~~~
**tmove** and **reset** modify the location, or the local coordinate system of a shape.
**tmove** applies the location of a given shape to other shapes. **reset** restores one or several shapes it to its or their original coordinate system(s).
**Example:**
-~~~~~
+~~~~{.php}
# create two boxes
box b1 10 10 10
box b2 20 0 0 10 10 10
tmove b2 b1
# return to original positions
reset b1 b2
-~~~~~
+~~~~
@subsubsection occt_draw_7_5_3 ttranslate, trotate
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ttranslate [name ...] dx dy dz
trotate [name ...] x y z dx dy dz angle
-~~~~~
+~~~~
**ttranslate** translates a set of shapes by a given vector, and **trotate** rotates them by a given angle around an axis. Both commands only modify the location of the shape.
When creating multiple shapes, the same location is used for all the shapes. (See *toto.tcl* example below. Note that the code of this file can also be directly executed in interactive mode.)
Locations are very economic in the data structure because multiple occurrences of an object share the topological description.
**Example:**
-~~~~~
+~~~~{.php}
# make rotated copies of a sphere in between two cylinders
# create a file source toto.tcl
# toto.tcl code:
# call the source file for multiple copies
source toto.tcl
-~~~~~
+~~~~
@subsubsection occt_draw_7_5_4 tmirror, tscale
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tmirror name x y z dx dy dz
tscale name x y z scale
-~~~~~
+~~~~
* **tmirror** makes a mirror copy of a shape about a plane x,y,z dx,dy,dz.
* **Tscale** applies a central homotopic mapping to a shape.
**Example:**
-~~~~~
+~~~~{.php}
# mirror a portion of cylinder about the YZ plane
pcylinder c1 10 10 270
copy c1 c2
tmirror c2 15 0 0 1 0 0
# and scale it
tscale c1 0 0 0 0.5
-~~~~~
+~~~~
@subsection occt_draw_7_6 Old Topological operations
Use the commands bfuse, bcut, bcommon instead.
Syntax:
-~~~~~
+~~~~{.php}
fuse name shape1 shape2
cut name shape1 shape2
common name shape1 shape2
-~~~~~
+~~~~
**fuse** creates a new shape by a boolean operation on two existing shapes. The new shape contains both originals intact.
**common** creates a new shape which contains only what is in common between the two original shapes in their intersection.
**Example:**
-~~~~~
+~~~~{.php}
# all four boolean operations on a box and a cylinder
box b 0 -10 5 20 20 10
common s4 b c
ttranslate s4 0 -40 0
-~~~~~
+~~~~
@subsubsection occt_draw_7_6_2 section, psection
These commands are no longer supported, so the result may be unpredictable.
Use the command **bsection** instead.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
section result shape1 shape2
psection name shape plane
-~~~~~
+~~~~
**section** creates a compound object consisting of the edges for the intersection curves on the faces of two shapes.
**psection** creates a planar section consisting of the edges for the intersection curves on the faces of a shape and a plane.
**Example:**
-~~~~~
+~~~~{.php}
# section line between a cylinder and a box
pcylinder c 10 20
box b 0 0 5 15 15 15
pcone c 10 30 30
plane p 0 0 15 1 1 2
psection s c p
-~~~~~
+~~~~
@subsubsection occt_draw_7_6_3 sewing
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
sewing result [tolerance] shape1 shape2 ...
-~~~~~
+~~~~
**Sewing** joins shapes by connecting their adjacent or near adjacent edges. Adjacency can be redefined by modifying the tolerance value.
**Example:**
-~~~~~
+~~~~{.php}
# create two adjacent boxes
box b 0 0 0 1 2 3
box b2 0 2 0 1 2 3
sewing sr b b2
whatis sr
sr is a shape COMPOUND FORWARD Free Modified
-~~~~~
+~~~~
@subsection occt_draw_7_7 New Topological operations
@subsubsection occt_draw_7_8_1 depouille
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
dep result shape dirx diry dirz face angle x y x dx dy dz [face angle...]
-~~~~~
+~~~~
Creates a new shape by drafting one or more faces of a shape.
Identify the shape(s) to be drafted, the drafting direction, and the face(s) with an angle and an axis of rotation for each face. You can use dot syntax to identify the faces.
**Example:**
-~~~~~
+~~~~{.php}
# draft a face of a box
box b 10 10 10
explode b f
== b_1 b_2 b_3 b_4 b_5 b_6
dep a b 0 0 1 b_2 10 0 10 0 1 0 5
-~~~~~
+~~~~
@subsubsection occt_draw_7_8_2 chamf
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
chamf newname shape edge face S dist
chamf newname shape edge face dist1 dist2
chamf newname shape edge face A dist angle
-~~~~~
+~~~~
Creates a chamfer along the edge between faces using:
**Examples:**
Let us create a chamfer based on equal distances from the edge (45 degree angle):
-~~~~~
+~~~~{.php}
# create a box
box b 1 2 3
chamf ch b . . S 0.5
# select an edge
==Pick an object
# select an adjacent face
-~~~~~
+~~~~
Let us create a chamfer based on different distances from the selected edge:
-~~~~~
+~~~~{.php}
box b 1 2 3
chamf ch b . . 0.3 0.4
==Pick an object
# select an edge
==Pick an object
# select an adjacent face
-~~~~~
+~~~~
Let us create a chamfer based on a distance from the edge and an angle:
-~~~~~
+~~~~{.php}
box b 1 2 3
chamf ch b . . A 0.4 30
==Pick an object
# select an edge
==Pick an object
# select an adjacent face
-~~~~~
+~~~~
@subsubsection occt_draw_7_8_3 blend
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
blend result object rad1 ed1 rad2 ed2 ... [R/Q/P]
-~~~~~
+~~~~
Creates a new shape by filleting the edges of an existing shape. The edge must be inside the shape. You may use the dot syntax. Note that the blend is propagated to the edges of tangential planar, cylindrical or conical faces.
**Example:**
-~~~~~
+~~~~{.php}
# blend a box, click on an edge
box b 20 20 20
blend b b 2 .
==- FilDS 0s
==- Reconstruction 0.06s
==- SetRegul 0s
-~~~~~
+~~~~
@subsubsection occt_draw_7_8_4 bfuseblend
Syntax:
-~~~~~
+~~~~{.php}
bfuseblend name shape1 shape2 radius [-d]
-~~~~~
+~~~~
Creates a boolean fusion of two shapes and then blends (fillets) the intersection edges using the given radius.
Option [-d] enables the Debugging mode in which the error messages, if any, will be printed.
**Example:**
-~~~~~
+~~~~{.php}
# fuse-blend two boxes
box b1 20 20 5
copy b1 b2
ttranslate b2 -10 10 3
bfuseblend a b1 b2 1
-~~~~~
+~~~~
@subsubsection occt_draw_7_8_4a bcutblend
Syntax:
-~~~~~
+~~~~{.php}
bcutblend name shape1 shape2 radius [-d]
-~~~~~
+~~~~
Creates a boolean cut of two shapes and then blends (fillets) the intersection edges using the given radius.
Option [-d] enables the Debugging mode in which the error messages, if any, will be printed.
**Example:**
-~~~~~
+~~~~{.php}
# cut-blend two boxes
box b1 20 20 5
copy b1 b2
ttranslate b2 -10 10 3
bcutblend a b1 b2 1
-~~~~~
+~~~~
@subsubsection occt_draw_7_8_5 mkevol, updatevol, buildevol
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
mkevol result object (then use updatevol) [R/Q/P]
updatevol edge u1 radius1 [u2 radius2 ...]
buildevol
-~~~~~
+~~~~
These three commands work together to create fillets with evolving radii.
* **buildevol** produces the result described previously in **mkevol** and **updatevol**.
**Example:**
-~~~~~
+~~~~{.php}
# makes an evolved radius on a box
box b 10 10 10
mkevol b b
==- FilDS 0.01s
==- Reconstruction 0.04s
==- SetRegul 0s
-~~~~~
+~~~~
@subsection occt_draw_defeaturing Defeaturing
Draw command **removefeatures** is intended for performing @ref occt_modalg_defeaturing "3D Model Defeaturing", i.e. it performs the removal of the requested features from the shape.
Syntax:
-~~~~
+~~~~{.php}
removefeatures result shape f1 f2 ... [-nohist] [-parallel]
-
+~~~~
Where:
result - result of the operation;
shape - the shape to remove the features from;
Options:
nohist - disables the history collection;
parallel - enables the parallel processing mode.
-~~~~
+
@subsection occt_draw_makeperiodic 3D Model Periodicity
If trimming is given it trims the shape to fit the requested period.
Syntax:
-~~~~
+~~~~{.php}
makeperiodic result shape [-x/y/z period [-trim first]]
-
+~~~~
Where:
result - resulting periodic shape;
shape - input shape to make it periodic:
-x/y/z period - option to make the shape periodic in X, Y or Z direction with the given period;
-trim first - option to trim the shape to fit the required period, starting the period in first.
-~~~~
+
@subsubsection occt_draw_makeperiodic_repeatshape repeatshape
The command should be called after **makeperiodic** command.
Syntax:
-~~~~
+~~~~{.php}
repeatshape result -x/y/z times
+~~~~
Where:
result - resulting shape;
-x/y/z times - direction for repetition and number of repetitions (negative number of times means the repetition in negative direction).
-~~~~
@subsubsection occt_draw_makeperiodic_periodictwins periodictwins
The command should be called after **makeperiodic** command.
Syntax:
-~~~~
+~~~~{.php}
periodictwins twins shape
-
+~~~~
Where:
twins - periodic twins for the given shape
shape - shape to find the twins for
-~~~~
+
@subsubsection occt_draw_makeperiodic_clearrepetitions clearrepetitions
The command makes the input touching shapes connected.
Syntax:
-~~~~
+~~~~{.php}
makeconnected result shape1 shape2 ...
+~~~~
Where:
result - resulting connected shape.
shape1 shape2 ... - shapes to be made connected.
-~~~~
@subsubsection occt_draw_makeconnected_cmaterialson cmaterialson
The command should be called after the shapes have been made connected, i.e. after the command **makeconnected**.
Syntax:
-~~~~
+~~~~{.php}
cmaterialson result +/- shape
-
+~~~~
Where:
result - material shapes
shape - shape for which the materials are needed
+/- - side of a given shape ('+' for positive side, '-' - for negative).
-~~~~
+
@subsubsection occt_draw_makeconnected_cmakeperiodic cmakeperiodic
The command should be called after the shapes have been made connected, i.e. after the command **makeconnected**.
Syntax:
-~~~~
+~~~~{.php}
cmakeperiodic result [-x/y/z period [-trim first]]
-
+~~~~
Where:
result - resulting periodic shape;
shape - input shape to make it periodic:
-x/y/z period - option to make the shape periodic in X, Y or Z direction with the given period;
-trim first - option to trim the shape to fit the required period, starting the period in first.
-~~~~
+
@subsubsection occt_draw_makeconnected_crepeatshape crepeatshape
The command should be called after the shapes have been made connected and periodic, i.e. after the commands **makeconnected** and **cmakeperiodic**.
Syntax:
-~~~~
+~~~~{.php}
crepeatshape result -x/y/z times
-
+~~~~
Where:
result - resulting shape;
-x/y/z times - direction for repetition and number of repetitions (negative number of times means the repetition in negative direction).
-~~~~
+
@subsubsection occt_draw_makeconnected_cperiodictwins cperiodictwins
The command should be called after the shapes have been made connected and periodic, i.e. after the commands **makeconnected** and **cmakeperiodic**.
Syntax:
-~~~~
+~~~~{.php}
cperiodictwins twins shape
+~~~~
Where:
twins - periodic twins of a shape.
shape - input shape.
-~~~~
@subsubsection occt_draw_makeconnected_cclearrepetitions cclearrepetitions
Otherwise the command will have no effect.
Syntax:
-~~~~
+~~~~{.php}
cclearrepetitions [result]
~~~~
@subsubsection occt_draw_7_9_1 lprops, sprops, vprops
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
lprops shape [x y z] [-skip] [-full] [-tri]
sprops shape [epsilon] [c[losed]] [x y z] [-skip] [-full] [-tri]
vprops shape [epsilon] [c[losed]] [x y z] [-skip] [-full] [-tri]
-~~~~~
+~~~~
* **lprops** computes the mass properties of all edges in the shape with a linear density of 1;
* **sprops** of all faces with a surface density of 1;
All three commands print the mass, the coordinates of the center of gravity, the matrix of inertia and the moments. Mass is either the length, the area or the volume. The center and the main axis of inertia are displayed.
**Example:**
-~~~~~
+~~~~{.php}
# volume of a cylinder
pcylinder c 10 20
vprops c
IX = 366519.141446336
IY = 366519.141444962
I.Z = 314159.265357595
-~~~~~
+~~~~
@subsubsection occt_draw_7_9_2 bounding
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
bounding {-s shape | -c xmin ymin zmin xmax ymax zmax} [-obb] [-shape name] [-dump] [-notriangulation] [-perfmeter name NbIters] [-save xmin ymin zmin xmax ymax zmax] [-nodraw] [-optimal] [-exttoler]
-~~~~~
+~~~~
Computes and displays the bounding box (BndBox) of a shape. The bounding box is a cuboid that circumscribes the source shape.
Generally, bounding boxes can be divided into two main types:
Detailed information about this command is available in DRAW help-system (enter "help bounding" in DRAW application).
**Example 1: Creation of AABB with given corners**
-~~~~~
+~~~~{.php}
bounding -c 50 100 30 180 200 100 -shape result
# look at the box
vdisplay result
vfit
vsetdispmode 1
-~~~~~
+~~~~
**Example 2: Compare AABB and OBB**
-~~~~~
+~~~~{.php}
# Create a torus and rotate it
ptorus t 20 5
trotate t 5 10 15 1 1 1 28
# Let us check this value
dval (x2-x1)*(y2-y1)*(z2-z1)
==64949.886543606823
-~~~~~
+~~~~
The same result is obtained.
-~~~~~
+~~~~{.php}
# Create OBB from the torus
bounding -s t -shape ro -dump -obb
==Oriented bounding box
# Compute the volume of OBB
vprops ro 1.0e-12
==Mass : 28694.7
-~~~~~
+~~~~
As we can see, the volume of OBB is significantly less than the volume of AABB.
@subsubsection occt_draw_7_9_2a isbbinterf
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
isbbinterf shape1 shape2 [-o]
-~~~~~
+~~~~
Checks whether the bounding boxes created from the given shapes are interfered. If "-o"-option is switched on then the oriented boxes will be checked. Otherwise, axis-aligned boxes will be checked.
**Example 1: Not interfered AABB**
-~~~~~
+~~~~{.php}
box b1 100 60 140 20 10 80
box b2 210 200 80 120 60 90
isbbinterf b1 b2
==The shapes are NOT interfered by AABB.
-~~~~~
+~~~~
**Example 2: Interfered AABB**
-~~~~~
+~~~~{.php}
box b1 300 300 300
box b2 100 100 100 50 50 50
isbbinterf b1 b2
==The shapes are interfered by AABB.
-~~~~~
+~~~~
**Example 3: Not interfered OBB**
-~~~~~
+~~~~{.php}
box b1 100 150 200
copy b1 b2
trotate b1 -150 -150 -150 1 2 3 -40
# Check of interference
isbbinterf b1 b2 -o
==The shapes are NOT interfered by OBB.
-~~~~~
+~~~~
**Example 4: Interfered OBB**
-~~~~~
+~~~~{.php}
box b1 100 150 200
copy b1 b2
trotate b1 -50 -50 -50 1 1 1 -40
# Check of interference
isbbinterf b1 b2 -o
==The shapes are interfered by OBB.
-~~~~~
+~~~~
@subsubsection occt_draw_7_9_3 distmini
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
distmini name Shape1 Shape2
-~~~~~
+~~~~
Calculates the minimum distance between two shapes. The calculation returns the number of solutions, if more than one solution exists. The options are displayed in the viewer in red and the results are listed in the shell window. The *distmini* lines are considered as shapes which have a value v.
**Example:**
-~~~~~
+~~~~{.php}
box b 0 0 0 10 20 30
box b2 30 30 0 10 20 30
distmini d1 b b2
==X=30 Y=30 Z=0
==d1_val d1 d12
-~~~~~
+~~~~
@subsubsection occt_draw_7_9_4 xdistef, xdistcs, xdistcc, xdistc2dc2dss, xdistcc2ds
Syntax:
-~~~~~
+~~~~{.php}
xdistef edge face
xdistcs curve surface firstParam lastParam [NumberOfSamplePoints]
xdistcc curve1 curve2 startParam finishParam [NumberOfSamplePoints]
xdistcc2ds c curve2d surf startParam finishParam [NumberOfSamplePoints]
xdistc2dc2dss curve2d_1 curve2d_2 surface_1 surface_2 startParam finishParam [NumberOfSamplePoints]
-~~~~~
+~~~~
It is assumed that curves have the same parametrization range and *startParam* is less than *finishParam*.
* **xdistc2dc2dss** -- distance between two 2d curves on surface.
**Examples**
-~~~~~
+~~~~{.php}
bopcurves b1 b2 -2d
mksurf s1 b1
mksurf s2 b2
xdistcs c_1 s1 0 1 100
xdistcc2ds c_1 c2d2_1 s2 0 1
xdistc2dc2dss c2d1_1 c2d2_1 s1 s2 0 1 1000
-~~~~~
+~~~~
@subsubsection occt_draw_7_9_5 checkshape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
checkshape [-top] shape [result] [-short]
-~~~~~
+~~~~
Where:
* *top* -- optional parameter, which allows checking only topological validity of a shape.
**checkshape** examines the selected object for topological and geometric coherence. The object should be a three dimensional shape.
**Example:**
-~~~~~
+~~~~{.php}
# checkshape returns a comment valid or invalid
box b1 0 0 0 1 1 1
checkshape b1
# returns the comment
this shape seems to be valid
-~~~~~
+~~~~
@subsubsection occt_draw_7_9_6 tolsphere
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tolsphere shape
-~~~~~
+~~~~
Where:
* *shape* -- the name of the shape to process.
**tolsphere** shows vertex tolerances by drawing spheres around each vertex in the shape. Each sphere is assigned a name of the shape with suffix "_vXXX", where XXX is the number of the vertex in the shape.
**Example:**
-~~~~~
+~~~~{.php}
# tolsphere returns all names of created spheres.
box b1 0 0 0 1 1 1
settolerance b1 0.05
tolsphere b1
# creates spheres and returns the names
b1_v1 b1_v2 b1_v3 b1_v4 b1_v5 b1_v6 b1_v7 b1_v8
-~~~~~
+~~~~
@subsubsection occt_draw_7_9_7 validrange
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
validrange edge [(out) u1 u2]
-~~~~~
+~~~~
Where:
* *edge* -- the name of the edge to analyze.
**validrange** computes valid range of the edge. If *u1* and *u2* are not given, it returns the first and the last parameters. Otherwise, it sets variables *u1* and *u2*.
**Example:**
-~~~~~
+~~~~{.php}
circle c 0 0 0 10
mkedge e c
mkedge e c 0 pi
1.9884375000000002e-008
dval u2
3.1415926337054181
-~~~~~
+~~~~
@subsection occt_draw_7_10 Surface creation
@subsubsection occt_draw_7_10_1 gplate,
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
gplate result nbrcurfront nbrpntconst [SurfInit] [edge 0] [edge tang (1:G1;2:G2) surf]...[point] [u v tang (1:G1;2:G2) surf] ...
-~~~~~
+~~~~
Creates a surface from a defined boundary. The boundary can be defined using edges, points, or other surfaces.
**Example:**
-~~~~~
+~~~~{.php}
plane p
trim p p -1 3 -1 3
mkface p p
Approximation results
Approximation error : 0.000422195884750181
Criterium error : 3.43709808053967e-05
-~~~~~
+~~~~
@subsubsection occt_draw_7_10_2 filling, fillingparam
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
filling result nbB nbC nbP [SurfInit] [edge][face]order...
edge[face]order... point/u v face order...
-~~~~~
+~~~~
Creates a surface between borders. This command uses the **gplate** algorithm but creates a surface that is tangential to the adjacent surfaces. The result is a smooth continuous surface based on the G1 criterion.
* <i>-a maxdeg maxseg </i> : Approximation option
**Example:**
-~~~~~
+~~~~{.php}
# to create four curved survaces and a point
plane p
trim p p -1 3 -1 3
MaxDeg = 8
MaxSegments = 9
-~~~~~
+~~~~
@subsection occt_draw_7_11 Complex Topology
@subsubsection occt_draw_7_11_1 offsetshape, offsetcompshape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
offsetshape r shape offset [tol] [face ...]
offsetcompshape r shape offset [face ...]
-~~~~~
+~~~~
**offsetshape** and **offsetcompshape** assign a thickness to the edges of a shape. The *offset* value can be negative or positive. This value defines the thickness and direction of the resulting shape. Each face can be removed to create a hollow object.
The opening between the object interior and exterior is defined by the argument face or faces.
**Example:**
-~~~~~
+~~~~{.php}
box b1 10 20 30
explode b1 f
== b1_1 b1_2 b1_3 b1_4 b1_5 b1_6
offsetcompshape r b1 -1 b1_3
-~~~~~
+~~~~
@subsubsection occt_draw_7_11_2 featprism, featdprism, featrevol, featlf, featrf
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
featprism shape element skface Dirx Diry Dirz Fuse(0/1/2) Modify(0/1)
featdprism shape face skface angle Fuse(0/1/2) Modify(0/1)
featrevol shape element skface Ox Oy Oz Dx Dy Dz Fuse(0/1/2) Modify(0/1)
featrf shape wire plane X Y Z DirX DirY DirZ Size Size Fuse(0/1/2) Modify(0/1)
featperform prism/revol/pipe/dprism/lf result [[Ffrom] Funtil]
featperformval prism/revol/dprism/lf result value
-~~~~~
+~~~~
**featprism** loads the arguments for a prism with contiguous sides normal to the face.
Let us create a feature prism with a draft angle and a normal direction :
-~~~~~
+~~~~{.php}
# create a box with a wire contour on the upper face
box b 1 1 1
profil f O 0 0 1 F 0.25 0.25 x 0.5 y 0.5 x -0.5
Gluer
still Gluer
Gluer result
-~~~~~
+~~~~
Let us create a feature prism with circular direction :
-~~~~~
+~~~~{.php}
# create a box with a wire contour on the upper face
box b 1 1 1
profil f O 0 0 1 F 0.25 0.25 x 0.5 y 0.5 x -0.5
Gluer
still Gluer
Gluer result
-~~~~~
+~~~~
Let us create a slot using the linear feature :
-~~~~~
+~~~~{.php}
#create the base model using the multi viewer
mu4
profile p x 5 y 1 x -3 y -0.5 x -1.5 y 0.5 x 0.5 y 4 x -1 y -5
# loads the linear feature arguments
featlf pr w pl 0 0 0.3 0 0 0 0 1
featperform lf result
-~~~~~
+~~~~
Let us create a rib using the revolution feature :
-~~~~~
+~~~~{.php}
#create the base model using the multi viewer
mu4
pcylinder c1 3 5
# loads the revolution feature arguments
featrf c1 w pl 0 0 0 0 0 1 0.3 0.3 1 1
featperform rf result
-~~~~~
+~~~~
@subsubsection occt_draw_7_11_3 draft
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
draft result shape dirx diry dirz angle shape/surf/length [-IN/-OUT] [Ri/Ro] [-Internal]
-~~~~~
+~~~~
Computes a draft angle surface from a wire. The surface is determined by the draft direction, the inclination of the draft surface, a draft angle, and a limiting distance.
**Note** that the original aim of adding a draft angle to a shape is to produce a shape which can be removed easily from a mould. The Examples below use larger angles than are used normally and the calculation results returned are not indicated.
**Example:**
-~~~~~
+~~~~{.php}
# to create a simple profile
profile p F 0 0 x 2 y 4 tt 0 4 w
# creates a draft with rounded angles
profile p F 0 0 x 2 y 4 tt 1 1.5 tt 0 4 w
# creates a draft with rounded external angles
draft res p 0 0 1 3 1 -Ro
-~~~~~
+~~~~
@subsubsection occt_draw_7_11_4 deform
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
deform newname name CoeffX CoeffY CoeffZ
-~~~~~
+~~~~
Modifies the shape using the x, y, and z coefficients. You can reduce or magnify the shape in the x,y, and z directions.
**Example:**
-~~~~~
+~~~~{.php}
pcylinder c 20 20
deform a c 1 3 5
# the conversion to bspline is followed by the
deformation
-~~~~~
+~~~~
@subsubsection occt_draw_7_11_5 nurbsconvert
Syntax:
-~~~~~
+~~~~{.php}
nurbsconvert result name [result name]
-~~~~~
+~~~~
Changes the NURBS curve definition of a shape to a Bspline curve definition.
This conversion is required for asymmetric deformation and prepares the arguments for other commands such as **deform**.
**edgestofaces** - The command allows building planar faces from the planar edges randomly located in 3D space.
It has the following syntax:
-~~~~
+~~~~{.php}
edgestofaces r_faces edges [-a AngTol -s Shared(0/1)]
~~~~
Options:
By default it is TRUE, i.e. the history is filled and saved.
Syntax:
-~~~~
+~~~~{.php}
setfillhistory : Controls the history collection by the algorithms and its saving into the session after algorithm is done.
Usage: setfillhistory [flag]
w/o arguments prints the current state of the option;
~~~~
Example:
-~~~~
+~~~~{.php}
box b1 10 10 10
box b2 10 10 10
setfillhistory 0
*savehistory* command saves the history from the session into a drawable object with the given name.
Syntax:
-~~~~
+~~~~{.php}
savehistory : savehistory name
~~~~
If another operation supporting history will be performed before the history of the first operation is saved it will be overwritten with the new history.
Example:
-~~~~
+~~~~{.php}
box b1 10 10 10
box b2 5 0 0 10 10 15
bfuse r b1 b2
*isdeleted* command checks if the given shape has been deleted in the given history.
Syntax:
-~~~~
+~~~~{.php}
isdeleted : isdeleted history shape
~~~~
Example:
-~~~~
+~~~~{.php}
box b1 4 4 4 2 2 2
box b2 10 10 10
bcommon r b1 b2
*modified* command returns the shapes Modified from the given shape in the given history. All modified shapes are put into a compound. If the shape has not been modified, the resulting compound will be empty. Note that if the shape has been modified into a single shape only, it will be returned without enclosure into the compound.
Syntax:
-~~~~
+~~~~{.php}
modified : modified modified_shapes history shape
~~~~
Example:
-~~~~
+~~~~{.php}
box b 10 10 10
explode b e
fillet r b 2 b_1
*generated* command returns the shapes Generated from the given shape in the given history. All generated shapes are put into a compound. If no shapes have been generated from the shape, the resulting compound will be empty. Note that; if the shape has generated a single shape only, it will be returned without enclosure into the compound.
Syntax:
-~~~~
+~~~~{.php}
generated : generated generated_shapes history shape
~~~~
Example:
-~~~~
+~~~~{.php}
polyline w1 0 0 0 10 0 0 10 10 0
polyline w2 5 1 10 9 1 10 9 5 10
Draw History mechanism allows fast and easy enabling of the Draw history support for the OCCT algorithms supporting standard history methods.
To enable History commands for the algorithm it is necessary to save the history of the algorithm into the session.
For that, it is necessary to put the following code into the command implementation just after the command is done:
-~~~~
+~~~~{.php}
BRepTest_Objects::SetHistory(ListOfArguments, Algorithm);
~~~~
Here is the example of how it is done in the command performing Split operation (see implementation of the *bapisplit* command):
-~~~~
+~~~~{.php}
BRepAlgoAPI_Splitter aSplitter;
// setting arguments
aSplitter.SetArguments(BOPTest_Objects::Shapes());
@subsubsection occt_draw_7_12_1 vtexture
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vtexture NameOfShape TextureFile
vtexture NameOfShape
vtexture NameOfShape ?
vtexture NameOfShape IdOfTexture
-~~~~~
+~~~~
**TextureFile** identifies the file containing the texture you want. The same syntax without **TextureFile** disables texture mapping. The question-mark <b>?</b> lists available textures. **IdOfTexture** allows applying predefined textures.
@subsubsection occt_draw_7_12_2 vtexscale
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vtexscale NameOfShape ScaleU ScaleV
vtexscale NameOfShape ScaleUV
vtexscale NameOfShape
-~~~~~
+~~~~
*ScaleU* and *Scale V* allow scaling the texture according to the U and V parameters individually, while *ScaleUV* applies the same scale to both parameters.
@subsubsection occt_draw_7_12_3 vtexorigin
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vtexorigin NameOfShape UOrigin VOrigin
vtexorigin NameOfShape UVOrigin
vtexorigin NameOfShape
-~~~~~
+~~~~
*UOrigin* and *VOrigin* allow placing the texture according to the U and V parameters individually, while *UVOrigin* applies the same position value to both parameters.
@subsubsection occt_draw_7_12_4 vtexrepeat
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vtexrepeat NameOfShape URepeat VRepeat
vtexrepeat NameOfShape UVRepeat
vtexrepeat NameOfShape
-~~~~~
+~~~~
*URepeat* and *VRepeat* allow repeating the texture along the U and V parameters individually, while *UVRepeat* applies the same number of repetitions for both parameters.
@subsubsection occt_draw_7_12_5 vtexdefault
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vtexdefault NameOfShape
-~~~~~
+~~~~
*Vtexdefault* sets or resets the texture mapping default parameters.
These commands allow intersecting the shapes only once for building all types of Boolean operations. After *bop* command is done, the other commands in this category use the intersection results prepared by *bop*.
It may be very useful as the intersection part is usually most time-consuming part of the operation.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
bop shape1 shape2
bopcommon result
bopfuse result
bopcut result
boptuc result
-~~~~~
+~~~~
**Example:**
Let's produce all four boolean operations on a box and a cylinder performing intersection only once:
-~~~~~
+~~~~{.php}
box b 0 -10 5 20 20 10
pcylinder c 5 20
# section operation
bopsection s5
-~~~~~
+~~~~
@subsubsection occt_draw_bop_two_bapi bfuse, bcut, btuc, bcommon, bsection
Each of these commands performs both intersection and building the result and may be useful if you need only the result of a single boolean operation.
Syntax:
-~~~~~
+~~~~{.php}
bcommon result shape1 shape2
bfuse result shape1 shape2
bcut result shape1 shape2
btuc result shape1 shape2
-~~~~~
+~~~~
**bection** command has some additional options for faces intersection:
-~~~~
+~~~~{.php}
bsection result shape1 shape2 [-n2d/-n2d1/-n2d2] [-na]
+~~~~
Where:
result - result of the operation
-n2d1 - disables PCurve construction on first object
-n2d2 - disables PCurve construction on second object
-na - disables approximation of the section curves
-~~~~
@subsection occt_draw_bop_multi Boolean Operations on multiple arguments
The command **bbop** is used for building the result of Boolean Operation. It has to be used after **bfillds** command.
Syntax:
-~~~~
+~~~~{.php}
bbop result iOp
+~~~~
Where:
result - result of the operation
2 - CUT operation
3 - CUT21 (opposite CUT, i.e. objects and tools are swapped) operation
4 - SECTION operation
-~~~~
+
**Example**
-~~~~
+~~~~{.php}
box b1 10 10 10
box b2 5 5 5 10 10 10
box b3 -5 -5 -5 10 10 10
General Fuse operation does not make the difference between Objects and Tools considering both as objects.
Syntax:
-~~~~
+~~~~{.php}
bbuild result
~~~~
**Example**
-~~~~
+~~~~{.php}
box b1 10 10 10
box b2 5 5 5 10 10 10
box b3 -5 -5 -5 10 10 10
The command **bsplit** is used for building the result of Split operation. It has to be used after **bfillds** command.
**Example**
-~~~~
+~~~~{.php}
box b1 10 10 10
box b2 5 5 5 10 10 10
box b3 -5 -5 -5 10 10 10
* History information for solids will be lost.
Syntax:
-~~~~
+~~~~{.php}
buildbop result -o s1 [s2 ...] -t s3 [s4 ...] -op operation (common/fuse/cut/tuc)
+~~~~
Where:
result - result shape of the operation
s1 s2 s3 s4 - arguments (solids) of the GF operation
operation - type of boolean operation
-~~~~
+
**Example**
-~~~~
+~~~~{.php}
box b1 10 10 10
box b2 5 5 5 10 10 10
box b3 -5 -5 -5 10 10 10
The algorithms in Boolean component have a wide range of options.
To see the current state of all option the command **boptions** should be used.
It has the following syntax:
-~~~~
+~~~~{.php}
boptions [-default]
-default - allows to set all options to default state.
**brunparallel** command enables/disables the parallel processing mode of the operation.
Syntax:
-~~~~
+~~~~{.php}
brunparallel flag
-
+~~~~
Where:
flag is the boolean flag controlling the mode:
flag == 0 - parallel processing mode is off.
flag != 0 - parallel processing mode is on.
-~~~~
+
The command is applicable for all commands in the component.
**bnondestructive** command enables/disables the safe processing mode in which the input arguments are protected from modification.
Syntax:
-~~~~
+~~~~{.php}
bnondestructive flag
-
+~~~~
Where:
flag is the boolean flag controlling the mode:
flag == 0 - safe processing mode is off.
flag != 0 - safe processing mode is on.
-~~~~
+
The command is applicable for all commands in the component.
**bfuzzyvalue** command sets the additional tolerance for operations.
Syntax:
-~~~~
+~~~~{.php}
bfuzzyvalue value
~~~~
**bglue** command sets the gluing mode for the BOP algorithms.
Syntax:
-~~~~
+~~~~{.php}
bglue 0/1/2
-
+~~~~
Where:
0 - disables gluing mode.
1 - enables the Shift gluing mode.
2 - enables the Full gluing mode.
-~~~~
+
The command is applicable for all commands in the component.
**bcheckinverted** command enables/disables the check of the input solids on inverted status in BOP algorithms.
Syntax:
-~~~~
+~~~~{.php}
bcheckinverted 0 (off) / 1 (on)
~~~~
**buseobb** command enables/disables the usage of OBB in BOP algorithms.
Syntax:
-~~~~
+~~~~{.php}
buseobb 0 (off) / 1 (on)
~~~~
**bsimplify** command enables/disables the result simplification after BOP. The command is applicable only to the API variants of GF, BOP and Split operations.
Syntax:
-~~~~
+~~~~{.php}
bsimplify [-e 0/1] [-f 0/1] [-a tol]
-
+~~~~
Where:
-e 0/1 - enables/disables edges unification
-f 0/1 - enables/disables faces unification
-a tol - changes default angular tolerance of unification algo.
-~~~~
+
@subsubsection occt_draw_bop_options_warn Drawing warning shapes
**bdrawwarnshapes** command enables/disables drawing of warning shapes of BOP algorithms.
Syntax:
-~~~~
+~~~~{.php}
bdrawwarnshapes 0 (do not draw) / 1 (draw warning shapes)
~~~~
@subsubsection occt_draw_bop_check_1 bopcheck
Syntax:
-~~~~
+~~~~{.php}
bopcheck shape [level of check: 0 - 9]
~~~~
* 9 - V/V, V/E, E/E, V/F, E/F, F/F, V/S, E/S, F/S and S/S - all interferences (Default value)
**Example:**
-~~~~
+~~~~{.php}
box b1 10 10 10
box b2 3 3 3 4 4 4
compound b1 b2 c
@subsubsection occt_draw_bop_check_2 bopargcheck
**bopargcheck** syntax:
-~~~~
+~~~~{.php}
bopargcheck Shape1 [[Shape2] [-F/O/C/T/S/U] [/R|F|T|V|E|I|P|C|S]] [#BF]
-<Boolean Operation>
**Example:**
Let's make an edge with big vertices:
-~~~~
+~~~~{.php}
vertex v1 0 0 0
settolerance v1 0.5
vertex v2 1 0 0
bopargcheck e
~~~~
Here is the output of this command:
-~~~~
+~~~~{.php}
Made faulty shape: s1si_1
Made faulty shape: s1se_1
Faulties for FIRST shape found : 2
**bopds**
-Syntax:
-~~~~
+Syntax:
+~~~~{.php}
bopds -v [e, f]
~~~~
Prints contents of the DS.
Example:
-~~~~
+~~~~{.php}
Draw[28]> bopdsdump
*** DS ***
Ranges:2 number of ranges
**bopindex**
Syntax:
-~~~~
+~~~~{.php}
bopindex S
~~~~
Prints DS index of shape *S*.
**bopiterator**
Syntax:
-~~~~~
+~~~~{.php}
bopiterator [t1 t2]
-~~~~~
+~~~~
Prints pairs of DS indices of source shapes that are intersected in terms of bounding boxes.
* *4* -- face.
Example:
-~~~~
+~~~~{.php}
Draw[104]> bopiterator 6 4
EF: ( z58 z12 )
EF: ( z17 z56 )
**bopinterf**
-Syntax:
-~~~~
+Syntax:
+~~~~{.php}
bopinterf t
~~~~
* *t=4* : edge/face.
Example:
-~~~~
+~~~~{.php}
Draw[108]> bopinterf 4
EF: (58, 12, 68), (17, 56, 69), (19, 64, 70), (45, 26, 71), (29, 36, 72), (38, 32, 73), 6 EF found.
~~~~
Displays split edges.
Example:
-~~~~
+~~~~{.php}
Draw[33]> bopsp
edge 58 : z58_74 z58_75
edge 17 : z17_76 z17_77
**bopcb**
Syntax:
-~~~~
+~~~~{.php}
bopcb [nE]
~~~~
* the source edge with the specified index *nE*.
Example:
-~~~~
+~~~~{.php}
Draw[43]> bopcb 17
-- CB:
PB:{ E:71 orE:17 Pave1: { 68 3.000 } Pave2: { 18 10.000 } }
**bopfin**
Syntax:
-~~~~
+~~~~{.php}
bopfin nF
~~~~
Prints Face Info about IN-parts for the face with DS index *nF*.
Example:
-~~~~
+~~~~{.php}
Draw[47]> bopfin 36
pave blocks In:
PB:{ E:71 orE:17 Pave1: { 68 3.000 } Pave2: { 18 10.000 } }
**bopfon**
Syntax:
-~~~~
+~~~~{.php}
bopfon nF
~~~~
Print Face Info about ON-parts for the face with DS index *nF*.
Example:
-~~~~
+~~~~{.php}
Draw[58]> bopfon 36
pave blocks On:
PB:{ E:72 orE:38 Pave1: { 69 0.000 } Pave2: { 68 10.000 } }
**bopwho**
Syntax:
-~~~~
+~~~~{.php}
bopwho nS
~~~~
Prints the information about the shape with DS index *nF*.
Example:
-~~~~
+~~~~{.php}
Draw[116]> bopwho 5
rank: 0
~~~~
* *rank: 0* -- means that shape 5 results from the Argument with index 0.
Example:
-~~~~
+~~~~{.php}
Draw[118]> bopwho 68
the shape is new
EF: (58, 12),
**bopnews**
Syntax:
-~~~~
+~~~~{.php}
bopnews -v [-e]
~~~~
**bopim**
-Syntax:
-~~~~
+Syntax:
+~~~~{.php}
bopim S
~~~~
Shows the compound of shapes that are images of shape *S* from the argument.
@subsubsection occt_draw_8_1_1 igesread
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
igesread <file_name> <result_shape_name> [<selection>]
-~~~~~
+~~~~
Reads an IGES file to an OCCT shape. This command will interactively ask the user to select a set of entities to be converted.
See also the detailed description of <a href="user_guides__iges.html#occt_iges_2_3_4">Selecting IGES entities</a>.
**Example:**
-~~~~~
+~~~~{.php}
# translation all roots from file
igesread /disk01/files/model.igs a *
-~~~~~
+~~~~
@subsubsection occt_draw_8_1_2 tplosttrim
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tplosttrim [<IGES_type>]
-~~~~~
+~~~~
Sometimes the trimming contours of IGES faces (i.e., entity 141 for 143, 142 for 144) can be lost during translation due to fails. This command gives us a number of lost trims and the number of corresponding IGES entities.
It outputs the rank and numbers of faces that lost their trims and their numbers for each type (143, 144, 510) and their total number. If a face lost several of its trims it is output only once.
Optional parameter <i>\<IGES_type\></i> can be *0TrimmedSurface, BoundedSurface* or *Face* to specify the only type of IGES faces.
**Example:**
-~~~~~
+~~~~{.php}
tplosttrim TrimmedSurface
-~~~~~
+~~~~
@subsubsection occt_draw_8_1_3 brepiges
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
brepiges <shape_name> <filename.igs>
-~~~~~
+~~~~
Writes an OCCT shape to an IGES file.
**Example:**
-~~~~~
+~~~~{.php}
# write shape with name aa to IGES file
brepiges aa /disk1/tmp/aaa.igs
== unit (write) : MM
== Now, to write a file, command : writeall filename
== Output on file : /disk1/tmp/aaa.igs
== Write OK
-~~~~~
+~~~~
@subsection occt_draw_8_2 STEP commands
@subsubsection occt_draw_8_2_1 stepread
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
stepread file_name result_shape_name [selection]
-~~~~~
+~~~~
Read a STEP file to an OCCT shape.
This command will interactively ask the user to select a set of entities to be converted:
See also the detailed description of <a href="user_guides__step.html#occt_step_2_3_6">Selecting STEP entities</a>.
**Example:**
-~~~~~
+~~~~{.php}
# translation all roots from file
stepread /disk01/files/model.stp a *
-~~~~~
+~~~~
@subsubsection occt_draw_8_2_2 stepwrite
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
stepwrite mode shape_name file_name
-~~~~~
+~~~~
Writes an OCCT shape to a STEP file.
Let us write shape *a* to a STEP file in mode *0*.
-~~~~~
+~~~~{.php}
stepwrite 0 a /disk1/tmp/aaa.igs
-~~~~~
+~~~~
@subsection occt_draw_8_3 General commands
@subsubsection occt_draw_8_3_1 count
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
count <counter> [<selection>]
-~~~~~
+~~~~
Calculates statistics on the entities in the model and outputs a count of entities.
| step214-types | Calculates how many entities of each STEP type exist |
**Example:**
-~~~~~
+~~~~{.php}
count xst-types
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_2 data
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
data <symbol>
-~~~~~
+~~~~
Obtains general statistics on the loaded data.
The information printed by this command depends on the symbol specified.
**Example:**
-~~~~~
+~~~~{.php}
# print full information about warnings and fails
data c
-~~~~~
+~~~~
| Symbol | Output |
| :------ | :------ |
@subsubsection occt_draw_8_3_3 elabel
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
elabel <num>
-~~~~~
+~~~~
Entities in the IGES and STEP files are numbered in the succeeding order. An entity can be identified either by its number or by its label. Label is the letter ‘#'(for STEP, for IGES use ‘D’) followed by the rank. This command gives us a label for an entity with a known number.
**Example:**
-~~~~~
+~~~~{.php}
elabel 84
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_4 entity
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
entity <#(D)>_or_<num> <level_of_information>
-~~~~~
+~~~~
The content of an IGES or STEP entity can be obtained by using this command.
Entity can be determined by its number or label.
<i>\<level_of_information\></i> has range [0-6]. You can get more information about this level using this command without parameters.
**Example:**
-~~~~~
+~~~~{.php}
# full information for STEP entity with label 84
entity #84 6
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_5 enum
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
enum <#(D)>
-~~~~~
+~~~~
Prints a number for the entity with a given label.
**Example:**
-~~~~~
+~~~~{.php}
# give a number for IGES entity with label 21
enum D21
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_6 estatus
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
estatus <#(D)>_or_<num>
-~~~~~
+~~~~
The list of entities referenced by a given entity and the list of entities referencing to it can be obtained by this command.
**Example:**
-~~~~~
+~~~~{.php}
estatus #315
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_7 fromshape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
fromshape <shape_name>
-~~~~~
+~~~~
Gives the number of an IGES or STEP entity corresponding to an OCCT shape. If no corresponding entity can be found and if OCCT shape is a compound the command explodes it to subshapes and try to find corresponding entities for them.
**Example:**
-~~~~~
+~~~~{.php}
fromshape a_1_23
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_8 givecount
Syntax:
-~~~~~
+~~~~{.php}
givecount <selection_name> [<selection_name>]
-~~~~~
+~~~~
Prints a number of loaded entities defined by the selection argument.
Possible values of \<selection_name\> you can find in the “IGES FORMAT Users’s Guide”.
**Example:**
-~~~~~
+~~~~{.php}
givecount xst-model-roots
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_9 givelist
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
givelist <selection_name>
-~~~~~
+~~~~
Prints a list of a subset of loaded entities defined by the selection argument:
| Selection | Description |
**Example:**
-~~~~~
+~~~~{.php}
# give a list of all entities of the model
givelist xst-model-all
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_10 listcount
-Syntax: listcount \<counter\> [\<selection\> ...]
+Syntax:listcount \<counter\> [\<selection\> ...]
Prints a list of entities per each type matching the criteria defined by arguments.
Optional <i>\<selection\></i> argument, if specified, defines a subset of entities, which are to be taken into account. Argument <i>\<counter\></i> should be one of the currently defined counters:
| iges-levels | Calculates how many entities lie in different IGES levels |
**Example:**
-~~~~~
+~~~~{.php}
listcount xst-types
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_11 listitems
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
listitems
-~~~~~
+~~~~
This command prints a list of objects (counters, selections etc.) defined in the current session.
@subsubsection occt_draw_8_3_12 listtypes
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
listtypes [<selection_name> ...]
-~~~~~
+~~~~
Gives a list of entity types which were encountered in the last loaded file (with a number of entities of each type). The list can be shown not for all entities but for a subset of them. This subset is defined by an optional selection argument.
@subsubsection occt_draw_8_3_13 newmodel
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
newmodel
-~~~~~
+~~~~
Clears the current model.
@subsubsection occt_draw_8_3_14 param
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
param [<parameter>] [<value>]
-~~~~~
+~~~~
This command is used to manage translation parameters.
Command without arguments gives a full list of parameters with current values.
Let us get the information about possible schemes for writing STEP file :
-~~~~~
+~~~~{.php}
param write.step.schema
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_15 sumcount
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
sumcount <counter> [<selection> ...]
-~~~~~
+~~~~
Prints only a number of entities per each type matching the criteria defined by arguments.
**Example:**
-~~~~~
+~~~~{.php}
sumcount xst-types
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_16 tpclear
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tpclear
-~~~~~
+~~~~
Clears the map of correspondences between IGES or STEP entities and OCCT shapes.
@subsubsection occt_draw_8_3_17 tpdraw
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tpdraw <#(D)>_or_<num>
-~~~~~
+~~~~
**Example:**
-~~~~~
+~~~~{.php}
tpdraw 57
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_18 tpent
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tpent <#(D)>_or_<num>
-~~~~~
+~~~~
Get information about the result of translation of the given IGES or STEP entity.
**Example:**
-~~~~~
+~~~~{.php}
tpent \#23
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_19 tpstat
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tpstat [*|?]<symbol> [<selection>]
-~~~~~
+~~~~
Provides all statistics on the last transfer, including a list of transferred entities with mapping from IGES or STEP to OCCT types, as well as fail and warning messages. The parameter <i>\<symbol\></i> defines what information will be printed:
To get help, run this command without arguments.
**Example:**
-~~~~~
+~~~~{.php}
# translation ratio on IGES faces
tpstat *l iges-faces
-~~~~~
+~~~~
@subsubsection occt_draw_8_3_20 xload
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
xload <file_name>
-~~~~~
+~~~~
This command loads an IGES or STEP file into memory (i.e. to fill the model with data from the file) without creation of an OCCT shape.
**Example:**
-~~~~~
+~~~~{.php}
xload /disk1/tmp/aaa.stp
-~~~~~
+~~~~
@subsection occt_draw_8_4 Overview of XDE commands
@subsubsection occt_draw_8_4_1 ReadIges
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ReadIges document file_name
-~~~~~
+~~~~
Reads information from an IGES file to an XCAF document.
**Example:**
-~~~~~
+~~~~{.php}
ReadIges D /disk1/tmp/aaa.igs
==> Document saved with name D
-~~~~~
+~~~~
@subsubsection occt_draw_8_4_2 ReadStep
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
ReadStep <document> <file_name>
-~~~~~
+~~~~
Reads information from a STEP file to an XCAF document.
**Example:**
-~~~~~
+~~~~{.php}
ReadStep D /disk1/tmp/aaa.stp
== Document saved with name D
-~~~~~
+~~~~
@subsubsection occt_draw_8_4_3 WriteIges
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
WriteIges <document> <file_name>
-~~~~~
+~~~~
**Example:**
-~~~~~
+~~~~{.php}
WriteIges D /disk1/tmp/aaa.igs
-~~~~~
+~~~~
@subsubsection occt_draw_8_4_4 WriteStep
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
WriteStep <document> <file_name>
-~~~~~
+~~~~
Writes information from an XCAF document to a STEP file.
**Example:**
-~~~~~
+~~~~{.php}
WriteStep D /disk1/tmp/aaa.stp
-~~~~~
+~~~~
@subsubsection occt_draw_8_4_5 XFileCur
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XFileCur
-~~~~~
+~~~~
Returns the name of file which is set as the current one in the Draw session.
**Example:**
-~~~~~
+~~~~{.php}
XFileCur
== *as1-ct-203.stp*
-~~~~~
+~~~~
@subsubsection occt_draw_8_4_6 XFileList
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XFileList
-~~~~~
+~~~~
Returns a list all files that were transferred by the last transfer. This command is meant (assigned) for the assemble step file.
**Example:**
-~~~~~
+~~~~{.php}
XFileList
==> *as1-ct-Bolt.stp*
==> *as1-ct-L-Bracktet.stp*
==> *as1-ct-LBA.stp*
==> *as1-ct-NBA.stp*
==> …
-~~~~~
+~~~~
@subsubsection occt_draw_8_4_7 XFileSet
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XFileSet <filename>
-~~~~~
+~~~~
Sets the current file taking it from the components list of the assemble file.
**Example:**
-~~~~~
+~~~~{.php}
XFileSet as1-ct-NBA.stp
-~~~~~
+~~~~
@subsubsection occt_draw_8_4_8 XFromShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XFromShape <shape>
-~~~~~
+~~~~
This command is similar to the command @ref occt_draw_8_3_7 "fromshape", but gives additional information about the file name. It is useful if a shape was translated from several files.
**Example:**
-~~~~~
+~~~~{.php}
XFromShape a
==> Shape a: imported from entity 217:#26 in file as1-ct-Nut.stp
-~~~~~
+~~~~
@subsection occt_draw_8_5 XDE general commands
@subsubsection occt_draw_8_5_1 XNewDoc
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XNewDoc <document>
-~~~~~
+~~~~
Creates a new XCAF document.
**Example:**
-~~~~~
+~~~~{.php}
XNewDoc D
-~~~~~
+~~~~
@subsubsection occt_draw_8_5_2 XShow
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XShow <document> [ <label1> … ]
-~~~~~
+~~~~
Shows a shape from a given label in the 3D viewer. If the label is not given -- shows all shapes from the document.
**Example:**
-~~~~~
+~~~~{.php}
# show shape from label 0:1:1:4 from document D
XShow D 0:1:1:4
-~~~~~
+~~~~
@subsubsection occt_draw_8_5_3 XStat
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XStat <document>
-~~~~~
+~~~~
Prints common information from an XCAF document.
**Example:**
-~~~~~
+~~~~{.php}
XStat D
==>Statistis of shapes in the document:
==>level N 0 : 9
==>Number of colors = 4
==>BLUE1 RED YELLOW BLUE2
==>Number of layers = 0
-~~~~~
+~~~~
@subsubsection occt_draw_8_5_4 XWdump
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XWdump <document> <filename>
-~~~~~
+~~~~
Saves the contents of the viewer window as an image (XWD, png or BMP file).
<i>\<filename\></i> must have a corresponding extension.
**Example:**
-~~~~~
+~~~~{.php}
XWdump D /disk1/tmp/image.png
-~~~~~
+~~~~
@subsubsection occt_draw_8_5_5 Xdump
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
Xdump <document> [int deep {0|1}]
-~~~~~
+~~~~
Prints information about the tree structure of the document. If parameter 1 is given, then the tree is printed with a link to shapes.
**Example:**
-~~~~~
+~~~~{.php}
Xdump D 1
==> ASSEMBLY 0:1:1:1 L-BRACKET(0xe8180448)
==> ASSEMBLY 0:1:1:2 NUT(0xe82151e8)
==> ASSEMBLY 0:1:1:2 NUT(0xe82151e8)
==> ASSEMBLY 0:1:1:3 BOLT(0xe829b000)
etc.
-~~~~~
+~~~~
@subsection occt_draw_8_6 XDE shape commands
@subsubsection occt_draw_8_6_1 XAddComponent
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XAddComponent <document> <label> <shape>
-~~~~~
+~~~~
Adds a component shape to assembly.
Let us add shape b as component shape to assembly shape from label *0:1:1:1*
-~~~~~
+~~~~{.php}
XAddComponent D 0:1:1:1 b
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_2 XAddShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XAddShape <document> <shape> [makeassembly=1]
-~~~~~
+~~~~
Adds a shape (or an assembly) to a document. If this shape already exists in the document, then prints the label which points to it. By default, a new shape is added as an assembly (i.e. last parameter 1), otherwise it is necessary to pass 0 as the last parameter.
**Example:**
-~~~~~
+~~~~{.php}
# add shape b to document D
XAddShape D b 0
== 0:1:1:10
# if pointed shape is compound and last parameter in
# XAddShape command is used by default (1), then for
# each subshapes new label is created
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_3 XFindComponent
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XFindComponent <document> <shape>
-~~~~~
+~~~~
Prints a sequence of labels of the assembly path.
**Example:**
-~~~~~
+~~~~{.php}
XFindComponent D b
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_4 XFindShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XFindShape <document> <shape>
-~~~~~
+~~~~
Finds and prints a label with an indicated top-level shape.
**Example:**
-~~~~~
+~~~~{.php}
XFindShape D a
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_5 XGetFreeShapes
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetFreeShapes <document> [shape_prefix]
-~~~~~
+~~~~
Print labels or create DRAW shapes for all free shapes in the document.
If *shape_prefix* is absent -- prints labels, else -- creates DRAW shapes with names
**Note**: a free shape is a shape to which no other shape refers to.
**Example:**
-~~~~~
+~~~~{.php}
XGetFreeShapes D
== 0:1:1:6 0:1:1:10 0:1:1:12 0:1:1:13
XGetFreeShapes D sh
== sh_1 sh_2 sh_3 sh_4
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_6 XGetOneShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetOneShape <shape> <document>
-~~~~~
+~~~~
Creates one DRAW shape for all free shapes from a document.
**Example:**
-~~~~~
+~~~~{.php}
XGetOneShape a D
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_7 XGetReferredShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetReferredShape <document> <label>
-~~~~~
+~~~~
Prints a label that contains a top-level shape that corresponds to a shape at a given label.
**Example:**
-~~~~~
+~~~~{.php}
XGetReferredShape D 0:1:1:1:1
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_8 XGetShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetShape <result> <document> <label>
-~~~~~
+~~~~
Puts a shape from the indicated label in document to result.
**Example:**
-~~~~~
+~~~~{.php}
XGetShape b D 0:1:1:3
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_9 XGetTopLevelShapes
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetTopLevelShapes <document>
-~~~~~
+~~~~
Prints labels that contain top-level shapes.
**Example:**
-~~~~~
+~~~~{.php}
XGetTopLevelShapes D
== 0:1:1:1 0:1:1:2 0:1:1:3 0:1:1:4 0:1:1:5 0:1:1:6 0:1:1:7
0:1:1:8 0:1:1:9
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_10 XLabelInfo
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XLabelInfo <document> <label>
-~~~~~
+~~~~
Prints information about a shape, stored at an indicated label.
**Example:**
-~~~~~
+~~~~{.php}
XLabelInfo D 0:1:1:6
==> There are TopLevel shapes. There is an Assembly. This Shape is not used.
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_11 XNewShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XNewShape <document>
-~~~~~
+~~~~
Creates a new empty top-level shape.
**Example:**
-~~~~~
+~~~~{.php}
XNewShape D
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_12 XRemoveComponent
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XRemoveComponent <document> <label>
-~~~~~
+~~~~
Removes a component from the components label.
**Example:**
-~~~~~
+~~~~{.php}
XRemoveComponent D 0:1:1:1:1
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_13 XRemoveShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XRemoveShape <document> <label>
-~~~~~
+~~~~
Removes a shape from a document (by it’s label).
**Example:**
-~~~~~
+~~~~{.php}
XRemoveShape D 0:1:1:2
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_14 XSetShape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XSetShape <document> <label> <shape>
-~~~~~
+~~~~
Sets a shape at the indicated label.
**Example:**
-~~~~~
+~~~~{.php}
XSetShape D 0:1:1:3 b
-~~~~~
+~~~~
@subsubsection occt_draw_8_6_15 XUpdateAssemblies
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XUpdateAssemblies <document>
-~~~~~
+~~~~
Updates all assembly compounds in the XDE document.
**Example:**
-~~~~~
+~~~~{.php}
XUpdateAssemblies D
-~~~~~
+~~~~
@subsection occt_draw_8_7_ XDE color commands
@subsubsection occt_draw_8_7_1 XAddColor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XAddColor <document> <R> <G> <B>
-~~~~~
+~~~~
Adds color in document to the color table. Parameters R,G,B are real.
**Example:**
-~~~~~
+~~~~{.php}
XAddColor D 0.5 0.25 0.25
-~~~~~
+~~~~
@subsubsection occt_draw_8_7_2 XFindColor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XFindColor <document> <R> <G> <B>
-~~~~~
+~~~~
Finds a label where the indicated color is situated.
**Example:**
-~~~~~
+~~~~{.php}
XFindColor D 0.25 0.25 0.5
==> 0:1:2:2
-~~~~~
+~~~~
@subsubsection occt_draw_8_7_3 XGetAllColors
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetAllColors <document>
-~~~~~
+~~~~
Prints all colors that are defined in the document.
**Example:**
-~~~~~
+~~~~{.php}
XGetAllColors D
==> RED DARKORANGE BLUE1 GREEN YELLOW3
-~~~~~
+~~~~
@subsubsection occt_draw_8_7_4 XGetColor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetColor <document> <label>
-~~~~~
+~~~~
Returns a color defined at the indicated label from the color table.
**Example:**
-~~~~~
+~~~~{.php}
XGetColor D 0:1:2:3
== BLUE1
-~~~~~
+~~~~
@subsubsection occt_draw_8_7_5 XGetObjVisibility
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetObjVisibility <document> {<label>|<shape>}
-~~~~~
+~~~~
Returns the visibility of a shape.
**Example:**
-~~~~~
+~~~~{.php}
XGetObjVisibility D 0:1:1:4
-~~~~~
+~~~~
@subsubsection occt_draw_8_7_6 XGetShapeColor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetShapeColor <document> <label> <colortype(s|c)>
-~~~~~
+~~~~
Returns the color defined by label. If <i>colortype</i>=’s’ -- returns surface color, else -- returns curve color.
**Example:**
-~~~~~
+~~~~{.php}
XGetShapeColor D 0:1:1:4 c
-~~~~~
+~~~~
@subsubsection occt_draw_8_7_7 XRemoveColor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XRemoveColor <document> <label>
-~~~~~
+~~~~
Removes a color from the color table in a document.
**Example:**
-~~~~~
+~~~~{.php}
XRemoveColor D 0:1:2:1
-~~~~~
+~~~~
@subsubsection occt_draw_8_7_8 XSetColor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XSetColor <document> {<label>|<shape>} <R> <G> <B>
-~~~~~
+~~~~
Sets an RGB color to a shape given by label.
**Example:**
-~~~~~
+~~~~{.php}
XsetColor D 0:1:1:4 0.5 0.5 0.
-~~~~~
+~~~~
@subsubsection occt_draw_8_7_9 XSetObjVisibility
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XSetObjVisibility <document> {<label>|<shape>} {0|1}
-~~~~~
+~~~~
Sets the visibility of a shape.
**Example:**
-~~~~~
+~~~~{.php}
# set shape from label 0:1:1:4 as invisible
XSetObjVisibility D 0:1:1:4 0
-~~~~~
+~~~~
@subsubsection occt_draw_8_7_10 XUnsetColor
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XUnsetColor <document> {<label>|<shape>} <colortype>
-~~~~~
+~~~~
Unset a color given type (‘s’ or ‘c’) for the indicated shape.
**Example:**
-~~~~~
+~~~~{.php}
XUnsetColor D 0:1:1:4 s
-~~~~~
+~~~~
@subsection occt_draw_8_8_ XDE layer commands
@subsubsection occt_draw_8_8_1 XAddLayer
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XAddLayer <document> <layer>
-~~~~~
+~~~~
Adds a new layer in an XCAF document.
**Example:**
-~~~~~
+~~~~{.php}
XAddLayer D layer2
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_2 XFindLayer
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XFindLayer <document> <layer>
-~~~~~
+~~~~
Prints a label where a layer is situated.
**Example:**
-~~~~~
+~~~~{.php}
XFindLayer D Bolt
== 0:1:3:2
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_3 XGetAllLayers
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetAllLayers <document>
-~~~~~
+~~~~
Prints all layers in an XCAF document.
**Example:**
-~~~~~
+~~~~{.php}
XGetAllLayers D
== *0:1:1:3* *Bolt* *0:1:1:9*
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_4 XGetLayers
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetLayers <document> {<shape>|<label>}
-~~~~~
+~~~~
Returns names of layers, which are pointed to by links of an indicated shape.
**Example:**
-~~~~~
+~~~~{.php}
XGetLayers D 0:1:1:3
== *bolt* *123*
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_5 XGetOneLayer
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetOneLayer <document> <label>
-~~~~~
+~~~~
Prints the name of a layer at a given label.
**Example:**
-~~~~~
+~~~~{.php}
XGetOneLayer D 0:1:3:2
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_6 XIsVisible
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XIsVisible <document> {<label>|<layer>}
-~~~~~
+~~~~
Returns 1 if the indicated layer is visible, else returns 0.
**Example:**
-~~~~~
+~~~~{.php}
XIsVisible D 0:1:3:1
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_7 XRemoveAllLayers
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XRemoveAllLayers <document>
-~~~~~
+~~~~
Removes all layers from an XCAF document.
**Example:**
-~~~~~
+~~~~{.php}
XRemoveAllLayers D
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_8 XRemoveLayer
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XRemoveLayer <document> {<label>|<layer>}
-~~~~~
+~~~~
Removes the indicated layer from an XCAF document.
**Example:**
-~~~~~
+~~~~{.php}
XRemoveLayer D layer2
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_9 XSetLayer
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XSetLayer XSetLayer <document> {<shape>|<label>} <layer> [shape_in_one_layer {0|1}]
-~~~~~
+~~~~
Sets a reference between a shape and a layer (adds a layer if it is necessary).
Parameter <i>\<shape_in_one_layer\></i> shows whether a shape could be in a number of layers or only in one (0 by default).
**Example:**
-~~~~~
+~~~~{.php}
XSetLayer D 0:1:1:2 layer2
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_10 XSetVisibility
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XSetVisibility <document> {<label>|<layer>} <isvisible {0|1}>
-~~~~~
+~~~~
Sets the visibility of a layer.
**Example:**
-~~~~~
+~~~~{.php}
# set layer at label 0:1:3:2 as invisible
XSetVisibility D 0:1:3:2 0
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_11 XUnSetAllLayers
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XUnSetAllLayers <document> {<label>|<shape>}
-~~~~~
+~~~~
Unsets a shape from all layers.
**Example:**
-~~~~~
+~~~~{.php}
XUnSetAllLayers D 0:1:1:2
-~~~~~
+~~~~
@subsubsection occt_draw_8_8_12 XUnSetLayer
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XUnSetLayer <document> {<label>|<shape>} <layer>
-~~~~~
+~~~~
Unsets a shape from the indicated layer.
**Example:**
-~~~~~
+~~~~{.php}
XUnSetLayer D 0:1:1:2 layer1
-~~~~~
+~~~~
@subsection occt_draw_8_9 XDE property commands
@subsubsection occt_draw_8_9_1 XCheckProps
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XCheckProps <document> [ {0|deflection} [<shape>|<label>] ]
-~~~~~
+~~~~
Gets properties for a given shape (*volume*, *area* and <i>centroid</i>) and compares them with the results after internal calculations. If the second parameter is 0, the standard OCCT tool is used for the computation of properties. If the second parameter is not 0, it is processed as a deflection. If the deflection is positive the computation is done by triangulations, if it is negative -- meshing is forced.
**Example:**
-~~~~~
+~~~~{.php}
# check properties for shapes at label 0:1:1:1 from
# document using standard Open CASCADE Technology tools
XCheckProps D 0 0:1:1:1
== Area defect: -0.0 ( 0%)
== Volume defect: 0.0 ( 0%)
== CG defect: dX=-0.000, dY=0.000, dZ=0.000
-~~~~~
+~~~~
@subsubsection occt_draw_8_9_2 XGetArea
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetArea <document> {<shape>|<label>}
-~~~~~
+~~~~
Returns the area of a given shape.
**Example:**
-~~~~~
+~~~~{.php}
XGetArea D 0:1:1:1
== 24628.31815094999
-~~~~~
+~~~~
@subsubsection occt_draw_8_9_3 XGetCentroid
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetCentroid <document> {<shape>|<label>}
-~~~~~
+~~~~
Returns the center of gravity coordinates of a given shape.
**Example:**
-~~~~~
+~~~~{.php}
XGetCentroid D 0:1:1:1
-~~~~~
+~~~~
@subsubsection occt_draw_8_9_4 XGetVolume
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XGetVolume <document> {<shape>|<label>}
-~~~~~
+~~~~
Returns the volume of a given shape.
**Example:**
-~~~~~
+~~~~{.php}
XGetVolume D 0:1:1:1
-~~~~~
+~~~~
@subsubsection occt_draw_8_9_5 XSetArea
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XSetArea <document> {<shape>|<label>} <area>
-~~~~~
+~~~~
Sets new area to attribute list ??? given shape.
**Example:**
-~~~~~
+~~~~{.php}
XSetArea D 0:1:1:1 2233.99
-~~~~~
+~~~~
@subsubsection occt_draw_8_9_6 XSetCentroid
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XSetCentroid <document> {<shape>|<label>} <x> <y> <z>
-~~~~~
+~~~~
Sets new center of gravity to the attribute list given shape.
**Example:**
-~~~~~
+~~~~{.php}
XSetCentroid D 0:1:1:1 0. 0. 100.
-~~~~~
+~~~~
@subsubsection occt_draw_8_9_7 XSetMaterial
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XSetMaterial <document> {<shape>|<label>} <name> <density(g/cu sm)>
-~~~~~
+~~~~
Adds a new label with material into the material table in a document, and adds a link to this material to the attribute list of a given shape or a given label. The last parameter sets the density of a pointed material.
**Example:**
-~~~~~
+~~~~{.php}
XSetMaterial D 0:1:1:1 Titanium 8899.77
-~~~~~
+~~~~
@subsubsection occt_draw_8_9_8 XSetVolume
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XSetVolume <document> {<shape>|<label>} <volume>
-~~~~~
+~~~~
Sets new volume to the attribute list ??? given shape.
**Example:**
-~~~~~
+~~~~{.php}
XSetVolume D 0:1:1:1 444555.33
-~~~~~
+~~~~
@subsubsection occt_draw_8_9_9 XShapeMassProps
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XShapeMassProps <document> [ <deflection> [{<shape>|<label>}] ]
-~~~~~
+~~~~
Computes and returns real mass and real center of gravity for a given shape or for all shapes in a document. The second parameter is used for calculation of the volume and CG(center of gravity). If it is 0, then the standard CASCADE tool (geometry) is used for computation, otherwise -- by triangulations with a given deflection.
**Example:**
-~~~~~
+~~~~{.php}
XShapeMassProps D
== Shape from label : 0:1:1:1
== Mass = 193.71681469282299
20.20271885211281,Z = 49.999999385313245
== Shape from label : 0:1:1:2 not have a mass
etc.
-~~~~~
+~~~~
@subsubsection occt_draw_8_9_10 XShapeVolume
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
XShapeVolume <shape> <deflection>
-~~~~~
+~~~~
Calculates the real volume of a pointed shape with a given deflection.
**Example:**
-~~~~~
+~~~~{.php}
XShapeVolume a 0
-~~~~~
+~~~~
@section occt_draw_9 Shape Healing commands
@subsubsection occt_draw_9_1_1 bsplres
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
bsplres <result> <shape> <tol3d> <tol2d< <reqdegree> <reqnbsegments> <continuity3d> <continuity2d> <PriorDeg> <RationalConvert>
-~~~~~
+~~~~
Performs approximations of a given shape (BSpline curves and surfaces or other surfaces) to BSpline with given required parameters. The specified continuity can be reduced if the approximation with a specified continuity was not done successfully. Results are put into the shape, which is given as a parameter result. For a more detailed description see the ShapeHealing User’s Guide (operator: **BSplineRestriction**).
@subsubsection occt_draw_9_1_2 checkfclass2d
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
checkfclass2d <face> <ucoord> <vcoord>
-~~~~~
+~~~~
Shows where a point which is given by coordinates is located in relation to a given face -- outbound, inside or at the bounds.
**Example:**
-~~~~~
+~~~~{.php}
checkfclass2d f 10.5 1.1
== Point is OUT
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_3 checkoverlapedges
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
checkoverlapedges <edge1> <edge2> [<toler> <domaindist>]
-~~~~~
+~~~~
Checks the overlapping of two given edges. If the distance between two edges is less than the given value of tolerance then edges are overlapped. Parameter \<domaindist\> sets length of part of edges on which edges are overlapped.
**Example:**
-~~~~~
+~~~~{.php}
checkoverlapedges e1 e2
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_4 comtol
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
comptol <shape> [nbpoints] [prefix]
-~~~~~
+~~~~
Compares the real value of tolerance on curves with the value calculated by standard (using 23 points). The maximal value of deviation of 3d curve from pcurve at given simple points is taken as a real value (371 is by default). Command returns the maximal, minimal and average value of tolerance for all edges and difference between real values and set values. Edges with the maximal value of tolerance and relation will be saved if the ‘prefix’ parameter is given.
**Example:**
-~~~~~
+~~~~{.php}
comptol h 871 t
==> Edges tolerance computed by 871 points:
==> MAX=0.80001130696523448 AVG=0.06349345591805905 MIN=0
==> Edge with max tolerance saved to t_edge_tol
==> Concerned faces saved to shapes t_1, t_2
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_5 convtorevol
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
convtorevol <result> <shape>
-~~~~~
+~~~~
Converts all elementary surfaces of a given shape into surfaces of revolution.
Results are put into the shape, which is given as the <i>\<result\></i> parameter.
**Example:**
-~~~~~
+~~~~{.php}
convtorevol r a
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_6 directfaces
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
directfaces <result> <shape>
-~~~~~
+~~~~
Converts indirect surfaces and returns the results into the shape, which is given as the result parameter.
**Example:**
-~~~~~
+~~~~{.php}
directfaces r a
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_7 expshape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
expshape <shape> <maxdegree> <maxseg>
-~~~~~
+~~~~
Gives statistics for a given shape. This test command is working with Bezier and BSpline entities.
**Example:**
-~~~~~
+~~~~{.php}
expshape a 10 10
==> Number of Rational Bspline curves 128
==> Number of Rational Bspline pcurves 48
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_8 fixsmall
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
fixsmall <result> <shape> [<toler>=1.]
-~~~~~
+~~~~
Fixes small edges in given shape by merging adjacent edges with agiven tolerance. Results are put into the shape, which is given as the result parameter.
**Example:**
-~~~~~
+~~~~{.php}
fixsmall r a 0.1
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_9 fixsmalledges
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
fixsmalledges <result> <shape> [<toler> <mode> <maxangle>]
-~~~~~
+~~~~
Searches at least one small edge at a given shape. If such edges have been found, then small edges are merged with a given tolerance. If parameter <i>\<mode\></i> is equal to *Standard_True* (can be given any values, except 2), then small edges, which can not be merged, are removed, otherwise they are to be kept (*Standard_False* is used by default). Parameter <i>\<maxangle\></i> sets a maximum possible angle for merging two adjacent edges, by default no limit angle is applied (-1). Results are put into the shape, which is given as parameter result.
**Example:**
-~~~~~
+~~~~{.php}
fixsmalledges r a 0.1 1
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_10 fixshape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
fixshape <result> <shape> [<preci> [<maxpreci>]] [{switches}]
-~~~~~
+~~~~
Performs fixes of all sub-shapes (such as *Solids*, *Shells*, *Faces*, *Wires* and *Edges*) of a given shape. Parameter <i>\<preci\></i> sets a basic precision value, <i>\<maxpreci\></i> sets the maximal allowed tolerance. Results are put into the shape, which is given as parameter result. <b>{switches}</b> allows to tune parameters of ShapeFix
For enhanced message output, use switch '+?'
**Example:**
-~~~~~
+~~~~{.php}
fixshape r a 0.001
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_11 fixwgaps
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
fixwgaps <result> <shape> [<toler>=0]
-~~~~~
+~~~~
Fixes gaps between ends of curves of adjacent edges (both 3d and pcurves) in wires in a given shape with a given tolerance. Results are put into the shape, which is given as parameter result.
**Example:**
-~~~~~
+~~~~{.php}
fixwgaps r a
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_12 offsetcurve, offset2dcurve
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
offsetcurve <result> <curve> <offset> <direction(as point)>
offset2dcurve <result> <curve> <offset>
-~~~~~
+~~~~
**offsetcurve** works with the curve in 3d space, **offset2dcurve** in 2d space.
Both commands are intended to create a new offset curve by copying the given curve to distance, given by parameter <i>\<offset\></i>. Parameter <i>\<direction\></i> defines direction of the offset curve. It is created as a point. For correct work of these commands the direction of normal of the offset curve must be perpendicular to the plane, the basis curve is located there. Results are put into the curve, which is given as parameter <i>\<result\></i>.
**Example:**
-~~~~~
+~~~~{.php}
point pp 10 10 10
offsetcurve r c 20 pp
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_13 projcurve
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
projcurve <edge>|<curve3d>|<curve3d first last> <X> <Y> <Z>
-~~~~~
+~~~~
**projcurve** returns the projection of a given point on a given curve. The curve may be defined by three ways: by giving the edge name, giving the 3D curve and by giving the unlimited curve and limiting it by pointing its start and finish values.
**Example:**
-~~~~~
+~~~~{.php}
projcurve k_1 0 1 5
==Edge k_1 Params from 0 to 1.3
==Precision (BRepBuilderAPI) : 9.9999999999999995e-008 ==Projection : 0 1 5
==Result : 0 1.1000000000000001 0
==Param = -0.20000000000000001 Gap = 5.0009999000199947
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_14 projpcurve
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
projpcurve <edge> <face> <Tol> <X> <Y> <Z> [<start_param>]
-~~~~~
+~~~~
**projpcurve** returns the projection of a given point on a given curve on surface.
The curve on surface is defined by giving the edge and face names.
**Example:**
-~~~~~
+~~~~{.php}
# Using global searching
projpcurve f_1 f 1.e-7 0.877 0 0.479
==Point: 0.87762772831890712 0 0.47934285275342808
==Param: 0.49990578239977856
==Dist: 0.0007152557954264938
-~~~~~
+~~~~
-~~~~~
+~~~~{.php}
# Using starting parameter on edge
projpcurve f_1 f 1.e-7 0.877 0 0.479 .6
==Point: 0.87762772831890712 0 0.47934285275342808
==Param: 0.49990578239977856
==Dist: 0.0007152557954264938
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_15 projface
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
projface <face> <X> <Y> [<Z>]
-~~~~~
+~~~~
Returns the projection of a given point to a given face in 2d or 3d space. If two coordinates (2d space) are given then returns coordinates projection of this point in 3d space and vice versa.
**Example:**
-~~~~~
+~~~~{.php}
projface a_1 10.0 0.0
== Point UV U = 10 V = 0
== = proj X = -116 Y = -45 Z = 0
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_16 scaleshape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
scaleshape <result> <shape> <scale>
-~~~~~
+~~~~
Returns a new shape, which is the result of scaling of a given shape with a coefficient equal to the parameter <i>\<scale\></i>. Tolerance is calculated for the new shape as well.
**Example:**
-~~~~~
+~~~~{.php}
scaleshape r a_1 0.8
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_17 settolerance
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
settolerance <shape> [<mode>=v-e-w-f-a] <val>(fix value) or
<tolmin> <tolmax>
-~~~~~
+~~~~
Sets new values of tolerance for a given shape. If the second parameter <i>mode</i> is given, then the tolerance value is set only for these sub shapes.
**Example:**
-~~~~~
+~~~~{.php}
settolerance a 0.001
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_18 splitface
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
splitface <result> <face> [u usplit1 usplit2...] [v vsplit1 vsplit2 ...]
-~~~~~
+~~~~
Splits a given face in parametric space and puts the result into the given parameter <i>\<result\></i>.
Returns the status of split face.
**Example:**
-~~~~~
+~~~~{.php}
# split face f by parameter u = 5
splitface r f u 5
==> Splitting by U: ,5
==> Status: DONE1
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_19 statshape
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
statshape <shape> [particul]
-~~~~~
+~~~~
Returns the number of sub-shapes, which compose the given shape. For example, the number of solids, number of faces etc. It also returns the number of geometrical objects or sub-shapes with a specified type, example, number of free faces, number of C0
surfaces. The last parameter becomes out of date.
**Example:**
-~~~~~
+~~~~{.php}
statshape a
==> Count Item
==> ----- ----
==> 78 Wire
==> 4 Face with more than one wire
==> 34 bspsur: BSplineSurface
-~~~~~
+~~~~
@subsubsection occt_draw_9_1_20 tolerance
Syntax:
-~~~~~
+~~~~{.php}
tolerance <shape> [<mode>:D v e f c] [<tolmin> <tolmax>:real]
-~~~~~
+~~~~
Returns tolerance (maximal, avg and minimal values) of all given shapes and tolerance of their *Faces*, *Edges* and *Vertices*. If parameter <i>\<tolmin\></i> or <i>\<tolmax\></i> or both of them are given, then sub-shapes are returned as a result of analys of this shape, which satisfy the given tolerances. If a particular value of entity ((**D**)all shapes (**v**) *vertices* (**e**) *edges* (**f**) *faces* (**c**) *combined* (*faces*)) is given as the second parameter then only this group will be analyzed for tolerance.
**Example:**
-~~~~~
+~~~~{.php}
tolerance a
==> Tolerance MAX=0.31512672416608001 AVG=0.14901359484722074 MIN=9.9999999999999995e-08
==> FACE : MAX=9.9999999999999995e-08 AVG=9.9999999999999995e-08 MIN=9.9999999999999995e-08
tolerance a v 0.1 0.001
==> Analysing Vertices gives 6 Shapes between tol1=0.10000000000000001 and tol2=0.001 , named tol_1 to tol_6
-~~~~~
+~~~~
@subsection occt_draw_9_2 Conversion commands
@subsubsection occt_draw_9_2_1 DT_ClosedSplit
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
DT_ClosedSplit <result> <shape>
-~~~~~
+~~~~
Divides all closed faces in the shape (for example cone) and returns result of given shape into shape, which is given as parameter result. Number of faces in resulting shapes will be increased.
Note: A closed face is a face with one or more seam.
**Example:**
-~~~~~
+~~~~{.php}
DT_ClosetSplit r a
-~~~~~
+~~~~
@subsubsection occt_draw_9_2_2 DT_ShapeConvert, DT_ShapeConvertRev
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
DT_ShapeConvert <result> <shape> <convert2d> <convert3d>
DT_ShapeConvertRev <result> <shape> <convert2d> <convert3d>
-~~~~~
+~~~~
Both commands are intended for the conversion of 3D, 2D curves to Bezier curves and surfaces to Bezier based surfaces. Parameters convert2d and convert3d take on a value 0 or 1. If the given value is 1, then the conversion will be performed, otherwise it will not be performed. The results are put into the shape, which is given as parameter Result. Command *DT_ShapeConvertRev* differs from *DT_ShapeConvert* by converting all elementary surfaces into surfaces of revolution first.
**Example:**
-~~~~~
+~~~~{.php}
DT_ShapeConvert r a 1 1
== Status: DONE1
-~~~~~
+~~~~
@subsubsection occt_draw_9_2_3 DT_ShapeDivide
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
DT_ShapeDivide <result> <shape> <tol>
-~~~~~
+~~~~
Divides the shape with C1 criterion and returns the result of geometry conversion of a given shape into the shape, which is given as parameter result. This command illustrates how class *ShapeUpgrade_ShapeDivideContinuity* works. This class allows to convert geometry with a continuity less than the specified continuity to geometry with target continuity. If conversion is not possible then the geometrical object is split into several ones, which satisfy the given tolerance. It also returns the status shape splitting:
* OK : no splitting was done
* Fail1 : Some errors occurred
**Example:**
-~~~~~
+~~~~{.php}
DT_ShapeDivide r a 0.001
== Status: OK
-~~~~~
+~~~~
@subsubsection occt_draw_9_2_4 DT_SplitAngle
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
DT_SplitAngle <result> <shape> [MaxAngle=95]
-~~~~~
+~~~~
Works with all revolved surfaces, like cylinders, surfaces of revolution, etc. This command divides given revolved surfaces into segments so that each resulting segment covers not more than the given *MaxAngle* degrees and puts the result of splitting into the shape, which is given as parameter result. Values of returned status are given above.
This command illustrates how class *ShapeUpgrade_ShapeDivideAngle* works.
**Example:**
-~~~~~
+~~~~{.php}
DT_SplitAngle r a
== Status: DONE2
-~~~~~
+~~~~
@subsubsection occt_draw_9_2_5 DT_SplitCurve
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
DT_SplitCurve <curve> <tol> <split(0|1)>
-~~~~~
+~~~~
Divides the 3d curve with C1 criterion and returns the result of splitting of the given curve into a new curve. If the curve had been divided by segments, then each segment is put to an individual result. This command can correct a given curve at a knot with the given tolerance, if it is impossible, then the given surface is split at that knot. If the last parameter is 1, then 5 knots are added at the given curve, and its surface is split by segments, but this will be performed not for all parametric spaces.
**Example:**
-~~~~~
+~~~~{.php}
DT_SplitCurve r c
-~~~~~
+~~~~
@subsubsection occt_draw_9_2_6 DT_SplitCurve2d
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
DT_SplitCurve2d Curve Tol Split(0/1)
-~~~~~
+~~~~
Works just as **DT_SplitCurve** (see above), only with 2d curve.
**Example:**
-~~~~~
+~~~~{.php}
DT_SplitCurve2d r c
-~~~~~
+~~~~
@subsubsection occt_draw_9_2_7 DT_SplitSurface
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
DT_SplitSurface <result> <Surface|GridSurf> <tol> <split(0|1)>
-~~~~~
+~~~~
Divides surface with C1 criterion and returns the result of splitting of a given surface into surface, which is given as parameter result. If the surface has been divided into segments, then each segment is put to an individual result. This command can correct a given C0 surface at a knot with a given tolerance, if it is impossible, then the given surface is split at that knot. If the last parameter is 1, then 5 knots are added to the given surface, and its surface is split by segments, but this will be performed not for all parametric spaces.
**Example:**
-~~~~~
+~~~~{.php}
# split surface with name "su"
DT_SplitSurface res su 0.1 1
==> single surf
==> appel a Surfaces
==> transfert resultat
==> res1_1_1 res1_2_1 res1_3_1 res1_4_1 res1_5_1 res1_6_1
-~~~~~
+~~~~
@subsubsection occt_draw_9_2_8 DT_ToBspl
Syntax:
-~~~~~
+~~~~{.php}
DT_ToBspl <result> <shape>
-~~~~~
+~~~~
Converts a surface of linear extrusion, revolution and offset surfaces into BSpline surfaces. Returns the result into the shape, which is given as parameter result.
**Example:**
-~~~~~
+~~~~{.php}
DT_ToBspl res sh
== error = 5.20375663162094e-08 spans = 10
== Surface is approximated with continuity 2
-~~~~~
+~~~~
@section occt_draw_10 Performance evaluation commands
@subsection occt_draw_10_1 VDrawSphere
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
vdrawsphere shapeName Fineness [X=0.0 Y=0.0 Z=0.0] [Radius=100.0] [ToEnableVBO=1] [NumberOfViewerUpdate=1] [ToShowEdges=0]
-~~~~~
+~~~~
Calculates and displays in a given number of steps a sphere with given coordinates, radius and fineness. Returns the information about the properties of the sphere, the time and the amount of memory required to build it.
This command can be used for visualization performance evaluation instead of the outdated Visualization Performance Meter.
**Example:**
-~~~~~
+~~~~{.php}
vdrawsphere s 200 1 1 1 500 1
== Compute Triangulation...
== NumberOfPoints: 39602
== CPU user time: 15.6000999999998950 msec
== CPU system time: 0.0000000000000000 msec
== CPU average time of scene redrawing: 15.6000999999998950 msec
-~~~~~
+~~~~
@section occt_draw_12 Simple vector algebra and measurements
@subsection occt_draw_12_1 Vector algebra commands
This section describes commands providing simple calculations with 2D and 3D vectors. The vector is represented by a TCL list of double values (coordinates). The commands get input vector coordinates from the command line as distinct values. So, if you have a vector stored in a variable you need to use *eval* command as a prefix, for example, to compute the magnitude of cross products of two vectors given by 3 points the following commands can be used:
-~~~~~{.cpp}
+~~~~{.php}
Draw[10]> set vec1 [vec 12 28 99 12 58 99]
0 30 0
Draw[13]> set vec2 [vec 12 28 99 16 21 89]
-300 0 -120
Draw[15]> eval module $cross
323.10988842807024
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_1 vec
Syntax:
-~~~~~
+~~~~{.php}
vec <x1> <y1> <z1> <x2> <y2> <z2>
-~~~~~
+~~~~
Returns coordinates of vector between two 3D points.
Example:
-~~~~~{.cpp}
+~~~~{.php}
vec 1 2 3 6 5 4
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_2 2dvec
Syntax:
-~~~~~
+~~~~{.php}
2dvec <x1> <y1> <x2> <y2>
-~~~~~
+~~~~
Returns coordinates of vector between two 2D points.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2dvec 1 2 4 3
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_3 pln
Syntax:
-~~~~~
+~~~~{.php}
pln <x1> <y1> <z1> <x2> <y2> <z2> <x3> <y3> <z3>
-~~~~~
+~~~~
Returns plane built on three points. A plane is represented by 6 double values: coordinates of the origin point and the normal directoin.
Example:
-~~~~~{.cpp}
+~~~~{.php}
pln 1 2 3 6 5 4 9 8 7
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_4 module
Syntax:
-~~~~~
+~~~~{.php}
module <x> <y> <z>
-~~~~~
+~~~~
Returns module of a vector.
Example:
-~~~~~{.cpp}
+~~~~{.php}
module 1 2 3
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_5 2dmodule
Syntax:
-~~~~~
+~~~~{.php}
2dmodule <x> <y>
-~~~~~
+~~~~
Returns module of a 2D vector.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2dmodule 1 2
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_6 norm
Syntax:
-~~~~~
+~~~~{.php}
norm <x> <y> <z>
-~~~~~
+~~~~
Returns unified vector from a given 3D vector.
Example:
-~~~~~{.cpp}
+~~~~{.php}
norm 1 2 3
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_7 2dnorm
Syntax:
-~~~~~
+~~~~{.php}
2dnorm <x> <y>
-~~~~~
+~~~~
Returns unified vector from a given 2D vector.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2dnorm 1 2
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_8 inverse
Syntax:
-~~~~~
+~~~~{.php}
inverse <x> <y> <z>
-~~~~~
+~~~~
Returns inversed 3D vector.
Example:
-~~~~~{.cpp}
+~~~~{.php}
inverse 1 2 3
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_9 2dinverse
Syntax:
-~~~~~
+~~~~{.php}
2dinverse <x> <y>
-~~~~~
+~~~~
Returns inversed 2D vector.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2dinverse 1 2
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_10 2dort
Syntax:
-~~~~~
+~~~~{.php}
2dort <x> <y>
-~~~~~
+~~~~
Returns 2D vector rotated on 90 degrees.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2dort 1 2
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_11 distpp
Syntax:
-~~~~~
+~~~~{.php}
distpp <x1> <y1> <z1> <x2> <y2> <z2>
-~~~~~
+~~~~
Returns distance between two 3D points.
Example:
-~~~~~{.cpp}
+~~~~{.php}
distpp 1 2 3 4 5 6
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_12 2ddistpp
Syntax:
-~~~~~
+~~~~{.php}
2ddistpp <x1> <y1> <x2> <y2>
-~~~~~
+~~~~
Returns distance between two 2D points.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2ddistpp 1 2 3 4
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_13 distplp
Syntax:
-~~~~~
+~~~~{.php}
distplp <x0> <y0> <z0> <nx> <ny> <nz> <xp> <yp> <zp>
-~~~~~
+~~~~
Returns distance between plane defined by point and normal direction and another point.
Example:
-~~~~~{.cpp}
+~~~~{.php}
distplp 0 0 0 0 0 1 5 6 7
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_14 distlp
Syntax:
-~~~~~
+~~~~{.php}
distlp <x0> <y0> <z0> <dx> <dy> <dz> <xp> <yp> <zp>
-~~~~~
+~~~~
Returns distance between 3D line defined by point and direction and another point.
Example:
-~~~~~{.cpp}
+~~~~{.php}
distlp 0 0 0 1 0 0 5 6 7
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_15 2ddistlp
Syntax:
-~~~~~
+~~~~{.php}
2ddistlp <x0> <y0> <dx> <dy> <xp> <yp>
-~~~~~
+~~~~
Returns distance between 2D line defined by point and direction and another point.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2ddistlp 0 0 1 0 5 6
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_16 distppp
Syntax:
-~~~~~
+~~~~{.php}
distppp <x1> <y1> <z1> <x2> <y2> <z2> <x3> <y3> <z3>
-~~~~~
+~~~~
Returns deviation of point (x2,y2,z2) from segment defined by points (x1,y1,z1) and (x3,y3,z3).
Example:
-~~~~~{.cpp}
+~~~~{.php}
distppp 0 0 0 1 1 0 2 0 0
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_17 2ddistppp
Syntax:
-~~~~~
+~~~~{.php}
2ddistppp <x1> <y1> <x2> <y2> <x3> <y3>
-~~~~~
+~~~~
Returns deviation of point (x2,y2) from segment defined by points (x1,y1) and (x3,y3). The result is a signed value. It is positive if the point (x2,y2) is on the left side of the segment, and negative otherwise.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2ddistppp 0 0 1 -1 2 0
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_18 barycen
Syntax:
-~~~~~
+~~~~{.php}
barycen <x1> <y1> <z1> <x2> <y2> <z2> <par>
-~~~~~
+~~~~
Returns point of a given parameter between two 3D points.
Example:
-~~~~~{.cpp}
+~~~~{.php}
barycen 0 0 0 1 1 1 0.3
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_19 2dbarycen
Syntax:
-~~~~~
+~~~~{.php}
2dbarycen <x1> <y1> <x2> <y2> <par>
-~~~~~
+~~~~
Returns point of a given parameter between two 2D points.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2dbarycen 0 0 1 1 0.3
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_20 cross
Syntax:
-~~~~~
+~~~~{.php}
cross <x1> <y1> <z1> <x2> <y2> <z2>
-~~~~~
+~~~~
Returns cross product of two 3D vectors.
Example:
-~~~~~{.cpp}
+~~~~{.php}
cross 1 0 0 0 1 0
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_21 2dcross
Syntax:
-~~~~~
+~~~~{.php}
2dcross <x1> <y1> <x2> <y2>
-~~~~~
+~~~~
Returns cross product of two 2D vectors.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2dcross 1 0 0 1
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_22 dot
Syntax:
-~~~~~
+~~~~{.php}
dot <x1> <y1> <z1> <x2> <y2> <z2>
-~~~~~
+~~~~
Returns scalar product of two 3D vectors.
Example:
-~~~~~{.cpp}
+~~~~{.php}
dot 1 0 0 0 1 0
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_23 2ddot
Syntax:
-~~~~~
+~~~~{.php}
2ddot <x1> <y1> <x2> <y2>
-~~~~~
+~~~~
Returns scalar product of two 2D vectors.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2ddot 1 0 0 1
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_24 scale
Syntax:
-~~~~~
+~~~~{.php}
scale <x> <y> <z> <factor>
-~~~~~
+~~~~
Returns 3D vector multiplied by scalar.
Example:
-~~~~~{.cpp}
+~~~~{.php}
scale 1 0 0 5
-~~~~~
+~~~~
@subsubsection occt_draw_12_1_25 2dscale
Syntax:
-~~~~~
+~~~~{.php}
2dscale <x> <y> <factor>
-~~~~~
+~~~~
Returns 2D vector multiplied by scalar.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2dscale 1 0 5
-~~~~~
+~~~~
@subsection occt_draw_12_2 Measurements commands
@subsubsection occt_draw_12_2_1 pnt
Syntax:
-~~~~~
+~~~~{.php}
pnt <object>
-~~~~~
+~~~~
Returns coordinates of point in the given Draw variable. Object can be of type point or vertex. Actually this command is built up from the commands @ref occt_draw_7_2_1a "mkpoint" and @ref occt_draw_6_6_1 "coord".
Example:
-~~~~~{.cpp}
+~~~~{.php}
vertex v 0 1 0
pnt v
-~~~~~
+~~~~
@subsubsection occt_draw_12_2_2 pntc
Syntax:
-~~~~~
+~~~~{.php}
pntc <curv> <par>
-~~~~~
+~~~~
Returns coordinates of point on 3D curve with given parameter. Actually this command is based on the command @ref occt_draw_6_6_2 "cvalue".
Example:
-~~~~~{.cpp}
+~~~~{.php}
circle c 0 0 0 10
pntc c [dval pi/2]
-~~~~~
+~~~~
@subsubsection occt_draw_12_2_3 2dpntc
Syntax:
-~~~~~
+~~~~{.php}
2dpntc <curv2d> <par>
-~~~~~
+~~~~
Returns coordinates of point on 2D curve with given parameter. Actually this command is based on the command @ref occt_draw_6_6_2 "2dcvalue".
Example:
-~~~~~{.cpp}
+~~~~{.php}
circle c 0 0 10
2dpntc c [dval pi/2]
-~~~~~
+~~~~
@subsubsection occt_draw_12_2_4 pntsu
Syntax:
-~~~~~
+~~~~{.php}
pntsu <surf> <u> <v>
-~~~~~
+~~~~
Returns coordinates of point on surface with given parameters. Actually this command is based on the command @ref occt_draw_6_6_3 "svalue".
Example:
-~~~~~{.cpp}
+~~~~{.php}
cylinder s 10
pntsu s [dval pi/2] 5
-~~~~~
+~~~~
@subsubsection occt_draw_12_2_5 pntcons
Syntax:
-~~~~~
+~~~~{.php}
pntcons <curv2d> <surf> <par>
-~~~~~
+~~~~
Returns coordinates of point on surface defined by point on 2D curve with given parameter. Actually this command is based on the commands @ref occt_draw_6_6_2 "2dcvalue" and @ref occt_draw_6_6_3 "svalue".
Example:
-~~~~~{.cpp}
+~~~~{.php}
line c 0 0 1 0
cylinder s 10
pntcons c s [dval pi/2]
-~~~~~
+~~~~
@subsubsection occt_draw_12_2_6 drseg
Syntax:
-~~~~~
+~~~~{.php}
drseg <name> <x1> <y1> <z1> <x2> <y2> <z2>
-~~~~~
+~~~~
Creates a linear segment between two 3D points. The new object is given the *name*. The object is drawn in the axonometric view.
Example:
-~~~~~{.cpp}
+~~~~{.php}
drseg s 0 0 0 1 0 0
-~~~~~
+~~~~
@subsubsection occt_draw_12_2_7 2ddrseg
Syntax:
-~~~~~
+~~~~{.php}
2ddrseg <name> <x1> <y1> <x2> <y2>
-~~~~~
+~~~~
Creates a linear segment between two 2D points. The new object is given the *name*. The object is drawn in the 2D view.
Example:
-~~~~~{.cpp}
+~~~~{.php}
2ddrseg s 0 0 1 0
-~~~~~
+~~~~
@subsubsection occt_draw_12_2_8 mpick
Syntax:
-~~~~~
+~~~~{.php}
mpick
-~~~~~
+~~~~
Prints in the console the coordinates of a point clicked by mouse in a view (axonometric or 2D). This command will wait for mouse click event in a view.
Example:
-~~~~~{.cpp}
+~~~~{.php}
mpick
-~~~~~
+~~~~
@subsubsection occt_draw_12_2_9 mdist
Syntax:
-~~~~~
+~~~~{.php}
mdist
-~~~~~
+~~~~
Prints in the console the distance between two points clicked by mouse in a view (axonometric or 2D). This command will wait for two mouse click events in a view.
Example:
-~~~~~{.cpp}
+~~~~{.php}
mdist
-~~~~~
+~~~~
@section occt_draw_13 Inspector commands
@subsection occt_draw_13_1 tinspector
-Syntax:
-~~~~~
+Syntax:
+~~~~{.php}
tinspector [-plugins {name1 ... [nameN] | all}]
[-activate name]
[-shape object [name1] ... [nameN]]
[-update]
[-select {object | name1 ... [nameN]}]
[-show {0|1} = 1]
-~~~~~
+~~~~
Starts inspection tool.
Options:
* *plugins* enters plugins that should be added in the inspector.
* *show* sets Inspector view visible or hidden. The first call of this command will show it.
**Example:**
-~~~~~
+~~~~{.php}
pload DCAF INSPECTOR
NewDocument Doc BinOcaf
SetInteger Doc ${aLabel} ${aSetAttr1}
tinspector -plugins dfbrowser -select 0:2 TDataStd_Integer
-~~~~~
+~~~~
**Example:**
-~~~~~
+~~~~{.php}
pload ALL INSPECTOR
box b1 200 100 120
box b2 100 200 220 100 120 100
tinspector -plugins shapeview -shape b1 -shape b2 -select b1
-~~~~~
+~~~~
**Example:**
-~~~~~
+~~~~{.php}
pload ALL INSPECTOR
tinspector -plugins vinspector
vselmode box_1 3 1
tinspector -update -select box_1
-~~~~~
+~~~~
@section occt_draw_11 Extending Test Harness with custom commands
Custom command implementation has not undergone any changes since the introduction of the plug-in mechanism. The syntax of every command should still be like in the following example.
**Example:**
-~~~~~
+~~~~{.cpp}
static Standard_Integer myadvcurve(Draw_Interpretor& di, Standard_Integer n, char** a)
{
...
}
-~~~~~
+~~~~
For examples of existing commands refer to Open CASCADE Technology (e.g. GeomliteTest.cxx).
To become available in the Test Harness the custom command must be registered in it. This should be done as follows.
**Example:**
-~~~~~
+~~~~{.cpp}
void MyPack::CurveCommands(Draw_Interpretor& theCommands)
{
...
__FILE__, myadvcurve, g );
...
}
-~~~~~
+~~~~
@subsection occt_draw_11_3 Creating a toolkit (library) as a plug-in
For convenience the *DPLUGIN* macro (defined in the *Draw_PluginMacro.hxx* file) has been provided. It implements the *PLUGINFACTORY()* function as a call to the *Package::Factory()* method and accepts *Package* as an argument. Respectively, this *Package::Factory()* method must be implemented in the library and activate all implemented commands.
**Example:**
-~~~~~
+~~~~{.cpp}
#include <Draw_PluginMacro.hxx>
void MyPack::Factory(Draw_Interpretor& theDI)
// Declare entry point PLUGINFACTORY
DPLUGIN(MyPack)
-~~~~~
+~~~~
@subsection occt_draw_11_4 Creation of the plug-in resource file
For several plug-ins one resource file can be created. In such case, keys denoting plug-ins can be combined into groups, these groups -- into their groups and so on (thereby creating some hierarchy). Any new parent key must have its value as a sequence of child keys separated by spaces, tabs or commas. Keys should form a tree without cyclic dependencies.
**Examples** (file MyDrawPlugin):
-~~~~~
+~~~~{.php}
! Hierarchy of plug-ins
ALL : ADVMODELING, MESHING
DEFAULT : MESHING
ADVSURF : TKMyAdvSurf
ADVCURV : TKMyAdvCurv
MESHING : TKMyMesh
-~~~~~
+~~~~
For other examples of the plug-in resource file refer to the @ref occt_draw_1_3_2 "Plug-in resource file" chapter above or to the <i>$CASROOT/src/DrawPlugin</i> file shipped with Open CASCADE Technology.
The procedure consists in defining the system variables and using the *pload* commands in the Test Harness session.
**Example:**
-~~~~
+~~~~{.php}
Draw[]> set env(CSF_MyDrawPluginDefaults) /users/test
Draw[]> pload -MyDrawPlugin ALL
~~~~
To reference an object, we instantiate the class with one of its constructors.
For example, in C++:
-~~~~~
+~~~~{.cpp}
Handle(MyClass) anObject = new MyClass();
-~~~~~
+~~~~
In Open CASCADE Technology, the Handles are specific classes that are used to safely manipulate objects allocated in the dynamic memory by reference,
providing reference counting mechanism and automatic destruction of the object when it is not referenced.
Objects of classes derived (directly or indirectly) from *Transient*, are normally allocated in dynamic memory using operator **new**, and manipulated by handle.
Handle is defined as template class *opencascade::handle<>*.
Open CASCADE Technology provides preprocessor macro *Handle()* that is historically used throughout OCCT code to name a handle:
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(Geom_Line) aLine; // "Handle(Geom_Line)" is expanded to "opencascade::handle<Geom_Line>"
-~~~~~
+~~~~
In addition, for most OCCT classes additional *typedef* is defined for a handle, as the name of a class prefixed by *Handle_*.
For instance, the above example can be also coded as:
-~~~~~{.cpp}
+~~~~{.cpp}
Handle_Geom_Line aLine; // "Handle_Geom_Line" is typedef to "opencascade::handle<Geom_Line>"
-~~~~~
+~~~~
#### Using a Handle
Before performing any operation on a transient object, you must declare the handle.
For example, if Point and Line are two transient classes from the Geom package, you would write:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Point) p1, p2;
-~~~~~
+~~~~
Declaring a handle creates a null handle that does not refer to any object.
The handle may be checked to be null by its method *IsNull()*.
To nullify a handle, use method *Nullify()*.
Header *Standard_Type.hxx* provides two variants of preprocessor macros facilitating this:
* Inline variant, which declares and defines RTTI methods by a single line of code:
-~~~~~{.cpp}
+~~~~{.cpp}
#include <Geom_Surface.hxx>
class Appli_ExtSurface : public Geom_Surface
{
public:
DEFINE_STANDARD_RTTIEXT(Appli_ExtSurface,Geom_Surface)
};
-~~~~~
+~~~~
* Out-of line variant, which uses one macro in the declaration (normally in the header file), and another in the implementation (in C++ source):
In *Appli_ExtSurface.hxx* file:
-~~~~~{.cpp}
+~~~~{.cpp}
#include <Geom_Surface.hxx>
class Appli_ExtSurface : public Geom_Surface
{
public:
DEFINE_STANDARD_RTTIEXT(Appli_ExtSurface,Geom_Surface)
};
-~~~~~
+~~~~
In *Appli_ExtSurface.cxx* file:
-~~~~~{.cpp}
+~~~~{.cpp}
#include <Appli_ExtSurface.hxx>
IMPLEMENT_STANDARD_RTTIEXT(Appli_ExtSurface,Geom_Surface)
-~~~~~
+~~~~
These macros define method *DynamicType()* that returns a type descriptor - handle to singleton instance of the class *Standard_Type* describing the class.
The type descriptor stores the name of the class and the descriptor of its parent class.
To get the type descriptor for a given class type, use macro *STANDARD_TYPE()* with the name of the class as argument.
Example of usage:
-~~~~~{.cpp}
+~~~~{.cpp}
if (aCurve->IsKind(STANDARD_TYPE(Geom_Line))) // equivalent to "if (dynamic_cast<Geom_Line>(aCurve.get()) != 0)"
{
...
}
-~~~~~
+~~~~
#### Type Conformity
Consider the class *Geom_CartesianPoint*, a sub-class of *Geom_Point*; the rule of type conformity can be illustrated as follows:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Point) aPnt1;
Handle(Geom_CartesianPoint) aPnt2;
aPnt2 = new Geom_CartesianPoint();
aPnt1 = aPnt2; // OK, the types are compatible
-~~~~~
+~~~~
The compiler sees *aPnt1* as a handle to *Geom_Point* though the actual object referenced by *aPnt1* is of the *Geom_CartesianPoint* type.
If this is not the case, the handle is nullified (explicit type conversion is sometimes called a "safe cast").
Consider the example below.
-~~~~~~
+~~~~{.cpp}
Handle(Geom_Point) aPnt1;
Handle(Geom_CartesianPoint) aPnt2, aPnt3;
aPnt2 = new Geom_CartesianPoint();
aPnt1 = aPnt2; // OK, standard assignment
aPnt3 = Handle(Geom_CartesianPoint)::DownCast (aPnt1);
// OK, the actual type of aPnt1 is Geom_CartesianPoint, although the static type of the handle is Geom_Point
-~~~~~~
+~~~~
If conversion is not compatible with the actual type of the referenced object, the handle which was "cast" becomes null (and no exception is raised).
So, if you require reliable services defined in a sub-class of the type seen by the handle (static type), write as follows:
-~~~~~~
+~~~~{.cpp}
void MyFunction (const Handle(A) & a)
{
Handle(B) b = Handle(B)::DownCast(a);
// the types are incompatible
}
}
-~~~~~~
+~~~~
Downcasting is used particularly with collections of objects of different types; however, these objects should inherit from the same root class.
For example, with a sequence of transient objects *TColStd_SequenceOfTransient* and two classes A and B that both inherit from *Standard_Transient*, you get the following syntax:
-~~~~~
+~~~~{.cpp}
Handle(A) a;
Handle(B) b;
Handle(Standard_Transient) t;
{
// the types are incompatible
}
-~~~~~
+~~~~
@subsubsection occt_fcug_2_2_3 Using Handles to Create Objects
To create an object which is manipulated by handle, declare the handle and initialize it with the standard C++ **new** operator, immediately followed by a call to the constructor.
The constructor can be any of those specified in the source of the class from which the object is instanced.
-~~~~~
+~~~~{.cpp}
Handle(Geom_CartesianPoint) aPnt;
aPnt = new Geom_CartesianPoint (0, 0, 0);
-~~~~~
+~~~~
Unlike for a pointer, the **delete** operator does not work on a handle; the referenced object is automatically destroyed when no longer in use.
To test or to modify the state of the handle, the method is translated by the *dot* operator.
The example below illustrates how to access the coordinates of an (optionally initialized) point object:
-~~~~~
+~~~~{.cpp}
Handle(Geom_CartesianPoint) aCentre;
Standard_Real x, y, z;
if (aCentre.IsNull())
aCentre = new PGeom_CartesianPoint (0, 0, 0);
}
aCentre->Coord (x, y, z);
-~~~~~
+~~~~
The example below illustrates how to access the type object of a Cartesian point:
-~~~~~
+~~~~{.cpp}
Handle(Standard_Transient) aPnt = new Geom_CartesianPoint (0., 0., 0.);
if (aPnt->DynamicType() == STANDARD_TYPE(Geom_CartesianPoint))
{
{
std::cout << "Type check FAILED\n";
}
-~~~~~
+~~~~
*Standard_NullObject* exception will be raised if a field or a method of an object is accessed via a *Null* handle.
For example, we can find the maximum degree of a Bezier curve:
-~~~~~
+~~~~{.cpp}
Standard_Integer aDegree = Geom_BezierCurve::MaxDegree();
-~~~~~
+~~~~
@subsubsection occt_fcug_2_2_5 Handle deallocation
The principle of allocation can be seen in the example below.
-~~~~~
+~~~~{.cpp}
...
{
Handle(TColStd_HSequenceOfInteger) H1 = new TColStd_HSequenceOfInteger();
// Here, H1 has 1 reference
}
// Here, H1 has no reference and the referred TColStd_HSequenceOfInteger object is deleted.
-~~~~~
+~~~~
You can easily cast a reference to the handle object to <i> void* </i> by defining the following:
-~~~~
+~~~~{.cpp}
void* aPointer;
Handle(Some_Class) aHandle;
// Here only a pointer will be copied
#### "C++ like" Syntax
The following example:
-~~~~~
+~~~~{.cpp}
throw Standard_DomainError ("Cannot cope with this condition");
-~~~~~
+~~~~
raises an exception of *Standard_DomainError* type with the associated message "Cannot cope with this condition", the message being optional.
This exception may be caught by a handler of a *Standard_DomainError* type as follows:
-~~~~~
+~~~~{.cpp}
try
{
OCC_CATCH_SIGNALS
{
// handle Standard_DomainError exceptions here
}
-~~~~~
+~~~~
#### Regular usage
then, the *Value* function may be implemented as follows:
-~~~~~
+~~~~{.cpp}
Item TCollection_Array1::Value (Standard_Integer theIndex) const
{
// where myR1 and myR2 are the lower and upper bounds of the array
}
return myContents[theIndex];
}
-~~~~~
+~~~~
Here validity of the index is first verified using the Lower and Upper functions in order to protect the call.
Normally the caller ensures the index being in the valid range before calling <i>Value()</i>.
It is a widely used practice to include that kind of protections in a debug build of the program and exclude in release (optimized) build.
To support this practice, the macros <i>Raise_if()</i> are provided for every OCCT exception class:
-~~~~~
+~~~~{.cpp}
<ErrorTypeName>_Raise_if(condition, "Error message");
-~~~~~
+~~~~
where *ErrorTypeName* is the exception type, *condition* is the logical expression leading to the raise of the exception, and *Error message* is the associated message.
The entire call may be removed by defining one of the preprocessor symbols *No_Exception* or <i>No_<ErrorTypeName></i> at compile-time:
-~~~~~
+~~~~{.cpp}
#define No_Exception // remove all raises
-~~~~~
+~~~~
Using this syntax, the *Value* function becomes:
-~~~~~
+~~~~{.cpp}
Item TCollection_Array1::Value (Standard_Integer theIndex) const
{
Standard_OutOfRange_Raise_if(theIndex < myR1 || theIndex > myR2, "index out of range in TCollection_Array1::Value");
return myContents[theIndex];
}
-~~~~~
+~~~~
@subsubsection occt_fcug_2_4_3 Handling an Exception
As an example, consider the exceptions of type *Standard_NumericError, Standard_Overflow, Standard_Underflow* and *Standard_DivideByZero*, where *Standard_NumericError* is the parent type of the three others.
-~~~~~
+~~~~{.cpp}
void f(1)
{
try
// ...
}
}
-~~~~~
+~~~~
Here, the first handler will catch exceptions of *Standard_Overflow* type
and the second one -- exceptions of *Standard_NumericError* type and all exceptions derived from it, including *Standard_Underflow* and *Standard_DivideByZero*.
The handlers are checked in order of appearance, from the nearest to the try block to the most distant from it, until one matches the raise expression.
For a try block, it would be a mistake to place a handler for a base exception type ahead of a handler for its derived type since that would ensure that the handler for the derived exception would never be invoked.
-~~~~~
+~~~~{.cpp}
void f(1)
{
int i = 0;
}
. . .
}
-~~~~~
+~~~~
The exceptions form a hierarchy tree completely separated from other user defined classes.
One exception of type *Standard_Failure* is the root of the entire exception hierarchy.
The main routine of a program would look like this:
-~~~~~
+~~~~{.cpp}
#include <Standard_ErrorHandler.hxx>
#include <Standard_Failure.hxx>
#include <iostream>
}
return 1;
}
-~~~~~
+~~~~
Though standard C++ scoping rules and syntax apply to try block and handlers, note that on some platforms Open CASCADE Technology may be compiled in compatibility mode when exceptions are emulated by long jumps (see below).
In this mode it is required that no statement precedes or follows any handler.
That method reads the information regarding available plug-ins and their locations from the resource file *Plugin* found by environment variable *CSF_PluginDefaults*:
-~~~~~
+~~~~
$CSF_PluginDefaults/Plugin
-~~~~~
+~~~~
The *Load* method looks for the library name in the resource file or registry through its GUID, for example, on UNIX:
-~~~~~
+~~~~
! METADATADRIVER whose value must be OS or DM.
! FW
a148e300-5740-11d1-a904-080036aaa103.Location: libFWOSPlugin.so
-~~~~~
+~~~~
Then the *Load* method loads the library according to the rules of the operating system of the host machine (for example, by using environment variables such as *LD_LIBRARY_PATH* with Unix and *PATH* with Windows).
After that it invokes the *PLUGINFACTORY* method to return the object, which supports the required service.
To invoke one of the services provided by the plug-in, you may call the *Plugin::Load()* global function with the *Standard_GUID* of the requested service as follows:
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(FADriver_PartStorer)::DownCast(PlugIn::Load (yourStandardGUID));
-~~~~~
+~~~~
Let us take *FAFactory.hxx* and *FAFactory.cxx* as an example:
-~~~~~{.cpp}
+~~~~{.cpp}
#include <Standard_Macro.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Transient.hxx>
public:
Standard_EXPORT static Handle(Standard_Transient) Factory (const Standard_GUID& theGUID);
};
-~~~~~
+~~~~
-~~~~~{.cpp}
+~~~~{.cpp}
#include <FAFactory.hxx>
#include <FADriver_PartRetriever.hxx>
// export plugin function "PLUGINFACTORY"
PLUGIN(FAFactory)
-~~~~~
+~~~~
Application might also instantiate a factory by linking to the library and calling *FAFactory::Factory()* directly.
Let see an example of NCollection template class instantiation for a sequence of points in the header file *MyPackage_SequenceOfPnt.hxx* (analogue of *TColgp_SequenceOfPnt*):
-~~~~~{.cpp}
+~~~~{.cpp}
#include <NCollection_Sequence.hxx>
#include <gp_Pnt.hxx>
typedef NCollection_Sequence<gp_Pnt> MyPackage_SequenceOfPnt;
-~~~~~
+~~~~
For the case, when sequence itself should be managed by handle, auxiliary macros *DEFINE_HSEQUENCE* can be used:
-~~~~~{.cpp}
+~~~~{.cpp}
#include <NCollection_Sequence.hxx>
#include <NCollection_DefineHSequence.hxx>
#include <gp_Pnt.hxx>
DEFINE_HSEQUENCE(MyPackage_HSequenceOfPnt, MyPackage_SequenceOfPnt)
...
Handle(MyPackage_HSequenceOfPnt) aSeq = new MyPackage_HSequenceOfPnt();
-~~~~~
+~~~~
See more details about available collections in following sections.
Usage sample:
-~~~~~{.cpp}
+~~~~{.cpp}
typedef Ncollection_Sequence<gp_Pnt> MyPackage_SequenceOfPnt;
void Perform (const MyPackage_SequenceOfPnt& theSequence)
{
...
}
}
-~~~~~
+~~~~
@subsubsection occt_fcug_3_1_5 Allocators
All constructors of *NCollection* classes receive the *Allocator* object as the last parameter.
This is an object of a type managed by Handle, inheriting *NCollection_BaseAllocator*, with the following (mandatory) methods redefined:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual void* Allocate (const size_t theSize) override;
virtual void Free (void* theAddress) override;
-~~~~~
+~~~~
It is used internally every time when the collection allocates memory for its item(s) and releases this memory.
The default value of this parameter (empty *Handle*) designates the use of *NCollection_BaseAllocator*, where the functions *Standard::Allocate* and *Standard::Free* are called.
The bounding object may have any dimension and geometry.
The minimal interface of *TheBndType* (besides public empty and copy constructor and operator=) used in NCollection_UBTree algorithm as follows:
-~~~~~{.cpp}
+~~~~{.cpp}
class MyBndType
{
public:
//! Computes the squared maximal linear extent of me (for a box it is the squared diagonal of the box).
Standard_Real SquareExtent() const;
};
-~~~~~
+~~~~
This interface is implemented in types of Bnd package: *Bnd_Box, Bnd_Box2d, Bnd_B2x, Bnd_B3x*.
Instantiation of *NCollection_UBTreeFiller* collects objects to be added, and then adds them at once to the given NCollection_UBTree instance in a random order using the Fisher-Yates algorithm.
Below is the sample code that creates an instance of *NCollection_UBTree* indexed by 2D boxes (Bnd_B2f), then a selection is performed returning the objects whose bounding boxes contain the given 2D point.
-~~~~~{.cpp}
+~~~~{.cpp}
typedef NCollection_UBTree<MyData, Bnd_B2f> UBTree;
typedef NCollection_List<MyData> ListOfSelected;
//! Tree Selector type
MyTreeSelector aSel (aPoint2d);
aTree.Select (aSel);
const ListOfSelected& aSelected = aSel.ListAccepted();
-~~~~~
+~~~~
##### NCollection_CellFilter
Packages *TShort*, *TColGeom*, *TColGeom2d*, *TColStd*, *TColgp* provide template instantiations (typedefs) of *NCollection* templates to standard OCCT types.
Classes with *H* prefix in name are handle-based variants and inherit Standard_Transient.
-~~~~~{.cpp}
+~~~~{.cpp}
typedef NCollection_Array1<gp_Vec> TColgp_Array1OfVec;
typedef NCollection_Array1<TCollection_AsciiString> TColStd_Array1OfAsciiString;
-~~~~~
+~~~~
Packages like *TopTools* also include definitions of collections and hash functions for complex types like shapes -- *TopTools_ShapeMapHasher*, *TopTools_MapOfShape*.
Vectors and matrices have arbitrary ranges which must be defined at declaration time and cannot be changed after declaration.
-~~~~~{.cpp}
+~~~~{.cpp}
math_Vector aVec (1, 3);
// a vector of dimension 3 with range (1..3)
math_Matrix aMat (0, 2, 0, 2);
// a matrix of dimension 3x3 with range (0..2, 0..2)
math_Vector aVec (N1, N2);
// a vector of dimension N2-N1+1 with range (N1..N2)
-~~~~~
+~~~~
Vector and Matrix objects use value semantics.
In other words, they cannot be shared and are copied through assignment.
-~~~~~{.cpp}
+~~~~{.cpp}
math_Vector aVec1 (1, 3), aVec2 (0, 2);
aVec2 = aVec1;
// aVec1 is copied into aVec2; a modification of aVec1 does not affect aVec2
-~~~~~
+~~~~
Vector and Matrix values may be initialized and obtained using indexes which must lie within the range definition of the vector or the matrix.
-~~~~~{.cpp}
+~~~~{.cpp}
math_Vector aVec (1, 3);
math_Matrix aMat (1, 3, 1, 3);
Standard_Real aValue;
aValue = aVec(1);
aMat (1, 3) = 1.0;
aValue = aMat (2, 2);
-~~~~~
+~~~~
Some operations on Vector and Matrix objects may not be legal.
In this case an exception is raised.
* *Standard_DimensionError* exception is raised when two matrices or vectors involved in an operation are of incompatible dimensions.
* *Standard_RangeError* exception is raised if an access outside the range definition of a vector or of a matrix is attempted.
-~~~~~~{.cpp}
+~~~~{.cpp}
math_Vector aVec1 (1, 3), aVec2 (1, 2), aVec3 (0, 2);
aVec1 = aVec2; // error: Standard_DimensionError is raised
aVec1 = aVec3; // OK: ranges are not equal but dimensions are compatible
aVec1 (0) = 2.0; // error: Standard_RangeError is raised
-~~~~~~
+~~~~
@subsection occt_occt_fcug_4_3 Primitive Geometric Types
The example below demonstrates the use of the math_Gauss class, which implements the Gauss solution for a set of linear equations.
The following definition is an extract from the header file of the class *math_Gauss*:
-~~~~~~{.cpp}
+~~~~{.cpp}
class math_Gauss
{
public:
Standard_Boolean IsDone() const;
void Solve (const math_Vector& B, math_Vector& X) const;
};
-~~~~~~
+~~~~
Now the main program uses the math_Gauss class to solve the equations _a*x1=b1_ and _a*x2=b2_:
-~~~~~{.cpp}
+~~~~{.cpp}
#include <math_Vector.hxx>
#include <math_Matrix.hxx>
main()
// StdFail_NotDone is raised
}
}
-~~~~~
+~~~~
The next example demonstrates the use of the *math_BissecNewton* class, which implements a combination of the Newton and Bissection algorithms to find the root of a function known to lie between two bounds.
The definition is an extract from the header file of the class *math_BissecNewton*:
-~~~~~{.cpp}
+~~~~{.cpp}
class math_BissecNewton
{
public:
Standard_Boolean IsDone() const;
Standard_Real Root();
};
-~~~~~
+~~~~
The abstract class *math_FunctionWithDerivative* describes the services which have to be implemented for the function _f_ which is to be used by a *math_BissecNewton* algorithm.
The following definition corresponds to the header file of the abstract class *math_FunctionWithDerivative*:
-~~~~~{.cpp}
+~~~~{.cpp}
class math_FunctionWithDerivative
{
public:
virtual Standard_Boolean Derivative (const Standard_Real x, Standard_Real& d) = 0;
virtual Standard_Boolean Values (const Standard_Real x, Standard_Real& f, Standard_Real& d) = 0;
};
-~~~~~
+~~~~
Now the test sample uses the *math_BissecNewton* class to find the root of the equation _f(x)=x**2-4_ in the interval [1.5, 2.5].
The function to solve is implemented in the class *myFunction* which inherits from the class *math_FunctionWithDerivative*, then the main program finds the required root.
-~~~~~{.cpp}
+~~~~{.cpp}
#include <math_BissecNewton.hxx>
#include <math_FunctionWithDerivative.hxx>
class myFunction : public math_FunctionWithDerivative
else // no
{
}
-~~~~~
+~~~~
@subsection occt_occt_fcug_4_7 Precision
This is because it is desirable to link parametric precision and real precision.
If you are on a curve defined by the equation *P(t)*, you would want to have equivalence between the following:
-~~~~~
+~~~~{.cpp}
Abs (t1 - t2) < ParametricPrecision
Distance (P(t1), P(t2)) < RealPrecision
-~~~~~
+~~~~
@subsubsection occt_occt_fcug_4_7_1 The Precision package
Its current value is *Epsilon(2 * PI)* i.e. the smallest number *x* such that *2*PI + x* is different of *2\*PI*.
It can be used to check confusion of two angles as follows:
-~~~{.cpp}
+~~~~{.cpp}
bool areEqualAngles (double theAngle1, double theAngle2)
{
return Abs(theAngle1 - theAngle2) < Precision::Angular();
~~~
It is also possible to check parallelism of two vectors as follows:
-~~~{.cpp}
+~~~~{.cpp}
bool areParallelVectors (const gp_Vec& theVec1, const gp_Vec& theVec2)
{
return theVec1.IsParallel (theVec2, Precision::Angular());
Note that *Precision::Angular()* can be used on both dot and cross products because for small angles the *Sine* and the *Angle* are equivalent.
So to test if two directions of type *gp_Dir* are perpendicular, it is legal to use the following code:
-~~~{.cpp}
+~~~~{.cpp}
bool arePerpendicular (const gp_Dir& theDir1, const gp_Dir& theDir2)
{
return Abs(theDir1 * theDir2) < Precision::Angular();
The current value is *1.e-7*, in other words, 1/10 micron if the unit used is the millimeter.
It can be used to check confusion of two points as follows:
-~~~{.cpp}
+~~~~{.cpp}
bool areEqualPoints (const gp_Pnt& thePnt1, const gp_Pnt& thePnt2)
{
return thePnt1.IsEqual (thePnt2, Precision::Confusion());
~~~
It is also possible to find a vector of null length:
-~~~{.cpp}
+~~~~{.cpp}
bool isNullVector (const gp_Vec& theVec)
{
return theVec.Magnitude() < Precision::Confusion();
@subsection occt_iges_2_3 Description of the process
@subsubsection occt_iges_2_3_1 Loading the IGES file
Before performing any other operation, you have to load the file using the syntax below.
-~~~~~
+~~~~{.cpp}
IGESControl_Reader reader;
IFSelect_ReturnStatus stat = reader.ReadFile(“filename.igs”);
-~~~~~
+~~~~
The loading operation only loads the IGES file into computer memory; it does not translate it.
@subsubsection occt_iges_2_3_2 Checking the IGES file
This step is not obligatory. Check the loaded file with:
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = reader.Check(Standard_True);
-~~~~~
+~~~~
The variable “ok is True” is returned if no fail message was found; “ok is False” is returned if there was at least one fail message.
-~~~~~
+~~~~{.cpp}
reader.PrintCheckLoad (failsonly, mode);
-~~~~~
+~~~~
Error messages are displayed if there are invalid or incomplete IGES entities, giving you information on the cause of the error.
-~~~~~
+~~~~{.cpp}
Standard_Boolean failsonly = Standard_True or Standard_False;
-~~~~~
+~~~~
If you give True, you will see fail messages only. If you give False, you will see both fail and warning messages.
Your analysis of the file can be either message-oriented or entity-oriented. Choose your preference with *IFSelect_PrintCount mode = IFSelect_xxx*, where *xxx* can be any of the following:
* 2: This option concerns IGES Spline curves only. IGES Spline curves are broken down into pieces of C2 continuity. If C2 cannot be ensured, the Spline curves will be broken down into pieces of C1 continuity.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.iges.bspline.continuity");
-~~~~~
+~~~~
Modify this value with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetIVal ("read.iges.bspline.continuity",2))
.. error ..;
-~~~~~
+~~~~
Default value is 1.
This parameter does not change the continuity of curves that are used in the construction of IGES BRep entities. In this case, the parameter does not influence the continuity of the resulting OCCT curves (it is ignored).
* User (1) the precision value is that of the read.precision.val parameter.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.precision.mode");
-~~~~~
+~~~~
Modify this value with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetIVal ("read.precision.mode",1))
.. error ..;
-~~~~~
+~~~~
Default value is *File* (0).
<h4>read.precision.val</h4>
This value is in the measurement unit defined in the IGES file header.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Real rp = Interface_Static::RVal("read.precision.val");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetRVal ("read.precision.val",0.001))
.. error ..;
-~~~~~
+~~~~
Default value is 0.0001.
The value given to this parameter is a target value that is applied to *TopoDS_Vertex, TopoDS_Edge* and *TopoDS_Face* entities. The processor does its best to reach it. Under certain circumstances, the value you give may not be attached to all of the entities concerned at the end of processing. IGES-to-OCCT translation does not improve the quality of the geometry in the original IGES file. This means that the value you enter may be impossible to attain the given quality of geometry in the IGES file.
* *Forced(1)* maximum tolerance is used as a rigid limit, i.e. it can not be exceeded and, if this happens, tolerance is trimmed to suit the maximum-allowable value.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer mv = Interface_Static::IVal("read.maxprecision.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetIVal ("read.maxprecision.mode",1))
.. error ..;
-~~~~~
+~~~~
Default value is *Preferred (0)*.
<h4>read.maxprecision.val</h4>
defines the maximum allowable tolerance (in mm) of the shape. It should be not less than the basis value of tolerance set in processor (either Resolution from the file or *read.precision.val*). Actually, the maximum between *read.maxprecision.val* and basis tolerance is used to define maximum allowed tolerance.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Real rp = Interface_Static::RVal("read.maxprecision.val");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetRVal ("read.maxprecision.val",0.1))
.. error ..;
-~~~~~
+~~~~
Default value is 1.
<h4>read.stdsameparameter.mode</h4>
* 1 (On) -- *BRepLib\::SameParameter* is called.
*BRepLib\::SameParameter* is used through *ShapeFix_Edge\::SameParameter*. It ensures that the resulting edge will have the lowest tolerance taking pcurves either unmodified from the IGES file or modified by *BRepLib\::SameParameter*.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer mv = Interface_Static::IVal("read.stdsameparameter.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetIVal ("read.stdsameparameter.mode",1))
.. error ..;
-~~~~~
+~~~~
Deafault value is 0 (Off).
<h4>read.surfacecurve.mode</h4>
If either a 3D or a 2D contour is absent in the file or cannot be translated, then it is re-computed from another contour. If the translation of both 2D and 3D contours fails, the whole curve (type 141 or 142) is not translated. If this curve is used for trimming a face, the face will be translated without this trimming and will have natural restrictions.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.surfacecurve.mode");
-~~~~~
+~~~~
Modify this value with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetIVal ("read.surfacecurve.mode",3))
.. error ..;
-~~~~~
+~~~~
Default value is Default (0).
<h4>read.encoderegularity.angle</h4>
This parameter is used within the *BRepLib::EncodeRegularity()* function which is called for a shape read from an IGES or a STEP file at the end of translation process. This function sets the regularity flag of an edge in a shell when this edge is shared by two faces. This flag shows the continuity, which these two faces are connected with at that edge.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Real era = Interface_Static::RVal("read.encoderegularity.angle");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetRVal ("read.encoderegularity.angle",0.1))
.. error ..;
-~~~~~
+~~~~
Default value is 0.01.
<h4>read.iges.bspline.approxd1.mode</h4>
This parameter is obsolete (it is rarely used in real practice). If set to True, it affects the translation of bspline curves of degree 1 from IGES: these curves (which geometrically are polylines) are split by duplicated points, and the translator attempts to convert each of the obtained parts to a bspline of a higher continuity.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Real bam = Interface_Static::CVal("read.iges.bspline.approxd1.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetRVal ("read.encoderegularity.angle","On"))
.. error ..;
-~~~~~
+~~~~
Default value is Off.
@subsubsection occt_iges_2_3_4 Selecting entities
A list of entities can be formed by invoking the method *IGESControl_Reader::GiveList*.
-~~~~~
+~~~~{.cpp}
Handle(TColStd_HSequenceOfTransient) list = reader.GiveList();
-~~~~~
+~~~~
Several predefined operators can be used to select a list of entities of a specific type.
-To make a selection, use the method *IGESControl_Reader::GiveList* with the selection type in quotation marks as an argument. You can also make cumulative selections. For example, you would use the following syntax:
+To make a selection, use the method *IGESControl_Reader::GiveList* with the selection type in quotation marks as an argument. You can also make cumulative selections. For example, you would use the following Syntax:
1. Requesting the faces in the file:
-~~~~~
+~~~~{.cpp}
faces = Reader.GiveList("iges-faces");
-~~~~~
+~~~~
2. Requesting the visible roots in the file:
-~~~~~
+~~~~{.cpp}
visibles = Reader.GiveList(iges-visible-roots);
-~~~~~
+~~~~
3. Requesting the visible faces:
-~~~~~
+~~~~{.cpp}
visfac = Reader.GiveList(iges-visible-roots,faces);
-~~~~~
+~~~~
Using a signature, you can define a selection dynamically, filtering the string by means of a criterion. When you request a selection using the method GiveList, you can give either a predefined selection or a selection by signature. You make your selection by signature using the predefined signature followed by your criterion in parentheses as shown in the example below. The syntaxes given are equivalent to each other.
-~~~~~
+~~~~{.cpp}
faces = Reader.GiveList(“xst-type(SurfaceOfRevolution)”);
faces = Reader.GiveList(“iges-type(120)”);
-~~~~~
+~~~~
You can also look for:
* values returned by your signature which match your criterion exactly
-~~~~~
+~~~~{.cpp}
faces = Reader.GiveList(“xst-type(=SurfaceOfRevolution)”);
-~~~~~
+~~~~
* values returned by your signature which do not contain your criterion
-~~~~~
+~~~~{.cpp}
faces = Reader.GiveList(“xst-type(!SurfaceOfRevolution)”);
-~~~~~
+~~~~
* values returned by your signature which do not exactly match your criterion.
-~~~~~
+~~~~{.cpp}
faces = Reader.GiveList(“xst-type(!=SurfaceOfRevolution)”);
-~~~~~
+~~~~
<h4>List of predefined operators that can be used:</h4>
* *xst-model-all* -- selects all entities.
@subsubsection occt_iges_2_3_5 Performing the IGES file translation
Perform translation according to what you want to translate:
1. Translate an entity identified by its rank with:
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = reader.Transfer (rank);
-~~~~~
+~~~~
2. Translate an entity identified by its handle with:
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = reader.TransferEntity (ent);
-~~~~~
+~~~~
3. Translate a list of entities in one operation with:
-~~~~~
+~~~~{.cpp}
Standard_Integer nbtrans = reader.TransferList (list);
reader.IsDone();
-~~~~~
+~~~~
where *nbtrans* returns the number of items in the list that produced a shape and *reader.IsDone()* indicates whether at least one entity was translated.
4. Translate a list of entities, entity by entity:
-~~~~~
+~~~~{.cpp}
Standard_Integer i,nb = list-Length();
for (i = 1; i <= nb; i ++) {
Handle(Standard_Transient) ent = list-Value(i);
Standard_Boolean OK = reader.TransferEntity (ent);
}
-~~~~~
+~~~~
5. Translate the whole file (all entities or only visible entities) with:
-~~~~~
+~~~~{.cpp}
Standard_Boolean onlyvisible = Standard_True or Standard_False;
reader.TransferRoots(onlyvisible)
-~~~~~
+~~~~
@subsubsection occt_iges_2_3_6 Getting the translation results
Each successful translation operation outputs one shape. A series of translations gives a series of shapes.
Each time you invoke *TransferEntity, Transfer* or *Transferlist*, their results are accumulated and NbShapes increases. You can clear the results (Clear function) between two translation operations, if you do not do this, the results from the next translation will be added to the accumulation. *TransferRoots* operations automatically clear all existing results before they start.
-~~~~~
+~~~~{.cpp}
Standard_Integer nbs = reader.NbShapes();
-~~~~~
+~~~~
returns the number of shapes recorded in the result.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape shape = reader.Shape(num);,
-~~~~~
+~~~~
returns the result *num*, where *num* is an integer between 1 and *NbShapes*.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape shape = reader.Shape();
-~~~~~
+~~~~
returns the first result in a translation operation.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape shape = reader.OneShape();
-~~~~~
+~~~~
returns all results in a single shape which is:
* a null shape if there are no results,
* in case of a single result, a shape that is specific to that result,
* a compound that lists the results if there are several results.
-~~~~~
+~~~~{.cpp}
reader.Clear();
-~~~~~
+~~~~
erases the existing results.
-~~~~~
+~~~~{.cpp}
reader.PrintTransferInfo (failsonly, mode);
-~~~~~
+~~~~
displays the messages that appeared during the last invocation of *Transfer* or *TransferRoots*.
If *failsonly* is *IFSelect_FailOnly*, only fail messages will be output, if it is *IFSelect_FailAndWarn*, all messages will be output. Parameter “mode” can have *IFSelect_xxx* values where *xxx* can be:
@subsection occt_iges_2_5 Messages
Messages are displayed concerning the normal functioning of the processor (transfer, loading, etc.).
You must declare an include file:
-~~~~~
+~~~~{.cpp}
#include \<Interface_DT.hxx\>
-~~~~~
+~~~~
You have the choice of the following options for messages:
-~~~~~
+~~~~{.cpp}
IDT_SetLevel (level);
-~~~~~
+~~~~
level modifies the level of messages:
* 0: no messages
* 1: raise and fail messages are displayed, as are messages concerning file access,
* 2: warnings are also displayed.
-~~~~~
+~~~~{.cpp}
IDT_SetFile (“tracefile.log”);
-~~~~~
+~~~~
prints the messages in a file,
-~~~~~
+~~~~{.cpp}
IDT_SetStandard();
-~~~~~
+~~~~
restores screen output.
@subsection occt_iges_2_6 Tolerance management
@subsection occt_iges_2_8 Example
-~~~~~
+~~~~{.cpp}
#include “IGESControl_Reader.hxx”
#include “TColStd_HSequenceOfTransient.hxx”
#include “TopoDS_Shape.hxx”
TopoDS_Shape sh = myIgesReader.OneShape();
//and obtains the results in an OCCT shape.
}
-~~~~~
+~~~~
@section occt_iges_3 Writing IGES
@subsection occt_iges_3_1 Procedure
* "Faces" (0): OCCT *TopoDS_Faces* will be translated into IGES 144 (Trimmed Surface) entities, no BRep entities will be written to the IGES file,
* "BRep" (1): OCCT *TopoDS_Faces* will be translated into IGES 510 (Face) entities, the IGES file will contain BRep entities.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer byvalue = Interface_Static::IVal("write.iges.brep.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
Interface_Static::SetIVal ("write.iges.brep.mode", 1);
-~~~~~
+~~~~
Default value is "Faces" (0).
* *write.convertsurface.mode* when writing to IGES in the BRep mode, this parameter indicates whether elementary surfaces (cylindrical, conical, spherical, and toroidal) are converted into corresponding IGES 5.3 entities (if the value of a parameter value is On), or written as surfaces of revolution (by default).
* *write.iges.unit:* allows choosing the unit. The default unit for Open CASCADE Technology is "MM" (millimeter). You can choose to write a file into any unit accepted by IGES.
* *write.precision.val:* is the user precision value. This parameter gives the resolution value for an IGES file when the *write.precision.mode* parameter value is 1. It is equal to 0.0001 by default, but can take any real positive (non null) value.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Real rp = Interface_Static::RVal(;write.precision.val;);
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetRVal(;write.precision.val;,0.01))
.. error ..
-~~~~~
+~~~~
Default value is 0.0001.
<h4>write.iges.resource.name</h4> and <h4>write.iges.sequence</h4> are the same as the corresponding read.iges.\* parameters. Note that the default sequence for writing contains *DirectFaces* operator, which converts elementary surfaces based on left-hand axes (valid in CASCADE) to right-hand axes (which are valid only in IGES).
Default values :
-~~~~~
+~~~~{.cpp}
write.iges.resource.name - IGES,
write.iges.sequence - ToIGES.
-~~~~~
+~~~~
@subsubsection occt_iges_3_3_3 Performing the Open CASCADE Technology shape translation
You can perform the translation in one or several operations. Here is how you translate topological and geometrical objects:
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = writer.AddShape (TopoDS_Shape);
-~~~~~
+~~~~
*ok* is True if translation was correctly performed and False if there was at least one entity that was not translated.
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = writer.AddGeom (geom);
-~~~~~
+~~~~
where *geom* is *Handle(Geom_Curve)* or *Handle(Geom_Surface)*;
*ok* is True if the translation was correctly performed and False if there was at least one entity whose geometry was not among the allowed types.
@subsubsection occt_iges_3_3_4 Writing the IGES file
Write the IGES file with:
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = writer.Write ("filename.igs");
-~~~~~
+~~~~
to give the file name.
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = writer.Write (S);
-~~~~~
+~~~~
where *S* is *Standard_OStream*
*ok* is True if the operation was correctly performed and False if an error occurred (for instance, if the processor could not create the file).
@subsection occt_iges_3_7 Example
-~~~~~{c++}
+~~~~{.cpp}
#include <IGESControl_Controller.hxx>
#include <IGESControl_Writer.hxx>
#include <TopoDS_Shape.hxx>
Standard_Boolean OK = ICW.Write (;MyFile.igs;);
//writes a model to the file MyFile.igs
}
-~~~~~
+~~~~
@section occt_iges_4 Using XSTEPDRAW
A set of parameters for importing and exporting IGES files is defined in the XSTEP resource file. In XSTEPDRAW, these parameters can be viewed or changed using command
-~~~~
+~~~~{.php}
Draw> param [<parameter_name> [<value>]]
~~~~
It is possible either only to load an IGES file into memory (i.e. to fill the model with data from the file), or to read it (i.e. to load and convert all entities to OCCT shapes).
Loading is done by the command
-~~~~~
+~~~~{.php}
Draw> xload <file_name>
-~~~~~
+~~~~
Once the file is loaded, it is possible to investigate the structure of the loaded data. To learn how to do it see @ref occt_iges_4_4 "Analyzing the transferred".
Reading of an IGES file is done by the command
-~~~~~
+~~~~{.php}
Draw> igesbrep <file_name> <result_shape_name> [<selection>]
-~~~~~
+~~~~
Here a dot can be used instead of a filename if the file is already loaded by *xload* or *igesbrep* command. In that case, only conversion of IGES entities to OCCT shapes will be done.
Command *igesbrep* will interactively ask the user to select a set of entities to be converted:
Instead of *igesbrep* it is possible to use commands:
-~~~~~
+~~~~{.php}
Draw> trimport <file_name> <result_shape_name> <selection>
-~~~~~
+~~~~
which outputs the result of translation of each selected entity into one shape, or
-~~~~~
+~~~~{.php}
Draw> trimpcomp <file_name> <result_shape_name> <selection>
-~~~~~
+~~~~
which outputs the result of translation of all selected entities into one shape (*TopoDS_Compound* for several entities).
An asterisk “*” can be specified instead of *selection*, it means *xst-transferrable-roots*.
@subsubsection occt_iges_4_4_1 Checking file contents
General statistics on the loaded data can be obtained by using command
-~~~~~
+~~~~{.php}
Draw> data <symbol>
-~~~~~
+~~~~
The information printed by this command depends on the symbol specified:
| Symbol | Output |
A list of these objects defined in the current session can be printed in DRAW by command
-~~~~~
+~~~~{.php}
Draw> listitems
-~~~~~
+~~~~
In the following commands if several <i>\<selection\></i> arguments are specified the results of each following selection are applied to the results of the previous one.
-~~~~~
+~~~~{.php}
Draw> givelist <selection_name> [<selection_name>]
-~~~~~
+~~~~
prints a list of loaded entities defined by selection argument.
-~~~~~
+~~~~{.php}
Draw> givecount <selection_name> [<selection_name>]
-~~~~~
+~~~~
prints a number of loaded entities defined by <i>selection</i> argument.
Three commands are used to calculate statistics on the entities in the model:
| iges-levels | Calculates how much entities lie in different IGES levels |
The command:
-~~~~~
+~~~~{.php}
Draw> listtypes <selection_name> ...
-~~~~~
+~~~~
gives a list of entity types which were encountered in the last loaded file (with a number of IGES entities of each type). The list can be shown not for all entities but for a subset of them. This subset is defined by an optional selection argument.
Entities in the IGES file are numbered in the succeeding order. An entity can be identified either by its number (#) or by its label. Label is the letter ‘D’ followed by the index of the first line with the data for this entity in the Directory Entry section of the IGES file. The label can be calculated on the basis of the number as ‘D(2*# -1)’. For example, entity # 6 has label D11.
@subsubsection occt_iges_4_4_2 Estimating the results of reading IGES
All of the following commands are available only after the data are converted into OCCT shapes (i.e. after command **igesbrep**).
-~~~~~
+~~~~{.php}
Draw> tpstat [*|?]<symbol> [<selection>]
-~~~~~
+~~~~
provides all statistics on the last transfer, including the list of transferred entities with mapping from IGES to OCCT types, as well as fail and warning messages. The parameter <i>\<symbol\></i> defines what information will be printed:
* G -- General statistics (list of results and messages)
* C -- Count of all warning and fail messages
To get help, run this command without arguments.
For example, to get translation ratio on IGES faces, you can use.
-~~~~~
+~~~~{.php}
Draw:> tpstat *l iges-faces
-~~~~~
+~~~~
The second version of the same command is TPSTAT (not capital spelling).
-~~~~~
+~~~~{.php}
Draw:> TPSTAT <symbol>
-~~~~~
+~~~~
Symbol can be of the following values:
* g -- General statistics (list of results and messages)
* c -- Count of all warning and fail messages
Sometimes the trimming contours of IGES faces (i.e., entity 141 for 143, 142 for 144) can be lost during translation due to fails.
The number of lost trims and the corresponding IGES entities can be obtained by the command:
-~~~~~
+~~~~{.php}
Draw> tplosttrim [<IGES_type>]
-~~~~~
+~~~~
It outputs the rank and DE numbers of faces that lost their trims and their numbers for each type (143, 144, 510) and their total number. If a face lost several of its trims it is output only once.
Optional parameter <i>\<IGES_type\></i> can be *TrimmedSurface, BoundedSurface* or *Face* to specify the only type of IGES faces.
For example, to get untrimmed 144 entities, use command
-~~~~~
+~~~~{.php}
Draw> tplosttrim TrimmedSurface
-~~~~~
+~~~~
To get the information on OCCT shape contents, use command
-~~~~~
+~~~~{.php}
Draw> statshape <shape_name>
-~~~~~
+~~~~
It outputs the number of each kind of shapes (vertex, edge, wire, etc.) in a shape and some geometrical data (number of C0 surfaces, curves, indirect surfaces, etc.).
Note. The number of faces is returned as a number of references. To obtain the number of single instances the standard command (from TTOPOLOGY executable) **nbshapes** can be used.
To analyze the internal validity of a shape, use command
-~~~~~
+~~~~{.php}
Draw> checkbrep <shape_name> <expurged_shape_name>
-~~~~~
+~~~~
It checks the geometry and topology of a shape for different cases of inconsistency, like self-intersecting wires or wrong orientation of trimming contours. If an error is found, it copies bad parts of the shape with the names "expurged_subshape_name _#" and generates an appropriate message. If possible, this command also tries to find IGES entities the OCCT shape was produced from.
<i>\<expurged_shape_name\></i> will contain the original shape without invalid subshapes.
To get information on tolerances of subshapes, use command
-~~~~~
+~~~~{.php}
Draw> tolerance <shape_name> [<min> [<max>] [<symbol>]]
-~~~~~
+~~~~
It outputs maximum, average and minimum values of tolerances for each kind of subshapes having tolerances or it can output tolerances of all subshapes of the whole shape.
When specifying *min* and *max* arguments this command outputs shapes with names <i>\<shape_name\>...</i> and their total number with tolerances in the range <i>[min, max]</i>.
| Measurement units | XSTEP.iges.unit | 1-11 (or a string value) |
Several shapes can be written in one file. To start writing a new file, enter command
-~~~~~
+~~~~{.php}
Draw> newmodel
-~~~~~
+~~~~
This command clears the *InterfaceModel* to make it empty.
-~~~~~
+~~~~{.php}
Draw> brepiges <shape_name_1> [<filename.igs>]
-~~~~~
+~~~~
Converts the specified shapes into IGES entities and puts them into the *InterfaceModel*.
-~~~~~
+~~~~{.php}
Draw> writeall <filename.igs>
-~~~~~
+~~~~
Allows writing the prepared model to a file with name *filename.igs*.
@section occt_iges_5 Reading from and writing to IGES
### Load an IGES file
Before performing any other operation, you must load an IGES file with:
-~~~~~
+~~~~{.cpp}
IGESCAFControl_Reader reader(XSDRAW::Session(), Standard_False);
IFSelect_ReturnStatus stat = reader.ReadFile(“filename.igs”);
-~~~~~
+~~~~
Loading the file only memorizes, but does not translate the data.
### Check the loaded IGES file
In addition, the following parameters can be set for XDE translation of attributes:
* For transferring colors:
-~~~~~
+~~~~{.cpp}
reader.SetColorMode(mode);
// mode can be Standard_True or Standard_False
-~~~~~
+~~~~
* For transferring names:
-~~~~~
+~~~~{.cpp}
reader.SetNameMode(mode);
// mode can be Standard_True or Standard_False
-~~~~~
+~~~~
### Translate an IGES file to XDE
The following function performs a translation of the whole document:
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = reader.Transfer(doc);
-~~~~~
+~~~~
where *doc* is a variable which contains a handle to the output document and should have a type *Handle(TDocStd_Document)*.
@subsection occt_iges_5_2 Writing to IGES
The translation from XDE to IGES can be initialized as follows:
-~~~~~
+~~~~{.cpp}
IGESCAFControl_Writer aWriter(XSDRAW::Session(),Standard_False);
-~~~~~
+~~~~
### Set parameters for translation from XDE to IGES
The following parameters can be set for translation of attributes to IGES:
* For transferring colors:
-~~~~~
+~~~~{.cpp}
aWriter.SetColorMode(mode);
// mode can be Standard_True or Standard_False
-~~~~~
+~~~~
* For transferring names:
-~~~~~
+~~~~{.cpp}
aWriter.SetNameMode(mode);
// mode can be Standard_True or Standard_False
-~~~~~
+~~~~
### Translate an XDE document to IGES
You can perform the translation of a document by calling the function:
-~~~~~
+~~~~{.cpp}
IFSelect_ReturnStatus aRetSt = aWriter.Transfer(doc);
-~~~~~
+~~~~
where "doc" is a variable which contains a handle to the input document for transferring and should have a type *Handle(TDocStd_Document)*.
### Write an IGES file
Write an IGES file with:
-~~~~~
+~~~~{.cpp}
IFSelect_ReturnStatus statw = aWriter.WriteFile("filename.igs");
-~~~~~
+~~~~
or
-~~~~~
+~~~~{.cpp}
IFSelect_ReturnStatus statw = writer.WriteFile (S);
-~~~~~
+~~~~
where S is OStream.
The simple code to start Inspector with all plugins loaded:
-~~~~~
+~~~~
pload INSPECTOR
tinspector
-~~~~~
+~~~~
@figure{drawexe_tinspector.png,"tinspector",360}
Here is an example of C++ implementation:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
#include <inspector/TInspector_Communicator.hxx>
}
MyTCommunicator->SetVisible (true);
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Give one the following objects for a plugin using a container of parameters:
The algorithm of shape triangulation is provided by the functionality of *BRepMesh_IncrementalMesh* class, which adds a triangulation of the shape to its topological data structure. This triangulation is used to visualize the shape in shaded mode.
-~~~~~
+~~~~{.cpp}
#include <IMeshData_Status.hxx>
#include <IMeshTools_Parameters.hxx>
#include <BRepMesh_IncrementalMesh.hxx>
const Standard_Integer aStatus = aMesher.GetStatusFlags();
return !aStatus;
}
-~~~~~
+~~~~
The default meshing algorithm *BRepMesh_IncrementalMesh* has two major options to define triangulation -- linear and angular deflections.
The following example demonstrates how it could be done from *Draw* environment:
-~~~~~
+~~~~{.php}
psphere s 10
### Default Algo ###
### Delabella Algo ###
incmesh s 0.0001 -algo delabella
-~~~~~
+~~~~
The code snippet below shows passing a custom mesh factory to BRepMesh_IncrementalMesh:
-~~~~~
+~~~~{.cpp}
IMeshTools_Parameters aMeshParams;
Handle(IMeshTools_Context) aContext = new BRepMesh_Context();
aContext->SetFaceDiscret (new BRepMesh_FaceDiscret (new BRepMesh_DelabellaMeshAlgoFactory()));
aMesher.ChangeParameters() = aMeshParams;
aMesher.Perform (aContext);
-~~~~~
+~~~~
#### Range splitter
Range splitter tools provide functionality to generate internal surface nodes defined within the range computed using discrete model data. The base functionality is provided by *BRepMesh_DefaultRangeSplitter* which can be used without modifications in case of planar surface. The default splitter does not generate any internal node.
@subsubsection occt_modalg_2_2_1 Intersection of two curves
*Geom2dAPI_InterCurveCurve* class may be instantiated for intersection of curves *C1* and *C2*.
-~~~~~
+~~~~{.cpp}
Geom2dAPI_InterCurveCurve Intersector(C1,C2,tolerance);
-~~~~~
+~~~~
or for self-intersection of curve *C3*.
-~~~~~
+~~~~{.cpp}
Geom2dAPI_InterCurveCurve Intersector(C3,tolerance);
-~~~~~
+~~~~
-~~~~~
+~~~~{.cpp}
Standard_Integer N = Intersector.NbPoints();
-~~~~~
+~~~~
Calls the number of intersection points
To select the desired intersection point, pass an integer index value in argument.
-~~~~~
+~~~~{.cpp}
gp_Pnt2d P = Intersector.Point(Index);
-~~~~~
+~~~~
To call the number of intersection segments, use
-~~~~~
+~~~~{.cpp}
Standard_Integer M = Intersector.NbSegments();
-~~~~~
+~~~~
To select the desired intersection segment pass integer index values in argument.
-~~~~~
+~~~~{.cpp}
Handle(Geom2d_Curve) Seg1, Seg2;
Intersector.Segment(Index,Seg1,Seg2);
// if intersection of 2 curves
Intersector.Segment(Index,Seg1);
// if self-intersection of a curve
-~~~~~
+~~~~
If you need access to a wider range of functionalities the following method will return the algorithmic object for the calculation of intersections:
-~~~~~
+~~~~{.cpp}
Geom2dInt_GInter& TheIntersector = Intersector.Intersector();
-~~~~~
+~~~~
@subsubsection occt_modalg_2_2_2 Intersection of Curves and Surfaces
The *GeomAPI_IntCS* class is used to compute the intersection points between a curve and a surface.
This class is instantiated as follows:
-~~~~~
+~~~~{.cpp}
GeomAPI_IntCS Intersector(C, S);
-~~~~~
+~~~~
To call the number of intersection points, use:
-~~~~~
+~~~~{.cpp}
Standard_Integer nb = Intersector.NbPoints();
-~~~~~
+~~~~
-~~~~~
+~~~~{.cpp}
gp_Pnt& P = Intersector.Point(Index);
-~~~~~
+~~~~
Where *Index* is an integer between 1 and *nb*, calls the intersection points.
The *GeomAPI_IntSS* class is used to compute the intersection of two surfaces from *Geom_Surface* with respect to a given tolerance.
This class is instantiated as follows:
-~~~~~
+~~~~{.cpp}
GeomAPI_IntSS Intersector(S1, S2, Tolerance);
-~~~~~
+~~~~
Once the *GeomAPI_IntSS* object has been created, it can be interpreted.
-~~~~~
+~~~~{.cpp}
Standard_Integer nb = Intersector. NbLines();
-~~~~~
+~~~~
Calls the number of intersection curves.
-~~~~~
+~~~~{.cpp}
Handle(Geom_Curve) C = Intersector.Line(Index)
-~~~~~
+~~~~
Where *Index* is an integer between 1 and *nb*, calls the intersection curves.
@subsubsection occt_modalg_2_3_1 Geom2dAPI_Interpolate
This class is used to interpolate a BSplineCurve passing through an array of points. If tangency is not requested at the point of interpolation, continuity will be *C2*. If tangency is requested at the point, continuity will be *C1*. If Periodicity is requested, the curve will be closed and the junction will be the first point given. The curve will then have a continuity of *C1* only.
This class may be instantiated as follows:
-~~~~~
+~~~~{.cpp}
Geom2dAPI_Interpolate
(const Handle_TColgp_HArray1OfPnt2d& Points,
const Standard_Boolean PeriodicFlag,
Geom2dAPI_Interpolate Interp(Points, Standard_False,
Precision::Confusion());
-~~~~~
+~~~~
It is possible to call the BSpline curve from the object defined above it.
-~~~~~
+~~~~{.cpp}
Handle(Geom2d_BSplineCurve) C = Interp.Curve();
-~~~~~
+~~~~
Note that the *Handle(Geom2d_BSplineCurve)* operator has been redefined by the method *Curve()*. Consequently, it is unnecessary to pass via the construction of an intermediate object of the *Geom2dAPI_Interpolate* type and the following syntax is correct.
-~~~~~
+~~~~{.cpp}
Handle(Geom2d_BSplineCurve) C =
Geom2dAPI_Interpolate(Points,
Standard_False,
Precision::Confusion());
-~~~~~
+~~~~
@subsubsection occt_modalg_2_3_2 GeomAPI_Interpolate
This class may be instantiated as follows:
-~~~~~
+~~~~{.cpp}
GeomAPI_Interpolate
(const Handle_TColgp_HArray1OfPnt& Points,
const Standard_Boolean PeriodicFlag,
GeomAPI_Interpolate Interp(Points, Standard_False,
Precision::Confusion());
-~~~~~
+~~~~
It is possible to call the BSpline curve from the object defined above it.
-~~~~~
+~~~~{.cpp}
Handle(Geom_BSplineCurve) C = Interp.Curve();
-~~~~~
+~~~~
Note that the *Handle(Geom_BSplineCurve)* operator has been redefined by the method *Curve()*. Thus, it is unnecessary to pass via the construction of an intermediate object of the *GeomAPI_Interpolate* type and the following syntax is correct.
Handle(Geom_BSplineCurve) C =
1.0e-7);
Boundary conditions may be imposed with the method Load.
-~~~~~
+~~~~{.cpp}
GeomAPI_Interpolate AnInterpolator
(Points, Standard_False, 1.0e-5);
AnInterpolator.Load (StartingTangent, EndingTangent);
-~~~~~
+~~~~
@subsection occt_modalg_2_4 Lines and Circles from Constraints
* **Unqualified** -- the relative position is not qualified, i.e. all solutions apply.
It is possible to create expressions using the qualifiers, for example:
-~~~~~
+~~~~{.cpp}
GccAna_Circ2d2TanRad
Solver(GccEnt::Outside(C1),
GccEnt::Enclosing(C2), Rad, Tolerance);
-~~~~~
+~~~~
This expression finds all circles of radius *Rad*, which are tangent to both circle *C1* and *C2*, while *C1* is outside and *C2* is inside.
Tangent and Exterior to C1.
Tangent and Exterior to C2.
-Syntax:
+Syntax:
-~~~~~
+~~~~{.cpp}
GccAna_Lin2d2Tan
Solver(GccEnt::Outside(C1),
GccEnt::Outside(C2),
Tolerance);
-~~~~~
+~~~~
**Example 1 Case 2**
Tangent and Including C1.
Tangent and Including C2.
-Syntax:
+Syntax:
-~~~~~
+~~~~{.cpp}
GccAna_Lin2d2Tan
Solver(GccEnt::Enclosing(C1),
GccEnt::Enclosing(C2),
Tolerance);
-~~~~~
+~~~~
**Example 1 Case 3**
Tangent and Including C1.
Tangent and Exterior to C2.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.cpp}
GccAna_Lin2d2Tan
Solver(GccEnt::Enclosing(C1),
GccEnt::Outside(C2),
Tolerance);
-~~~~~
+~~~~
**Example 1 Case 4**
Tangent and Exterior to C1.
Tangent and Including C2.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.cpp}
GccAna_Lin2d2Tan
Solver(GccEnt::Outside(C1),
GccEnt::Enclosing(C2),
Tolerance);
-~~~~~
+~~~~
**Example 1 Case 5**
Tangent and Undefined with respect to C1.
Tangent and Undefined with respect to C2.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.cpp}
GccAna_Lin2d2Tan
Solver(GccEnt::Unqualified(C1),
GccEnt::Unqualified(C2),
Tolerance);
-~~~~~
+~~~~
#### Circle of given radius tangent to two circles
The following four diagrams show the four cases in using qualifiers in the creation of a circle.
Tangent and Exterior to C1.
Tangent and Exterior to C2.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.cpp}
GccAna_Circ2d2TanRad
Solver(GccEnt::Outside(C1),
GccEnt::Outside(C2), Rad, Tolerance);
-~~~~~
+~~~~
**Example 2 Case 2**
Tangent and Exterior to C1.
Tangent and Included by C2.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.cpp}
GccAna_Circ2d2TanRad
Solver(GccEnt::Outside(C1),
GccEnt::Enclosed(C2), Rad, Tolerance);
-~~~~~
+~~~~
**Example 2 Case 3**
@figure{/user_guides/modeling_algos/images/modeling_algos_image016.png,"Solutions enclose C2",220}
Tangent and Exterior to C1.
Tangent and Including C2.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.cpp}
GccAna_Circ2d2TanRad
Solver(GccEnt::Outside(C1),
GccEnt::Enclosing(C2), Rad, Tolerance);
-~~~~~
+~~~~
**Example 2 Case 4**
@figure{/user_guides/modeling_algos/images/modeling_algos_image017.png,"Solutions enclose C1",220}
Tangent and Enclosing C1.
Tangent and Enclosing C2.
-Syntax:
-~~~~~
+Syntax:
+~~~~{.cpp}
GccAna_Circ2d2TanRad
Solver(GccEnt::Enclosing(C1),
GccEnt::Enclosing(C2), Rad, Tolerance);
-~~~~~
+~~~~
**Example 2 Case 5**
The following syntax will give all the circles of radius *Rad*, which are tangent to *C1* and *C2* without discrimination of relative position:
-~~~~~
+~~~~{.cpp}
GccAna_Circ2d2TanRad Solver(GccEnt::Unqualified(C1),
GccEnt::Unqualified(C2),
Rad,Tolerance);
-~~~~~
+~~~~
@subsubsection occt_modalg_2_4_3 Types of algorithms
If you want to give a specific length to a batten curve, use:
-~~~~~
+~~~~{.cpp}
b.SetSlidingFactor(L / b.SlidingOfReference())
-~~~~~
+~~~~
where *b* is the name of the batten curve object
Free sliding is generally more aesthetically pleasing than constrained sliding. However, the computation can fail with values such as angles greater than *p/2* because in this case the length is theoretically infinite.
Let us create a Plate surface and approximate it from a polyline as a curve constraint and a point constraint
-~~~~~
+~~~~{.cpp}
Standard_Integer NbCurFront=4,
NbPointConstraint=1;
gp_Pnt P1(0.,0.,0.);
Standard_Real Umin, Umax, Vmin, Vmax;
PSurf->Bounds( Umin, Umax, Vmin, Vmax);
BRepBuilderAPI_MakeFace MF(Surf,Umin, Umax, Vmin, Vmax);
-~~~~~
+~~~~
@subsection occt_modalg_2_6 Projections
The class *Geom2dAPI_ProjectPointOnCurve* may be instantiated as in the following example:
-~~~~~
+~~~~{.cpp}
gp_Pnt2d P;
Handle(Geom2d_BezierCurve) C =
new Geom2d_BezierCurve(args);
Geom2dAPI_ProjectPointOnCurve Projector (P, C);
-~~~~~
+~~~~
To restrict the search for normals to a given domain <i>[U1,U2]</i>, use the following constructor:
-~~~~~
+~~~~{.cpp}
Geom2dAPI_ProjectPointOnCurve Projector (P, C, U1, U2);
-~~~~~
+~~~~
Having thus created the *Geom2dAPI_ProjectPointOnCurve* object, we can now interrogate it.
#### Calling the number of solution points
-~~~~~
+~~~~{.cpp}
Standard_Integer NumSolutions = Projector.NbPoints();
-~~~~~
+~~~~
#### Calling the location of a solution point
The solutions are indexed in a range from *1* to *Projector.NbPoints()*. The point, which corresponds to a given *Index* may be found:
-~~~~~
+~~~~{.cpp}
gp_Pnt2d Pn = Projector.Point(Index);
-~~~~~
+~~~~
#### Calling the parameter of a solution point
For a given point corresponding to a given *Index*:
-~~~~~
+~~~~{.cpp}
Standard_Real U = Projector.Parameter(Index);
-~~~~~
+~~~~
This can also be programmed as:
-~~~~~
+~~~~{.cpp}
Standard_Real U;
Projector.Parameter(Index,U);
-~~~~~
+~~~~
#### Calling the distance between the start and end points
We can find the distance between the initial point and a point, which corresponds to the given *Index*:
-~~~~~
+~~~~{.cpp}
Standard_Real D = Projector.Distance(Index);
-~~~~~
+~~~~
#### Calling the nearest solution point
This class offers a method to return the closest solution point to the starting point. This solution is accessed as follows:
-~~~~~
+~~~~{.cpp}
gp_Pnt2d P1 = Projector.NearestPoint();
-~~~~~
+~~~~
#### Calling the parameter of the nearest solution point
-~~~~~
+~~~~{.cpp}
Standard_Real U = Projector.LowerDistanceParameter();
-~~~~~
+~~~~
#### Calling the minimum distance from the point to the curve
-~~~~~
+~~~~{.cpp}
Standard_Real D = Projector.LowerDistance();
-~~~~~
+~~~~
#### Redefined operators
*Standard_Real()* returns the minimum distance from the point to the curve.
-~~~~~
+~~~~{.cpp}
Standard_Real D = Geom2dAPI_ProjectPointOnCurve (P,C);
-~~~~~
+~~~~
*Standard_Integer()* returns the number of solutions.
-~~~~~
+~~~~{.cpp}
Standard_Integer N =
Geom2dAPI_ProjectPointOnCurve (P,C);
-~~~~~
+~~~~
*gp_Pnt2d()* returns the nearest solution point.
-~~~~~
+~~~~{.cpp}
gp_Pnt2d P1 = Geom2dAPI_ProjectPointOnCurve (P,C);
-~~~~~
+~~~~
Using these operators makes coding easier when you only need the nearest point. Thus:
-~~~~~
+~~~~{.cpp}
Geom2dAPI_ProjectPointOnCurve Projector (P, C);
gp_Pnt2d P1 = Projector.NearestPoint();
-~~~~~
+~~~~
can be written more concisely as:
-~~~~~
+~~~~{.cpp}
gp_Pnt2d P1 = Geom2dAPI_ProjectPointOnCurve (P,C);
-~~~~~
+~~~~
However, note that in this second case no intermediate *Geom2dAPI_ProjectPointOnCurve* object is created, and thus it is impossible to have access to other solution points.
If you want to use the wider range of functionalities available from the *Extrema* package, a call to the *Extrema()* method will return the algorithmic object for calculating extrema. For example:
-~~~~~
+~~~~{.cpp}
Extrema_ExtPC2d& TheExtrema = Projector.Extrema();
-~~~~~
+~~~~
@subsubsection occt_modalg_2_6_2 Projection of a 3D Point on a Curve
The class *GeomAPI_ProjectPointOnCurve* is instantiated as in the following example:
-~~~~~
+~~~~{.cpp}
gp_Pnt P;
Handle(Geom_BezierCurve) C =
new Geom_BezierCurve(args);
GeomAPI_ProjectPointOnCurve Projector (P, C);
-~~~~~
+~~~~
If you wish to restrict the search for normals to the given domain [U1,U2], use the following constructor:
-~~~~~
+~~~~{.cpp}
GeomAPI_ProjectPointOnCurve Projector (P, C, U1, U2);
-~~~~~
+~~~~
Having thus created the *GeomAPI_ProjectPointOnCurve* object, you can now interrogate it.
#### Calling the number of solution points
-~~~~~
+~~~~{.cpp}
Standard_Integer NumSolutions = Projector.NbPoints();
-~~~~~
+~~~~
#### Calling the location of a solution point
The solutions are indexed in a range from 1 to *Projector.NbPoints()*. The point, which corresponds to a given index, may be found:
-~~~~~
+~~~~{.cpp}
gp_Pnt Pn = Projector.Point(Index);
-~~~~~
+~~~~
#### Calling the parameter of a solution point
For a given point corresponding to a given index:
-~~~~~
+~~~~{.cpp}
Standard_Real U = Projector.Parameter(Index);
-~~~~~
+~~~~
This can also be programmed as:
-~~~~~
+~~~~{.cpp}
Standard_Real U;
Projector.Parameter(Index,U);
-~~~~~
+~~~~
#### Calling the distance between the start and end point
The distance between the initial point and a point, which corresponds to a given index, may be found:
-~~~~~
+~~~~{.cpp}
Standard_Real D = Projector.Distance(Index);
-~~~~~
+~~~~
#### Calling the nearest solution point
This class offers a method to return the closest solution point to the starting point. This solution is accessed as follows:
-~~~~~
+~~~~{.cpp}
gp_Pnt P1 = Projector.NearestPoint();
-~~~~~
+~~~~
#### Calling the parameter of the nearest solution point
-~~~~~
+~~~~{.cpp}
Standard_Real U = Projector.LowerDistanceParameter();
-~~~~~
+~~~~
#### Calling the minimum distance from the point to the curve
-~~~~~
+~~~~{.cpp}
Standard_Real D = Projector.LowerDistance();
-~~~~~
+~~~~
#### Redefined operators
*Standard_Real()* returns the minimum distance from the point to the curve.
-~~~~~
+~~~~{.cpp}
Standard_Real D = GeomAPI_ProjectPointOnCurve (P,C);
-~~~~~
+~~~~
*Standard_Integer()* returns the number of solutions.
-~~~~~
+~~~~{.cpp}
Standard_Integer N = GeomAPI_ProjectPointOnCurve (P,C);
-~~~~~
+~~~~
*gp_Pnt2d()* returns the nearest solution point.
-~~~~~
+~~~~{.cpp}
gp_Pnt P1 = GeomAPI_ProjectPointOnCurve (P,C);
-~~~~~
+~~~~
Using these operators makes coding easier when you only need the nearest point. In this way,
-~~~~~
+~~~~{.cpp}
GeomAPI_ProjectPointOnCurve Projector (P, C);
gp_Pnt P1 = Projector.NearestPoint();
-~~~~~
+~~~~
can be written more concisely as:
-~~~~~
+~~~~{.cpp}
gp_Pnt P1 = GeomAPI_ProjectPointOnCurve (P,C);
-~~~~~
+~~~~
In the second case, however, no intermediate *GeomAPI_ProjectPointOnCurve* object is created, and it is impossible to access other solutions points.
#### Access to lower-level functionalities
If you want to use the wider range of functionalities available from the *Extrema* package, a call to the *Extrema()* method will return the algorithmic object for calculating the extrema. For example:
-~~~~~
+~~~~{.cpp}
Extrema_ExtPC& TheExtrema = Projector.Extrema();
-~~~~~
+~~~~
@subsubsection occt_modalg_2_6_3 Projection of a Point on a Surface
The algorithm will function with any class inheriting *Geom_Surface*.
*GeomAPI_ProjectPointOnSurf* is instantiated as in the following example:
-~~~~~
+~~~~{.cpp}
gp_Pnt P;
Handle (Geom_Surface) S = new Geom_BezierSurface(args);
GeomAPI_ProjectPointOnSurf Proj (P, S);
-~~~~~
+~~~~
To restrict the search for normals within the given rectangular domain [U1, U2, V1, V2], use the constructor <i>GeomAPI_ProjectPointOnSurf Proj (P, S, U1, U2, V1, V2)</i>
The values of *U1, U2, V1* and *V2* lie at or within their maximum and minimum limits, i.e.:
-~~~~~
+~~~~{.cpp}
Umin <= U1 < U2 <= Umax
Vmin <= V1 < V2 <= Vmax
-~~~~~
+~~~~
Having thus created the *GeomAPI_ProjectPointOnSurf* object, you can interrogate it.
#### Calling the number of solution points
-~~~~~
+~~~~{.cpp}
Standard_Integer NumSolutions = Proj.NbPoints();
-~~~~~
+~~~~
#### Calling the location of a solution point
The solutions are indexed in a range from 1 to *Proj.NbPoints()*. The point corresponding to the given index may be found:
-~~~~~
+~~~~{.cpp}
gp_Pnt Pn = Proj.Point(Index);
-~~~~~
+~~~~
#### Calling the parameters of a solution point
For a given point corresponding to the given index:
-~~~~~
+~~~~{.cpp}
Standard_Real U,V;
Proj.Parameters(Index, U, V);
-~~~~~
+~~~~
#### Calling the distance between the start and end point
The distance between the initial point and a point corresponding to the given index may be found:
-~~~~~
+~~~~{.cpp}
Standard_Real D = Projector.Distance(Index);
-~~~~~
+~~~~
#### Calling the nearest solution point
This class offers a method, which returns the closest solution point to the starting point. This solution is accessed as follows:
-~~~~~
+~~~~{.cpp}
gp_Pnt P1 = Proj.NearestPoint();
-~~~~~
+~~~~
#### Calling the parameters of the nearest solution point
-~~~~~
+~~~~{.cpp}
Standard_Real U,V;
Proj.LowerDistanceParameters (U, V);
-~~~~~
+~~~~
#### Calling the minimum distance from a point to the surface
-~~~~~
+~~~~{.cpp}
Standard_Real D = Proj.LowerDistance();
-~~~~~
+~~~~
#### Redefined operators
*Standard_Real()* returns the minimum distance from the point to the surface.
-~~~~~
+~~~~{.cpp}
Standard_Real D = GeomAPI_ProjectPointOnSurf (P,S);
-~~~~~
+~~~~
*Standard_Integer()* returns the number of solutions.
-~~~~~
+~~~~{.cpp}
Standard_Integer N = GeomAPI_ProjectPointOnSurf (P,S);
-~~~~~
+~~~~
*gp_Pnt2d()* returns the nearest solution point.
-~~~~~
+~~~~{.cpp}
gp_Pnt P1 = GeomAPI_ProjectPointOnSurf (P,S);
-~~~~~
+~~~~
Using these operators makes coding easier when you only need the nearest point. In this way,
-~~~~~
+~~~~{.cpp}
GeomAPI_ProjectPointOnSurface Proj (P, S);
gp_Pnt P1 = Proj.NearestPoint();
-~~~~~
+~~~~
can be written more concisely as:
-~~~~~
+~~~~{.cpp}
gp_Pnt P1 = GeomAPI_ProjectPointOnSurface (P,S);
-~~~~~
+~~~~
In the second case, however, no intermediate *GeomAPI_ProjectPointOnSurf* object is created, and it is impossible to access other solution points.
If you want to use the wider range of functionalities available from the *Extrema* package, a call to the *Extrema()* method will return the algorithmic object for calculating the extrema as follows:
-~~~~~
+~~~~{.cpp}
Extrema_ExtPS& TheExtrema = Proj.Extrema();
-~~~~~
+~~~~
@subsubsection occt_modalg_2_12_8 Switching from 2d and 3d Curves
* build a 3d curve from a *Geom2d_Curve* and a *gp_Pln* plane.
These methods are called as follows:
-~~~~~
+~~~~{.cpp}
Handle(Geom2d_Curve) C2d = GeomAPI::To2d(C3d, Pln);
Handle(Geom_Curve) C3d = GeomAPI::To3d(C2d, Pln);
-~~~~~
+~~~~
@section occt_modalg_3 Standard Topological Objects
@subsection occt_modalg_3_1 Vertex
*BRepBuilderAPI_MakeVertex* creates a new vertex from a 3D point from gp.
-~~~~~
+~~~~{.cpp}
gp_Pnt P(0,0,10);
TopoDS_Vertex V = BRepBuilderAPI_MakeVertex(P);
-~~~~~
+~~~~
This class always creates a new vertex and has no other methods.
Use *BRepBuilderAPI_MakeEdge* to create from a curve and vertices. The basic method constructs an edge from a curve, two vertices, and two parameters.
-~~~~~
+~~~~{.cpp}
Handle(Geom_Curve) C = ...; // a curve
TopoDS_Vertex V1 = ...,V2 = ...;// two Vertices
Standard_Real p1 = ..., p2 = ..;// two parameters
TopoDS_Edge E = BRepBuilderAPI_MakeEdge(C,V1,V2,p1,p2);
-~~~~~
+~~~~
where C is the domain of the edge; V1 is the first vertex oriented FORWARD; V2 is the second vertex oriented REVERSED; p1 and p2 are the parameters for the vertices V1 and V2 on the curve. The default tolerance is associated with this edge.
**The parameters**
* Must be increasing and in the range of the curve, i.e.:
-~~~~~
+~~~~{.cpp}
C->FirstParameter() <= p1 < p2 <= C->LastParameter()
-~~~~~
+~~~~
* If the parameters are decreasing, the Vertices are switched, i.e. V2 becomes V1 and V1 becomes V2.
* On a periodic curve the parameters p1 and p2 are adjusted by adding or subtracting the period to obtain p1 in the range of the curve and p2 in the range p1 < p2 <= p1+ Period. So on a parametric curve p2 can be greater than the second parameter, see the figure below.
The five following methods are thus derived from the basic construction:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Curve) C = ...; // a curve
TopoDS_Vertex V1 = ...,V2 = ...;// two Vertices
Standard_Real p1 = ..., p2 = ..;// two parameters
E = BRepBuilderAPI_MakeEdge(C,p1,p2);
// Make an edge from the whole curve
E = BRepBuilderAPI_MakeEdge(C);
-~~~~~
+~~~~
Six methods (the five above and the basic method) are also provided for curves from the gp package in place of Curve from Geom. The methods create the corresponding Curve from Geom and are implemented for the following classes:
There are also two methods to construct edges from two vertices or two points. These methods assume that the curve is a line; the vertices or points must have different locations.
-~~~~~
+~~~~{.cpp}
TopoDS_Vertex V1 = ...,V2 = ...;// two Vertices
gp_Pnt P1 = ..., P2 = ...;// two points
// linear edge from two points
E = BRepBuilderAPI_MakeEdge(P1,P2);
-~~~~~
+~~~~
@subsubsection occt_modalg_3_2_3 Other information and error status
@figure{/user_guides/modeling_algos/images/modeling_algos_image024.png,"Creating a Wire",360}
-~~~~~
+~~~~{.cpp}
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <TopoDS_Shape.hxx>
#include <gp_Circ.hxx>
}
return MW.Wire();
}
-~~~~~
+~~~~
@subsection occt_modalg_3_3 Edge 2D
The basic usage of *BRepBuilderAPI_MakePolygon* is to create a wire by adding vertices or points using the Add method. At any moment, the current wire can be extracted. The close method can be used to close the current wire. In the following example, a closed wire is created from an array of points.
-~~~~~
+~~~~{.cpp}
#include <TopoDS_Wire.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
#include <TColgp_Array1OfPnt.hxx>
MP.Close();
return MP;
}
-~~~~~
+~~~~
Short-cuts are provided for 2, 3, or 4 points or vertices. Those methods have a Boolean last argument to tell if the polygon is closed. The default value is False.
Two examples:
Example of a closed triangle from three vertices:
-~~~~~
+~~~~{.cpp}
TopoDS_Wire W = BRepBuilderAPI_MakePolygon(V1,V2,V3,Standard_True);
-~~~~~
+~~~~
Example of an open polygon from four points:
-~~~~~
+~~~~{.cpp}
TopoDS_Wire W = BRepBuilderAPI_MakePolygon(P1,P2,P3,P4);
-~~~~~
+~~~~
*BRepBuilderAPI_MakePolygon* class maintains a current wire. The current wire can be extracted at any moment and the construction can proceed to a longer wire. After each point insertion, the class maintains the last created edge and vertex, which are returned by the methods *Edge, FirstVertex* and *LastVertex*.
A face can be constructed from a surface and four parameters to determine a limitation of the UV space. The parameters are optional, if they are omitted the natural bounds of the surface are used. Up to four edges and vertices are created with a wire. No edge is created when the parameter is infinite.
-~~~~~
+~~~~{.cpp}
Handle(Geom_Surface) S = ...; // a surface
Standard_Real umin,umax,vmin,vmax; // parameters
TopoDS_Face F = BRepBuilderAPI_MakeFace(S,umin,umax,vmin,vmax);
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image025.png,"Basic Face Construction",360}
To make a face from the natural boundary of a surface, the parameters are not required:
-~~~~~
+~~~~{.cpp}
Handle(Geom_Surface) S = ...; // a surface
TopoDS_Face F = BRepBuilderAPI_MakeFace(S);
-~~~~~
+~~~~
Constraints on the parameters are similar to the constraints in *BRepBuilderAPI_MakeEdge*.
* *umin,umax (vmin,vmax)* must be in the range of the surface and must be increasing.
Once a face has been created, a wire can be added using the *Add* method. For example, the following code creates a cylindrical surface and adds a wire.
-~~~~~
+~~~~{.cpp}
gp_Cylinder C = ..; // a cylinder
TopoDS_Wire W = ...;// a wire
BRepBuilderAPI_MakeFace MF(C);
MF.Add(W);
TopoDS_Face F = MF;
-~~~~~
+~~~~
More than one wire can be added to a face, provided that they do not cross each other and they define only one area on the surface. (Note that this is not checked).
For one wire, a simple syntax is provided to construct the face from the surface and the wire. The above lines could be written:
-~~~~~
+~~~~{.cpp}
TopoDS_Face F = BRepBuilderAPI_MakeFace(C,W);
-~~~~~
+~~~~
The edges on a face must have a parametric curve description. If there is no parametric curve for an edge of the wire on the face it is computed by projection, moreover, the calculation is possible only for the planar face.
A planar face can be created from only a wire, provided this wire defines a plane. For example, to create a planar face from a set of points you can use *BRepBuilderAPI_MakePolygon* and *BRepBuilderAPI_MakeFace*.
-~~~~~
+~~~~{.cpp}
#include <TopoDS_Face.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <BRepBuilderAPI_MakePolygon.hxx>
TopoDS_Face F = BRepBuilderAPI_MakeFace(MP.Wire());
return F;
}
-~~~~~
+~~~~
The last use of *MakeFace* is to copy an existing face to add new wires. For example, the following code adds a new wire to a face:
-~~~~~
+~~~~{.cpp}
TopoDS_Face F = ...; // a face
TopoDS_Wire W = ...; // a wire
F = BRepBuilderAPI_MakeFace(F,W);
-~~~~~
+~~~~
To add more than one wire an instance of the *BRepBuilderAPI_MakeFace* class can be created with the face and the first wire and the new wires inserted with the *Add* method.
Up to four edges can be used directly, for example:
-~~~~~
+~~~~{.cpp}
TopoDS_Wire W = BRepBuilderAPI_MakeWire(E1,E2,E3,E4);
-~~~~~
+~~~~
For a higher or unknown number of edges the Add method must be used; for example, to build a wire from an array of shapes (to be edges).
-~~~~~
+~~~~{.cpp}
TopTools_Array1OfShapes theEdges;
BRepBuilderAPI_MakeWire MW;
for (Standard_Integer i = theEdge.Lower();
i <= theEdges.Upper(); i++)
MW.Add(TopoDS::Edge(theEdges(i));
TopoDS_Wire W = MW;
-~~~~~
+~~~~
The class can be constructed with a wire. A wire can also be added. In this case, all the edges of the wires are added. For example to merge two wires:
-~~~~~
+~~~~{.cpp}
#include <TopoDS_Wire.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
MW.Add(W2);
return MW;
}
-~~~~~
+~~~~
*BRepBuilderAPI_MakeWire* class connects the edges to the wire. When a new edge is added if one of its vertices is shared with the wire it is considered as connected to the wire. If there is no shared vertex, the algorithm searches for a vertex of the edge and a vertex of the wire, which are at the same location (the tolerances of the vertices are used to test if they have the same location). If such a pair of vertices is found, the edge is copied with the vertex of the wire in place of the original vertex. All the vertices of the edge can be exchanged for vertices from the wire. If no connection is found the wire is considered to be disconnected. This is an error.
* From a system of axes *gp_Ax2* and three dimensions. Same as the first way but the box is parallel to the given system of axes.
An error is raised if the box is flat in any dimension using the default precision. The following code shows how to create a box:
-~~~~~
+~~~~{.cpp}
TopoDS_Solid theBox = BRepPrimAPI_MakeBox(10.,20.,30.);
-~~~~~
+~~~~
The four methods to build a box are shown in the figure:
The following code builds the cylindrical face of the figure, which is a quarter of cylinder along the *Y* axis with the origin at *X,Y,Z* the length of *DY* and radius *R*.
-~~~~~
+~~~~{.cpp}
Standard_Real X = 20, Y = 10, Z = 15, R = 10, DY = 30;
// Make the system of coordinates
axes.Translate(gp_Vec(X,Y,Z));
TopoDS_Face F =
BRepPrimAPI_MakeCylinder(axes,R,DY,PI/2.);
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image029.png,"Cylinder",360}
@subsubsection occt_modalg_4_1_5 Cone
The following code builds the solid cone of the figure, which is located in the default system with radii *R1* and *R2* and height *H*.
-~~~~~
+~~~~{.cpp}
Standard_Real R1 = 30, R2 = 10, H = 15;
TopoDS_Solid S = BRepPrimAPI_MakeCone(R1,R2,H);
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image030.png,"Cone",360}
The following code builds four spheres from a radius and three angles.
-~~~~~
+~~~~{.cpp}
Standard_Real R = 30, ang =
PI/2, a1 = -PI/2.3, a2 = PI/4;
TopoDS_Solid S1 = BRepPrimAPI_MakeSphere(R);
TopoDS_Solid S2 = BRepPrimAPI_MakeSphere(R,ang);
TopoDS_Solid S3 = BRepPrimAPI_MakeSphere(R,a1,a2);
TopoDS_Solid S4 = BRepPrimAPI_MakeSphere(R,a1,a2,ang);
-~~~~~
+~~~~
Note that we could equally well choose to create Shells instead of Solids.
The following code builds four toroidal shells from two radii and three angles.
-~~~~~
+~~~~{.cpp}
Standard_Real R1 = 30, R2 = 10, ang = PI, a1 = 0,
a2 = PI/2;
TopoDS_Shell S1 = BRepPrimAPI_MakeTorus(R1,R2);
TopoDS_Shell S3 = BRepPrimAPI_MakeTorus(R1,R2,a1,a2);
TopoDS_Shell S4 =
BRepPrimAPI_MakeTorus(R1,R2,a1,a2,ang);
-~~~~~
+~~~~
Note that we could equally well choose to create Solids instead of Shells.
The following code creates a finite, an infinite and a semi-infinite solid using a face, a direction and a length.
-~~~~~
+~~~~{.cpp}
TopoDS_Face F = ..; // The swept face
gp_Dir direc(0,0,1);
Standard_Real l = 10;
// infinite
TopoDS_Solid P3 = BRepPrimAPI_MakePrism(F,direc,Standard_False);
// semi-infinite
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image034.png,"Finite, infinite, and semi-infinite prisms",420}
*BRepPrimAPI_MakeRevol* constructors have a last argument to copy or share the original shape.
The following code creates a full and a partial rotation using a face, an axis and an angle.
-~~~~~
+~~~~{.cpp}
TopoDS_Face F = ...; // the profile
gp_Ax1 axis(gp_Pnt(0,0,0),gp_Dir(0,0,1));
Standard_Real ang = PI/3;
TopoDS_Solid R1 = BRepPrimAPI_MakeRevol(F,axis);
// Full revol
TopoDS_Solid R2 = BRepPrimAPI_MakeRevol(F,axis,ang);
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image035.png,"Full and partial rotation",420}
*BRepAlgoAPI_Fuse* performs the Fuse operation.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape A = ..., B = ...;
TopoDS_Shape S = BRepAlgoAPI_Fuse(A,B);
-~~~~~
+~~~~
#### Common
*BRepAlgoAPI_Common* performs the Common operation.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape A = ..., B = ...;
TopoDS_Shape S = BRepAlgoAPI_Common(A,B);
-~~~~~
+~~~~
#### Cut
*BRepAlgoAPI_Cut* performs the Cut operation.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape A = ..., B = ...;
TopoDS_Shape S = BRepAlgoAPI_Cut(A,B);
-~~~~~
+~~~~
#### Section
@figure{/user_guides/modeling_algos/images/modeling_algos_image037.png,"Section operation",220}
-~~~~~
+~~~~{.cpp}
TopoDS_Shape A = ..., TopoDS_ShapeB = ...;
TopoDS_Shape S = BRepAlgoAPI_Section(A,B);
-~~~~~
+~~~~
To make the faces from edges it is, firstly, necessary to create planar wires from the given edges and than create planar faces from each wire.
The static methods *BOPAlgo_Tools::EdgesToWires* and *BOPAlgo_Tools::WiresToFaces* can be used for that:
-~~~~~
+~~~~{.cpp}
TopoDS_Shape anEdges = ...; /* The input edges */
Standard_Real anAngTol = 1.e-8; /* The angular tolerance for distinguishing the planes in which the wires are located */
Standard_Boolean bShared = Standard_False; /* Defines whether the edges are shared or not */
cout << "Error: Unable to build faces from wires\n";
return;
}
-~~~~~
+~~~~
These methods can also be used separately:
* *BOPAlgo_Tools::EdgesToWires* allows creating planar wires from edges.
Let us use the class *BRepBuilderAPI_MakeEdge* to create a linear edge from two points.
-~~~~~
+~~~~{.cpp}
gp_Pnt P1(10,0,0), P2(20,0,0);
TopoDS_Edge E = BRepBuilderAPI_MakeEdge(P1,P2);
-~~~~~
+~~~~
This is the simplest way to create edge E from two points P1, P2, but the developer can test for errors when he is not as confident of the data as in the previous example.
-~~~~~
+~~~~{.cpp}
#include <gp_Pnt.hxx>
#include <TopoDS_Edge.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
}
TopoDS_Edge E = ME;
}
-~~~~~
+~~~~
In this example an intermediary object ME has been introduced. This can be tested for the completion of the function before accessing the result. More information on **error handling** in the topology programming interface can be found in the next section.
*BRepBuilderAPI_MakeEdge* provides valuable information. For example, when creating an edge from two points, two vertices have to be created from the points. Sometimes you may be interested in getting these vertices quickly without exploring the new edge. Such information can be provided when using a class. The following example shows a function creating an edge and two vertices from two points.
-~~~~~
+~~~~{.cpp}
void MakeEdgeAndVertices(const gp_Pnt& P1,
const gp_Pnt& P2,
TopoDS_Edge& E,
E = ME;
V1 = ME.Vextex1();
V2 = ME.Vertex2();
-~~~~~
+~~~~
The class *BRepBuilderAPI_MakeEdge* provides two methods *Vertex1* and *Vertex2*, which return two vertices used to create the edge.
How can *BRepBuilderAPI_MakeEdge* be both a function and a class? It can do this because it uses the casting capabilities of C++. The *BRepBuilderAPI_MakeEdge* class has a method called Edge; in the previous example the line <i>E = ME</i> could have been written.
-~~~~~
+~~~~{.cpp}
E = ME.Edge();
-~~~~~
+~~~~
This instruction tells the C++ compiler that there is an **implicit casting** of a *BRepBuilderAPI_MakeEdge* into a *TopoDS_Edge* using the *Edge* method. It means this method is automatically called when a *BRepBuilderAPI_MakeEdge* is found where a *TopoDS_Edge* is required.
*BRepTools_History* is the general History tool intended for unification of the histories of different algorithms.
*BRepTools_History* can be created from any algorithm supporting the standard history methods *(IsDeleted(), Modified()* and *Generated())*:
-~~~~
+~~~~{.cpp}
// The arguments of the operation
TopoDS_Shape aS = ...;
*BRepTools_History* also allows merging histories. Thus, if you have two or more subsequent operations you can get one final history combined from histories of these operations:
-~~~~
+~~~~{.cpp}
Handle(BRepTools_History) aHist1 = ...; // History of first operation
Handle(BRepTools_History) aHist2 = ...; // History of second operation
~~~~
It is possible to merge the second history into the first one:
-~~~~
+~~~~{.cpp}
aHist1->Merge(aHist2);
~~~~
Or create the new history keeping the two histories unmodified:
-~~~~
+~~~~{.cpp}
Handle(BRepTools_History) aResHistory = new BRepTools_History;
aResHistory->Merge(aHist1);
aResHistory->Merge(aHist2);
### Constant radius
-~~~~~
+~~~~{.cpp}
#include <TopoDS_Shape.hxx>
#include <TopoDS.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
}
return MF.Shape();
}
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image039.png,"Fillet with constant radius",360}
#### Changing radius
-~~~~~
+~~~~{.cpp}
void CSampleTopologicalOperationsDoc::OnEvolvedblend1()
{
TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,200,200);
Rake.Add(ParAndRad, TopoDS::Edge(ex.Current()));
TopoDS_Shape evolvedBox = Rake.Shape();
}
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image040.png,"Fillet with changing radius",360}
* The surfaces created are ruled and not smooth.
* The *Add* syntax for selecting edges requires one or two distances, one edge and one face (contiguous to the edge).
-~~~~~
+~~~~{.cpp}
Add(dist, E, F)
Add(d1, d2, E, F) with d1 on the face F.
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image041.png,"Chamfer",360}
* one edge, one vertex, one distance and one angle.
Fillets and chamfers are calculated when addition is complete.
-If face F2 is created by 2D fillet and chamfer builder from face F1, the builder can be rebuilt (the builder recovers the status it had before deletion). To do so, use the following syntax:
-~~~~~
+If face F2 is created by 2D fillet and chamfer builder from face F1, the builder can be rebuilt (the builder recovers the status it had before deletion). To do so, use the following Syntax:
+~~~~{.cpp}
BRepFilletAPI_MakeFillet2d builder;
builder.Init(F1,F2);
-~~~~~
+~~~~
Planar Fillet
-------------
-~~~~~
+~~~~{.cpp}
#include “BRepPrimAPI_MakeBox.hxx”
#include “TopoDS_Shape.hxx”
#include “TopExp_Explorer.hxx”
// while...
return MF.Shape();
}
-~~~~~
+~~~~
@subsection occt_modalg_7 Offsets, Drafts, Pipes and Evolved shapes
The possible drawback of the simple algorithm is that it leads, in general case, to tolerance increasing. The tolerances have to grow in order to cover the gaps between the neighbor faces in the output. It should be noted that the actual tolerance growth depends on the offset distance and the quality of joints between the input faces. Anyway the good input shell (smooth connections between adjacent faces) will lead to good result.
The snippets below show usage examples:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepOffsetAPI_MakeOffsetShape OffsetMaker1;
// Computes offset shape using analytical continuation mechanism.
OffsetMaker1.PerformByJoin(Shape, OffsetValue, Tolerance);
OffsetMaker2.PerformBySimple(Shape, OffsetValue);
if (OffsetMaker2.IsDone())
NewShape = OffsetMaker2.Shape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_modalg_7_2 Shelling
Shelling is used to offset given faces of a solid by a specific value. It rounds or intersects adjacent faces along its edges depending on the convexity of the edge.
The MakeThickSolidByJoin method of the *BRepOffsetAPI_MakeThickSolid* takes the solid, the list of faces to remove and an offset value as input.
-~~~~~
+~~~~{.cpp}
TopoDS_Solid SolidInitial = ...;
Standard_Real Of = ...;
Tol);
if (SolidMaker.IsDone())
Result = SolidMaker.Shape();
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image042.png,"Shelling",420}
Also it is possible to create solid between shell, offset shell. This functionality can be called using *BRepOffsetAPI_MakeThickSolid::MakeThickSolidBySimple* method. The code below shows usage example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
BRepOffsetAPI_MakeThickSolid SolidMaker;
SolidMaker.MakeThickSolidBySimple(Shell, OffsetValue);
if (myDone.IsDone())
Solid = SolidMaker.Shape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_modalg_7_3 Draft Angle
The following code places a draft angle on several faces of a shape; the same direction, angle and neutral plane are used for each face:
-~~~~~
+~~~~{.cpp}
TopoDS_Shape myShape = ...
// The original shape
TopTools_ListOfShape ListOfFace;
TopoDS_Shape myResult = theDraft.Shape();
...
}
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image043.png,"DraftAngle",420}
The angle between the spine and the profile is preserved throughout the pipe.
-~~~~~
+~~~~{.cpp}
TopoDS_Wire Spine = ...;
TopoDS_Shape Profile = ...;
TopoDS_Shape Pipe = BRepOffsetAPI_MakePipe(Spine,Profile);
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image044.png,"Example of a Pipe",320}
+ the X axis is given by the tangent to the spine at the point defined above
+ the Z axis is the normal to the plane which contains the spine.
-~~~~~
+~~~~{.cpp}
TopoDS_Face Spine = ...;
TopoDS_Wire Profile = ...;
TopoDS_Shape Evol =
BRepOffsetAPI_MakeEvolved(Spine,Profile);
-~~~~~
+~~~~
@subsection occt_modalg_3b Object Modification
The following example deals with the rotation of shapes.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape myShape1 = ...;
// The original shape 1
theTrsf.Perform(myShape2,Standard_True);
// Here duplication is forced
TopoDS_Shape myNewShape2 = theTrsf.Shape()
-~~~~~
+~~~~
@subsubsection occt_modalg_3b_2 Duplication
Use the *BRepBuilderAPI_Copy* class to duplicate a shape. A new shape is thus created.
In the following example, a solid is copied:
-~~~~~
+~~~~{.cpp}
TopoDS Solid MySolid;
....// Creates a solid
TopoDS_Solid myCopy = BRepBuilderAPI_Copy(mySolid);
-~~~~~
+~~~~
@subsection occt_modalg_3a_1 Error Handling in the Topology API
Consequently, you might be tempted to adopt the highly inadvisable style of programming illustrated in the following example:
-~~~~~
+~~~~{.cpp}
#include <Standard_ErrorHandler.hxx>
try {
TopoDS_Edge E = BRepBuilderAPI_MakeEdge(P1,P2);
catch {
// process the error.
}
-~~~~~
+~~~~
To help the user, the Topology API classes only raise the exception *StdFail_NotDone*. Any other exception means that something happened which was unforeseen in the design of this API.
The *NotDone* exception is only raised when the user tries to access the result of the computation and the original data is corrupted. At the construction of the class instance, if the algorithm cannot be completed, the internal flag *NotDone* is set. This flag can be tested and in some situations a more complete description of the error can be queried. If the user ignores the *NotDone* status and tries to access the result, an exception is raised.
-~~~~~
+~~~~{.cpp}
BRepBuilderAPI_MakeEdge ME(P1,P2);
if (!ME.IsDone()) {
// doing ME.Edge() or E = ME here
(“ProcessPoints::Failed to create an edge”);
}
TopoDS_Edge E = ME;
-~~~~~
+~~~~
@subsection occt_modalg_8 Sewing
To connect a set of *n* contiguous but independent faces, do the following:
-~~~~~
+~~~~{.cpp}
BRepBuilderAPI_Sewing Sew;
Sew.Add(Face1);
Sew.Add(Face2);
Sew.Add(Facen);
Sew.Perform();
TopoDS_Shape result= Sew.SewedShape();
-~~~~~
+~~~~
If all faces have been sewn correctly, the result is a shell. Otherwise, it is a compound. After a successful sewing operation all faces have a coherent orientation.
See the example:
-~~~~
+~~~~{.cpp}
//initial sewn shapes
TopoDS_Shape aS1, aS2; // these shapes are expected to be well sewn shells
In the following sequence, a protrusion is performed, i.e. a face of the shape is changed into a prism.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape Sbase = ...; // an initial shape
TopoDS_Face Fbase = ....; // a base of prism
TopoDS_Shape theResult = thePrism;
...
}
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image047.png,"Fusion with MakePrism",320}
The *Perform* methods are the same as for *MakePrism*.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);
TopExp_Explorer Ex;
Ex.Init(S,TopAbs_FACE);
Standard_True);
MKDP.Perform(200);
TopoDS_Shape res1 = MKDP.Shape();
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image049.png,"A tapered prism",320}
In the following sequence, a face is revolved and the revolution is limited by a face of the base shape.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape Sbase = ...; // an initial shape
TopoDS_Face Frevol = ....; // a base of prism
TopoDS_Face FUntil = ....; // face limiting the revol
TopoDS_Shape theResult = theRevol;
...
}
-~~~~~
+~~~~
**Pipe**
Let us have a look at the example:
-~~~~~
+~~~~{.cpp}
TopoDS_Shape S = BRepPrimAPI_MakeBox(400.,250.,300.);
TopExp_Explorer Ex;
Ex.Init(S,TopAbs_FACE);
Standard_True);
MKPipe.Perform();
TopoDS_Shape res1 = MKPipe.Shape();
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image050.png,"Pipe depression",240}
Linear form is implemented in *MakeLinearForm* class, which creates a rib or a groove along a planar surface. There is one *Perform()* method, which performs a prism from the wire along the *direction1* and *direction2* interacting with base shape *Sbase*. The height of the prism is *Magnitude(Direction1)+Magnitude(direction2)*.
-~~~~~
+~~~~{.cpp}
BRepBuilderAPI_MakeWire mkw;
gp_Pnt p1 = gp_Pnt(0.,0.,0.);
gp_Pnt p2 = gp_Pnt(200.,0.,0.);
(0.,5.,0.), gp_Dir(0.,-3.,0.), 1, Standard_True);
aform.Perform();
TopoDS_Shape res = aform.Shape();
-~~~~~
+~~~~
@figure{/user_guides/modeling_algos/images/modeling_algos_image051.png,"Creating a rib",240}
**Note** that every face and edge has to be bounded, if two edges of two glued faces are coincident they must be explicitly bounded.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape Sbase = ...; // the basic shape
TopoDS_Shape Sglued = ...; // the glued shape
TopoDS_Shape theResult = theGlue;
...
}
-~~~~~
+~~~~
@subsubsection occt_modalg_9_2_4 Split Shape
**Note** The added wires and edges must define closed wires on faces or wires located between two existing edges. Existing edges must not be intersected.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape Sbase = ...; // basic shape
TopoDS_Face Fsplit = ...; // face of Sbase
TopoDS_Wire Wsplit = ...; // new wire contained in Fsplit
Spls.Add(Wsplit, Fsplit);
TopoDS_Shape theResult = Spls;
...
-~~~~~
+~~~~
@subsection occt_modalg_defeaturing 3D Model Defeaturing
@subsubsection occt_modalg_defeaturing_usage Usage
Here is the example of usage of the *BRepAlgoAPI_Defeaturing* algorithm on the C++ level:
-~~~~
+~~~~{.cpp}
TopoDS_Shape aSolid = ...; // Input shape to remove the features from
TopTools_ListOfShape aFeatures = ...; // Features to remove from the shape
Standard_Boolean bRunParallel = ...; // Parallel processing mode
~~~~
Use the API history methods to track the history of a shape:
-~~~~
+~~~~{.cpp}
// Obtain modification of the shape
const TopTools_ListOfShape& BRepAlgoAPI_Defeaturing::Modified(const TopoDS_Shape& theS);
For better understanding of what periodicity means lets create a simple prism and make it periodic.
The following draw script creates the L-shape prism with extensions 10x5x10:
-~~~~
+~~~~{.cpp}
polyline p 0 0 0 0 0 10 5 0 10 5 0 5 10 0 5 10 0 0 0 0 0
mkplane f p
prism s f 0 5 0
The algorithm is implemented in the class *BOPAlgo_MakePeriodic*.
Here is the example of its usage on the API level:
-~~~~
+~~~~{.cpp}
TopoDS_Shape aShape = ...; // The shape to make periodic
Standard_Boolean bMakeXPeriodic = ...; // Flag for making or not the shape periodic in X direction
Standard_Real aXPeriod = ...; // X period for the shape
The other options of the base class are not supported here and will have no effect.
All the history information obtained during the operation is stored into *BRepTools_History* object and available through *History()* method:
-~~~~
+~~~~{.cpp}
// Get the history object
const Handle(BRepTools_History)& BOPAlgo_MakePeriodic::History();
~~~~
Imagine that you need to make the drills in the plate on the same distance from each other. To model this process it is necessary to make a lot of cylinders (simulating the drills) and cut these cylinders from the plate.
With the periodicity tool, the process looks very simple:
-~~~~
+~~~~{.cpp}
# create plate 100 x 100
box plate -50 -50 0 100 100 1
# create a single drill with radius 1
### HLRBRep_Algo
-~~~~~
+~~~~{.cpp}
// Build The algorithm object
myAlgo = new HLRBRep_Algo();
aHLRToShape.OutLineHCompound();
TopoDS_Shape IsoLineHCompound =
aHLRToShape.IsoLineHCompound();
-~~~~~
+~~~~
### HLRBRep_PolyAlgo
-~~~~~
+~~~~{.cpp}
// Build The algorithm object
myPolyAlgo = new HLRBRep_PolyAlgo();
aPolyHLRToShape.RgNLineHCompound();
TopoDS_Shape OutLineHCompound =
aPolyHLRToShape.OutLineHCompound();
-~~~~~
+~~~~
* *MaterialsOnPositiveSide()* - returns the original shapes (materials) located on the positive side of the given shape (i.e. with FORWARD orientation);
* *MaterialsOnNegativeSide()* - returns the original shapes (materials) located on the negative side of the given shape (i.e. with REVERSED orientation);
-~~~~
+~~~~{.cpp}
// Returns the original shapes which images contain the given shape with FORWARD orientation.
const TopTools_ListOfShape& BOPAlgo_MakeConnected::MaterialsOnPositiveSide(const TopoDS_Shape& theS)
The algorithm supports history of shapes modifications during the operation. Additionally to standard history method provided by *BRepTools_History* and used here as a history tool, the algorithm also provides the method to track the back connection - from resulting shapes to the input ones.
The method is called *GetOrigins()*:
-~~~~
+~~~~{.cpp}
// Returns the list of original shapes from which the current shape has been created.
const TopTools_ListOfShape& BOPAlgo_MakeConnected::GetOrigins(const TopoDS_Shape& theS);
~~~~
@subsection occt_modalg_makeconnected_usage Usage
Here is the example of usage of the *BOPAlgo_MakePeriodic* algorithm on the API level:
-~~~~
+~~~~{.cpp}
TopTools_ListOfShape anArguments = ...; // Shapes to make connected
Standard_Boolean bRunParallel = ...; // Parallel processing mode
The other options of the base class are not supported here and will have no effect.
All the history information obtained during the operation is stored into *BRepTools_History* object and available through *History()* method:
-~~~~
+~~~~{.cpp}
// Get the history object
const Handle(BRepTools_History)& BOPAlgo_MakeConnected::History();
~~~~
@figure{/user_guides/modeling_data/images/modeling_data_image003.png,"Approximation of a BSpline from scattered points",420}
This class may be instantiated as follows:
-~~~~~
+~~~~{.cpp}
GeomAPI_Interpolate Interp(Points);
-~~~~~
+~~~~
From this object, the BSpline curve may be requested as follows:
-~~~~~
+~~~~{.cpp}
Handle(Geom_BSplineCurve) C = Interp.Curve();
-~~~~~
+~~~~
#### 2D Approximation
The resulting BSpline curve will be C2 or second degree continuous, except where a tangency constraint is defined on a point, through which the curve passes. In this case, it will be only C1 continuous. This class is instantiated as follows:
-~~~~~
+~~~~{.cpp}
GeomAPI_PointsToBSpline
Approx(Points,DegMin,DegMax,Continuity, Tol);
-~~~~~
+~~~~
From this object, the BSpline curve may be requested as follows:
-~~~~~
+~~~~{.cpp}
Handle(Geom_BSplineCurve) K = Approx.Curve();
-~~~~~
+~~~~
#### Surface Approximation
If it was unsuccessful, the status gives the reason for the failure.
-~~~~
+~~~~{.cpp}
gp_Pnt P1 (0.,0.,0.);
gp_Pnt P2 (0.,10.,0.);
gp_Pnt P3 (10.,0.,0.);
It is possible to create a point using a *gce* package class, then question it to recover the corresponding *gp* object.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Pnt2d Point1,Point2;
...
//Initialization of Point1 and Point2
if (L.Status() == gce_Done() ){
gp_Lin2d l = L.Value();
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
This is useful if you are uncertain as to whether the arguments can create the *gp* object without raising an exception. In the case above, if *Point1* and *Point2* are closer than the tolerance value required by *MakeLin2d*, the function *Status* will return the enumeration *gce_ConfusedPoint*. This tells you why the *gp* object cannot be created. If you know that the points *Point1* and *Point2* are separated by the value exceeding the tolerance value, then you may create the *gp* object directly, as follows:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
gp_Lin2d l = gce_MakeLin2d(Point1,Point2);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_modat_1_2_2 Geometric entities manipulated by handle
Let us take an adapted curve **C**, i.e. an object which is an interface between the services provided by either a 2D curve from the package Geom2d (in case of an Adaptor_Curve2d curve) or a 3D curve from the package Geom (in case of an Adaptor_Curve curve), and the services required on the curve by the computation algorithm. The adapted curve is created in the following way:
**2D case :**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(Geom2d_Curve) mycurve = ... ;
Geom2dAdaptor_Curve C (mycurve) ;
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
**3D case :**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(Geom_Curve) mycurve = ... ;
GeomAdaptor_Curve C (mycurve) ;
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The algorithm is then constructed with this object:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
GCPnts_UniformDeflection myAlgo () ;
Standard_Real Deflection = ... ;
myAlgo.Initialize ( C , Deflection ) ;
...
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_modat_1_5 Extrema
The following example shows a routine receiving an argument of the *TopoDS_Shape* type, then putting it into a variable V if it is a vertex or calling the method ProcessEdge if it is an edge.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
// OK for compiler but an exception will be raised at run-time
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The Explorer visits the whole structure in order to find the shapes of the requested type not contained in the type to avoid. The example below shows how to find all faces in the shape *S*:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
void test() {
TopoDS_Shape S;
TopExp_Explorer Ex;
ProcessFace(Ex.Current());
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Find all the vertices which are not in an edge
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
for (Ex.Init(S,TopAbs_VERTEX,TopAbs_EDGE); ...)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Find all the faces in a SHELL, then all the faces not in a SHELL:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
void test() {
TopExp_Explorer Ex1, Ex2;
TopoDS_Shape S;
ProcessFace(Ex1.Current());
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The Explorer presumes that objects contain only objects of an equal or inferior type. For example, if searching for faces it does not look at wires, edges, or vertices to see if they contain faces.
The *MapShapes* method from *TopExp* package allows filling a Map. An exploration using the Explorer class can visit an object more than once if it is referenced more than once. For example, an edge of a solid is generally referenced by two faces. To process objects only once, they have to be placed in a Map.
**Example**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
void TopExp::MapShapes (const TopoDS_Shape& S,
const TopAbs_ShapeEnum T,
TopTools_IndexedMapOfShape& M)
Ex.Next();
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
In the following example all faces and all edges of an object are drawn in accordance with the following rules:
- The faces are represented by a network of *NbIso* iso-parametric lines with *FaceIsoColor* color.
3. Exploring the edges and for each of them increment the counter of faces in the array.
4. From the Map of edges, drawing each edge with the color corresponding to the number of faces.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
void DrawShape ( const TopoDS_Shape& aShape,
const Standard_Integer nbIsos,
const Color FaceIsocolor,
}
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_modat_5_5 Lists and Maps of Shapes
The following example counts the size of a data structure as a number of *TShapes*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
#include <TopoDS_Iterator.hxx>
Standard_Integer Size(const TopoDS_Shape& aShape)
{
}
return size;
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
This program is incorrect if there is sharing in the data structure.
Thus for a contour of four edges it should count 1 wire + 4 edges +4 vertices with the result 9, but as the vertices are each shared by two edges this program will return 13. One solution is to put all the Shapes in a Map so as to avoid counting them twice, as in the following example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
#include <TopoDS_Iterator.hxx>
#include <TopTools_MapOfShape.hxx>
MapShapes(aShape,M);
return M.Extent();
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
**Note** For more details about Maps, refer to the *TCollection* documentation (Foundation Classes Reference Manual).
- A table of Shapes is created in parallel with the map to receive the copies.
- The structure is copied using the auxiliary recursive function,which copies from the map to the array.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
#include <TopoDS_Shape.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
}
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
In the above example, the index *i* is that of the first object not treated in the Map. When *i* reaches the same size as the Map this means that everything has been treated. The treatment consists in inserting in the Map all the sub-objects, if they are not yet in the Map, they are inserted with an index greater than *i*.
**Note** that the objects are inserted with a local reference set to the identity and a FORWARD orientation. Only the underlying TShape is of great interest.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
//Create an array to store the copies.
TopTools_Array1OfShapetheCopies(1,theMap.Extent());
S.Location(aShape.Location());
S.Orientation(aShape.Orientation());
return S;
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Below is the auxiliary function, which copies the element of rank *i* from the map to the table. This method checks if the object has been copied; if not copied, then an empty copy is performed into the table and the copies of all the sub-elements are inserted by finding their rank in the map.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
void AuxiliaryCopy(Standard_Integer index,
const TopTools_IndexedMapOfShapes& sources,
TopTools_Array1OfShape& copies,
}
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
**Wire Explorer**
*TopExp_Explorer*, however, recuperates the lines in any order.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Wire W = ...;
BRepTools_WireExplorer Ex;
for(Ex.Init(W); Ex.More(); Ex.Next()) {
ProcessTheVertexConnectingTheCurrentEdgeToThePrevious
One(Ex.CurrentVertex());
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section occt_modat_4 Properties of Shapes
To append and return a new child label, you use *TDF_TagSource::NewChild*. In the example below, the argument *level2*, which is passed to *NewChild,* is a *TDF_Label*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~{.cpp}
TDF_Label child1 = TDF_TagSource::NewChild (level2);
TDF_Label child2 = TDF_TagSource::NewChild (level2);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_3_3_2 Creation of a child label by user delivery from a tag
To retrieve a child label from a tag which you have specified yourself, you need to use *TDF_Label::FindChild* and *TDF_Label::Tag* as in the example below. Here, the integer 3 designates the tag of the label you are interested in, and the Boolean false is the value for the argument *create*. When this argument is set to *false*, no new child label is created.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~{.cpp}
TDF_Label achild = root.FindChild(3,Standard_False);
if (!achild.IsNull()) {
Standard_Integer tag = achild.Tag();
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_ocaf_3_4 Label
To create a new child label in the data framework using explicit delivery of tags, use *TDF_Label::FindChild*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
//creating a label with tag 10 at Root
TDF_Label lab1 = aDF->Root().FindChild(10);
TDF_Label lab2 = lab1.FindChild(7);
TDF_Label lab3 = lab1.FindChild(2);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
You could also use the same syntax but add the Boolean *true* as a value of the argument **create**. This ensures that a new child label will be created if none is found. Note that in the previous syntax, this was also the case since **create** is *true* by default.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TDF_Label level1 = root.FindChild(3,Standard_True);
TDF_Label level2 = level1.FindChild(1,Standard_True);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_3_4_3 Retrieving child labels
You can retrieve child labels of your current label by iteration on the first level in the scope of this label.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TDF_Label current;
//
for (TDF_ChildIterator it1 (current,Standard_False); it1.More(); it1.Next()) {
// do something on a child (level 1)
//
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
You can also retrieve all child labels in every descendant generation of your current label by iteration on all levels in the scope of this label.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
for (TDF_ChildIterator itall (current,Standard_True); itall.More(); itall.Next()) {
achild = itall.Value();
//
// do something on a child (all levels)
//
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Using *TDF_Tool::Entry* with *TDF_ChildIterator* you can retrieve the entries of your current label’s child labels as well.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
void DumpChildren(const TDF_Label& aLabel)
{
TDF_ChildIterator it;
cout << as.ToCString() << endl;
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_3_4_4 Retrieving the father label
Retrieving the father label of a current label.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TDF_Label father = achild.Father();
isroot = father.IsRoot();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_ocaf_3_5 Attribute
To retrieve an attribute from a label, you use *TDF_Label::FindAttribute*. In the example below, the GUID for integer attributes, and *INT*, a handle to an attribute are passed as arguments to *FindAttribute* for the current label.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
if(current.FindAttribute(TDataStd_Integer::GetID(),INT))
{
// the attribute is found
{
// the attribute is not found
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_3_5_2 Identifying an attribute using a GUID
You can create a new instance of an attribute and retrieve its GUID. In the example below, a new integer attribute is created, and its GUID is passed to the variable *guid* by the method ID inherited from *TDF_Attribute*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(TDataStd_Integer) INT = new TDataStd_Integer();
Standard_GUID guid = INT->ID();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_3_5_3 Attaching an attribute to a label
*TDF_Attribute::Label* for *INT* then returns the label *attach* to which *INT* is attached.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
current.Add (INT); // INT is now attached to current
current.Add (INT); // causes failure
TDF_Label attach = INT->Label();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Note. There is an exception from this rule for some sub-set of Standard attributes. See for details chapter 6.Standard Attributes.
*TDF_Attribute::HasAttribute* tests whether there is an attached attribute, and *TDF_Tool::NbAttributes* returns the number of attributes attached to the label in question, e.g. *current*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
// Testing of attribute attachment
//
if (current.IsA(TDataStd_Integer::GetID())) {
Standard_Integer nbatt = current.NbAttributes();
// the label has nbatt attributes attached
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_3_5_5 Removing an attribute from a label
To remove an attribute from a label, you use *TDF_Label::Forget* with the GUID of the deleted attribute. To remove all attributes of a label, *TDF_Label::ForgetAll*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
current.Forget(TDataStd_Integer::GetID());
// integer attribute is now not attached to current label
current.ForgetAll();
// current has now 0 attributes attached
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_3_5_6 Specific attribute creation
If the set of existing and ready to use attributes implementing standard data types does not cover the needs of a specific data presentation task, the user can build his own data type and the corresponding new specific attribute implementing this new data type.
To create an application, use the following syntax.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(TDocStd_Application) app = new TDocStd_Application ();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_4_2_2 Creating a new document
To the application which you declared in the previous example (4.2.1), you must add the document *doc* as an argument of *TDocStd_Application::NewDocument*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(TDocStd_Document) doc;
app->NewDocument("NewDocumentFormat", doc);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Here "NewDocumentFormat" is identifier of the format of your document.
OCCT defines several standard formats, distinguishing by a set of supported OCAF attributes, and method of encoding (e.g. binary data or XML), described below.
To retrieve the application containing your document, you use the syntax below.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
app = Handle(TDocStd_Application)::DownCast (doc->Application());
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_ocaf_4_3 The Document
The document contains your data framework, and allows you to retrieve this framework, recover its main label, save it in a file, and open or close this file.
To access the main label in the data framework, you use *TDocStd_Document::Main* as in the example below. The main label is the first child of the root label in the data framework, and has the entry 0:1.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TDF_Label label = doc->Main();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_4_3_2 Retrieving the document from a label in its framework
To retrieve the document from a label in its data framework, you use *TDocStd_Document::Get* as in the example below. The argument *label* passed to this method is an instantiation of *TDF_Label*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
doc = TDocStd_Document::Get(label);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_4_3_format Defining storage format
In order to use OCAF persistence to save and read your documents to / from the file, you need to define one or several formats in your application.
For that, use method TDocStd_Application::DefineFormat(), for instance:
-~~~~~
+~~~~{.cpp}
app->DefineFormat ("NewDocumentFormat", "New format for OCAF documents", "ndf",
new NewDocumentFormat_RetrievalDriver(),
new NewDocumentFormat_StorageDriver());
-~~~~~
+~~~~
This example defines format "NewDocumentFormat" with a default file extension "ndf", and instantiates drivers for reading and storing documents from and to that format.
Either of the drivers can be null, in this case the corresponding action will not be supported for that format.
For convenience, these toolkits provide static methods *DefineFormat()* accepting handle to application.
These methods allow defining corresponding formats easily, e.g.:
-~~~~~
+~~~~{.cpp}
BinDrivers::DefineFormat (app); // define format "BinOcaf"
-~~~~~
+~~~~
Use these toolkits as an example for implementation of persistence drivers for custom attributes, or new persistence formats.
Then create that resource file and define the parameters of your format:
-~~~~~
+~~~~
ndf.FileFormat: NewDocumentFormat
NewDocumentFormat.Description: New Document Format Version 1.0
NewDocumentFormat.FileExtension: ndf
NewDocumentFormat.StoragePlugin: bb5aa176-c65c-4c84-862e-6b7c1fe16921
NewDocumentFormat.RetrievalPlugin: 76fb4c04-ea9a-46aa-88a2-25f6a228d902
-~~~~~
+~~~~
The GUIDs should be unique and correspond to the GUIDs supported by relevant plugin.
You can use an existing plugins (see the table above) or create your own.
Finally, make a copy of the resource file "Plugin" from *$CASROOT/src/StdResource* and, if necessary, add the definition of your plugin in it, for instance:
-~~~~~
+~~~~
bb5aa176-c65c-4c84-862e-6b7c1fe16921.Location: TKNewFormat
76fb4c04-ea9a-46aa-88a2-25f6a228d902.Location: TKNewFormat
-~~~~~
+~~~~
In order to have these resource files loaded during the program execution, it is necessary to set two environment variables: *CSF_PluginDefaults* and *CSF_NewFormatDefaults*.
For example, set the files in the directory *MyApplicationPath/MyResources*:
-~~~~~
+~~~~
setenv CSF_PluginDefaults MyApplicationPath/MyResources
setenv CSF_NewFormatDefaults MyApplicationPath/MyResources
-~~~~~
+~~~~
@subsubsection occt_ocaf_4_3_3 Saving a document
To save the document, make sure that its parameter *StorageFormat()* corresponds to one of the formats defined in the application, and use method *TDocStd_Application::SaveAs*, for instance:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
app->SaveAs(doc, "/tmp/example.caf");
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_4_3_4 Opening the document from a file
To open the document from a file where it has been previously saved, you can use *TDocStd_Application::Open* as in the example below. The arguments are the path of the file and the document saved in this file.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~
app->Open("/tmp/example.caf", doc);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsubsection occt_ocaf_4_3_5 Cutting, copying and pasting inside a document
* The data container (e.g. <i> Lab_source</i>)
* The destination of the copy (e.g. <i> Lab_ Target</i> )
-~~~~
+~~~~{.cpp}
Copy = copy (Lab_Source => Lab_Clipboard)
Cut = copy + Lab_Source.ForgetAll() // command clear the contents of LabelSource.
Paste = copy (Lab_Clipboard => Lab_target)
So we need a tool to copy all (or a part) of the content of a label and its sub-label,
to another place defined by a label.
-~~~~
+~~~~{.cpp}
TDF_CopyLabel aCopy;
TDF_IDFilter aFilter (Standard_False);
To copy a document with a possibility of updating it later, you use *TDocStd_XLinkTool::CopyWithLink*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(TDocStd_Document) doc1;
Handle(TDocStd_Document) doc2;
TDocStd_XLinkTool XLinkTool;
XLinkTool.CopyWithLink(target,source);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
Now the target document has a copy of the source document. The copy also has a link in order to update the content of the copy if the original changes.
In the example below, something has changed in the source document. As a result, you need to update the copy in the target document. This copy is passed to *TDocStd_XLinkTool::UpdateLink* as the argument *target*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
XLinkTool.UpdateLink(target);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
#### Without any link between the copy and the original
You can also create a copy of the document with no link between the original and the copy. The syntax to use this option is *TDocStd_XLinkTool::Copy*. The copied document is again represented by the argument *target*, and the original -- by *source.*
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
XLinkTool.Copy(target, source);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section occt_ocaf_5 OCAF Shape Attributes
The class *TNaming_Builder* allows creating a named shape attribute. It has a label of a future attribute as an argument of the constructor. Respective methods are used for the evolution and setting of shape pairs. If for the same TNaming_Builder object a lot of pairs of shapes with the same evolution are given, then these pairs would be placed in the resulting named shape. After the creation of a new object of the TNaming_Builder class, an empty named shape is created at the given label.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
// a new empty named shape is created at "label"
TNaming_Builder builder(label);
// set a pair of shapes with evolution GENERATED
builder.Generated(oldshape2,newshape2);
// get the result - TNaming_NamedShape attribute
Handle(TNaming_NamedShape) ns = builder.NamedShape();
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_ocaf_5_5 Reading the contents of a named shape attribute
* The method <i>NamedShape(TopoDS_Shape,TDF_Label) </i> returns a named shape, which contains a given shape as a new shape. A given label is any label from the data framework -- it just gives access to it.
* *TNaming_Iterator* gives access to the named shape and hooks pairs.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
// create an iterator for a named shape
TNaming_Iterator iter(namedshape);
// iterate while some pairs are not iterated
// go to the next pair
iter.Next();
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_ocaf_5_6 Topological naming
If you need to create a topological attribute for existing data, use the method *NamedShape*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
class MyPkg_MyClass
{
public: Standard_Boolean SameEdge (const Handle(CafTest_Line)& L1, const Handle(CafTest_Line)& L2);
Handle(TNaming_NamedShape) NS2 = L2->NamedShape();
return BRepTools::Compare(NS1,NS2);
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_ocaf_5_8 Example of topological naming usage
To find an attribute attached to a specific label, you use the GUID of the attribute type you are looking for. This information can be found using the method <i> GetID</i> and the method <i> Find</i> for the label as follows:
-~~~~
+~~~~{.cpp}
Standard_GUID anID = MyAttributeClass::GetID();
Standard_Boolean HasAttribute = aLabel.Find(anID,anAttribute);
~~~~
Let's consider it on the example of the TDataStd_Real attribute. The previous version of the attribute allowed to set the attribute using
static method Set in next way:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
static Handle(TDataStd_Real) Set (const TDF_Label& label, const Standard_Real value);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
This is a default form which is kept by the attribute. It uses the default GUID for the attribute identification - TDataStd_Real::GetID().
In case if you want to use the new feature (user defined Real attribute), for example to define several attributes which should keep a value
of the same type - Standard_Real, but to be associated with different user's notions (or objects) the new static method Set should be used.
In our example we will define two Real attributes which presents two customer's objects - Density and Volume and will be put on the same Label.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
#define DENSITY Standard_GUID("12e9454b-6dbc-11d4-b9c8-0060b0ee2810")
#define VOLUME Standard_GUID("161595c0-3628-4737-915a-c160ce94c6f7")
To find an user defined Real attribute just use a corresponding GUID:
Handle (TDataStd_Real) anAtt;
aLabel.FindAttribute (DENSITY, anAtt);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_ocaf_6_4_1 Creation Attributes with User Defined GUID.
You can create a new instance of an attribute with user define GUID and add it to label in two ways.
1. Using static method Set(). For example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
TDF_Label aLabel = ...;
Standard_Integer aValue = ...;
Standard_GUID aGuid = TDataStd_Integer::GetID();
TDataStd_Integer::Set(aLabel, aGuid, aValue);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
2. Using the default constructor
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
Handle(TDataStd_Integer) anInt = new TDataStd_Integer();
anInt->SetID(aGuid);
aLabel.Add(anInt);
anInt->Set(aValue);
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section occt_ocaf_7 Visualization Attributes
To initialize the AIS viewer as in the example below, use method *Find*.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
// "access" is any label of the data framework
Handle(TPrsStd_AISViewer) viewer = TPrsStd_AISViewer::Find(access)
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_ocaf_7_2_2 Defining a presentation attribute
To fill a driver table with standard drivers, first initialize the AIS viewer as in the example above, and then pass the return value of the method *InitStandardDrivers* to the driver table returned by the method *Get*. Then attach a *TNaming_NamedShape* to a label and set the named shape in the presentation attribute using the method *Set*. Then attach the presentation attribute to the named shape attribute, and the *AIS_InteractiveObject*, which the presentation attribute contains, will initialize its drivers for the named shape. This can be seen in the example below.
**Example**
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
DriverTable::Get() -> InitStandardDrivers();
// next, attach your named shape to a label
TPrsStd_AISPresentation::Set(NS};
// here, attach the AISPresentation to NS.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section occt_ocaf_8 Function Services
This is an example of the code for iteration and execution of functions.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
// The scope of functions is defined.
Handle(TFunction_Scope) aScope = TFunction_Scope::Set (anyLabel);
}
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@subsection occt_ocaf_8a_6 Example 2: Cylinder function driver
This is an example of the code for a cylinder function driver. To make the things clearer, the methods <i>\::Arguments()</i> and <i>\::Results()</i> from the base class are also mentioned.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
// A virtual method ::Arguments() returns a list of arguments of the function.
CylinderDriver::Arguments( TDF_LabelList& args )
return 0;
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
The following example is a sample text from an XML file obtained by storing an OCAF document with two labels (0: and 0:2) and two attributes -- *TDataStd_Name* (on label 0:) and *TNaming_NamedShape* (on label 0:2). The \<shapes\> section contents are replaced by an ellipsis.
-~~~~
+~~~~{.cpp}
<?xml version="1.0" encoding="UTF-8"?>
<document format="XmlOcaf" xmlns="http://www.opencascade.org/OCAF/XML" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opencascade.org/OCAF/XML http://www.opencascade.org/OCAF/XML/XmlOcaf.xsd">
The other available format is *XmlOcaf*. The class **TObj_Model** declares and provides a default
implementation of two virtual methods:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean Load (const char* theFile);
virtual Standard_Boolean SaveAs (const char* theFile);
-~~~~~
+~~~~
which retrieve and store the model from or
in the OCAF file. The descendants
should define the following protected method to support Load and Save operations:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean initNewModel (const Standard_Boolean IsNew);
-~~~~~
+~~~~
This method is called by *Load* after creation of a new model
or after its loading from the file; its purpose is to perform
All objects in the model are stored in the main partition and accessed by iterators.
To access all model objects use:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TObj_ObjectIterator) GetObjects () const;
-~~~~~
+~~~~
This method returns a recursive iterator on all objects stored in the model.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TObj_ObjectIterator) GetChildren () const;
-~~~~~
+~~~~
This method returns an iterator on child objects of the main partition.
Use the following method to get the main partition:
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(TObj_Partition) GetMainPartition() const;
-~~~~~
+~~~~
To receive the iterator on objects of a specific type *AType* use the following call:
-~~~~~{.cpp}
+~~~~{.cpp}
GetMainPartition()->GetChildren(STANDARD_TYPE(AType) );
-~~~~~
+~~~~
The set of protected methods is provided for descendant classes to deal with partitions:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TObj_Partition) getPartition (const TDF_Label, const Standard_Boolean theHidden) const;
-~~~~~
+~~~~
This method returns (creating if necessary) a partition in the specified label of the document.
The partition can be created as hidden (*TObj_HiddenPartition* class).
in the sub-label of the specified label in the document
(the label of the main partition for the second method) and with the given name:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TObj_Partition) getPartition (const TDF_Label, const Standard_Integer theIndex, const TCollection_ExtendedString& theName, const Standard_Boolean theHidden) const;
virtual Handle(TObj_Partition) getPartition (const Standard_Integer theIndex, const TCollection_ExtendedString& theName, const Standard_Boolean theHidden) const;
-~~~~~
+~~~~
If the default object naming and the name register mechanism
is turned on, the object can be found in the model by its unique name:
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(TObj_Object) FindObject (const Handle(TCollection_HExtendedString)& theName, const Handle(TObj_TNameContainer)& theDictionary) const;
-~~~~~
+~~~~
@subsubsection occt_tobj_2_5 Own model data
*AfterRetrieval* of the *TObj_Object* class and skip the registration of the object name.
Use the following methods for the naming mechanism:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Boolean IsRegisteredName (const Handle(TCollection_HExtendedString)& theName, const Handle(TObj_TNameContainer)& theDictionary ) const;
-~~~~~
+~~~~
Returns **True** if the object name is already registered in the indicated (or model) dictionary.
-~~~~~{.cpp}
+~~~~{.cpp}
void RegisterName (const Handle(TCollection_HExtendedString)& theName, const TDF_Label& theLabel, const Handle(TObj_TNameContainer)& theDictionary ) const;
-~~~~~
+~~~~
Registers the object name with the indicated label where the object
is located in the OCAF document. Note that the default implementation
of the method *SetName* of the object registers the new name automatically
(if the name is not yet registered for any other object)
-~~~~~{.cpp}
+~~~~{.cpp}
void UnRegisterName (const Handle(TCollection_HExtendedString)& theName, const Handle(TObj_TNameContainer)& theDictionary ) const;
-~~~~~
+~~~~
Unregisters the name from the dictionary.
The names of *TObj* model objects are removed from the dictionary when the objects are deleted from the model.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(TObj_TNameContainer) GetDictionary() const;
-~~~~~
+~~~~
Returns a default instance of the model dictionary (located at the model root label).
The default implementation works only with one dictionary.
Class *TObj_Model* provides the API for transaction mechanism (supported by OCAF):
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Boolean HasOpenCommand() const;
-~~~~~
+~~~~
Returns True if a Command transaction is open
-~~~~~{.cpp}
+~~~~{.cpp}
void OpenCommand() const;
-~~~~~
+~~~~
Opens a new command transaction.
-~~~~~{.cpp}
+~~~~{.cpp}
void CommitCommand() const;
-~~~~~
+~~~~
Commits the Command transaction. Does nothing If there is no open Command transaction.
-~~~~~{.cpp}
+~~~~{.cpp}
void AbortCommand() const;
-~~~~~
+~~~~
Aborts the Command transaction. Does nothing if there is no open Command transaction.
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Boolean IsModified() const;
-~~~~~
+~~~~
Returns True if the model document has a modified status (has changes after the last save)
-~~~~~{.cpp}
+~~~~{.cpp}
void SetModified( const Standard_Boolean );
-~~~~~
+~~~~
Changes the modified status by force. For synchronization of transactions
within several *TObj_Model* documents use class *TDocStd_MultiTransactionManager*.
Class *TObj_Model* provides the descendant classes with a means to control
the format of the persistent file by choosing the schema used to store or retrieve operations.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual TCollection_ExtendedString GetFormat () const;
-~~~~~
+~~~~
Returns the string *TObjBin* or *TObjXml* indicating
the current persistent mechanism. The default value is *TObjBin*.
of the model format. The current version of the model
format is stored in the model file and can be checked upon retrieval.
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer GetFormatVersion() const;
-~~~~~
+~~~~
Returns the format version stored in the model file
-~~~~~{.cpp}
+~~~~{.cpp}
void SetFormatVersion(const Standard_Integer theVersion);
-~~~~~
+~~~~
Defines the format version used for save.
The following methods are used for model update to ensure its consistency
with respect to the other models in case of cross-model dependencies:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean Update();
-~~~~~
+~~~~
This method is usually called after loading of the model.
The default implementation does nothing and returns **True**.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean initNewModel( const Standard_Boolean IsNew);
-~~~~~
+~~~~
This method performs model initialization, check and updates (as described above).
-~~~~~{.cpp}
+~~~~{.cpp}
virtual void updateBackReferences( const Handle(TObj_Object)& theObj);
-~~~~~
+~~~~
This method is called from the previous method to update back references
of the indicated object after the retrieval of the model from file
To copy the model between OCAF documents use the following methods:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean Paste (Handle(TObj_Model) theModel, Handle(TDF_RelocationTable) theRelocTable = 0 );
-~~~~~
+~~~~
Pastes the current model to the new model. The relocation table
ensures correct copying of the sub-data shared by several parts of the model.
It stores a map of processed original objects of relevant types in their copies.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TObj_Model) NewEmpty() = 0;
-~~~~~
+~~~~
Redefines a pure virtual method to create a new empty instance of the model.
-~~~~~{.cpp}
+~~~~{.cpp}
void CopyReferences ( const Handle(TObj_Model)& theTarget, const Handle(TDF_RelocationTable)& theRelocTable);
-~~~~~
+~~~~
Copies the references from the current model to the target model.
The messenger is stored as the field of the model instance
and can be set and retrieved by the following methods:
-~~~~~{.cpp}
+~~~~{.cpp}
void SetMessenger( const Handle(Message_Messenger)& );
Handle(Message_Messenger) Messenger() const;
-~~~~~
+~~~~
A developer should create his own instance of the Messenger
bound to the application user interface, and attribute it to the model
An object can be received from the model by the following methods:
-~~~~~{.cpp}
+~~~~{.cpp}
static Standard_Boolean GetObj ( const TDF_Label& theLabel, Handle(TObj_Object)& theResObject, const Standard_Boolean isSuper = Standard_False );
-~~~~~
+~~~~
Returns *True* if the object has been found in the indicated label (or in the upper level label if *isSuper* is *True*).
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(TObj_Object) GetFatherObject ( const Handle(Standard_Type)& theType = NULL ) const;
-~~~~~
+~~~~
Returns the father object of the indicated type
for the current object (the direct father object if the type is NULL).
*TObj_Object* class provides a set of auxiliary methods for descendants
to access the data stored in sub-labels by their tag numbers:
-~~~~~{.cpp}
+~~~~{.cpp}
TDF_Label getDataLabel (const Standard_Integer theRank1, const Standard_Integer theRank2 = 0) const;
TDF_Label getReferenceLabel (const Standard_Integer theRank1, const Standard_Integer theRank2 = 0) const;
-~~~~~
+~~~~
Returns the label in *Data* or *References* sub-labels at a given tag number (theRank1).
The second argument, theRank2, allows accessing the next level of hierarchy
*TColStd_HArray1OfReal*, *TColStd_HArray1OfInteger*, *TColStd_HArray1OfExtendedString*).
For instance, methods provided for real numbers are:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Real getReal (const Standard_Integer theRank1, const Standard_Integer theRank2 = 0) const;
Standard_Boolean setReal (const Standard_Real theValue, const Standard_Integer theRank1, const Standard_Integer theRank2 = 0, const Standard_Real theTolerance = 0.) const;
-~~~~~
+~~~~
Similar methods are provided to access references to other objects:
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(TObj_Object) getReference (const Standard_Integer theRank1, const Standard_Integer theRank2 = 0) const;
Standard_Boolean setReference (const Handle(TObj_Object) &theObject, const Standard_Integer theRank1, const Standard_Integer theRank2 = 0);
-~~~~~
+~~~~
The method *addReference* gives an easy way to store a sequence of homogeneous references in one label.
-~~~~~{.cpp}
+~~~~{.cpp}
TDF_Label addReference (const Standard_Integer theRank1, const Handle(TObj_Object) &theObject);
-~~~~~
+~~~~
Note that while references to other objects should be defined by descendant classes
individually according to the type of object, *TObj_Object* provides methods
Two macros defined in the file TObj_Persistence.hxx have to be included in the definition
of each model object class inheriting TObj_Object to activate the persistence mechanism:
-~~~~~{.cpp}
+~~~~{.cpp}
DECLARE_TOBJOCAF_PERSISTENCE (classname, ancestorname)
-~~~~~
+~~~~
Should be included in the private section of declaration of each class inheriting
*TObj_Object* (hxx file). This macro adds an additional constructor to the object class,
and declares an auxiliary (private) class inheriting *TObj_Persistence*
that provides a tool to create a new object of the proper type.
-~~~~~{.cpp}
+~~~~{.cpp}
IMPLEMENT_TOBJOCAF_PERSISTENCE (classname)
-~~~~~
+~~~~
Should be included in .cxx file of each object class that should be saved and restored.
This is not needed for abstract types of objects. This macro implements the functions
This functionality is provided by the following methods:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TObj_TNameContainer) GetDictionary() const;
-~~~~~
+~~~~
Returns the name container where the name of object should be registered.
The default implementation returns the model name container.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(TCollection_HExtendedString) GetName() const;
Standard_Boolean GetName( TCollection_ExtendedString& theName ) const;
Standard_Boolean GetName( TCollection_AsciiString& theName ) const;
-~~~~~
+~~~~
Returns the object name. The methods with in / out argument return False if the object name is not defined.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean SetName ( const Handle(TCollection_HExtendedString)& theName ) const;
Standard_Boolean SetName ( const Handle(TCollection_HAsciiString)& theName ) const;
Standard_Boolean SetName ( const Standard_CString theName ) const;
-~~~~~
+~~~~
Attributes a new name to the object and returns **True** if the name has been attributed successfully.
Returns False if the name has been already attributed to another object.
The most used methods for work with references are:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean HasReference( const Handle(TObj_Object)& theObject) const;
-~~~~~
+~~~~
Returns True if the current object refers to the indicated object.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TObj_ObjectIterator) GetReferences ( const Handle(Standard_Type)& theType = NULL ) const;
-~~~~~
+~~~~
Returns an iterator on the object references. The optional argument *theType*
restricts the types of referred objects, or does not if it is NULL.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual void RemoveAllReferences();
-~~~~~
+~~~~
Removes all references from the current object.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual void RemoveReference( const Handle(TObj_Object)& theObject );
-~~~~~
+~~~~
Removes the reference to the indicated object.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TObj_ObjectIterator) GetBackReferences ( const Handle(Standard_Type)& theType = NULL ) const;
-~~~~~
+~~~~
Returns an iterator on the object back references.
The argument theType restricts the types of master objects, or does not if it is NULL.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual void ReplaceReference ( const Handle(TObj_Object)& theOldObject, const Handle(TObj_Object)& theNewObject );
-~~~~~
+~~~~
Replaces the reference to theOldObject by the reference to *theNewObject*.
The handle theNewObject may be NULL to remove the reference.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean RelocateReferences ( const TDF_Label& theFromRoot, const TDF_Label& theToRoot, const Standard_Boolean theUpdateackRefs = Standard_True );
-~~~~~
+~~~~
Replaces all references to a descendant label of *theFromRoot*
by the references to an equivalent label under *theToRoot*.
Returns **False** if the resulting reference does not point at a *TObj_Object*.
Updates back references if theUpdateackRefs is **True**.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean CanRemoveReference ( const Handle(TObj_Object)& theObj) const;
-~~~~~
+~~~~
Returns **True** if the reference can be removed and the master object
will remain valid (*weak* reference).
The most used methods for object removing are:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean CanDetachObject (const TObj_DeletingMode theMode = TObj_FreeOnly );
-~~~~~
+~~~~
Returns **True** if the object can be deleted with the indicated deletion mode.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Boolean Detach ( const TObj_DeletingMode theMode = TObj_FreeOnly );
-~~~~~
+~~~~
Removes the object from the document if possible
(according to the indicated deletion mode).
*TObj_Object* provides a number of special virtual methods to support replications of objects. These methods should be redefined by descendants when necessary.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TObj_Object) Clone (const TDF_Label& theTargetLabel, Handle(TDF_RelocationTable) theRelocTable = 0);
-~~~~~
+~~~~
Copies the object to theTargetLabel. The new object will have all references of its original.
Returns a handle to the new object (null handle if fail). The data are copied directly,
but the name is changed by adding the postfix *_copy*.
To assign different names to the copies redefine the method:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Handle(TCollection_HExtendedString) GetNameForClone ( const Handle(TObj_Object)& ) const;
-~~~~~
+~~~~
Returns the name for a new object copy. It could be useful to return the same object name
if the copy will be in the other model or in the other partition with its own dictionary.
The method *Clone* uses the following public methods for object data replications:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual void CopyReferences (const const Handle(TObj_Object)& theTargetObject, const Handle(TDF_RelocationTable) theRelocTable);
-~~~~~
+~~~~
Adds to the copy of the original object its references.
-~~~~~{.cpp}
+~~~~{.cpp}
virtual void CopyChildren (TDF_Label& theTargetLabel, const Handle(TDF_RelocationTable) theRelocTable);
-~~~~~
+~~~~
Copies the children of an object to the target child label.
The user (developer) can define any new flags in descendant classes.
To set/get an object, the flags use the following methods:
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer GetFlags() const;
void SetFlags( const Standard_Integer theMask );
Stadnard_Boolean TestFlags( const Standard_Integer theMask ) const;
void ClearFlags( const Standard_Integer theMask = 0 );
-~~~~~
+~~~~
In addition, the generic virtual interface stores the logical properties
of the object class in the form of a set of bit flags.
Type flags can be received by the method:
-~~~~~{.cpp}
+~~~~{.cpp}
virtual Standard_Integer GetTypeFlags() const;
-~~~~~
+~~~~
The default implementation returns the flag **Visible**
defined in the enumeration *TypeFlags*. This flag is used to define visibility
The main partition object methods:
-~~~~~{.cpp}
+~~~~{.cpp}
TDF_Label NewLabel() const;
-~~~~~
+~~~~
Allocates and returns a new label for creation of a new child object.
-~~~~~{.cpp}
+~~~~{.cpp}
void SetNamePrefix ( const Handle(TCollection_HExtendedString)& thePrefix);
-~~~~~
+~~~~
Defines the prefix for automatic generation of names of the newly created objects.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(TCollection_HExtendedString) GetNamePrefix() const;
-~~~~~
+~~~~
Returns the current name prefix.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(TCollection_HExtendedString) GetNewName ( const Standard_Boolean theIsToChangeCount) const;
-~~~~~
+~~~~
Generates the new name and increases the internal counter of child objects if theIsToChangeCount is **True**.
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer GetLastIndex() const;
-~~~~~
+~~~~
Returns the last reserved child index.
-~~~~~{.cpp}
+~~~~{.cpp}
void SetLastIndex( const Standard_Integer theIndex );
-~~~~~
+~~~~
Sets the last reserved index.
* Store the names of software extensions.
* **Driver** -- an abstract class, which defines the communications protocol with a system.
* **Entry** -- an ASCII character string containing the tag list of a label. For example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
0:3:24:7:2:7
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
* **External links** -- references from one data structure to another data structure in another document.
To store these references properly, a label must also contain an external link attribute.
In C++, the application behavior is implemented in virtual functions redefined in these derived classes. This is known as overriding.
* **GUID** -- Global Universal ID. A string of 37 characters intended to uniquely identify an object. For example:
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
2a96b602-ec8b-11d0-bee7-080009dc3333
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
* **Label** -- a point in the data framework, which allows data to be attached to it by means of attributes. It has a name in the form of an entry, which identifies its place in the data framework.
* **Modified label** -- containing attributes whose data has been modified.
It is possible to test the status for the presence of some flag(s), using Status...() method(s) provided by the class:
-~~~~~
+~~~~{.cpp}
if ( object.Status.. ( ShapeExtend_DONE ) ) {// something was done
}
-~~~~~
+~~~~
8 'DONE' and 8 'FAIL' flags, named ShapeExtend_DONE1 ... ShapeExtend_FAIL8, are defined for a detailed analysis of the encountered situation. Each method assigns its own meaning to each flag, documented in the header for that method. There are also three enumerative values used for testing several flags at a time:
* *ShapeExtend_OK* -- if no flags have been set;
In some cases using only *ShapeFix_Shape* can be insufficient. It is possible to use tools for merging and removing small edges and fixing gaps between 2D and 3D curves.
5. Create *ShapeFix_Wireframe* tool and initialize it by shape:
-~~~~~
+~~~~{.cpp}
Handle(ShapeFix_Wirefarme) SFWF = new ShapeFix_Wirefarme(shape);
Or
Handle(ShapeFix_Wirefarme) SFWF = new ShapeFix_Wirefarme;
SFWF->Load(shape);
-~~~~~
+~~~~
6. Set the basic precision and the maximum allowed tolerance:
-~~~~~
+~~~~{.cpp}
sfs->SetPrecision ( Prec );
sfs->SetMaxTolerance ( maxTol );
-~~~~~
+~~~~
See the description for *Prec* and *maxTol* above.
7. Merge and remove small edges:
-~~~~~
+~~~~{.cpp}
SFWF->DropSmallEdgesMode() = Standard_True;
SFWF->FixSmallEdges();
-~~~~~
+~~~~
**Note:** Small edges are not removed with the default mode, but in many cases removing small edges is very useful for fixing a shape.
8. Fix gaps for 2D and 3D curves
-~~~~~
+~~~~{.cpp}
SFWF->FixWireGaps();
-~~~~~
+~~~~
9. Get the result
-~~~~~
+~~~~{.cpp}
TopoDS_Shape Result = SFWF->Shape();
-~~~~~
+~~~~
@subsection occt_shg_2_2 Shape Correction.
For example, in the following way it is possible to fix face *Face1* of shape *Shape1*:
-~~~~~
+~~~~{.cpp}
//create tools for fixing a face
Handle(ShapeFix_Face) SFF= new ShapeFix_Face;
//get the result
TopoDS_Shape NewShape = Context->Apply(Shape1);
//Resulting shape contains the fixed face.
-~~~~~
+~~~~
A set of required fixes and invalid sub-shapes can be obtained with the help of tools responsible for the analysis of shape validity (section 3.2).
6. Get the result in two ways :
- with help of a special method *Shape(),Face(),Wire().Edge()*.
- from the rebuilding tool by method *Apply* (for access to rebuilding tool use method *Context()*):
-~~~~~
+~~~~{.cpp}
TopoDS_Shape resultShape = fixtool->Context()->Apply(initialShape);
-~~~~~
+~~~~
Modification fistory for the shape and its sub-shapes can be obtained from the tool for shape re-building (*ShapeBuild_ReShape*).
-~~~~~
+~~~~{.cpp}
TopoDS_Shape modifsubshape = fixtool->Context() -> Apply(initsubshape);
-~~~~~
+~~~~
@subsubsection occt_shg_2_3_2 Flags Management
For example, it is possible to forbid performing fixes to remove small edges - *FixSmall*
-~~~~~
+~~~~{.cpp}
Handle(ShapeFix_Shape) Sfs = new ShapeFix_Shape(shape);
Sfs-> FixWireTool ()->FixSmallMode () =0;
if(Sfs->Perform())
TopoDS_Shape resShape = Sfs->Shape();
-~~~~~
+~~~~
@subsubsection occt_shg_2_3_3 Repairing tool for shapes
For example, it is possible to force the removal of invalid 2D curves from a face.
-~~~~~
+~~~~{.cpp}
TopoDS_Face face … // face with invalid 2D curves.
//creation of tool and its initialization by shape.
Handle(ShapeFix_Shape) sfs = new ShapeFix_Shape(face);
else if(sfs->Status(ShapeExtent_OK)) {
cout<< "Initial face is valid with specified precision ="<< precendl;
}
-~~~~~
+~~~~
@subsubsection occt_shg_2_3_4 Repairing tool for solids
* *FixMissingSeamMode* -- mode to fix a missing seam, True by default. If True, tries to insert a seam.
* *FixSmallAreaWireMode* -- mode to fix a small-area wire, False by default. If True, drops wires bounding small areas.
-~~~~~
+~~~~{.cpp}
TopoDS_Face face = ...;
TopoDS_Wire wire = ...;
//Get the resulting face
TopoDS_Face newface = sff.Face();
-~~~~~
+~~~~
@subsubsection occt_shg_2_3_7 Repairing tool for wires
Let us create a custom set of fixes as an example.
-~~~~~
+~~~~{.cpp}
TopoDS_Face face = ...;
TopoDS_Wire wire = ...;
Standard_Real precision = 1e-04;
}
TopoDS_Wire newwire = sfw.Wire();
//Returns the corrected wire
-~~~~~
+~~~~
#### Example: Correction of a wire
* there are no intersecting adjacent edges;
and then immediately apply fixing tools.
-~~~~~
+~~~~{.cpp}
TopoDS_Face face = ...;
TopoDS_Wire wire = ...;
Standard_Real precision = 1e-04;
// The edges are cut at the intersection point so that they no longer intersect.
}
}
-~~~~~
+~~~~
As the result all failures have been fixed.
First it is necessary to apply the @ref occt_shg_3_1_3 "tool for checking the edge validity" to find that the maximum deviation between pcurve and 3D curve is greater than tolerance. Then we can use the repairing tool to increase the tolerance and make the deviation acceptable.
-~~~~~
+~~~~{.cpp}
ShapeAnalysis_Edge sae;
TopoDS_Face face = ...;
TopoDS_Wire wire = ...;
sfe.FixSameParameter();
cout<<“New tolerance “<<BRep_Tool::Tolerance(edge)<<endl;
}
-~~~~~
+~~~~
@figure{/user_guides/shape_healing/images/shape_healing_image012.png,"Resulting shape",420}
* set the working precision problems will be detected with and the maximum allowed tolerance
* perform fixes
-~~~~~
+~~~~{.cpp}
//creation of a tool
Handle(ShapeFix_Wireframe) sfwf = new ShapeFix_Wireframe(shape);
//sets the working precision problems will be detected with and the maximum allowed tolerance
sfwf->FixSmallEdges();
//getting the result
TopoDS_Shape resShape = sfwf->Shape();
-~~~~~
+~~~~
It is desirable that a shape is topologically correct before applying the methods of this class.
The sequence of actions for performing the fix is the same as for the fixes described above:
-~~~~~
+~~~~{.cpp}
//creation of a tool
Handle(ShapeFix_FixSmallFace) sff = new ShapeFix_FixSmallFace(shape);
//setting of tolerances
sff.Perform();
//getting the result
TopoDS_Shape resShape = sff.FixShape();
-~~~~~
+~~~~
@subsubsection occt_shg_2_3_11 Tool to modify tolerances of shapes (Class ShapeFix_ShapeTolerance).
* set a tolerance for sub-shapes, by method SetTolerance,
* limit tolerances with given ranges, by method LimitTolerance.
-~~~~~
+~~~~{.cpp}
//creation of a tool
ShapeFix_ShapeTolerance Sft;
//setting a specified tolerance on shape and all of its sub-shapes.
Sft.SetTolerance(shape,toler,TopAbs_VERTEX);
//limiting the tolerance on the shape and its sub-shapes between minimum and maximum tolerances
Sft.LimitTolerance(shape,tolermin,tolermax);
-~~~~~
+~~~~
@section occt_shg_3 Analysis
* initialize it by shape and set a tolerance problems will be detected with if it is necessary.
* check the problem that interests you.
-~~~~~
+~~~~{.cpp}
TopoDS_Face face = ...;
ShapeAnalysis_Edge sae;
//Creates a tool for analyzing an edge
if (!sae.HasCurve3d (edge)) {
cout <<"Edge has no 3D curve"<< endl; }
}
-~~~~~
+~~~~
@subsubsection occt_shg_3_1_1 Analysis of orientation of wires on a face.
It is possible to check whether a face has an outer boundary with the help of method *ShapeAnalysis::IsOuterBound*.
-~~~~~
+~~~~{.cpp}
TopoDS_Face face … //analyzed face
if(!ShapeAnalysis::IsOuterBound(face)) {
cout<<"Face has not outer boundary"<<endl;
}
-~~~~~
+~~~~
@subsubsection occt_shg_3_1_2 Analysis of wire validity
This class maintains status management. Each API method stores the status of its last execution which can be queried by the corresponding *Status..()* method. In addition, each API method returns a Boolean value, which is True when a case being analyzed is detected (with the set *ShapeExtend_DONE* status), otherwise it is False.
-~~~~~
+~~~~{.cpp}
TopoDS_Face face = ...;
TopoDS_Wire wire = ...;
Standard_Real precision = 1e-04;
if (saw.CheckSelfIntersection()) {
cout<<"Wire has self-intersecting or intersecting adjacent edges"<< endl;
}
-~~~~~
+~~~~
@subsubsection occt_shg_3_1_3 Analysis of edge validity
This class supports status management described above.
-~~~~~
+~~~~{.cpp}
TopoDS_Face face = ...;
ShapeAnalysis_Edge sae;
//Creates a tool for analyzing an edge
cout<<"Edges are overlapped with tolerance = "<<prec<<endl;
cout<<"Domain of overlapping ="<<dist<<endl;
}
-~~~~~
+~~~~
@subsubsection occt_shg_3_1_4 Analysis of presence of small faces
* *CheckSpotFace()* checks if the size of the face is less than the given precision;
* *CheckStripFace* checks if the size of the face in one dimension is less than the given precision.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape shape … // checked shape
//Creation of a tool
ShapeAnalysis_CheckSmallFace saf;
}
if(numSmallfaces)
cout<<"Number of small faces in the shape ="<< numSmallfaces <<endl;
-~~~~~
+~~~~
@subsubsection occt_shg_3_1_5 Analysis of shell validity and closure
Class *ShapeAnalysis_Shell* allows checking the orientation of edges in a manifold shell. With the help of this tool, free edges (edges entered into one face) and bad edges (edges entered into the shell twice with the same orientation) can be found. By occurrence of bad and free edges a conclusion about the shell validity and the closure of the shell can be made.
-~~~~~
+~~~~{.cpp}
TopoDS_Shell shell // checked shape
ShapeAnalysis_Shell sas(shell);
//analysis of the shell , second parameter is set to True for //getting free edges,(default False)
cout<<"Shell is open"<<endl;
TopoDS_Compound freeEdges = sas.FreeEdges();
}
-~~~~~
+~~~~
@subsection occt_shg_3_2 Analysis of shape properties.
@subsubsection occt_shg_3_2_1 Analysis of tolerance on shape
* finding sub-shapes with tolerances exceeding the given value,
* finding sub-shapes with tolerances in the given range.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape shape = ...;
ShapeAnalysis_ShapeTolerance sast;
Standard_Real AverageOnShape = sast.Tolerance (shape, 0);
if (MaxOnVertex > MaxAllowed) {
cout<<"Maximum tolerance of the vertices exceeds maximum allowed"<<endl;
}
-~~~~~
+~~~~
@subsubsection occt_shg_3_2_2 Analysis of free boundaries.
Class ShapeAnalysis_FreeBounds is intended to analyze and output the free bounds of a shape. Free bounds are wires consisting of edges referenced only once by only one face in the shape.
This class works on two distinct types of shapes when analyzing their free bounds:
* Analysis of possible free bounds taking the specified tolerance into account. This analysis can be applied to a compound of faces. The analyzer of the sewing algorithm (*BRepAlgo_Sewing*) is used to forecast what free bounds would be obtained after the sewing of these faces is performed. The following method should be used for this analysis:
-~~~~~
+~~~~{.cpp}
ShapeAnalysis_FreeBounds safb(shape,toler);
-~~~~~
+~~~~
* Analysis of already existing free bounds. Actual free bounds (edges shared by the only face in the shell) are output in this case. *ShapeAnalysis_Shell* is used for that.
-~~~~~
+~~~~{.cpp}
ShapeAnalysis_FreeBounds safb(shape);
-~~~~~
+~~~~
When connecting edges into wires this algorithm tries to build wires of maximum length. Two options are provided for the user to extract closed sub-contours out of closed and/or open contours. Free bounds are returned as two compounds, one for closed and one for open wires. To obtain a result it is necessary to use methods:
-~~~~~
+~~~~{.cpp}
TopoDS_Compound ClosedWires = safb.GetClosedWires();
TopoDS_Compound OpenWires = safb.GetOpenWires();
-~~~~~
+~~~~
This class also provides some static methods for advanced use: connecting edges/wires to wires, extracting closed sub-wires from wires, distributing wires into compounds for closed and open wires.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape shape = ...;
Standard_Real SewTolerance = 1.e-03;
//Tolerance for sewing
//Returns a compound of closed free bounds
TopoDS_Compound OpenWires = safb.GetClosedWires();
//Returns a compound of open free bounds
-~~~~~
+~~~~
@subsubsection occt_shg_3_2_3 Analysis of shape contents
Let us, for example, select faces based on offset surfaces.
-~~~~~
+~~~~{.cpp}
ShapeAnalysis_ShapeContents safc;
//set a corresponding flag for storing faces based on the offset surfaces
safc.ModifyOffsetSurfaceMode() = Standard_True;
Standard_Integer NbOffsetSurfaces = safc.NbOffsetSurf();
//getting the sequence of faces based on offset surfaces.
Handle(TopTools_HSequenceOfShape) seqFaces = safc.OffsetSurfaceSec();
-~~~~~
+~~~~
@section occt_shg_4 Upgrading
Let us, for example, split all surfaces and all 3D and 2D curves having a continuity of less the C2.
-~~~~~
+~~~~{.cpp}
//create a tool and initializes it by shape.
ShapeUpgrade_ShapeDivideContinuity ShapeDivedeCont(initShape);
for(TopExp_Explorer aExp(initShape,TopAbs_FACE); aExp.More(0; aExp.Next()) {
TopoDS_Shape modifShape = ShapeDivideCont.GetContext()-> Apply(aExp.Current());
}
-~~~~~
+~~~~
@subsubsection occt_shg_4_1_3 Creation of a new tool for splitting a shape.
To create a new splitting tool it is necessary to create tools for geometry splitting according to a desirable criterion. The new tools should be inherited from basic tools for geometry splitting. Then the new tools should be set into corresponding tools for shape splitting.
Let us split a shape according to a specified criterion.
-~~~~~
+~~~~{.cpp}
//creation of new tools for geometry splitting by a specified criterion.
Handle(MyTools_SplitSurfaceTool) MySplitSurfaceTool = new MyTools_SplitSurfaceTool;
Handle(MyTools_SplitCurve3DTool) MySplitCurve3Dtool = new MyTools_SplitCurve3DTool;
for(TopExp_Explorer aExp(initShape,TopAbs_FACE); aExp.More(0; aExp.Next()) {
TopoDS_Shape modifShape = ShapeDivide.GetContext()-> Apply(aExp.Current());
}
-~~~~~
+~~~~
@subsection occt_shg_4_2 General splitting tools.
Header file for the tool for surface splitting by continuity:
-~~~~~
+~~~~{.cpp}
class ShapeUpgrade_SplitSurfaceContinuity : public ShapeUpgrade_SplitSurface {
Standard_EXPORT ShapeUpgrade_SplitSurfaceContinuity();
Standard_Real myTolerance;
Standard_Integer myCont;
};
-~~~~~
+~~~~
@subsection occt_shg_4_3 Specific splitting tools.
@subsubsection occt_shg_4_3_1 Conversion of shape geometry to the target continuity
Class *ShapeUpgrade_ShapeDivideContinuity* allows converting geometry with continuity less than the specified continuity to geometry with target continuity. If converting is not possible than geometrical object is split into several ones, which satisfy the given criteria. A topological object based on this geometry is replaced by several objects based on the new geometry.
-~~~~~
+~~~~{.cpp}
ShapeUpgrade_ShapeDivideContinuity sdc (shape);
sdc.SetTolerance (tol3d);
sdc.SetTolerance3d (tol2d); // if known, else 1.e-09 is taken
// if there are several results, they are recorded inside a Compound.
// .. process as needed
}
-~~~~~
+~~~~
@subsubsection occt_shg_4_3_2 Splitting by angle
Class *ShapeUpgrade_ShapeDivideAngle* allows splitting all surfaces of revolution, cylindrical, toroidal, conical, spherical surfaces in the given shape so that each resulting segment covers not more than the defined angle (in radians).
* *GetBSplineMode,*
Let us attempt to produce a conversion of planes to Bezier surfaces.
-~~~~~
+~~~~{.cpp}
//Creation and initialization of a tool.
ShapeUpgrade_ShapeConvertToBezier SCB (Shape);
//setting tolerances
SCB.Perform();
If(SCB.Status(ShapeExtend_DONE)
TopoDS_Shape result = SCB.GetResult();
-~~~~~
+~~~~
@subsubsection occt_shg_4_3_4 Tool for splitting closed faces
Class *ShapeUpgrade_ShapeDivideClosed* provides splitting of closed faces in the shape to a defined number of components by the U and V parameters. It topologically and (partially) geometrically processes closed faces and performs splitting with the help of class *ShapeUpgrade_ClosedFaceDivide*.
-~~~~~
+~~~~{.cpp}
TopoDS_Shape aShape = …;
ShapeUpgrade_ShapeDivideClosed tool (aShape );
Standard_Real closeTol = …;
. . .
}
TopoDS_Shape aResult = tool.Result();
-~~~~~
+~~~~
@subsubsection occt_shg_4_3_5 Tool for splitting a C0 BSpline 2D or 3D curve to a sequence C1 BSpline curves
* To produce a splitting use method Perform from the base class.
* The result shape can be obtained with the help the method *Result()*.
-~~~~~
+~~~~{.cpp}
ShapeUpgrade_ShapeDivideArea tool (inputShape);
tool.MaxArea() = aMaxArea;
tool.Perform();
TopoDS_Shape ResultShape = tool.Result();
ShapeFix::SameParameter ( ResultShape, Standard_False );
}
-~~~~~
+~~~~
**Note** that the use of method *ShapeFix::SameParameter* is necessary, otherwise the parameter edges obtained as a result of splitting can be different.
To implement the necessary shape modification it is enough to initialize the appropriate tool by the shape and desirable parameters and to get the resulting shape. For example for conversion of indirect surfaces in the shape do the following:
-~~~~~
+~~~~{.cpp}
TopoDS_Shape initialShape ..
TopoDS_Shape resultShape = ShapeCustom::DirectFaces(initialShape);
-~~~~~
+~~~~
@subsubsection occt_shg_4_4_1 Conversion of indirect surfaces.
-~~~~~
+~~~~{.cpp}
ShapeCustom::DirectFaces
static TopoDS_Shape DirectFaces(const TopoDS_Shape& S);
-~~~~~
+~~~~
This method provides conversion of indirect elementary surfaces (elementary surfaces with left-handed coordinate systems) in the shape into direct ones. New 2d curves (recomputed for converted surfaces) are added to the same edges being shared by both the resulting shape and the original shape *S*.
@subsubsection occt_shg_4_4_2 Shape Scaling
-~~~~~
+~~~~{.cpp}
ShapeCustom::ScaleShape
TopoDS_Shape ShapeCustom::ScaleShape(const TopoDS_Shape& S,
const Standard_Real scale);
-~~~~~
+~~~~
This method returns a new shape, which is a scaled original shape with a coefficient equal to the specified value of scale. It uses the tool *ShapeCustom_TrsfModification*.
*ShapeCustom_BSplineRestriction* allows approximation of surfaces, curves and 2D curves with a specified degree, maximum number of segments, 2d tolerance and 3d tolerance. If the approximation result cannot be achieved with the specified continuity, the latter can be reduced.
The method with all parameters looks as follows:
-~~~~~
+~~~~{.cpp}
ShapeCustom::BsplineRestriction
TopoDS_Shape ShapeCustom::BSplineRestriction (const TopoDS_Shape& S,
const Standard_Real Tol3d, const Standard_Real Tol2d,
const Standard_Boolean Degree,
const Standard_Boolean Rational,
const Handle(ShapeCustom_RestrictionParameters)& aParameters)
-~~~~~
+~~~~
It returns a new shape with all surfaces, curves and 2D curves of BSpline/Bezier type or based on them, converted with a degree less than *MaxDegree* or with a number of spans less then *NbMaxSegment* depending on the priority parameter *Degree*. If this parameter is equal to True then *Degree* will be increased to the value *GmaxDegree*, otherwise *NbMaxSegments* will be increased to the value *GmaxSegments*. *GmaxDegree* and *GMaxSegments* are the maximum possible degree and the number of spans correspondingly. These values will be used in cases when an approximation with specified parameters is impossible and either *GmaxDegree* or *GMaxSegments* is selected depending on the priority.
@subsubsection occt_shg_4_4_4 Conversion of elementary surfaces into surfaces of revolution
-~~~~~
+~~~~{.cpp}
ShapeCustom::ConvertToRevolution()
TopoDS_Shape ShapeCustom::ConvertToRevolution(const TopoDS_Shape& S) ;
-~~~~~
+~~~~
This method returns a new shape with all elementary periodic surfaces converted to *Geom_SurfaceOfRevolution*. It uses the tool *ShapeCustom_ConvertToRevolution*.
@subsubsection occt_shg_4_4_5 Conversion of elementary surfaces into Bspline surfaces
-~~~~~
+~~~~{.cpp}
ShapeCustom::ConvertToBSpline()
TopoDS_Shape ShapeCustom::ConvertToBSpline( const TopoDS_Shape& S,
const Standard_Boolean extrMode,
const Standard_Boolean revolMode,
const Standard_Boolean offsetMode);
-~~~~~
+~~~~
This method returns a new shape with all surfaces of linear extrusion, revolution and offset surfaces converted according to flags to *Geom_BSplineSurface* (with the same parameterization). It uses the tool *ShapeCustom_ConvertToBSpline*.
The general calling syntax for scaling is
-~~~~~
+~~~~{.cpp}
TopoDS_Shape scaled_shape = ShapeCustom::ScaleShape(shape, scale);
-~~~~~
+~~~~
Note that scale is a real value. You can refine your mapping process by using additional calls to follow shape mapping sub-shape by sub-shape. The following code along with pertinent includes can be used:
-~~~~~
+~~~~{.cpp}
p_Trsf T;
Standard_Real scale = 100; // for example!
T.SetScale (gp_Pnt (0, 0, 0), scale);
BRepTools_Modifier MD;
TopoDS_Shape res = ShapeCustom::ApplyModifier (
Shape, TM, context,MD );
-~~~~~
+~~~~
The map, called context in our example, contains the history.
Substitutions are made one by one and all shapes are transformed.
To determine what happens to a particular sub-shape, it is possible to use:
-~~~~~
+~~~~{.cpp}
TopoDS_Shape oneres = context.Find (oneshape);
//In case there is a doubt, you can also add:
if (context.IsBound(oneshape)) oneres = context.Find(oneshape);
TopoDs_Shape oneshape = iter.key ();
TopoDs_Shape oneres = iter.value ();
}
-~~~~~
+~~~~
@subsubsection occt_shg_4_4_7 Remove internal wires
The example of method application is also given below:
-~~~~~
+~~~~{.cpp}
//Initialization of the class by shape.
Handle(ShapeUpgrade_RemoveInternalWires) aTool = new ShapeUpgrade_RemoveInternalWires(inputShape);
//setting parameters
}
//getting result shape
TopoDS_Shape res = aTool->GetResult();
-~~~~~
+~~~~
@subsubsection occt_shg_4_4_8 Conversion of surfaces
The conversion is done only if the new (analytical) surface does not deviate from the source one more than by the given precision.
-~~~~~
+~~~~{.cpp}
Handle(Geom_Surface) initSurf;
ShapeCustom_Surface ConvSurf(initSurf);
//conversion to analytical form
Handle(Geom_Surface) newSurf = ConvSurf.ConvertToPeriodic(Standard_False);
//getting the maximum deviation of the new surface from the initial surface
Standard_Real maxdist = ConvSurf.Gap();
-~~~~~
+~~~~
@subsubsection occt_shg_4_4_9 Unify Same Domain
* Method *Generated()* is used to get a new common shape from the old shape. If a group of edges has been unified into one common edge then method *Generated()* called on any edge from this group will return the common edge. The same goes for the faces.
The example of the usage is given below:
-~~~~~
+~~~~{.cpp}
// 'Sh' is the initial shape
ShapeUpgrade_UnifySameDomain USD(Sh, true, true, true); // UnifyFaces mode on, UnifyEdges mode on, ConcatBSplines mode on.
USD.Build();
//Let Sh1 as a part of Sh
//get the new (probably unified) shape form the Sh1
TopoDS_Shape ResSh1 = USD.Generated(Sh1);
-~~~~~
+~~~~
@section occt_shg_5_ Auxiliary tools for repairing, analysis and upgrading
Let us use the tool to get the result shape after modification of sub-shapes of the initial shape:
-~~~~~
+~~~~{.cpp}
TopoDS_Shape initialShape…
//creation of a rebuilding tool
Handle(ShapeBuild_ReShape) Context = new ShapeBuild_ReShape.
//getting the resulting sub-shape from the subshape1 of the initial shape.
TopoDS_Shape result_subshape1 = Context->Apply(subshape1);
-~~~~~
+~~~~
@subsection occt_shg_5_2 Status definition
Let us remove edges from the wire and define whether it is seam edge
-~~~~~
+~~~~{.cpp}
TopoDS_Wire ini = ..
Handle(ShapeExtend_Wire) asewd = new ShapeExtend_Wire(initwire);
//Removing edge Edge1 from the wire.
//Definition of whether Edge2 is a seam edge
Standard_Integer index_edge2 = asewd->Index(Edge2);
asewd->IsSeam(index_edge2);
-~~~~~
+~~~~
@subsection occt_shg_5_4 Tool for exploring shapes
Let us send and get a message attached to object:
-~~~~~
+~~~~{.cpp}
Handle(ShapeExtend_MsgRegistrator) MessageReg = new ShapeExtend_MsgRegistrator;
//attaches messages to an object (shape or entity)
Message_Msg msg..
Message_Msg msg = iter.Value();
}
}
-~~~~~
+~~~~
@subsection occt_shg_5_6 Tools for performance measurement
Let us try to use timers in *XSDRAWIGES.cxx* and *IGESBRep_Reader.cxx* to analyse the performance of command *igesbrep*:
-~~~~~
+~~~~{.cpp}
XSDRAWIGES.cxx
...
#include <MoniTool_Timer.hxx>
}
...
}
-~~~~~
+~~~~
The result of *DumpTimer()* after file translation is as follows:
This function is used in the following way:
-~~~~~
+~~~~{.cpp}
TopoDS_Shape aShape = …;
Standard_Real Prec = …,
Standard_Real MaxTol = …;
TopoDS_Shape aResult;
Handle(Standard_Transient) info;
TopoDS_Shape aResult = XSAlgo::AlgoContainer()->ProcessShape(aShape, Prec, MaxTol., "Name of ResourceFile", "NameSequence", info );
-~~~~~
+~~~~
Let us create a custom sequence of operations:
1. Create a resource file with the name *ResourceFile*, which includes the following string:
-~~~~~
+~~~~{.cpp}
NameSequence.exec.op: MyOper
-~~~~~
+~~~~
where *MyOper* is the name of operation.
2. Input a custom parameter for this operation in the resource file, for example:
-~~~~~
+~~~~{.cpp}
NameSequence.MyOper.Tolerance: 0.01
-~~~~~
+~~~~
where *Tolerance* is the name of the parameter and 0.01 is its value.
3. Add the following string into *void ShapeProcess_OperLibrary::Init()*:
-~~~~~
+~~~~{.cpp}
ShapeProcess::RegisterOperator(;MyOper;,
new ShapeProcess_UOperator(myfunction));
-~~~~~
+~~~~
where *myfunction* is a function which implements the operation.
4. Create this function in *ShapeProcess_OperLibrary* as follows:
-~~~~~
+~~~~{.cpp}
static Standard_Boolean myfunction (const
Handle(ShapeProcess_Context)& context)
{
//receive our parameter:
Standard_Real toler;
ctx->GetReal(;Tolerance;, toler);
-~~~~~
+~~~~
5. Make the necessary operations with *aShape* using the received value of parameter *Tolerance* from the resource file.
-~~~~~
+~~~~{.cpp}
return Standard_True;
}
-~~~~~
+~~~~
6. Define some operations (with their parameters) *MyOper1, MyOper2, MyOper3*, etc. and describe the corresponding functions in *ShapeProcess_OperLibrary*.
7. Perform the required sequence using the specified name of operations and values of parameters in the resource file.
For example: input of the following string:
-~~~~~
+~~~~{.cpp}
NameSequence.exec.op: MyOper1,MyOper3
-~~~~~
+~~~~
means that the corresponding functions from *ShapeProcess_OperLibrary* will be performed with the original shape *aShape* using parameters defined for *MyOper1* and *MyOper3* in the resource file.
It is necessary to note that these operations will be performed step by step and the result obtained after performing the first operation will be used as the initial shape for the second operation.
The following example illustrates the structure of a message file:
-~~~~~
+~~~~{.cpp}
!This is a sample message file
!------------------------------
!Messages for ShapeAnalysis package
!...
!
!End of the message file
-~~~~~
+~~~~
### Loading the message file
A custom file can be loaded into memory using the method *Message_MsgFile::LoadFile*, taking as an argument the path to your file as in the example below:
-~~~~~
+~~~~{.cpp}
Standard_CString MsgFilePath = ;(path)/sample.file;;
Message_MsgFile::LoadFile (MsgFilePath);
-~~~~~
+~~~~
@subsection occt_shg_7_3 Tool for managing filling messages
* integer -- coded in the text as \%d,
* real -- coded in the text as \%f.
The parameter fields are filled by the message text by calling the corresponding methods *AddInteger, AddReal* and *AddString*. Both the original text of the message and the input text with substituted parameters are stored in the object. The prepared and filled message can be output to the default trace file. The text of the message (either original or filled) can be also obtained.
-~~~~~
+~~~~{.cpp}
Message_Msg msg01 (;SampleKeyword;);
//Creates the message msg01, identified in the file by the keyword SampleKeyword
msg1.AddInteger (73);
msg1.AddString (;SampleFile;);
//fills out the code areas
-~~~~~
+~~~~
@subsection occt_shg_7_4 Tool for managing trace files
* define an object of *Message_TraceFile*, with its own definition (file name or cout, trace level), and use it where it is defined,
* use the default trace file (file name or cout, trace level), usable from anywhere.
Use the constructor method to define the target file and the level of the messages as in the example below:
-~~~~~
+~~~~{.cpp}
Message_TraceFile myTF
(tracelevel, "tracefile.log", Standard_False);
-~~~~~
+~~~~
The parameters are as follows:
* *tracelevel* is a Standard_Integer and modifies the level of messages. It has the following values and semantics:
+ 0: gives general information such as the start and end of process;
@subsubsection occt_step_2_3_1 Loading the STEP file
Before performing any other operation you have to load the file with:
-~~~~~
+~~~~{.cpp}
STEPControl_Reader reader;
IFSelect_ReturnStatus stat = reader.ReadFile("filename.stp");
-~~~~~
+~~~~
Loading the file only memorizes the data, it does not translate it.
@subsubsection occt_step_2_3_2 Checking the STEP file
This step is not obligatory. Check the loaded file with:
-~~~~~
+~~~~{.cpp}
reader.PrintCheckLoad(failsonly,mode);
-~~~~~
+~~~~
Error messages are displayed if there are invalid or incomplete STEP entities, giving you the information on the cause of error.
If *failsonly* is true only fail messages are displayed. All messages are displayed if *failsonly* is false. Your analysis of the file can be either message-oriented or entity-oriented. Choose your preference with:
-~~~~~
+~~~~{.cpp}
IFSelect_PrintCount mode = IFSelect_xxx
-~~~~~
+~~~~
Where xxx can be one of the following:
* *ItemsByEntity* -- gives a sequential list of all messages per STEP entity,
* *CountByItem* -- gives the number of STEP entities with their types per message
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.precision.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("read.precision.mode",1))
.. error ..
-~~~~~
+~~~~
Default value is File (0).
<h4>read.precision.val:</h4>
This value is a basic value of tolerance in the processor. The value is in millimeters, independently of the length unit defined in the STEP file.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Real rp = Interface_Static::RVal("read.precision.val");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetRVal("read.precision.val",0.01))
.. error ..
-~~~~~
+~~~~
By default this value is 0.0001.
The value given to this parameter is a basic value for ShapeHealing algorithms and the processor. It does its best to reach it. Under certain circumstances, the value you give may not be attached to all of the entities concerned at the end of processing. STEP-to-OpenCASCADE translation does not improve the quality of the geometry in the original STEP file. This means that the value you enter may be impossible to attach to all shapes with the given quality of the geometry in the STEP file.
Defines the maximum allowed tolerance (in mm) of the shape. It should be not less than the basic value of tolerance set in the processor (either the uncertainty from the file or *read.precision.val*). Actually, the maximum between *read.maxprecision.val* and the basis tolerance is used to define the maximum allowed tolerance.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Real rp = Interface_Static::RVal("read.maxprecision.val");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetRVal("read.maxprecision.val",0.1))
.. error ..
-~~~~~
+~~~~
Default value is 1.
Note that maximum tolerance even explicitly defined by the user may be insufficient to ensure the validity of the shape (if real geometry is of bad quality). Therefore the user is provided with an additional parameter, which allows him to choose: either he prefers to ensure the shape validity or he rigidly sets the value of maximum tolerance. In the first case there is a possibility that the tolerance will not have any upper limit, in the second case the shape may be invalid.
* 1 (Forced) -- maximum tolerance is used as a rigid limit, i.e. no tolerance can exceed it and if it is the case, the tolerance is trimmed by the maximum tolerance.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.maxprecision.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("read.maxprecision.mode",1))
.. error ..
-~~~~~
+~~~~
Default value is 0 ("Preferred").
<h4>read.stdsameparameter.mode</h4>
The functionality of *BRepLib::SameParameter* is used through *ShapeFix_Edge::SameParameter*. It ensures that the resulting edge will have the lowest tolerance taking pcurves either unmodified from the STEP file or modified by *BRepLib::SameParameter*.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer mv = Interface_Static::IVal("read.stdsameparameter.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetIVal ("read.stdsameparameter.mode",1))
.. error ..;
-~~~~~
+~~~~
Default value is 0 (;Off;).
<h4>read.surfacecurve.mode:</h4>
* *3DUse_Preferred (3)* : 3D curves are used to rebuild 2D ones.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer rp = Interface_Static::IVal("read.surfacecurve.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("read.surfacecurve.mode",3))
.. error ..
-~~~~~
+~~~~
Default value is (0).
<h4>read.encoderegularity.angle</h4>
This parameter is used for call to *BRepLib::EncodeRegularity()* function which is called for the shape read from an IGES or a STEP file at the end of translation process. This function sets the regularity flag of the edge in the shell when this edge is shared by two faces. This flag shows the continuity these two faces are connected with at that edge.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Real era = Interface_Static::RVal("read.encoderegularity.angle");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetRVal ("read.encoderegularity.angle",0.1))
.. error ..;
-~~~~~
+~~~~
Default value is 0.01.
<h4>step.angleunit.mode</h4>
* 0 (OFF) -- *SHAPE_DEFINITION_REPRESENTATION* entities are taken as top-level ones; assembly is recognized by *CONTEXT_DEPENDENT_SHAPE_REPRESENTATION* entities. This is compatibility mode, which can be used for reading legacy STEP files produced by older versions of STEP translators and having incorrect or incomplete product information.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.step.product.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("read.step.product.mode",1))
.. error ..
-~~~~~
+~~~~
Default value is 1 (ON).
Note that the following parameters have effect only if *read.step.product.mode* is ON.
Note that in AP 203 and AP214 files all products should be marked as `design', so if this mode is set to `analysis', nothing will be read.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.step.product.context");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal(;read.step.product.context;,1))
.. error ..
-~~~~~
+~~~~
Default value is 1 (all).
<h4>read.step.shape.repr:</h4>
When this option is not equal to 1, for products with multiple representations the representation having a type closest to the selected one in this list will be translated.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.step.shape.repr");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("read.step.shape.repr",1))
.. error ..
-~~~~~
+~~~~
Default value is 1 (All).
<h4>read.step.assembly.level:</h4>
* 4 (shape) -- Translate only shapes associated with the product, ignoring the assembly structure (if any). This can be useful to translate only a shape associated with specific product, as a complement to *assembly* mode.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.step.assembly.level");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("read.step.assembly.level",1))
.. error ..
-~~~~~
+~~~~
Default value is 1 (All).
* 0 (OFF) -- do not translate
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.step.shape.relationship");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal(;read.step.shape.relationship;,1))
.. error ..
-~~~~~
+~~~~
Default value is 1 (ON).
<h4>read.step.shape.aspect:</h4>
* 0 (OFF) -- do not translate
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("read.step.shape.aspect");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal(;read.step.shape.aspect;,1))
.. error ..
-~~~~~
+~~~~
Default value is 1 (ON).
<h4>read.step.constructivegeom.relationship:</h4>
By default, the flag is set to 0 (OFF) so these entities are not translated.
Set this flag to 1 (ON) if you need to translate constructive geometry entities associated with the parts:
-~~~~~
+~~~~{.cpp}
if (!Interface_Static::SetIVal("read.step.constructivegeom.relationship", 1)) { .. error .. }
-~~~~~
+~~~~
The "CONSTRUCTIVE_GEOMETRY_REPRESENTATION" entity is translated into compound of two unlimited planar faces,
whose location is result of translation of corresponding "AXIS_PLACEMENT" entity.
The result of translation can be obtained either for the "CONSTRUCTIVE_GEOMETRY_REPRESENTATION_RELATIONSHIP" entity,
of for each of the two "AXIS2_PLACEMENT_3D" entities referenced by it. as follows:
-~~~~~
+~~~~{.cpp}
STEPControl_Reader aReader;
... // translate file and parse STEP model to find relevant axis entity
Handle(StepGeom_Axis2Placement3d) aSTEPAxis = ...;
}
}
}
-~~~~~
+~~~~
@subsubsection occt_step_2_3_4 Performing the STEP file translation
Each successful translation operation outputs one shape. A series of translations gives a set of shapes.
Each time you invoke *TransferOne(), TransferRoot()* or *TransferList()*, their results are accumulated and the counter of results increases. You can clear the results with:
-~~~~~
+~~~~{.cpp}
reader.ClearShapes();
-~~~~~
+~~~~
between two translation operations, if you do not, the results from the next translation will be added to the accumulation.
*TransferRoots()* operations automatically clear all existing results before they start.
<h5>Checking that translation was correctly performed</h5>
Each time you invoke *Transfer* or *TransferRoots()*, you can display the related messages with the help of:
-~~~~~
+~~~~{.cpp}
reader.PrintCheckTransfer(failsonly,mode);
-~~~~~
+~~~~
This check concerns the last invocation of *Transfer* or *TransferRoots()* only.
<h5>The whole file</h5>
Transferring the whole file means transferring all root entities. The number of roots can be evaluated when the file is loaded:
-~~~~~
+~~~~{.cpp}
Standard_Integer NbRoots = reader.NbRootsForTransfer();
Standard_Integer num = reader.TransferRoots();
-~~~~~
+~~~~
<h5>List of entities</h5>
A list of entities can be formed by invoking *STEP214Control_Reader::GiveList* (this is a method of the parent class).
Here is a simple example of how a list is translated:
-~~~~~
+~~~~{.cpp}
Handle(TColStd_HSequenceOfTransient) list = reader.GiveList();
-~~~~~
+~~~~
The result is a *TColStd_HSequenceOfTransient*.
You can either translate a list entity by entity or all at once. An entity-by-entity operation lets you check each individual entity translated.
<h5>Translating a whole list in one operation</h5>
-~~~~~
+~~~~{.cpp}
Standard_Integer nbtrans = reader.TransferList (list);
-~~~~~
+~~~~
*nbtrans* gives the number of items in the list that produced a shape.
<h5>Translating a list entity by entity:</h5>
-~~~~~
+~~~~{.cpp}
Standard_Integer i,nb = list->Length();
for (i = 1; i <= nb; i ++) {
Handle(Standard_Transient) ent = list->Value(i);
Standard_Boolean OK = reader.TransferEntity (ent);
}
-~~~~~
+~~~~
<h4>Selections</h4>
There is a number of predefined operators that can be used. They are:
<h5>Selection by rank</h5>
Use method *StepData_StepModel::NextNumberForLabel* to find its rank with the following:
-~~~~~
+~~~~{.cpp}
Standard_CString label = `#...';
StepData_StepModel model = reader.StepModel();
rank = model->NextNumberForLabe(label, 0, Standard_False);
-~~~~~
+~~~~
Translate an entity specified by its rank:
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = reader.Transfer (rank);
-~~~~~
+~~~~
<h5>Direct selection of an entity</h5>
*ent* is the entity. The argument is a *Handle(Standard_Transient)*.
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = reader.TransferEntity (ent);
-~~~~~
+~~~~
@subsection occt_step_2_4 Mapping STEP entities to Open CASCADE Technology shapes
Tables given in this paragraph show the mapping of STEP entities to OCCT objects. Only topological and geometrical STEP entities and entities defining assembly structures are described in this paragraph. For a full list of STEP entities, refer to Appendix A.
@figure{/user_guides/step/images/step_image003.png,"The structure of calls in reading STEP",420}
@subsection occt_step_2_7 Example
-~~~~~
+~~~~{.cpp}
#include <STEPControl_Reader.hxx>
#include <TopoDS_Shape.hxx>
#include <BRepTools.hxx>
. . .
}
-~~~~~
+~~~~
@section occt_step_3 Writing STEP
@subsection occt_step_3_3 Description of the process
@subsubsection occt_step_3_3_1 Initializing the process
Before performing any other operation you have to create a writer object:
-~~~~~
+~~~~{.cpp}
STEPControl_Writer writer;
-~~~~~
+~~~~
@subsubsection occt_step_3_3_2 Setting the translation parameters
The following parameters are used for the OCCT-to-STEP translation.
Standard_Integer ic = Interface_Static::IVal("write.precision.mode");
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("write.precision.mode",1))
.. error ..
-~~~~~
+~~~~
Default value is 0.
<h4>write.precision.val</h4>
This value is stored in shape_representation in a STEP file as an uncertainty.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Real rp = Interface_Static::RVal("write.precision.val");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetRVal("write.precision.val",0.01))
.. error ..
-~~~~~
+~~~~
Default value is 0.0001.
<h4>write.step.assembly</h4>
* 2 (Auto) : writes shapes having a structure of (possibly nested) *TopoDS_Compounds* in the form of STEP assemblies, single shapes are written without assembly structures.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer rp = Interface_Static::IVal("write.step.assembly");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("write.step.assembly",1))
.. error ..
-~~~~~
+~~~~
Default value is 0.
<h4>write.step.schema</h4>
* 5 or *AP242DIS*: AP242, DIS version.
Read this parameter with:
-~~~~~
+~~~~{.cpp}
TCollection_AsciiString schema = Interface_Static::CVal("write.step.schema");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetCVal("write.step.schema","DIS"))
.. error ..
-~~~~~
+~~~~
Default value is 1 (;CD;).
For the parameter *write.step.schema* to take effect, method *STEPControl_Writer::Model(Standard_True)* should be called after changing this parameter (corresponding command in DRAW is *newmodel*).
* On (1) : (default) writes pcurves to STEP file
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer wp = Interface_Static::IVal("write.surfacecurve.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("write.surfacecurve.mode",1))
.. error ..
-~~~~~
+~~~~
Default value is On.
<h4>write.step.unit</h4>
* 1 (Single Vertex) : Each vertex exported in its own SHAPE DEFINITION REPRESENTATION (vertex name and style are not lost, but size of STEP file increases).
Read this parameter with:
-~~~~~
+~~~~{.cpp}
Standard_Integer ic = Interface_Static::IVal("write.step.vertex.mode");
-~~~~~
+~~~~
Modify this parameter with:
-~~~~~
+~~~~{.cpp}
if(!Interface_Static::SetIVal("write.step.vertex.mode",1))
.. error ..
-~~~~~
+~~~~
Default value is 0.
@subsubsection occt_step_3_3_3 Performing the Open CASCADE Technology shape translation
If *TopoDS_Compound* contains any other types besides the ones mentioned in the table, these sub-shapes will be ignored.
In case if an OCCT shape cannot be translated according to its mode the result of translation is void.
-~~~~~
+~~~~{.cpp}
STEP214Control_StepModelTope mode = STEP214Control_ManifoldSolidBrep;
IFSelect_ReturnStatus stat = writer.Transfer(shape,mode);
-~~~~~
+~~~~
@subsubsection occt_step_3_3_4 Writing the STEP file
Write the STEP file with:
-~~~~~
+~~~~{.cpp}
IFSelect_ReturnStatus stat = writer.Write("filename.stp");
-~~~~~
+~~~~
to give the file name.
@subsection occt_step_3_4 Mapping Open CASCADE Technology shapes to STEP entities
@subsection occt_step_3_7 Example
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.cpp}
+~~~~{.cpp}
#include <STEPControl.hxx>
#include <STEPControl_Writer.hxx>
#include <TopoDS_Shape.hxx>
// writes the resulting entity in the STEP file
}
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+~~~~
@section occt_step_4 Physical STEP file reading and writing
@subsection occt_step_6_2 Setting the interface parameters
A set of parameters for importing and exporting STEP data is defined in the XSTEP resource file. In XSDRAW, these parameters can be viewed or changed using the command
-~~~~~
+~~~~{.php}
Draw:> param [<parameter_name> [<value>]]
-~~~~~
+~~~~
Command *param* with no arguments gives a list of all parameters with their values. When the argument *parameter_name* is specified, information about this parameter is printed (current value and short description).
The third argument is used to set a new value of the given parameter. The result of the setting is printed immediately.
It is possible either only to load a STEP file into memory (i.e. fill the *InterfaceModel* with data from the file), or to read it (i.e. load and convert all entities to OCCT shapes).
Loading is done by the command
-~~~~~
+~~~~{.php}
Draw:> xload <file_name>
-~~~~~
+~~~~
Once the file is loaded, it is possible to investigate the structure of the loaded data. To find out how you do it, look in the beginning of the analysis subsection.
Reading a STEP file is done by the command
-~~~~~
+~~~~{.php}
Draw:> stepread <file_name> <result_shape_name> [selection]
-~~~~~
+~~~~
Here a dot can be used instead of a filename if the file is already loaded by xload or stepread.
The optional selection (see below for a description of selections) specifies a set of entities to be translated. If an asterisk `*' is given, all transferable roots are translated. If a selection is not given, the user is prompted to define a scope of transfer interactively:
General statistics on the loaded data can be obtained by using the command
-~~~~
+~~~~{.php}
Draw:> data <symbol>
~~~~
The list cannot be shown for all entities but for a subset of them. This subset is defined by an optional selection argument (for the list of possible values for STEP, see the table above).
Two commands are used to calculate statistics on the entities in the model:
-~~~~~
+~~~~{.php}
Draw:> count <counter> [<selection>]
Draw:> listcount <counter> [<selection>]
-~~~~~
+~~~~
The former only prints a count of entities while the latter also gives a list of them.
The optional selection argument, if specified, defines a subset of entities, which are to be taken into account. The first argument should be one of the currently defined counters:
Several shapes can be written in one file. To start writing a new file, enter command *Draw:> newmodel*.
Actually, command *newmodel* will clear the *InterfaceModel* to empty it, and the next command will convert the specified shape to STEP entities and add them to the *InterfaceModel*:
-~~~~~
+~~~~{.php}
Draw:> stepwrite <mode> <shape_name> [<file_name>]
-~~~~~
+~~~~
The following modes are available :
* *a* -- "as is" -- the mode is selected automatically depending on the type & geometry of the shape;
* *s* -- *shell_based_surface_model*
After a successful translation, if *file_name* parameter is not specified, the procedure asks you whether to write a STEP model in the file or not:
-~~~~~
+~~~~{.php}
execution status : 1
Mode (0 end, 1 file) :
-~~~~~
+~~~~
It is necessary to call command *newmodel* to perform a new translation of the next OCCT shape.
@section occt_step_7 Reading from and writing to STEP
### Load a STEP file
Before performing any other operation, you must load a STEP file with:
-~~~~~
+~~~~{.cpp}
STEPCAFControl_Reader reader(XSDRAW::Session(), Standard_False);
IFSelect_ReturnStatus stat = reader.ReadFile("filename.stp");
-~~~~~
+~~~~
Loading the file only memorizes the data, it does not translate it.
### Check the loaded STEP file
In addition, the following parameters can be set for XDE translation of attributes:
* Parameter for transferring colors:
-~~~~~
+~~~~{.cpp}
reader.SetColorMode(mode);
// mode can be Standard_True or Standard_False
-~~~~~
+~~~~
* Parameter for transferring names:
-~~~~~
+~~~~{.cpp}
reader.SetNameMode(mode);
// mode can be Standard_True or Standard_False
-~~~~~
+~~~~
### Translate a STEP file to XDE
The following function performs a translation of the whole document:
-~~~~~
+~~~~{.cpp}
Standard_Boolean ok = reader.Transfer(doc);
-~~~~~
+~~~~
where *doc* is a variable which contains a handle to the output document and should have a type *Handle(TDocStd_Document)*.
@subsection occt_step_7_3 Writing to STEP
The translation from XDE to STEP can be initialized as follows:
-~~~~~
+~~~~{.cpp}
STEPCAFControl_Writer aWriter(XSDRAW::Session(),Standard_False);
-~~~~~
+~~~~
### Set parameters for translation from XDE to STEP
The following parameters can be set for a translation of attributes to STEP:
* For transferring colors:
-~~~~~
+~~~~{.cpp}
aWriter.SetColorMode(mode);
// mode can be Standard_True or Standard_False
-~~~~~
+~~~~
* For transferring names:
-~~~~~
+~~~~{.cpp}
aWriter.SetNameMode(mode);
// mode can be Standard_True or Standard_False
-~~~~~
+~~~~
### Translate an XDE document to STEP
You can perform the translation of document by calling the function:
-~~~~~
+~~~~{.cpp}
IFSelect_ReturnStatus aRetSt = aWriter.Transfer(doc);
-~~~~~
+~~~~
where *doc* is a variable, which contains a handle to the input document for transferring and should have a type *Handle(TDocStd_Document)*.
### Write a STEP file
Write a STEP file with:
-~~~~~
+~~~~{.cpp}
IFSelect_ReturnStatus statw = aWriter.WriteFile("filename.stp");
-~~~~~
+~~~~
or
-~~~~~
+~~~~{.cpp}
IFSelect_ReturnStatus statw = writer.WriteFile (S);
-~~~~~
+~~~~
where *S* is *OStream*.
@subsection occt_step_7_4 Attributes written to STEP
See the same item in section @ref occt_step_7_1 "Reading from STEP" to find more information.
Note: OCCT use AP214 by default, so for GD&T exporting AP242 should be set manually:
-~~~~~
+~~~~{.cpp}
Interface_Static::SetCVal("write.step.schema", "AP242DIS"));
-~~~~~
+~~~~
or
-~~~~~
+~~~~{.cpp}
Interface_Static::SetIVal("write.step.schema", 5));
-~~~~~
+~~~~
### Saved views
Saved Views are not exported by OCCT.
To visualize an OCCT topological shape in VTK viewer, it is necessary to perform the following steps:
1. Create *IVtkOCC_Shape* instance (VIS wrapper for OCCT shape) and initialize it with *TopoDS_Shape* object containing the actual geometry:
-~~~~
+~~~~{.cpp}
TopoDS_Shape aShape;
// Initialize aShape variable: e.g. load it from BREP file
IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape(aShape);
~~~~
2. Create VTK polygonal data source for the target OCCT topological shape and initialize it with created *IVtkOCC_Shape* instance. At this stage the faceter is implicitly plugged:
-~~~~
+~~~~{.cpp}
vtkSmartPointer<IVtkTools_ShapeDataSource> DS = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
DS->SetShape(aShapeImpl);
~~~~
3. Visualize the loaded shape in usual VTK way starting a pipeline from the newly created specific source:
-~~~~
+~~~~{.cpp}
vtkSmartPointer<vtkPolyDataMapper> Mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
Mapper->SetInputConnection(aDS->GetOutputPort());
~~~~
It is always possible to access the shape data source from VTK actor by means of dedicated methods from *IVtkTools_ShapeObject* class:
-~~~~
+~~~~{.cpp}
IVtkTools_ShapeDataSource* DS = IVtkTools_ShapeObject::GetShapeSource(Actor);
IVtkOCC_Shape::Handle occShape = IVtkTools_ShapeObject::GetOccShape(Actor);
~~~~
It is also possible to get a shape wrapper from the shape data source:
-~~~~
+~~~~{.cpp}
IVtkOCC_Shape::Handle occShape = DS->GetShape();
~~~~
To colorize different parts of a shape according to the default OCCT color scheme, it is possible to configure the corresponding VTK mapper using a dedicated auxiliary function of *IVtkTools* namespace:
-~~~~
+~~~~{.cpp}
IVtkTools::InitShapeMapper(Mapper);
~~~~
It is possible to get an instance of *vtkLookupTable class* with a default OCCT color scheme by means of the following method:
-~~~~
+~~~~{.cpp}
vtkSmartPointer<vtkLookupTable> Table = IVtkTools::InitLookupTable();
~~~~
@subsubsection occt_vis_3_2_2 Custom color scheme
To set up application-specific colors for a shape presentation, use *InitShapeMapper* function with an additional argument passing a custom lookup table:
-~~~~
+~~~~{.cpp}
IVtkTools::InitShapeMapper(Mapper, Table);
~~~~
@subsubsection occt_vis_3_2_3 Setting custom colors for sub-shapes
It is also possible to bind custom colors to any sub-shape type listed in *IVtk_MeshType* enumeration. For example, to access the color bound to *free edge* entities, the following calls are available in *IVtkTools* namespace:
-~~~~
+~~~~{.cpp}
SetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B);
SetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B, A);
GetLookupTableColor(aLookupTable, MT_FreeEdge, R, G, B);
As VTK color mapping approach is based on associating scalar data arrays to VTK cells, the coloring of shape components can be turned on/off in the following way:
-~~~~
+~~~~{.cpp}
Mapper->ScalarVisibilityOn(); // use colors from lookup table
Mapper->ScalarVisibilityOff(); // use a color of actor’s property
~~~~
For example, the shading representation can be obtained in the following way:
-~~~~
+~~~~{.cpp}
vtkSmartPointer<IVtkTools_ShapeDataSource> DS = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
vtkSmartPointer<IVtkTools_DisplayModeFilter> DMFilter = vtkSmartPointer<IVtkTools_DisplayModeFilter>::New();
@subsection occt_vis_3_4 Interactive selection
*IVtkTools* package provides *IVtkTools_ShapePicker* class to perform selection of OCCT shapes and sub-shapes in VTK viewer and access the picking results. The typical usage of *IVtkTools_ShapePicker* tool consists in the following sequence of actions:
1. Create a picker and set its renderer to your active VTK renderer:
-~~~~
+~~~~{.cpp}
vtkSmartPointer<IVtkTools_ShapePicker> aPicker = vtkSmartPointer<IVtkTools_ShapePicker>::New();
aPicker->SetRenderer(aRenderer);
~~~~
2. Activate the desired selection mode by choosing the corresponding sub-shape types from *IVtk_SelectionMode* enumeration. For example, the following call allows selection of edges on all selectable shape actors of the renderer:
-~~~~
+~~~~{.cpp}
aPicker->SetSelectionMode(SM_Edge);
~~~~
If it is necessary to limit selection by a particular shape actor, one can use the mentioned *SetSelectionMode* method with *IVtk_IShape* handle or *vtkActor* pointer as the first argument:
-~~~~
+~~~~{.cpp}
IVtk_IShape::Handle aShape = new IVtkOCC_Shape(occShape);
aPicker->SetSelectionMode(aShape, SM_Edge); // If shape handle is available
aPicker->SetSelectionMode(anActor, SM_Edge); // If shape actor is available
~~~~
Different selection modes can be turned on/off for a picker at the same time independently from each other.
-~~~~
+~~~~{.cpp}
aPicker->SetSelectionMode(SM_Edge);
aPicker->SetSelectionMode(SM_Face);
~~~~
To turn off a selection mode, the additional optional Boolean parameter is used with *false* value, for example:
-~~~~
+~~~~{.cpp}
aPicker->SetSelectionMode(aShape, SM_Edge, false);
~~~~
3. Call *Pick* method passing the mouse display coordinates:
-~~~~
+~~~~{.cpp}
aPicker->Pick(x, y, 0);
~~~~
By default, the renderer passed in the step 1 is used. In order to perform pick operation for another renderer an additional optional parameter can be specified:
-~~~~
+~~~~{.cpp}
aPicker->Pick(x, y, 0, aRenderer);
~~~~
4. Obtain the top-level picking results as a collection of picked VTK actors:
-~~~~
+~~~~{.cpp}
vtkActorCollection* anActorCollection = aPicker->GetPickedActors();
~~~~
or as a collection of picked shape IDs:
-~~~~
+~~~~{.cpp}
IVtk_ShapeIdList ids = aPicker->GetPickedShapesIds();
~~~~
These methods return a single top picked actor or a shape by default. To get all the picked actors or shapes it is necessary to send “true” value in the optional Boolean parameter:
-~~~~
+~~~~{.cpp}
anActorCollection = aPicker->GetPickedActors(true);
ids = aPicker->GetPickedShapesIds(true);
~~~~
5. Obtain the picked sub-shape IDs:
-~~~~
+~~~~{.cpp}
IVtk_ShapeIdList subShapeIds = aPicker->GetPickedSubShapesIds(shapeId);
~~~~
This method also returns a single ID of a top-level picked sub-shape and has the same optional Boolean parameter to get all the picked sub-shapes of a shape:
-~~~~
+~~~~{.cpp}
subShapeIds = aPicker->GetPickedSubShapesIds(shapeId, true);
~~~~
For example, sub-shapes can be represented in VTK viewer in the following way:
-~~~~
+~~~~{.cpp}
// Load a shape into data source (see 3.1)
...
vtkSmartPointer<IVtkTools_ShapeDataSource> DS = vtkSmartPointer<IVtkTools_ShapeDataSource>::New();
The visualization pipeline for OCCT shape presentation can be initialized as follows:
1. Create an instance of *IShape* class initialized by OCCT topological shape:
-~~~~
+~~~~{.cpp}
TopoDS_Shape aShape;
// Load or create a TopoDS_Shape in the variable a Shape
IVtkOCC_Shape::Handle aShapeImpl = new IVtkOCC_Shape(aShape);
~~~~
2. Create an empty instance of IShapeData implementation for VTK:
-~~~~
+~~~~{.cpp}
IVtk_IShapeData::Handle aDataImpl = new IVtkVTK_ShapeData();
~~~~
3 Create an instance of *IShapeMesher* implementation for OCCT (any faceter can be used at this stage):
-~~~~
+~~~~{.cpp}
IVtk_IShapeMesher::Handle aMesher = new IVtkOCC_ShapeMesher();
~~~~
4 Triangulate the OCCT topological shape by means of the Mesher and access the result:
-~~~~
+~~~~{.cpp}
aMesher->Build (aShapeImpl, aDataImpl);
vtkPolyData* aPolyData = aDataImpl->GetVtkPolyData();
The typical usage of *IVtk_IShapePickerAlgo* consists in the following sequence of actions:
1. Create an instance of the picker class:
-~~~~
+~~~~{.cpp}
IVtkOCC_ShapePickerAlgo::Handle Picker = new IVtkOCC_ShapePickerAlgo();
~~~~
2. Set an instance of *IVtk_IView* class to the algorithm in order to define the viewer parameters:
-~~~~
+~~~~{.cpp}
IVtkVTK_View::Handle View = new IVtkVTK_View(Renderer);
Picker->SetView(View);
~~~~
3. Activate the desired selection modes using values from *IVtk_SelectionMode* enumeration. For example, the following call allows selection of edges:
-~~~~
+~~~~{.cpp}
TopoDS_Shape aShape;
// Load or create a TopoDS_Shape in the variable a Shape
...
~~~~
Different selection modes can be turned on/off for a picker at the same time independently from each other.
To turn off a selection mode the additional optional Boolean parameter is used with *false* value, for example:
-~~~~
+~~~~{.cpp}
myOccPickerAlgo->SetSelectionMode(occShape, SM_Edge, false);
~~~~
4. Call *Pick* method passing the mouse coordinates:
-~~~~
+~~~~{.cpp}
myOccPickerAlgo->Pick(x, y);
~~~~
5. Obtain top-level picking results as IDs of the picked top-level shapes:
-~~~~
+~~~~{.cpp}
IVtk_ShapeIdList ids = myOccPickerAlgo->ShapesPicked();
~~~~
6. Obtain IDs of the picked sub-shapes:
-~~~~
+~~~~{.cpp}
IVtk_ShapeIdList subShapeIds
= myOccPickerAlgo->SubShapesPicked(shapeId);
~~~~
@subsubsection occt_visu_2_1_3 A Basic Example: How to display a 3D object
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(V3d_Viewer) theViewer;
Handle(AIS_InteractiveContext) aContext = new AIS_InteractiveContext (theViewer);
TopoDS_Solid aShape = aWedgeMaker.Solid();
Handle(AIS_Shape) aShapePrs = new AIS_Shape (aShape); // creation of the presentable object
aContext->Display (aShapePrs, AIS_Shaded, 0, true); // display the presentable object and redraw 3d viewer
-~~~~~
+~~~~
The shape is created using the *BRepPrimAPI_MakeWedge* command.
An *AIS_Shape* is then created from the shape.
The code snippet below illustrates the above steps.
It also contains the code to start the detection procedure and parse the results of selection.
-~~~~~{.cpp}
+~~~~{.cpp}
// Suppose there is an instance of class InteractiveBox from the previous sample.
// It contains an implementation of method InteractiveBox::ComputeSelection() for selection
// modes 0 (whole box must be selected) and 1 (edge of the box must be selectable)
// deactivate all selection modes for aBox1
theContext->Deactivate (aBox1);
-~~~~~
+~~~~
It is also important to know, that there are 2 types of detection implemented for rectangular selection in OCCT:
- <b>inclusive</b> detection.
The standard OCCT selection mechanism uses inclusion detection by default.
To change this, use the following code:
-~~~~~{.cpp}
+~~~~{.cpp}
// Assume there is a created interactive context
const Handle(AIS_InteractiveContext) theContext;
// Retrieve the current viewer selector
const Handle(StdSelect_ViewerSelector3d)& aMainSelector = theContext->MainSelector();
// Set the flag to allow overlap detection
aMainSelector->AllowOverlapDetection (true);
-~~~~~
+~~~~
@section occt_visu_3 Application Interactive Services
@subsection occt_visu_3_1 Introduction
#### For 3D:
-~~~~~{.cpp}
+~~~~{.cpp}
void PackageName_ClassName::Compute (const Handle(PrsMgr_PresentationManager)& thePresentationManager,
const Handle(Prs3d_Presentation)& thePresentation,
const Standard_Integer theMode);
-~~~~~
+~~~~
#### For hidden line removal (HLR) mode in 3D:
-~~~~~{.cpp}
+~~~~{.cpp}
void PackageName_ClassName::Compute (const Handle(Prs3d_Projector)& theProjector,
const Handle(Prs3d_Presentation)& thePresentation);
-~~~~~
+~~~~
@subsubsection occt_visu_3_2_2 Hidden Line Removal
Let us take for example the class called *IShape* representing an interactive object:
-~~~~~{.cpp}
+~~~~{.cpp}
myPk_IShape::myPk_IShape (const TopoDS_Shape& theShape, PrsMgr_TypeOfPresentation theType)
: AIS_InteractiveObject (theType), myShape (theShape) { SetHilightMode (0); }
// Hidden line mode calculation algorithm
StdPrs_HLRPolyShape::Add (thePrs, myShape, myDrawer, theProjector);
}
-~~~~~
+~~~~
@subsubsection occt_visu_3_2_4 Selection
* *vlistconnected* : Lists objects in the assembly.
Have a look at the examples below:
-~~~~~
+~~~~{.php}
pload MODELING VISUALIZATION
vinit
psphere s 1
vdisplay s
vconnectto s2 3 0 0 s # make instance
vfit
-~~~~~
+~~~~
See how proxy *OpenGl_Structure* is used to represent instance:
The original object does not have to be displayed in order to make instance.
Also selection handles transformations of instances correctly:
-~~~~~
+~~~~{.php}
pload MODELING VISUALIZATION
vinit
psphere s 1
vsetloc s -2 0 0
vconnect x 3 0 0 s p # make assembly
vfit
-~~~~~
+~~~~
@figure{/user_guides/visualization/images/visualization_image030.png,"",420}
Here is the example of a more complex hierarchy involving sub-assemblies:
-~~~~~
+~~~~{.php}
pload MODELING VISUALIZATION
vinit
box b 1 1 1
vconnect z2 4 0 0 d d2
vconnect z3 6 0 0 z z2
vfit
-~~~~~
+~~~~
@subsection occt_visu_3_3 Interactive Context
There is one essential rule to follow: the modification of an interactive object, which is already known by the Context, must be done using Context functions.
You can only directly call the functions available for an interactive object if it has not been loaded into an Interactive Context.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(AIS_Shape) aShapePrs = new AIS_Shape (theShape);
myIntContext->Display (aShapePrs, AIS_Shaded, 0, false, aShapePrs->AcceptShapeDecomposition());
myIntContext->SetColor(aShapePrs, Quantity_NOC_RED);
-~~~~~
+~~~~
You can also write
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(AIS_Shape) aShapePrs = new AIS_Shape (theShape);
aShapePrs->SetColor (Quantity_NOC_RED);
aShapePrs->SetDisplayMode (AIS_Shaded);
myIntContext->Display (aShapePrs);
-~~~~~
+~~~~
@subsubsection occt_visu_3_3_2 Groups of functions
Let us examine the case of two interactive objects: *theObj1* and *theObj2*:
-~~~~~{.cpp}
+~~~~{.cpp}
theCtx->Display (theObj1, false);
theCtx->Display (theObj2, true); // TRUE for viewer update
theCtx->SetDisplayMode (theObj1, 3, false);
theCtx->SetDisplayMode (2, true);
// theObj2 is visualized in mode 2 (if it accepts this mode)
// theObj1 stays visualized in its mode 3
-~~~~~
+~~~~
*PrsMgr_PresentationManager* and *SelectMgr_ViewerSelector3d*, which manage the presentation and selection of present interactive objects, are associated to the main Viewer.
#### Example
-~~~~~{.cpp}
+~~~~{.cpp}
// shading visualization mode, no specific mode, authorization for decomposition into sub-shapes
const TopoDS_Shape theShape;
Handle(AIS_Shape) aShapePrs = new AIS_Shape (theShape);
// only faces of revolution or planar faces will be selected
myContext->MoveTo (thePixelX, thePixelY, myView, true);
-~~~~~
+~~~~
@subsubsection occt_visu_3_4_6 Selection
Highlighting of detected and selected entities is automatically managed by the Interactive Context.
The Highlight colors are those dealt with above. You can nonetheless disconnect this automatic mode if you want to manage this part yourself:
-~~~~~{.cpp}
+~~~~{.cpp}
AIS_InteractiveContext::SetAutomaticHilight
AIS_InteractiveContext::AutomaticHilight
-~~~~~
+~~~~
You can question the Interactive context by moving the mouse.
The following functions can be used:
#### Example
-~~~~~{.cpp}
+~~~~{.cpp}
for (myAISCtx->InitSelected(); myAISCtx->MoreSelected(); myAISCtx->NextSelected())
{
Handle(SelectMgr_EntityOwner) anOwner = myAISCtx->SelectedOwner();
TopoDS_Shape aShape = aBRepOwner->Shape();
}
}
-~~~~~
+~~~~
@subsubsection occt_visu_3_4_7 Selection schemes
The class *AIS_ColoredShape* allows using custom colors and line widths for *TopoDS_Shape* objects and their sub-shapes.
-~~~~~{.cpp}
+~~~~{.cpp}
AIS_ColoredShape aColoredShape = new AIS_ColoredShape (theShape);
// setup color of entire shape
// customize line width of specified sub-shape
aColoredShape->SetCustomWidth (theSubShape, 0.25);
-~~~~~
+~~~~
The presentation class *AIS_PointCloud* can be used for efficient drawing of large arbitrary sets of colored points.
It uses *Graphic3d_ArrayOfPoints* to pass point data into OpenGl graphic driver to draw a set points as an array of "point sprites".
@figure{point_cloud.png,"A random colored cloud of points",240}
Example:
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(Graphic3d_ArrayOfPoints) aPoints = new Graphic3d_ArrayOfPoints (2000, Standard_True);
aPoints->AddVertex (gp_Pnt(-40.0, -40.0, -40.0), Quantity_Color (Quantity_NOC_BLUE1));
aPoints->AddVertex (gp_Pnt (40.0, 40.0, 40.0), Quantity_Color (Quantity_NOC_BLUE2));
Handle(AIS_PointCloud) aPntCloud = new AIS_PointCloud();
aPntCloud->SetPoints (aPoints);
-~~~~~
+~~~~
The draw command *vpointcloud* builds a cloud of points from shape triangulation.
This command can also draw a sphere surface or a volume with a large amount of points (more than one million).
Moreover, you can redefine the base builder class and provide your own presentation builder.
You can add/remove builders using the following methods:
-~~~~~{.cpp}
+~~~~{.cpp}
MeshVS_Mesh::AddBuilder (const Handle(MeshVS_PrsBuilder)& theBuilder, Standard_Boolean theToTreatAsHilighter);
MeshVS_Mesh::RemoveBuilder (const Standard_Integer theIndex);
MeshVS_Mesh::RemoveBuilderById (const Standard_Integer theId);
-~~~~~
+~~~~
There is a set of reserved display and highlighting mode flags for *MeshVS_Mesh*.
Mode value is a number of bits that allows selecting additional display parameters and combining the following mode flags,
which allow displaying mesh in wireframe, shading and shrink modes:
-~~~~~{.cpp}
+~~~~{.cpp}
MeshVS_DMF_WireFrame
MeshVS_DMF_Shading
MeshVS_DMF_Shrink
-~~~~~
+~~~~
It is also possible to display deformed mesh in wireframe, shading or shrink modes using:
-~~~~~{.cpp}
+~~~~{.cpp}
MeshVS_DMF_DeformedPrsWireFrame
MeshVS_DMF_DeformedPrsShading
MeshVS_DMF_DeformedPrsShrink
-~~~~~
+~~~~
The following methods represent different kinds of data:
-~~~~~{.cpp}
+~~~~{.cpp}
MeshVS_DMF_VectorDataPrs
MeshVS_DMF_NodalColorDataPrs
MeshVS_DMF_ElementalColorDataPrs
MeshVS_DMF_TextDataPrs
MeshVS_DMF_EntitiesWithData
-~~~~~
+~~~~
The following methods provide selection and highlighting:
-~~~~~{.cpp}
+~~~~{.cpp}
MeshVS_DMF_SelectionPrs
MeshVS_DMF_HilightPrs
-~~~~~
+~~~~
*MeshVS_DMF_User* is a user-defined mode.
Such an object, for example, can be used for displaying the object and stored in the STL file format:
-~~~~~{.cpp}
+~~~~{.cpp}
// read the data and create a data source
Handle(Poly_Triangulation) aSTLMesh = RWStl::ReadFile (aFileName);
Handle(XSDRAWSTLVRML_DataSource) aDataSource = new XSDRAWSTLVRML_DataSource (aSTLMesh);
// use default presentation builder
Handle(MeshVS_MeshPrsBuilder) aBuilder = new MeshVS_MeshPrsBuilder (aMeshPrs);
aMeshPrs->AddBuilder (aBuilder, true);
-~~~~~
+~~~~
*MeshVS_NodalColorPrsBuilder* allows representing a mesh with a color scaled texture mapped on it.
To do this you should define a color map for the color scale, pass this map to the presentation builder, and define an appropriate value in the range of 0.0 - 1.0 for every node.
The following example demonstrates how you can do this (check if the view has been set up to display textures):
-~~~~~{.cpp}
+~~~~{.cpp}
// assign nodal builder to the mesh
Handle(MeshVS_NodalColorPrsBuilder) aBuilder = new MeshVS_NodalColorPrsBuilder (theMeshPrs, MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
aBuilder->UseTexture (true);
aBuilder->SetInvalidColor (Quantity_NOC_BLACK);
aBuilder->SetTextureCoords (aScaleMap);
aMesh->AddBuilder (aBuilder, true);
-~~~~~
+~~~~
@subsection occt_visu_3_6 Dynamic Selection
The following example shows how to define an array of points:
-~~~~~{.cpp}
+~~~~{.cpp}
// create an array
Handle(Graphic3d_ArrayOfPoints) anArray = new Graphic3d_ArrayOfPoints (theVerticiesMaxCount);
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->AddPrimitiveArray (anArray);
aGroup->SetGroupPrimitivesAspect (myDrawer->PointAspect()->Aspect());
-~~~~~
+~~~~
If the primitives share the same vertices (polygons, triangles, etc.) then you can define them as indices of the vertices array.
The method *Graphic3d_ArrayOfPrimitives::AddEdge* allows defining the primitives by indices.
The following example shows how to define an array of triangles:
-~~~~~{.cpp}
+~~~~{.cpp}
// create an array
Handle(Graphic3d_ArrayOfTriangles) anArray = new Graphic3d_ArrayOfTriangles (theVerticesMaxCount, theEdgesMaxCount, Graphic3d_ArrayFlags_None);
// add vertices to the array
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aGroup->AddPrimitiveArray (anArray);
aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
-~~~~~
+~~~~
@subsubsection occt_visu_4_2_5 Text primitive
The text attributes for the group could be defined with the *Graphic3d_AspectText3d* attributes group.
To add any text to the graphic structure you can use the following methods:
-~~~~~{.cpp}
+~~~~{.cpp}
void Graphic3d_Group::AddText (const Handle(Graphic3d_Text)& theTextParams,
const Standard_Boolean theToEvalMinMax);
-~~~~~
+~~~~
You can pass FALSE as *theToEvalMinMax* if you do not want the Graphic3d structure boundaries to be affected by the text position.
**Note** that the text orientation angle can be defined by *Graphic3d_AspectText3d* attributes.
See the example:
-~~~~~{.cpp}
+~~~~{.cpp}
// get the group
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
aText->SetText ("Text");
aText->SetPosition (gp_Pnt (1, 1, 1));
aGroup->AddText (aText);
-~~~~~
+~~~~
@subsubsection occt_visu_4_2_6 Materials
Custom shaders can be assigned to a generic presentation by its drawer attributes (Graphic3d aspects).
To enable custom shader for a specific AIS_Shape in your application, the following API functions can be used:
-~~~~~{.cpp}
+~~~~{.cpp}
// Create shader program
Handle(Graphic3d_ShaderProgram) aProgram = new Graphic3d_ShaderProgram();
// Set aspect property for specific AIS_Shape
theAISShape->Attributes()->ShadingAspect()->Aspect()->SetShaderProgram (aProgram);
-~~~~~
+~~~~
@subsection occt_visu_4_3 Graphic attributes
This sample TEST program for the *V3d* Package uses primary packages *Xw* and *Graphic3d* and secondary packages *Visual3d, Aspect, Quantity* and *math*.
-~~~~~{.cpp}
+~~~~{.cpp}
// create a default display connection
Handle(Aspect_DisplayConnection) aDispConnection = new Aspect_DisplayConnection();
// create a Graphic Driver
aView->Update();
// Fit view to object size
aView->FitAll();
-~~~~~
+~~~~
@subsubsection occt_visu_4_4_3 Define viewing parameters
Most common view manipulations (panning, zooming, rotation) are implemented as convenience methods of *V3d_View* class or by *AIS_ViewController* tool.
However *Graphic3d_Camera* class can also be used directly by application developers.
Example:
-~~~~~{.cpp}
+~~~~{.cpp}
// rotate camera by X axis on 30.0 degrees
gp_Trsf aTrsf;
aTrsf.SetRotation (gp_Ax1 (gp_Pnt (0.0, 0.0, 0.0), gp_Dir (1.0, 0.0, 0.0)), M_PI / 4.0);
aView->Camera()->Transform (aTrsf);
-~~~~~
+~~~~
@subsubsection occt_visu_4_4_4 Orthographic Projection
The following code configures the camera for orthographic rendering:
-~~~~~{.cpp}
+~~~~{.cpp}
// Create an orthographic View in this Viewer
Handle(V3d_View) aView = new V3d_View (theViewer);
aView->Camera()->SetProjectionType (Graphic3d_Camera::Projection_Orthographic);
aView->Update(); // update the Visualization in this View
-~~~~~
+~~~~
@subsubsection occt_visu_4_4_5 Perspective Projection
The following code configures the camera for perspective rendering:
-~~~~~{.cpp}
+~~~~{.cpp}
// Create a perspective View in this Viewer
Handle(V3d_View) aView = new V3d_View (theViewer);
aView->Camera()->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
aView->Update();
-~~~~~
+~~~~
@subsubsection occt_visu_4_4_6 Stereographic Projection
To enable quad buffering support you should provide the following settings to the graphic driver *OpenGl_Caps*:
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(OpenGl_GraphicDriver) aDriver = new OpenGl_GraphicDriver();
OpenGl_Caps& aCaps = aDriver->ChangeOptions();
aCaps.contextStereo = Standard_True;
-~~~~~
+~~~~
The following code configures the camera for stereographic rendering:
-~~~~~{.cpp}
+~~~~{.cpp}
// Create a Stereographic View in this Viewer
Handle(V3d_View) aView = new V3d_View (theViewer);
aView->Camera()->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
aView->Camera()->SetIOD (IODType_Absolute, 5.0);
// Finally update the Visualization in this View
aView->Update();
-~~~~~
+~~~~
Other 3D displays are also supported, including row-interlaced with passive glasses and anaglyph glasses - see *Graphic3d_StereoMode* enumeration.
Example to activate another stereoscopic display:
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(V3d_View) theView;
theView->Camera()->SetProjectionType (Graphic3d_Camera::Projection_Stereo);
theView->ChangeRenderingParams().StereoParams = Graphic3d_StereoMode_RowInterlaced;
-~~~~~
+~~~~
Supporting of VR/AR headsets in application is more involving.
Class *Aspect_XRSession* defines a basic interface for working with extended reality.
There are several types of background styles available for *V3d_View*: solid color, gradient color, image and environment cubemap.
To set solid color for the background you can use the following method:
-~~~~~{.cpp}
+~~~~{.cpp}
void V3d_View::SetBackgroundColor (const Quantity_Color& theColor);
-~~~~~
+~~~~
The gradient background style could be set up with the following method:
-~~~~~{.cpp}
+~~~~{.cpp}
void V3d_View::SetBgGradientColors (const Quantity_Color& theColor1,
const Quantity_Color& theColor2,
const Aspect_GradientFillMethod theFillStyle,
const Standard_Boolean theToUpdate = false);
-~~~~~
+~~~~
The *theColor1* and *theColor2* parameters define the boundary colors of interpolation, the *theFillStyle* parameter defines the direction of interpolation.
To set the image as a background and change the background image style you can use the following method:
-~~~~~{.cpp}
+~~~~{.cpp}
void V3d_View::SetBackgroundImage (const Standard_CString theFileName,
const Aspect_FillMethod theFillStyle,
const Standard_Boolean theToUpdate = false);
-~~~~~
+~~~~
The *theFileName* parameter defines the image file name and the path to it, the *theFillStyle* parameter defines the method of filling the background with the image.
The methods are:
* Transparency shadow effects
Example:
-~~~~~{.cpp}
+~~~~{.cpp}
Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
// specifies rendering mode
aParams.Method = Graphic3d_RM_RAYTRACING;
aParams.IsTransparentShadowEnabled = true;
// update the view
aView->Update();
-~~~~~
+~~~~
@subsubsection occt_visu_4_4_14 Display priorities
Example:
-~~~~~{.cpp}
+~~~~{.cpp}
// set z-layer to an interactive object
Handle(AIS_InteractiveContext) theContext;
Handle(AIS_InteractiveObject) theInterObj;
Standard_Integer anId = -1;
aViewer->AddZLayer (anId);
theContext->SetZLayer (theInterObj, anId);
-~~~~~
+~~~~
For each z-layer, it is allowed to:
* Enable / disable depth test for layer.
It returns *Graphic3d_ZLayerSettings* for a given *LayerId*.
Example:
-~~~~~{.cpp}
+~~~~{.cpp}
// change z-layer settings
Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (anId);
aSettings.SetEnableDepthTest (true);
aSettings.SetClearDepth (true);
aSettings.SetPolygonOffset (Graphic3d_PolygonOffset());
aViewer->SetZLayerSettings (anId, aSettings);
-~~~~~
+~~~~
Another application for Z-Layer feature is treating visual precision issues when displaying objects far from the World Center.
The key problem with such objects is that visualization data is stored and manipulated with single precision floating-point numbers (32-bit).
* Defines a Z-Layer for each spatial cell containing any object.
* Defines the Local Origin property of the Z-Layer according to the center of the cell.
-~~~~~{.cpp}
+~~~~{.cpp}
Graphic3d_ZLayerSettings aSettings = aViewer->ZLayerSettings (anId);
aSettings.SetLocalOrigin (400.0, 0.0, 0.0);
-~~~~~
+~~~~
* Assigns a presentable object to the nearest Z-Layer.
Note that Local Origin of the Layer is used only for rendering - everything outside will be still defined in the World Coordinate System,
it holds the plane equation coefficients and provides its graphical representation.
To set and get plane equation coefficients you can use the following methods:
-~~~~~{.cpp}
+~~~~{.cpp}
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const gp_Pln& thePlane)
void Graphic3d_ClipPlane::SetEquation (const gp_Pln& thePlane)
Graphic3d_ClipPlane::Graphic3d_ClipPlane (const Equation& theEquation)
void Graphic3d_ClipPlane::SetEquation (const Equation& theEquation)
gp_Pln Graphic3d_ClipPlane::ToPlane() const
-~~~~~
+~~~~
The clipping planes can be activated with the following method:
-~~~~~{.cpp}
+~~~~{.cpp}
void Graphic3d_ClipPlane::SetOn (const Standard_Boolean theIsOn)
-~~~~~
+~~~~
The number of clipping planes is limited.
You can check the limit value via method *Graphic3d_GraphicDriver::InquireLimit()*;
-~~~~~{.cpp}
+~~~~{.cpp}
// get the limit of clipping planes for the current view
Standard_Integer aMaxClipPlanes = aView->Viewer()->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxNbClipPlanes);
-~~~~~
+~~~~
Let us see for example how to create a new clipping plane with custom parameters and add it to a view or to an object:
-~~~~~{.cpp}
+~~~~{.cpp}
// create a new clipping plane
Handle(Graphic3d_ClipPlane) aClipPlane = new Graphic3d_ClipPlane();
// change equation of the clipping plane
aClipPlane->SetOn (Standard_True);
// update the view
aView->Update();
-~~~~~
+~~~~
@subsubsection occt_visu_4_4_17 Automatic back face culling
Create colors.
-~~~~~{.cpp}
+~~~~{.cpp}
Quantity_Color aBlack (Quantity_NOC_BLACK);
Quantity_Color aBlue (Quantity_NOC_MATRABLUE);
Quantity_Color aBrown (Quantity_NOC_BROWN4);
Quantity_Color aMyColor (0.99, 0.65, 0.31, Quantity_TOC_RGB);
Quantity_Color aBeet (Quantity_NOC_BEET);
Quantity_Color aWhite (Quantity_NOC_WHITE);
-~~~~~
+~~~~
Create line attributes.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(Graphic3d_AspectLine3d) anAspectBrown = new Graphic3d_AspectLine3d();
Handle(Graphic3d_AspectLine3d) anAspectBlue = new Graphic3d_AspectLine3d();
Handle(Graphic3d_AspectLine3d) anAspectWhite = new Graphic3d_AspectLine3d();
anAspectBrown->SetColor (aBrown);
anAspectBlue ->SetColor (aBlue);
anAspectWhite->SetColor (aWhite);
-~~~~~
+~~~~
Create marker attributes.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(Graphic3d_AspectMarker3d aFirebrickMarker = new Graphic3d_AspectMarker3d();
// marker attributes
aFirebrickMarker->SetColor (Firebrick);
aFirebrickMarker->SetType (Aspect_TOM_BALL);
// or custom image
aFirebrickMarker->SetMarkerImage (theImage)
-~~~~~
+~~~~
Create facet attributes.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(Graphic3d_AspectFillArea3d) aFaceAspect = new Graphic3d_AspectFillArea3d();
Graphic3d_MaterialAspect aBrassMaterial (Graphic3d_NameOfMaterial_Brass);
Graphic3d_MaterialAspect aGoldMaterial (Graphic3d_NameOfMaterial_Gold);
aFaceAspect->SetDistinguishOn ();
aFaceAspect->SetFrontMaterial (aGoldMaterial);
aFaceAspect->SetBackMaterial (aBrassMaterial);
-~~~~~
+~~~~
Create text attributes.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(Graphic3d_AspectText3d) aTextAspect = new Graphic3d_AspectText3d (aForest, Font_NOF_MONOSPACE, 1.0, 0.0);
-~~~~~
+~~~~
@subsubsection occt_visu_4_5_2 Create a 3D Viewer (a Windows example)
-~~~~~{.cpp}
+~~~~{.cpp}
// create a graphic driver
Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (Handle(Aspect_DisplayConnection)());
// create a viewer
a3DViewer->SetLightOn();
// set background color to black
a3DViewer->SetDefaultBackgroundColor (Quantity_NOC_BLACK);
-~~~~~
+~~~~
@subsubsection occt_visu_4_5_3 Create a 3D view (a Windows example)
It is assumed that a valid Windows window may already be accessed via the method *GetSafeHwnd()* (as in case of MFC sample).
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(WNT_Window) aWNTWindow = new WNT_Window (GetSafeHwnd());
myView = myViewer->CreateView();
myView->SetWindow (aWNTWindow);
-~~~~~
+~~~~
@subsubsection occt_visu_4_5_4 Create an interactive context
-~~~~~{.cpp}
+~~~~{.cpp}
myAISContext = new AIS_InteractiveContext (myViewer);
-~~~~~
+~~~~
You are now able to display interactive objects such as an *AIS_Shape*.
-~~~~~{.cpp}
+~~~~{.cpp}
TopoDS_Shape aShape = BRepAPI_MakeBox (10, 20, 30).Solid();
Handle(AIS_Shape) anAISShape = new AIS_Shape (aShape);
myAISContext->Display (anAISShape, true);
-~~~~~
+~~~~
@subsubsection occt_visu_4_5_5 Create your own interactive object
Let us look at the example of compute methods
-~~~~~{.cpp}
+~~~~{.cpp}
void MyPresentableObject::Compute (const Handle(PrsMgr_PresentationManager)& thePrsManager,
const Handle(Graphic3d_Structure)& thePrs,
const Standard_Integer theMode)
(
//...
)
-~~~~~
+~~~~
@subsubsection occt_visu_4_5_6 Create primitives in the interactive object
Get the group used in *Graphic3d_Structure*.
-~~~~~{.cpp}
+~~~~{.cpp}
Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
-~~~~~
+~~~~
Update the group attributes.
-~~~~~{.cpp}
+~~~~{.cpp}
aGroup->SetGroupPrimitivesAspect (anAspectBlue);
-~~~~~
+~~~~
Create two triangles in *aGroup*.
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Integer aNbTria = 2;
Handle(Graphic3d_ArrayOfTriangles) aTriangles = new Graphic3d_ArrayOfTriangles (3 * aNbTria, 0, Graphic3d_ArrayFlags_VertexNormal);
for (Standard_Integer aTriIter = 1; aTriIter <= aNbTria; ++aTriIter)
}
aGroup->AddPrimitiveArray (aTriangles);
aGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectFillArea3d());
-~~~~~
+~~~~
Use the polyline function to create a boundary box for the *thePrs* structure in group *aGroup*.
-~~~~~{.cpp}
+~~~~{.cpp}
Standard_Real Xm, Ym, Zm, XM, YM, ZM;
thePrs->MinMaxValues (Xm, Ym, Zm, XM, YM, ZM);
aGroup->AddPrimitiveArray(aPolylines);
aGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d());
-~~~~~
+~~~~
Create text and markers in group *aGroup*.
-~~~~~{.cpp}
+~~~~{.cpp}
static char* THE_TEXT[3] =
{
"Application title",
-(Standard_Real )i * 4);
aGroup->Text (THE_TEXT[i], Marker, 20.);
}
-~~~~~
+~~~~
@section occt_visu_5 Mesh Visualization Services
Before working with shapes, properties, and other types of information, the global organization of an XDE Document can be queried or completed to determine if an existing Document is actually structured for use with XDE.
To find out if an existing *TDocStd_Document* is suitable for XDE, use:
-~~~~~
+~~~~{.cpp}
Handle(TDocStd_Document) doc...
if ( XCAFDoc_DocumentTool::IsXCAFDocument (doc) ) { .. yes .. }
-~~~~~
+~~~~
If the Document is suitable for XDE, you can perform operations and queries explained in this guide. However, if a Document is not fully structured for XDE, it must be initialized.
@subsubsection occt_xde_2_1_3 Get an Application or an Initialized Document
If you want to retrieve an existing application or an existing document (known to be correctly structured for XDE), use:
-~~~~~
+~~~~{.cpp}
Handle(TDocStd_Document) aDoc;
Handle(XCAFApp_Application) anApp = XCAFApp_Application::GetApplication();
anApp->NewDocument(;MDTV-XCAF;,aDoc);
-~~~~~
+~~~~
@subsection occt_xde_2_2 Shapes and Assemblies
@subsubsection occt_xde_2_2_1 Initialize an XDE Document (Shapes)
An XDE Document begins with a *TDocStd_Document*. Assuming you have a *TDocStd_Document* already created, you can ensure that it is correctly structured for XDE by initializing the XDE structure as follows:
-~~~~~
+~~~~{.cpp}
Handle(TDocStd_Document) doc...
Handle (XCAFDoc_ShapeTool) myAssembly =
XCAFDoc_DocumentTool::ShapeTool (Doc->Main());
TDF_Label aLabel = myAssembly->NewShape()
-~~~~~
+~~~~
**Note** that the method *XCAFDoc_DocumentTool::ShapeTool* returns the *XCAFDoc_ShapeTool*. The first time this method is used, it creates the *XCAFDoc_ShapeTool*. In our example, a handle is used for the *TDocStd_Document*.
@subsubsection occt_xde_2_2_2 Get a Node considered as an Assembly
To get a node considered as an Assembly from an XDE structure, you can use the Label of the node. Assuming that you have a properly initialized *TDocStd_Document*, use:
-~~~~~
+~~~~{.cpp}
Handle(TDocStd_Document) doc...
Handle(XCAFDoc_ShapeTool) myAssembly = XCAFDoc_DocumentTool::ShapeTool (aLabel);
-~~~~~
+~~~~
In the previous example, you can also get the Main Item of an XDE document, which records the root shape representation (as a Compound if it is an Assembly) by using *ShapeTool(Doc->Main())* instead of *ShapeTool(aLabel)*.
You can then query or edit this Assembly node, the Main Item or another one (*myAssembly* in our examples).
Some actions in this chapter affect the content of the document, considered as an Assembly. As a result, you will sometimes need to update various representations (including the compounds).
To update the representations, use:
-~~~~~
+~~~~{.cpp}
myAssembly->UpdateAssemblies();
-~~~~~
+~~~~
This call performs a top-down update of the Assembly compounds stored in the document.
**Note** that you have to run this method manually to actualize your Assemblies after any low-level modifications on shapes.
* If the Shape is not a compound, it is taken as a whole, without breaking it down.
To break down a Compound in the assembly structure, use:
-~~~~~
+~~~~{.cpp}
Standard_Boolean makeAssembly;
// True to interpret a Compound as an Assembly,
// False to take it as a whole
aLabel = myAssembly->AddShape(aShape, makeAssembly);
-~~~~~
+~~~~
Each node of the assembly therefore refers to its sub-shapes.
Concerning located instances of sub-shapes, the corresponding shapes, (without location) appear at distinct sub-labels. They are referred to by a shape instance, which associates a location.
@subsubsection occt_xde_2_2_5 Setting a given Shape at a given Label
A top-level shape can be changed. In this example, no interpretation of compound is performed:
-~~~~~
+~~~~{.cpp}
Standard_CString LabelString ...;
// identifies the Label (form ;0:i:j...;)
TDF_Label aLabel...;
// A label must be present
myAssembly->SetShape(aLabel, aShape);
-~~~~~
+~~~~
@subsubsection occt_xde_2_2_6 Getting a Shape from a Label
To get a shape from its Label from the top-level, use:
-~~~~~
+~~~~{.cpp}
TDF_Label aLabel...
// A label must be present
if (aLabel.IsNull()) {
if (aShape.IsNull()) {
// this label is not for a Shape
}
-~~~~~
+~~~~
**Note** that if the label corresponds to an assembly, the result is a compound.
@subsubsection occt_xde_2_2_7 Getting a Label from a Shape
To get a Label, which is attached to a Shape from the top-level, use:
-~~~~~
+~~~~{.cpp}
Standard_Boolean findInstance = Standard_False;
// (this is default value)
aLabel = myAssembly->FindShape(aShape [,findInstance]);
if (aLabel.IsNull()) {
// no label found for this shape
}
-~~~~~
+~~~~
If *findInstance* is True, a search is made for the shape with the same location. If it is False (default value), a search is made among original, non-located shapes.
@subsubsection occt_xde_2_2_8 Other Queries on a Label
#### Main Shapes
To determine if a Shape is recorded (or not), use:
-~~~~~
+~~~~{.cpp}
if ( myAssembly->IsShape(aLabel) ) { .. yes .. }
-~~~~~
+~~~~
To determine if the shape is top-level, i.e. was added by the *AddShape* method, use:
-~~~~~
+~~~~{.cpp}
if ( myAssembly->IsTopLevel(aLabel) ) { .. yes .. }
-~~~~~
+~~~~
To get a list of top-level shapes added by the *AddShape* method, use:
-~~~~~
+~~~~{.cpp}
TDF_LabelSequence frshapes;
myAssembly->GetShapes(frshapes);
-~~~~~
+~~~~
To get all free shapes at once if the list above has only one item, use:
-~~~~~
+~~~~{.cpp}
TopoDS_Shape result = myAssembly->GetShape(frshapes.Value(1));
-~~~~~
+~~~~
If there is more than one item, you must create and fill a compound, use:
-~~~~~
+~~~~{.cpp}
TopoDS_Compound C;
BRep_Builder B;
B.MakeCompound(C);
TopoDS_Shape S = myAssembly->GetShape(frshapes.Value(i));
B.Add(C,S);
}
-~~~~~
+~~~~
In our example, the result is the compound C.
To determine if a shape is a free shape (no reference or super-assembly), use:
-~~~~~
+~~~~{.cpp}
if ( myAssembly->IsFree(aLabel) ) { .. yes .. }
-~~~~~
+~~~~
To get a list of Free Shapes (roots), use:
-~~~~~
+~~~~{.cpp}
TDF_LabelSequence frshapes;
myAssembly->GetFreeShapes(frshapes);
-~~~~~
+~~~~
To get the shapes, which use a given shape as a component, use:
-~~~~~
+~~~~{.cpp}
TDF_LabelSequence users;
Standard_Integer nbusers = myAssembly->GetUsers(aLabel,users);
-~~~~~
+~~~~
The count of users is contained with *nbusers*. It contains 0 if there are no users.
#### Assembly and Components
To determine if a label is attached to the main part or to a sub-part (component), use:
-~~~~~
+~~~~{.cpp}
if (myAssembly->IsComponent(aLabel)) { .. yes .. }
-~~~~~
+~~~~
To determine whether a label is a node of a (sub-) assembly or a simple shape, use:
-~~~~~
+~~~~{.cpp}
if ( myAssembly->IsAssembly(aLabel) ) { .. yes .. }
-~~~~~
+~~~~
If the label is a node of a (sub-) assembly, you can get the count of components, use:
-~~~~~
+~~~~{.cpp}
Standard_Boolean subchilds = Standard_False; //default
Standard_Integer nbc = myAssembly->NbComponents (aLabel [,subchilds]);
-~~~~~
+~~~~
If *subchilds* is True, commands also consider sub-levels. By default, only level one is checked.
To get component Labels themselves, use:
-~~~~~
+~~~~{.cpp}
Standard_Boolean subchilds = Standard_False; //default
TDF_LabelSequence comps;
Standard_Boolean isassembly = myAssembly->GetComponents
(aLabel,comps[,subchilds]);
-~~~~~
+~~~~
@subsubsection occt_xde_2_2_9 Instances and References for Components
To determine if a label is a simple shape, use:
-~~~~~
+~~~~{.cpp}
if ( myAssembly->IsSimpleShape(aLabel) ) { .. yes .. }
-~~~~~
+~~~~
To determine if a label is a located reference to another one, use:
-~~~~~
+~~~~{.cpp}
if ( myAssembly->IsReference(aLabel) ) { .. yes .. }
-~~~~~
+~~~~
If the label is a located reference, you can get the location, use:
-~~~~~
+~~~~{.cpp}
TopLoc_Location loc = myAssembly->GetLocation (aLabel);
-~~~~~
+~~~~
To get the label of a referenced original shape (also tests if it is a reference), use:
-~~~~~
+~~~~{.cpp}
Standard_Boolean isref = myAssembly->GetReferredShape
(aLabel, refLabel);
-~~~~~
+~~~~
**Note** *isref* returns False if *aLabel* is not for a reference.
In addition to the previously described *AddShape* and *SetShape*, several shape edits are possible.
To remove a Shape, and all its sub-labels, use:
-~~~~~
+~~~~{.cpp}
Standard_Boolean remsh = myAssembly->RemoveShape(aLabel);
// remsh is returned True if done
-~~~~~
+~~~~
This operation will fail if the shape is neither free nor top level.
To add a Component to the Assembly, from a new shape, use:
-~~~~~
+~~~~{.cpp}
Standard_Boolean expand = Standard_False; //default
TDF_Label aLabel = myAssembly->AddComponent (aShape [,expand]);
-~~~~~
+~~~~
If *expand* is True and *aShape* is a Compound, *aShape* is broken down to produce sub-components, one for each of its sub-shapes.
To add a component to the assembly, from a previously recorded shape (the new component is defined by the label of the reference shape, and its location), use:
-~~~~~
+~~~~{.cpp}
TDF_Label refLabel ...; // the label of reference shape
TopLoc_Location loc ...; // the desired location
TDF_Label aLabel = myAssembly->AddComponent (refLabel, loc);
-~~~~~
+~~~~
To remove a component from the assembly, use:
-~~~~~
+~~~~{.cpp}
myAssembly->RemoveComponent (aLabel);
-~~~~~
+~~~~
@subsection occt_xde_2_4 Management of Sub-Shapes
In addition to components of a (sub-)assembly, it is possible to have individual identification of some sub-shapes inside any shape. Therefore, you can attach specific attributes such as Colors. Some additional actions can be performed on sub-shapes that are neither top-level, nor components:
To add a sub-shape to a given Label, use:
-~~~~~
+~~~~{.cpp}
TDF_Label subLabel = myAssembly->AddSubShape (aLabel, subShape);
-~~~~~
+~~~~
To find the Label attached to a given sub-shape, use:
-~~~~~
+~~~~{.cpp}
TDF_Label subLabel; // new label to be computed
if ( myAssembly-> FindSubShape (aLabel, subShape, subLabel)) { .. yes .. }
-~~~~~
+~~~~
If the sub-shape is found (yes), *subLabel* is filled by the correct value.
To find the top-level simple shape (not a compound whether free or not), which contains a given sub-shape, use:
-~~~~~
+~~~~{.cpp}
TDF_Label mainLabel = myAssembly->FindMainShape(subShape);
-~~~~~
+~~~~
**Note** that there should be only one shape for a valid model. In any case, the search stops on the first one found.
To get the sub-shapes of a shape, which are recorded under a label, use:
-~~~~~
+~~~~{.cpp}
TDF_LabelSequence subs;
Standard_Boolean hassubs = myAssembly->GetSubShapes (aLabel,subs);
-~~~~~
+~~~~
@subsection occt_xde_2_5 Properties
Some properties can be attached directly to shapes. These properties are:
* Name (standard definition from OCAF)
These considerations are not specific to XDE. What is specific to data exchange is the way names are attached to entities.
To get the name attached to a label (as a reminder using OCAF), use:
-~~~~~
+~~~~{.cpp}
Handle(TDataStd_Name) N;
if ( !aLabel.FindAttribute(TDataStd_Name::GetID(),N)) {
// no name is attached
}
TCollection_ExtendedString name = N->Get();
-~~~~~
+~~~~
Don't forget to consider Extended String as ASCII, for the exchange file.
To set a name to a label (as a reminder using OCAF), use:
-~~~~~
+~~~~{.cpp}
TCollection_ExtendedString aName ...;
// contains the desired name for this Label (ASCII)
TDataStd_Name::Set (aLabel, aName);
-~~~~~
+~~~~
@subsubsection occt_xde_2_5_2 Centroid
A Centroid is defined by a Point to fix its position. It is handled as a property, item of the class *XCAFDoc_Centroid*, sub-class of *TDF_Attribute*. However, global methods give access to the position itself.
A centroid can be determined at any level of an assembly, thereby allowing a check of both individual simple shapes and their combinations including locations.
To get a Centroid attached to a Shape, use:
-~~~~~
+~~~~{.cpp}
gp_Pnt pos;
Handle(XCAFDoc_Centroid) C;
aLabel.FindAttribute ( XCAFDoc_Centroid::GetID(), C );
if ( !C.IsNull() ) pos = C->Get();
-~~~~~
+~~~~
To set a Centroid to a Shape, use:
-~~~~~
+~~~~{.cpp}
gp_Pnt pos (X,Y,Z);
// the position previously computed for the centroid
XCAFDoc_Centroid::Set ( aLabel, pos );
-~~~~~
+~~~~
@subsubsection occt_xde_2_5_3 Area
An Area is defined by a Real, it corresponds to the computed Area of a Shape, provided that it contains surfaces. It is handled as a property, item of the class *XCAFDoc_Area*, sub-class of *TDF_Attribute*.
This notion has been introduced in STEP but it is usually disregarded for a Solid, as Volume is used instead. In addition, it is attached to simple shapes, not to assemblies.
To get an area attached to a Shape, use:
-~~~~~
+~~~~{.cpp}
Standard_Real area;
Handle(XCAFDoc_Area) A;
L.FindAttribute ( XCAFDoc_Area::GetID(), A );
Standard_Real area ...;
// value previously computed for the area
XCAFDoc_Area::Set ( aLabel, area );
-~~~~~
+~~~~
@subsubsection occt_xde_2_5_4 Volume
A Volume is defined by a Real and corresponds to the computed volume of a Shape, provided that it contains solids. It is handled as a property, an item of the class *XCAFDoc_Volume*, sub-class of *TDF_Attribute*.
This notion has been introduced in STEP. It may be attached to simple shapes or their assemblies for computing cumulated volumes and centers of gravity.
To get a Volume attached to a Shape, use:
-~~~~~
+~~~~{.cpp}
Standard_Real volume;
Handle(XCAFDoc_Volume) V;
L.FindAttribute ( XCAFDoc_Volume::GetID(), V );
if ( !V.IsNull() ) volume = V->Get();
-~~~~~
+~~~~
To set a volume value to a Shape, use:
-~~~~~
+~~~~{.cpp}
Standard_Real volume ...;
// value previously computed for the volume
XCAFDoc_Volume::Set ( aLabel, volume );
-~~~~~
+~~~~
@subsection occt_xde_2_6 Colors and Layers
XDE can read and write colors and layers assigned to shapes or their subparts (down to level of faces and edges) to and from both IGES and STEP formats.
@subsubsection occt_xde_2_6_1 Initialization
To query, edit, or initialize a Document to handle Colors of XCAF, use:
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_ColorTool) myColors =
XCAFDoc_DocumentTool::ColorTool(Doc->Main ());
-~~~~~
+~~~~
This call can be used at any time. The first time it is used, a relevant structure is added to the document. This definition is used for all the following color calls and will not be repeated for these.
@subsubsection occt_xde_2_6_2 Adding a Color
When the Color is added by its value *Quantity_Color*, it is added only if it has not yet been recorded (same RGB values) in the Document.
To set a Color to a Shape using a label, use:
-~~~~~
+~~~~{.cpp}
Quantity_Color Col (red,green,blue);
XCAFDoc_ColorType ctype ..;
// can take one of these values :
// XCAFDoc_ColorSurf : surfaces only
// XCAFDoc_ColorCurv : curves only
myColors->SetColor ( aLabel, Col, ctype );
-~~~~~
+~~~~
Alternately, the Shape can be designated directly, without using its label, use:
-~~~~~
+~~~~{.cpp}
myColors->SetColor ( aShape, Col, ctype );
// Creating and Adding a Color, explicitly
Quantity_Color Col (red,green,blue);
TDF_Label ColLabel = myColors->AddColor ( Col );
-~~~~~
+~~~~
**Note** that this Color can then be named, allowing later retrieval by its Name instead of its Value.
To set a Color, identified by its Label and already recorded, to a Shape, use:
-~~~~~
+~~~~{.cpp}
XCAFDoc_ColorType ctype ..; // see above
if ( myColors->SetColors ( aLabel, ColLabel, ctype) ) {.. it is done .. }
-~~~~~
+~~~~
In this example, *aLabel* can be replaced by *aShape* directly.
@subsubsection occt_xde_2_6_3 Queries on Colors
Various queries can be performed on colors. However, only specific queries are included in this section, not general queries using names.
To determine if a Color is attached to a Shape, for a given color type (ctype), use:
-~~~~~
+~~~~{.cpp}
if ( myColors->IsSet (aLabel , ctype)) {
// yes, there is one ..
}
-~~~~~
+~~~~
In this example, *aLabel* can be replaced by *aShape* directly.
To get the Color attached to a Shape (for any color type), use:
-~~~~~
+~~~~{.cpp}
Quantity_Color col;
// will receive the recorded value (if there is some)
if ( !myColors->GetColor(aLabel, col) ) {
// sorry, no color ..
}
-~~~~~
+~~~~
Color name can also be queried from *col.StringName* or *col.Name*.
In this example, *aLabel* can be replaced by *aShape* directly.
To get the Color attached to a Shape, with a specific color type, use:
-~~~~~
+~~~~{.cpp}
XCAFDoc_ColorType ctype ..;
Quantity_Color col;
// will receive the recorded value (if there is some)
if ( !myColors->GetColor(aLabel, ctype, col) ) {
// sorry, no color ..
}
-~~~~~
+~~~~
To get all the Colors recorded in the Document, use:
-~~~~~
+~~~~{.cpp}
Quantity_Color col; // to receive the values
TDF_LabelSequence ColLabels;
myColors->GetColors(ColLabels);
if ( !myColors->GetColor(aLabel, col) ) continue;
// col receives the color n0 i ..
}
-~~~~~
+~~~~
To find a Color from its Value, use:
-~~~~~
+~~~~{.cpp}
Quantity_Color Col (red,green,blue);
TDF_Label ColLabel = myColors-FindColor (Col);
if ( !ColLabel.IsNull() ) { .. found .. }
-~~~~~
+~~~~
@subsubsection occt_xde_2_6_4 Editing Colors
Besides adding colors, the following attribute edits can be made:
To unset a Color on a Shape, use:
-~~~~~
+~~~~{.cpp}
XCAFDoc_ColorType ctype ...;
// desired type (XCAFDoc_ColorGen for all )
myColors->UnSetColor (aLabel,ctype);
-~~~~~
+~~~~
To remove a Color and all the references to it (so that the related shapes will become colorless), use:
-~~~~~
+~~~~{.cpp}
myColors->RemoveColor(ColLabel);
-~~~~~
+~~~~
@subsection occt_xde_2_7 Geometric Dimensions & Tolerances (GD\&T)
@subsubsection occt_xde_2_7_1 Initialization
To query, edit, or initialize a Document to handle GD\&Ts of XCAF, use:
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_DimTolTool) myDimTolTool =
XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
-~~~~~
+~~~~
This call can be used at any time. When it is used for the first time, a relevant structure is added to the document. This definition is used for all later GD\&T calls and is not repeated for them.
@subsubsection occt_xde_2_7_2 Adding a GD\&T
created entity.
Here is an example of adding a new dimension:
-~~~~~
+~~~~{.cpp}
TDF_Label aDimLabel = myDimTolTool->AddDimension();
if (!aDimLabel.IsNull())
{
// error processing
}
-~~~~~
+~~~~
A similar approach can be used for other GD\&T types.
@subsubsection occt_xde_2_7_3 Editing a GD\&T
A newly added GD\&T entity is empty. To set its data a corresponding access object should be used as it is demonstrated
below, where the dimension becomes a linear distance between two points.
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_Dimension) aDimAttr;
aDimLabel.FindAttribute(XCAFDoc_Dimension::GetID(), aDimAttr);
if (!aDimAttr.IsNull())
//...
aDimAttr->SetObject(aDimObject);
}
-~~~~~
+~~~~
A similar approach can be used for other GD\&T types.
@subsubsection occt_xde_2_7_4 Linking GD\&Ts
These methods can take a single label or a sequence of labels. All previous links will be removed.
The example below demonstrates linking of a dimension to sequences of shape labels:
-~~~~~
+~~~~{.cpp}
TDF_LabelSequence aShapes1, aShapes2;
aShapes1.Append(aShape11);
//...
aShapes2.Append(aShape21);
//...
aDGTTool->SetDimension(aShapes1, aShapes2, aDimLabel);
-~~~~~
+~~~~
In addition, a special method *SetDatumToGeomTol* should be used to link a datum with a geometric tolerance.
In an XDE document, Clipping planes are managed by the class *XCAFDoc_ClippingPlaneTool*. It works basing on the same principles as ShapeTool works with Shapes. This tool can be provided on the Main Label or on any sub-label. Clipping planes are stored in a child of the starting document label 0.1.8, where planes themselves are defined as *TDataXtd_Plane* attribute. *TDataStd_Name* attribute is used for naming.
To query, edit, or initialize a Document to handle clipping planes of XCAF, use:
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_ClippingPlaneTool) myClipPlaneTool =
XCAFDoc_DocumentTool::ClippingPlaneTool(Doc->Main());
-~~~~~
+~~~~
This call can be used at any time. When it is used for the first time, a relevant structure is added to the document.
To add a clipping plane use one of overloaded methods *AddClippingPlane*, e.g.:
-~~~~~
+~~~~{.cpp}
gp_Pln aPln = ...
Standard_Boolean aCapping = ...
TDF_Label aClipPlnLbl = myClipPlaneTool->AddClippingPlane(aPln, "Name of plane", aCapping);
{
// error processing
}
-~~~~~
+~~~~
To remove a plane use *RemoveClippingPlane* method, e.g.:
-~~~~~
+~~~~{.cpp}
if (!myClipPlaneTool->RemoveClippingPlane(aClipPlnLbl))
{
// not removed
}
-~~~~~
+~~~~
The plane will not be removed if it is referenced in at least one view.
To change the clipping plane and its name use *UpdateClippingPlane* method, e.g.:
-~~~~~
+~~~~{.cpp}
gp_Pln aPln = ...
myClipPlaneTool->UpdateClippingPlane(aClipPlnLbl, aPln, "New name of plane");
-~~~~~
+~~~~
Capping property can be changed using *SetCapping* method, e.g.:
-~~~~~
+~~~~{.cpp}
Standard_Boolean aCapping = ...
myClipPlaneTool->SetCapping(aClipPlnLbl, aCapping);
-~~~~~
+~~~~
*XCAFDoc_ClippingPlaneTool* can be used to get all clipping plane labels and to check if a label belongs to the *ClippingPlane table*, e.g.:
-~~~~~
+~~~~{.cpp}
TDF_LabelSequence aClipPlaneLbls;
myClipPlaneTool->GetClippingPlanes(aClipPlaneLbls);
...
...
}
}
-~~~~~
+~~~~
@subsection occt_xde_2_9 Saved views
In an XDE document, Views are managed by the class *XCAFDoc_ViewTool*. It works basing on the same principles as ShapeTool works with Shapes. This tool can be provided on the Main Label or on any sub-label. Views are stored in a child of the starting document label 0.1.7, where a view itself is defined as *XCAFDoc_View* sub-class of *TDF_Attribute*. Views and selected shapes, clipping planes, GD\&Ts and notes are related by Graph Nodes.
To query, edit, or initialize a Document to handle views of XCAF, use:
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_ViewTool) myViewTool =
XCAFDoc_DocumentTool::ViewTool(Doc->Main());
-~~~~~
+~~~~
This call can be used at any time. When it is used for the first time, a relevant structure is added to the document.
To add a view use *AddView* method and an access *XCAFView_Object* object to set camera parameters, e.g.:
-~~~~~
+~~~~{.cpp}
TDF_Label aViewLbl = myViewTool->AddView();
if (aViewLbl.IsNull())
{
...
aViewAttr->SetObject(aViewObject);
}
-~~~~~
+~~~~
To set shapes, clipping planes, GD\&Ts and notes selected for the view use one of overloaded *SetView* methods of *XCAFDoc_ViewTool*.
To set only clipping planes one should use *SetClippingPlanes* method.
-~~~~~
+~~~~{.cpp}
TDF_LabelSequence aShapes; ...
TDF_LabelSequence aGDTs; ...
myViewTool->SetView(aShapes, aGDTs, aViewLbl);
TDF_LabelSequence aClippingPlanes; ...
myViewTool->SetClippingPlanes(aClippingPlanes, aViewLbl);
-~~~~~
+~~~~
To remove a view use *RemoveView* method.
To get all view labels and check if a label belongs to the View table use:
-~~~~~
+~~~~{.cpp}
TDF_LabelSequence aViewLbls;
myViewTool->GetViewLabels(aViewLbls);
...
...
}
}
-~~~~~
+~~~~
To get shapes, clipping planes, GD\&Ts or notes associated with a particular view use the following methods:
* *GetRefShapeLabel* - returns a sequence of associated shape labels;
@subsubsection occt_xde_2_10_1 Initialization
To query, edit, or initialize a Document to handle custom notes of XCAF, use:
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_NotesTool) myNotes =
XCAFDoc_DocumentTool::NotesTool(Doc->Main ());
-~~~~~
+~~~~
This call can be used at any time. The first time it is used, a relevant structure is added to the document. This definition is used for all later notes calls and will not be repeated for them.
@subsubsection occt_xde_2_10_2 Creating Notes
- *CreateBinData* : creates a note with arbitrary binary data, e.g. contents of a file.
Both methods return an instance of *XCAFDoc_Note* class.
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_NotesTool) myNotes = ...
Handle(XCAFDoc_Note) myNote = myNotes->CreateComment("User", "Timestamp", "Hello, World!");
-~~~~~
+~~~~
This code adds a child label to label 0.1.9.1 with *XCAFDoc_NoteComment* attribute.
@subsubsection occt_xde_2_10_3 Editing a Note
An instance of *XCAFDoc_Note* class can be used for note editing.
One may change common note data.
-~~~~~
+~~~~{.cpp}
myNote->Set("New User", "New Timestamp");
-~~~~~
+~~~~
To change specific data one needs to down cast *myNote* handle to the appropriate sub-class:
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_NoteComment) myCommentNote = Handle(XCAFDoc_NoteComment)::DownCast(myNote);
if (!myCommentNote.IsNull()) {
myCommentNote->Set("New comment");
}
-~~~~~
+~~~~
In order to edit auxiliary note data such as text and attachment position, plane for rendering and tessellated presentation,
one should use a transfer object *XCAFNoteObjects_NoteObject* by GetObject and SetObject methods of *XCAFDoc_Note* class.
*XCAFNoteObjects_NoteObject* class provides the following functionality:
- GetPresentation and SetPresentation methods allow to test for and specify tessellated presentation
After getting, the transfer object can be edited and set back to the note:
-~~~~~
+~~~~{.cpp}
Handle(XCAFNoteObjects_NoteObject) aNoteObj = myNote->GetObject();
if (!aNoteObj.IsNull())
{
aNoteObj->SetPresentation (aS);
myNote->SetObject (aNoteObj);
}
-~~~~~
+~~~~
@subsubsection occt_xde_2_10_4 Adding Notes
- *AddNoteToSubshape* : binds a note to a sub-shape.
All methods return a pointer to *XCAFDoc_AssemblyItemRef* attribute identifying the annotated item.
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_NotesTool) myNotes = ...
Handle(XCAFDoc_Note) myNote = ...
TDF_Label theLabel; ...
Handle(XCAFDoc_AssemblyItemRef) myRefAttr = myNotes->AddNoteToAttr(myNote->Label(), theAttrGUID);
Standard_Integer theSubshape = 1;
Handle(XCAFDoc_AssemblyItemRef) myRefSubshape = myNotes->AddNoteToSubshape(myNote->Label(), theSubshape);
-~~~~~
+~~~~
This code adds three child labels with *XCAFDoc_AssemblyItemRef* attribute to label 0.1.9.2. *XCAFDoc_GraphNode* attributes are added to the child labels and note labels.
@subsubsection occt_xde_2_10_5 Finding Notes
- *FindAnnotatedItemAttr* : returns an annotation label for a label's attribute;
- *FindAnnotatedItemSubshape* : returns an annotation label for a sub-shape.
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_NotesTool) myNotes = ...
TDF_Label theLabel; ...
TDF_Label myLabel = myNotes->FindAnnotatedItem(theLabel);
TDF_Label myLabelAttr = myNotes->FindAnnotatedItemAttr(theLabel, theAttrGUID);
Standard_Integer theSubshape = 1;
TDF_Label myLabelSubshape = myNotes->FindAnnotatedItemSubshape(theLabel, theSubshape);
-~~~~~
+~~~~
Null label will be returned if there is no corresponding annotation.
To get all notes of the Document item use the following *XCAFDoc_NotesTool* methods:
- *GetAttrSubshape* : outputs a sequence of note labels bound to a sub-shape.
All these methods return the number of notes.
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_NotesTool) myNotes = ...
TDF_Label theLabel; ...
TDF_LabelSequence theNotes;
Standard_Integer theSubshape = 1;
TDF_LabelSequence theNotesSubshape;
myNotes->GetAttrSubshape(theLabel, theSubshape, theNotesSubshape);
-~~~~~
+~~~~
@subsubsection occt_xde_2_10_6 Removing Notes
- *RemoveAttrNote* : unbinds a note from a label's attribute;
- *RemoveSubshapeNote* : unbinds a note from a sub-shape.
-~~~~~
+~~~~{.cpp}
Handle(XCAFDoc_Note) myNote = ...
TDF_Label theLabel; ...
myNotes->RemoveNote(myNote->Label(), theLabel);
myRefAttr = myNotes->RemoveAttrNote(myNote->Label(), theAttrGUID);
Standard_Integer theSubshape = 1;
myNotes->RemoveSubshapeNote(myNote->Label(), theSubshape);
-~~~~~
+~~~~
A note will not be deleted automatically.
Counterpart methods to remove all notes are available, too.
@subsubsection occt_xde_2_11_1 Reading a STEP file
To read a STEP file by itself, use:
-~~~~~
+~~~~{.cpp}
STEPCAFControl_Reader reader;
IFSelect_ReturnStatus readstat = reader.ReadFile(filename);
// The various ways of reading a file are available here too :
}
// Here, the Document has been filled from a STEP file,
// it is ready to use
-~~~~~
+~~~~
In addition, the reader provides methods that are applicable to document transfers and for directly querying of the data produced.
@subsubsection occt_xde_2_11_2 Writing a STEP file
To write a STEP file by itself, use:
-~~~~~
+~~~~{.cpp}
STEPControl_StepModelType mode =
STEPControl_AsIs;
// Asis is the recommended value, others are available
}
// Writing the File
IFSelect_ReturnStatus stat = writer.Write(file-name);
-~~~~~
+~~~~
@subsubsection occt_xde_2_11_3 Reading an IGES File
Use the same procedure as for a STEP file but with IGESCAFControl instead of STEPCAFControl.