<div>Hi,</div><div>I&#39;m looking for 3d engine to display a mesh from FEM softwares like ANSYS cdb file / Nastran bdf file. First of all i would like to display FEM model in 3D interactive GL window. I choose TCL and VTK and i create following code. In entry widget i define a quantity of nodes and elements in node and element file and then based on function invoked from &#39;Render&#39; button model is displayed. </div>
<div>Problem is in efficiency. Because each element is created as separate object (i would like to display models above 1000000 elements) VTK has big problem.</div><div>VTK has possibility to create something like poly vtkHexahedron object ?</div>
<div>in vertex is polyvertex and therefore i&#39;m wondering about poly hex object ?</div><div>Do you have any idea ?</div><div>Best regards,</div><div><br></div><div>####### CODE #######</div><div>package require vtk<br>
package require vtkinteraction<br>package require vtktesting<br>package require Tcl<br>package require Tk<br><br>global qty<br><br># Main code<br>vtkRenderer model_renderer<br>[model_renderer GetCullers] RemoveAllItems<br>
<br>vtkRenderWindow model_window<br>model_window AddRenderer model_renderer<br><br>model_renderer SetBackground .5 .5 .5<br><br>model_renderer ResetCamera<br>[model_renderer GetActiveCamera] Dolly 2.5<br>model_renderer ResetCameraClippingRange<br>
<br>vtkRenderWindowInteractor iaction<br>iaction SetRenderWindow model_window<br><br>wm title . &quot;CDB reader&quot;<br>label .l1 -text &quot;OpenGL module ver 0.1 - CDB Reader&quot;<br>frame .f1<br>entry .e1 -textvariable node_qty<br>
entry .e2 -textvariable elem_qty<br>button .b1 -text &quot;Open node&quot; -command &quot;open_model_node node_qty&quot;<br>button .b2 -text &quot;Open elem&quot; -command &quot;open_model_elem elem_qty&quot;<br>button .b3 -text &quot;Render&quot; -command &quot;render elem_qty&quot;<br>
button .b4 -text &quot;Close&quot; -command &quot;destroy .&quot;<br>set render_widget [vtkTkRenderWidget .f1.r -width 800 -height 600 -rw model_window]<br>iaction Initialize<br>::vtk::bind_tk_render_widget $render_widget<br>
<br>grid .l1 -row 1 -column 1 -columnspan 7<br>grid .f1 -row 2 -column 1 -columnspan 7<br>grid .e1 -row 3 -column 2<br>grid .e2 -row 3 -column 3<br>grid .b1 -row 3 -column 4<br>grid .b2 -row 3 -column 5<br>grid .b3 -row 3 -column 6<br>
grid .b4 -row 3 -column 7<br>grid .f1.r -row 1 -column 1<br><br>.b3 configure -state disabled<br><br>#$render_widget Render<br><br>proc generate {qty} {<br>        upvar 1 $qty qty_loc<br>        set fw [open node_file.txt w]<br>        for {set i 1} {$i &lt;= $qty_loc} {incr i} {<br>
                puts $fw &quot;$i [expr rand()] [expr rand()] [expr rand()]&quot;<br>        }<br>        close $fw<br>}<br><br><br>proc open_model_node {node_qty} {<br>        global ndata<br>        upvar 1 $node_qty node_qty_loc<br><br>        set file_select [tk_getOpenFile -initialdir [pwd]]<br>
        set fr_node [open $file_select r]<br><br>        for {set i 1} {$i &lt;= $node_qty_loc} {incr i} {<br>                set line [gets $fr_node]<br>                lappend ndata([lindex $line 0]) [lindex $line 1]<br>                lappend ndata([lindex $line 0]) [lindex $line 2]<br>
                lappend ndata([lindex $line 0]) [lindex $line 3]<br>        }<br>        close $fr_node<br>}<br><br>proc open_model_elem {elem_qty} {<br>        global edata<br>        upvar 1 $elem_qty elem_qty_loc<br><br>        set file_select [tk_getOpenFile -initialdir [pwd]]<br>
        set fr_elem [open $file_select r]<br><br>        for {set i 1} {$i &lt;= $elem_qty_loc} {incr i} {<br>                set line [gets $fr_elem]<br>                lappend edata($i) [lindex $line 13]<br>                lappend edata($i) [lindex $line 0]<br>                lappend edata($i) [lindex $line 1]<br>
                lappend edata($i) [lindex $line 2]<br>                lappend edata($i) [lindex $line 3]<br>                lappend edata($i) [lindex $line 4]<br>                lappend edata($i) [lindex $line 5]<br>                lappend edata($i) [lindex $line 6]<br>                lappend edata($i) [lindex $line 7]<br>
        }        <br><br><br>        .b3 configure -state normal<br>}<br><br>proc clear {} {<br>        model_renderer Clear<br>        model_window Clear<br>}<br><br>proc element {eid n1 n2 n3 n4 n5 n6 n7 n8} {<br>        global ndata<br><br>        vtkPoints hexahedronPoints_$eid<br>
          hexahedronPoints_$eid SetNumberOfPoints 8<br>          hexahedronPoints_$eid InsertPoint 0 [lindex $ndata($n1) 0] [lindex $ndata($n1) 1] [lindex $ndata($n1) 2]<br>          hexahedronPoints_$eid InsertPoint 1 [lindex $ndata($n2) 0] [lindex $ndata($n2) 1] [lindex $ndata($n2) 2]<br>
          hexahedronPoints_$eid InsertPoint 2 [lindex $ndata($n3) 0] [lindex $ndata($n3) 1] [lindex $ndata($n3) 2]<br>          hexahedronPoints_$eid InsertPoint 3 [lindex $ndata($n4) 0] [lindex $ndata($n4) 1] [lindex $ndata($n4) 2]<br>
          hexahedronPoints_$eid InsertPoint 4 [lindex $ndata($n5) 0] [lindex $ndata($n5) 1] [lindex $ndata($n5) 2]<br>          hexahedronPoints_$eid InsertPoint 5 [lindex $ndata($n6) 0] [lindex $ndata($n6) 1] [lindex $ndata($n6) 2]<br>
          hexahedronPoints_$eid InsertPoint 6 [lindex $ndata($n7) 0] [lindex $ndata($n7) 1] [lindex $ndata($n7) 2]<br>          hexahedronPoints_$eid InsertPoint 7 [lindex $ndata($n8) 0] [lindex $ndata($n8) 1] [lindex $ndata($n8) 2]<br>
        vtkHexahedron aHexahedron_$eid<br>          [aHexahedron_$eid GetPointIds] SetId 0 0<br>          [aHexahedron_$eid GetPointIds] SetId 1 1<br>          [aHexahedron_$eid GetPointIds] SetId 2 2<br>          [aHexahedron_$eid GetPointIds] SetId 3 3<br>
          [aHexahedron_$eid GetPointIds] SetId 4 4<br>          [aHexahedron_$eid GetPointIds] SetId 5 5<br>          [aHexahedron_$eid GetPointIds] SetId 6 6<br>          [aHexahedron_$eid GetPointIds] SetId 7 7<br>        vtkUnstructuredGrid aHexahedronGrid_$eid<br>
          aHexahedronGrid_$eid Allocate 1 1<br>          aHexahedronGrid_$eid InsertNextCell [aHexahedron_$eid GetCellType] [aHexahedron_$eid GetPointIds]<br>          aHexahedronGrid_$eid SetPoints hexahedronPoints_$eid<br>        vtkDataSetMapper aHexahedronMapper_$eid<br>
          aHexahedronMapper_$eid SetInput aHexahedronGrid_$eid<br>        vtkActor aHexahedronActor_$eid<br>          aHexahedronActor_$eid SetMapper aHexahedronMapper_$eid<br>          [aHexahedronActor_$eid GetProperty] SetColor 0.5 1 1<br>        <br>        model_renderer AddActor aHexahedronActor_$eid<br>
}<br><br>proc render {elem_qty} {<br>        global ndata<br>        global edata<br>        upvar 1 $elem_qty elem_qty_loc<br><br>        for {set i 1} {$i &lt;= $elem_qty_loc} {incr i} {<br>                element [lindex $edata($i) 0] [lindex $edata($i) 1] [lindex $edata($i) 2] [lindex $edata($i) 3] [lindex $edata($i) 4] [lindex $edata($i) 5] [lindex $edata($i) 6] [lindex $edata($i) 7] [lindex $edata($i) 8]<br>
        }<br><br>        model_renderer ResetCamera<br>}<br></div><div><br></div><div>####### CODE #######<br clear="all"></div><br>-- <br>Rafa³ Robak<br><a href="http://www.robak.info">www.robak.info</a><br>