Transition between 2D and 3D is very slow

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
FieldConsult
Posts: 54
Joined: 14 Mar 2015, 22:33

Transition between 2D and 3D is very slow

Post by FieldConsult » 27 Jun 2018, 21:27

Whenever I create an image with a considerable number of triangles, the transition between 2D and 3D is very slow. Is it necessary to re-read all the entities each time the 2D or 3D viewer is set?

According to the code, when go from 2D to 3D visualization, iterate process through all the entities in the image is go for to redraw them in the Freeform of GLScene, as you can avoid this process, since it overdens the application process too much ? Is it possible to draw directly on the GLScene from the beginning and, if possible, how?
Triangles Colors.PNG
Triangles Colors.PNG (17.54 KiB) Viewed 32266 times
Another aspect of the problem is that on many occasions the color of the triangles does not follow the pattern indicated and the result is of very poor quality, the code does a quality job but the display spoils the result, see the attached image. Is it possible to correct this color display error so that a flat surface looks really flat?

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Transition between 2D and 3D is very slow

Post by support » 28 Jun 2018, 17:57

Hello,

Iteration through all the entities normally occurs when the 3D scene is regenerated that in turn occurs if the drawing or triangulation quality were changed. When you switch between visualization modes (2D <-> 3D), the 3D scene shouldn't be regenerated. Please post a code which switches visualization mode from 2D to 3D, we will check it.

As for the problem with the color of triangles, could you please post a code which was used for setting a TsgDXF3dFace color? If you see graphic artifacts when rotating the model (particular triangles are displayed with a wrong color), it may be a GLScene or graphic card issue.

Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

FieldConsult
Posts: 54
Joined: 14 Mar 2015, 22:33

Re: Transition between 2D and 3D is very slow

Post by FieldConsult » 28 Jun 2018, 21:20

For example: if I draw the triangles with the 3D view activated and the 2D view deactivated, the image is not reflected at the end of the process of drawing the triangles (the number of triangles varies with the type of model, from a few hundred to a few thousand). The 2D view must be activated first and then switch to the 3D view to activate the first refresh of the drawing.

Code: Select all

  //Drawing process
  dwgForm.dwg3DView.BeginUpdate; //different attempts, it can be use or both
    dwgForm.dwg2DView.BeginUpdate; //different attempts, it can be use or both
      dwgForm.OnProgress:= OnProgress; does not affect the drawing speed
      DrawIfcModel(FIfcModel); //process of generating the triangles on the image
      //canceled as it does not help with drawing speed
      //dwgForm.DwgCADImage.RefreshCurrentLayout;       
     //dwgForm.dwg2DView.FitToSize; 
      dwgForm.SetViewer; //Process to change from 2D view to 3D view
    dwgForm.dwg2DView.EndUpdate;
  dwgForm.dwg3DView.EndUpdate;

Code: Select all

  //dwgForm.SetViewer //Process to change from 2D view to 3D view
  if sCadImage = nil then Exit;
  try
    if not dwg3DView.Visible then
    begin
      dwg3DView.Visible := True;
      dwg2DView.Visible := False;
      if dwg3DView.Empty then
      begin
        try
          Screen.Cursor := crHourGlass;
          dwg3DView.LoadFromConverter(sCadImage.Converter, sCadImage);
        finally
          Screen.Cursor := crDefault;
        end;
      end
      else
        LoadViewFromCADImage(sCadImage, dwg3DView);
    end;
    if dwg3DView.ShowingStyle <> AStyle then
      dwg3DView.ShowingStyle := AStyle;

    HideOrbit3D;

  except on E: Exception do
  end;
The code comes from one examples of your library.

Test1: Draw the triangles in the image with the Visible 3D view (3DNavigator) and the hidden 2D view (Visible = False). When finishing the tracing of the triangles, the view does not show anything, it is empty, we proceed to show the 2D view and hide the 3D view, the application is blocked for almost a minute and finally shows the top view of the drawing (vTop), we proceed to activate the 3D view to visualize the model in perspective, the application is blocked while the view is refreshed and after 15 minutes must be suspended, completely blocked.

Test2: We proceed to draw the triangles with the visible 2D view and the hidden 3D view (Visible = False), the drawing process takes a normal time less than one minute but, when the application executes the code to activate the 3D view the application is blocked (not responding), again and after more than 10 minutes, hopefully the 3D view is shown.

Between 2 to 3 times out of 10 there is luck and it is possible to show the model in 3D visualization.

In question to the colors of the triangles, it is not a problem of card or user memory or something similar. The following image is from the same application, the same code, that I have done in Visual Studio with C # and C ++ code, separately, and both give me the same result, the colors are even, as it should be, see image.
Triangles Colors2.PNG
Triangles Colors2.PNG (38.4 KiB) Viewed 32228 times
The color assignment is made on the layers and not on the triangles, therefore all the triangles of the same layer have the same color. The triangles are grouped in several blocks that are assigned to the same layer, that is, in a layer there can be 2 or 20 blocks with a different number of triangles in them.

The triangle is created and associated with an active block, then the active block is associated with a new DXFInsert and the latter is associated with the image.

FieldConsult
Posts: 54
Joined: 14 Mar 2015, 22:33

Re: Transition between 2D and 3D is very slow

Post by FieldConsult » 29 Jun 2018, 21:11

Testing again:

Triangles draw with the library on 3DNavigator:
Triangles Colors3.PNG
Triangles Colors3.PNG (9.91 KiB) Viewed 32184 times
The same triangles, saved to dwg file with the library and open with Autocad:
Triangles Colors4.PNG
Triangles Colors4.PNG (8.6 KiB) Viewed 32184 times
Colors of the triangles are wrong with the library not with the video card or something else.

The same file saved with the library open with the delphi application, again:
Triangles Colors5.PNG
Triangles Colors5.PNG (10.4 KiB) Viewed 32184 times
The second time you open the same image with the same application in Delphi, the colors of the triangles are inverted, the first image Colors3, the light color is in the upper part but, in the image Colors5 the light color is in the part lower.

How is this possible?

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Transition between 2D and 3D is very slow

Post by support » 29 Jun 2018, 21:31

Hello,

Thank you for the detailed description of the issues.

Judging by the code which switches to 3D visualization and your test cases, a bottleneck is this particular case is Tsg3DDrawingNavigator.LoadFromConverter method which iterates through the entities in TsgDXFConverter. Unfortunately, for now there is no other method for rendering a 3D scene in Tsg3DDrawingNavigator. As for the problem with color of triangles, it may be purely a GLScene issue.

To find a way of resolving both issues, we need to reproduce them using the drawing files from your test cases (those that are shown on Triangles Colors.PNG images). It would be helpful, if you could send them to us.


Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

FieldConsult
Posts: 54
Joined: 14 Mar 2015, 22:33

Re: Transition between 2D and 3D is very slow

Post by FieldConsult » 29 Jun 2018, 22:38

I have sent the file to the support by mail:
The files is: Triangles Test Files.zip

Remember that this file was created after reading all the information of structures from a source file in IFC format

Thank!

FieldConsult
Posts: 54
Joined: 14 Mar 2015, 22:33

Re: Transition between 2D and 3D is very slow

Post by FieldConsult » 30 Jun 2018, 15:16

This is not a version problem, this is the same file using the demo version of v12
Triangles Colors v12.PNG
Triangles Colors v12.PNG (50.93 KiB) Viewed 32133 times

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Transition between 2D and 3D is very slow

Post by support » 03 Jul 2018, 21:30

FieldConsult wrote:This is not a version problem, this is the same file using the demo version of v12
There is a problem in our code. I have forwarded the given issue to the development team by opening a support case.

Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

FieldConsult
Posts: 54
Joined: 14 Mar 2015, 22:33

Re: Transition between 2D and 3D is very slow

Post by FieldConsult » 20 Aug 2018, 21:18

It is possible to tell us how to solve this problem since the presentation makes it unfeasible to use the library for professional and serious development?.

The 3D visualization is horrible

Tahnks!!

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Transition between 2D and 3D is very slow

Post by support » 20 Aug 2018, 21:27

Hello,

You will have to wait until this problem is solved in CAD VCL source code. Unfortunately, we don't have a workaround for it.

Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply