1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0023136: Increase visibility of DRAW samples

Tcl samples moved from src/DrawResources to samples/tcl.
Scripts VisualisationDemo.tcl and ModelingDemo.tcl fixed to work on Windows.
File wing.brep moved from src/DrawResources to data/occ, and DataExchangeDemo.tcl corrected.
OCAFDemo.tcl removed, as it has little sense and referred data files are lost
Added sample Tcl script creating a model defined on the 'Open CASCADE challenge' web page
This commit is contained in:
abv 2012-05-18 15:05:29 +04:00
parent d029c7ef22
commit 03392dd2e7
10 changed files with 141 additions and 416 deletions

0
src/DrawResources/wing.brep → data/occ/wing.brep Executable file → Normal file
View File

View File

@ -15,76 +15,70 @@
# purpose or non-infringement. Please see the License for the specific terms
# and conditions governing the rights and limitations under the License.
set stationname $tcl_platform(platform)
if { ${stationname} == "windows" } {
proc winfo { aTest aWindow } { return False }
}
# Command to log a message to both command-line and dialog window
proc sage { a} {
global stationname
if { ${stationname} != "windows" } {
if { ![winfo exists .h ] } {
toplevel .h -bg azure3
wm title .h "INFO DATAEXCHANGE TEST HARNESS"
wm geometry .h +320+20
}
if { [winfo exists .h.m ] } {
set astring [.h.m cget -text]
set newstring "${astring} \n $a"
.h.m configure -text $newstring
puts $a
} else {
message .h.m -justify left -bg azure2 -width 13c -relief ridge -bd 4\
-text $a
puts $a
}
pack .h.m
update
}
if { ![winfo exists .h ] } {
toplevel .h -bg azure3
wm title .h "INFO TEST HARNESS"
wm geometry .h +320+20
}
if { [winfo exists .h.m ] } {
set astring [.h.m cget -text]
set newstring "${astring} \n $a"
.h.m configure -text $newstring
puts $a
} else {
message .h.m -justify left -bg azure2 -width 13c -relief ridge -bd 4 -text $a
puts $a
}
pack .h.m
update
}
pload DATAEXCHANGE
smallview
if { [winfo exists .h ] } {
destroy .h
}
set ddir .
if { [info exists env(CASROOT)] } {
set thedir [file join $env(CASROOT) src DEResource]
cd ${thedir}
set ddir [file join $env(CASROOT) data occ]
}
set tdir .
if { [info exist env(TEMP)] } {
set tdir $env(TEMP)
}
datadir .
sage " First, we retrieve a BREP File "
sage " datadir ."
sage " restore wing.brep wing"
sage " restore $ddir/wing.brep wing"
sage " "
datadir .
restore wing.brep wing
restore $ddir/wing.brep wing
disp wing
fit
sage "Generate the IGES File of this BREP"
sage " brepiges wing /tmp/wing.igs"
sage " brepiges wing $tdir/wing.igs"
sage " "
brepiges wing /tmp/wing.igs
brepiges wing $tdir/wing.igs
wait 3
sage "we delete all data"
sage "we delete all DRAW data"
sage ""
dall
fit
wait 3
sage "Restore this IGES File we have created "
sage " igesbrep wing.igs new *"
sage " igesbrep $tdir/wing.igs new *"
sage ""
cd /tmp
igesbrep wing.igs new *
igesbrep $tdir/wing.igs new *
disp new
fit
if { [winfo exists .h ] } {
destroy .h
}
puts "End IGES Elementary Test "
sage " "
unlink /tmp/wing.igs
file delete $tdir/wing.igs

View File

@ -15,38 +15,27 @@
# purpose or non-infringement. Please see the License for the specific terms
# and conditions governing the rights and limitations under the License.
set stationname $tcl_platform(platform)
if { ${stationname} == "windows" } {
proc winfo { aTest aWindow } { return False }
}
# Command to log a message to both command-line and dialog window
proc sage { a} {
global stationname
if { ${stationname} != "windows" } {
if { ![winfo exists .h ] } {
toplevel .h -bg azure3
wm title .h "INFO TEST HARNESS"
wm geometry .h +320+20
}
if { [winfo exists .h.m ] } {
set astring [.h.m cget -text]
set newstring "${astring} \n $a"
.h.m configure -text $newstring
puts $a
} else {
message .h.m -justify left -bg azure2 -width 13c -relief ridge -bd 4\
-text $a
puts $a
}
pack .h.m
update
}
if { ![winfo exists .h ] } {
toplevel .h -bg azure3
wm title .h "INFO TEST HARNESS"
wm geometry .h +320+20
}
if { [winfo exists .h.m ] } {
set astring [.h.m cget -text]
set newstring "${astring} \n $a"
.h.m configure -text $newstring
puts $a
} else {
message .h.m -justify left -bg azure2 -width 13c -relief ridge -bd 4 -text $a
puts $a
}
pack .h.m
update
}
pload MODELING
smallview
if { [winfo exists .h ] } {
@ -130,4 +119,3 @@ donl r
hlr nohid r
hlr hlr r
sage "Demo completed"

4
samples/tcl/Readme.txt Normal file
View File

@ -0,0 +1,4 @@
This directory provides a set of demo scripts for using OCCT functionality from
within DRAW Test Harness. Call the scripts from DRAW prompt, e.g.:
Draw[]> source samples/tcl/VisualizationDemo.tcl

View File

@ -15,42 +15,32 @@
# purpose or non-infringement. Please see the License for the specific terms
# and conditions governing the rights and limitations under the License.
set stationname $tcl_platform(platform)
if { ${stationname} == "windows" } {
proc winfo { aTest aWindow } { return False }
}
# Command to log a message to both command-line and dialog window
proc sage { a} {
global stationname
if { ${stationname} != "windows" } {
if { ![winfo exists .h ] } {
toplevel .h -bg azure3
wm title .h "INFO AISViewer"
wm geometry .h +320+20
}
if { [winfo exists .h.m ] } {
set astring [.h.m cget -text]
set newstring "${astring} \n $a"
.h.m configure -text $newstring
puts $a
} else {
message .h.m -justify left -bg azure2 -width 13c -relief ridge -bd 4\
-text $a
puts $a
}
pack .h.m
update
}
if { ![winfo exists .h ] } {
toplevel .h -bg azure3
wm title .h "INFO TEST HARNESS"
wm geometry .h +320+20
}
if { [winfo exists .h.m ] } {
set astring [.h.m cget -text]
set newstring "${astring} \n $a"
.h.m configure -text $newstring
puts $a
} else {
message .h.m -justify left -bg azure2 -width 13c -relief ridge -bd 4 -text $a
puts $a
}
pack .h.m
update
}
if { [winfo exists .h ] } {
destroy .h
}
pload MODELING VISUALIZATION
sage " Creating the V3D Viewer"
sage " vinit"
sage " "

61
samples/tcl/challenge.tcl Normal file
View File

@ -0,0 +1,61 @@
# This script creates a model described at
# http://www.caddd.org/2010/04/opencascade-challenge.html
pload MODELING VISUALIZATION
# make base
box b0 0 0 0 12 7 6
explode b0 e
blend b01 b0 1 b0_8
blend b02 b01 1 b0_6
# make cut at bottom
box b1 3 -1 0 2 9 1.5
bcut b2 b02 b1
explode b2 e
blend b3 b2 1 b2_27
blend b4 b3 1 b2_30
# make central cut
box h1 3 -1 2.5 2 9 0.5
box h2 3 -1 3 2 9 2
plane p 4 -1 3 0 1 0
pcylinder c p 1 9
bcommon h3 h2 c
bcut b5 b4 h1
bcut b6 b5 h3
# make side cut
box b7 9 -1 1 2 9 4
explode b7 e
blend b71 b7 1 b7_6
blend b72 b71 1 b7_8
bcut b8 b6 b72
# make box for inner cylindrical cut
box bc1 -1 0 2 9 1 4
box bc2 2 -1 2 4 3 3
bcut bc3 bc1 bc2
explode bc3 e
blend bc4 bc3 1 bc3_20
blend bc5 bc4 1 bc3_23
blend bc6 bc5 1.99 bc3_21
blend bc7 bc6 1.99 bc3_22
# make inner cylindrical cut
explode bc7 f
revol r bc7_1 -1 0 6 1 0 0 100
bcut b9 b8 r
# make outer cylindrical cut
plane p2 -1 0 6 1 0 0
pcylinder c2 p2 6 15
bcommon res b9 c2
# show result
donly res
vinit
vdisplay res
vsetdispmode 1
vfit

View File

@ -1,93 +0,0 @@
# Copyright (c) 1999-2012 OPEN CASCADE SAS
#
# The content of this file is subject to the Open CASCADE Technology Public
# License Version 6.5 (the "License"). You may not use the content of this file
# except in compliance with the License. Please obtain a copy of the License
# at http://www.opencascade.org and read it completely before using this file.
#
# The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
# main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
#
# The Original Code and all software distributed under the License is
# distributed on an "AS IS" basis, without warranty of any kind, and the
# Initial Developer hereby disclaims all such warranties, including without
# limitation, any warranties of merchantability, fitness for a particular
# purpose or non-infringement. Please see the License for the specific terms
# and conditions governing the rights and limitations under the License.
# first , Opening Document write on Unix
puts "First , Opening Document write on Unix "
set Data [file join $env(CASROOT) src TCAF]
set DocName [file join ${Data} FileUnix.std]
if [ file exists ${DocName} ] {
Open ${DocName} Unix
DumpDocument Unix
} else {
puts " ${DocName} does not exist "
}
# first , Opening Document write on WindowsNT
puts ""
puts "now , Opening Document write on WindowsNT "
puts ""
set DocName [file join ${Data} FileWNT.std]
puts "trying to Open : ${DocName} "
if [ file exists ${DocName} ] {
catch { Open ${DocName} WNT } filesta
if { ${filesta} == "" } {
DumpDocument WNT
} else {
puts " Problem when trying to read ${DocName} ==> $filesta "
}
} else {
puts " ${DocName} does not exist "
}
puts "List the Document in the Session :"
ListDocuments
puts ""
puts "now , We create new Document "
puts ""
NewDocument New MDTV-Standard
UndoLimit New 5
NewCommand New
Label New 0:20
SetReal New 0:20 .12345
set newName /tmp/New.std
if { [info exists env(TEMP)] } {
set newName $env(TEMP)/New.std
}
SaveAs New ${newName}
puts " "
puts "List the Document in the Session :"
ListDocuments
puts " "
puts "We close it"
Close New
puts "List the Document in the Session :"
ListDocuments
puts "Verify if the new Document is saved : ${newName} "
if [file exists ${newName}] {
puts " ... exists : Yes "
puts " ... size : [file size ${newName}]"
puts " "
puts " We try to read it :"
Open ${newName} ReadDoc
DumpDocument ReadDoc
puts "List the Document in the Session :"
ListDocuments
} else {
puts " ... exists : No "
}
puts " "
puts " "
puts "end "

View File

@ -1,46 +0,0 @@
#!/bin/csh -f
#
# This is a simple script demo for Draw Module on Unix platform.
#
# The V.E. CASROOT must be setted to the directory where CasCade 3.0 has been
# downloaded.
#
setenv station `uname`
if ( ${station} == "IRIX64" ) setenv station IRIX
if (! ($?LD_LIBRARY_PATH) ) setenv LD_LIBRARY_PATH ""
setenv LD_LIBRARY_PATH "${CASROOT}/${station}/lib:${LD_LIBRARY_PATH}"
if ( ${station} == "AIX" ) then
setenv LIBPATH ${LD_LIBRARY_PATH}
endif
if ( ${station} == "HP-UX" ) then
setenv SHLIB_PATH ${LD_LIBRARY_PATH}
endif
if ( ${station} == "Linux" ) then
setenv LIBPATH "/usr/X11R6/lib:${LD_LIBRARY_PATH}"
endif
#
# This is for setting VE used by Draw
#
# POP : Since C31 Version ; this Varaible are not Mandatory
#setenv DRAWHOME $CASROOT/src/DrawResources
#setenv DRAWDEFAULT $DRAWHOME/DrawDefault
echo ""
echo " Running demo using :"
echo ""
echo "LD_LIBRARY_PATH : $LD_LIBRARY_PATH"
echo "CASROOT : $CASROOT"
if ($?DRAWHOME) then
echo "DRAWHOME : $DRAWHOME"
endif
if ($?DRAWDEFAULT) then
echo "DRAWDEFAULT : $DRAWDEFAULT"
endif
#
# Run the executable.
#
$CASROOT/${station}/bin/TTOPOLOGY
#
exit

View File

@ -1,40 +0,0 @@
echo ON
echo " Open CASCADE "
if not DEFINED CASROOT echo CASROOT is mandatory
if %PROCESSOR_ARCHITECTURE% EQU x86 Set STATION=Windows_NT
rem =========================================
rem
rem LD_LIBRARY_PATH definition
rem
rem =========================================
if NOT DEFINED OLDPATH set OLDPATH=%PATH%
set PATH=%PATH%;%CASROOT%\%STATION%\dll;
rem the Path where Tcl is installed
set PATH=D:/DevTools/Tcltk/bin/;%PATH%;
rem ======================================
Set DrawExe=%CASROOT%\%STATION%\bin\TTOPOLOGY.exe
# POP : Since C31 Version ; this Varaible are not Mandatory
rem if not DEFINED DRAWHOME Set DRAWHOME=%CASROOT%/src/DrawResources
rem if not DEFINED DRAWDEFAULT set DRAWDEFAULT=%DRAWHOME%\\DrawDefault
Set MMGT_CLEAR=1
%DRAWEXE%

View File

@ -1,133 +0,0 @@
# Copyright (c) 1999-2012 OPEN CASCADE SAS
#
# The content of this file is subject to the Open CASCADE Technology Public
# License Version 6.5 (the "License"). You may not use the content of this file
# except in compliance with the License. Please obtain a copy of the License
# at http://www.opencascade.org and read it completely before using this file.
#
# The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
# main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
#
# The Original Code and all software distributed under the License is
# distributed on an "AS IS" basis, without warranty of any kind, and the
# Initial Developer hereby disclaims all such warranties, including without
# limitation, any warranties of merchantability, fitness for a particular
# purpose or non-infringement. Please see the License for the specific terms
# and conditions governing the rights and limitations under the License.
set stationname $tcl_platform(platform)
if { ${stationname} == "windows" } {
proc winfo { aTest aWindow } { return False }
}
proc sage { a} {
global stationname
if { ${stationname} != "windows" } {
if { ![winfo exists .h ] } {
toplevel .h -bg azure3
wm title .h "INFO TEST HARNESS"
wm geometry .h +320+20
}
if { [winfo exists .h.m ] } {
set astring [.h.m cget -text]
set newstring "${astring} \n $a"
.h.m configure -text $newstring
puts $a
} else {
message .h.m -justify left -bg azure2 -width 13c -relief ridge -bd 4\
-text $a
puts $a
}
pack .h.m
update
}
}
smallview
if { [winfo exists .h ] } {
destroy .h
}
sage " Creating a box"
sage " box b -10 -10 -10 20 20 20"
sage " "
box b -10 -10 -10 20 20 20
fit
nexplode b f
erase b
sage " Draft of two lateral faces "
sage " depouille r b 0 0 -1 b_6 -15 10 -10 10 0 0 -1 "
sage " nexplode r f"
sage " depouille rr r 0 0 -1 r_1 -15 -10 -10 10 0 0 -1 "
sage " "
depouille r b 0 0 -1 b_6 -15 10 -10 10 0 0 -1
clear
nexplode r f
depouille rr r 0 0 -1 r_1 -15 -10 -10 10 0 0 -1
clear
nexplode rr e
sage " Fillet on four lateral edges, then on the top and bottom edges "
sage " nexplode rr e"
sage " blend result rr 3 rr_2 3 rr_3 3 rr_10 3 rr_11"
sage " nexplode result e"
sage " blend result result 2 result_11 3 result_12"
sage " "
blend result rr 3 rr_2 3 rr_3 3 rr_10 3 rr_11
erase rr
erase result
nexplode result e
blend result result 2 result_11 3 result_12
clear
nexplode result f
sage " Creating a profile on the top face "
sage " nexplode result f"
sage " profile p S result_16 F 10 4 D 1 0 C 2 90. Y 8 C 2 90. X -2 C 2 90. Y -8 C 2 90. X 2
"
sage " "
profile p S result_16 F 10 4 D 1 0 C 2 90. Y 8 C 2 90. X -2 C 2 90. Y -8 C 2 90. X 2
sage " Creating a prism"
sage " prism rr p 0 0 20"
sage " "
prism rr p 0 0 20
fit
sage " Fusion of this prism with the original part "
sage " fuse result rr result"
sage " "
fuse result rr result
donl result
nexplode result f
erase result
fit
sage " Opening the top face"
sage " offsetshape r result -1 0.0001 result_17"
sage " "
nexplode result f
offsetshape r result -1 0.0001 result_17
sage " Creating a cylinder and positionning it"
sage " pcylinder cyl 2 300"
sage " trotate cyl cyl 0 0 0 1 0 0 45"
sage " ttranslate cyl cyl 0 7.5 0"
sage " "
pcylinder cyl 2 30
trotate cyl cyl 0 0 0 1 0 0 45
ttranslate cyl cyl 0 7.5 0
sage " Display the Shape on Hidden Line Mode "
sage " hlr hid r"
sage ""
donl r
hlr hid r
sage " Display the Shape on HLR Mode "
sage " hlr nohid r"
sage " hlr hlr r"
sage ""
donl r
hlr nohid r
hlr hlr r
sage "Demo completed"