|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
$$
$$ PROGRAM: CUBE.grs
$$
$$ KEYWORDS:
$$ UTILITY
$$
$$ ABSTRACT:
$$ This routine automatically determines the size of a block
$$ containing the selected solid.
$$.
$$ The resulting block is aligned with faces parallel to the
$$ principle planes of the wcs.
$$
$$
$$
$$ SYSTEM TYPE: ALL
$$
$$ THEORY/VARIABLE USAGE:
$$
$$ VERSIONS SUPPORTED: ALL
$$
GRIPSW/DECLRV
$$
NUMBER/AIND,CUBSIZ,DOT1,MAT0(12),RANGE(6),RD(7),RESP,V1(3),V1A(3),V2(3),V3(3)
NUMBER/VZ(3),N
ENTITY/LINES(2),RSRF,SOLID1,S1
$$
$$ DEFINE THE INITIAL DISTANCE FROM THE WCS ORIGIN TO THE RULED SURFACE PLANES,
$$ SET UP ZERO VECTOR:
$$
DATA/CUBSIZ,500
DATA/VZ,0,0,0
$$
$$ ABORT IF NO ACTIVE PART:
$$
IFTHEN/&ACTPRT==1
MESSG/'ACTIVE PART REQUIRED'
JUMP/DONE:
ENDIF
$$
$$ GET SOLID OBJECT:
$$
BACK01:
IDENT/'SELECT SOLID OBJECT',SOLID1,RESP
JUMP/DONE:,DONE:,RESP
$$
$$ HIGHLIGHT ENTITY & PROMPT FOR CUBE SIZE:
$$
BACK02:
$$ PARAM/'MAXIMUM CUBE SIZE',$
$$ 'MAXIMUM SIZE',INT,CUBSIZ,RESP
$$ JUMP/BACK01:,DONE:,RESP
$$ IFTHEN/CUBSIZ<=0
$$ MESSG/'CUBE SIZE MUST BE POSITIVE NUMBER'
$$ JUMP/BACK02:
$$ ENDIF
$$
$$SOLID1=&ENAME(1,'TEST')
$$
$$ LOOP ONCE FOR EACH AXIS:
$$
DO/DOL90:,AIND,1,3
$$
$$ SET UP VECTOR POINTING PARALLEL TO AXIS BEING EVALUATED,
$$ CREATE A RULED SURFACE TO REPRESENT A SIDE OF THE CUBE:
$$
V3=VZ
V3(AIND)=1
IFTHEN/AIND==1
LINES(1)=LINE/0,-CUBSIZ/2,-CUBSIZ/2,0,CUBSIZ/2,-CUBSIZ/2
LINES(2)=LINE/0,-CUBSIZ/2,CUBSIZ/2,0,CUBSIZ/2,CUBSIZ/2
ELSEIF/AIND==2
LINES(1)=LINE/-CUBSIZ/2,0,-CUBSIZ/2,CUBSIZ/2,0,-CUBSIZ/2
LINES(2)=LINE/-CUBSIZ/2,0,CUBSIZ/2,CUBSIZ/2,0,CUBSIZ/2
ELSE
LINES(1)=LINE/-CUBSIZ/2,-CUBSIZ/2,0,CUBSIZ/2,-CUBSIZ/2,0
LINES(2)=LINE/-CUBSIZ/2,CUBSIZ/2,0,CUBSIZ/2,CUBSIZ/2,0
ENDIF
$$
$$ SHIFT THE LINES OUT TO STARTING POSITION:
$$ (1/2 THE CUBE SIZE ALONG THE SELECTED AXIS, NEGATIVE)
$$
MAT0=MATRIX/TRANSL,-SCALVF(CUBSIZ/2,V3)
TRANSF/MAT0,LINES(1..2),MOVE
$$
$$ CREATE A RULED SURFACE FOR DISTANCE CHECKING,
$$ GET THE MINIMUM DISTANCE BETWEEN THE TEST SURFACE & THE SOLID,
$$ ERROR ON ZERO DISTANCE VALUES:
$$
RSRF=RLDSRF/LINES(1),,LINES(2)
RD=RELDST/RSRF,SOLID1
IF/RD(7)==0,JUMP/CROSSB:
$$
$$ CALCULATE VECTOR BASED ON SHORTEST LINE BETWEEN THE TWO OBJECTS:
$$ (CHECK THE VECTOR AGAINST A REFERENCE VECTOR TO MAKE SURE
$$ THE SHAPE FITS INSIDE THE CUBE
$$
V1(1)=RD(4)-RD(1)
V1(2)=RD(5)-RD(2)
V1(3)=RD(6)-RD(3)
DOT1=DOTF(UNITF(V3),UNITF(V1))
IF/DOT1==-1,JUMP/OUTSID:
IF/ABSF(DOT1)<1,JUMP/BADDOT:
$$
$$ GET THE ORDINATE VALUE FROM THE END OF THE LINE THAT TOUCHES THE
$$ SOLID BODY:
$$
RANGE(AIND*2-1)=RD(AIND+3)
PRINT/'FACE '+ISTR(AIND*2-1)+' OF 6 EVALUATED'
$$
$$ NOW SHIFT THIS RULED SURFACE TO THE OTHER SIDE OF THE OBJECT AND
$$ REPEAT THE PROCESS:
$$
V2=SCALVF(CUBSIZ,UNITF(V3))
MAT0=MATRIX/TRANSL,V2
TRANSF/MAT0,LINES(1..2),MOVE
$$
RD=RELDST/RSRF,SOLID1
$$
IF/RD(7)==0,JUMP/CROSSB:
$$
V1A(1)=RD(4)-RD(1)
V1A(2)=RD(5)-RD(2)
V1A(3)=RD(6)-RD(3)
DOT1=DOTF(UNITF(V3),UNITF(V1A))
IF/DOT1==1,JUMP/OUTSID:
IF/ABSF(DOT1)<1,JUMP/BADDOT:
$$
RANGE(AIND*2)=RD(AIND+3)
PRINT/'FACE '+ISTR(AIND*2)+' OF 6 EVALUATED'
$$
$$ CLEAN UP:
$$
DELETE/RSRF
DELETE/LINES(1..2)
DOL90:
$$
$$ DISPLAY SIZE & CREATE BLOCK ENCLOSING THE SOLID:
$$
PRINT/USING,'BLOCK SIZE: #@@@.@@@@@ x #@@@.@@@@@ x #@@@.@@@@@',$
RANGE(2)-RANGE(1),RANGE(4)-RANGE(3),RANGE(6)-RANGE(5)
$$
S1=SOLBLK/ORIGIN,RANGE(1),RANGE(3),RANGE(5),$
SIZE,RANGE(2)-RANGE(1),RANGE(4)-RANGE(3),RANGE(6)-RANGE(5)
&COLOR(S1)=&GRAY
JUMP/DONE:
$$
CROSSB:
MESSG/'SOLID CROSSES CUBE BOUNDARY'
JUMP/REDO:
$$
OUTSID:
MESSG/'SOLID OUTSIDE CUBE BOUNDARY'
JUMP/REDO:
$$
BADDOT:
MESSG/'DISTANCE VECT NOT PARALLEL TO AXIS!'
JUMP/REDO:
$$
REDO:
DELETE/RSRF
DELETE/LINES(1..2)
MESSG/'INCREASE CUBE SIDE TO TRY AGAIN'
JUMP/BACK02:
DONE:
HALT |
|