WriteVrml wireframe representation

I would like to get wireframe representation with WriteVrml on the Doc level similar to writevrml on the shape level. draw help mentions an option for that but I am not sure if it is actually implemented. Is it supposed to work ?

I think incmesh necessarily tesselates all edges as well but perhaps there is something else which needs to be prepared ?

Draw[15]> pwd
C:/OpenCASCADE-7.4.0-vc14-64/opencascade-7.4.0/data/step
Draw[16]> ReadStep D screw.step
 File STEP to read : screw.step
Document saved with name D
Draw[17]> XGetFreeShapes D shape
shape
Draw[18]> incmesh shape 1
Incremental Mesh, multi-threading OFF
Meshing statuses: NoError
Draw[19]> help WriteVrml
WriteVrml       : Doc filename [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 0 by default]
Draw[20]> WriteVrml D screwWire.wrl 2 1

This does not include the wireframe lines in the output. In fact, it still includes the shaded surfaces.

For the screw example, one can just use writevrml:

Draw[27]> help writevrml
writevrml       : shape file [version VRML#1.0/VRML#2.0 (1/2): 2 by default] [representation shaded/wireframe/both (0/1/2): 1 by default]
Draw[28]> writevrml shape screwShapeWire.wrl 2 1

since there is just one simple shape. But for more complex assemblies it would be necessary to find and iterate over all subshapes and referred shapes. If WriteVrml does not apply how to best go through the document to extract all necessary shapes for writevrml ?

(This is just asking in terms of draw since it is convenient)

Patrik Mueller's picture

Hi Andreas,

you could try to use XGetOneShape to get a shape containing the free shapes.

https://www.opencascade.com/doc/occt-7.4.0/overview/html/occt_user_guide...

Greets,

Patrik

andreasplesch_159166's picture

Apologies for the delayed response, and many thanks for the suggestion.

I tried XGetOneShape with as1-oc-214.stp:

Draw[3]> ReadStep A as1-oc-214.stp
 File STEP to read : as1-oc-214.stp
Document saved with name A
Draw[5]> XGetOneShape oneshape A
oneshape
Draw[8]> writevrml  oneshape oneshape.wrl 2 1

This generates an incomplete wireframe, eg. only for the immediate/non-referenced subshapes (see attached image). More accurately, it appears that only the first of the references to a given subshape is included. The second and all subsequent references are apparently ignored. Or perhaps no instances are included, only solid parts.

How do I best find and cycle through all, including the referred subshapes (all nuts in the example) ?

Attachments: 
andreasplesch_159166's picture

Here is the structure of as1-oc-214.stp:

Draw[10]> Xdump A

ASSEMBLY COMPOUND 0:1:1:1 "as1"
        INSTANCE COMPOUND 0:1:1:1:1 (refers to 0:1:1:2) "rod-assembly_1"
        INSTANCE COMPOUND 0:1:1:1:2 (refers to 0:1:1:5) "l-bracket-assembly_1"
        INSTANCE SOLID 0:1:1:1:3 (refers to 0:1:1:9) "plate_1"
        INSTANCE COMPOUND 0:1:1:1:4 (refers to 0:1:1:5) "l-bracket-assembly_2"

ASSEMBLY COMPOUND 0:1:1:2 "rod-assembly"
        INSTANCE SOLID 0:1:1:2:1 (refers to 0:1:1:3) "nut_1"
        INSTANCE SOLID 0:1:1:2:2 (refers to 0:1:1:3) "nut_2"
        INSTANCE SOLID 0:1:1:2:3 (refers to 0:1:1:4) "rod_1"

PART SOLID 0:1:1:3 "nut"

PART SOLID 0:1:1:4 "rod"

ASSEMBLY COMPOUND 0:1:1:5 "l-bracket-assembly"
        INSTANCE COMPOUND 0:1:1:5:1 (refers to 0:1:1:6) "nut-bolt-assembly_1"
        INSTANCE COMPOUND 0:1:1:5:2 (refers to 0:1:1:6) "nut-bolt-assembly_2"
        INSTANCE COMPOUND 0:1:1:5:3 (refers to 0:1:1:6) "nut-bolt-assembly_3"
        INSTANCE SOLID 0:1:1:5:4 (refers to 0:1:1:8) "l-bracket_1"

ASSEMBLY COMPOUND 0:1:1:6 "nut-bolt-assembly"
        INSTANCE SOLID 0:1:1:6:1 (refers to 0:1:1:7) "bolt_1"
        INSTANCE SOLID 0:1:1:6:2 (refers to 0:1:1:3) "nut_3"

PART SOLID 0:1:1:7 "bolt"

PART SOLID 0:1:1:8 "l-bracket"

PART SOLID 0:1:1:9 "plate"


Free Shapes: 1
ASSEMBLY COMPOUND  0:1:1:1 "as1"

And attached the complete wireframe for comparison.

Attachments: 
Patrik Mueller's picture

Hi Andreas,

you could check the XDump source. If you use XDE. it could be easier to generate your own VRML output as you can usie instancing inside VRML to reduce the file size.

But this depends on your use case.

Greets,

Patrik

andreasplesch_159166's picture

Yes, this is essentially what I am doing, using pythonocc as a starting point. I believe occ WriteVrml actually does DEF/USE for instancing just not for the wireframe.