C# Users: Features and Differences
Documentation
CEETRON Envision is written in C++ and the C# version is provided as a wrapper layer on top of this. Because of this, all documentation and tutorial snippets are provided in C++ only. Due to the close relations between the C++ and the C# languages, reading class/function description and code examples in the C++ generated documentation should be trivial for a C# programmer.
Namespaces
While the namespaces in C++ are quite short (cee::ug, cee::vis, …) the namespaces in the C# version have been written out with long names. The main namespace cee, is in C# replaced with company and product name Ceetron.CeetronEnvision. All namespaces under cee are renamed as follows:
vis -> Visualization
geo -> Geometry
ug -> UnstructGrid
win -> Win
exp -> Export
vtfx -> VTFx
imp.cae -> ImportCae
rep -> Report
plt -> Plot2d
All members of the Core component are located on the root namespace Ceetron.CeetronEnvision. Note that the same applies to C++ where they are located directly in the cee namespace.
Properties
The C# version uses properties instead of the standard set’ers and get’ers in C++. For instance, the visibility for an object is typically accessed using visible()/setVisible() in C++, while in C# it will be a property called Visible.
// C++
part->settings()->setVisible(true);
// C#
part.Settings.Visible = true;
Inheritance
Due to limitations in the C# wrapper layer, there is a special handling of inheritance in the C# version of CEETRON Envision. The problem is downcasting objects that are fetched from within CEETRON Envision. For instance:
Model model = myView.model(0); // Get the first model (GeometryModel) from the Visualization.View instance.
GeometryModel normalCastGeometryModel = model as GeometryModel; // null due to wrapper limitations
GeometryModel ceeCastGeometryModel = GeometryModel.castFromBaseClass(model); // Correct cast
MarkupModel ceeCastedWrongModel = MarkupModel.castFromBaseClass(model); // null due to wrong cast
In this scenario, we KNOW that the first model in the view is of type GeometryModel, but casting using “as” will fail and normalCastGeometryModel will be null. To work around this limitation, we have provided casting methods for all such classes. Using the static castFromBaseClass will always give you a correct cast. For an invalid cast, the returned value will be null.
This downcasting issue only applies to objects retrieved from Ceetron toolkits. Casting will always work for classes created and managed in your application. For instance:
Model myModel = new GeometryModel();
GeometryModel normalCastMyGeometryModel = myModel as GeometryModel;
GeometryModel ceeCastMyGeometryModel = GeometryModel.castFromBaseClass(myModel);
In this case, both cast methods are valid and return the correct object of type GeometryModel.
Deployment
For CEETRON Envision, the development language is C++, which means that any product developed using one of our toolkits must distribute Visual C++ redistributables. To deploy redistributable Visual C++ files, you should use the Visual C++ Redistributable Packages that are included in Visual Studio, use redistributable merge modules, or you can directly install redistributable Visual C++ DLLs in the application local folder.
Using the redistributable packages is recommended because they enable automatic updates of the Visual C++ libraries.
The latest Visual C++ Redistributable Packages for all Visual Studio versions can be downloaded from: https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist
If you just deploy with the redistributable DLLs in the application folder, you will need to copy the following files:
vcruntime*.dll “C Runtime Library (CRT)”
msvcp*.dll “Standard C++ Library”