Export U3D / PDF3D from Visual C ++

I was asked to solve the memory usage problem of a CAD application written in Visual C ++, which occurs when I try to export a drawing to PDF3D.

The export function works well for simple models or only parts of a complex model, but not for the entire complex model.

We use the sourceforge U3D project to create a U3D object; after we paste it into the pdf. This is the problem of creating an object that is problematic.

The sourceforge U3D project is a library built into C ++ for use in C ++ too, which has been dead since 2007, has poor documentation, and its collection of samples is far from enough! The TODO list of the project also indicates that it has memory problems!

So, I was asked to attack the problem with two sides:

  • Support U3D code.

  • Change the way the application interacts with the U3D library.

They also said that side 2. is preferable since it is under our control.

When I tried to solve the problem, I got two conclusions:

  • I highly suspect that the U3D EncodeX method is responsible for misuse of memory.

  • I tried a lot of little things changes for how apllication interacts with lib (changing compression parameters, flags, etc.), and each time the result was a memory reallocation.

So the question is: is it worth continuing to use this library? The code is not happy to read ... Or maybe it would be nice to look at other libraries for the same purpose? I have not studied them, but I am seriously thinking about switching to VCGlib or libharu ... please offer something else if you know this is good.

Other alternatives would be: to use the Visual Technologies PDF3D exporter, which has unacceptable costs, or to develop my own implementation of the U3D exporter, which will have disadvantages as a very limited set of U3D functions, and also it could not prepare for the expected deadline. Therefore, prohibit these options.

I really need help deciding which is better.

Thanks in advance, SΓ©rgio

+2
source share
2 answers

After some despair and unsuccessful nights, trying to detect memory leaks or some other memory problems, we came to the conclusion about the most practical solution:

Extract only the part of the code needed to download the file, and export it as U3D to a small program and make it access the main CAD application. Although this is not the most elegant solution, it really works well - none of the processes reaches memory usage even close to the 2 GB barrier.

I'm sorry that I was not authorized to allow this before. I suggested several other things, such as:

  • 64 bit transition

  • Use the option supported by modern versions of Windows to expand the memory limit for each process to more than 2 GB.

None of these two solutions was acceptable, as it would be necessary to force some customers to reinstall already running hardware or software.

+1
source

Some comments: VCGlib is unrelated, MeshLab relies on VCGlib for basic functions, but for U3D, a command line export tool for converting from text format to U3D is used, and this tool is from sf U3D lib. libharu - can embed 3D models in its PDF output, and not create models (U3D or PRC files).

Another option is to display a different Adobe 3D PDF, PRC format. The Acrobat SDK has a pseudo-code format description. Based on this PRC conclusion, the Asymptote tool was implemented. Find it on sourceforge and ask a question on the Asymptote forum if you are interested.

+2
source

Source: https://habr.com/ru/post/1301751/


All Articles