This is a story about how we built a new C3D Viewer into the LOTSMAN: PLM product lifecycle management system, why we did it, and what we did.

.1 What is a “secondary view”
Any notable PLM solution includes PDM (Product Data Management) mechanisms / subsystem.
The PDM-system database stores documents and files created in various CAD systems: 3D models, drawings, specifications and calculations.
')
In order for the content of these documents to be available to those users who do not have the appropriate CAD applications installed at the workplace (and they are very expensive), the PDM system creates a “secondary presentation of the document” - a copy of the document in some "Neutral" publicly available format.
After the “secondary view” is loaded into the system, based on it, you can build a preview of the document content directly in the PDM-system client interface; use as a carrier when exchanging information with external users, in the coordination processes and in the exchange of comments using notes and annotations.
.2 Secondary presentation at LOTSMAN: PLM
At various times, VRML, eDrawings, and 3D PDF alternated in their role as a “secondary view” of 3D models at LOTSMAN: PLM.
About VRML, I will not speak - the mistakes of youth ... who does not happen.
eDrawings was not bad, but you had to pay very immodest money to develop an adapter to it and support services. In addition, starting in 2014, eDrawings became available only in the x64 version. We couldn’t embed it in our 32bit client LOTSMAN: PLM as ActiveX anyway.
3D PDF initially seemed to be a gift - free, already installed on every first computer, the de facto standard in our galaxy arm, plus the ready-made ActiveX library suitable for embedding, but over time, its dark side began to open to us:
- We have the right to distribute Acrobat Reader in its distribution. It turned out that Acrobat Reader is not installed on every first computer. Sometimes there is an incompatible version of Acrobat Reader installed, and sometimes another PDF viewer that is incompatible with Acrobat Reader and, at the same time, very expensive for the user's heart.
- Acrobat Reader development vector is unpredictable. Each release is full of surprises and adds an arsenal of tools that we use to automatically close windows of unnecessary messages, minimize annoying panels, and install vaguely documented options.
- The release of the Acrobat Reader update is sudden and inevitable. About him, we learn from the messages of users that we have stopped working "secondary view".
- Feedback from the developer is probably possible, but, as regular study of the sad forums shows, is hopeless.
- Sometimes using ActiveX Acrobat Reader crashes your application. We finally arrived at using SafeMode in Acrobat Reader. In this mode, only the hidden child process Acrobat Reader crashes periodically, and our application continues to work.
- ActiveX Acrobat Reader is available only in 32bit version without options.
And most importantly - poor performance when working with large models (assemblies):
- Slow export from KOMPAS-3D to 3D PDF.
Perhaps part of the responsibility lies with KOMPAS-3D, but what is - that is. - The large size of the 3D PDF file, which increases the load on the file system and the network and requires more RAM.
The search for optimal, in terms of the ratios of the accuracy of the output models to the file size, settings did not give acceptable results. - Slow loading speed for large 3D PDF models.
- Poor speed / quality of rendering large files.
.3 Meet the C3D Viewer
We have always followed with interest the successes and novelties of C3D Labs (still a subsidiary of ASCON, colleagues). The appearance of the new C3D Viewer has not gone unnoticed. Having gained access to early beta versions of the product, we conducted a comparative study of functionality and performance.
The results of the research inspired us to launch the project, the outcome of which was to be the embedding of the C3D Viewer component as a means of viewing and annotating the secondary presentation of 3D models in LOTSMAN: PLM.
- Acceleration of saving to C3D format compared to PDF - from 6 to 18 times!
No correlation was found with the size of the models and the number of components. - C3D files are smaller than PDF files - from 2 to 39 times!
- Download speed of C3D files is faster than PDF download speed - from 6 to 264 times.
No correlation was found with the size of the models and the number of components. - The quality and smoothness of the display while rotating with C3D Viewer is much higher than the quality of Adobe Reader.
For unknown reasons, measuring FPS in Adobe Reader did not always work. In cases where metering attempts were successful, the FPS did not exceed the value "5". C3D Viewer "twists" with a speed of 30-100 ++ FPS on different models.
The interest in the project was mutual, which in the best way affected the quality of interaction with the developers and the speed of solving various problems.
According to our requests, the C3D Labs team has developed a functional for annotating 3D models and provided localization in Russian.
A number of improvements to the C3D Viewer API were due to the specific use of the component in our application. As a result, new methods and events appeared in the API, which allowed us to implement our own mechanism for indicating the progress of model loading and emergency interruption / cancellation of loading.
And since I mentioned the high cost of eDrawings, it is fair to say that the C3D Viewer is also not free for us, but the conditions for its use are much more democratic.
.4 Embedding
At the beginning, you should give a brief technical description of the system into which we were to embed C3D Viewer, the LOTSMAN: PLM client application.
This is a desktop Win32 application with an MDI interface, written in Delphi 2006.
The layout of the child MDI windows is dynamic, built on the basis of the description of a set of interrelated "panels", each of which represents a certain aspect of information about the specified object.
The C3D Viewer software component is the ActiveX COM Library (C ++, Qt).
The API is simple and compact, the key operations are asynchronous, they are executed in a separate thread, so the interaction with the component is based on calling methods and handling events.
The prototype of the secondary view module was assembled and integrated into LOTSMAN: PLM took only a couple of hours, but other “trifles” required much more time.
We have implemented our own toolbars, a context menu, a panel displaying the structure of the model, and a panel with a list of annotations in the required volume and form, in accordance with the general visual style of the application interface.
We use the component in several modes of working with the secondary view: built-in view, full-screen view and annotation mode.


What were the difficulties:
Import Type Library Description
One of the first problems was that Delphi 2006 incorrectly imports the type library description from the ActiveX C3D Viewer, which is written in C ++ c Qt.
They got out by applying the import utility of the Delphi 2010 type library, which, however, also did not give 100% the correct result - we had to fix a dozen lines manually.
Difficulties of "adoption"
In our application, the user has a WYSIWYG layout editor, which allows you to add and move “panels” with information. On one of these panels is located and ActiveX C3D Viewer.
It turned out that when you move the panel from the ActiveX C3D Viewer to another “container”, its partial “destruction” occurs.
Found out that the reason - in a specific implementation of the mechanism for changing the parent window VCL Delphi. In short, winapi eventually calls DestroyWindow ActiveX C3D Viewer, after which it starts to consider itself "killed", and Delphi, meanwhile, continues to consider it "alive."We bypassed this problem by placing ActiveX in a special container that knows how to determine that the parent window is being changed, and at this moment it correctly releases ActiveX and creates it again.
Memory problems
We have a 32-bit application, and “Out of memory” has not been canceled. The possibility of the appearance of huge assemblies in conditions of a limited 2 GB of RAM size inevitably led to the fact that the problem became more acute.
Particularly acute was the fact that if the memory was running out during the loading of the model in the C3D Viewer, this led to an unexpected abnormal termination of the entire application.
The reason could not be determined immediately. I had to develop my own PostMortem Debugger based on the sampling profiler, which restored the stack using the JDBG debug information.
Understanding the reason, we started by increasing the available RAM limit to 3.5 GB by adding the IMAGE_FILE_LARGE_ADDRESS_AWARE flag to the EXE header, somewhat reducing the memory consumption in your application, but did not enjoy the result.
The fact is that if you have a 32-bit MDI application (with a multi-window interface), then the user, in principle, can open an unlimited common sense number of windows. And he will do it. Has the right to.
To reduce the likelihood of problems associated with a lack of memory, we have embedded in the application mechanism to control and optimize memory usage. When a certain limit is reached, the currently inactive MDI windows are plunged into “sleep mode”, thereby freeing up resources.
Problems with virtual machines
C3D Viewer requires at least 2.1 to display OGL version. We tried different virtual machines, here is some information about it:
Hyper-V - C3D Viewer does not work.
Virtual Box 4.1.44 + Window 7 - C3D Viewer works.
VMWare Player v14 (Accelerate 3D Graphics + OGL v3 in settings) - C3D Viewer works.
As a result, the active phase of development and debugging of a new viewer took about two months. Another two or three weeks we spent on the elimination of errors.
.5 What's ahead
In the next versions of the C3D Viewer, we hope to see the dynamic section functions, model measurements, new features for working with PMI, model configurations in conjunction with KOMPAS-3D and LOTSMAN: PLM.
PS
There is a free version for exploring the C3D Viewer (download
here ). It does not include the API and some other features. The version for embedding can be requested for testing from the C3D Labs developers.

Sergey Ershov, Head of Applied Workstation, ASCON.