pen Cascade is an open-source 3D modeling and full-fledged computer-aided design (CAD) library first developed by Matra Datavision and now maintained at OpenCascade.org. While it is an enormously powerful tool, we've encountered a few minor limitations that we needed to correct, and have made a minor improvement or two. Since Open Cascade itself is open source, we've made the source code to our improvements available here for free. We'd love to see these improvements incorporated into the latest version of Open Cascade, but until then, we've made the changes available to you here.
The fixes - changing to the standard C++ library, reorganizing the header files into a directory structure, and using precompiled headers - required simple changes to nearly every file in the Open Cascade source tree. Therefore rather than providing the modified code, we've written a program that processes an existing Open Cascade source tree and modifies the code. This ImproveCascade program should let you to apply the improvements to any version of the Open Cascade library.
The basic steps to use the ImproveCascade tool are:
- Download the file fdstream.hpp (or get it directly from the original author, Nicolai Josuttis) and save it in your OpenCascade's "inc" directory.
- Download the single-file source code, ImproveCascade.cpp.
- Compile the ImproveCascade.cpp source file to create an executable.
- In your Open Cascade source code directory, rename the directories "src" to "src-old", "inc" to "inc-old", and "drv" to "drv-old".
- Run the executable followed by one or more of the command-line options described below, followed by the path to your Open Cascade directory.
- Build the Open Cascade library normally following the standard build instructions for your platform.
- When the process is complete, you have tested compiling your applications against the new Open Cascade library, and you are satisfied with the results, you may delete the "src-old", "inc-old", and "drv-old" directories.
Feel free to contact us if you have any questions about the tool or wish to contribute extensions or improvements. Also see the ImproveCascade Project Page at the Open Cascade Contributor's Portal.
Support New C++ standards
The -s option modifies the source code to conform to now widespread C++ standards, such as using the header file <ostream>, which places definitions in the std:: namespace, rather than using the <ostream.h> header file, which places definitions in the global namespace. This change is necessary in order to compile the code on newer compilers such as Microsoft Visual Studio .NET 2003, or on any other compiler that no longer supports the older C++ libraries.
Reorganize the Massive inc Directory
The -i option modifies the inc directory to reorganize the 12,000+ Open Cascade header files into subdirectories, and also modifies the source code to look for header files in these new locations using explicit directory specifications. Prior to making this change, we encountered numerous problems with having over 12,000 header files in a single directory. Everything from the operating system to our virus scanning and backup software had trouble with the enormous directory, and compilation of client applications and of Open Cascade itself took far too much time. Every #include statement required the compiler or C preprocessor to open that enormous directory and search it for the named header file, even for header files that would actually be located in some other directory.
If you use this option, you will have to make minor changes to your source code to use this modified version of the library. The reorganization of the header files was very simple, ImproveCascade just replaces "_" with "/" in all header file names except for a few cases where doing so would have conflicted with preprocessor macro symbols (so file names containing "WNT", "MFT", "HVertex", "HCurve2d", or "HSurface" were left unchanged.) For example, you will have to change #include lines in your application source code from #include <Standard_Stream.hxx> to #include <Standard/Stream.hxx>, change #include <PBRep_PolygonOnClosedTriangulation.ixx> to #include <PBRep/PolygonOnClosedTriangulation.ixx>, and so forth. The benefits are a more orderly header file, faster compilation, and eliminating the various problems associated with a directory of 12,000+ files.
Use Precompiled Headers
The -p option creates OCC.h and OCC.cpp files that can be used to build a precompiled header file, and then modifies every source file in Open Cascade to add #include "OCC.h" as the first line of the file. The goal was to further speed the compilation of Open Cascade itself by taking advantage of the compiler's ability to precompile common header files. However, even after modifying the Microsoft Visual Studio project files to take advantage of this feature, we found very little speed improvement in the compilation of Open Cascade. We've left the option in in case others want to try it out. Please let us know if you gain any speed improvement with this option, or if you are able to improve this option to make it work better.