### Example: Object Visualization Setup Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Demonstrates initializing the viewer, creating a box, and applying display and appearance settings. ```php vinit box b 10 10 10 vdisplay b vfit vsetdispmode b 1 vaspects -setColor red -setTransparency 0.2 vrotate 10 10 10 ``` -------------------------------- ### Plug-in Configuration Example in Resource File Source: https://github.com/open-cascade-sas/occt/wiki/foundation_classes An example entry from a plug-in resource file, showing how to define a plug-in's metadata. It includes a GUID and its corresponding library location. This format is used by the `Load()` method to find and load plug-ins. ```plaintext ! METADATADRIVER whose value must be OS or DM. ! FW a148e300-5740-11d1-a904-080036aaa103.Location: libFWOSPlugin.so ``` -------------------------------- ### Example: Split Operation Setup Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Sets up objects and tools for a Split operation by clearing previous arguments, adding shapes, and performing the initial intersection. The actual split is built using 'bsplit' (not shown in this snippet). ```php box b1 10 10 10 box b2 5 5 5 10 10 10 box b3 -5 -5 -5 10 10 10 # Clear objects and tools from previous runs bclearobjects bcleartools # add b1 as object baddobjects b1 # add b2 and b3 as tools baddtools b2 b3 # perform intersection bfillds ``` -------------------------------- ### Example: Preparing for Split Operation Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Shows the setup for a split operation: clearing previous arguments, adding shapes as objects and tools, and performing the intersection step with 'bfillds'. The actual split result is built with 'bsplit'. ```Tcl box b1 10 10 10 box b2 5 5 5 10 10 10 box b3 -5 -5 -5 10 10 10 # Clear objects and tools from previous runs bclearobjects bcleartools # add b1 as object baddobjects b1 # add b2 and b3 as tools baddtools b2 b3 # perform intersection bfillds ``` -------------------------------- ### DRAW Example: Initial Geometry Setup Source: https://github.com/open-cascade-sas/occt/wiki/boolean_operations Sets up initial geometric shapes (cylinder, sphere, plane) using DRAW commands. This is a prerequisite for demonstrating various boolean operations with the Cells Builder. ```php pcylinder c 10 30 psphere s 15 ttranslate s 0 0 30 plane p 0 0 20 1 0 0 mkface f p -25 30 -17 17 ``` -------------------------------- ### Build and Install FreeImage Source: https://github.com/open-cascade-sas/occt/wiki/building_3rdparty Commands to navigate to the source directory, build, and install FreeImage. ```bash cd FREEIMAGE_SRC_DIR ``` ```bash make ``` ```bash make install ``` -------------------------------- ### Install OCCT with MinGW Makefiles Source: https://github.com/open-cascade-sas/occt/blob/master/dox/build/build_occt/building_occt.md Execute this command with mingw32-make to install the built libraries to the specified install folder. ```bash mingw32-make install ``` -------------------------------- ### Quick Start Build with vcpkg Source: https://github.com/open-cascade-sas/occt/blob/master/dox/build/build_occt/building_occt.md This command configures and builds OCCT using vcpkg for dependency management. It enables several common third-party libraries and sets the build type to Release. Use this for a fast, automated setup. ```bash cmake -S . -B build \ -DBUILD_USE_VCPKG=ON \ -DUSE_TBB=ON -DUSE_VTK=ON -DUSE_FREEIMAGE=ON \ -DUSE_RAPIDJSON=ON -DUSE_DRACO=ON \ -DCMAKE_BUILD_TYPE=Release cmake --build build --config Release --parallel ``` -------------------------------- ### Install OCCT with Make (Linux/macOS) Source: https://github.com/open-cascade-sas/occt/blob/master/dox/build/build_occt/building_occt.md Execute this command with make to install the built libraries to the specified install folder. ```bash make install ``` -------------------------------- ### OCAF Plugin File Example Source: https://github.com/open-cascade-sas/occt/wiki/sample_ocaf Lists the required plug-ins for an OCAF application, specifying their GUIDs, locations, and the libraries they are found in. This includes base document drivers and custom application drivers. ```text a148e300-5740-11d1-a904-080036aaa103.Location: FWOSPlugin ! base document drivers plugin ad696000-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin ad696001-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin ad696002-5b34-11d1-b5ba-00a0c9064368.Location: PAppStdPlugin 47b0b826-d931-11d1-b5da-00a0c9064368.Location: PAppStdPlugin 47b0b827-d931-11d1-b5da-00a0c9064368.Location: PAppStdPlugin ``` -------------------------------- ### Install Resource Files Source: https://github.com/open-cascade-sas/occt/blob/master/CMakeLists.txt Installs resource files from the 'resources' directory to the installation destination, preserving subdirectory structure. ```cmake FILE_TO_LIST ("adm/RESOURCES" RESOURCES) foreach(RESOURCE ${RESOURCES}) get_filename_component(RESOURCE_FOLDER ${RESOURCE} DIRECTORY) if(NOT "${RESOURCE_FOLDER}" STREQUAL "") get_filename_component(RESOURCE_FOLDER ${RESOURCE_FOLDER} NAME) OCCT_INSTALL_FILE_OR_DIR ("resources/${RESOURCE}" "${INSTALL_DIR_RESOURCE}/${RESOURCE_FOLDER}") else() OCCT_INSTALL_FILE_OR_DIR ("resources/${RESOURCE}" "${INSTALL_DIR_RESOURCE}") endif() endforeach() ``` -------------------------------- ### Example Grids List Source: https://github.com/open-cascade-sas/occt/blob/master/dox/contribution/tests/tests.md An example of a 'grids.list' file, showing two test grids: 'basic' and 'advanced'. ```plaintext 001 basic 002 advanced ``` -------------------------------- ### Build and Install Tcl on macOS Source: https://github.com/open-cascade-sas/occt/wiki/building_3rdparty Configure, build, and install Tcl from source on macOS. ```bash cd TCL_SRC_DIR/macosx ``` ```bash configure --enable-gcc --enable-shared --enable-threads --prefix=TCL_INSTALL_DIR ``` ```bash make ``` ```bash make install ``` -------------------------------- ### Get Help on Commands Starting with 'a' Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Demonstrates how to use the 'help' command to get information on all commands starting with the letter 'a'. ```tcl # Gives help on all commands starting with *a* ``` -------------------------------- ### vpointcloud Command Example Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Shows how to create a point cloud with specified parameters using the vpointcloud command. ```php vinit vpointcloud pc 0 0 0 100 100000 surface -randColor vfit ``` -------------------------------- ### Example GUID Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/ocaf/ocaf.md A Global Universal ID (GUID) is a string of 37 characters intended to uniquely identify an object. ```text 2a96b602-ec8b-11d0-bee7-080009dc3333 ``` -------------------------------- ### Example: Translation Ratio on IGES Faces Source: https://github.com/open-cascade-sas/occt/wiki/iges An example demonstrating how to use 'tpstat' to get the translation ratio specifically for IGES faces. ```draw Draw:> tpstat *l iges-faces ``` -------------------------------- ### vpoint Command Example Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Demonstrates creating a point in 3D space using the vpoint command. ```php vinit vpoint p 0 0 0 ``` -------------------------------- ### Example: Shading and Sub-object Display Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Examples showing how to apply shading to a sphere and display sub-objects. ```php vinit psphere s 20 vdisplay s vfit vsetdispmode 1 vsetshading s 0.005 ``` ```php vinit box b 10 10 10 psphere s 20 vdisplay b s vfit vsetdispmode 1 vsub b 1 ``` -------------------------------- ### GetUAttribute: Get a User Attribute Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Finds a UAttribute attribute at the specified entry using a local GUID. Requires the GUID to be set in a variable. ```php GetUAttribute dfname entry loacalGUID ``` ```php set localGUID "c73bd076-22ee-11d2-acde-080009dc4422" GetUAttribute D 0:2 ${localGUID} ``` -------------------------------- ### Setting up a 3D View and Lights Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/visualization/visualization.md This snippet demonstrates how to create and configure a 3D view, including setting up lighting and associating it with a window. It covers creating aspect fill areas, adding primitives, and managing lights. ```cpp occ::handle anAspects = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_RED, Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0f, Graphic3d_NameOfMaterial_Gold, Graphic3d_NameOfMaterial_Gold); aPrsGroup->SetGroupPrimitivesAspect (anAspects); aPrsGroup->AddPrimitiveArray (aTriangles); // Create Ambient and Infinite Lights in this Viewer occ::handle aLight1 = new V3d_AmbientLight (Quantity_NOC_GRAY50); occ::handle aLight2 = new V3d_DirectionalLight (V3d_Zneg, Quantity_NOC_WHITE, true); aViewer->AddLight (aLight1); aViewer->AddLight (aLight2); aViewer->SetLightOn(); // Create a 3D quality Window with the same DisplayConnection // @note Xw_Window is X11-only. Cross-platform code should use Aspect_Window or the AIS context instead. occ::handle aWindow = new Xw_Window (aDispConnection, "Test V3d", 100, 100, 500, 500); aWindow->Map(); // Map this Window to this screen // Create a Perspective View in this Viewer occ::handle aView = new V3d_View (aViewer); aView->Camera()->SetProjectionType (Graphic3d_Camera::Projection_Perspective); // Associate this View with the Window aView->SetWindow (aWindow); // Display presentation in this View aStruct->Display(); // Finally update the Visualization in this View aView->Update(); // Fit view to object size aView->FitAll(); ``` -------------------------------- ### Create and Get GUID of an Integer Attribute Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/ocaf/ocaf.md Create a new integer attribute and retrieve its unique GUID using the ID() method inherited from TDF_Attribute. ```cpp occ::handle INT = new TData_Integer(); Standard_GUID guid = INT->ID(); ``` -------------------------------- ### OCAF Resource File Example Source: https://github.com/open-cascade-sas/occt/blob/master/dox/samples/ocaf.md This is an example of a resource file that declares a new model document OCAF-MyApplication. It maps document types to storage and retrieval drivers using GUIDs. ```text formatlist:OCAF-MyApplication OCAF-MyApplication.Description: MyApplication Document Version 1.0 OCAF-MyApplication.FileExtension: sta OCAF-MyApplication.StoragePlugin: ad696000-5b34-11d1-b5ba-00a0c9064368 OCAF-MyApplication.RetrievalPlugin: ad696001-5b34-11d1-b5ba-00a0c9064368 OCAF-MyApplicationSchema: ad696002-5b34-11d1-b5ba-00a0c9064368 OCAF-MyApplication.AttributeStoragePlugin: 47b0b826-d931-11d1-b5da-00a0c9064368 OCAF-MyApplication.AttributeRetrievalPlugin: 47b0b827-d931-11d1-b5da-00a0c9064368 ``` -------------------------------- ### Class Method Naming Convention Source: https://github.com/open-cascade-sas/occt/wiki/coding_rules Public methods should start with an uppercase letter, while protected and private methods should start with a lowercase letter. This example shows a getter and setter for an integer value. ```cpp class MyPackage_MyClass { public: Standard_Integer Value() const; void SetValue (const Standard_Integer theValue); private: void setIntegerValue (const Standard_Integer theValue); }; ``` -------------------------------- ### Create and Display Instance using vconnectto Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/visualization/visualization.md Demonstrates creating an instance of an object and displaying it at a specified location using TCL commands. ```tcl pload MODELING VISUALIZATION vinit psphere s 1 vdisplay s vconnectto s2 3 0 0 s # make instance vfit ``` -------------------------------- ### Get Nearest Solution Point (3D) Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/modeling_algos/modeling_algos.md Retrieves the solution point that is closest to the original starting point. ```cpp gp_Pnt P1 = Projector.NearestPoint(); ``` -------------------------------- ### Get Shape Volume Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Retrieves the volume of a specified shape or label within a document. No output is shown in the example. ```tcl XGetVolume D 0:1:1:1 ``` -------------------------------- ### Build and Install VTK Source: https://github.com/open-cascade-sas/occt/wiki/building_3rdparty Use ccmake to configure and build the VTK library. ```bash ccmake VTK_SRC_DIR ``` ```bash make ``` ```bash make install ``` -------------------------------- ### Get Shape Centroid Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Retrieves the center of gravity coordinates for a given shape or label in a document. No output is shown in the example. ```tcl XGetCentroid D 0:1:1:1 ``` -------------------------------- ### Erase Objects by Name Pattern Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Removes objects from all views. This example erases objects whose names start with 'c_'. ```Tcl # erase everything with a name starting with c_ foreach var [directory c_*] {erase $var} ``` -------------------------------- ### Setup Documentation Targets Source: https://github.com/open-cascade-sas/occt/blob/master/CMakeLists.txt Sets up documentation targets if BUILD_DOC_Overview or BUILD_DOC_RefMan options are enabled. It includes the necessary CMake file for documentation. ```cmake if (BUILD_DOC_Overview OR BUILD_DOC_RefMan) OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_doc") # Setup documentation targets OCCT_SETUP_DOC_TARGETS() endif() ``` -------------------------------- ### Running a Demo Script Source: https://github.com/open-cascade-sas/occt/blob/master/dox/samples/draw_scripts.md Example of how to source a demo script from the DRAW prompt using its absolute or CASROOT-relative path. ```Tcl source $env(CASROOT)/resources/samples/tcl/bottle.tcl ``` -------------------------------- ### Create Assembly with Instance using vconnect Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/visualization/visualization.md Shows how to create an assembly of objects, including an instance, and display them with transformations. The original object does not need to be displayed to create an instance. ```tcl pload MODELING VISUALIZATION vinit psphere s 1 psphere p 0.5 vdisplay s # p is not displayed vsetloc s -2 0 0 vconnect x 3 0 0 s p # make assembly vfit ``` -------------------------------- ### Variable Naming Conventions Source: https://github.com/open-cascade-sas/occt/blob/master/dox/contribution/coding_rules.md Variable names should not conflict with global names and should not start with an underscore. Examples show good and bad practices. ```cpp int Elapsed_Time = 0; // this is bad - possible class name int gp = 0; // this is bad - existing package name int aGp = 0; // this is OK int _KERNEL = 0; // this is bad int THE_KERNEL = 0; // this is OK ``` -------------------------------- ### Get Entity Number by Label Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Prints the number for an entity given its label. Labels typically start with '#' for STEP and 'D' for IGES. ```php enum <#(D)> ``` -------------------------------- ### Begin Script Example Source: https://github.com/open-cascade-sas/occt/blob/master/dox/contribution/tests/tests.md The 'begin' file is a Tcl script executed before each test in a group. It typically loads Draw commands and sets parameters like CPU time limits. ```tcl pload TOPTEST ;# load topological command set cpulimit 300 ;# set maximum time allowed for script execution ``` -------------------------------- ### Get Unique Attribute ID Source: https://github.com/open-cascade-sas/occt/wiki/sample_ocaf Returns the unique GUID for the transformation attribute. This is used for identifying the attribute among others attached to the same label. ```cpp #include //======================================================================= //function : GetID //purpose : The method returns a unique GUID of this attribute. // By means of this GUID this attribute may be identified // among other attributes attached to the same label. //======================================================================= const Standard_GUID& MyPackage_Transformation::GetID() { static Standard_GUID ID("4443368E-C808-4468-984D-B26906BA8573"); return ID; } ``` -------------------------------- ### Initialize V3d Viewer and Graphic Driver Source: https://github.com/open-cascade-sas/occt/wiki/visualization Sets up the visualization environment by creating a display connection, an OpenGL graphic driver, and a V3d viewer. It also configures the viewer's background color and creates a structure for rendering. ```cpp // create a default display connection Handle(Aspect_DisplayConnection) aDispConnection = new Aspect_DisplayConnection(); // create a Graphic Driver Handle(OpenGl_GraphicDriver) aGraphicDriver = new OpenGl_GraphicDriver (aDispConnection); // create a Viewer to this Driver Handle(V3d_Viewer) aViewer = new V3d_Viewer (aGraphicDriver); aViewer->SetDefaultBackgroundColor (Quantity_NOC_DARKVIOLET); // Create a structure in this Viewer Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (aViewer->StructureManager()); aStruct->SetVisual (Graphic3d_TOS_SHADING); // Type of structure // Create a group of primitives in this structure Handle(Graphic3d_Group) aPrsGroup = aStruct->NewGroup(); // Fill this group with one quad of size 100 Handle(Graphic3d_ArrayOfTriangleStrips) aTriangles = new Graphic3d_ArrayOfTriangleStrips (4); aTriangles->AddVertex (-100./2., -100./2., 0.0); aTriangles->AddVertex (-100./2., 100./2., 0.0); aTriangles->AddVertex ( 100./2., -100./2., 0.0); aTriangles->AddVertex ( 100./2., 100./2., 0.0); Handle(Graphic3d_AspectFillArea3d) anAspects = new Graphic3d_AspectFillArea3d (Aspect_IS_SOLID, Quantity_NOC_RED, ``` -------------------------------- ### vsize Command Example Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Shows how to use the vsize command to set the size of a previously defined object, like a tetrahedron. ```php vinit vtrihedron tr1 vtrihedron tr2 0 0 0 1 0 0 1 0 0 vsize tr2 400 ``` -------------------------------- ### Define a Message File Structure Source: https://github.com/open-cascade-sas/occt/wiki/shape_healing Example of an ASCII message file format using keys prefixed with a dot and comments starting with an exclamation mark. ```cpp !This is a sample message file !------------------------------ !Messages for ShapeAnalysis package ! .SampleKeyword Your message string goes here ! !... ! !End of the message file ``` -------------------------------- ### OCAF Resource File Example Source: https://github.com/open-cascade-sas/occt/wiki/sample_ocaf Defines a new model document 'OCAF-MyApplication', including its description, file extension, and the GUIDs for its storage, retrieval, and schema plugins. ```text formatlist:OCAF-MyApplication OCAF-MyApplication.Description: MyApplication Document Version 1.0 OCAF-MyApplication.FileExtension: sta OCAF-MyApplication.StoragePlugin: ad696000-5b34-11d1-b5ba-00a0c9064368 OCAF-MyApplication.RetrievalPlugin: ad696001-5b34-11d1-b5ba-00a0c9064368 OCAF-MyApplicationSchema: ad696002-5b34-11d1-b5ba-00a0c9064368 OCAF-MyApplication.AttributeStoragePlugin: 47b0b826-d931-11d1-b5da-00a0c9064368 OCAF-MyApplication.AttributeRetrievalPlugin: 47b0b827-d931-11d1-b5da-00a0c9064368 ``` -------------------------------- ### vdimention Command Examples Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Demonstrates creating length, angle, and radius dimensions using the vdimension command. Note that length dimensions require a working plane. ```php vinit vpoint p1 0 0 0 vpoint p2 50 50 0 vdimension dim1 -length -plane xoy -shapes p1 p2 ``` ```php vpoint p3 100 0 0 vdimension dim2 -angle -shapes p1 p2 p3 ``` ```php vcircle circle p1 p2 p3 0 vdimension dim3 -radius -shapes circle vfit ``` -------------------------------- ### Get Topological Variable from DBRep Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Example of retrieving a TopoDS_Shape object from DBRep using its variable name. This is typically used within a custom Draw command. ```cpp int MyCommand (Draw_Interpretor& theCommands, int argc, char** argv) {...... // Creation of a TopoDS_Shape from a Draw topological // name TopoDS_Shape aShape = DBRep::Get(argv[1]); } ``` -------------------------------- ### Initialize VTK Viewer Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Creates a window for the VTK viewer. ```php ivtkinit ``` -------------------------------- ### Get Geometric Variable from DrawTrSurf Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Example of retrieving a Geom_Geometry object from DrawTrSurf using its variable name. This is typically used within a custom Draw command. ```cpp int MyCommand (Draw_Interpretor& theCommands, int argc, char** argv) {...... // Creation of a Geom_Geometry from a Draw geometric // name occ::handle aGeom = DrawTrSurf::Get(argv[1]); } ``` -------------------------------- ### Post-Migration Formatting and Build Source: https://github.com/open-cascade-sas/occt/blob/master/adm/scripts/migration_800/README.md Standard commands to format code, build the project, and run tests after migration. ```bash # Run your CI/CD formatting tool (clang-format) ``` ```bash cmake --build build --config Release ``` ```bash ctest --test-dir build ``` -------------------------------- ### Get Nearest Solution Point (Method) Source: https://github.com/open-cascade-sas/occt/wiki/modeling_algos Retrieves the solution point that is closest to the original starting point. This method provides direct access to the best-fit point on the curve. ```cpp gp_Pnt P1 = Projector.NearestPoint(); ``` -------------------------------- ### Get Distance from Start Point to Solution Point Source: https://github.com/open-cascade-sas/occt/wiki/modeling_algos Calculates the distance between the initial point and a specific solution point on the curve, identified by its index. This helps in evaluating the accuracy of the projection. ```cpp Standard_Real D = Projector.Distance(Index); ``` -------------------------------- ### Realtime Initialization and Parameter Modification Source: https://github.com/open-cascade-sas/occt/wiki/de_wrapper Demonstrates how to register a node and modify internal parameters using a smart pointer. ```cpp // global variable static Handle(STEPCAFControl_ConfigurationNode) THE_STEP_NODE; static Handle(DE_ConfigurationNode) RegisterStepNode() { Handle(DE_Wrapper) aSession = DE_Wrapper::GlobalWrapper(); if (!THE_STEP_NODE.IsNull()) { return THE_STEP_NODE; } THE_STEP_NODE = new STEPCAFControl_ConfigurationNode(); aSession->Bind(THE_STEP_NODE); return THE_STEP_NODE; } // Change parameter value THE_STEP_NODE->InternalParameters.ReadRelationship = false; THE_STEP_NODE->InternalParameters.ReadName = false; THE_STEP_NODE->InternalParameters.ReadProps = false; ``` -------------------------------- ### Run Demonstration File Source: https://github.com/open-cascade-sas/occt/wiki/draw_scripts Executes a Tcl demonstration script provided with Open CASCADE. Replace '' with the desired script name. ```Tcl source ``` -------------------------------- ### DRAW Example: CellsBuilder Initialization and Build Source: https://github.com/open-cascade-sas/occt/wiki/boolean_operations Initializes the DRAW environment and performs the CellsBuilder operation on a set of objects. This is a common setup step before applying specific boolean operations. ```php bclearobjects bcleartools baddobjects c s f bfillds bcbuild r ``` -------------------------------- ### BRep File Example Source: https://github.com/open-cascade-sas/occt/blob/master/dox/specification/brep_format.md A sample .brep file demonstrating the structure of drawable shapes, locations, curve data, and polygon data. ```text DBRep_DrawableShape CASCADE Topology V1, (c) Matra-Datavision Locations 3 1 0 0 1 0 1 0 0 0 0 1 0 0 1 1 0 0 4 0 1 0 5 0 0 1 6 2 1 1 2 1 0 Curve2ds 24 1 0 0 1 0 1 0 0 1 0 1 3 0 0 -1 1 0 0 0 1 1 0 -2 1 0 1 0 0 1 0 1 0 0 0 -1 1 0 0 0 1 1 0 0 1 0 1 0 1 1 0 1 3 0 0 -1 1 1 0 0 1 1 0 -2 1 0 1 0 1 1 0 1 0 0 0 -1 1 1 0 0 1 1 0 0 0 1 1 0 0 1 0 1 3 0 0 1 1 0 0 1 0 1 0 0 0 1 1 0 2 1 0 1 3 0 0 1 1 0 2 1 0 Curves 13 1 0 0 0 0 0 1 1 0 0 3 -0 1 0 1 0 2 0 0 0 1 1 0 0 0 -0 1 0 1 1 0 0 0 0 1 1 1 0 3 0 1 0 1 1 2 0 0 0 1 1 1 0 0 -0 1 0 1 0 0 0 1 0 -0 1 0 0 3 1 0 -0 1 0 2 0 1 0 -0 1 0 2 3 1 0 -0 1 1 0 0 1 0 0 Polygon3D 1 2 1 0.1 1 0 0 2 0 0 0 1 PolygonOnTriangulations 24 2 1 2 p 0.1 1 0 3 2 1 4 p 0.1 1 0 3 2 2 3 p 0.1 1 0 2 2 1 2 p 0.1 1 0 2 2 4 3 p 0.1 1 0 3 2 1 4 p 0.1 1 0 3 2 1 4 p 0.1 1 0 2 2 1 2 p 0.1 1 0 2 2 1 2 ``` -------------------------------- ### Example: Raytracing Activation Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Demonstrates initializing the viewer and enabling raytracing for a displayed object. ```php vinit box b 10 10 10 vdisplay b vfit vraytrace 1 ``` -------------------------------- ### Project Point onto Curve on Surface Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Projects a point onto a curve that lies on a surface. The curve is defined by an edge and its face. An optional start parameter can be provided to guide the projection search. ```php projpcurve [] ``` ```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 ``` -------------------------------- ### Create a point cloud Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Initializes the viewer, creates a point cloud with specified parameters, and fits the view. ```tcl vinit vpointcloud pc 0 0 0 100 100000 surface -randColor vfit ``` -------------------------------- ### Configure and execute General Fuse algorithm in C++ Source: https://github.com/open-cascade-sas/occt/wiki/boolean_operations Demonstrates setting up arguments, configuring performance and safety options, and executing the operation using the BOPAlgo_Builder class. ```cpp BOPAlgo_Builder aBuilder; // Setting arguments TopTools_ListOfShape aLSObjects = …; // Objects aBuilder.SetArguments(aLSObjects); // Setting options for GF // Set parallel processing mode (default is false) Standard_Boolean bRunParallel = Standard_True; aBuilder.SetRunParallel(bRunParallel); // Set Fuzzy value (default is Precision::Confusion()) Standard_Real aFuzzyValue = 1.e-5; aBuilder.SetFuzzyValue(aFuzzyValue); // Set safe processing mode (default is false) Standard_Boolean bSafeMode = Standard_True; aBuilder.SetNonDestructive(bSafeMode); // Set Gluing mode for coinciding arguments (default is off) BOPAlgo_GlueEnum aGlue = BOPAlgo_GlueShift; aBuilder.SetGlue(aGlue); // Disabling/Enabling the check for inverted solids (default is true) Standard Boolean bCheckInverted = Standard_False; aBuilder.SetCheckInverted(bCheckInverted); // Set OBB usage (default is false) Standard_Boolean bUseOBB = Standard_True; aBuilder.SetUseOBB(buseobb); // Perform the operation aBuilder.Perform(); // Check for the errors if (aBuilder.HasErrors()) { return; } // Check for the warnings if (aBuilder.HasWarnings()) { // treatment of the warnings ... } // result of the operation const TopoDS_Shape& aResult = aBuilder.Shape(); ``` -------------------------------- ### vclipplane Command Example Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Illustrates setting a clipping plane using vclipplane with an equation and applying it to a view. Includes displaying a box and fitting the view. ```php vinit vclipplane pln1 -equation 1 0 0 -0.1 -set Driver1/Viewer1/View1 box b 100 100 100 vdisplay b vsetdispmode 1 vfit vrotate 10 10 10 vselect 100 100 ``` -------------------------------- ### Project Point onto Curve on Surface (Tcl) Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Projects a given point onto a curve that lies on a specified face. The curve must have a 2D representation on the face. An optional start parameter can be provided to guide the projection search. ```tcl projpcurve [] ``` -------------------------------- ### Configure GF Algorithm Options in C++ Source: https://github.com/open-cascade-sas/occt/blob/master/dox/specification/boolean_operations/boolean_operations.md Demonstrates how to set various options for the BOPAlgo_Builder, including parallel processing, fuzzy values, safe mode, gluing, inverted solid checks, and OBB usage before performing an operation. ```cpp BOPAlgo_Builder aBuilder; // Setting arguments NCollection_List aLSObjects = …; // Objects aBuilder.SetArguments(aLSObjects); // Setting options for GF // Set parallel processing mode (default is false) bool bRunParallel = true; aBuilder.SetRunParallel(bRunParallel); // Set Fuzzy value (default is Precision::Confusion()) double aFuzzyValue = 1.e-5; aBuilder.SetFuzzyValue(aFuzzyValue); // Set safe processing mode (default is false) bool bSafeMode = true; aBuilder.SetNonDestructive(bSafeMode); // Set Gluing mode for coinciding arguments (default is off) BOPAlgo_GlueEnum aGlue = BOPAlgo_GlueShift; aBuilder.SetGlue(aGlue); // Disabling/Enabling the check for inverted solids (default is true) bool bCheckInverted = false; aBuilder.SetCheckInverted(bCheckInverted); // Set OBB usage (default is false) bool bUseOBB = true; aBuilder.SetUseOBB(bUseOBB); // Perform the operation aBuilder.Perform(); // Check for the errors if (aBuilder.HasErrors()) { return; } // Check for the warnings if (aBuilder.HasWarnings()) { // treatment of the warnings ... } // result of the operation const TopoDS_Shape& aResult = aBuilder.Shape(); ``` -------------------------------- ### Install Custom Install Script Source: https://github.com/open-cascade-sas/occt/blob/master/CMakeLists.txt Installs a custom install script using a template, with a name derived from compiler and bitness settings. ```cmake set (SUB_CUSTOM_BUILD_NAME "custom_${COMPILER}_${COMPILER_BITNESS}.install.${SCRIPT_EXT}") # Set custom bin/lib paths variable for template if (LAYOUT_IS_VCPKG) # For vcpkg layout, paths need to handle debug/release structure # Debug builds: scripts in debug/bin, need to go ../../ to reach root # Release builds: scripts in bin, need to go ../ to reach root if (WIN32) set (OCCT_CUSTOM_BIN_LIB_PATHS "set \"CSF_OCCTBinPath=%CASROOT%\\bin\"\n set \"CSF_OCCTLibPath=%CASROOT%\\lib\"\n if exist \"%SCRIPTROOT%\\..\\..\\include\" (\n set \"CASCONTENTROOT=%SCRIPTROOT%\\..\\..\"\n ) else (\n set \"CASCONTENTROOT=%SCRIPTROOT%\\..\"\n )\n set \"CSF_OCCTIncludePath=%CASCONTENTROOT%\\include\"\n set \"CSF_OCCTResourcePath=%CASCONTENTROOT%\\share\\${OCCT_PROJECT_NAME}\"\n set \"CSF_OCCTDataPath=%CASCONTENTROOT%\\share\\${OCCT_PROJECT_NAME}\"\n set \"CSF_OCCTTestsPath=%CASCONTENTROOT%\\share\\${OCCT_PROJECT_NAME}\\tests\"\n set \"CSF_OCCTDocPath=%CASCONTENTROOT%\\share\\${OCCT_PROJECT_NAME}\\doc\"") else() set (OCCT_CUSTOM_BIN_LIB_PATHS "export CSF_OCCTBinPath=\"${CASROOT}/bin\"\n export CSF_OCCTLibPath=\"${CASROOT}/lib\"\n if [ -d \"${aScriptPath}/../../include\" ]; then\n export CASCONTENTROOT=$(cd \"${aScriptPath}/../..\" && pwd)\n else\n export CASCONTENTROOT=$(cd \"${aScriptPath}/..\" && pwd)\n fi\n export CSF_OCCTIncludePath=\"${CASCONTENTROOT}/include\"\n export CSF_OCCTResourcePath=\"${CASCONTENTROOT}/share/${OCCT_PROJECT_NAME}\"\n export CSF_OCCTDataPath=\"${CASCONTENTROOT}/share/${OCCT_PROJECT_NAME}\"\n export CSF_OCCTTestsPath=\"${CASCONTENTROOT}/share/${OCCT_PROJECT_NAME}/tests\"\n export CSF_OCCTDocPath=\"${CASCONTENTROOT}/share/${OCCT_PROJECT_NAME}/doc\"") endif() # For vcpkg, we handle all paths in the bin/lib paths logic above set (OCCT_CUSTOM_ADDITIONAL_PATHS "") else() # For other layouts, use CASROOT with full paths including build-specific suffixes if (WIN32) set (OCCT_CUSTOM_BIN_LIB_PATHS "set \"CSF_OCCTBinPath=%CASROOT%/${INSTALL_DIR_BIN}%3\"\n set \"CSF_OCCTLibPath=%CASROOT%/${INSTALL_DIR_LIB}%3\"") set (OCCT_CUSTOM_ADDITIONAL_PATHS "set \"CSF_OCCTIncludePath=%CASROOT%/${INSTALL_DIR_INCLUDE}\"\n set \"CSF_OCCTResourcePath=%CASROOT%/${INSTALL_DIR_RESOURCE}\"\n set \"CSF_OCCTDataPath=%CASROOT%/${INSTALL_DIR_DATA}\"\n set \"CSF_OCCTTestsPath=%CASROOT%/${INSTALL_DIR_TESTS}\"\n set \"CSF_OCCTDocPath=%CASROOT%/${INSTALL_DIR_DOC}\"") else() set (OCCT_CUSTOM_BIN_LIB_PATHS "export CSF_OCCTBinPath=\"${CASROOT}/${INSTALL_DIR_BIN}\"\n export CSF_OCCTLibPath=\"${CASROOT}/${INSTALL_DIR_LIB}\"") set (OCCT_CUSTOM_ADDITIONAL_PATHS "export CSF_OCCTIncludePath=\"${CASROOT}/${INSTALL_DIR_INCLUDE}\"\n export CSF_OCCTResourcePath=\"${CASROOT}/${INSTALL_DIR_RESOURCE}\"\n export CSF_OCCTDataPath=\"${CASROOT}/${INSTALL_DIR_DATA}\"\n export CSF_OCCTTestsPath=\"${CASROOT}/${INSTALL_DIR_TESTS}\"\n export CSF_OCCTDocPath=\"${CASROOT}/${INSTALL_DIR_DOC}\"") endif() endif() OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.install.${SCRIPT_EXT}.in" "${SUB_CUSTOM_BUILD_NAME}" "${SUB_CUSTOM_NAME}" "${INSTALL_DIR_SCRIPT}") ``` -------------------------------- ### Load Default Plugin Example Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Example of using the 'pload' command without arguments to load the default DrawPlugin and the DEFAULT key, activating basic modeling commands. ```tcl Draw[] pload (equivalent to pload -DrawPlugin DEFAULT). ``` -------------------------------- ### vplane Command Example Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Shows how to define a plane using the vplane command, specifying an axis and a point on the plane. ```php vinit vpoint p1 0 50 0 vaxis axe1 0 0 0 0 0 1 vtrihedron tr vplane plane1 axe1 p1 ``` -------------------------------- ### Install Package Version File Source: https://github.com/open-cascade-sas/occt/blob/master/CMakeLists.txt Installs the generated OpenCASCADEConfigVersion.cmake file to the CMake installation directory. ```cmake install (FILES "${CMAKE_BINARY_DIR}/OpenCASCADEConfigVersion.cmake" DESTINATION "${INSTALL_DIR_CMAKE}") ``` -------------------------------- ### BRepGraph Builder Options Source: https://github.com/open-cascade-sas/occt/blob/master/src/ModelingData/TKBRep/BRepGraph/README.md Explains the BRepGraph_Builder::Perform() method and the CreateAutoProduct option for controlling root product creation. ```text After topology population, BRepGraph_Builder::Perform() can auto-create a single root Product wrapping the top-level topology node. This graph-level policy is controlled by BRepGraph_Builder::BuildOptions::CreateAutoProduct (default true), because it is implemented by the builder layer rather than the backend population pipeline. When disabled (e.g. XCAF builder manages Products itself), the caller is responsible for creating Products. ``` -------------------------------- ### Install Test Cases Source: https://github.com/open-cascade-sas/occt/blob/master/CMakeLists.txt Conditionally installs test cases to the specified installation directory if the INSTALL_TEST_CASES option is enabled. ```cmake if (INSTALL_TEST_CASES) OCCT_INSTALL_FILE_OR_DIR ("tests/" "${INSTALL_DIR_TESTS}") endif() ``` -------------------------------- ### vconnect Command Example Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness Illustrates connecting objects using the vconnect command, specifying a target object and connection parameters. ```php vinit vpoint p1 0 0 0 vpoint p2 50 0 0 vsegment segment p1 p2 restore CrankArm.brep obj vdisplay obj vconnect new obj 100100100 1 0 0 0 0 1 ``` -------------------------------- ### Plugin Factory Implementation Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Example of implementing a plug-in library for the Draw Test Harness. It includes the necessary macro to declare the entry point and a factory method to activate commands. ```cpp #include void MyPack::Factory(Draw_Interpretor& theDI) { ... // MyPack::CurveCommands(theDI); ... } // Declare entry point PLUGINFACTORY DPLUGIN(MyPack) ``` -------------------------------- ### Example DrawPlugin Resource File Excerpt Source: https://github.com/open-cascade-sas/occt/wiki/draw_test_harness This excerpt shows the structure of a DrawPlugin resource file, defining keys that map to visualization, kernel, and toolkit names. ```plaintext OCAF : VISUALIZATION, OCAFKERNEL VISUALIZATION : AISV OCAFKERNEL : DCAF DCAF : TKDCAF AISV : TKViewerTest ``` -------------------------------- ### Build and Install Tk on macOS Source: https://github.com/open-cascade-sas/occt/wiki/building_3rdparty Configure, build, and install Tk from source on macOS, linking against the Tcl installation. ```bash cd TK_SRC_DIR/macosx ``` ```bash configure --enable-gcc --enable-shared --enable-threads --with-tcl=TCL_LIB_DIR --prefix=TK_INSTALL_DIR ``` ```bash make ``` ```bash make install ``` -------------------------------- ### Configure and Install Environment Script (Unix-like) Source: https://github.com/open-cascade-sas/occt/blob/master/CMakeLists.txt Configures and installs a combined environment script for building and installation on Unix-like systems. ```cmake OCCT_CONFIGURE_AND_INSTALL ("adm/templates/env.install.${SCRIPT_EXT}.in" "${SUB_ENV_BUILD_NAME}" "${SUB_ENV_NAME}" "${INSTALL_DIR_SCRIPT}") ``` -------------------------------- ### Generate HTML Overview Documentation Source: https://github.com/open-cascade-sas/occt/blob/master/dox/contribution/documentation/documentation.md Use this CMake target to generate the HTML documentation for the Overview and User Guides. Ensure your build is configured with `-DBUILD_DOC_Overview=ON`. ```bash cmake --build . --target Overview ``` -------------------------------- ### Generate Combined Documentation Source: https://github.com/open-cascade-sas/occt/blob/master/dox/contribution/documentation/documentation.md Use this CMake target to generate both the HTML Overview and Reference Manual documentation. Ensure your build is configured with the appropriate documentation options. ```bash cmake --build . --target doc ``` -------------------------------- ### Install Emscripten Build Artifacts Source: https://github.com/open-cascade-sas/occt/blob/master/src/Draw/DRAWEXE/CMakeLists.txt Installs the generated HTML, ICO, data, and optional worker.js files for the Emscripten build to the designated installation directory. ```cmake install(FILES ${PROJECT_NAME}.html DESTINATION "${INSTALL_DIR_BIN}/${OCCT_INSTALL_BIN_LETTER}") install(FILES ../DrawResources/lamp.ico DESTINATION "${INSTALL_DIR_BIN}/${OCCT_INSTALL_BIN_LETTER}") install(FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.data DESTINATION "${INSTALL_DIR_BIN}/${OCCT_INSTALL_BIN_LETTER}") if (CMAKE_CXX_FLAGS MATCHES "-pthread") install(FILES ${CMAKE_BINARY_DIR}/${OS_WITH_BIT}/${COMPILER}/bin\${OCCT_INSTALL_BIN_LETTER}/${PROJECT_NAME}.worker.js DESTINATION "${INSTALL_DIR_BIN}/${OCCT_INSTALL_BIN_LETTER}") endif() ``` -------------------------------- ### Vector Algebra Example Source: https://github.com/open-cascade-sas/occt/blob/master/dox/user_guides/draw_test_harness/draw_test_harness.md Demonstrates the use of vector algebra commands, including setting vectors, calculating cross products, and finding the module of a vector. ```tcl 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] 4 -7 -10 Draw[14]> set cross [eval cross $vec1 $vec2] -300 0 -120 Draw[15]> eval module $cross 323.10988842807024 ``` -------------------------------- ### Install Deprecated NCollection Alias Headers Source: https://github.com/open-cascade-sas/occt/blob/master/CMakeLists.txt Installs deprecated NCollection alias headers from the 'src/Deprecated/NCollectionAliases/' directory to the specified installation destination for backward compatibility. ```cmake install(DIRECTORY src/Deprecated/NCollectionAliases/ DESTINATION "${INSTALL_DIR_INCLUDE}") ``` -------------------------------- ### Validate and Install Custom Scripts Source: https://github.com/open-cascade-sas/occt/blob/master/CMakeLists.txt Checks if custom scripts exist and if additional content needs to be appended before installing them. It uses the OCCT_CONFIGURE_AND_INSTALL macro for the installation process. ```cmake if (EXISTS "${CMAKE_BINARY_DIR}/custom.${SCRIPT_EXT}" AND EXISTS "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}") file (READ "${INSTALL_DIR}/${INSTALL_DIR_SCRIPT}/custom.${SCRIPT_EXT}" CUSTOM_CONTENT) string(FIND "${CUSTOM_CONTENT}" "${ADDITIONAL_CUSTOM_CONTENT}" pos) if (pos EQUAL -1) set (CUSTOM_CONTENT "${CUSTOM_CONTENT} ${ADDITIONAL_CUSTOM_CONTENT}") OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR_SCRIPT}") endif() else() OCCT_CONFIGURE_AND_INSTALL ("adm/templates/custom.${SCRIPT_EXT}.main" "custom.${SCRIPT_EXT}" "custom.${SCRIPT_EXT}" "${INSTALL_DIR_SCRIPT}") endif() ```