WriteVrml works only after XDisplay

I am trying to export VRML with Draw using WriteVrml. It works but only after I use XDisplay to render the document on the view. Without, the VRML is generated but only has a header and no geometry content:

Draw[25]> pwd
C:/OpenCASCADE-7.4.0-vc14-64/opencascade-7.4.0/data/step
Draw[28]> ReadStep D screw.step
 File STEP to read : screw.step
Document saved with name D
Draw[31]> WriteVrml D screw.wrl

screw.wrl:

#VRML V2.0 utf8

WorldInfo {
  info [
    "Generated by Open CASCADE Technology 7.4"
  ]
}

After rendering with XDisplay it works:

Draw[26]> vclear
Draw[27]> vinit View1
Driver1/Viewer1/View1
Draw[28]> ReadStep D screw.step
 File STEP to read : screw.step
Document saved with name D
Draw[29]> XDisplay -dispMode 1 D
D:the product name
Draw[31]> WriteVrml D screw.wrl

How can I avoid the rendering ?

andreasplesch_159166's picture

Let me know if I can provide anything else to help. WriteStep and WriteIges works as expected, eg. without displaying.

Patrik Mueller's picture

Hi Andreas,

never worked with Draw, but could you try to do

incmesh

after reading and before writing?

I assume

WriteVrml

need tesselation on the shape before writing. If you do a display this is done by AIS.

Best regards,

Patrik

andreasplesch_159166's picture

Thank you much. Indeed, generating a mesh worked:

Draw[1]> pload ALL
1
Draw[2]> cd data/step
Draw[3]> ReadStep A screw.step
 File STEP to read : screw.step
Document saved with name A
Draw[4]> XGetFreeShapes A shapes
shapes
Draw[5]> incmesh shapes 0.01 -relative
Incremental Mesh, multi-threading OFF
Meshing statuses: NoError
Draw[7]> WriteVrml A screwMeshed.vrml

The incmesh command is not documented in https://www.opencascade.com/doc/occt-7.4.0/overview/html/occt_user_guides__test_harness.html

I only used draw to reproduce a problem with python. I see that incmesh is the tcl command interface to https://www.opencascade.com/doc/occt-7.4.0/refman/html/class_b_rep_mesh___incremental_mesh.html

Are there examples or recommendations on how to use that class ? How does AIS determine good deflection values ?

Draw[12]> incmesh
Builds triangular mesh for the shape
usage: incmesh Shape LinearDeflection [options]
options:
        -a val          angular deflection for edges in deg
                        (default ~28.64 deg = 0.5 rad)

        -ai val         angular deflection inside of faces in deg
                        (default ~57.29 deg = 1 rad)

        -di val         Linear deflection used to tessellate the face interior.
        -min            minimum size parameter limiting size of triangle's
                        edges to prevent sinking into amplification in case
                        of distorted curves and surfaces

        -relative       notifies that relative deflection is used
                        (switched off by default)

        -int_vert_off   disables insertion of internal vertices into mesh
                        (enabled by default)
        -surf_def_off   disables control of deflection of mesh from real
                        surface (enabled by default)
        -parallel       enables parallel execution (switched off by default)
        -adjust_min     enables local adjustment of min size depending on edge size (switched off by default)
andreasplesch_159166's picture

Thanks that worked !

Draw[1]> pload ALL
1
Draw[2]> cd data/step
Draw[3]> ReadStep A screw.step
 File STEP to read : screw.step
Document saved with name A
Draw[4]> XGetFreeShapes A shapes
shapes
Draw[5]> incmesh shapes 0.01 -relative
Incremental Mesh, multi-threading OFF
Meshing statuses: NoError
Draw[7]> WriteVrml A screwMeshed.vrml
Draw[8]> help incmesh
incmesh         : Builds triangular mesh for the shape, run w/o args for help

I am using draw to reproduce an issue I had with python. incmesh uses

https://www.opencascade.com/doc/occt-7.4.0/refman/html/class_b_rep_mesh___incremental_mesh.html#details

Do you of examples or recommendation on how to use BRepMesh_IncrementalMesh ?

Especially with regards to automating deviation parameter selection ? How does AIS choose those for presentation triangulation ?

Draw[12]> incmesh
Builds triangular mesh for the shape
usage: incmesh Shape LinearDeflection [options]
options:
        -a val          angular deflection for edges in deg
                        (default ~28.64 deg = 0.5 rad)

        -ai val         angular deflection inside of faces in deg
                        (default ~57.29 deg = 1 rad)

        -di val         Linear deflection used to tessellate the face interior.
        -min            minimum size parameter limiting size of triangle's
                        edges to prevent sinking into amplification in case
                        of distorted curves and surfaces

        -relative       notifies that relative deflection is used
                        (switched off by default)

        -int_vert_off   disables insertion of internal vertices into mesh
                        (enabled by default)
        -surf_def_off   disables control of deflection of mesh from real
                        surface (enabled by default)
        -parallel       enables parallel execution (switched off by default)
        -adjust_min     enables local adjustment of min size depending on edge size (switched off by default)

Thanks for any feedback or input.

Patrik Mueller's picture

You should ask the OCCT people about the calculation/definition of the default parameters.

andreasplesch_159166's picture

Well, I started to dig through the source but I could not find anything special, just default values, and I think relative to bounding box size.